linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [linus:master] [selftests/futex]  0ecb4232fc: kernel-selftests.futex/functional.make.fail
@ 2025-07-15  7:36 kernel test robot
  2025-07-15  7:57 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 5+ messages in thread
From: kernel test robot @ 2025-07-15  7:36 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: oe-lkp, lkp, linux-kernel, Peter Zijlstra, Vlastimil Babka,
	oliver.sang



Hello,

kernel test robot noticed "kernel-selftests.futex/functional.make.fail" on:

commit: 0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d ("selftests/futex: Set the home_node in futex_numa_mpol")
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master

[test failed on linus/master      bc9ff192a6c940d9a26e21a0a82f2667067aaf5f]
[test failed on linux-next/master b551c4e2a98a177a06148cf16505643cd2108386]

in testcase: kernel-selftests
version: kernel-selftests-x86_64-7ff71e6d9239-1_20250215
with following parameters:

	group: futex



config: x86_64-rhel-9.4-kselftests
compiler: gcc-12
test machine: 36 threads 1 sockets Intel(R) Core(TM) i9-9980XE CPU @ 3.00GHz (Skylake) with 32G memory

(please refer to attached dmesg/kmsg for entire log/backtrace)




If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202507150858.bedaf012-lkp@intel.com

KERNEL SELFTESTS: linux_headers_dir is /usr/src/linux-headers-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d
2025-07-10 23:09:01 sed -i s/default_timeout=45/default_timeout=300/ kselftest/runner.sh
2025-07-10 23:09:01 make -j36 TARGETS=futex/functional
make[1]: Entering directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional'
  CC       futex_wait_timeout
  CC       futex_wait_wouldblock
  CC       futex_requeue_pi
  CC       futex_requeue_pi_mismatched_ops
  CC       futex_wait_uninitialized_heap
  CC       futex_requeue_pi_signal_restart
  CC       futex_wait_private_mapped_file
  CC       futex_wait
  CC       futex_requeue
  CC       futex_priv_hash
  CC       futex_numa_mpol
  CC       futex_waitv
  CC       futex_numa
futex_numa_mpol.c: In function ‘main’:
futex_numa_mpol.c:213:31: warning: implicit declaration of function ‘numa_set_mempolicy_home_node’; did you mean ‘SYS_set_mempolicy_home_node’? [-Wimplicit-function-declaration]
  213 |                         ret = numa_set_mempolicy_home_node(futex_ptr, mem_size, i, 0);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                               SYS_set_mempolicy_home_node
/usr/bin/ld: /tmp/ccifp3lK.o: in function `main':
/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional/futex_numa_mpol.c:213: undefined reference to `numa_set_mempolicy_home_node'
collect2: error: ld returned 1 exit status
make[1]: *** [../../lib.mk:221: /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional/futex_numa_mpol] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional'
make: *** [Makefile:207: all] Error 2
2025-07-10 23:09:02 make -j36 TARGETS=futex
make[1]: Entering directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex'
  CC       futex_numa_mpol
futex_numa_mpol.c: In function ‘main’:
futex_numa_mpol.c:213:31: warning: implicit declaration of function ‘numa_set_mempolicy_home_node’; did you mean ‘SYS_set_mempolicy_home_node’? [-Wimplicit-function-declaration]
  213 |                         ret = numa_set_mempolicy_home_node(futex_ptr, mem_size, i, 0);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                               SYS_set_mempolicy_home_node
/usr/bin/ld: /tmp/ccT08B2V.o: in function `main':
/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional/futex_numa_mpol.c:213: undefined reference to `numa_set_mempolicy_home_node'
collect2: error: ld returned 1 exit status
make[2]: *** [../../lib.mk:222: /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional/futex_numa_mpol] Error 1
make[1]: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex'
2025-07-10 23:09:02 make -j36 TARGETS=futex install
make[1]: Entering directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex'
  CC       futex_numa_mpol
futex_numa_mpol.c: In function ‘main’:
futex_numa_mpol.c:213:31: warning: implicit declaration of function ‘numa_set_mempolicy_home_node’; did you mean ‘SYS_set_mempolicy_home_node’? [-Wimplicit-function-declaration]
  213 |                         ret = numa_set_mempolicy_home_node(futex_ptr, mem_size, i, 0);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                               SYS_set_mempolicy_home_node
