Skip to content

Commit b527e51

Browse files
committed
selftest/futex: Compile also with libnuma < 2.0.16
JIRA: https://issues.redhat.com/browse/RHEL-101190 commit ed323ae Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Date: Mon, 15 Sep 2025 23:26:30 +0200 selftest/futex: Compile also with libnuma < 2.0.16 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: 0ecb423 ("selftests/futex: Set the home_node in futex_numa_mpol") Closes: https://lore.kernel.org/oe-lkp/202507150858.bedaf012-lkp@intel.com Reported-by: kernel test robot <oliver.sang@intel.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Waiman Long <longman@redhat.com>
1 parent 02b32ac commit b527e51

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

tools/testing/selftests/futex/functional/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# SPDX-License-Identifier: GPL-2.0
2+
PKG_CONFIG ?= pkg-config
3+
LIBNUMA_TEST = $(shell sh -c "$(PKG_CONFIG) numa --atleast-version 2.0.16 > /dev/null 2>&1 && echo SUFFICIENT || echo NO")
4+
25
INCLUDES := -I../include -I../../ $(KHDR_INCLUDES)
3-
CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 $(INCLUDES) $(KHDR_INCLUDES)
6+
CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 $(INCLUDES) $(KHDR_INCLUDES) -DLIBNUMA_VER_$(LIBNUMA_TEST)=1
47
LDLIBS := -lpthread -lrt -lnuma
58

69
LOCAL_HDRS := \

tools/testing/selftests/futex/functional/futex_numa_mpol.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ static void test_futex(void *futex_ptr, int err_value)
131131
__test_futex(futex_ptr, err_value, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_NUMA);
132132
}
133133

134-
static void test_futex_mpol(void *futex_ptr, int err_value)
135-
{
136-
__test_futex(futex_ptr, err_value, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_NUMA | FUTEX2_MPOL);
137-
}
138-
139134
static void usage(char *prog)
140135
{
141136
printf("Usage: %s\n", prog);
@@ -148,7 +143,7 @@ static void usage(char *prog)
148143
int main(int argc, char *argv[])
149144
{
150145
struct futex32_numa *futex_numa;
151-
int mem_size, i;
146+
int mem_size;
152147
void *futex_ptr;
153148
int c;
154149

@@ -171,7 +166,7 @@ int main(int argc, char *argv[])
171166
}
172167

173168
ksft_print_header();
174-
ksft_set_plan(1);
169+
ksft_set_plan(2);
175170

176171
mem_size = sysconf(_SC_PAGE_SIZE);
177172
futex_ptr = mmap(NULL, mem_size * 2, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
@@ -211,8 +206,11 @@ int main(int argc, char *argv[])
211206
ksft_print_msg("Memory back to RW\n");
212207
test_futex(futex_ptr, 0);
213208

209+
ksft_test_result_pass("futex2 memory boundarie tests passed\n");
210+
214211
/* MPOL test. Does not work as expected */
215-
for (i = 0; i < 4; i++) {
212+
#ifdef LIBNUMA_VER_SUFFICIENT
213+
for (int i = 0; i < 4; i++) {
216214
unsigned long nodemask;
217215
int ret;
218216

@@ -231,15 +229,16 @@ int main(int argc, char *argv[])
231229
ret = futex2_wake(futex_ptr, 0, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_NUMA | FUTEX2_MPOL);
232230
if (ret < 0)
233231
ksft_test_result_fail("Failed to wake 0 with MPOL: %m\n");
234-
if (0)
235-
test_futex_mpol(futex_numa, 0);
236232
if (futex_numa->numa != i) {
237233
ksft_exit_fail_msg("Returned NUMA node is %d expected %d\n",
238234
futex_numa->numa, i);
239235
}
240236
}
241237
}
242-
ksft_test_result_pass("NUMA MPOL tests passed\n");
238+
ksft_test_result_pass("futex2 MPOL hints test passed\n");
239+
#else
240+
ksft_test_result_skip("futex2 MPOL hints test requires libnuma 2.0.16+\n");
241+
#endif
243242
ksft_finished();
244243
return 0;
245244
}

0 commit comments

Comments
 (0)