From patchwork Fri Mar 1 01:08:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 2200161 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2015ADF2A2 for ; Fri, 1 Mar 2013 01:08:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751886Ab3CABIx (ORCPT ); Thu, 28 Feb 2013 20:08:53 -0500 Received: from prdiron-1.llnl.gov ([128.15.143.171]:35143 "EHLO prdiron-1.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751078Ab3CABIx (ORCPT ); Thu, 28 Feb 2013 20:08:53 -0500 X-Attachments: Received: from eris.llnl.gov (HELO trebuchet.chaos) ([128.115.7.7]) by prdiron-1.llnl.gov with SMTP; 28 Feb 2013 17:08:52 -0800 Date: Thu, 28 Feb 2013 17:08:51 -0800 From: Ira Weiny To: "linux-rdma@vger.kernel.org" Cc: Hal Rosenstock Subject: [PATCH V2 06/07] opensm/perfmgr: fix access to shared sweep_state variable Message-Id: <20130228170851.8b4aaf79859f7205599f021f@llnl.gov> X-Mailer: Sylpheed 3.3.0 (GTK+ 2.18.9; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Rebased for new series Signed-off-by: Ira Weiny --- include/opensm/osm_perfmgr.h | 1 + opensm/osm_perfmgr.c | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/opensm/osm_perfmgr.h b/include/opensm/osm_perfmgr.h index fddd687..4141d41 100644 --- a/include/opensm/osm_perfmgr.h +++ b/include/opensm/osm_perfmgr.h @@ -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 */ diff --git a/opensm/osm_perfmgr.c b/opensm/osm_perfmgr.c index 8c6e1a3..9df28f9 100644 --- a/opensm/osm_perfmgr.c +++ b/opensm/osm_perfmgr.c @@ -434,11 +434,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); } @@ -986,11 +997,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) @@ -1051,7 +1066,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); } /********************************************************************** @@ -1816,6 +1833,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;