Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+16 -44
+5 -2
tools/testing/selftests/futex/functional/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 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") 3 + LIBNUMA_TEST = $(shell sh -c "$(PKG_CONFIG) numa --atleast-version 2.0.18 > /dev/null 2>&1 && echo SUFFICIENT || echo NO") 4 4 5 5 INCLUDES := -I../include -I../../ $(KHDR_INCLUDES) 6 6 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 8 11 9 12 LOCAL_HDRS := \ 10 13 ../include/futextest.h \
+3 -1
tools/testing/selftests/futex/functional/futex_numa_mpol.c
··· 10 10 #include <stdio.h> 11 11 #include <stdlib.h> 12 12 #include <unistd.h> 13 + #ifdef LIBNUMA_VER_SUFFICIENT 13 14 #include <numa.h> 14 15 #include <numaif.h> 16 + #endif 15 17 16 18 #include <linux/futex.h> 17 19 #include <sys/mman.h> ··· 208 206 } 209 207 ksft_test_result_pass("futex2 MPOL hints test passed\n"); 210 208 #else 211 - ksft_test_result_skip("futex2 MPOL hints test requires libnuma 2.0.16+\n"); 209 + ksft_test_result_skip("futex2 MPOL hints test requires libnuma 2.0.18+\n"); 212 210 #endif 213 211 munmap(futex_ptr, mem_size * 2); 214 212 }
+8 -41
tools/testing/selftests/futex/functional/futex_requeue.c
··· 34 34 volatile futex_t _f1 = 0; 35 35 volatile futex_t f2 = 0; 36 36 pthread_t waiter[10]; 37 - int res; 38 37 39 38 f1 = &_f1; 40 39 41 40 /* 42 41 * Requeue a waiter from f1 to f2, and wake f2. 43 42 */ 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)); 46 44 47 45 usleep(WAKE_WAIT_US); 48 46 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)); 65 49 } 66 50 67 51 TEST(requeue_multiple) ··· 53 69 volatile futex_t _f1 = 0; 54 70 volatile futex_t f2 = 0; 55 71 pthread_t waiter[10]; 56 - int res, i; 72 + int i; 57 73 58 74 f1 = &_f1; 59 75 ··· 61 77 * Create 10 waiters at f1. At futex_requeue, wake 3 and requeue 7. 62 78 * At futex_wake, wake INT_MAX (should be exactly 7). 63 79 */ 64 - for (i = 0; i < 10; i++) { 65 - if (pthread_create(&waiter[i], NULL, waiterfn, NULL)) 66 - ksft_exit_fail_msg("pthread_create failed\n"); 67 - } 80 + for (i = 0; i < 10; i++) 81 + ASSERT_EQ(0, pthread_create(&waiter[i], NULL, waiterfn, NULL)); 68 82 69 83 usleep(WAKE_WAIT_US); 70 84 71 - ksft_print_dbg_msg("Waking 3 futexes at f1 and requeuing 7 futexes from f1 to f2\n"); 72 - res = futex_cmp_requeue(f1, 0, &f2, 3, 7, 0); 73 - if (res != 10) { 74 - ksft_test_result_fail("futex_requeue many returned: %d %s\n", 75 - res ? errno : res, 76 - res ? strerror(errno) : ""); 77 - } 78 - 79 - ksft_print_dbg_msg("Waking INT_MAX futexes at f2\n"); 80 - res = futex_wake(&f2, INT_MAX, 0); 81 - if (res != 7) { 82 - ksft_test_result_fail("futex_requeue many returned: %d %s\n", 83 - res ? errno : res, 84 - res ? strerror(errno) : ""); 85 - } else { 86 - ksft_test_result_pass("futex_requeue many succeeds\n"); 87 - } 85 + EXPECT_EQ(10, futex_cmp_requeue(f1, 0, &f2, 3, 7, 0)); 86 + EXPECT_EQ(7, futex_wake(&f2, INT_MAX, 0)); 88 87 } 89 88 90 89 TEST_HARNESS_MAIN