Skip to content

Commit

Permalink
Merge pull request #3548 from marcinslusarz/merge15
Browse files Browse the repository at this point in the history
Merge back changes from stable-1.5
  • Loading branch information
marcinslusarz committed Feb 4, 2019
2 parents c1d4525 + 10c2b23 commit 86c4760
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 17 deletions.
21 changes: 11 additions & 10 deletions doc/libpmem/pmem_is_pmem.3.md
Expand Up @@ -7,7 +7,7 @@ header: PMDK
date: pmem API version 1.1
...

[comment]: <> (Copyright 2017-2018, Intel Corporation)
[comment]: <> (Copyright 2017-2019, Intel Corporation)

[comment]: <> (Redistribution and use in source and binary forms, with or without)
[comment]: <> (modification, are permitted provided that the following conditions)
Expand Down Expand Up @@ -75,15 +75,16 @@ responsibility for flushing stores to persistence will find the
functions described in this section to be the most commonly used.

The **pmem_is_pmem**() function detects if the entire range
\[*addr*, *addr*+*len*) consists of persistent memory.
The implementation of **pmem_is_pmem**() requires a non-trivial amount
of work to determine if the given range is entirely persistent memory.
For this reason, it is better to call **pmem_is_pmem**() once when a
range of memory is first encountered, save the result, and use the saved
result to determine whether **pmem_persist**(3) or **msync**(2) is
appropriate for flushing changes to persistence. Calling
**pmem_is_pmem**() each time changes are flushed to persistence will
not perform well.
\[*addr*, *addr*+*len*) consists of persistent memory. Calling this function
with a memory range that originates from a source different than
**pmem_map_file()** is undefined. The implementation of **pmem_is_pmem**()
requires a non-trivial amount of work to determine if the given range is
entirely persistent memory. For this reason, it is better to call
**pmem_is_pmem**() once when a range of memory is first encountered,
save the result, and use the saved result to determine whether
**pmem_persist**(3) or **msync**(2) is appropriate for flushing changes to
persistence. Calling **pmem_is_pmem**() each time changes are flushed to
persistence will not perform well.

The _UW(pmem_map_file) function creates a new read/write mapping for a
file. If **PMEM_FILE_CREATE** is not specified in *flags*, the entire existing
Expand Down
1 change: 1 addition & 0 deletions src/libpmemobj/stats.c
Expand Up @@ -97,6 +97,7 @@ stats_new(PMEMobjpool *pop)
struct stats *s = Malloc(sizeof(*s));
s->enabled = 0;
s->persistent = &pop->stats_persistent;
VALGRIND_ADD_TO_GLOBAL_TX_IGNORE(s->persistent, sizeof(*s->persistent));
s->transient = Zalloc(sizeof(struct stats_transient));
if (s->transient == NULL)
goto error_transient_alloc;
Expand Down
3 changes: 2 additions & 1 deletion src/libpmemobj/tx.c
Expand Up @@ -511,7 +511,8 @@ add_to_tx_and_lock(struct tx *tx, enum pobj_tx_param type, void *lock)
break;
}

SLIST_INSERT_HEAD(&tx->tx_locks, txl, tx_lock);
if (retval == 0)
SLIST_INSERT_HEAD(&tx->tx_locks, txl, tx_lock);

return retval;
}
Expand Down
46 changes: 46 additions & 0 deletions src/test/obj_ctl_stats/TEST1
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
#
# Copyright 2019, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#


# standard unit test setup
. ../unittest/unittest.sh

require_test_type short
require_fs_type any
configure_valgrind pmemcheck force-enable

setup

expect_normal_exit ./obj_ctl_stats$EXESUFFIX $DIR/testfile1

pass
12 changes: 11 additions & 1 deletion src/test/obj_ctl_stats/obj_ctl_stats.c
@@ -1,5 +1,5 @@
/*
* Copyright 2017, Intel Corporation
* Copyright 2017-2019, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -82,6 +82,16 @@ main(int argc, char *argv[])
UT_ASSERTeq(ret, 0);
UT_ASSERTeq(allocated, 0);

TX_BEGIN(pop) {
oid = pmemobj_tx_alloc(1, 0);
} TX_ONABORT {
UT_ASSERT(0);
} TX_END
oid_size = pmemobj_alloc_usable_size(oid) + 16;
ret = pmemobj_ctl_get(pop, "stats.heap.curr_allocated", &allocated);
UT_ASSERTeq(ret, 0);
UT_ASSERTeq(allocated, oid_size);

pmemobj_close(pop);

DONE(NULL);
Expand Down
26 changes: 25 additions & 1 deletion src/test/obj_tx_lock/obj_tx_lock.c
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018, Intel Corporation
* Copyright 2016-2019, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -141,6 +141,29 @@ do_tx_add_locks_nested_all(struct transaction_data *data)
return NULL;
}

/*
* do_tx_add_taken_lock -- (internal) verify that failed tx_lock doesn't add
* the lock to transaction
*/
static void *
do_tx_add_taken_lock(struct transaction_data *data)
{
/* wrlocks on Windows don't detect self-deadlocks */
#ifdef _WIN32
(void) data;
#else
UT_ASSERTeq(pmemobj_rwlock_wrlock(Pop, &data->rwlocks[0]), 0);

TX_BEGIN(Pop) {
UT_ASSERTne(pmemobj_tx_lock(TX_PARAM_RWLOCK, &data->rwlocks[0]),
0);
} TX_END

UT_ASSERTne(pmemobj_rwlock_trywrlock(Pop, &data->rwlocks[0]), 0);
UT_ASSERTeq(pmemobj_rwlock_unlock(Pop, &data->rwlocks[0]), 0);
#endif
return NULL;
}

int
main(int argc, char *argv[])
Expand All @@ -162,6 +185,7 @@ main(int argc, char *argv[])
do_tx_add_locks(test_obj);
do_tx_add_locks_nested(test_obj);
do_tx_add_locks_nested_all(test_obj);
do_tx_add_taken_lock(test_obj);

pmemobj_close(Pop);

Expand Down
3 changes: 1 addition & 2 deletions utils/docker/build-local.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Copyright 2017-2018, Intel Corporation
# Copyright 2017-2019, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -115,7 +115,6 @@ docker run --privileged=true --name=$containerName -ti \
--env WORKDIR=$WORKDIR \
--env EXPERIMENTAL=$EXPERIMENTAL \
--env SCRIPTSDIR=$SCRIPTSDIR \
--env CLANG_FORMAT=clang-format-6.0 \
--env KEEP_TEST_CONFIG=$KEEP_TEST_CONFIG \
$ndctl_enable \
-v $HOST_WORKDIR:$WORKDIR \
Expand Down
1 change: 0 additions & 1 deletion utils/docker/build-travis.sh
Expand Up @@ -108,7 +108,6 @@ docker run --rm --privileged=true --name=$containerName -ti \
--env EXPERIMENTAL=$EXPERIMENTAL \
--env BUILD_PACKAGE_CHECK=$BUILD_PACKAGE_CHECK \
--env SCRIPTSDIR=$SCRIPTSDIR \
--env CLANG_FORMAT=clang-format-6.0 \
--env TRAVIS=$TRAVIS \
--env TRAVIS_COMMIT_RANGE=$TRAVIS_COMMIT_RANGE \
--env TRAVIS_COMMIT=$TRAVIS_COMMIT \
Expand Down
3 changes: 2 additions & 1 deletion utils/docker/images/Dockerfile.ubuntu-18.04
@@ -1,5 +1,5 @@
#
# Copyright 2016-2017, Intel Corporation
# Copyright 2016-2019, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -44,6 +44,7 @@ RUN apt-get update \
autoconf \
bc \
clang \
clang-format \
cmake \
debhelper \
devscripts \
Expand Down

0 comments on commit 86c4760

Please sign in to comment.