From 07c08bcc788244c876f52207080d50105750e412 Mon Sep 17 00:00:00 2001 From: eitan Date: Mon, 31 Oct 2005 12:20:45 +0000 Subject: [PATCH] [OpenSM] - Fix race bug - looking at the qp0_mads_outstanding was done in a lock after decrementing it. The signaling was done according to the value viewed on the qp0_mads_outstanding, and not on the new value updated. As result - can receive a signal of NO_PENDING_TRANSACTIONS outside of its place. git-svn-id: svn://openib.tc.cornell.edu/gen1@134 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/ulp/opensm/user/opensm/osm_sm_mad_ctrl.c | 18 ++---------------- trunk/ulp/opensm/user/opensm/osm_vl15intf.c | 17 +---------------- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/trunk/ulp/opensm/user/opensm/osm_sm_mad_ctrl.c b/trunk/ulp/opensm/user/opensm/osm_sm_mad_ctrl.c index c01b808b..9ae897cf 100644 --- a/trunk/ulp/opensm/user/opensm/osm_sm_mad_ctrl.c +++ b/trunk/ulp/opensm/user/opensm/osm_sm_mad_ctrl.c @@ -102,10 +102,11 @@ __osm_sm_mad_ctrl_retire_trans_mad( "__osm_sm_mad_ctrl_retire_trans_mad: ERR 3120: " "Trying to dec qp0_mads_outstanding=0. " "Problem with transaction mgr!\n"); + outstanding = 0; } else { - cl_atomic_dec( &p_ctrl->p_stats->qp0_mads_outstanding ); + outstanding = cl_atomic_dec( &p_ctrl->p_stats->qp0_mads_outstanding ); } if( osm_log_is_active( p_ctrl->p_log, OSM_LOG_DEBUG ) ) @@ -116,21 +117,6 @@ __osm_sm_mad_ctrl_retire_trans_mad( p_ctrl->p_stats->qp0_mads_outstanding ); } - /* - Acquire the lock non-exclusively. - Other modules that send MADs grab this lock exclusively. - These modules that are in the process of sending MADs - will hold the lock until they finish posting all the MADs - they plan to send. While the other module is sending MADs - the outstanding count may temporarily go to zero. - Thus, by grabbing the lock ourselves, we get an accurate - view of whether or not the number of outstanding MADs is - really zero. - */ - CL_PLOCK_ACQUIRE( p_ctrl->p_lock ); - outstanding = p_ctrl->p_stats->qp0_mads_outstanding; - CL_PLOCK_RELEASE( p_ctrl->p_lock ); - if( outstanding == 0 ) { /* diff --git a/trunk/ulp/opensm/user/opensm/osm_vl15intf.c b/trunk/ulp/opensm/user/opensm/osm_vl15intf.c index ae382851..3eb14c54 100644 --- a/trunk/ulp/opensm/user/opensm/osm_vl15intf.c +++ b/trunk/ulp/opensm/user/opensm/osm_vl15intf.c @@ -178,28 +178,13 @@ __osm_vl15_poller( the cl_disp_post with OSM_SIGNAL_NO_PENDING_TRANSACTION (in order to wake up the state mgr). */ - cl_atomic_dec( &p_vl->p_stats->qp0_mads_outstanding ); + outstanding = cl_atomic_dec( &p_vl->p_stats->qp0_mads_outstanding ); osm_log( p_vl->p_log, OSM_LOG_DEBUG, "__osm_vl15_poller: " "%u QP0 MADs outstanding.\n", p_vl->p_stats->qp0_mads_outstanding ); - /* - Acquire the lock non-exclusively. - Other modules that send MADs grab this lock exclusively. - These modules that are in the process of sending MADs - will hold the lock until they finish posting all the MADs - they plan to send. While the other module is sending MADs - the outstanding count may temporarily go to zero. - Thus, by grabbing the lock ourselves, we get an accurate - view of whether or not the number of outstanding MADs is - really zero. - */ - CL_PLOCK_ACQUIRE( p_vl->p_lock ); - outstanding = p_vl->p_stats->qp0_mads_outstanding; - CL_PLOCK_RELEASE( p_vl->p_lock ); - if( outstanding == 0 ) { /* -- 2.41.0