All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v5 04/12] numa: Drop NUMA API v1 support
Date: Wed, 18 Oct 2017 13:10:58 +0200	[thread overview]
Message-ID: <20171018111106.17215-5-pvorel@suse.cz> (raw)
In-Reply-To: <20171018111106.17215-1-pvorel@suse.cz>

NOTE: there still some code using v1 API
(thus flag -DNUMA_VERSION1_COMPATIBILITY is needed)

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 .../cpuset_syscall_test/cpuset_syscall_test.c      |  4 +--
 testcases/kernel/hotplug/memory_hotplug/commands.c | 12 +------
 testcases/kernel/lib/numa_helper.c                 | 15 ++-------
 testcases/kernel/mem/vma/vma02.c                   | 13 +++-----
 testcases/kernel/mem/vma/vma04.c                   | 12 ++-----
 .../syscalls/get_mempolicy/get_mempolicy01.c       | 38 ++--------------------
 6 files changed, 14 insertions(+), 80 deletions(-)

diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
index 371cbc751..c3ed1a502 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
@@ -51,8 +51,8 @@
 char *TCID = "cpuset_syscall_test";
 int TST_TOTAL = 1;
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
+#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H && HAVE_MPOL_CONSTANTS \
+	&& defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 
 #include "../cpuset_lib/cpuset.h"
 #include "../cpuset_lib/bitmask.h"
diff --git a/testcases/kernel/hotplug/memory_hotplug/commands.c b/testcases/kernel/hotplug/memory_hotplug/commands.c
index a9c618d82..7f271c341 100644
--- a/testcases/kernel/hotplug/memory_hotplug/commands.c
+++ b/testcases/kernel/hotplug/memory_hotplug/commands.c
@@ -29,7 +29,7 @@
  */
 
 #include "config.h"
-#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_LINUX_MEMPOLICY_H
+#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H
 #include <linux/mempolicy.h>
 #include <sys/types.h>
 #include <sys/time.h>
@@ -59,7 +59,6 @@
 #define MPOL_MF_WAIT    (1<<2)	/* Wait for existing pages to migrate */
 #endif
 
-#if defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION == 2
 static inline int nodemask_isset(nodemask_t * mask, int node)
 {
 	if ((unsigned)node >= NUMA_NUM_NODES)
@@ -75,7 +74,6 @@ static inline void nodemask_set(nodemask_t * mask, int node)
 	mask->n[node / (8 * sizeof(unsigned long))] |=
 	    (1UL << (node % (8 * sizeof(unsigned long))));
 }
-#endif
 
 static char *whitespace = " \t";
 
@@ -385,11 +383,7 @@ static int get_arg_nodeid_list(char *args, unsigned int *list)
 	int node, count = 0;
 
 	gcp = &glctx;
-#if defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION == 2
 	my_allowed_nodes = numa_get_membind_compat();
