From patchwork Thu Mar 22 18:40:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 10302145 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 7EE3F600F6 for ; Thu, 22 Mar 2018 18:40:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 712822842E for ; Thu, 22 Mar 2018 18:40:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65F9D28863; Thu, 22 Mar 2018 18:40:16 +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=-0.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, URIBL_BLACK autolearn=no 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 3AB8A2842E for ; Thu, 22 Mar 2018 18:40:14 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DF294225E4014; Thu, 22 Mar 2018 11:33:41 -0700 (PDT) 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.88; helo=mga01.intel.com; envelope-from=ross.zwisler@linux.intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 8106E225E400C for ; Thu, 22 Mar 2018 11:33:39 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Mar 2018 11:40:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,345,1517904000"; d="scan'208";a="30421931" Received: from theros.lm.intel.com ([10.232.112.164]) by fmsmga002.fm.intel.com with ESMTP; 22 Mar 2018 11:40:11 -0700 From: Ross Zwisler To: Dan Williams , linux-nvdimm@lists.01.org, "Jiang, Dave" Subject: [ndctl PATCH 2/2] ndctl: fail NUMA filtering when unavailable Date: Thu, 22 Mar 2018 12:40:07 -0600 Message-Id: <20180322184007.25667-2-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180322184007.25667-1-ross.zwisler@linux.intel.com> References: <20180322184007.25667-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 Instead of just failing to find namespaces when trying to filter by NUMA node when CONFIG_NUMA wasn't enabled in the kernel, instead fail loudly as numactl does: # numactl --cpunodebind=0 ls numactl: This system does not support NUMA policy Signed-off-by: Ross Zwisler --- This enabling requires numactl to create a pkg-config file, which it currently does not. This support is added by the following patch which I just sent out: https://patchwork.kernel.org/patch/10302135/ --- Makefile.am.in | 3 ++- autogen.sh | 3 ++- configure.ac | 12 ++++++++++++ ndctl.spec.in | 3 ++- ndctl/Makefile.am | 3 ++- util/filter.c | 11 +++++++++++ 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Makefile.am.in b/Makefile.am.in index 6c5229d..b927e17 100644 --- a/Makefile.am.in +++ b/Makefile.am.in @@ -15,7 +15,8 @@ AM_CPPFLAGS = \ $(KMOD_CFLAGS) \ $(UDEV_CFLAGS) \ $(UUID_CFLAGS) \ - $(JSON_CFLAGS) + $(JSON_CFLAGS) \ + $(NUMA_CFLAGS) AM_CFLAGS = ${my_CFLAGS} \ -fvisibility=hidden \ diff --git a/autogen.sh b/autogen.sh index a23cf53..46515b2 100755 --- a/autogen.sh +++ b/autogen.sh @@ -17,7 +17,8 @@ libdir() { args="--prefix=/usr \ --sysconfdir=/etc \ ---libdir=$(libdir /usr/lib)" +--libdir=$(libdir /usr/lib) \ +--with-numa" echo echo "----------------------------------------------------------------" diff --git a/configure.ac b/configure.ac index 3eaac32..af21cb6 100644 --- a/configure.ac +++ b/configure.ac @@ -94,6 +94,18 @@ PKG_CHECK_MODULES([UDEV], [libudev]) PKG_CHECK_MODULES([UUID], [uuid]) PKG_CHECK_MODULES([JSON], [json-c]) +AC_ARG_WITH([numa], + AS_HELP_STRING([--with-numa], + [Install with NUMA support. @<:@default=no@:>@]), + [], + [with_numa=no]) + +if test "x$with_numa" = "xyes"; then + PKG_CHECK_MODULES([NUMA], [numa]) + AC_DEFINE([WITH_NUMA], [1], [with NUMA support]) +fi +AM_CONDITIONAL([WITH_NUMA], [test "x$with_numa" = "xyes"]) + AC_ARG_WITH([bash-completion-dir], AS_HELP_STRING([--with-bash-completion-dir[=PATH]], [Install the bash auto-completion script in this directory. @<:@default=yes@:>@]), diff --git a/ndctl.spec.in b/ndctl.spec.in index e2c879c..3fcb4d8 100644 --- a/ndctl.spec.in +++ b/ndctl.spec.in @@ -20,6 +20,7 @@ BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(uuid) BuildRequires: pkgconfig(json-c) BuildRequires: pkgconfig(bash-completion) +BuildRequires: pkgconfig(numa) %description Utility library for managing the "libnvdimm" subsystem. The "libnvdimm" @@ -90,7 +91,7 @@ control API for these devices. %build echo %{version} > version ./autogen.sh -%configure --disable-static --disable-silent-rules +%configure --disable-static --disable-silent-rules --with-numa make %{?_smp_mflags} %install diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am index 213cabd..6b891f8 100644 --- a/ndctl/Makefile.am +++ b/ndctl/Makefile.am @@ -29,7 +29,8 @@ ndctl_LDADD =\ ../libutil.a \ $(UUID_LIBS) \ $(KMOD_LIBS) \ - $(JSON_LIBS) + $(JSON_LIBS) \ + $(NUMA_LIBS) if ENABLE_TEST ndctl_SOURCES += ../test/libndctl.c \ diff --git a/util/filter.c b/util/filter.c index 291d7ed..512f927 100644 --- a/util/filter.c +++ b/util/filter.c @@ -10,6 +10,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ +#include #include #include #include @@ -328,6 +329,16 @@ int util_filter_walk(struct ndctl_ctx *ctx, struct util_filter_ctx *fctx, } if (param->numa_node && strcmp(param->numa_node, "all") != 0) { +#ifdef WITH_NUMA + if (numa_available() < 0) { + error("This system does not support NUMA"); +#else + { + error("ndctl was not configured with NUMA support"); +#endif + return -EINVAL; + } + numa_node = strtol(param->numa_node, &end, 0); if (end == param->numa_node || end[0]) { error("invalid numa_node: '%s'\n", param->numa_node);