/usr/bin/ld: /tmp/ccpPRT4b.o: in function `main':
/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional/futex_numa_mpol.c:213: undefined reference to `numa_set_mempolicy_home_node'
collect2: error: ld returned 1 exit status
make[2]: *** [../../lib.mk:222: /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional/futex_numa_mpol] Error 1
make[1]: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex'
mkdir -p /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/kselftest_install/kselftest
install -m 744 kselftest/module.sh /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/kselftest_install/kselftest/
install -m 744 kselftest/runner.sh /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/kselftest_install/kselftest/
install -m 744 kselftest/prefix.pl /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/kselftest_install/kselftest/
install -m 744 kselftest/ktap_helpers.sh /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/kselftest_install/kselftest/
install -m 744 kselftest/ksft.py /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/kselftest_install/kselftest/
install -m 744 run_kselftest.sh /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/kselftest_install/
rm -f /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/kselftest_install/kselftest-list.txt
make[1]: Entering directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex'
  CC       futex_numa_mpol
futex_numa_mpol.c: In function ‘main’:
futex_numa_mpol.c:213:31: warning: implicit declaration of function ‘numa_set_mempolicy_home_node’; did you mean ‘SYS_set_mempolicy_home_node’? [-Wimplicit-function-declaration]
  213 |                         ret = numa_set_mempolicy_home_node(futex_ptr, mem_size, i, 0);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                               SYS_set_mempolicy_home_node
/usr/bin/ld: /tmp/ccLRFTsP.o: in function `main':
/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional/futex_numa_mpol.c:213: undefined reference to `numa_set_mempolicy_home_node'
collect2: error: ld returned 1 exit status
make[2]: *** [../../lib.mk:222: /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional/futex_numa_mpol] Error 1
mkdir -p /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/kselftest_install/futex
install -t /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/kselftest_install/futex run.sh  
make[2]: Entering directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex'
make[2]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
  CC       futex_numa_mpol
futex_numa_mpol.c: In function ‘main’:
futex_numa_mpol.c:213:31: warning: implicit declaration of function ‘numa_set_mempolicy_home_node’; did you mean ‘SYS_set_mempolicy_home_node’? [-Wimplicit-function-declaration]
  213 |                         ret = numa_set_mempolicy_home_node(futex_ptr, mem_size, i, 0);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                               SYS_set_mempolicy_home_node
/usr/bin/ld: /tmp/cco6y6tU.o: in function `main':
/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional/futex_numa_mpol.c:213: undefined reference to `numa_set_mempolicy_home_node'
collect2: error: ld returned 1 exit status
make[2]: *** [../../lib.mk:222: /usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional/futex_numa_mpol] Error 1
make[2]: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional'
make[1]: *** [../lib.mk:175: install] Error 2
make[1]: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex'
make: *** [Makefile:272: install] Error 2



The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20250715/202507150858.bedaf012-lkp@intel.com



-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linus:master] [selftests/futex]  0ecb4232fc: kernel-selftests.futex/functional.make.fail
  2025-07-15  7:36 [linus:master] [selftests/futex] 0ecb4232fc: kernel-selftests.futex/functional.make.fail kernel test robot
@ 2025-07-15  7:57 ` Sebastian Andrzej Siewior
  2025-07-15  9:52   ` [PATCH] selftests/futex: Compile also on libnuma < 2.0.16 Sebastian Andrzej Siewior
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-07-15  7:57 UTC (permalink / raw)
  To: kernel test robot
  Cc: oe-lkp, lkp, linux-kernel, Peter Zijlstra, Vlastimil Babka

