@@ -137,6 +137,7 @@ typedef struct osm_perfmgr {
cl_disp_reg_handle_t pc_disp_h;
osm_perfmgr_state_t state;
osm_perfmgr_sweep_state_t sweep_state;
+ cl_spinlock_t lock;
uint16_t sweep_time_s;
perfmgr_db_t *db;
atomic32_t outstanding_queries; /* this along with sig_query */
@@ -433,11 +433,22 @@ static ib_api_status_t perfmgr_send_mad(osm_perfmgr_t *perfmgr,
cl_atomic_inc(&(perfmgr->outstanding_queries));
while (perfmgr->outstanding_queries >
(int32_t)perfmgr->max_outstanding_queries) {
+ cl_spinlock_acquire(&perfmgr->lock);
perfmgr->sweep_state = PERFMGR_SWEEP_SUSPENDED;
+ cl_spinlock_release(&perfmgr->lock);
cl_event_wait_on(&perfmgr->sig_query, EVENT_NO_TIMEOUT,
TRUE);
+
+ cl_spinlock_acquire(&perfmgr->lock);
+ if (perfmgr->sweep_state == PERFMGR_SWEEP_SUSPENDED) {
+ perfmgr->sweep_state = PERFMGR_SWEEP_ACTIVE;
+ cl_spinlock_release(&perfmgr->lock);
+ } else {
+ cl_spinlock_release(&perfmgr->lock);
+ OSM_LOG(perfmgr->log, OSM_LOG_ERROR, "ERR 54FF: "
+ "PM was NOT in Suspended state???\n");
+ }
}
- perfmgr->sweep_state = PERFMGR_SWEEP_ACTIVE;
}
return (status);
}
@@ -982,11 +993,15 @@ void osm_perfmgr_process(osm_perfmgr_t * pm)
if (pm->state != PERFMGR_STATE_ENABLED)
return;
+ cl_spinlock_acquire(&pm->lock);
if (pm->sweep_state == PERFMGR_SWEEP_ACTIVE ||
- pm->sweep_state == PERFMGR_SWEEP_SUSPENDED)
+ pm->sweep_state == PERFMGR_SWEEP_SUSPENDED) {
+ cl_spinlock_release(&pm->lock);
return;
+ }
pm->sweep_state = PERFMGR_SWEEP_ACTIVE;
+ cl_spinlock_release(&pm->lock);
if (pm->subn->sm_state == IB_SMINFO_STATE_STANDBY ||
pm->subn->sm_state == IB_SMINFO_STATE_NOTACTIVE)
@@ -1045,7 +1060,9 @@ void osm_perfmgr_process(osm_perfmgr_t * pm)
clear_mad_stats();
#endif
+ cl_spinlock_acquire(&pm->lock);
pm->sweep_state = PERFMGR_SWEEP_SLEEP;
+ cl_spinlock_release(&pm->lock);
}
/**********************************************************************
@@ -1777,6 +1794,8 @@ ib_api_status_t osm_perfmgr_init(osm_perfmgr_t * pm, osm_opensm_t * osm,
pm->trans_id = PERFMGR_INITIAL_TID_VALUE;
pm->state =
p_opt->perfmgr ? PERFMGR_STATE_ENABLED : PERFMGR_STATE_DISABLE;
+ pm->sweep_state = PERFMGR_SWEEP_SLEEP;
+ cl_spinlock_init(&pm->lock);
pm->sweep_time_s = p_opt->perfmgr_sweep_time_s;
pm->max_outstanding_queries = p_opt->perfmgr_max_outstanding_queries;
pm->ignore_cas = p_opt->perfmgr_ignore_cas;
Signed-off-by: Ira Weiny <weiny2@llnl.gov> --- include/opensm/osm_perfmgr.h | 1 + opensm/osm_perfmgr.c | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-)