From patchwork Wed Mar 7 18:02:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 10264637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2BAE86055B for ; Wed, 7 Mar 2018 18:02:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DAD8295EB for ; Wed, 7 Mar 2018 18:02:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1208D2960B; Wed, 7 Mar 2018 18:02:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 54B2D295EB for ; Wed, 7 Mar 2018 18:02:46 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 070322250EDD3; Wed, 7 Mar 2018 09:56:30 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: None (no SPF record) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=ross.zwisler@linux.intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8A69D21ED1C7D for ; Wed, 7 Mar 2018 09:56:28 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2018 10:02:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,436,1515484800"; d="scan'208";a="23731233" Received: from theros.lm.intel.com ([10.232.112.164]) by orsmga006.jf.intel.com with ESMTP; 07 Mar 2018 10:02:41 -0800 From: Ross Zwisler To: linux-nvdimm@lists.01.org, dan.j.williams@intel.com Subject: [PATCH 2/3] ndctl: add numa_node support for regions Date: Wed, 7 Mar 2018 11:02:36 -0700 Message-Id: <20180307180237.9289-2-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180307180237.9289-1-ross.zwisler@linux.intel.com> References: <20180307180237.9289-1-ross.zwisler@linux.intel.com> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Add an API for getting the numa node of a given region and add a numa_node field to the "ndctl list" region output. Signed-off-by: Ross Zwisler Reviewed-by: Dan Williams --- ndctl/lib/libndctl.c | 13 +++++++++++++ ndctl/lib/libndctl.sym | 1 + ndctl/libndctl.h | 1 + ndctl/list.c | 8 ++++++++ 4 files changed, 23 insertions(+) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index b7180e8..a165e69 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -132,6 +132,7 @@ struct ndctl_mapping { * @type_name: 'pmem' or 'block' * @generation: incremented everytime the region is disabled * @nstype: the resulting type of namespace this region produces + * @numa_node: numa node attribute * * A region may alias between pmem and block-window access methods. The * region driver is tasked with parsing the label (if their is one) and @@ -157,6 +158,7 @@ struct ndctl_region { char *region_buf; int buf_len; int generation; + int numa_node; struct list_head btts; struct list_head pfns; struct list_head daxs; @@ -1808,6 +1810,12 @@ static void *add_region(void *parent, int id, const char *region_base) goto err_read; region->module = to_module(ctx, buf); + sprintf(path, "%s/numa_node", region_base); + if (sysfs_read_attr(ctx, path, buf) == 0) + region->numa_node = strtol(buf, NULL, 0); + else + region->numa_node = -1; + if (region_set_type(region, path) < 0) goto err_read; @@ -2011,6 +2019,11 @@ NDCTL_EXPORT struct ndctl_dimm *ndctl_region_get_next_dimm(struct ndctl_region * return NULL; } +NDCTL_EXPORT int ndctl_region_get_numa_node(struct ndctl_region *region) +{ + return region->numa_node; +} + static int regions_badblocks_init(struct ndctl_region *region) { struct ndctl_ctx *ctx = ndctl_region_get_ctx(region); diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym index af9b7d5..175a482 100644 --- a/ndctl/lib/libndctl.sym +++ b/ndctl/lib/libndctl.sym @@ -344,4 +344,5 @@ global: ndctl_cmd_fw_fquery_get_fw_rev; ndctl_cmd_fw_xlat_firmware_status; ndctl_dimm_cmd_new_ack_shutdown_count; + ndctl_region_get_numa_node; } LIBNDCTL_13; diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h index 9db775b..017c9cc 100644 --- a/ndctl/libndctl.h +++ b/ndctl/libndctl.h @@ -340,6 +340,7 @@ struct ndctl_ctx *ndctl_region_get_ctx(struct ndctl_region *region); struct ndctl_dimm *ndctl_region_get_first_dimm(struct ndctl_region *region); struct ndctl_dimm *ndctl_region_get_next_dimm(struct ndctl_region *region, struct ndctl_dimm *dimm); +int ndctl_region_get_numa_node(struct ndctl_region *region); struct ndctl_region *ndctl_bus_get_region_by_physical_address(struct ndctl_bus *bus, unsigned long long address); #define ndctl_dimm_foreach_in_region(region, dimm) \ diff --git a/ndctl/list.c b/ndctl/list.c index af1c024..4cb66de 100644 --- a/ndctl/list.c +++ b/ndctl/list.c @@ -73,6 +73,7 @@ static struct json_object *region_to_json(struct ndctl_region *region, struct ndctl_interleave_set *iset; struct ndctl_mapping *mapping; unsigned int bb_count = 0; + int numa; if (!jregion) return NULL; @@ -107,6 +108,13 @@ static struct json_object *region_to_json(struct ndctl_region *region, goto err; json_object_object_add(jregion, "type", jobj); + numa = ndctl_region_get_numa_node(region); + if (numa >= 0) { + jobj = json_object_new_int(numa); + if (jobj) + json_object_object_add(jregion, "numa_node", jobj); + } + iset = ndctl_region_get_interleave_set(region); if (iset) { jobj = util_json_object_hex(