On 2025-07-15 15:36:13 [+0800], kernel test robot wrote:
> 
> 
> Hello,
> 
> kernel test robot noticed "kernel-selftests.futex/functional.make.fail" on:
> 
> commit: 0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d ("selftests/futex: Set the home_node in futex_numa_mpol")
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master
> 
> [test failed on linus/master      bc9ff192a6c940d9a26e21a0a82f2667067aaf5f]
> [test failed on linux-next/master b551c4e2a98a177a06148cf16505643cd2108386]
> 
> in testcase: kernel-selftests
> version: kernel-selftests-x86_64-7ff71e6d9239-1_20250215
> with following parameters:
> 
> 	group: futex
> make[1]: Entering directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-0ecb4232fc65e659ca7020f8bb2e0fc347acfb7d/tools/testing/selftests/futex/functional'
> futex_numa_mpol.c: In function ‘main’:
> futex_numa_mpol.c:213:31: warning: implicit declaration of function ‘numa_set_mempolicy_home_node’; did you mean ‘SYS_set_mempolicy_home_node’? [-Wimplicit-function-declaration]
>   213 |                         ret = numa_set_mempolicy_home_node(futex_ptr, mem_size, i, 0);
>       |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       |                               SYS_set_mempolicy_home_node

I assume libnuma-dev is around because there are not any other warnings.
That is unfortunate but it seems that numa_set_mempolicy_home_node() is
only around since v2.0.18.
Is and update doable? Otherwise I would have to disable the test.

Sebastian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] selftests/futex: Compile also on libnuma < 2.0.16
  2025-07-15  7:57 ` Sebastian Andrzej Siewior
@ 2025-07-15  9:52   ` Sebastian Andrzej Siewior
  2025-07-21 17:22     ` Thomas Gleixner
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-07-15  9:52 UTC (permalink / raw)
  To: kernel test robot
  Cc: oe-lkp, lkp, linux-kernel, Peter Zijlstra, Vlastimil Babka

After using numa_set_mempolicy_home_node() the test fails to compile on
systems with libnuma library versioned lower than 2.0.16.

In order to allow lower library version add a pkg-config related check
and exclude that part of the code. Without the proper MPOL setup it
can't be tested.

Make a total number of tests two. The first one is the first batch and
the second is the MPOL related one. The goal is to let the user know if
it has been skipped due to library limitation.

Remove test_futex_mpol(), it was unused and it is now complained by the
compiler if the part is not compiled.

Mark the variable i __maybe_unused since the compiler now complains if
the MPOL tests are not compiled.

Fixes: 0ecb4232fc65e ("selftests/futex: Set the home_node in futex_numa_mpol")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202507150858.bedaf012-lkp@intel.com
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 .../selftests/futex/functional/Makefile       |  5 ++++-
 .../futex/functional/futex_numa_mpol.c        | 21 ++++++++++---------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
index 8cfb87f7f7c50..361631828629c 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -1,6 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
+PKG_CONFIG ?= pkg-config
+LIBNUMA_TEST = $(shell sh -c "$(PKG_CONFIG) numa --atleast-version 2.0.16 > /dev/null 2>&1 && echo SUFFICIENT || echo NO")
+
 INCLUDES := -I../include -I../../ $(KHDR_INCLUDES)
-CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread $(INCLUDES) $(KHDR_INCLUDES)
+CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread $(INCLUDES) $(KHDR_INCLUDES) -DLIBUNMA_VER_$(LIBNUMA_TEST)=1
 LDLIBS := -lpthread -lrt -lnuma
 
 LOCAL_HDRS := \
diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
index a9ecfb2d3932a..a8af1657da083 100644
--- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c
+++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
@@ -22,6 +22,8 @@
 
 #define MAX_THREADS	64
 
+#define __maybe_unused __attribute__((__unused__))
+
 static pthread_barrier_t barrier_main;
 static pthread_t threads[MAX_THREADS];
 
@@ -125,11 +127,6 @@ static void test_futex(void *futex_ptr, int must_fail)
 	__test_futex(futex_ptr, must_fail, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_NUMA);
 }
 
-static void test_futex_mpol(void *futex_ptr, int must_fail)
-{
-	__test_futex(futex_ptr, must_fail, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_NUMA | FUTEX2_MPOL);
-}
-
 static void usage(char *prog)
 {
 	printf("Usage: %s\n", prog);
@@ -142,7 +139,7 @@ static void usage(char *prog)
 int main(int argc, char *argv[])
 {
 	struct futex32_numa *futex_numa;
-	int mem_size, i;
+	int mem_size, i __maybe_unused;
 	void *futex_ptr;
 	int c;
 
@@ -165,7 +162,7 @@ int main(int argc, char *argv[])
 	}
 
 	ksft_print_header();
-	ksft_set_plan(1);
+	ksft_set_plan(2);
 
 	mem_size = sysconf(_SC_PAGE_SIZE);
 	futex_ptr = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
@@ -201,7 +198,10 @@ int main(int argc, char *argv[])
 	ksft_print_msg("Memory back to RW\n");
 	test_futex(futex_ptr, 0);
 
+	ksft_test_result_pass("futex2 memory boundarie tests passed\n");
+
 	/* MPOL test. Does not work as expected */
+#ifdef LIBUNMA_VER_SUFFICIENT
 	for (i = 0; i < 4; i++) {
 		unsigned long nodemask;
 		int ret;
@@ -221,15 +221,16 @@ int main(int argc, char *argv[])
 			ret = futex2_wake(futex_ptr, 0, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_NUMA | FUTEX2_MPOL);
 			if (ret < 0)
 				ksft_test_result_fail("Failed to wake 0 with MPOL: %m\n");
-			if (0)
-				test_futex_mpol(futex_numa, 0);
 			if (futex_numa->numa != i) {
 				ksft_exit_fail_msg("Returned NUMA node is %d expected %d\n",
 						   futex_numa->numa, i);
 			}
 		}
 	}
-	ksft_test_result_pass("NUMA MPOL tests passed\n");
+	ksft_test_result_pass("futex2 MPOL hints test passed\n");
+#else
+	ksft_test_result_skip("futex2 MPOL hints. Reqiuire libnuma 2.0.16+\n");
+#endif
 	ksft_finished();
 	return 0;
 }
-- 
2.50.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/futex: Compile also on libnuma < 2.0.16
  2025-07-15  9:52   ` [PATCH] selftests/futex: Compile also on libnuma < 2.0.16 Sebastian Andrzej Siewior