-#else
-	my_allowed_nodes = numa_get_membind();
-#endif
 	while (*args != '\0') {
 		if (!isdigit(*args)) {
 			fprintf(stderr, "%s:  expected digit for <node/list>\n",
@@ -447,11 +441,7 @@ static int get_current_nodeid_list(unsigned int *fromids)
 	int node;
 
 	gcp = &glctx;
-#if defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION == 2
 	my_allowed_nodes = numa_get_membind_compat();
-#else
-	my_allowed_nodes = numa_get_membind();
-#endif
 	for (node = 0; node <= max_node; ++node) {
 		if (nodemask_isset(&my_allowed_nodes, node))
 			*(fromids + nr_nodes++) = node;
diff --git a/testcases/kernel/lib/numa_helper.c b/testcases/kernel/lib/numa_helper.c
index dd080ee4e..8dc9d23a8 100644
--- a/testcases/kernel/lib/numa_helper.c
+++ b/testcases/kernel/lib/numa_helper.c
@@ -39,20 +39,9 @@
 unsigned long get_max_node(void)
 {
 	unsigned long max_node = 0;
-#if HAVE_NUMA_H
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-	max_node = NUMA_NUM_NODES;
-	/*
-	 * NUMA_NUM_NODES is not reliable, libnuma >=2 is looking
-	 * at /proc/self/status to figure out correct number.
-	 * If buffer is not large enough get_mempolicy will fail with EINVAL.
-	 */
-	if (max_node < 1024)
-		max_node = 1024;
-#else
+#if HAVE_NUMA_H && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 	max_node = numa_max_possible_node() + 1;
 #endif
-#endif /* HAVE_NUMA_H */
 	return max_node;
 }
 
@@ -209,7 +198,7 @@ int get_allowed_nodes_arr(int flag, int *num_nodes, int **nodes)
 		}
 	} while (0);
 	free(nodemask);
-#endif
+#endif /* HAVE_NUMA_H */
 	return ret;
 }
 
diff --git a/testcases/kernel/mem/vma/vma02.c b/testcases/kernel/mem/vma/vma02.c
index ae35b2a07..1492e1385 100644
--- a/testcases/kernel/mem/vma/vma02.c
+++ b/testcases/kernel/mem/vma/vma02.c
@@ -49,9 +49,9 @@
 char *TCID = "vma02";
 int TST_TOTAL = 1;
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
-#if defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION == 2
+#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_MPOL_CONSTANTS && \
+	defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+
 static unsigned long pagesize;
 static int opt_node;
 static char *opt_nodestr;
@@ -163,12 +163,7 @@ void usage(void)
 {
 	printf("  -n      Number of NUMA nodes\n");
 }
-#else /* libnuma v1 */
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "XXX: test is only supported on libnuma v2.");
-}
-#endif
+
 #else /* no NUMA */
 int main(void)
 {
diff --git a/testcases/kernel/mem/vma/vma04.c b/testcases/kernel/mem/vma/vma04.c
index 5e2cc91b7..905fbd3ad 100644
--- a/testcases/kernel/mem/vma/vma04.c
+++ b/testcases/kernel/mem/vma/vma04.c
@@ -53,9 +53,9 @@
 char *TCID = "vma04";
 int TST_TOTAL = 5;
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
-#if defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION == 2
+#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_MPOL_CONSTANTS && \
+	defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+
 static unsigned long pagesize;
 static int opt_node;
 static char *opt_nodestr;
@@ -325,12 +325,6 @@ static void usage(void)
 	printf("  -n      Number of NUMA nodes\n");
 }
 
