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.

selftests/futex: Remove support for IMMUTABLE

Testing for the IMMUTABLE part of the futex interface is not needed
after the removal of the interface.

Remove support for IMMUTABLE from the sefltest.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250710110011.384614-6-bigeasy@linutronix.de

authored by

Sebastian Andrzej Siewior and committed by
Peter Zijlstra
16adc7f1 760e6f7b

+22 -49
+22 -49
tools/testing/selftests/futex/functional/futex_priv_hash.c
··· 26 26 #ifndef PR_FUTEX_HASH 27 27 #define PR_FUTEX_HASH 78 28 28 # define PR_FUTEX_HASH_SET_SLOTS 1 29 - # define FH_FLAG_IMMUTABLE (1ULL << 0) 30 29 # define PR_FUTEX_HASH_GET_SLOTS 2 31 - # define PR_FUTEX_HASH_GET_IMMUTABLE 3 32 30 #endif 33 31 34 - static int futex_hash_slots_set(unsigned int slots, int flags) 32 + static int futex_hash_slots_set(unsigned int slots) 35 33 { 36 - return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, slots, flags); 34 + return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, slots, 0); 37 35 } 38 36 39 37 static int futex_hash_slots_get(void) ··· 39 41 return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_GET_SLOTS); 40 42 } 41 43 42 - static int futex_hash_immutable_get(void) 43 - { 44 - return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_GET_IMMUTABLE); 45 - } 46 - 47 44 static void futex_hash_slots_set_verify(int slots) 48 45 { 49 46 int ret; 50 47 51 - ret = futex_hash_slots_set(slots, 0); 48 + ret = futex_hash_slots_set(slots); 52 49 if (ret != 0) { 53 50 ksft_test_result_fail("Failed to set slots to %d: %m\n", slots); 54 51 ksft_finished(); ··· 57 64 ksft_test_result_pass("SET and GET slots %d passed\n", slots); 58 65 } 59 66 60 - static void futex_hash_slots_set_must_fail(int slots, int flags) 67 + static void futex_hash_slots_set_must_fail(int slots) 61 68 { 62 69 int ret; 63 70 64 - ret = futex_hash_slots_set(slots, flags); 65 - ksft_test_result(ret < 0, "futex_hash_slots_set(%d, %d)\n", 66 - slots, flags); 71 + ret = futex_hash_slots_set(slots); 72 + ksft_test_result(ret < 0, "futex_hash_slots_set(%d)\n", 73 + slots); 67 74 } 68 75 69 76 static void *thread_return_fn(void *arg) ··· 145 152 { 146 153 int futex_slots1, futex_slotsn, online_cpus; 147 154 pthread_mutexattr_t mutex_attr_pi; 148 - int use_global_hash = 0; 149 155 int ret, retry = 20; 150 156 int c; 151 157 152 - while ((c = getopt(argc, argv, "cghv:")) != -1) { 158 + while ((c = getopt(argc, argv, "chv:")) != -1) { 153 159 switch (c) { 154 160 case 'c': 155 161 log_color(1); 156 - break; 157 - case 'g': 158 - use_global_hash = 1; 159 162 break; 160 163 case 'h': 161 164 usage(basename(argv[0])); ··· 167 178 } 168 179 169 180 ksft_print_header(); 170 - ksft_set_plan(22); 181 + ksft_set_plan(21); 171 182 172 183 ret = pthread_mutexattr_init(&mutex_attr_pi); 173 184 ret |= pthread_mutexattr_setprotocol(&mutex_attr_pi, PTHREAD_PRIO_INHERIT); ··· 179 190 ret = futex_hash_slots_get(); 180 191 if (ret != 0) 181 192 ksft_exit_fail_msg("futex_hash_slots_get() failed: %d, %m\n", ret); 182 - 183 - ret = futex_hash_immutable_get(); 184 - if (ret != 0) 185 - ksft_exit_fail_msg("futex_hash_immutable_get() failed: %d, %m\n", ret); 186 193 187 194 ksft_test_result_pass("Basic get slots and immutable status.\n"); 188 195 ret = pthread_create(&threads[0], NULL, thread_return_fn, NULL); ··· 252 267 futex_hash_slots_set_verify(32); 253 268 futex_hash_slots_set_verify(16); 254 269 255 - ret = futex_hash_slots_set(15, 0); 270 + ret = futex_hash_slots_set(15); 256 271 ksft_test_result(ret < 0, "Use 15 slots\n"); 257 272 258 273 futex_hash_slots_set_verify(2); ··· 270 285 ksft_test_result(ret == 2, "No more auto-resize after manaul setting, got %d\n", 271 286 ret); 272 287 273 - futex_hash_slots_set_must_fail(1 << 29, 0); 288 + futex_hash_slots_set_must_fail(1 << 29); 289 + futex_hash_slots_set_verify(4); 274 290 275 291 /* 276 - * Once the private hash has been made immutable or global hash has been requested, 277 - * then this requested can not be undone. 292 + * Once the global hash has been requested, then this requested can not 293 + * be undone. 278 294 */ 279 - if (use_global_hash) { 280 - ret = futex_hash_slots_set(0, 0); 281 - ksft_test_result(ret == 0, "Global hash request\n"); 282 - } else { 283 - ret = futex_hash_slots_set(4, FH_FLAG_IMMUTABLE); 284 - ksft_test_result(ret == 0, "Immutable resize to 4\n"); 285 - } 295 + ret = futex_hash_slots_set(0); 296 + ksft_test_result(ret == 0, "Global hash request\n"); 286 297 if (ret != 0) 287 298 goto out; 288 299 289 - futex_hash_slots_set_must_fail(4, 0); 290 - futex_hash_slots_set_must_fail(4, FH_FLAG_IMMUTABLE); 291 - futex_hash_slots_set_must_fail(8, 0); 292 - futex_hash_slots_set_must_fail(8, FH_FLAG_IMMUTABLE); 293 - futex_hash_slots_set_must_fail(0, FH_FLAG_IMMUTABLE); 294 - futex_hash_slots_set_must_fail(6, FH_FLAG_IMMUTABLE); 300 + futex_hash_slots_set_must_fail(4); 301 + futex_hash_slots_set_must_fail(8); 302 + futex_hash_slots_set_must_fail(8); 303 + futex_hash_slots_set_must_fail(0); 304 + futex_hash_slots_set_must_fail(6); 295 305 296 306 ret = pthread_barrier_init(&barrier_main, NULL, MAX_THREADS); 297 307 if (ret != 0) { ··· 297 317 join_max_threads(); 298 318 299 319 ret = futex_hash_slots_get(); 300 - if (use_global_hash) { 301 - ksft_test_result(ret == 0, "Continue to use global hash\n"); 302 - } else { 303 - ksft_test_result(ret == 4, "Continue to use the 4 hash buckets\n"); 304 - } 305 - 306 - ret = futex_hash_immutable_get(); 307 - ksft_test_result(ret == 1, "Hash reports to be immutable\n"); 320 + ksft_test_result(ret == 0, "Continue to use global hash\n"); 308 321 309 322 out: 310 323 ksft_finished();