@ 2025-07-21 17:22     ` Thomas Gleixner
  2025-08-18 13:54       ` [PATCH v2] " Sebastian Andrzej Siewior
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2025-07-21 17:22 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, kernel test robot
  Cc: oe-lkp, lkp, linux-kernel, Peter Zijlstra, Vlastimil Babka

On Tue, Jul 15 2025 at 11:52, Sebastian Andrzej Siewior wrote:
>  INCLUDES := -I../include -I../../ $(KHDR_INCLUDES)
> -CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread $(INCLUDES) $(KHDR_INCLUDES)
> +CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread $(INCLUDES) $(KHDR_INCLUDES) -DLIBUNMA_VER_$(LIBNUMA_TEST)=1

LIBUNMA?

>  int main(int argc, char *argv[])
>  {
>  	struct futex32_numa *futex_numa;
> -	int mem_size, i;
> +	int mem_size, i __maybe_unused;

Why this unused muck?

> +#ifdef LIBUNMA_VER_SUFFICIENT
>  	for (i = 0; i < 4; i++) {

if you can just do

       for (int i = 0; ...

?

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] selftests/futex: Compile also on libnuma < 2.0.16
  2025-07-21 17:22     ` Thomas Gleixner
@ 2025-08-18 13:54       ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-08-18 13:54 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: kernel test robot, oe-lkp, lkp, linux-kernel, Peter Zijlstra,
	Vlastimil Babka

After using numa_set_mempolicy_home_node() the test fails to compile on
systems with libnuma library versioned lower than 2.0.16.

In order to allow lower library version add a pkg-config related check
and exclude that part of the code. Without the proper MPOL setup it
can't be tested.

Make a total number of tests two. The first one is the first batch and
the second is the MPOL related one. The goal is to let the user know if
it has been skipped due to library limitation.

Remove test_futex_mpol(), it was unused and it is now complained by the
compiler if the part is not compiled.

Fixes: 0ecb4232fc65e ("selftests/futex: Set the home_node in futex_numa_mpol")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202507150858.bedaf012-lkp@intel.com
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
v1…v2:
   - typo in LIBNUMA fixed
   - avoid __maybe_unused

 .../selftests/futex/functional/Makefile       |  5 ++++-
 .../futex/functional/futex_numa_mpol.c        | 21 +++++++++----------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
index 8cfb87f7f7c50..6f7887f585afb 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -1,6 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
+PKG_CONFIG ?= pkg-config
+LIBNUMA_TEST = $(shell sh -c "$(PKG_CONFIG) numa --atleast-version 2.0.16 > /dev/null 2>&1 && echo SUFFICIENT || echo NO")
+
 INCLUDES := -I../include -I../../ $(KHDR_INCLUDES)
-CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread $(INCLUDES) $(KHDR_INCLUDES)
+CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread $(INCLUDES) $(KHDR_INCLUDES) -DLIBNUMA_VER_$(LIBNUMA_TEST)=1
 LDLIBS := -lpthread -lrt -lnuma
 
 LOCAL_HDRS := \
diff --git a/tools/testing/selftests/futex/functional/futex_numa_mpol.c b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
index a9ecfb2d3932a..120ea7d5a3cf9 100644
--- a/tools/testing/selftests/futex/functional/futex_numa_mpol.c
+++ b/tools/testing/selftests/futex/functional/futex_numa_mpol.c
@@ -125,11 +125,6 @@ static void test_futex(void *futex_ptr, int must_fail)
 	__test_futex(futex_ptr, must_fail, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_NUMA);
 }
 
-static void test_futex_mpol(void *futex_ptr, int must_fail)
-{
-	__test_futex(futex_ptr, must_fail, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_NUMA | FUTEX2_MPOL);
-}
-
 static void usage(char *prog)
 {
 	printf("Usage: %s\n", prog);
@@ -142,7 +137,7 @@ static void usage(char *prog)
 int main(int argc, char *argv[])
 {
 	struct futex32_numa *futex_numa;
-	int mem_size, i;
+	int mem_size;
 	void *futex_ptr;
 	int c;
 
@@ -165,7 +160,7 @@ int main(int argc, char *argv[])
 	}
 
 	ksft_print_header();
-	ksft_set_plan(1);
+	ksft_set_plan(2);
 
 	mem_size = sysconf(_SC_PAGE_SIZE);
 	futex_ptr = mmap(NULL, mem_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
@@ -201,8 +196,11 @@ int main(int argc, char *argv[])
 	ksft_print_msg("Memory back to RW\n");
 	test_futex(futex_ptr, 0);
 
+	ksft_test_result_pass("futex2 memory boundarie tests passed\n");
+
 	/* MPOL test. Does not work as expected */
-	for (i = 0; i < 4; i++) {
+#ifdef LIBNUMA_VER_SUFFICIENT
+	for (int i = 0; i < 4; i++) {
 		unsigned long nodemask;
 		int ret;
 
@@ -221,15 +219,16 @@ int main(int argc, char *argv[])
 			ret = futex2_wake(futex_ptr, 0, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_NUMA | FUTEX2_MPOL);
 			if (ret < 0)
 				ksft_test_result_fail("Failed to wake 0 with MPOL: %m\n");
-			if (0)
-				test_futex_mpol(futex_numa, 0);
 			if (futex_numa->numa != i) {
 				ksft_exit_fail_msg("Returned NUMA node is %d expected %d\n",
 						   futex_numa->numa, i);
 			}
 		}
 	}
-	ksft_test_result_pass("NUMA MPOL tests passed\n");
+	ksft_test_result_pass("futex2 MPOL hints test passed\n");
+#else
+	ksft_test_result_skip("futex2 MPOL hints test requires libnuma 2.0.16+\n");
+#endif
 	ksft_finished();
 	return 0;
 }
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-08-18 13:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15  7:36 [linus:master] [selftests/futex] 0ecb4232fc: kernel-selftests.futex/functional.make.fail kernel test robot
2025-07-15  7:57 ` Sebastian Andrzej Siewior
2025-07-15  9:52   ` [PATCH] selftests/futex: Compile also on libnuma < 2.0.16 Sebastian Andrzej Siewior
2025-07-21 17:22     ` Thomas Gleixner
2025-08-18 13:54       ` [PATCH v2] " Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).