-#else /* libnuma v1 */
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "XXX: test is only supported on libnuma v2.");
-}
-#endif
 #else /* no NUMA */
 int main(void)
 {
diff --git a/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c b/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c
index cca50288f..daa5f5dcc 100644
--- a/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c
+++ b/testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c
@@ -66,7 +66,8 @@
 char *TCID = "get_mempolicy01";
 int TST_TOTAL = 1;
 
-#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_MPOL_CONSTANTS
+#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_MPOL_CONSTANTS && \
+	defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 
 #define MEM_LENGTH	(4 * 1024 * 1024)
 
@@ -221,13 +222,8 @@ static int do_test(struct test_case *tc)
 {
 	int ret, err, result, cmp_ok;
 	int policy, flags;
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-	nodemask_t *nodemask, *getnodemask;
-	unsigned long maxnode = NUMA_NUM_NODES;
-#else
 	struct bitmask *nodemask = numa_allocate_nodemask();
 	struct bitmask *getnodemask = numa_allocate_nodemask();
-#endif
 	char *p = NULL;
 	unsigned long len = MEM_LENGTH;
 	int test_node = -1;
@@ -235,15 +231,7 @@ static int do_test(struct test_case *tc)
 	ret = get_allowed_nodes(NH_MEMS, 1, &test_node);
 	if (ret < 0)
 		tst_brkm(TBROK | TERRNO, cleanup, "get_allowed_nodes: %d", ret);
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-	nodemask = malloc(sizeof(nodemask_t));
-	nodemask_zero(nodemask);
-	nodemask_set(nodemask, test_node);
-	getnodemask = malloc(sizeof(nodemask_t));
-	nodemask_zero(getnodemask);
-#else
 	numa_bitmask_setbit(nodemask, test_node);
-#endif
 	switch (tc->ttype) {
 	case DEFAULT:
 		flags = 0;
@@ -252,13 +240,8 @@ static int do_test(struct test_case *tc)
 			TEST(ltp_syscall(__NR_set_mempolicy, tc->policy,
 				NULL, 0));
 		else
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-			TEST(ltp_syscall(__NR_set_mempolicy, tc->policy,
-				nodemask, maxnode));
-#else
 			TEST(ltp_syscall(__NR_set_mempolicy, tc->policy,
 				nodemask->maskp, nodemask->size));
-#endif
 		if (TEST_RETURN < 0) {
 			tst_resm(TBROK | TERRNO, "set_mempolicy");
 			return -1;
@@ -275,13 +258,8 @@ static int do_test(struct test_case *tc)
 			TEST(ltp_syscall(__NR_mbind, p, len, tc->policy,
 				NULL, 0, 0));
 		else
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-			TEST(ltp_syscall(__NR_mbind, p, len, tc->policy,
-				nodemask, maxnode, 0));
-#else
 			TEST(ltp_syscall(__NR_mbind, p, len, tc->policy,
 				nodemask->maskp, nodemask->size, 0));
-#endif
 		if (TEST_RETURN < 0) {
 			tst_resm(TBROK | TERRNO, "mbind");
 			return -1;
@@ -299,30 +277,18 @@ static int do_test(struct test_case *tc)
 	}
 	errno = 0;
 	cmp_ok = 1;
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-	TEST(ret = ltp_syscall(__NR_get_mempolicy, &policy, getnodemask,
-			   maxnode, p, flags));
-#else
 	TEST(ret = ltp_syscall(__NR_get_mempolicy, &policy, getnodemask->maskp,
 			   getnodemask->size, p, flags));
-#endif
 	err = TEST_ERRNO;
 	if (ret < 0)
 		goto TEST_END;
 
 	/* if policy == MPOL_DEFAULT, get_mempolicy doesn't return nodemask */
 	if (tc->policy == MPOL_DEFAULT)
-#if !defined(LIBNUMA_API_VERSION) || LIBNUMA_API_VERSION < 2
-		nodemask_zero(nodemask);
-	cmp_ok = (tc->policy == policy && (tc->from_node == NONE ||
-					   nodemask_equal(nodemask,
-							  getnodemask)));
-#else
 		numa_bitmask_clearall(nodemask);
 	cmp_ok = (tc->policy == policy && (tc->from_node == NONE ||
 					   numa_bitmask_equal(nodemask,
 							      getnodemask)));
-#endif
 TEST_END:
 	result = (err != tc->err) || !cmp_ok;
 	PRINT_RESULT_CMP(0, tc->ret, tc->err, ret, err, cmp_ok);
-- 
2.14.2


  parent reply	other threads:[~2017-10-18 11:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-18 11:10 [LTP] [PATCH v5 00/12] Fix 32-bit cross compilation Petr Vorel
2017-10-18 11:10 ` [LTP] [PATCH v5 01/12] m4: Fix libaio detection on 32-bit cross build Petr Vorel
2017-10-26 10:44   ` Cyril Hrubis
2017-10-18 11:10 ` [LTP] [PATCH v5 02/12] kernel/io: Build all directories even without libaio Petr Vorel
2017-10-26 10:44   ` Cyril Hrubis
2017-10-18 11:10 ` [LTP] [PATCH v5 03/12] make: Remove workarounds for build without libnuma Petr Vorel
2017-10-26 10:45   ` Cyril Hrubis
2017-10-30  8:57     ` Petr Vorel
2017-10-18 11:10 ` Petr Vorel [this message]
2017-10-18 11:10 ` [LTP] [PATCH v5 05/12] numa: Drop NUMA_CPPFLAGS Petr Vorel
2017-10-18 11:11 ` [LTP] [PATCH v5 06/12] hotplug/memory_hotplug: Update TODO Petr Vorel
2017-10-18 11:11 ` [LTP] [PATCH v5 07/12] hotplug/memory_hotplug: Remove unused header Petr Vorel
2017-10-26 10:53   ` Cyril Hrubis
2017-10-18 11:11 ` [LTP] [PATCH v5 08/12] hotplug/memory_hotplug: Exit with TCONF when NUMA headers not available Petr Vorel
2017-10-26 11:04   ` Cyril Hrubis
2017-10-28 16:47     ` Petr Vorel
2017-10-31 12:50       ` Cyril Hrubis
2017-10-18 11:11 ` [LTP] [PATCH v5 09/12] m4, kernel/lib: Detect libnuma presence in kernel libs Petr Vorel
2017-10-18 11:11 ` [LTP] [PATCH v5 10/12] numa: Check for API >= v2 with autoconf Petr Vorel
2017-10-18 11:11 ` [LTP] [PATCH v5 11/12] numa: Remove HAVE_NUMA_ALLOC_ONNODE definition Petr Vorel
2017-10-18 11:11 ` [LTP] [PATCH v5 12/12] numa: Remove HAVE_NUMA_MOVE_PAGES definition Petr Vorel
2017-11-02 15:52   ` Cyril Hrubis
2017-11-07 20:07     ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171018111106.17215-5-pvorel@suse.cz \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.