Skip to content

Commit f82b61d

Browse files
committed
Merge tag 'locking_futex_for_v7.1_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull futex selftest updates from Borislav Petkov: - Correct the version guard for the futex_numa_mpol test to require libnuma 2.0.18 instead of 2.0.16, which is the version that actually introduced numa_set_mempolicy_home_node() used by the test - Allow the futex_numa_mpol selftest to build and run on systems without libnuma installed with affected test gracefully being skipped instead of failing to compile - Use the proper assertion macros so that individual sub-test failures are correctly propagated and the test suite reports failure when something goes wrong * tag 'locking_futex_for_v7.1_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: selftests/futex: Bump up libnuma version check selftests/futex: Conditionally include libnuma support selftests/futex: Fix incorrect result reporting of futex_requeue test item
2 parents 334fbe7 + b374977 commit f82b61d

3 files changed

Lines changed: 16 additions & 44 deletions

File tree

tools/testing/selftests/futex/functional/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# SPDX-License-Identifier: GPL-2.0
22
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")
3+
LIBNUMA_TEST = $(shell sh -c "$(PKG_CONFIG) numa --atleast-version 2.0.18 > /dev/null 2>&1 && echo SUFFICIENT || echo NO")
44

55
INCLUDES := -I../include -I../../ $(KHDR_INCLUDES)
66
CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 $(INCLUDES) $(KHDR_INCLUDES) -DLIBNUMA_VER_$(LIBNUMA_TEST)=1
7-
LDLIBS := -lpthread -lrt -lnuma
7+
LDLIBS := -lpthread -lrt
8+
ifeq ($(LIBNUMA_TEST),SUFFICIENT)
9+
LDLIBS += -lnuma
10+
endif
811

912
LOCAL_HDRS := \
1013
../include/futextest.h \

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
#include <stdio.h>
1111
#include <stdlib.h>
1212
#include <unistd.h>
13+
#ifdef LIBNUMA_VER_SUFFICIENT
1314
#include <numa.h>
1415
#include <numaif.h>
16+
#endif
1517

1618
#include <linux/futex.h>
1719
#include <sys/mman.h>
@@ -206,7 +208,7 @@ TEST(futex_numa_mpol)
206208
}
207209
ksft_test_result_pass("futex2 MPOL hints test passed\n");
208210
#else
209-
ksft_test_result_skip("futex2 MPOL hints test requires libnuma 2.0.16+\n");
211+
ksft_test_result_skip("futex2 MPOL hints test requires libnuma 2.0.18+\n");
210212
#endif
211213
munmap(futex_ptr, mem_size * 2);
212214
}

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

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -34,73 +34,40 @@ TEST(requeue_single)
3434
volatile futex_t _f1 = 0;
3535
volatile futex_t f2 = 0;
3636
pthread_t waiter[10];
37-
int res;
3837

3938
f1 = &_f1;
4039

4140
/*
4241
* Requeue a waiter from f1 to f2, and wake f2.
4342
*/
44-
if (pthread_create(&waiter[0], NULL, waiterfn, NULL))
45-
ksft_exit_fail_msg("pthread_create failed\n");
43+
ASSERT_EQ(0, pthread_create(&waiter[0], NULL, waiterfn, NULL));
4644

4745
usleep(WAKE_WAIT_US);
4846

49-
ksft_print_dbg_msg("Requeuing 1 futex from f1 to f2\n");
50-
res = futex_cmp_requeue(f1, 0, &f2, 0, 1, 0);
51-
if (res != 1)
52-
ksft_test_result_fail("futex_requeue simple returned: %d %s\n",
53-
res ? errno : res,
54-
res ? strerror(errno) : "");
55-
56-
ksft_print_dbg_msg("Waking 1 futex at f2\n");
57-
res = futex_wake(&f2, 1, 0);
58-
if (res != 1) {
59-
ksft_test_result_fail("futex_requeue simple returned: %d %s\n",
60-
res ? errno : res,
61-
res ? strerror(errno) : "");
62-
} else {
63-
ksft_test_result_pass("futex_requeue simple succeeds\n");
64-
}
47+
EXPECT_EQ(1, futex_cmp_requeue(f1, 0, &f2, 0, 1, 0));
48+
EXPECT_EQ(1, futex_wake(&f2, 1, 0));
6549
}
6650

6751
TEST(requeue_multiple)
6852
{
6953
volatile futex_t _f1 = 0;
7054
volatile futex_t f2 = 0;
7155
pthread_t waiter[10];
72-
int res, i;
56+
int i;
7357

7458
f1 = &_f1;
7559

7660
/*
7761
* Create 10 waiters at f1. At futex_requeue, wake 3 and requeue 7.
7862
* At futex_wake, wake INT_MAX (should be exactly 7).
7963
*/
80-
for (i = 0; i < 10; i++) {
81-
if (pthread_create(&waiter[i], NULL, waiterfn, NULL))
82-
ksft_exit_fail_msg("pthread_create failed\n");
83-
}
64+
for (i = 0; i < 10; i++)
65+
ASSERT_EQ(0, pthread_create(&waiter[i], NULL, waiterfn, NULL));
8466

8567
usleep(WAKE_WAIT_US);
8668

87-
ksft_print_dbg_msg("Waking 3 futexes at f1 and requeuing 7 futexes from f1 to f2\n");
88-
res = futex_cmp_requeue(f1, 0, &f2, 3, 7, 0);
89-
if (res != 10) {
90-
ksft_test_result_fail("futex_requeue many returned: %d %s\n",
91-
res ? errno : res,
92-
res ? strerror(errno) : "");
93-
}
94-
95-
ksft_print_dbg_msg("Waking INT_MAX futexes at f2\n");
96-
res = futex_wake(&f2, INT_MAX, 0);
97-
if (res != 7) {
98-
ksft_test_result_fail("futex_requeue many returned: %d %s\n",
99-
res ? errno : res,
100-
res ? strerror(errno) : "");
101-
} else {
102-
ksft_test_result_pass("futex_requeue many succeeds\n");
103-
}
69+
EXPECT_EQ(10, futex_cmp_requeue(f1, 0, &f2, 3, 7, 0));
70+
EXPECT_EQ(7, futex_wake(&f2, INT_MAX, 0));
10471
}
10572

10673
TEST_HARNESS_MAIN

0 commit comments

Comments
 (0)