From b62f9779d201773142d7eef1e31af1d5eb0f93f8 Mon Sep 17 00:00:00 2001 From: khizmax Date: Sat, 3 Jun 2017 11:09:31 +0300 Subject: [PATCH] Fixed memory ordering --- cds/intrusive/details/ellen_bintree_base.h | 6 +++--- cds/intrusive/ellen_bintree_rcu.h | 18 +++++++++--------- cds/intrusive/impl/ellen_bintree.h | 18 +++++++++--------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cds/intrusive/details/ellen_bintree_base.h b/cds/intrusive/details/ellen_bintree_base.h index ed03e3b8..9814a6e1 100644 --- a/cds/intrusive/details/ellen_bintree_base.h +++ b/cds/intrusive/details/ellen_bintree_base.h @@ -132,13 +132,13 @@ namespace cds { namespace intrusive { /// Checks if the node is internal bool is_internal() const { - return (m_nFlags.load(atomics::memory_order_relaxed) & internal) != 0; + return (m_nFlags.load(atomics::memory_order_acquire) & internal) != 0; } /// Returns infinite key, 0 if the node is not infinite unsigned int infinite_key() const { - return m_nFlags.load(atomics::memory_order_relaxed) & key_infinite; + return m_nFlags.load(atomics::memory_order_acquire) & key_infinite; } /// Sets infinite key for the node (for internal use only!!!) @@ -159,7 +159,7 @@ namespace cds { namespace intrusive { assert( false ); break; } - m_nFlags.store( nFlags, atomics::memory_order_relaxed ); + m_nFlags.store( nFlags, atomics::memory_order_release ); } }; diff --git a/cds/intrusive/ellen_bintree_rcu.h b/cds/intrusive/ellen_bintree_rcu.h index 5d7ec110..97ffde6c 100644 --- a/cds/intrusive/ellen_bintree_rcu.h +++ b/cds/intrusive/ellen_bintree_rcu.h @@ -1404,7 +1404,7 @@ namespace cds { namespace intrusive { update_ptr cur( pOp, update_desc::IFlag ); pOp->iInfo.pParent->m_pUpdate.compare_exchange_strong( cur, pOp->iInfo.pParent->null_update_desc(), - memory_model::memory_order_acquire, atomics::memory_order_relaxed ); + memory_model::memory_order_release, atomics::memory_order_relaxed ); } bool check_delete_precondition( search_result& res ) @@ -1423,7 +1423,7 @@ namespace cds { namespace intrusive { update_ptr pUpdate( pOp->dInfo.pUpdateParent ); update_ptr pMark( pOp, update_desc::Mark ); if ( pOp->dInfo.pParent->m_pUpdate.compare_exchange_strong( pUpdate, pMark, - memory_model::memory_order_release, atomics::memory_order_relaxed )) + memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { help_marked( pOp ); retire_node( pOp->dInfo.pParent, rl ); @@ -1447,7 +1447,7 @@ namespace cds { namespace intrusive { // Undo grandparent dInfo update_ptr pDel( pOp, update_desc::DFlag ); if ( pOp->dInfo.pGrandParent->m_pUpdate.compare_exchange_strong( pDel, pOp->dInfo.pGrandParent->null_update_desc(), - memory_model::memory_order_acquire, atomics::memory_order_relaxed )) + memory_model::memory_order_release, atomics::memory_order_relaxed )) { retire_update_desc( pOp, rl, false ); } @@ -1473,7 +1473,7 @@ namespace cds { namespace intrusive { update_ptr upd( pOp, update_desc::DFlag ); pOp->dInfo.pGrandParent->m_pUpdate.compare_exchange_strong( upd, pOp->dInfo.pGrandParent->null_update_desc(), - memory_model::memory_order_acquire, atomics::memory_order_relaxed ); + memory_model::memory_order_release, atomics::memory_order_relaxed ); } template @@ -1660,7 +1660,7 @@ namespace cds { namespace intrusive { update_ptr updGP( res.updGrandParent.ptr()); if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ), - memory_model::memory_order_release, atomics::memory_order_acquire )) + memory_model::memory_order_acq_rel, atomics::memory_order_acquire )) { if ( help_delete( pOp, updRetire )) { // res.pLeaf is not deleted yet since RCU is blocked @@ -1738,7 +1738,7 @@ namespace cds { namespace intrusive { update_ptr updGP( res.updGrandParent.ptr()); if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ), - memory_model::memory_order_release, atomics::memory_order_acquire )) + memory_model::memory_order_acq_rel, atomics::memory_order_acquire )) { if ( help_delete( pOp, updRetire )) { pResult = node_traits::to_value_ptr( res.pLeaf ); @@ -1803,7 +1803,7 @@ namespace cds { namespace intrusive { update_ptr updGP( res.updGrandParent.ptr()); if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ), - memory_model::memory_order_release, atomics::memory_order_acquire )) + memory_model::memory_order_acq_rel, atomics::memory_order_acquire )) { if ( help_delete( pOp, updRetire )) { pResult = node_traits::to_value_ptr( res.pLeaf ); @@ -1867,7 +1867,7 @@ namespace cds { namespace intrusive { update_ptr updGP( res.updGrandParent.ptr()); if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ), - memory_model::memory_order_release, atomics::memory_order_acquire )) + memory_model::memory_order_acq_rel, atomics::memory_order_acquire )) { if ( help_delete( pOp, updRetire )) { pResult = node_traits::to_value_ptr( res.pLeaf ); @@ -1991,7 +1991,7 @@ namespace cds { namespace intrusive { update_ptr updCur( res.updParent.ptr()); if ( res.pParent->m_pUpdate.compare_exchange_strong( updCur, update_ptr( pOp, update_desc::IFlag ), - memory_model::memory_order_release, atomics::memory_order_acquire )) + memory_model::memory_order_acq_rel, atomics::memory_order_acquire )) { // do insert help_insert( pOp ); diff --git a/cds/intrusive/impl/ellen_bintree.h b/cds/intrusive/impl/ellen_bintree.h index 48154282..974854b4 100644 --- a/cds/intrusive/impl/ellen_bintree.h +++ b/cds/intrusive/impl/ellen_bintree.h @@ -1159,7 +1159,7 @@ namespace cds { namespace intrusive { // Unflag parent update_ptr cur( pOp, update_desc::IFlag ); CDS_VERIFY( pOp->iInfo.pParent->m_pUpdate.compare_exchange_strong( cur, pOp->iInfo.pParent->null_update_desc(), - memory_model::memory_order_acquire, atomics::memory_order_relaxed )); + memory_model::memory_order_release, atomics::memory_order_relaxed )); } bool check_delete_precondition( search_result& res ) const @@ -1179,7 +1179,7 @@ namespace cds { namespace intrusive { update_ptr pUpdate( pOp->dInfo.pUpdateParent ); update_ptr pMark( pOp, update_desc::Mark ); if ( pOp->dInfo.pParent->m_pUpdate.compare_exchange_strong( pUpdate, pMark, // * - memory_model::memory_order_release, atomics::memory_order_relaxed )) + memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { help_marked( pOp ); @@ -1198,7 +1198,7 @@ namespace cds { namespace intrusive { // Undo grandparent dInfo update_ptr pDel( pOp, update_desc::DFlag ); if ( pOp->dInfo.pGrandParent->m_pUpdate.compare_exchange_strong( pDel, pOp->dInfo.pGrandParent->null_update_desc(), - memory_model::memory_order_acquire, atomics::memory_order_relaxed )) + memory_model::memory_order_release, atomics::memory_order_relaxed )) { retire_update_desc( pOp ); } @@ -1234,7 +1234,7 @@ namespace cds { namespace intrusive { update_ptr upd( pOp, update_desc::DFlag ); CDS_VERIFY( pOp->dInfo.pGrandParent->m_pUpdate.compare_exchange_strong( upd, pOp->dInfo.pGrandParent->null_update_desc(), - memory_model::memory_order_acquire, atomics::memory_order_relaxed )); + memory_model::memory_order_release, atomics::memory_order_relaxed )); } bool try_insert( value_type& val, internal_node * pNewInternal, search_result& res ) @@ -1281,7 +1281,7 @@ namespace cds { namespace intrusive { update_ptr updCur( res.updParent.ptr()); if ( res.pParent->m_pUpdate.compare_exchange_strong( updCur, update_ptr( pOp, update_desc::IFlag ), - memory_model::memory_order_release, atomics::memory_order_relaxed )) { + memory_model::memory_order_acq_rel, atomics::memory_order_relaxed )) { // do insert help_insert( pOp ); retire_update_desc( pOp ); @@ -1327,7 +1327,7 @@ namespace cds { namespace intrusive { update_ptr updGP( res.updGrandParent.ptr()); if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ), - memory_model::memory_order_release, atomics::memory_order_relaxed )) { + memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { if ( help_delete( pOp )) { // res.pLeaf is not deleted yet since it is guarded f( *node_traits::to_value_ptr( res.pLeaf )); @@ -1378,7 +1378,7 @@ namespace cds { namespace intrusive { update_ptr updGP( res.updGrandParent.ptr()); if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ), - memory_model::memory_order_release, atomics::memory_order_relaxed )) { + memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { if ( help_delete( pOp )) break; pOp = nullptr; @@ -1445,7 +1445,7 @@ namespace cds { namespace intrusive { update_ptr updGP( res.updGrandParent.ptr()); if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ), - memory_model::memory_order_release, atomics::memory_order_relaxed )) + memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { if ( help_delete( pOp )) break; @@ -1494,7 +1494,7 @@ namespace cds { namespace intrusive { update_ptr updGP( res.updGrandParent.ptr()); if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ), - memory_model::memory_order_release, atomics::memory_order_relaxed )) + memory_model::memory_order_acquire, atomics::memory_order_relaxed )) { if ( help_delete( pOp )) break; -- 2.34.1