From 3556f22396745ac9777523fc303934a2e07172ce Mon Sep 17 00:00:00 2001 From: John Esmet Date: Wed, 17 Apr 2013 00:01:16 -0400 Subject: [PATCH] refs #5351 put this in the race tools header, make sure it does not break a release build git-svn-id: file:///svn/toku/tokudb@49925 c7de825b-a66e-492c-adef-691d508d4ae1 --- locktree/treenode.cc | 28 +++------------------------- toku_include/toku_race_tools.h | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/locktree/treenode.cc b/locktree/treenode.cc index 3245cf0472c..456cb86d6d2 100644 --- a/locktree/treenode.cc +++ b/locktree/treenode.cc @@ -347,28 +347,6 @@ bool treenode::right_imbalanced(int threshold) const { return m_right_child.ptr != nullptr && right_depth > threshold + left_depth; } -/* - * How to make helgrind happy about tree rotations and new mutex orderings: - * - * // Tell helgrind that we unlocked it so that the next call doesn't get a "destroyed a locked mutex" error. - * // Tell helgrind that we destroyed the mutex. - * VALGRIND_HG_MUTEX_UNLOCK_PRE(&locka); - * VALGRIND_HG_MUTEX_DESTROY_PRE(&locka); - * - * // And recreate it. It would be better to simply be able to say that the order on these two can now be reversed, because this code forgets all the ordering information for this mutex. - * // Then tell helgrind that we have locked it again. - * VALGRIND_HG_MUTEX_INIT_POST(&locka, 0); - * VALGRIND_HG_MUTEX_LOCK_POST(&locka); - * - * When the ordering of two locks changes, we don't need tell Helgrind about do both locks. Just one is good enough. - */ - -#define RESET_LOCKED_MUTEX_ORDERING_INFO(mutex) \ - VALGRIND_HG_MUTEX_UNLOCK_PRE(mutex); \ - VALGRIND_HG_MUTEX_DESTROY_PRE(mutex); \ - VALGRIND_HG_MUTEX_INIT_POST(mutex, 0); \ - VALGRIND_HG_MUTEX_LOCK_POST(mutex); - // effect: rebalances the subtree rooted at this node // using AVL style O(1) rotations. unlocks this // node if it is not the new root of the subtree. @@ -422,14 +400,14 @@ treenode *treenode::maybe_rebalance(void) { // // one of them is the new root. we unlock everything except the new root. if (child && child != new_root) { - RESET_LOCKED_MUTEX_ORDERING_INFO(&child->m_mutex); + TOKU_VALGRIND_RESET_MUTEX_ORDERING_INFO(&child->m_mutex); child->mutex_unlock(); } if (this != new_root) { - RESET_LOCKED_MUTEX_ORDERING_INFO(&m_mutex); + TOKU_VALGRIND_RESET_MUTEX_ORDERING_INFO(&m_mutex); mutex_unlock(); } - RESET_LOCKED_MUTEX_ORDERING_INFO(&new_root->m_mutex); + TOKU_VALGRIND_RESET_MUTEX_ORDERING_INFO(&new_root->m_mutex); return new_root; } diff --git a/toku_include/toku_race_tools.h b/toku_include/toku_race_tools.h index 232e0d9eff3..208996120e9 100644 --- a/toku_include/toku_race_tools.h +++ b/toku_include/toku_race_tools.h @@ -19,6 +19,28 @@ # define TOKU_DRD_IGNORE_VAR(v) DRD_IGNORE_VAR(v) # define TOKU_DRD_STOP_IGNORING_VAR(v) DRD_STOP_IGNORING_VAR(v) +/* + * How to make helgrind happy about tree rotations and new mutex orderings: + * + * // Tell helgrind that we unlocked it so that the next call doesn't get a "destroyed a locked mutex" error. + * // Tell helgrind that we destroyed the mutex. + * VALGRIND_HG_MUTEX_UNLOCK_PRE(&locka); + * VALGRIND_HG_MUTEX_DESTROY_PRE(&locka); + * + * // And recreate it. It would be better to simply be able to say that the order on these two can now be reversed, because this code forgets all the ordering information for this mutex. + * // Then tell helgrind that we have locked it again. + * VALGRIND_HG_MUTEX_INIT_POST(&locka, 0); + * VALGRIND_HG_MUTEX_LOCK_POST(&locka); + * + * When the ordering of two locks changes, we don't need tell Helgrind about do both locks. Just one is good enough. + */ + +# define TOKU_VALGRIND_RESET_MUTEX_ORDERING_INFO(mutex) \ + VALGRIND_HG_MUTEX_UNLOCK_PRE(mutex); \ + VALGRIND_HG_MUTEX_DESTROY_PRE(mutex); \ + VALGRIND_HG_MUTEX_INIT_POST(mutex, 0); \ + VALGRIND_HG_MUTEX_LOCK_POST(mutex); + #else # define NVALGRIND 1 @@ -27,6 +49,7 @@ # define TOKU_VALGRIND_HG_DISABLE_CHECKING(p, size) ((void) 0) # define TOKU_DRD_IGNORE_VAR(v) # define TOKU_DRD_STOP_IGNORING_VAR(v) +# define TOKU_VALGRIND_RESET_MUTEX_ORDERING_INFO(mutex) #endif