Skip to contentSkip to conversation

Fix 32-bit cross compilation

PATCH New Petr Vorel 2 participants 23 messages Oct 18, 2017 – Nov 7, 2017

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

v5 cover Fix 32-bit cross compilation

Changes v4->v5:
* Removed left placeholder in m4/ltp-eventfd.m4
* Removed duplicit libaio.h check in configure.ac.
* Added new commit: kernel/io: Build all directories even without libaio

NOTE: this is also available as a branch on github:
https://github.com/pevik/ltp/tree/autotools/fix-32bit-build.v5

Kind regards,
Petr

Petr Vorel (12):
m4: Fix libaio detection on 32-bit cross build kernel/io: Build all directories even without libaio
make: Remove workarounds for build without libnuma
numa: Drop NUMA API v1 support
numa: Drop NUMA_CPPFLAGS
hotplug/memory_hotplug: Update TODO hotplug/memory_hotplug: Remove unused header hotplug/memory_hotplug: Exit with TCONF when NUMA headers not
available
m4,kernel/lib: Detect libnuma presence in kernel libs
numa: Check for API >= v2 with autoconf
numa: Remove HAVE_NUMA_ALLOC_ONNODE definition
numa: Remove HAVE_NUMA_MOVE_PAGES definition

 configure.ac                                       |  1 -
 include/config.h.default                           |  3 --
 include/mk/config.mk.default                       |  1 -
 include/mk/config.mk.in                            |  1 -
 m4/ltp-eventfd.m4                                  | 28 +++++++--------
 m4/ltp-numa.m4                                     | 42 +++++++++-------------
 .../controllers/cpuset/cpuset_lib/libcpuset.c      |  1 +
 .../cpuset/cpuset_syscall_test/Makefile            |  1 -
 .../cpuset_syscall_test/cpuset_syscall_test.c      |  5 ++-
 testcases/kernel/hotplug/memory_hotplug/TODO       |  5 ---
 testcases/kernel/hotplug/memory_hotplug/commands.c | 17 +++------
 testcases/kernel/hotplug/memory_hotplug/memtoy.c   | 18 ++++++----
 testcases/kernel/hotplug/memory_hotplug/segment.c  |  7 +++-
 testcases/kernel/include/lib.mk                    |  2 +-
 testcases/kernel/include/numa_helper.h             |  2 +-
 testcases/kernel/io/Makefile                       |  2 --
 testcases/kernel/io/aio/aio01/aio01.c              | 23 ++++++------
 testcases/kernel/io/aio/aio02/aio_tio.c            |  3 +-
 testcases/kernel/io/aio/aio02/main.c               |  8 ++---
 testcases/kernel/io/ltp-aiodio/aio-stress.c        | 15 ++++++--
 testcases/kernel/io/ltp-aiodio/aiocp.c             |  7 ++--
 testcases/kernel/io/ltp-aiodio/aiodio_append.c     | 14 ++++++--
 testcases/kernel/io/ltp-aiodio/aiodio_sparse.c     | 18 +++++++---
 testcases/kernel/lib/Makefile                      |  3 +-
 testcases/kernel/lib/numa_helper.c                 | 25 ++++---------
 testcases/kernel/mem/cpuset/cpuset01.c             | 11 +++---
 testcases/kernel/mem/ksm/ksm02.c                   | 10 +++---
 testcases/kernel/mem/ksm/ksm04.c                   | 10 +++---
 testcases/kernel/mem/ksm/ksm06.c                   | 13 ++++---
 testcases/kernel/mem/lib/mem.c                     | 13 ++++---
 testcases/kernel/mem/oom/oom02.c                   | 11 +++---
 testcases/kernel/mem/oom/oom03.c                   | 10 ++++--
 testcases/kernel/mem/oom/oom04.c                   | 11 +++---
 testcases/kernel/mem/oom/oom05.c                   | 11 +++---
 testcases/kernel/mem/vma/vma02.c                   | 16 +++------
 testcases/kernel/mem/vma/vma04.c                   | 15 +++-----
 testcases/kernel/numa/Makefile                     |  2 +-
 testcases/kernel/syscalls/eventfd/eventfd01.c      | 16 ++++++---
 .../syscalls/get_mempolicy/get_mempolicy01.c       | 41 +++------------------
 testcases/kernel/syscalls/io_cancel/io_cancel01.c  | 12 ++++---
 .../kernel/syscalls/io_destroy/io_destroy01.c      | 12 ++++---
 .../kernel/syscalls/io_getevents/io_getevents01.c  | 13 +++----
 testcases/kernel/syscalls/io_setup/io_setup01.c    | 12 ++++---
 testcases/kernel/syscalls/io_submit/io_submit01.c  | 11 +++---
 testcases/kernel/syscalls/mbind/Makefile           |  9 -----
 testcases/kernel/syscalls/mbind/mbind01.c          | 11 +++---
 testcases/kernel/syscalls/migrate_pages/Makefile   |  3 --
 .../syscalls/migrate_pages/migrate_pages01.c       |  9 ++---
 .../syscalls/migrate_pages/migrate_pages02.c       | 10 +++---
 testcases/kernel/syscalls/move_pages/Makefile      |  5 ---
 .../kernel/syscalls/move_pages/move_pages01.c      |  4 +--
 .../kernel/syscalls/move_pages/move_pages02.c      |  4 +--
 .../kernel/syscalls/move_pages/move_pages03.c      |  4 +--
 .../kernel/syscalls/move_pages/move_pages04.c      |  4 +--
 .../kernel/syscalls/move_pages/move_pages05.c      |  4 +--
 .../kernel/syscalls/move_pages/move_pages06.c      |  4 +--
 .../kernel/syscalls/move_pages/move_pages07.c      |  4 +--
 .../kernel/syscalls/move_pages/move_pages08.c      |  4 +--
 .../kernel/syscalls/move_pages/move_pages09.c      |  4 +--
 .../kernel/syscalls/move_pages/move_pages10.c      |  4 +--
 .../kernel/syscalls/move_pages/move_pages11.c      |  4 +--
 .../kernel/syscalls/move_pages/move_pages12.c      |  4 +--
 .../syscalls/move_pages/move_pages_support.c       | 18 +++++-----
 63 files changed, 295 insertions(+), 320 deletions(-)
Signature · 1 line
2.14.2
author
#1 lore raw

PATCH v5 1/12 m4: Fix libaio detection on 32-bit cross build

This fixes link problems when libaio.h but but libaio not (e.g. on 32-bit cross build).

+ remove duplicite check for libaio.h in configure.ac (added in ef77253961).

---
 configure.ac                                       |  1 -
 m4/ltp-eventfd.m4                                  | 28 +++++++++++-----------
 testcases/kernel/io/aio/aio01/aio01.c              | 23 ++++++++----------
 testcases/kernel/io/aio/aio02/aio_tio.c            |  3 +--
 testcases/kernel/io/aio/aio02/main.c               |  8 +++----
 testcases/kernel/io/ltp-aiodio/aio-stress.c        | 15 ++++++++++--
 testcases/kernel/io/ltp-aiodio/aiocp.c             |  7 ++----
 testcases/kernel/io/ltp-aiodio/aiodio_append.c     | 14 +++++++++--
 testcases/kernel/io/ltp-aiodio/aiodio_sparse.c     | 18 ++++++++++----
 testcases/kernel/syscalls/eventfd/eventfd01.c      | 16 +++++++++----
 testcases/kernel/syscalls/io_cancel/io_cancel01.c  | 12 ++++++----
 .../kernel/syscalls/io_destroy/io_destroy01.c      | 12 ++++++----
 .../kernel/syscalls/io_getevents/io_getevents01.c  | 13 +++++-----
 testcases/kernel/syscalls/io_setup/io_setup01.c    | 12 ++++++----
 testcases/kernel/syscalls/io_submit/io_submit01.c  | 11 +++++----
 15 files changed, 115 insertions(+), 78 deletions(-)
configure.ac +0 -1
index 2356531cd..1e12889b7 100644
@@ -33,7 +33,6 @@ AC_PREFIX_DEFAULT(/opt/ltp)
 AC_CHECK_HEADERS([ \
     ifaddrs.h \
     keyutils.h \
-    libaio.h \
     linux/can.h \
     linux/genetlink.h \
     linux/keyctl.h \
m4/ltp-eventfd.m4 +14 -14
index 923b9bde3..d06ddba66 100644
@@ -16,28 +16,28 @@ dnl along with this program;  if not, write to the Free Software
 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 dnl
 dnl Author: Masatake YAMATO <[email protected]>
+dnl Copyright (c) 2017 Petr Vorel <[email protected]>
 dnl
 
 dnl
 dnl LTP_CHECK_SYSCALL_EVENTFD
 dnl ----------------------------
 dnl
-AC_DEFUN([LTP_CHECK_SYSCALL_EVENTFD],
-[dnl
-AH_TEMPLATE(HAVE_IO_SET_EVENTFD,
-[Define to 1 if you have the `io_set_eventfd' function.])
-AC_CHECK_HEADERS(libaio.h,[
-	AC_CHECK_LIB(aio,io_setup,[
-		AIO_LIBS="-laio"
+AC_DEFUN([LTP_CHECK_SYSCALL_EVENTFD], [
+	AC_CHECK_HEADERS(libaio.h, [have_libaio=yes])
+	AC_CHECK_LIB(aio, io_setup, [have_aio=yes])
+
+	if test "x$have_libaio" = "xyes" -a "x$have_aio" = "xyes"; then
+		AC_DEFINE(HAVE_LIBAIO, 1, [Define to 1 if you have libaio and it's headers installed.])
+		AC_SUBST(AIO_LIBS, "-laio")
+
 		AC_MSG_CHECKING([io_set_eventfd is defined in aio library or aio header])
 		AC_TRY_LINK([#include <stdio.h>
                              #include <libaio.h>
 		            ],
-                            [io_set_eventfd(NULL, 0); return 0;
-			    ],
-			    [AC_DEFINE(HAVE_IO_SET_EVENTFD)
-			     AC_MSG_RESULT(yes)],
-                            [AC_MSG_RESULT(no)])],
-		AIO_LIBS="")])
-AC_SUBST(AIO_LIBS)
+		            [io_set_eventfd(NULL, 0); return 0;],
+		            [AC_DEFINE(HAVE_IO_SET_EVENTFD, 1, [Define to 1 if you have `io_set_eventfd' function.])
+						AC_MSG_RESULT(yes)],
+		            [AC_MSG_RESULT(no)])
+	fi
 ])
testcases/kernel/io/aio/aio01/aio01.c +10 -13
index 2829b2485..ba23e226c 100644
@@ -47,26 +47,26 @@
 
 #define _XOPEN_SOURCE 600
 
-#include "test.h"
-#include "config.h"
-
-char *TCID = "aio01";
-int TST_TOTAL = 6;
-
-#ifdef HAVE_LIBAIO_H
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <time.h>
 #include <errno.h>
-#include <libaio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 
+#include "test.h"
+#include "config.h"
+
+char *TCID = "aio01";
+int TST_TOTAL = 6;
+
+#ifdef HAVE_LIBAIO
+#include <libaio.h>
+
 static void help(void);
 static void setup(void);
 static void cleanup(void);
@@ -413,14 +413,11 @@ static void cleanup(void)
 	close(fd);
 	io_queue_release(io_ctx);
 	tst_rmdir();
-
 }
 
 #else
-
 int main(void)
 {
-	tst_brkm(TCONF, NULL, "libaio missing");
+	tst_brkm(TCONF, NULL, "test requires libaio and it's development packages");
 }
-
 #endif
testcases/kernel/io/aio/aio02/aio_tio.c +1 -2
index 34fa9ed51..08fb04162 100644
@@ -37,7 +37,7 @@
 #include <string.h>
 #include <errno.h>
 
-#if HAVE_LIBAIO_H
+#ifdef HAVE_LIBAIO
 
 #define AIO_MAXIO 32
 #define AIO_BLKSIZE (64*1024)
@@ -237,5 +237,4 @@ int test_main(void)
 
 	return status;
 }
-
 #endif
testcases/kernel/io/aio/aio02/main.c +4 -4
index 24ec17181..7b157f31b 100644
@@ -6,16 +6,16 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include "test.h"
+
 #include "config.h"
+#include "test.h"
 
 #define TEST_NAME "aio_tio"
 
 char *TCID = "aio02/" TEST_NAME;
 int TST_TOTAL = 0;
 
-#if HAVE_LIBAIO_H
-
+#ifdef HAVE_LIBAIO
 #include <libaio.h>
 
 int test_main(void);
@@ -32,6 +32,6 @@ int main(void)
 #else
 int main(void)
 {
-	tst_brkm(TCONF, NULL, "libaio missing");
+	tst_brkm(TCONF, NULL, "test requires libaio and it's development packages");
 }
 #endif
testcases/kernel/io/ltp-aiodio/aio-stress.c +13 -2
index d6d7b0880..348f398db 100644
@@ -50,19 +50,23 @@
 #include <errno.h>
 #include <assert.h>
 #include <stdlib.h>
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/time.h>
-#include <libaio.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
 #include <sys/mman.h>
 #include <string.h>
 #include <pthread.h>
 
+#include "config.h"
+#include "tst_res_flags.h"
+
+#ifdef HAVE_LIBAIO
+#include <libaio.h>
+
 #define IO_FREE 0
 #define IO_PENDING 1
 #define RUN_FOREVER -1
@@ -1557,3 +1561,10 @@ int main(int ac, char **av)
 	}
 	return status;
 }
+#else
+int main(void)
+{
+	fprintf(stderr, "test requires libaio and it's development packages\n");
+	return TCONF;
+}
+#endif
testcases/kernel/io/ltp-aiodio/aiocp.c +2 -5
index 93984bf28..d315353d0 100644
@@ -38,8 +38,7 @@
 #include "config.h"
 #include "tst_res_flags.h"
 
-#if HAVE_LIBAIO_H
-
+#ifdef HAVE_LIBAIO
 #include <libaio.h>
 
 #define AIO_BLKSIZE	(64*1024)
@@ -600,11 +599,9 @@ int main(int argc, char *const *argv)
  */
 
 #else
-
 int main(void)
 {
-	fprintf(stderr, "System doesn't have libaio support.\n");
+	fprintf(stderr, "test requires libaio and it's development packages\n");
 	return TCONF;
 }
-
 #endif
testcases/kernel/io/ltp-aiodio/aiodio_append.c +12 -2
index 39a529fa3..5d97ed941 100644
@@ -32,10 +32,14 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#include <libaio.h>
-
+#include "config.h"
 #include "test.h"
 
+char *TCID = "aiodio_append";
+
+#ifdef HAVE_LIBAIO
+#include <libaio.h>
+
 #define NUM_CHILDREN 8
 
 #include "common_checkzero.h"
@@ -174,3 +178,9 @@ int main(int argc, char **argv)
 
 	return 0;
 }
+#else
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "test requires libaio and it's development packages");
+}
+#endif
testcases/kernel/io/ltp-aiodio/aiodio_sparse.c +14 -4
index d40e45b1b..4767f49d2 100644
@@ -35,11 +35,17 @@
 #include <limits.h>
 #include <getopt.h>
 
-#include <libaio.h>
 
+#include "config.h"
 #include "test.h"
 #include "safe_macros.h"
 
+char *TCID = "aiodio_sparse";
+int TST_TOTAL = 1;
+
+#ifdef HAVE_LIBAIO
+#include <libaio.h>
+
 #define NUM_CHILDREN 1000
 
 int debug;
@@ -49,9 +55,6 @@ static void setup(void);
 static void cleanup(void);
 static void usage(void);
 
-char *TCID = "aiodio_sparse";
-int TST_TOTAL = 1;
-
 #include "common_sparse.h"
 
 /*
@@ -325,3 +328,10 @@ static void cleanup(void)
 
 	tst_rmdir();
 }
+
+#else
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "test requires libaio and it's development packages");
+}
+#endif
testcases/kernel/syscalls/eventfd/eventfd01.c +11 -5
index 37cca7d53..e4f9c804a 100644
@@ -61,15 +61,14 @@
 #define CLEANUP cleanup
 #include "lapi/syscalls.h"
 
-#ifdef HAVE_LIBAIO_H
+TCID_DEFINE(eventfd01);
+int TST_TOTAL = 15;
+
+#ifdef HAVE_LIBAIO
 #include <libaio.h>
-#endif
 
 static void setup(void);
 
-TCID_DEFINE(eventfd01);
-int TST_TOTAL = 15;
-
 static int myeventfd(unsigned int initval, int flags)
 {
 	/* eventfd2 uses FLAGS but eventfd doesn't take FLAGS. */
@@ -727,3 +726,10 @@ static void cleanup(void)
 {
 	tst_rmdir();
 }
+
+#else
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "test requires libaio and it's development packages");
+}
+#endif
testcases/kernel/syscalls/io_cancel/io_cancel01.c +7 -5
index 8d7ca2607..ed6af050b 100644
@@ -21,6 +21,9 @@
 /* Porting from Crackerjack to LTP is done
    by Masatake YAMATO <[email protected]> */
 
+#include <errno.h>
+#include <string.h>
+
 #include "config.h"
 #include "test.h"
 
@@ -28,10 +31,8 @@ char *TCID = "io_cancel01";
 
 int TST_TOTAL = 1;
 
-#ifdef HAVE_LIBAIO_H
+#ifdef HAVE_LIBAIO
 #include <libaio.h>
-#include <errno.h>
-#include <string.h>
 
 static void cleanup(void)
 {
@@ -105,9 +106,10 @@ int main(int argc, char *argv[])
 	cleanup();
 	tst_exit();
 }
+
 #else
-int main(int argc, char *argv[])
+int main(void)
 {
-	tst_brkm(TCONF, NULL, "System doesn't have libaio support");
+	tst_brkm(TCONF, NULL, "test requires libaio and it's development packages");
 }
 #endif
testcases/kernel/syscalls/io_destroy/io_destroy01.c +7 -5
index 9de4987f4..88bef7ecf 100644
@@ -21,6 +21,9 @@
 /* Porting from Crackerjack to LTP is done
    by Masatake YAMATO <[email protected]> */
 
+#include <errno.h>
+#include <string.h>
+
 #include "config.h"
 #include "test.h"
 
@@ -28,10 +31,8 @@ char *TCID = "io_destroy01";
 
 int TST_TOTAL = 1;
 
-#ifdef HAVE_LIBAIO_H
+#ifdef HAVE_LIBAIO
 #include <libaio.h>
-#include <errno.h>
-#include <string.h>
 
 static void cleanup(void)
 {
@@ -99,9 +100,10 @@ int main(int argc, char *argv[])
 	cleanup();
 	tst_exit();
 }
+
 #else
-int main(int argc, char *argv[])
+int main(void)
 {
-	tst_brkm(TCONF, NULL, "System doesn't support execution of the test");
+	tst_brkm(TCONF, NULL, "test requires libaio and it's development packages");
 }
 #endif
testcases/kernel/syscalls/io_getevents/io_getevents01.c +7 -6
index 0f31ece32..b34f17907 100644
@@ -21,17 +21,17 @@
 /* Porting from Crackerjack to LTP is done
    by Masatake YAMATO <[email protected]> */
 
+#include <errno.h>
+#include <string.h>
+
 #include "config.h"
 #include "test.h"
 
 char *TCID = "io_getevents01";
-
 int TST_TOTAL = 1;
 
-#ifdef HAVE_LIBAIO_H
+#ifdef HAVE_LIBAIO
 #include <libaio.h>
-#include <errno.h>
-#include <string.h>
 
 static void cleanup(void)
 {
@@ -104,9 +104,10 @@ int main(int argc, char *argv[])
 	cleanup();
 	tst_exit();
 }
+
 #else
-int main(int argc, char *argv[])
+int main(void)
 {
-	tst_brkm(TCONF, NULL, "System doesn't support execution of the test");
+	tst_brkm(TCONF, NULL, "test requires libaio and it's development packages");
 }
 #endif
testcases/kernel/syscalls/io_setup/io_setup01.c +7 -5
index 829cef516..22b91bc17 100644
@@ -21,6 +21,9 @@
 /* Porting from Crackerjack to LTP is done
    by Masatake YAMATO <[email protected]> */
 
+#include <errno.h>
+#include <string.h>
+
 #include "config.h"
 #include "test.h"
 
@@ -28,10 +31,8 @@ char *TCID = "io_setup01";
 
 int TST_TOTAL = 4;
 
-#ifdef HAVE_LIBAIO_H
+#ifdef HAVE_LIBAIO
 #include <libaio.h>
-#include <errno.h>
-#include <string.h>
 
 static void cleanup(void)
 {
@@ -131,9 +132,10 @@ int main(int argc, char *argv[])
 
 	tst_exit();
 }
+
 #else
-int main(int argc, char *argv[])
+int main(void)
 {
-	tst_brkm(TCONF, NULL, "System doesn't support execution of the test");
+	tst_brkm(TCONF, NULL, "test requires libaio and it's development packages");
 }
 #endif
testcases/kernel/syscalls/io_submit/io_submit01.c +6 -5
index 9baf520b8..f4f9933f6 100644
@@ -20,14 +20,15 @@
 /* Porting from Crackerjack to LTP is done
    by Masatake YAMATO <[email protected]> */
 
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+
 #include "config.h"
 #include "tst_test.h"
 
-#ifdef HAVE_LIBAIO_H
+#ifdef HAVE_LIBAIO
 #include <libaio.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
 
 static io_context_t ctx;
 static io_context_t invalid_ctx;
@@ -139,5 +140,5 @@ static struct tst_test test = {
 };
 
 #else
-	TST_TEST_TCONF("libaio.h was mission upon compilation");
+	TST_TEST_TCONF("test requires libaio and it's development packages");
 #endif
Signature · 1 line
2.14.2
author
#3 lore raw

PATCH v5 2/12 kernel/io: Build all directories even without libaio

In reply to Petr Vorel

With fixed build without missing libaio or it's headers there is no need to filter out directories.

---
 testcases/kernel/io/Makefile | 2 --
 1 file changed, 2 deletions(-)
testcases/kernel/io/Makefile +0 -2
index 88ba99692..7db02882a 100644
@@ -24,6 +24,4 @@ top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-FILTER_OUT_DIRS		:= $(if $(AIO_LIBS),,aio ltp-aiodio)
-
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
Signature · 1 line
2.14.2
author
#5 lore raw

PATCH v5 3/12 make: Remove workarounds for build without libnuma

In reply to Petr Vorel
---
 testcases/kernel/syscalls/mbind/Makefile         | 9 ---------
 testcases/kernel/syscalls/migrate_pages/Makefile | 3 ---
 testcases/kernel/syscalls/move_pages/Makefile    | 5 -----
 3 files changed, 17 deletions(-)
testcases/kernel/syscalls/mbind/Makefile +0 -9
index 5132dffa4..1e2f5e4de 100644
@@ -20,15 +20,6 @@ top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-#
-# gcc complains about unused functions / variables when HAS_NUMA_H isn't
-# defined, so let's just skip the warning. It's nothing more than a few extra
-# variables and functions allocated on the stack, so meh... no harm, no foul.
-#
-ifeq ($(NUMA_LIBS),)
-CPPFLAGS		+= -Wno-unused
-endif
-
 CPPFLAGS		+= -I$(abs_srcdir)/../utils/
 
 include $(top_srcdir)/testcases/kernel/include/lib.mk
testcases/kernel/syscalls/migrate_pages/Makefile +0 -3
index 7168cd6e1..46a35d3e0 100644
@@ -23,9 +23,6 @@ include $(top_srcdir)/include/mk/testcases.mk
 MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*[0-9].c))
 $(MAKE_TARGETS): %: %.o migrate_pages_common.o
 
-ifeq ($(NUMA_LIBS),)
-CPPFLAGS		+= -Wno-unused
-endif
 CPPFLAGS		+= -I$(abs_srcdir)/../utils/
 
 include $(top_srcdir)/testcases/kernel/include/lib.mk
testcases/kernel/syscalls/move_pages/Makefile +0 -5
index d4620e10a..989277019 100644
@@ -26,11 +26,6 @@ INSTALL_TARGETS		:= move_pages.sh
 
 MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*[0-9].c))
 
-# linux_syscall_numbers.h is forcing move_pages_support.o to complain about
-# cleanup being undefined [and when defined] unused. Let's just skip this
-# warning...
-move_pages_support.o: CFLAGS += -Wno-unused-function
-
 $(MAKE_TARGETS): %: %.o move_pages_support.o
 
 LDLIBS			+= -lpthread -lrt
Signature · 1 line
2.14.2
author
#7 lore raw

PATCH v5 3/12 make: Remove workarounds for build without libnuma

Quoted 2 lines

Hi!
Looks good.

Thanks, I pushed these three commits. I'm sorry I've forgotten to add your name with Acked-by.

Kind regards,
Petr

author
#8 lore raw

PATCH v5 4/12 numa: Drop NUMA API v1 support

In reply to Petr Vorel

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

---
 .../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(-)
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c +2 -2
index 371cbc751..c3ed1a502 100644
@@ -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"
testcases/kernel/hotplug/memory_hotplug/commands.c +1 -11
index a9c618d82..7f271c341 100644
@@ -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;
testcases/kernel/lib/numa_helper.c +2 -13
index dd080ee4e..8dc9d23a8 100644
@@ -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;
 }
 
testcases/kernel/mem/vma/vma02.c +4 -9
index ae35b2a07..1492e1385 100644
@@ -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)
 {
testcases/kernel/mem/vma/vma04.c +3 -9
index 5e2cc91b7..905fbd3ad 100644
@@ -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)
 {
testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c +2 -36
index cca50288f..daa5f5dcc 100644
@@ -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);
Signature · 1 line
2.14.2
author
#9 lore raw

PATCH v5 5/12 numa: Drop NUMA_CPPFLAGS

In reply to Petr Vorel

and remove most -DNUMA_VERSION1_COMPATIBILITY flags. The place which requires it (e.g. using legacy code) is testcases/kernel/lib/commands.c.

---
 include/mk/config.mk.default                                     | 1 -
 include/mk/config.mk.in                                          | 1 -
 m4/ltp-numa.m4                                                   | 9 ++-------
 testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile | 1 -
 testcases/kernel/include/lib.mk                                  | 2 +-
 testcases/kernel/lib/Makefile                                    | 3 ++-
 testcases/kernel/numa/Makefile                                   | 2 +-
 7 files changed, 6 insertions(+), 13 deletions(-)
include/mk/config.mk.default +0 -1
index dff3479db..0934d9453 100644
@@ -39,7 +39,6 @@ YACC			:= bison -y
 #ACL_LIBS		:= -lacl
 #CRYPTO_LIBS		:= -lcrypto
 #LEXLIB			:= -lfl
-#NUMA_CPPFLAGS		:= -DNUMA_VERSION1_COMPATIBILITY
 #NUMA_LIBS		:= -lnuma
 #SELINUX_LIBS		:= -lselinux
 #TIRPC_CPPFLAGS		:= -I/usr/include/tirpc
include/mk/config.mk.in +0 -1
index dde2a9e55..8c4f9da82 100644
@@ -41,7 +41,6 @@ CAP_LIBS		:= @CAP_LIBS@
 ACL_LIBS		:= @ACL_LIBS@
 CRYPTO_LIBS		:= @CRYPTO_LIBS@
 LEXLIB			:= @LEXLIB@
-NUMA_CPPFLAGS		:= @NUMA_CPPFLAGS@
 NUMA_LIBS		:= @NUMA_LIBS@
 SELINUX_LIBS		:= @SELINUX_LIBS@
 TIRPC_CPPFLAGS		:= @TIRPC_CPPFLAGS@
m4/ltp-numa.m4 +2 -7
index 30650cd00..b9e9069b6 100644
@@ -22,8 +22,7 @@ dnl
 dnl LTP_CHECK_SYSCALL_NUMA
 dnl ----------------------------
 dnl
-AC_DEFUN([LTP_CHECK_SYSCALL_NUMA],
-[dnl
+AC_DEFUN([LTP_CHECK_SYSCALL_NUMA], [
 AC_CHECK_HEADERS([linux/mempolicy.h numa.h numaif.h],[
 	LTP_SYSCALL_NUMA_HEADERS=yes
 	AC_CHECK_LIB(numa,numa_alloc_onnode,[have_numa_alloc_onnode="yes"])
@@ -35,14 +34,10 @@ AC_CHECK_HEADERS([linux/mempolicy.h numa.h numaif.h],[
 		AC_DEFINE(HAVE_NUMA_MOVE_PAGES,1,[define to 1 if you have 'numa_move_pages' function])
 	fi
 ]
-	AC_CHECK_LIB(numa,numa_available,[
-NUMA_CPPFLAGS="-DNUMA_VERSION1_COMPATIBILITY"
-NUMA_LIBS="-lnuma"
-	])
+	AC_CHECK_LIB(numa,numa_available,[NUMA_LIBS="-lnuma"])
 dnl For testcases/kernel/controllers/cpuset, testcases/kernel/syscalls/get_mempolicy,
 dnl testcases/kernel/syscalls/mbind
 AC_CHECK_DECLS([MPOL_BIND, MPOL_DEFAULT, MPOL_F_ADDR, MPOL_F_MEMS_ALLOWED, MPOL_F_NODE, MPOL_INTERLEAVE, MPOL_PREFERRED],[have_mpol_constants="yes"],,[#include <numaif.h>])
-AC_SUBST(NUMA_CPPFLAGS)
 AC_SUBST(NUMA_LIBS)
 if test "x$have_mpol_constants" = "xyes"; then
 	AC_DEFINE(HAVE_MPOL_CONSTANTS,1,[define to 1 if you have all constants required to use mbind tests])
testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile +0 -1
index 6de1f8901..3f5e591f9 100644
@@ -26,7 +26,6 @@ include $(top_srcdir)/include/mk/testcases.mk
 include $(abs_srcdir)/../Makefile.inc
 
 LDLIBS                  += $(NUMA_LIBS)
-CPPFLAGS                += $(NUMA_CPPFLAGS)
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
 
testcases/kernel/include/lib.mk +1 -1
index 5c97ae2c9..40a09b77e 100644
@@ -22,7 +22,7 @@ LIBKERNTEST_SRCDIR	:= $(KERNEL_SRCDIR)/lib
 KERNEL_DIR		:= $(abs_top_builddir)/testcases/kernel
 LIBKERNTEST_DIR		:= $(KERNEL_DIR)/lib
 LIBKERNTEST		:= $(LIBKERNTEST_DIR)/libkerntest.a
-CPPFLAGS		+= $(NUMA_CPPFLAGS) -I$(KERNEL_SRCDIR)/include
+CPPFLAGS		+= -I$(KERNEL_SRCDIR)/include
 LDLIBS			+= -lkerntest -lltp $(NUMA_LIBS)
 LDFLAGS			+= -L$(LIBKERNTEST_DIR)
 
testcases/kernel/lib/Makefile +2 -1
index 8e19eed9e..fabf2f06e 100644
@@ -22,7 +22,8 @@ top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-CPPFLAGS		+= $(NUMA_CPPFLAGS) -I$(abs_srcdir)/../include \
+CPPFLAGS		+= -DNUMA_VERSION1_COMPATIBILITY \
+			   -I$(abs_srcdir)/../include \
 			   -I$(abs_builddir)/../include
 INTERNAL_LIB		:= libkerntest.a
 
testcases/kernel/numa/Makefile +1 -1
index f5e1881fd..48494e456 100644
@@ -20,7 +20,7 @@ top_srcdir		:= ../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-CPPFLAGS		+= -D_GNU_SOURCE -DNUMA_VERSION1_COMPATIBILITY
+CPPFLAGS		+= -D_GNU_SOURCE
 
 LDLIBS 			+= $(NUMA_LIBS)
 
Signature · 1 line
2.14.2
author
#10 lore raw

PATCH v5 6/12 hotplug/memory_hotplug: Update TODO

In reply to Petr Vorel

_NEED_MIGRATE_PAGES definition was removed in commit 5ed9ed059 ("Address the issue reported in the following email by installing all .c files.")

---
 testcases/kernel/hotplug/memory_hotplug/TODO | 5 -----
 1 file changed, 5 deletions(-)
testcases/kernel/hotplug/memory_hotplug/TODO +0 -5
index 35c18aa57..1460eb6a2 100644
@@ -1,12 +1,7 @@
 memtoy:
 
-if migrate_pages(2) system call ever becomes standard, will need to change
-Makefile not to build and link against migrate_pages.o and not to define
-_NEED_MIGRATE_PAGES.
-
 More documentation?
 
-
 Desired features?
 
 	+ verify contents after migration?
Signature · 1 line
2.14.2
author
#11 lore raw

PATCH v5 7/12 hotplug/memory_hotplug: Remove unused header

In reply to Petr Vorel
---
 testcases/kernel/hotplug/memory_hotplug/commands.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
testcases/kernel/hotplug/memory_hotplug/commands.c +1 -2
index 7f271c341..35056b5b6 100644
@@ -29,8 +29,7 @@
  */
 
 #include "config.h"
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H
-#include <linux/mempolicy.h>
+#if HAVE_NUMA_H && HAVE_NUMAIF_H
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/mman.h>
Signature · 1 line
2.14.2
#12 lore raw

PATCH v5 7/12 hotplug/memory_hotplug: Remove unused header

Hi!

testcases/kernel/hotplug/memory_hotplug/commands.c line 32

Quoted 4 lines

#include "config.h"

testcases/kernel/hotplug/memory_hotplug/commands.c +1 -2
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H
-#include <linux/mempolicy.h>
+#if HAVE_NUMA_H && HAVE_NUMAIF_H

I guess that we have the same definitions in the linux/mempolicy.h and numaif.h, right? I wonder how we even could include both of them without producing warnings for constant redefinitions, etc.

Anyway, can you please include a bit more explanation in the commit message? Something along the lines that the constant are present in both headers and that we only need to include one?

Otherwise it looks good to me.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#13 lore raw

PATCH v5 8/12 hotplug/memory_hotplug: Exit with TCONF when NUMA headers not available

In reply to Petr Vorel
---
 testcases/kernel/hotplug/memory_hotplug/memtoy.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/kernel/hotplug/memory_hotplug/memtoy.c +3 -1
index 1a96d914a..296788e30 100644
@@ -24,6 +24,8 @@
 
 #include <stdio.h>
 #include "config.h"
+#include "tst_res_flags.h"
+
 /* Shortcut because the test requires numa and mempolicy support. */
 #if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_LINUX_MEMPOLICY_H
 #include <sys/types.h>
@@ -495,6 +497,6 @@ int main(int argc, char *argv[])
 int main(void)
 {
 	printf("System doesn't have required numa support.\n");
-	return 0;
+	return TCONF;
 }
 #endif /* HAVE_NUMA_H && HAVE_NUMAIF_H */
Signature · 1 line
2.14.2
#14 lore raw

PATCH v5 8/12 hotplug/memory_hotplug: Exit with TCONF when NUMA headers not available

Hi!

Quoted 14 lines
testcases/kernel/hotplug/memory_hotplug/memtoy.c +2 -0
index 1a96d914a..296788e30 100644
@@ -24,6 +24,8 @@
 
 #include <stdio.h>
 #include "config.h"
+#include "tst_res_flags.h"
+
 /* Shortcut because the test requires numa and mempolicy support. */
 #if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_LINUX_MEMPOLICY_H
 #include <sys/types.h>

testcases/kernel/hotplug/memory_hotplug/memtoy.c int main(int argc, char *argv[]) · line 501

Quoted 6 lines
testcases/kernel/hotplug/memory_hotplug/memtoy.c +1 -1
@@ -495,6 +497,6 @@ int main(int argc, char *argv[])
 int main(void)
 {
 	printf("System doesn't have required numa support.\n");
-	return 0;
+	return TCONF;
 }

I was trying to figure out how is this binary executed and it seems like it is not. There even seems to be some scripts for it. So in the long term we should investigate if it's worth keeping or not and maybe ressurect it.

So all in all I do not see if there is a value in patching it if we do not run it at all and it produces strange failures on non-numa machine anyways...

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#15 lore raw

PATCH v5 8/12 hotplug/memory_hotplug: Exit with TCONF when NUMA headers not available

Hi Cyril,

Quoted 1 line
Quoted 1 line

--- a/testcases/kernel/hotplug/memory_hotplug/memtoy.c

<snip>

Quoted 8 lines

I was trying to figure out how is this binary executed and it seems like it is not. There even seems to be some scripts for it. So in the long term we should investigate if it's worth keeping or not and maybe ressurect it.

So all in all I do not see if there is a value in patching it if we do not run it at all and it produces strange failures on non-numa machine anyways...

How about deleting whole testcases/kernel/hotplug/memory_hotplug directory? The only binary from that directory is memtoy, which is indeed not used in any runtest file nor any script called by a runtest file.

It was taken from an upstream project from
http://devresources.linux-foundation.org/dev/hotplug/, which is now available in https://github.com/kosaki/memtoy.

I can send patch with RFC tag to ML before, if you want.

Kind regards,
Petr

#16 lore raw

PATCH v5 8/12 hotplug/memory_hotplug: Exit with TCONF when NUMA headers not available

Hi!

Quoted 7 lines

How about deleting whole testcases/kernel/hotplug/memory_hotplug directory? The only binary from that directory is memtoy, which is indeed not used in any runtest file nor any script called by a runtest file.

It was taken from an upstream project from
http://devresources.linux-foundation.org/dev/hotplug/, which is now available in https://github.com/kosaki/memtoy.

That one seems to be last updated 9 years ago, so it's dead as well. So the real question is if it's useful or not. We may as well raise the question on LTP ML and possibly on LMKL as well. Maybe there is someone using it and can explain if it's useful and how.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#17 lore raw

PATCH v5 9/12 m4, kernel/lib: Detect libnuma presence in kernel libs

In reply to Petr Vorel

This fixes link problems when NUMA headers are available but libnuma not (e.g. on 32-bit cross build).

numa_alloc_onnode() and numa_move_pages() do not depend on linux/mempolicy.h, thus remove the dependency.

Removed HAVE_MPOL_CONSTANTS definition and it's usage as with dropped NUMA API v1 are these constants always available.

Removed dependency on linux/mempolicy.h (#if HAVE_LINUX_MEMPOLICY_H check) from C files which do not need it.

Removed unused variable LTP_SYSCALL_NUMA_HEADERS (added in cb805c4aa, but never used).

---
 m4/ltp-numa.m4                                     | 34 ++++++++++------------
 .../controllers/cpuset/cpuset_lib/libcpuset.c      |  1 +
 .../cpuset_syscall_test/cpuset_syscall_test.c      |  6 ++--
 testcases/kernel/hotplug/memory_hotplug/commands.c |  6 +++-
 testcases/kernel/hotplug/memory_hotplug/memtoy.c   | 13 +++++----
 testcases/kernel/hotplug/memory_hotplug/segment.c  |  6 +++-
 testcases/kernel/include/numa_helper.h             |  2 +-
 testcases/kernel/lib/numa_helper.c                 | 14 ++++-----
 testcases/kernel/mem/cpuset/cpuset01.c             | 10 ++++---
 testcases/kernel/mem/ksm/ksm02.c                   | 11 ++++---
 testcases/kernel/mem/ksm/ksm04.c                   | 11 ++++---
 testcases/kernel/mem/ksm/ksm06.c                   | 14 +++++----
 testcases/kernel/mem/lib/mem.c                     | 13 ++++-----
 testcases/kernel/mem/oom/oom02.c                   | 11 ++++---
 testcases/kernel/mem/oom/oom03.c                   | 10 +++++--
 testcases/kernel/mem/oom/oom04.c                   | 11 ++++---
 testcases/kernel/mem/oom/oom05.c                   | 11 ++++---
 testcases/kernel/mem/vma/vma02.c                   |  7 ++---
 testcases/kernel/mem/vma/vma04.c                   |  7 ++---
 .../syscalls/get_mempolicy/get_mempolicy01.c       |  7 +++--
 testcases/kernel/syscalls/mbind/mbind01.c          | 11 ++++---
 .../syscalls/migrate_pages/migrate_pages01.c       | 10 ++++---
 .../syscalls/migrate_pages/migrate_pages02.c       | 11 ++++---
 .../syscalls/move_pages/move_pages_support.c       | 14 ++++-----
 24 files changed, 145 insertions(+), 106 deletions(-)
m4/ltp-numa.m4 +15 -19
index b9e9069b6..f21e38858 100644
@@ -16,6 +16,7 @@ dnl along with this program;  if not, write to the Free Software
 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 dnl
 dnl Author: Ngie Cooper <[email protected]>
+dnl Copyright (c) 2017 Petr Vorel <[email protected]>
 dnl
 
 dnl
@@ -23,23 +24,18 @@ dnl LTP_CHECK_SYSCALL_NUMA
 dnl ----------------------------
 dnl
 AC_DEFUN([LTP_CHECK_SYSCALL_NUMA], [
-AC_CHECK_HEADERS([linux/mempolicy.h numa.h numaif.h],[
-	LTP_SYSCALL_NUMA_HEADERS=yes
-	AC_CHECK_LIB(numa,numa_alloc_onnode,[have_numa_alloc_onnode="yes"])
-	if  test "x$have_numa_alloc_onnode" = "xyes"; then
-		AC_DEFINE(HAVE_NUMA_ALLOC_ONNODE,1,[define to 1 if you have 'numa_alloc_onnode' function])
-	fi
-	AC_CHECK_LIB(numa,numa_move_pages,[have_numa_move_pages="yes"])
-	if  test "x$have_numa_move_pages" = "xyes"; then
-		AC_DEFINE(HAVE_NUMA_MOVE_PAGES,1,[define to 1 if you have 'numa_move_pages' function])
+	AC_CHECK_LIB(numa, numa_available, [have_libnuma=yes])
+	AC_CHECK_HEADERS([numa.h numaif.h], [], [have_numa_headers=no])
+
+	if test "x$have_libnuma" = "xyes" -a "x$have_numa_headers" != "xno"; then
+		AC_SUBST(NUMA_LIBS, "-lnuma")
+		AC_DEFINE(HAVE_LIBNUMA, 1, [Define to 1 if you have libnuma and it's headers installed.])
+
+		AC_CHECK_LIB(numa, numa_alloc_onnode, [
+			AC_DEFINE(HAVE_NUMA_ALLOC_ONNODE, 1, [Define to 1 if you have `numa_alloc_onnode' function.])
+		])
+		AC_CHECK_LIB(numa, numa_move_pages, [
+			AC_DEFINE(HAVE_NUMA_MOVE_PAGES, 1, [Define to 1 if you have `numa_move_pages' function.])
+		])
 	fi
-]
-	AC_CHECK_LIB(numa,numa_available,[NUMA_LIBS="-lnuma"])
-dnl For testcases/kernel/controllers/cpuset, testcases/kernel/syscalls/get_mempolicy,
-dnl testcases/kernel/syscalls/mbind
-AC_CHECK_DECLS([MPOL_BIND, MPOL_DEFAULT, MPOL_F_ADDR, MPOL_F_MEMS_ALLOWED, MPOL_F_NODE, MPOL_INTERLEAVE, MPOL_PREFERRED],[have_mpol_constants="yes"],,[#include <numaif.h>])
-AC_SUBST(NUMA_LIBS)
-if test "x$have_mpol_constants" = "xyes"; then
-	AC_DEFINE(HAVE_MPOL_CONSTANTS,1,[define to 1 if you have all constants required to use mbind tests])
-fi
-)])
+])
testcases/kernel/controllers/cpuset/cpuset_lib/libcpuset.c +1 -0
index b38289679..9b67e37c9 100644
@@ -50,6 +50,7 @@
 #include "test.h"
 #include "lapi/syscalls.h"
 #include "config.h"
+
 #if HAVE_LINUX_MEMPOLICY_H
 #include <linux/mempolicy.h>
 
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c +3 -3
index c3ed1a502..6a6c7a803 100644
@@ -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 \
-	&& defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
+	&& defined(HAVE_LINUX_MEMPOLICY_H)
 
 #include "../cpuset_lib/cpuset.h"
 #include "../cpuset_lib/bitmask.h"
@@ -243,6 +243,6 @@ int main(int argc, char *argv[])
 #else
 int main(void)
 {
-	tst_brkm(TCONF, NULL, "System doesn't have required mempolicy support");
+	tst_brkm(TCONF, NULL, "test requires libnuma >= 2 and it's development packages");
 }
 #endif
testcases/kernel/hotplug/memory_hotplug/commands.c +5 -1
index 35056b5b6..54a79224d 100644
@@ -29,7 +29,11 @@
  */
 
 #include "config.h"
-#if HAVE_NUMA_H && HAVE_NUMAIF_H
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
+
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/mman.h>
testcases/kernel/hotplug/memory_hotplug/memtoy.c +8 -5
index 296788e30..40d08ef63 100644
@@ -23,11 +23,14 @@
  */
 
 #include <stdio.h>
+
 #include "config.h"
 #include "tst_res_flags.h"
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
 
-/* Shortcut because the test requires numa and mempolicy support. */
-#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_LINUX_MEMPOLICY_H
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/mman.h>
@@ -493,10 +496,10 @@ int main(int argc, char *argv[])
 	return 0;
 
 }
-#else /* ! (HAVE_NUMA_H && HAVE_NUMAIF_H) */
+#else
 int main(void)
 {
-	printf("System doesn't have required numa support.\n");
+	fprintf(stderr, "test requires libnuma >= 2 and it's development packages\n");
 	return TCONF;
 }
-#endif /* HAVE_NUMA_H && HAVE_NUMAIF_H */
+#endif
testcases/kernel/hotplug/memory_hotplug/segment.c +5 -1
index 62ccd81f9..a087eb2e1 100644
@@ -28,7 +28,11 @@
  */
 
 #include "config.h"
-#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_LINUX_MEMPOLICY_H
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
+
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <sys/mman.h>
testcases/kernel/include/numa_helper.h +1 -1
index b9d55f04d..39cf7aa23 100644
@@ -36,4 +36,4 @@ int get_allowed_nodes(int flag, int count, ...);
 void nh_dump_nodes(void);
 int is_numa(void (*cleanup_fn)(void), int flag, int min_nodes);
 
-#endif
+#endif /* NUMA_HELPER_H */
testcases/kernel/lib/numa_helper.c +7 -7
index 8dc9d23a8..095285bb2 100644
@@ -39,13 +39,13 @@
 unsigned long get_max_node(void)
 {
 	unsigned long max_node = 0;
-#if HAVE_NUMA_H && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 	max_node = numa_max_possible_node() + 1;
 #endif
 	return max_node;
 }
 
-#if HAVE_NUMA_H
+#ifdef HAVE_LIBNUMA
 static void get_nodemask_allnodes(nodemask_t * nodemask, unsigned long max_node)
 {
 	unsigned long nodemask_size = max_node / 8;
@@ -63,7 +63,7 @@ static void get_nodemask_allnodes(nodemask_t * nodemask, unsigned long max_node)
 
 static int filter_nodemask_mem(nodemask_t * nodemask, unsigned long max_node)
 {
-#if MPOL_F_MEMS_ALLOWED
+#ifdef MPOL_F_MEMS_ALLOWED
 	unsigned long nodemask_size = max_node / 8;
 	memset(nodemask, 0, nodemask_size);
 	/*
@@ -134,7 +134,7 @@ static void filter_nodemask_cpu(nodemask_t * nodemask, unsigned long max_node)
 	}
 	free(cpumask);
 }
-#endif /* HAVE_NUMA_H */
+#endif /* HAVE_LIBNUMA */
 
 /*
  * get_allowed_nodes_arr - get number and array of available nodes
@@ -152,7 +152,7 @@ static void filter_nodemask_cpu(nodemask_t * nodemask, unsigned long max_node)
 int get_allowed_nodes_arr(int flag, int *num_nodes, int **nodes)
 {
 	int ret = 0;
-#if HAVE_NUMA_H
+#ifdef HAVE_LIBNUMA
 	int i;
 	nodemask_t *nodemask = NULL;
 #endif
@@ -160,7 +160,7 @@ int get_allowed_nodes_arr(int flag, int *num_nodes, int **nodes)
 	if (nodes)
 		*nodes = NULL;
 
-#if HAVE_NUMA_H
+#ifdef HAVE_LIBNUMA
 	unsigned long max_node, nodemask_size;
 
 	if (numa_available() == -1)
@@ -198,7 +198,7 @@ int get_allowed_nodes_arr(int flag, int *num_nodes, int **nodes)
 		}
 	} while (0);
 	free(nodemask);
-#endif /* HAVE_NUMA_H */
+#endif /* HAVE_LIBNUMA */
 	return ret;
 }
 
testcases/kernel/mem/cpuset/cpuset01.c +6 -4
index 3d68cc07a..4efb01f23 100644
@@ -23,6 +23,9 @@
 #include "config.h"
 #include <stdio.h>
 #include <sys/wait.h>
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
 #if HAVE_NUMAIF_H
 #include <numaif.h>
 #endif
@@ -30,8 +33,7 @@
 #include "mem.h"
 #include "numa_helper.h"
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 volatile int end;
 static int *nodes;
 static int nnodes;
@@ -186,6 +188,6 @@ static struct tst_test test = {
 	.min_kver = "2.6.32",
 };
 
-#else /* no NUMA */
-	TST_TEST_TCONF("no NUMA development packages installed.");
+#else
+	TST_TEST_TCONF("test requires libnuma >= 2 and it's development packages");
 #endif
testcases/kernel/mem/ksm/ksm02.c +7 -4
index 6fe75d380..801412fd7 100644
@@ -50,6 +50,9 @@
 #include <sys/stat.h>
 #include <errno.h>
 #include <fcntl.h>
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
 #if HAVE_NUMAIF_H
 #include <numaif.h>
 #endif
@@ -59,8 +62,8 @@
 #include "mem.h"
 #include "ksm_common.h"
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
+	&& HAVE_LINUX_MEMPOLICY_H
 
 static void verify_ksm(void)
 {
@@ -121,6 +124,6 @@ static struct tst_test test = {
 	.min_kver = "2.6.32",
 };
 
-#else /* no NUMA */
-	TST_TEST_TCONF("no NUMA development packages installed.");
+#else
+	TST_TEST_TCONF("test requires libnuma >= 2 and it's development packages");
 #endif
testcases/kernel/mem/ksm/ksm04.c +7 -4
index 1c8bf20c2..bdce8b9fb 100644
@@ -50,6 +50,9 @@
 #include <sys/stat.h>
 #include <errno.h>
 #include <fcntl.h>
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
 #if HAVE_NUMAIF_H
 #include <numaif.h>
 #endif
@@ -59,8 +62,8 @@
 #include "mem.h"
 #include "ksm_common.h"
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
+	&& HAVE_LINUX_MEMPOLICY_H
 
 static void verify_ksm(void)
 {
@@ -125,6 +128,6 @@ static struct tst_test test = {
 	.min_kver = "2.6.32",
 };
 
-#else /* no NUMA */
-	TST_TEST_TCONF("no NUMA development packages installed.");
+#else
+	TST_TEST_TCONF("test requires libnuma >= 2 and it's development packages");
 #endif
testcases/kernel/mem/ksm/ksm06.c +9 -5
index 334a04834..4763460cf 100644
@@ -28,6 +28,9 @@
 #include <limits.h>
 #include <errno.h>
 #include <fcntl.h>
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
 #if HAVE_NUMAIF_H
 #include <numaif.h>
 #endif
@@ -35,11 +38,12 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <limits.h>
-#include "numa_helper.h"
+
 #include "mem.h"
+#include "numa_helper.h"
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
+	&& HAVE_LINUX_MEMPOLICY_H
 
 static int run = -1;
 static int sleep_millisecs = -1;
@@ -105,6 +109,6 @@ static struct tst_test test = {
 	.test_all = test_ksm,
 };
 
-#else /* no NUMA */
-	TST_TEST_TCONF("no NUMA development packages installed.");
+#else
+	TST_TEST_TCONF("test requires libnuma >= 2 and it's development packages");
 #endif
testcases/kernel/mem/lib/mem.c +6 -7
index dd82b08d2..c046c77c5 100644
@@ -162,10 +162,9 @@ void oom(int testcase, int lite, int retcode, int allow_sigkill)
 	}
 }
 
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 static void set_global_mempolicy(int mempolicy)
 {
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
 	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
 	int num_nodes, *nodes;
 	int ret;
@@ -203,8 +202,10 @@ static void set_global_mempolicy(int mempolicy)
 		if (set_mempolicy(mempolicy, nmask, MAXNODES) == -1)
 			tst_brk(TBROK|TERRNO, "set_mempolicy");
 	}
-#endif
 }
+#else
+static void set_global_mempolicy(int mempolicy LTP_ATTRIBUTE_UNUSED) { }
+#endif
 
 void testoom(int mempolicy, int lite, int retcode, int allow_sigkill)
 {
@@ -562,8 +563,7 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages)
 	unsigned long length;
 	unsigned long pagesize;
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
 #endif
 
@@ -588,8 +588,7 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages)
 			tst_brk(TBROK|TERRNO, "madvise");
 #endif
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 		clean_node(nmask);
 		set_node(nmask, nodes[i]);
 		/*
testcases/kernel/mem/oom/oom02.c +7 -4
index 3434a34ba..6bc08213f 100644
@@ -26,11 +26,14 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
+
 #include "numa_helper.h"
 #include "mem.h"
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 
 static void verify_oom(void)
 {
@@ -71,6 +74,6 @@ static struct tst_test test = {
 	.test_all = verify_oom,
 };
 
-#else /* no NUMA */
-	TST_TEST_TCONF("no NUMA development packages installed.");
+#else
+	TST_TEST_TCONF("test requires libnuma >= 2 and it's development packages");
 #endif
testcases/kernel/mem/oom/oom03.c +7 -3
index f883bc054..29159d629 100644
@@ -20,16 +20,20 @@
  * the GNU General Public License for more details.
  */
 
+#include "config.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
+
 #include "numa_helper.h"
 #include "mem.h"
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 
 static void verify_oom(void)
 {
@@ -85,5 +89,5 @@ static struct tst_test test = {
 };
 
 #else
-	TST_TEST_TCONF("no NUMA development packages installed.");
+	TST_TEST_TCONF("test requires libnuma >= 2 and it's development packages");
 #endif
testcases/kernel/mem/oom/oom04.c +7 -4
index e4e70e26f..39fedd2a8 100644
@@ -26,11 +26,14 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
+
 #include "numa_helper.h"
 #include "mem.h"
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 
 static void verify_oom(void)
 {
@@ -93,6 +96,6 @@ static struct tst_test test = {
 	.test_all = verify_oom,
 };
 
-#else /* no NUMA */
-	TST_TEST_TCONF("no NUMA development packages installed.");
+#else
+	TST_TEST_TCONF("test requires libnuma >= 2 and it's development packages");
 #endif
testcases/kernel/mem/oom/oom05.c +7 -4
index bdf5d1923..7095974c5 100644
@@ -26,11 +26,14 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
+
 #include "numa_helper.h"
 #include "mem.h"
 
-#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
-	&& HAVE_MPOL_CONSTANTS
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 
 static void verify_oom(void)
 {
@@ -119,6 +122,6 @@ static struct tst_test test = {
 	.test_all = verify_oom,
 };
 
-#else /* no NUMA */
-	TST_TEST_TCONF("no NUMA development packages installed.");
+#else
+	TST_TEST_TCONF("test requires libnuma >= 2 and it's development packages");
 #endif
testcases/kernel/mem/vma/vma02.c +3 -4
index 1492e1385..99642e39e 100644
@@ -49,8 +49,7 @@
 char *TCID = "vma02";
 int TST_TOTAL = 1;
 
-#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_MPOL_CONSTANTS && \
-	defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 
 static unsigned long pagesize;
 static int opt_node;
@@ -164,9 +163,9 @@ void usage(void)
 	printf("  -n      Number of NUMA nodes\n");
 }
 
-#else /* no NUMA */
+#else
 int main(void)
 {
-	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
+	tst_brkm(TCONF, NULL, "test requires libnuma >= 2 and it's development packages");
 }
 #endif
testcases/kernel/mem/vma/vma04.c +3 -4
index 905fbd3ad..030a92691 100644
@@ -53,8 +53,7 @@
 char *TCID = "vma04";
 int TST_TOTAL = 5;
 
-#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_MPOL_CONSTANTS && \
-	defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 
 static unsigned long pagesize;
 static int opt_node;
@@ -325,9 +324,9 @@ static void usage(void)
 	printf("  -n      Number of NUMA nodes\n");
 }
 
-#else /* no NUMA */
+#else
 int main(void)
 {
-	tst_brkm(TCONF, NULL, "no NUMA development packages installed.");
+	tst_brkm(TCONF, NULL, "test requires libnuma >= 2 and it's development packages");
 }
 #endif
testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c +4 -3
index daa5f5dcc..90c4f9662 100644
@@ -57,6 +57,7 @@
 #if HAVE_NUMAIF_H
 #include <numaif.h>
 #endif
+
 #include "test.h"
 #include "lapi/syscalls.h"
 #include "include_j_h.h"
@@ -66,8 +67,7 @@
 char *TCID = "get_mempolicy01";
 int TST_TOTAL = 1;
 
-#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_MPOL_CONSTANTS && \
-	defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 
 #define MEM_LENGTH	(4 * 1024 * 1024)
 
@@ -311,9 +311,10 @@ static void setup(void)
 	TEST_PAUSE;
 	tst_tmpdir();
 }
+
 #else
 int main(void)
 {
-	tst_brkm(TCONF, NULL, "System doesn't have required numa support");
+	tst_brkm(TCONF, NULL, "test requires libnuma >= 2 and it's development packages");
 }
 #endif
testcases/kernel/syscalls/mbind/mbind01.c +7 -4
index be5470691..291cf3e95 100644
@@ -22,12 +22,15 @@
  */
 
 #include <errno.h>
+#if HAVE_NUMA_H
+#include <numa.h>
+#endif
 
+#include "config.h"
 #include "numa_helper.h"
 #include "tst_test.h"
 
-#if HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_MPOL_CONSTANTS && \
-	defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 
 #define MEM_LENGTH (4 * 1024 * 1024)
 
@@ -233,6 +236,6 @@ static struct tst_test test = {
 	.setup = setup,
 };
 
-#else /* libnuma >= 2 */
-TST_TEST_TCONF("test requires libnuma >= 2.");
+#else
+TST_TEST_TCONF("test requires libnuma >= 2 and it's development packages");
 #endif
testcases/kernel/syscalls/migrate_pages/migrate_pages01.c +6 -4
index 32c78b29a..6add4fa67 100644
@@ -55,7 +55,9 @@ option_t options[] = {
 	{NULL, NULL, NULL}
 };
 
-#if defined(__NR_migrate_pages) && HAVE_NUMA_H && HAVE_NUMAIF_H
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
+	&& defined(__NR_migrate_pages)
+
 static unsigned long *sane_old_nodes;
 static unsigned long *sane_new_nodes;
 static int sane_nodemask_size;
@@ -249,10 +251,10 @@ static void cleanup(void)
 	free(sane_new_nodes);
 }
 
-#else /* __NR_migrate_pages */
+#else
 int main(void)
 {
-	tst_brkm(TCONF, NULL, "System doesn't support __NR_migrate_pages"
-		 " or libnuma is not available");
+	tst_brkm(TCONF, NULL, "System doesn't support __NR_migrate_pages or "
+		 "libnuma or libnuma development packages are not available");
 }
 #endif
testcases/kernel/syscalls/migrate_pages/migrate_pages02.c +7 -4
index 6755a384d..480fbd20c 100644
@@ -45,6 +45,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <pwd.h>
+
 #include "config.h"
 #include "test.h"
 #include "safe_macros.h"
@@ -65,7 +66,9 @@
 char *TCID = "migrate_pages02";
 int TST_TOTAL = 1;
 
-#if defined(__NR_migrate_pages) && HAVE_NUMA_H && HAVE_NUMAIF_H
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
+	&& defined(__NR_migrate_pages)
+
 static const char nobody_uid[] = "nobody";
 static struct passwd *ltpuser;
 static int *nodes, nodeA, nodeB;
@@ -397,10 +400,10 @@ static void cleanup(void)
 	free(nodes);
 }
 
-#else /* __NR_migrate_pages */
+#else
 int main(void)
 {
-	tst_brkm(TCONF, NULL, "System doesn't support __NR_migrate_pages"
-		 " or libnuma is not available");
+	tst_brkm(TCONF, NULL, "System doesn't support __NR_migrate_pages or "
+		 "libnuma or libnuma development packages are not available");
 }
 #endif
testcases/kernel/syscalls/move_pages/move_pages_support.c +7 -7
index a488c88f0..3fce8b77f 100644
@@ -16,6 +16,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
 #include <sys/mman.h>
 #include <sys/syscall.h>
 #include <unistd.h>
@@ -35,8 +36,7 @@ long get_page_size(void)
  */
 void free_pages(void **pages, unsigned int num)
 {
-
-#if HAVE_NUMA_H
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 	int i;
 	size_t onepage = get_page_size();
 
@@ -111,7 +111,7 @@ int alloc_pages_linear(void **pages, unsigned int num)
 {
 	int nodes[num];
 
-#if HAVE_NUMA_H
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 	unsigned int i;
 	unsigned int n = 0;
 	int num_allowed_nodes;
@@ -168,7 +168,7 @@ int alloc_pages_on_node(void **pages, unsigned int num, int node)
 void
 verify_pages_on_nodes(void **pages, int *status, unsigned int num, int *nodes)
 {
-#if HAVE_NUMA_H
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 	unsigned int i;
 	int which_node;
 	int ret;
@@ -214,7 +214,7 @@ verify_pages_on_nodes(void **pages, int *status, unsigned int num, int *nodes)
  */
 void verify_pages_linear(void **pages, int *status, unsigned int num)
 {
-#if HAVE_NUMA_H
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 	unsigned int i;
 	unsigned int n = 0;
 	int nodes[num];
@@ -269,7 +269,7 @@ void verify_pages_on_node(void **pages, int *status, unsigned int num, int node)
  */
 int alloc_shared_pages_on_node(void **pages, unsigned int num, int node)
 {
-#if HAVE_NUMA_H
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 	char *shared;
 	unsigned int i;
 	int nodes[num];
@@ -392,7 +392,7 @@ void free_sem(sem_t * sem, int num)
  */
 void check_config(unsigned int min_nodes)
 {
-#if HAVE_NUMA_H && HAVE_NUMAIF_H
+#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
 	int num_allowed_nodes;
 	int ret;
 
Signature · 1 line
2.14.2
author
#18 lore raw

PATCH v5 10/12 numa: Check for API >= v2 with autoconf

In reply to Petr Vorel

instead of more verbose check in C code.

---
 m4/ltp-numa.m4                                               | 12 ++++++++++--
 .../cpuset/cpuset_syscall_test/cpuset_syscall_test.c         |  3 +--
 testcases/kernel/hotplug/memory_hotplug/commands.c           |  2 +-
 testcases/kernel/hotplug/memory_hotplug/memtoy.c             |  3 ++-
 testcases/kernel/hotplug/memory_hotplug/segment.c            |  3 ++-
 testcases/kernel/lib/numa_helper.c                           | 12 ++++++------
 testcases/kernel/mem/cpuset/cpuset01.c                       |  3 ++-
 testcases/kernel/mem/ksm/ksm02.c                             |  3 +--
 testcases/kernel/mem/ksm/ksm04.c                             |  3 +--
 testcases/kernel/mem/ksm/ksm06.c                             |  3 +--
 testcases/kernel/mem/lib/mem.c                               |  6 +++---
 testcases/kernel/mem/oom/oom02.c                             |  2 +-
 testcases/kernel/mem/oom/oom03.c                             |  2 +-
 testcases/kernel/mem/oom/oom04.c                             |  2 +-
 testcases/kernel/mem/oom/oom05.c                             |  2 +-
 testcases/kernel/mem/vma/vma02.c                             |  2 +-
 testcases/kernel/mem/vma/vma04.c                             |  2 +-
 testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c    |  2 +-
 testcases/kernel/syscalls/mbind/mbind01.c                    |  2 +-
 testcases/kernel/syscalls/migrate_pages/migrate_pages01.c    |  3 +--
 testcases/kernel/syscalls/migrate_pages/migrate_pages02.c    |  3 +--
 testcases/kernel/syscalls/move_pages/move_pages_support.c    | 12 ++++++------
 22 files changed, 46 insertions(+), 41 deletions(-)
m4/ltp-numa.m4 +10 -2
index f21e38858..547fa58a5 100644
@@ -27,9 +27,17 @@ AC_DEFUN([LTP_CHECK_SYSCALL_NUMA], [
 	AC_CHECK_LIB(numa, numa_available, [have_libnuma=yes])
 	AC_CHECK_HEADERS([numa.h numaif.h], [], [have_numa_headers=no])
 
-	if test "x$have_libnuma" = "xyes" -a "x$have_numa_headers" != "xno"; then
+	AC_RUN_IFELSE([AC_LANG_PROGRAM([
+#include <numa.h>
+		], [
+#if LIBNUMA_API_VERSION < 2
+exit(1);
+#endif
+		])], [have_numa_headers_v2=yes])
+
+	if test "x$have_libnuma" = "xyes" -a "x$have_numa_headers" != "xno" -a "x$have_numa_headers_v2" = "xyes"; then
 		AC_SUBST(NUMA_LIBS, "-lnuma")
-		AC_DEFINE(HAVE_LIBNUMA, 1, [Define to 1 if you have libnuma and it's headers installed.])
+		AC_DEFINE(HAVE_NUMA_V2, 1, [Define to 1 if you have libnuma and it's headers version >= 2 installed.])
 
 		AC_CHECK_LIB(numa, numa_alloc_onnode, [
 			AC_DEFINE(HAVE_NUMA_ALLOC_ONNODE, 1, [Define to 1 if you have `numa_alloc_onnode' function.])
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c +1 -2
index 6a6c7a803..9e568a970 100644
@@ -51,8 +51,7 @@
 char *TCID = "cpuset_syscall_test";
 int TST_TOTAL = 1;
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
-	&& defined(HAVE_LINUX_MEMPOLICY_H)
+#ifdef defined(HAVE_NUMA_V2) && defined(HAVE_LINUX_MEMPOLICY_H)
 
 #include "../cpuset_lib/cpuset.h"
 #include "../cpuset_lib/bitmask.h"
testcases/kernel/hotplug/memory_hotplug/commands.c +1 -1
index 54a79224d..886ee82f7 100644
@@ -33,7 +33,7 @@
 #include <numa.h>
 #endif
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/mman.h>
testcases/kernel/hotplug/memory_hotplug/memtoy.c +2 -1
index 40d08ef63..fe76fb9d8 100644
@@ -30,7 +30,8 @@
 #include <numa.h>
 #endif
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
+
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/mman.h>
testcases/kernel/hotplug/memory_hotplug/segment.c +2 -1
index a087eb2e1..73c718ce7 100644
@@ -32,7 +32,8 @@
 #include <numa.h>
 #endif
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
+
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <sys/mman.h>
testcases/kernel/lib/numa_helper.c +6 -6
index 095285bb2..2eee8d35d 100644
@@ -39,13 +39,13 @@
 unsigned long get_max_node(void)
 {
 	unsigned long max_node = 0;
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 	max_node = numa_max_possible_node() + 1;
 #endif
 	return max_node;
 }
 
-#ifdef HAVE_LIBNUMA
+#ifdef HAVE_NUMA_V2
 static void get_nodemask_allnodes(nodemask_t * nodemask, unsigned long max_node)
 {
 	unsigned long nodemask_size = max_node / 8;
@@ -134,7 +134,7 @@ static void filter_nodemask_cpu(nodemask_t * nodemask, unsigned long max_node)
 	}
 	free(cpumask);
 }
-#endif /* HAVE_LIBNUMA */
+#endif /* HAVE_NUMA_V2 */
 
 /*
  * get_allowed_nodes_arr - get number and array of available nodes
@@ -152,7 +152,7 @@ static void filter_nodemask_cpu(nodemask_t * nodemask, unsigned long max_node)
 int get_allowed_nodes_arr(int flag, int *num_nodes, int **nodes)
 {
 	int ret = 0;
-#ifdef HAVE_LIBNUMA
+#ifdef HAVE_NUMA_V2
 	int i;
 	nodemask_t *nodemask = NULL;
 #endif
@@ -160,7 +160,7 @@ int get_allowed_nodes_arr(int flag, int *num_nodes, int **nodes)
 	if (nodes)
 		*nodes = NULL;
 
-#ifdef HAVE_LIBNUMA
+#ifdef HAVE_NUMA_V2
 	unsigned long max_node, nodemask_size;
 
 	if (numa_available() == -1)
@@ -198,7 +198,7 @@ int get_allowed_nodes_arr(int flag, int *num_nodes, int **nodes)
 		}
 	} while (0);
 	free(nodemask);
-#endif /* HAVE_LIBNUMA */
+#endif /* HAVE_NUMA_V2 */
 	return ret;
 }
 
testcases/kernel/mem/cpuset/cpuset01.c +2 -1
index 4efb01f23..354b6fc32 100644
@@ -33,7 +33,8 @@
 #include "mem.h"
 #include "numa_helper.h"
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
+
 volatile int end;
 static int *nodes;
 static int nnodes;
testcases/kernel/mem/ksm/ksm02.c +1 -2
index 801412fd7..e8ac8aa15 100644
@@ -62,8 +62,7 @@
 #include "mem.h"
 #include "ksm_common.h"
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
-	&& HAVE_LINUX_MEMPOLICY_H
+#if defined(HAVE_NUMA_V2) && defined(HAVE_LINUX_MEMPOLICY_H)
 
 static void verify_ksm(void)
 {
testcases/kernel/mem/ksm/ksm04.c +1 -2
index bdce8b9fb..1070bfba1 100644
@@ -62,8 +62,7 @@
 #include "mem.h"
 #include "ksm_common.h"
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
-	&& HAVE_LINUX_MEMPOLICY_H
+#if defined(HAVE_NUMA_V2) && defined(HAVE_LINUX_MEMPOLICY_H)
 
 static void verify_ksm(void)
 {
testcases/kernel/mem/ksm/ksm06.c +1 -2
index 4763460cf..e0fa0270e 100644
@@ -42,8 +42,7 @@
 #include "mem.h"
 #include "numa_helper.h"
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
-	&& HAVE_LINUX_MEMPOLICY_H
+#if defined(HAVE_NUMA_V2) && defined(HAVE_LINUX_MEMPOLICY_H)
 
 static int run = -1;
 static int sleep_millisecs = -1;
testcases/kernel/mem/lib/mem.c +3 -3
index c046c77c5..fc2f130f4 100644
@@ -162,7 +162,7 @@ void oom(int testcase, int lite, int retcode, int allow_sigkill)
 	}
 }
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 static void set_global_mempolicy(int mempolicy)
 {
 	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
@@ -563,7 +563,7 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages)
 	unsigned long length;
 	unsigned long pagesize;
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 	unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
 #endif
 
@@ -588,7 +588,7 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages)
 			tst_brk(TBROK|TERRNO, "madvise");
 #endif
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 		clean_node(nmask);
 		set_node(nmask, nodes[i]);
 		/*
testcases/kernel/mem/oom/oom02.c +1 -1
index 6bc08213f..45e64d370 100644
@@ -33,7 +33,7 @@
 #include "numa_helper.h"
 #include "mem.h"
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 
 static void verify_oom(void)
 {
testcases/kernel/mem/oom/oom03.c +1 -1
index 29159d629..c4b90c190 100644
@@ -33,7 +33,7 @@
 #include "numa_helper.h"
 #include "mem.h"
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 
 static void verify_oom(void)
 {
testcases/kernel/mem/oom/oom04.c +1 -1
index 39fedd2a8..7dbf9ce70 100644
@@ -33,7 +33,7 @@
 #include "numa_helper.h"
 #include "mem.h"
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 
 static void verify_oom(void)
 {
testcases/kernel/mem/oom/oom05.c +1 -1
index 7095974c5..eb2453156 100644
@@ -33,7 +33,7 @@
 #include "numa_helper.h"
 #include "mem.h"
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 
 static void verify_oom(void)
 {
testcases/kernel/mem/vma/vma02.c +1 -1
index 99642e39e..33d000d01 100644
@@ -49,7 +49,7 @@
 char *TCID = "vma02";
 int TST_TOTAL = 1;
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 
 static unsigned long pagesize;
 static int opt_node;
testcases/kernel/mem/vma/vma04.c +1 -1
index 030a92691..a5918bcb7 100644
@@ -53,7 +53,7 @@
 char *TCID = "vma04";
 int TST_TOTAL = 5;
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 
 static unsigned long pagesize;
 static int opt_node;
testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c +1 -1
index 90c4f9662..a1b9e4327 100644
@@ -67,7 +67,7 @@
 char *TCID = "get_mempolicy01";
 int TST_TOTAL = 1;
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 
 #define MEM_LENGTH	(4 * 1024 * 1024)
 
testcases/kernel/syscalls/mbind/mbind01.c +1 -1
index 291cf3e95..4eb7da698 100644
@@ -30,7 +30,7 @@
 #include "numa_helper.h"
 #include "tst_test.h"
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 
 #define MEM_LENGTH (4 * 1024 * 1024)
 
testcases/kernel/syscalls/migrate_pages/migrate_pages01.c +1 -2
index 6add4fa67..01409f300 100644
@@ -55,8 +55,7 @@ option_t options[] = {
 	{NULL, NULL, NULL}
 };
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
-	&& defined(__NR_migrate_pages)
+#if defined(HAVE_NUMA_V2) && defined(__NR_migrate_pages)
 
 static unsigned long *sane_old_nodes;
 static unsigned long *sane_new_nodes;
testcases/kernel/syscalls/migrate_pages/migrate_pages02.c +1 -2
index 480fbd20c..faf96b6b7 100644
@@ -66,8 +66,7 @@
 char *TCID = "migrate_pages02";
 int TST_TOTAL = 1;
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2 \
-	&& defined(__NR_migrate_pages)
+#if defined(HAVE_NUMA_V2) && defined(__NR_migrate_pages)
 
 static const char nobody_uid[] = "nobody";
 static struct passwd *ltpuser;
testcases/kernel/syscalls/move_pages/move_pages_support.c +6 -6
index 3fce8b77f..340a715fc 100644
@@ -36,7 +36,7 @@ long get_page_size(void)
  */
 void free_pages(void **pages, unsigned int num)
 {
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 	int i;
 	size_t onepage = get_page_size();
 
@@ -111,7 +111,7 @@ int alloc_pages_linear(void **pages, unsigned int num)
 {
 	int nodes[num];
 
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	unsigned int n = 0;
 	int num_allowed_nodes;
@@ -168,7 +168,7 @@ int alloc_pages_on_node(void **pages, unsigned int num, int node)
 void
 verify_pages_on_nodes(void **pages, int *status, unsigned int num, int *nodes)
 {
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	int which_node;
 	int ret;
@@ -214,7 +214,7 @@ verify_pages_on_nodes(void **pages, int *status, unsigned int num, int *nodes)
  */
 void verify_pages_linear(void **pages, int *status, unsigned int num)
 {
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	unsigned int n = 0;
 	int nodes[num];
@@ -269,7 +269,7 @@ void verify_pages_on_node(void **pages, int *status, unsigned int num, int node)
  */
 int alloc_shared_pages_on_node(void **pages, unsigned int num, int node)
 {
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 	char *shared;
 	unsigned int i;
 	int nodes[num];
@@ -392,7 +392,7 @@ void free_sem(sem_t * sem, int num)
  */
 void check_config(unsigned int min_nodes)
 {
-#if HAVE_LIBNUMA && defined(LIBNUMA_API_VERSION) && LIBNUMA_API_VERSION >= 2
+#ifdef HAVE_NUMA_V2
 	int num_allowed_nodes;
 	int ret;
 
Signature · 1 line
2.14.2
author
#19 lore raw

PATCH v5 11/12 numa: Remove HAVE_NUMA_ALLOC_ONNODE definition

In reply to Petr Vorel

numa_alloc_onnode() was added in libnuma v0.6 and we require NUMA API v2 => replace with HAVE_NUMA_V2 definition.

---
 include/config.h.default                                  | 3 ---
 m4/ltp-numa.m4                                            | 3 ---
 testcases/kernel/syscalls/move_pages/move_pages_support.c | 4 ++--
 3 files changed, 2 insertions(+), 8 deletions(-)
include/config.h.default +0 -3
index ef6a3d55f..8b245fce0 100644
@@ -125,9 +125,6 @@
 /* 2.6 version of swapon/swapoff */
 #define HAVE_NEW_SWAPONOFF 1
 
-/* Define to 1 if you have the `numa_alloc_onnode' function. */
-#undef HAVE_NUMA_ALLOC_ONNODE
-
 /* Define to 1 if you have the <numa.h> header file. */
 #undef HAVE_NUMA_H
 
m4/ltp-numa.m4 +0 -3
index 547fa58a5..56a2b81f7 100644
@@ -39,9 +39,6 @@ exit(1);
 		AC_SUBST(NUMA_LIBS, "-lnuma")
 		AC_DEFINE(HAVE_NUMA_V2, 1, [Define to 1 if you have libnuma and it's headers version >= 2 installed.])
 
-		AC_CHECK_LIB(numa, numa_alloc_onnode, [
-			AC_DEFINE(HAVE_NUMA_ALLOC_ONNODE, 1, [Define to 1 if you have `numa_alloc_onnode' function.])
-		])
 		AC_CHECK_LIB(numa, numa_move_pages, [
 			AC_DEFINE(HAVE_NUMA_MOVE_PAGES, 1, [Define to 1 if you have `numa_move_pages' function.])
 		])
testcases/kernel/syscalls/move_pages/move_pages_support.c +2 -2
index 340a715fc..31f74968f 100644
@@ -63,7 +63,7 @@ void free_pages(void **pages, unsigned int num)
 int alloc_pages_on_nodes(void **pages, unsigned int num, int *nodes)
 {
 	int i;
-#if HAVE_NUMA_ALLOC_ONNODE
+#ifdef HAVE_NUMA_V2
 	size_t onepage = get_page_size();
 #endif
 
@@ -74,7 +74,7 @@ int alloc_pages_on_nodes(void **pages, unsigned int num, int *nodes)
 	for (i = 0; i < num; i++) {
 		char *page;
 
-#if HAVE_NUMA_ALLOC_ONNODE
+#ifdef HAVE_NUMA_V2
 		pages[i] = numa_alloc_onnode(onepage, nodes[i]);
 #endif
 		if (pages[i] == NULL) {
Signature · 1 line
2.14.2
author
#20 lore raw

PATCH v5 12/12 numa: Remove HAVE_NUMA_MOVE_PAGES definition

In reply to Petr Vorel

numa_move_pages() was added in NUMA API v2 => replace with HAVE_NUMA_V2 definition.

---
 m4/ltp-numa.m4                                      | 4 ----
 testcases/kernel/syscalls/move_pages/move_pages01.c | 4 ++--
 testcases/kernel/syscalls/move_pages/move_pages02.c | 4 ++--
 testcases/kernel/syscalls/move_pages/move_pages03.c | 4 ++--
 testcases/kernel/syscalls/move_pages/move_pages04.c | 4 ++--
 testcases/kernel/syscalls/move_pages/move_pages05.c | 4 ++--
 testcases/kernel/syscalls/move_pages/move_pages06.c | 4 ++--
 testcases/kernel/syscalls/move_pages/move_pages07.c | 4 ++--
 testcases/kernel/syscalls/move_pages/move_pages08.c | 4 ++--
 testcases/kernel/syscalls/move_pages/move_pages09.c | 4 ++--
 testcases/kernel/syscalls/move_pages/move_pages10.c | 4 ++--
 testcases/kernel/syscalls/move_pages/move_pages11.c | 4 ++--
 testcases/kernel/syscalls/move_pages/move_pages12.c | 4 ++--
 13 files changed, 24 insertions(+), 28 deletions(-)
m4/ltp-numa.m4 +0 -4
index 56a2b81f7..f199643a1 100644
@@ -38,9 +38,5 @@ exit(1);
 	if test "x$have_libnuma" = "xyes" -a "x$have_numa_headers" != "xno" -a "x$have_numa_headers_v2" = "xyes"; then
 		AC_SUBST(NUMA_LIBS, "-lnuma")
 		AC_DEFINE(HAVE_NUMA_V2, 1, [Define to 1 if you have libnuma and it's headers version >= 2 installed.])
-
-		AC_CHECK_LIB(numa, numa_move_pages, [
-			AC_DEFINE(HAVE_NUMA_MOVE_PAGES, 1, [Define to 1 if you have `numa_move_pages' function.])
-		])
 	fi
 ])
testcases/kernel/syscalls/move_pages/move_pages01.c +2 -2
index 6f9bd896d..e86c5fc80 100644
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
 
 	setup();
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 	int lc;
 
 	/* check for looping state if -i option is given */
@@ -101,7 +101,7 @@ int main(int argc, char **argv)
 
 	}
 #else
-	tst_resm(TCONF, "move_pages support not found.");
+	tst_resm(TCONF, "test requires libnuma >= 2 and it's development packages");
 #endif
 
 	cleanup();
testcases/kernel/syscalls/move_pages/move_pages02.c +2 -2
index 23594ab1b..ee84b92a7 100644
@@ -73,7 +73,7 @@ int main(int argc, char **argv)
 
 	setup();
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	int lc;
 	unsigned int from_node;
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
 		free_pages(pages, TEST_PAGES);
 	}
 #else
-	tst_resm(TCONF, "move_pages support not found.");
+	tst_resm(TCONF, "test requires libnuma >= 2 and it's development packages");
 #endif
 
 	cleanup();
testcases/kernel/syscalls/move_pages/move_pages03.c +2 -2
index ec036e610..f3f4fd9c1 100644
@@ -111,7 +111,7 @@ int main(int argc, char **argv)
 
 	setup();
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	int lc;
 	unsigned int from_node;
@@ -183,7 +183,7 @@ err_free_pages:
 		free_shared_pages(pages, TEST_PAGES);
 	}
 #else
-	tst_resm(TCONF, "move_pages support not found.");
+	tst_resm(TCONF, "test requires libnuma >= 2 and it's development packages");
 #endif
 
 	cleanup();
testcases/kernel/syscalls/move_pages/move_pages04.c +2 -2
index 0182538c0..3678df0e0 100644
@@ -84,7 +84,7 @@ int main(int argc, char **argv)
 
 	setup();
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	int lc;
 	unsigned int from_node;
@@ -150,7 +150,7 @@ err_free_pages:
 		free_pages(pages, TEST_PAGES);
 	}
 #else
-	tst_resm(TCONF, "move_pages support not found.");
+	tst_resm(TCONF, "test requires libnuma >= 2 and it's development packages");
 #endif
 
 	cleanup();
testcases/kernel/syscalls/move_pages/move_pages05.c +2 -2
index 10264ef20..da9642e7e 100644
@@ -112,7 +112,7 @@ int main(int argc, char **argv)
 
 	setup();
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	int lc;
 	unsigned int from_node;
@@ -198,7 +198,7 @@ err_free_shared:
 		free_shared_pages(pages + SHARED_PAGE, N_SHARED_PAGES);
 	}
 #else
-	tst_resm(TCONF, "move_pages support not found.");
+	tst_resm(TCONF, "test requires libnuma >= 2 and it's development packages");
 #endif
 
 	cleanup();
testcases/kernel/syscalls/move_pages/move_pages06.c +2 -2
index 847fc6279..0edb58218 100644
@@ -73,7 +73,7 @@ int main(int argc, char **argv)
 
 	setup();
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	int lc;
 	unsigned int from_node;
@@ -113,7 +113,7 @@ int main(int argc, char **argv)
 		free_pages(pages, TEST_PAGES);
 	}
 #else
-	tst_resm(TCONF, "move_pages support not found.");
+	tst_resm(TCONF, "test requires libnuma >= 2 and it's development packages");
 #endif
 
 	cleanup();
testcases/kernel/syscalls/move_pages/move_pages07.c +2 -2
index b8653bd8c..0ed54b77a 100644
@@ -73,7 +73,7 @@ int main(int argc, char **argv)
 
 	setup();
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	int lc;
 	unsigned int from_node;
@@ -115,7 +115,7 @@ int main(int argc, char **argv)
 		free_pages(pages, TEST_PAGES);
 	}
 #else
-	tst_resm(TCONF, "move_pages support not found.");
+	tst_resm(TCONF, "test requires libnuma >= 2 and it's development packages");
 #endif
 
 	cleanup();
testcases/kernel/syscalls/move_pages/move_pages08.c +2 -2
index 66544eb2a..bf237f35e 100644
@@ -74,7 +74,7 @@ int main(int argc, char **argv)
 
 	setup();
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	int lc;
 	unsigned int from_node;
@@ -113,7 +113,7 @@ int main(int argc, char **argv)
 		free_pages(pages, TEST_PAGES);
 	}
 #else
-	tst_resm(TCONF, "move_pages support not found.");
+	tst_resm(TCONF, "test requires libnuma >= 2 and it's development packages");
 #endif
 
 	cleanup();
testcases/kernel/syscalls/move_pages/move_pages09.c +2 -2
index d217fc2a1..2d9dc4680 100644
@@ -73,7 +73,7 @@ int main(int argc, char **argv)
 
 	setup();
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	int lc;
 	unsigned int from_node;
@@ -125,7 +125,7 @@ int main(int argc, char **argv)
 		free_pages(pages, TEST_PAGES);
 	}
 #else
-	tst_resm(TCONF, "move_pages support not found.");
+	tst_resm(TCONF, "test requires libnuma >= 2 and it's development packages");
 #endif
 
 	cleanup();
testcases/kernel/syscalls/move_pages/move_pages10.c +2 -2
index 1777ff465..7044135fa 100644
@@ -73,7 +73,7 @@ int main(int argc, char **argv)
 
 	setup();
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	int lc;
 	unsigned int from_node;
@@ -112,7 +112,7 @@ int main(int argc, char **argv)
 		free_pages(pages, TEST_PAGES);
 	}
 #else
-	tst_resm(TCONF, "move_pages support not found.");
+	tst_resm(TCONF, "test requires libnuma >= 2 and it's development packages");
 #endif
 
 	cleanup();
testcases/kernel/syscalls/move_pages/move_pages11.c +2 -2
index 773e9c569..a9d84c5d5 100644
@@ -112,7 +112,7 @@ int main(int argc, char **argv)
 
 	setup();
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 	unsigned int i;
 	int lc;
 	unsigned int from_node;
@@ -186,7 +186,7 @@ err_free_pages:
 		free_shared_pages(pages, TEST_PAGES);
 	}
 #else
-	tst_resm(TCONF, "move_pages support not found.");
+	tst_resm(TCONF, "test requires libnuma >= 2 and it's development packages");
 #endif
 
 	cleanup();
testcases/kernel/syscalls/move_pages/move_pages12.c +2 -2
index 4c7d5c2c0..1ac7bc1c4 100644
@@ -43,7 +43,7 @@
 #include "move_pages_support.h"
 #include "lapi/mmap.h"
 
-#if HAVE_NUMA_MOVE_PAGES
+#ifdef HAVE_NUMA_V2
 
 #define LOOPS	1000
 #define PATH_MEMINFO	"/proc/meminfo"
@@ -267,5 +267,5 @@ static struct tst_test test = {
 };
 
 #else
-	TST_TEST_TCONF("move_pages support not found");
+	TST_TEST_TCONF("test requires libnuma >= 2 and it's development packages");
 #endif
Signature · 1 line
2.14.2
#21 lore raw

PATCH v5 12/12 numa: Remove HAVE_NUMA_MOVE_PAGES definition

Hi!
The numa: prefixed patches looks good to me.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#22 lore raw

PATCH v5 12/12 numa: Remove HAVE_NUMA_MOVE_PAGES definition

Hi Cyril,

Quoted 2 lines

Hi!
The numa: prefixed patches looks good to me.

Thanks! Pushed all of them, but "hotplug/memory_hotplug: Update TODO".

I'm sorry, I again forget to add you with Acked-by tag :-(.

Kind regards,
Petr