From patchwork Fri Jun 20 11:52:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wan, Kaike" X-Patchwork-Id: 4388571 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 51C229F390 for ; Fri, 20 Jun 2014 11:53:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65A70203DC for ; Fri, 20 Jun 2014 11:53:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63E0D203DA for ; Fri, 20 Jun 2014 11:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967160AbaFTLxt (ORCPT ); Fri, 20 Jun 2014 07:53:49 -0400 Received: from mga02.intel.com ([134.134.136.20]:52001 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967155AbaFTLxt (ORCPT ); Fri, 20 Jun 2014 07:53:49 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 20 Jun 2014 04:53:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,513,1400050800"; d="scan'208";a="560674359" Received: from phlsvsds.ph.intel.com ([10.228.195.38]) by orsmga002.jf.intel.com with ESMTP; 20 Jun 2014 04:53:26 -0700 Received: from phlsvsds.ph.intel.com (localhost.localdomain [127.0.0.1]) by phlsvsds.ph.intel.com (8.13.8/8.13.8) with ESMTP id s5KBrPXo032392; Fri, 20 Jun 2014 07:53:25 -0400 Received: (from kaikewan@localhost) by phlsvsds.ph.intel.com (8.13.8/8.13.8/Submit) id s5KBrPGd032389; Fri, 20 Jun 2014 07:53:25 -0400 X-Authentication-Warning: phlsvsds.ph.intel.com: kaikewan set sender to kaike.wan@intel.com using -f From: kaike.wan@intel.com To: sean.hefty@intel.com Cc: linux-rdma@vger.kernel.org, Kaike Wan Subject: [PATCH 2/2] ibacm/prov: export a function to increment performance counters Date: Fri, 20 Jun 2014 07:52:46 -0400 Message-Id: <1403265166-32346-2-git-send-email-kaike.wan@intel.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1403265166-32346-1-git-send-email-kaike.wan@intel.com> References: <1403265166-32346-1-git-send-email-kaike.wan@intel.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kaike Wan Instead of exposing the combined counters directly, this patch exports a function to providers to increment the combined counters. This offers better encapsulation and avoids exposing the private type atomic_t. Signed-off-by: Kaike Wan --- include/infiniband/acm_prov.h | 4 +--- prov/acmp/src/acmp.c | 14 +++++++------- src/acm.c | 8 +++++++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/infiniband/acm_prov.h b/include/infiniband/acm_prov.h index 9e299b9..890e6ba 100644 --- a/include/infiniband/acm_prov.h +++ b/include/infiniband/acm_prov.h @@ -80,9 +80,6 @@ struct acm_provider { void (*query_perf)(void *ep_context, uint64_t *values, uint8_t *cnt); }; -/* Variables exported from core */ -extern atomic_t counter[ACM_MAX_COUNTER]; - int provider_query(struct acm_provider **info, uint32_t *version); /* Functions exported from core */ @@ -117,5 +114,6 @@ extern void acm_free_sa_mad(struct acm_sa_mad *mad); extern int acm_send_sa_mad(struct acm_sa_mad *mad); extern char * acm_get_opts_file(void); +extern void acm_increment_counter(int type); #endif /* ACM_PROV_H */ diff --git a/prov/acmp/src/acmp.c b/prov/acmp/src/acmp.c index 5db62e2..2dd356d 100644 --- a/prov/acmp/src/acmp.c +++ b/prov/acmp/src/acmp.c @@ -798,7 +798,7 @@ static uint8_t acmp_resolve_path_sa(struct acmp_ep *ep, struct acmp_dest *dest, memcpy(mad->data, &dest->path, sizeof(dest->path)); mad->comp_mask = acm_path_comp_mask(&dest->path); - atomic_inc(&counter[ACM_CNTR_ROUTE_QUERY]); + acm_increment_counter(ACM_CNTR_ROUTE_QUERY); atomic_inc(&ep->counters[ACM_CNTR_ROUTE_QUERY]); dest->state = ACMP_QUERY_ROUTE; if (acm_send_sa_mad(sa_mad)) { @@ -1630,7 +1630,7 @@ acmp_query(void *addr_context, struct acm_msg *msg, uint64_t id) sizeof(struct ibv_path_record)); mad->comp_mask = acm_path_comp_mask(&msg->resolve_data[0].info.path); - atomic_inc(&counter[ACM_CNTR_ROUTE_QUERY]); + acm_increment_counter(ACM_CNTR_ROUTE_QUERY); atomic_inc(&ep->counters[ACM_CNTR_ROUTE_QUERY]); if (acm_send_sa_mad(sa_mad)) { acm_log(0, "Error - Failed to send sa mad\n"); @@ -1691,8 +1691,8 @@ acmp_send_resolve(struct acmp_ep *ep, struct acmp_dest *dest, rec->gid_cnt = (uint8_t) ep->mc_cnt; for (i = 0; i < ep->mc_cnt; i++) memcpy(&rec->gid[i], ep->mc_dest[i].address, 16); - - atomic_inc(&counter[ACM_CNTR_ADDR_QUERY]); + + acm_increment_counter(ACM_CNTR_ADDR_QUERY); atomic_inc(&ep->counters[ACM_CNTR_ADDR_QUERY]); acmp_post_send(&ep->resolve_queue, msg); return 0; @@ -1758,13 +1758,13 @@ test: if (acmp_dest_timeout(dest)) goto test; acm_log(2, "request satisfied from local cache\n"); - atomic_inc(&counter[ACM_CNTR_ROUTE_CACHE]); + acm_increment_counter(ACM_CNTR_ROUTE_CACHE); atomic_inc(&ep->counters[ACM_CNTR_ROUTE_CACHE]); status = ACM_STATUS_SUCCESS; break; case ACMP_ADDR_RESOLVED: acm_log(2, "have address, resolving route\n"); - atomic_inc(&counter[ACM_CNTR_ADDR_CACHE]); + acm_increment_counter(ACM_CNTR_ADDR_CACHE); atomic_inc(&ep->counters[ACM_CNTR_ADDR_CACHE]); status = acmp_resolve_path_sa(ep, dest, acmp_dest_sa_resp); if (status) { @@ -1833,7 +1833,7 @@ test: if (acmp_dest_timeout(dest)) goto test; acm_log(2, "request satisfied from local cache\n"); - atomic_inc(&counter[ACM_CNTR_ROUTE_CACHE]); + acm_increment_counter(ACM_CNTR_ROUTE_CACHE); atomic_inc(&ep->counters[ACM_CNTR_ROUTE_CACHE]); status = ACM_STATUS_SUCCESS; break; diff --git a/src/acm.c b/src/acm.c index 97b773e..8f147ef 100644 --- a/src/acm.c +++ b/src/acm.c @@ -163,7 +163,7 @@ static struct acmc_client client_array[FD_SETSIZE - 1]; static FILE *flog; static lock_t log_lock; PER_THREAD char log_data[ACM_MAX_ADDRESS]; -atomic_t counter[ACM_MAX_COUNTER]; +static atomic_t counter[ACM_MAX_COUNTER]; static struct acmc_device * acm_get_device_from_gid(union ibv_gid *sgid, uint8_t *port); @@ -261,6 +261,12 @@ char * acm_get_opts_file(void) return opts_file; } +void acm_increment_counter(int type) +{ + if (type >= 0 && type < ACM_MAX_COUNTER) + atomic_inc(&counter[type]); +} + static struct acmc_prov_context * acm_alloc_prov_context(struct acm_provider *prov) {