Commit 870fcc2c authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

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
parent dbee905d
...@@ -347,28 +347,6 @@ bool treenode::right_imbalanced(int threshold) const { ...@@ -347,28 +347,6 @@ bool treenode::right_imbalanced(int threshold) const {
return m_right_child.ptr != nullptr && right_depth > threshold + left_depth; 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 // effect: rebalances the subtree rooted at this node
// using AVL style O(1) rotations. unlocks this // using AVL style O(1) rotations. unlocks this
// node if it is not the new root of the subtree. // node if it is not the new root of the subtree.
...@@ -422,14 +400,14 @@ treenode *treenode::maybe_rebalance(void) { ...@@ -422,14 +400,14 @@ treenode *treenode::maybe_rebalance(void) {
// //
// one of them is the new root. we unlock everything except the new root. // one of them is the new root. we unlock everything except the new root.
if (child && child != 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(); child->mutex_unlock();
} }
if (this != new_root) { if (this != new_root) {
RESET_LOCKED_MUTEX_ORDERING_INFO(&m_mutex); TOKU_VALGRIND_RESET_MUTEX_ORDERING_INFO(&m_mutex);
mutex_unlock(); mutex_unlock();
} }
RESET_LOCKED_MUTEX_ORDERING_INFO(&new_root->m_mutex); TOKU_VALGRIND_RESET_MUTEX_ORDERING_INFO(&new_root->m_mutex);
return new_root; return new_root;
} }
......
...@@ -19,6 +19,28 @@ ...@@ -19,6 +19,28 @@
# define TOKU_DRD_IGNORE_VAR(v) DRD_IGNORE_VAR(v) # define TOKU_DRD_IGNORE_VAR(v) DRD_IGNORE_VAR(v)
# define TOKU_DRD_STOP_IGNORING_VAR(v) DRD_STOP_IGNORING_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 #else
# define NVALGRIND 1 # define NVALGRIND 1
...@@ -27,6 +49,7 @@ ...@@ -27,6 +49,7 @@
# define TOKU_VALGRIND_HG_DISABLE_CHECKING(p, size) ((void) 0) # define TOKU_VALGRIND_HG_DISABLE_CHECKING(p, size) ((void) 0)
# define TOKU_DRD_IGNORE_VAR(v) # define TOKU_DRD_IGNORE_VAR(v)
# define TOKU_DRD_STOP_IGNORING_VAR(v) # define TOKU_DRD_STOP_IGNORING_VAR(v)
# define TOKU_VALGRIND_RESET_MUTEX_ORDERING_INFO(mutex)
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment