Fix 32-bit cross compilation
v2 cover Fix 32-bit cross compilation
Minor changes v2->v2:
* New commit "m4: Simplify check for linux/keyctl.h header".
* Fix commits (accidentally remove check for keyutils.h and sys/acl.h headers).
Petr Vorel (7):
m4: Fix libkeyutils detection on 32-bit cross build
m4: Fix libacl detection on 32-bit cross build
m4: Simplify check for linux/can.h header
m4: Simplify check for linux/keyctl.h header
m4: Fix libcrypto detection on 32-bit cross build
make: Remove workarounds for build without libnuma m4,kernel/lib: Detect libnuma presence in kernel libs
configure.ac | 15 +++++++------ m4/ltp-acl.m4 | 7 +++--- m4/ltp-can.m4 | 25 ---------------------- m4/ltp-crypto.m4 | 10 +++++---- m4/ltp-keyctl.m4 | 25 ---------------------- m4/ltp-keyutils.m4 | 6 +++--- m4/ltp-numa.m4 | 6 +++++- .../cpuset_syscall_test/cpuset_syscall_test.c | 4 ++-- testcases/kernel/hotplug/memory_hotplug/commands.c | 2 +- testcases/kernel/hotplug/memory_hotplug/memtoy.c | 9 ++++---- testcases/kernel/hotplug/memory_hotplug/segment.c | 2 +- testcases/kernel/include/numa_helper.h | 2 +- testcases/kernel/lib/numa_helper.c | 14 ++++++------ testcases/kernel/mem/cpuset/cpuset01.c | 4 ++-- testcases/kernel/mem/ksm/ksm02.c | 4 ++-- testcases/kernel/mem/ksm/ksm04.c | 4 ++-- testcases/kernel/mem/lib/mem.c | 6 +++--- testcases/kernel/mem/vma/vma02.c | 17 ++++++--------- testcases/kernel/mem/vma/vma04.c | 16 +++++--------- .../integrity/ima/src/ima_boot_aggregate.c | 13 +++++++---- .../security/integrity/ima/src/ima_measure.c | 17 +++++++-------- .../syscalls/get_mempolicy/get_mempolicy01.c | 4 ++-- testcases/kernel/syscalls/mbind/Makefile | 9 -------- testcases/kernel/syscalls/mbind/mbind01.c | 4 ++-- testcases/kernel/syscalls/migrate_pages/Makefile | 3 --- .../syscalls/migrate_pages/migrate_pages02.c | 2 +- testcases/kernel/syscalls/move_pages/Makefile | 5 ----- .../syscalls/move_pages/move_pages_support.c | 8 +++---- 28 files changed, 88 insertions(+), 155 deletions(-) delete mode 100644 m4/ltp-can.m4 delete mode 100644 m4/ltp-keyctl.m4
Signature · 1 line
2.14.2
RFC PATCH v2 1/7 m4: Fix libkeyutils detection on 32-bit cross build
--- configure.ac | 1 + m4/ltp-keyutils.m4 | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-)
configure.ac +1 -0
@@ -36,6 +36,7 @@ AC_CHECK_HEADERS([ \ mm.h \ pthread.h \ sys/xattr.h \ + keyutils.h \ linux/genetlink.h \ linux/mempolicy.h \ linux/module.h \
m4/ltp-keyutils.m4 +3 -3
@@ -18,7 +18,7 @@ dnl dnl LTP_CHECK_KEYUTILS_SUPPORT dnl ---------------------------- dnl -AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT],[ -AC_CHECK_HEADERS([keyutils.h], [keyutils_libs="-lkeyutils"]) -AC_SUBST([KEYUTILS_LIBS], [$keyutils_libs]) +AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT], [ + AC_CHECK_LIB([keyutils], [add_key], [keyutils_libs="-lkeyutils"]) + AC_SUBST([KEYUTILS_LIBS], [$keyutils_libs]) ])
Signature · 1 line
2.14.2
RFC PATCH v2 1/7 m4: Fix libkeyutils detection on 32-bit cross build
Hi!
Quoted 23 lines
Signed-off-by Petr Vorel <[email protected]>--- configure.ac | 1 + m4/ltp-keyutils.m4 | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-)configure.ac +1
-0@@ -36,6 +36,7 @@ AC_CHECK_HEADERS([ \ mm.h \ pthread.h \ sys/xattr.h \ + keyutils.h \ linux/genetlink.h \ linux/mempolicy.h \ linux/module.h \m4/ltp-keyutils.m4 +0
-0
m4/ltp-keyutils.m4 dnl · line 24
Quoted 10 lines
m4/ltp-keyutils.m4 +3
-3@@ -18,7 +18,7 @@ dnl dnl LTP_CHECK_KEYUTILS_SUPPORT dnl ---------------------------- dnl -AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT],[ -AC_CHECK_HEADERS([keyutils.h], [keyutils_libs="-lkeyutils"]) -AC_SUBST([KEYUTILS_LIBS], [$keyutils_libs]) +AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT], [ + AC_CHECK_LIB([keyutils], [add_key], [keyutils_libs="-lkeyutils"]) + AC_SUBST([KEYUTILS_LIBS], [$keyutils_libs]) ])
Okay, this fixes most of the problems, but the request_key tests are still broken as far as I can tell. Since these use #ifdef HAVE_KEYUTILS_H, which will still fail if 64bit library is present but not the 32bit one, right? I suppose that it fails with missing symbols for add_key() and request_key().
Afaik these should be converted to make use of the lapi/keyctl.h header just like the add_key tests, right? Or did I miss something?
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH v2 1/7 m4: Fix libkeyutils detection on 32-bit cross build
Hi Cyril,
thanks for your review, all the suggestions and finding typos for this patch-set. I'll put them into v3.
Quoted 31 lines
Quoted 31 lines
Signed-off-by Petr Vorel <[email protected]>--- configure.ac | 1 + m4/ltp-keyutils.m4 | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-)configure.ac +1
-0@@ -36,6 +36,7 @@ AC_CHECK_HEADERS([ \ mm.h \ pthread.h \ sys/xattr.h \ + keyutils.h \ linux/genetlink.h \ linux/mempolicy.h \ linux/module.h \m4/ltp-keyutils.m4 +2
-3@@ -18,7 +18,7 @@ dnl dnl LTP_CHECK_KEYUTILS_SUPPORT dnl ---------------------------- dnl -AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT],[ -AC_CHECK_HEADERS([keyutils.h], [keyutils_libs="-lkeyutils"]) -AC_SUBST([KEYUTILS_LIBS], [$keyutils_libs]) +AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT], [ + AC_CHECK_LIB([keyutils], [add_key], [keyutils_libs="-lkeyutils"])
Quoted 8 lines
m4/ltp-keyutils.m4 dnl · line 24
Quoted 2 lines
m4/ltp-keyutils.m4 +1
-0+ AC_SUBST([KEYUTILS_LIBS], [$keyutils_libs]) ])Okay, this fixes most of the problems, but the
request_keytests are still broken as far as I can tell. Since these use #ifdefHAVE_KEYUTILS_H, which will still fail if 64bit library is present but not the 32bit one, right? I suppose that it fails with missing symbols foradd_key()andrequest_key().
Yep, you're right :-(.
Quoted 2 lines
Afaik these should be converted to make use of the
lapi/keyctl.hheader just like theadd_keytests, right? Or did I miss something?
Sure. I've noticed that, but today after firing v2.
Kind regards,
Petr
RFC PATCH v2 2/7 m4: Fix libacl detection on 32-bit cross build
In reply to Petr Vorel--- configure.ac | 1 + m4/ltp-acl.m4 | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-)
configure.ac +1 -0
@@ -41,6 +41,7 @@ AC_CHECK_HEADERS([ \ linux/mempolicy.h \ linux/module.h \ linux/netlink.h \ + sys/acl.h \ sys/epoll.h \ sys/inotify.h \ sys/fanotify.h \
m4/ltp-acl.m4 +3 -4
@@ -23,8 +23,7 @@ dnl LTP_CHECK_ACL_SUPPORT dnl ---------------------------- dnl AC_DEFUN([LTP_CHECK_ACL_SUPPORT],[ -AH_TEMPLATE(HAVE_LIBACL, -[Define to 1 if you have libacl installed.]) -AC_CHECK_HEADERS([sys/acl.h], [acl_libs="-lacl"]) -AC_SUBST([ACL_LIBS], [$acl_libs]) + AH_TEMPLATE(HAVE_LIBACL, [Define to 1 if you have libacl installed.]) + AC_CHECK_LIB([acl], [acl_init], [acl_libs="-lacl"]) + AC_SUBST([ACL_LIBS], [$acl_libs]) ])
Signature · 1 line
2.14.2
RFC PATCH v2 2/7 m4: Fix libacl detection on 32-bit cross build
Hi!
Quoted 22 lines
configure.ac | 1 + m4/ltp-acl.m4 | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-)configure.ac +1
-0@@ -41,6 +41,7 @@ AC_CHECK_HEADERS([ \ linux/mempolicy.h \ linux/module.h \ linux/netlink.h \ + sys/acl.h \ sys/epoll.h \ sys/inotify.h \ sys/fanotify.h \m4/ltp-acl.m4 +0
-0@@ -23,8 +23,7 @@ dnl LTP_CHECK_ACL_SUPPORT dnl ----------------------------
m4/ltp-acl.m4 dnl LTP_CHECK_ACL_SUPPORT · line 29
Quoted 10 lines
m4/ltp-acl.m4 +3
-4dnl AC_DEFUN([LTP_CHECK_ACL_SUPPORT],[ -AH_TEMPLATE(HAVE_LIBACL, -[Define to 1 if you have libacl installed.]) -AC_CHECK_HEADERS([sys/acl.h], [acl_libs="-lacl"]) -AC_SUBST([ACL_LIBS], [$acl_libs]) + AH_TEMPLATE(HAVE_LIBACL, [Define to 1 if you have libacl installed.]) + AC_CHECK_LIB([acl], [acl_init], [acl_libs="-lacl"]) + AC_SUBST([ACL_LIBS], [$acl_libs]) ])
The acl1.c ifdefs around HAVE_SYS_ACL_H, we should make use of HAVE_LIBACL there instead otherwise it's still broken, right?
Also we should do something as AC_DEFINE(HAVE_LIBACL, ...) in the AC_CHECK_LIB() and we may also drop the header check.
I guess that we should do something as:
AC_CHECK_LIB([acl], [acl_init],
[AC_DEFINE(HAVE_LIBACL, 1, "Define to 1 if you have libacl installed"),
AC_SUBST(ACL_LIBS, "-lacl)])
Per all libraries, so that we would end up with HAVE_LIBACL to be used in #ifdefs in C code and with ACL_LIBS to be used in Makefiles. We have to do both to avoid compilation failures.
We would have to keep a few check for headers though, since we do have a few checks for HAVE_FOO_H in the include/lapi/ headers that turn on/off fallback definitions.
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH v2 3/7 m4: Simplify check for linux/can.h header
In reply to Petr Vorel--- configure.ac | 2 +- m4/ltp-can.m4 | 25 ------------------------- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 m4/ltp-can.m4
configure.ac +1 -1
@@ -37,6 +37,7 @@ AC_CHECK_HEADERS([ \ pthread.h \ sys/xattr.h \ keyutils.h \ + linux/can.h \ linux/genetlink.h \ linux/mempolicy.h \ linux/module.h \
@@ -178,7 +179,6 @@ LTP_CHECK_TEE LTP_CHECK_SPLICE LTP_CHECK_VMSPLICE LTP_CHECK_TIMERFD -LTP_CHECK_CAN_SUPPORT LTP_CHECK_IOVEC LTP_CHECK_KEYCTL LTP_CHECK_LINUXRANDOM
m4/ltp-can.m4 deleted +0 -25
@@ -1,25 +0,0 @@ -dnl -dnl Copyright (c) Linux Test Project, 2014 -dnl -dnl This program is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 2 of the License, or -dnl (at your option) any later version. -dnl -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -dnl the GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -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 -dnl LTP_CHECK_CAN_SUPPORT -dnl ---------------------------- -dnl -AC_DEFUN([LTP_CHECK_CAN_SUPPORT],[ -AC_CHECK_HEADERS([linux/can.h]) -])
Signature · 1 line
2.14.2
RFC PATCH v2 3/7 m4: Simplify check for linux/can.h header
Hi!
This one and the next one are obviously OK, but does not apply without the previous ones, otherwise I would have pushed these right away.
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH v2 4/7 m4: Simplify check for linux/keyctl.h header
In reply to Petr Vorel--- configure.ac | 2 +- m4/ltp-keyctl.m4 | 25 ------------------------- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 m4/ltp-keyctl.m4
configure.ac +1 -1
@@ -39,6 +39,7 @@ AC_CHECK_HEADERS([ \ keyutils.h \ linux/can.h \ linux/genetlink.h \ + linux/keyctl.h \ linux/mempolicy.h \ linux/module.h \ linux/netlink.h \
@@ -180,7 +181,6 @@ LTP_CHECK_SPLICE LTP_CHECK_VMSPLICE LTP_CHECK_TIMERFD LTP_CHECK_IOVEC -LTP_CHECK_KEYCTL LTP_CHECK_LINUXRANDOM LTP_CHECK_IF_LINK LTP_CHECK_KCMP
m4/ltp-keyctl.m4 deleted +0 -25
@@ -1,25 +0,0 @@ -dnl -dnl Copyright (c) 2014 Linux Test Project -dnl -dnl This program is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU General Public License as -dnl published by the Free Software Foundation; either version 2 of -dnl the License, or (at your option) any later version. -dnl -dnl This program is distributed in the hope that it would be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with this program; if not, write the Free Software Foundation, -dnl Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -dnl - -dnl -dnl LTP_CHECK_KEYCTL -dnl ---------------------------- -dnl -AC_DEFUN([LTP_CHECK_KEYCTL],[ -AC_CHECK_HEADERS([linux/keyctl.h]) -])
Signature · 1 line
2.14.2
RFC PATCH v2 5/7 m4: Fix libcrypto detection on 32-bit cross build
In reply to Petr Vorel--- configure.ac | 11 ++++++----- m4/ltp-crypto.m4 | 10 ++++++---- .../security/integrity/ima/src/ima_boot_aggregate.c | 13 +++++++++---- .../kernel/security/integrity/ima/src/ima_measure.c | 17 ++++++++--------- 4 files changed, 29 insertions(+), 22 deletions(-)
configure.ac +6 -5
@@ -32,22 +32,23 @@ AC_PREFIX_DEFAULT(/opt/ltp) AC_CHECK_HEADERS([ \ ifaddrs.h \ - libaio.h \ - mm.h \ - pthread.h \ - sys/xattr.h \ keyutils.h \ + libaio.h \ linux/can.h \ linux/genetlink.h \ linux/keyctl.h \ linux/mempolicy.h \ linux/module.h \ linux/netlink.h \ + mm.h \ + openssl/sha.h \ + pthread.h \ sys/acl.h \ sys/epoll.h \ - sys/inotify.h \ sys/fanotify.h \ + sys/inotify.h \ sys/prctl.h \ + sys/xattr.h \ ]) # Tools knobs
m4/ltp-crypto.m4 +6 -4
@@ -2,8 +2,10 @@ dnl dnl LTP_CHECK_CRYPTO dnl ---------------------------- dnl -AC_DEFUN([LTP_CHECK_CRYPTO], -[dnl -AC_CHECK_HEADERS(openssl/sha.h,[CRYPTO_LIBS=-lcrypto],[CRYPTO_LIBS=]) -AC_SUBST(CRYPTO_LIBS) +AC_DEFUN([LTP_CHECK_CRYPTO], [ + AC_CHECK_LIB([crypto], [SHA1_Init], [crypto_libs="-lcrypto"]) + AC_SUBST([CRYPTO_LIBS], [$crypto_libs]) + if test "x$have_libnuma" != "x"; then + AC_DEFINE(HAVE_LIBCRYPTO,1,[define whether libcrypto is installed]) + fi ])
testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c +9 -4
@@ -29,6 +29,8 @@#include <openssl/sha.h> #endif +#if HAVE_LIBCRYPTO &&HAVE_OPENSSL_SHA_H +#define MAX_EVENT_SIZE 500#define EVENT_HEADER_SIZE 32#define MAX_EVENT_DATA_SIZE (MAX_EVENT_SIZE - EVENT_HEADER_SIZE)
@@ -48,7 +50,6 @@ static void display_sha1_digest(unsigned char *pcr)int main (int argc,char *argv[]) { -#if HAVE_OPENSSL_SHA_H unsigned char boot_aggregate[SHA_DIGEST_LENGTH ]; struct { struct {
@@ -113,8 +114,12 @@ int main(int argc, char *argv[])printf ("boot_aggregate:" );display_sha1_digest (boot_aggregate); -#else -tst_resm (TCONF ,"System doesn't have openssl/sha.h" ); -#endif tst_exit(); } + +#else +int main (void ) +{ +tst_resm (TCONF ,"test requires libcrypto and openssl development packages" ); +} +#endif
testcases/kernel/security/integrity/ima/src/ima_measure.c +8 -9
@@ -28,6 +28,7 @@#include <openssl/sha.h> #endif +#if HAVE_LIBCRYPTO &&HAVE_OPENSSL_SHA_H #define TCG_EVENT_NAME_LEN_MAX 255char *TCID ="ima_measure" ;
@@ -39,8 +40,6 @@ static int verbose;if (verbose) \ printf(format, ##arg) -#if HAVE_OPENSSL_SHA_H - static u_int8_t zero[SHA_DIGEST_LENGTH];static u_int8_t fox[SHA_DIGEST_LENGTH ];
@@ -97,8 +96,6 @@ static int verify_template_hash(struct event *template)return 0 ; } -#endif -/* * ima_measurements.c - calculate the SHA1 aggregate-pcr value based * on the IMA runtime binary measurements.
@@ -131,8 +128,6 @@ static int verify_template_hash(struct event *template)*/ int main (int argc,char *argv[]) { - -#if HAVE_OPENSSL_SHA_H FILE *fp;struct event template;u_int8_t pcr[SHA_DIGEST_LENGTH ];
@@ -212,8 +207,12 @@ int main(int argc, char *argv[]) verbose =1 ;print_info ("PCRAggr (re-calculated):" );display_sha1_digest (pcr); -#else -tst_resm (TCONF ,"System doesn't have openssl/sha.h" ); -#endif tst_exit(); } + +#else +int main (void ) +{ +tst_resm (TCONF ,"test requires libcrypto and openssl development packages" ); +} +#endif
Signature · 1 line
2.14.2
RFC PATCH v2 5/7 m4: Fix libcrypto detection on 32-bit cross build
Hi!
Quoted 21 lines
configure.ac +2
-4@@ -32,22 +32,23 @@ AC_PREFIX_DEFAULT(/opt/ltp) AC_CHECK_HEADERS([ \ ifaddrs.h \ - libaio.h \ - mm.h \ - pthread.h \ - sys/xattr.h \ keyutils.h \ + libaio.h \ linux/can.h \ linux/genetlink.h \ linux/keyctl.h \ linux/mempolicy.h \ linux/module.h \ linux/netlink.h \ + mm.h \
configure.ac AC_PREFIX_DEFAULT(/opt/ltp) · line 52
Quoted 10 lines
configure.ac +4
-1+ openssl/sha.h \ + pthread.h \ sys/acl.h \ sys/epoll.h \ - sys/inotify.h \ sys/fanotify.h \ + sys/inotify.h \ sys/prctl.h \ + sys/xattr.h \ ])
Can we sort these in a separate patch please?
Quoted 7 lines
configure.ac +0
-0# Tools knobsm4/ltp-crypto.m4 +0
-0@@ -2,8 +2,10 @@ dnl dnl LTP_CHECK_CRYPTO
m4/ltp-crypto.m4 dnl · line 8
Quoted 10 lines
m4/ltp-crypto.m4 +4
-4dnl ---------------------------- dnl -AC_DEFUN([LTP_CHECK_CRYPTO], -[dnl -AC_CHECK_HEADERS(openssl/sha.h,[CRYPTO_LIBS=-lcrypto],[CRYPTO_LIBS=]) -AC_SUBST(CRYPTO_LIBS) +AC_DEFUN([LTP_CHECK_CRYPTO], [ + AC_CHECK_LIB([crypto], [SHA1_Init], [crypto_libs="-lcrypto"]) + AC_SUBST([CRYPTO_LIBS], [$crypto_libs]) + if test "x$have_libnuma" != "x"; then
^ Typo?
testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c line 32
Quoted 12 lines
m4/ltp-crypto.m4 +2
-0+ AC_DEFINE(HAVE_LIBCRYPTO,1,[define whether libcrypto is installed]) + fi ])testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c +1
-0@@ -29,6 +29,8 @@#include <openssl/sha.h> #endif +#if HAVE_LIBCRYPTO &&HAVE_OPENSSL_SHA_H
I wonder if we have to use both here, I guess that it's safer that way. But it would be cleaner if we changed the m4 checks not to set HAVE_LIBCRYPTO if either of the AC_CHECK_LIB() or AC_CHECK_HEADER() have failed.
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH v2 6/7 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
@@ -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
@@ -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
@@ -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
RFC PATCH v2 7/7 m4, kernel/lib: Detect libnuma presence in kernel libs
In reply to Petr VorelThis fixes link problems when NUMA headers are available but libnuma not (e.g. on 32-bit cross build).
--- m4/ltp-numa.m4 | 6 +++++- .../cpuset/cpuset_syscall_test/cpuset_syscall_test.c | 4 ++-- testcases/kernel/hotplug/memory_hotplug/commands.c | 2 +- testcases/kernel/hotplug/memory_hotplug/memtoy.c | 9 ++++----- testcases/kernel/hotplug/memory_hotplug/segment.c | 2 +- testcases/kernel/include/numa_helper.h | 2 +- testcases/kernel/lib/numa_helper.c | 14 +++++++------- testcases/kernel/mem/cpuset/cpuset01.c | 4 ++-- testcases/kernel/mem/ksm/ksm02.c | 4 ++-- testcases/kernel/mem/ksm/ksm04.c | 4 ++-- testcases/kernel/mem/lib/mem.c | 6 +++--- testcases/kernel/mem/vma/vma02.c | 17 ++++++----------- testcases/kernel/mem/vma/vma04.c | 16 +++++----------- .../kernel/syscalls/get_mempolicy/get_mempolicy01.c | 4 ++-- testcases/kernel/syscalls/mbind/mbind01.c | 4 ++-- .../kernel/syscalls/migrate_pages/migrate_pages02.c | 2 +- .../kernel/syscalls/move_pages/move_pages_support.c | 8 ++++---- 17 files changed, 50 insertions(+), 58 deletions(-)
m4/ltp-numa.m4 +5 -1
@@ -23,7 +23,11 @@ dnl LTP_CHECK_SYSCALL_NUMA dnl ---------------------------- dnl AC_DEFUN([LTP_CHECK_SYSCALL_NUMA], -[dnl +[ +AC_CHECK_LIB(numa,numa_available,[have_libnuma="yes"]) +if test "x$have_libnuma" = "xyes"; then + AC_DEFINE(HAVE_LIBNUMA,1,[define whether libnuma is installed]) +fi 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"])
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c +2 -2
@@ -51,7 +51,7 @@char *TCID ="cpuset_syscall_test" ;int TST_TOTAL =1 ; -#if HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ +#if HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ &&HAVE_MPOL_CONSTANTS #include "../cpuset_lib/cpuset.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" ); }#endif
testcases/kernel/hotplug/memory_hotplug/commands.c +1 -1
@@ -29,7 +29,7 @@*/ #include "config.h" -#if HAVE_NUMA_H &&HAVE_NUMAIF_H &&HAVE_LINUX_MEMPOLICY_H +#if HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_NUMAIF_H &&HAVE_LINUX_MEMPOLICY_H #include <linux/mempolicy.h> #include <sys/types.h> #include <sys/time.h>
testcases/kernel/hotplug/memory_hotplug/memtoy.c +4 -5
@@ -24,8 +24,7 @@#include <stdio.h> #include "config.h" -/* Shortcut because the test requires numa and mempolicy support. */ -#if HAVE_NUMA_H &&HAVE_NUMAIF_H &&HAVE_LINUX_MEMPOLICY_H +#if HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_NUMAIF_H &&HAVE_LINUX_MEMPOLICY_H #include <sys/types.h> #include <sys/time.h> #include <sys/mman.h>
@@ -491,10 +490,10 @@ int main(int argc, char *argv[]) return 0; } -#else /* ! (HAVE_NUMA_H && HAVE_NUMAIF_H) */ +#else /* HAVE_LIBNUMA && HAVE_NUMA_H && HAVE_NUMAIF_H && HAVE_LINUX_MEMPOLICY_H */ int main (void ) { -printf ("System doesn't have required numa support.\n" ); +printf ("test requires libnuma >= 2\n" );return 0 ; } -#endif /* HAVE_NUMA_H && HAVE_NUMAIF_H */ +#endif
testcases/kernel/hotplug/memory_hotplug/segment.c +1 -1
@@ -28,7 +28,7 @@*/ #include "config.h" -#if HAVE_NUMA_H &&HAVE_NUMAIF_H &&HAVE_LINUX_MEMPOLICY_H +#if HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_NUMAIF_H &&HAVE_LINUX_MEMPOLICY_H #include <sys/types.h> #include <sys/ipc.h> #include <sys/mman.h>
testcases/kernel/include/numa_helper.h +1 -1
@@ -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
@@ -39,7 +39,7 @@unsigned long get_max_node (void ) {unsigned long max_node =0 ; -#if HAVE_NUMA_H +#if HAVE_LIBNUMA &&HAVE_NUMA_H #if !defined(LIBNUMA_API_VERSION ) ||LIBNUMA_API_VERSION <2 max_node =NUMA_NUM_NODES ;/*
@@ -52,11 +52,11 @@ unsigned long get_max_node(void)#else max_node =numa_max_possible_node () +1 ;#endif -#endif /* HAVE_NUMA_H */ +#endif /* HAVE_LIBNUMA && HAVE_NUMA_H */ return max_node; } -#if HAVE_NUMA_H +#if HAVE_LIBNUMA &&HAVE_NUMA_H static void get_nodemask_allnodes (nodemask_t * nodemask,unsigned long max_node) {unsigned long nodemask_size = max_node /8 ;
@@ -145,7 +145,7 @@ static void filter_nodemask_cpu(nodemask_t * nodemask, unsigned long max_node) }free (cpumask); } -#endif /* HAVE_NUMA_H */ +#endif /* HAVE_LIBNUMA && HAVE_NUMA_H */ /* * get_allowed_nodes_arr - get number and array of available nodes
@@ -163,7 +163,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 +#if HAVE_LIBNUMA &&HAVE_NUMA_H int i;nodemask_t *nodemask =NULL ;#endif
@@ -171,7 +171,7 @@ int get_allowed_nodes_arr(int flag, int *num_nodes, int **nodes)if (nodes) *nodes =NULL ; -#if HAVE_NUMA_H +#if HAVE_LIBNUMA &&HAVE_NUMA_H unsigned long max_node, nodemask_size;if (numa_available () ==-1 )
@@ -209,7 +209,7 @@ int get_allowed_nodes_arr(int flag, int *num_nodes, int **nodes) } }while (0 );free (nodemask); -#endif +#endif /* HAVE_LIBNUMA && HAVE_NUMA_H */ return ret; }
testcases/kernel/mem/cpuset/cpuset01.c +2 -2
@@ -30,7 +30,7 @@#include "mem.h" #include "numa_helper.h" -#if HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ +#if HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ &&HAVE_MPOL_CONSTANTS volatile int end;static int *nodes;
@@ -187,5 +187,5 @@ static struct tst_test test = { };#else /* no NUMA */ -TST_TEST_TCONF ("no NUMA development packages installed." ); +TST_TEST_TCONF ("test requires libnuma >= 2" );#endif
testcases/kernel/mem/ksm/ksm02.c +2 -2
@@ -59,7 +59,7 @@#include "mem.h" #include "ksm_common.h" -#if HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ +#if HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ &&HAVE_MPOL_CONSTANTS static void verify_ksm (void )
@@ -122,5 +122,5 @@ static struct tst_test test = { };#else /* no NUMA */ -TST_TEST_TCONF ("no NUMA development packages installed." ); +TST_TEST_TCONF ("test requires libnuma and NUMA development packages" );#endif
testcases/kernel/mem/ksm/ksm04.c +2 -2
@@ -59,7 +59,7 @@#include "mem.h" #include "ksm_common.h" -#if HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ +#if HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ &&HAVE_MPOL_CONSTANTS static void verify_ksm (void )
@@ -126,5 +126,5 @@ static struct tst_test test = { };#else /* no NUMA */ -TST_TEST_TCONF ("no NUMA development packages installed." ); +TST_TEST_TCONF ("test requires libnuma and NUMA development packages" );#endif
testcases/kernel/mem/lib/mem.c +3 -3
@@ -164,7 +164,7 @@ void oom(int testcase, int lite, int retcode, int allow_sigkill)static void set_global_mempolicy (int mempolicy) { -#if HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ +#if HAVE_LIBNUMA &&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;
@@ -562,7 +562,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 \ +#if HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ &&HAVE_MPOL_CONSTANTS 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_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ +#if HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ &&HAVE_MPOL_CONSTANTS clean_node (nmask);set_node (nmask, nodes[i]);
testcases/kernel/mem/vma/vma02.c +6 -11
@@ -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_LIBNUMA &&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,15 +163,10 @@ 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 */ + +#else /* libnuma >= 2 */ int main (void ) { -tst_brkm (TCONF ,NULL ,"no NUMA development packages installed." ); +tst_brkm (TCONF ,NULL ,"test requires libnuma >= 2" ); }#endif
testcases/kernel/mem/vma/vma04.c +5 -11
@@ -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_LIBNUMA &&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,15 +325,9 @@ 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 */ +#else /* libnuma >= 2 */ int main (void ) { -tst_brkm (TCONF ,NULL ,"no NUMA development packages installed." ); +tst_brkm (TCONF ,NULL ,"test requires libnuma >= 2" ); }#endif
testcases/kernel/syscalls/get_mempolicy/get_mempolicy01.c +2 -2
@@ -66,7 +66,7 @@char *TCID ="get_mempolicy01" ;int TST_TOTAL =1 ; -#if HAVE_NUMA_H &&HAVE_NUMAIF_H &&HAVE_MPOL_CONSTANTS +#if HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_NUMAIF_H &&HAVE_MPOL_CONSTANTS #define MEM_LENGTH (4 * 1024 * 1024)
@@ -348,6 +348,6 @@ static void setup(void)#else int main (void ) { -tst_brkm (TCONF ,NULL ,"System doesn't have required numa support" ); +tst_brkm (TCONF ,NULL ,"test requires libnuma >= 2" ); }#endif
testcases/kernel/syscalls/mbind/mbind01.c +2 -2
@@ -26,7 +26,7 @@#include "numa_helper.h" #include "tst_test.h" -#if HAVE_NUMA_H &&HAVE_NUMAIF_H &&HAVE_MPOL_CONSTANTS && \ +#if HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_NUMAIF_H &&HAVE_MPOL_CONSTANTS && \ defined(LIBNUMA_API_VERSION ) &&LIBNUMA_API_VERSION >=2 #define MEM_LENGTH (4 * 1024 * 1024)
@@ -234,5 +234,5 @@ static struct tst_test test = { };#else /* libnuma >= 2 */ -TST_TEST_TCONF ("test requires libnuma >= 2." ); +TST_TEST_TCONF ("test requires libnuma >= 2" );#endif
testcases/kernel/syscalls/migrate_pages/migrate_pages02.c +1 -1
@@ -65,7 +65,7 @@char *TCID ="migrate_pages02" ;int TST_TOTAL =1 ; -#if defined(__NR_migrate_pages) &&HAVE_NUMA_H &&HAVE_NUMAIF_H +#if defined(__NR_migrate_pages) &&HAVE_LIBNUMA &&HAVE_NUMA_H &&HAVE_NUMAIF_H static const char nobody_uid[] ="nobody" ;static struct passwd *ltpuser;static int *nodes, nodeA, nodeB;
testcases/kernel/syscalls/move_pages/move_pages_support.c +4 -4
@@ -36,7 +36,7 @@ long get_page_size(void)void free_pages (void **pages,unsigned int num) { -#if HAVE_NUMA_H +#if HAVE_LIBNUMA &&HAVE_NUMA_H int i;size_t onepage =get_page_size ();
@@ -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 &&HAVE_NUMA_H unsigned int i;int which_node;int ret;
@@ -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 &&HAVE_NUMA_H 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 &&HAVE_NUMA_H &&HAVE_NUMAIF_H int num_allowed_nodes;int ret;
Signature · 1 line
2.14.2
RFC PATCH v2 7/7 m4, kernel/lib: Detect libnuma presence in kernel libs
Hi!
Quoted 1 line
+#if
HAVE_LIBNUMA&&HAVE_NUMA_H
I guess that the HAVE_LIBNUMA and HAVE_NUMA_H could be combined to HAVE_LIBNUMA as well, if we find a reasonable solution.
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH v2 7/7 m4, kernel/lib: Detect libnuma presence in kernel libs
Quoted 5 lines
Hi!
Quoted 1 line
+#if
HAVE_LIBNUMA&&HAVE_NUMA_HI guess that the
HAVE_LIBNUMAandHAVE_NUMA_Hcould be combined toHAVE_LIBNUMAas well, if we find a reasonable solution.
Right, should be possible, the same way as combining HAVE_LIBCRYPTO and HAVE_OPENSSL_SHA_H you suggested in previous patch.
Kind regards,
Petr
v2 cover Fix 32-bit cross compilation
In reply to Petr VorelHello Petr,
I think this also requires a fix for libaio. Currently we just check for libaio.h in configure.ac.
Signature · 2 lines
Thank you, Richard.
v2 cover Fix 32-bit cross compilation
Hi Richard,
Quoted 2 lines
I think this also requires a fix for libaio. Currently we just check for
libaio.hin configure.ac.
Thanks! I'll include it in v3 (or in separate version in case v2 gets merged).
Kind regards,
Petr