@@ -26,31 +26,24 @@ static int counter;
2626#ifndef PR_FUTEX_HASH
2727#define PR_FUTEX_HASH 78
2828# define PR_FUTEX_HASH_SET_SLOTS 1
29- # define FH_FLAG_IMMUTABLE (1ULL << 0)
3029# define PR_FUTEX_HASH_GET_SLOTS 2
31- # define PR_FUTEX_HASH_GET_IMMUTABLE 3
3230#endif
3331
34- static int futex_hash_slots_set (unsigned int slots , int flags )
32+ static int futex_hash_slots_set (unsigned int slots )
3533{
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 );
3735}
3836
3937static int futex_hash_slots_get (void )
4038{
4139 return prctl (PR_FUTEX_HASH , PR_FUTEX_HASH_GET_SLOTS );
4240}
4341
44- static int futex_hash_immutable_get (void )
45- {
46- return prctl (PR_FUTEX_HASH , PR_FUTEX_HASH_GET_IMMUTABLE );
47- }
48-
4942static void futex_hash_slots_set_verify (int slots )
5043{
5144 int ret ;
5245
53- ret = futex_hash_slots_set (slots , 0 );
46+ ret = futex_hash_slots_set (slots );
5447 if (ret != 0 ) {
5548 ksft_test_result_fail ("Failed to set slots to %d: %m\n" , slots );
5649 ksft_finished ();
@@ -64,13 +57,13 @@ static void futex_hash_slots_set_verify(int slots)
6457 ksft_test_result_pass ("SET and GET slots %d passed\n" , slots );
6558}
6659
67- static void futex_hash_slots_set_must_fail (int slots , int flags )
60+ static void futex_hash_slots_set_must_fail (int slots )
6861{
6962 int ret ;
7063
71- ret = futex_hash_slots_set (slots , flags );
72- ksft_test_result (ret < 0 , "futex_hash_slots_set(%d, %d )\n" ,
73- slots , flags );
64+ ret = futex_hash_slots_set (slots );
65+ ksft_test_result (ret < 0 , "futex_hash_slots_set(%d)\n" ,
66+ slots );
7467}
7568
7669static void * thread_return_fn (void * arg )
@@ -152,18 +145,14 @@ int main(int argc, char *argv[])
152145{
153146 int futex_slots1 , futex_slotsn , online_cpus ;
154147 pthread_mutexattr_t mutex_attr_pi ;
155- int use_global_hash = 0 ;
156148 int ret , retry = 20 ;
157149 int c ;
158150
159- while ((c = getopt (argc , argv , "cghv :" )) != -1 ) {
151+ while ((c = getopt (argc , argv , "chv :" )) != -1 ) {
160152 switch (c ) {
161153 case 'c' :
162154 log_color (1 );
163155 break ;
164- case 'g' :
165- use_global_hash = 1 ;
166- break ;
167156 case 'h' :
168157 usage (basename (argv [0 ]));
169158 exit (0 );
@@ -178,7 +167,7 @@ int main(int argc, char *argv[])
178167 }
179168
180169 ksft_print_header ();
181- ksft_set_plan (22 );
170+ ksft_set_plan (21 );
182171
183172 ret = pthread_mutexattr_init (& mutex_attr_pi );
184173 ret |= pthread_mutexattr_setprotocol (& mutex_attr_pi , PTHREAD_PRIO_INHERIT );
@@ -191,10 +180,6 @@ int main(int argc, char *argv[])
191180 if (ret != 0 )
192181 ksft_exit_fail_msg ("futex_hash_slots_get() failed: %d, %m\n" , ret );
193182
194- ret = futex_hash_immutable_get ();
195- if (ret != 0 )
196- ksft_exit_fail_msg ("futex_hash_immutable_get() failed: %d, %m\n" , ret );
197-
198183 ksft_test_result_pass ("Basic get slots and immutable status.\n" );
199184 ret = pthread_create (& threads [0 ], NULL , thread_return_fn , NULL );
200185 if (ret != 0 )
@@ -267,7 +252,7 @@ int main(int argc, char *argv[])
267252 futex_hash_slots_set_verify (32 );
268253 futex_hash_slots_set_verify (16 );
269254
270- ret = futex_hash_slots_set (15 , 0 );
255+ ret = futex_hash_slots_set (15 );
271256 ksft_test_result (ret < 0 , "Use 15 slots\n" );
272257
273258 futex_hash_slots_set_verify (2 );
@@ -285,28 +270,23 @@ int main(int argc, char *argv[])
285270 ksft_test_result (ret == 2 , "No more auto-resize after manaul setting, got %d\n" ,
286271 ret );
287272
288- futex_hash_slots_set_must_fail (1 << 29 , 0 );
273+ futex_hash_slots_set_must_fail (1 << 29 );
274+ futex_hash_slots_set_verify (4 );
289275
290276 /*
291- * Once the private hash has been made immutable or global hash has been requested,
292- * then this requested can not be undone.
277+ * Once the global hash has been requested, then this requested can not
278+ * be undone.
293279 */
294- if (use_global_hash ) {
295- ret = futex_hash_slots_set (0 , 0 );
296- ksft_test_result (ret == 0 , "Global hash request\n" );
297- } else {
298- ret = futex_hash_slots_set (4 , FH_FLAG_IMMUTABLE );
299- ksft_test_result (ret == 0 , "Immutable resize to 4\n" );
300- }
280+ ret = futex_hash_slots_set (0 );
281+ ksft_test_result (ret == 0 , "Global hash request\n" );
301282 if (ret != 0 )
302283 goto out ;
303284
304- futex_hash_slots_set_must_fail (4 , 0 );
305- futex_hash_slots_set_must_fail (4 , FH_FLAG_IMMUTABLE );
306- futex_hash_slots_set_must_fail (8 , 0 );
307- futex_hash_slots_set_must_fail (8 , FH_FLAG_IMMUTABLE );
308- futex_hash_slots_set_must_fail (0 , FH_FLAG_IMMUTABLE );
309- futex_hash_slots_set_must_fail (6 , FH_FLAG_IMMUTABLE );
285+ futex_hash_slots_set_must_fail (4 );
286+ futex_hash_slots_set_must_fail (8 );
287+ futex_hash_slots_set_must_fail (8 );
288+ futex_hash_slots_set_must_fail (0 );
289+ futex_hash_slots_set_must_fail (6 );
310290
311291 ret = pthread_barrier_init (& barrier_main , NULL , MAX_THREADS );
312292 if (ret != 0 ) {
@@ -317,14 +297,7 @@ int main(int argc, char *argv[])
317297 join_max_threads ();
318298
319299 ret = futex_hash_slots_get ();
320- if (use_global_hash ) {
321- ksft_test_result (ret == 0 , "Continue to use global hash\n" );
322- } else {
323- ksft_test_result (ret == 4 , "Continue to use the 4 hash buckets\n" );
324- }
325-
326- ret = futex_hash_immutable_get ();
327- ksft_test_result (ret == 1 , "Hash reports to be immutable\n" );
300+ ksft_test_result (ret == 0 , "Continue to use global hash\n" );
328301
329302out :
330303 ksft_finished ();
0 commit comments