]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools headers: Synchronize prctl.h ABI header
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Sat, 17 May 2025 15:14:54 +0000 (17:14 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 21 May 2025 11:57:41 +0000 (13:57 +0200)
The prctl.h ABI header was slightly updated during the development of
the interface. In particular the "immutable" parameter became a bit in
the option argument.

Synchronize prctl.h ABI header again and make use of the definition in
the testsuite and "perf bench futex".

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: André Almeida <andrealmeid@igalia.com>
Link: https://lore.kernel.org/r/20250517151455.1065363-5-bigeasy@linutronix.de
tools/include/uapi/linux/prctl.h
tools/perf/bench/futex.c
tools/testing/selftests/futex/functional/futex_priv_hash.c

index 21f30b3ded74bcb029bf05dadaa33c4069c99a48..43dec6eed559a68685fb03e659859bd2c4ee3395 100644 (file)
@@ -367,6 +367,7 @@ struct prctl_mm_map {
 /* FUTEX hash management */
 #define PR_FUTEX_HASH                  78
 # define PR_FUTEX_HASH_SET_SLOTS       1
+# define FH_FLAG_IMMUTABLE             (1ULL << 0)
 # define PR_FUTEX_HASH_GET_SLOTS       2
 # define PR_FUTEX_HASH_GET_IMMUTABLE   3
 
index 02ae6c52ba881c4d1b8f30c5bfa69c33a6ab87ad..26382e4d8d4ce2ff1d18bd692e13e7c41d625629 100644 (file)
@@ -9,12 +9,14 @@
 
 void futex_set_nbuckets_param(struct bench_futex_parameters *params)
 {
+       unsigned long flags;
        int ret;
 
        if (params->nbuckets < 0)
                return;
 
-       ret = prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, params->nbuckets, params->buckets_immutable);
+       flags = params->buckets_immutable ? FH_FLAG_IMMUTABLE : 0;
+       ret = prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, params->nbuckets, flags);
        if (ret) {
                printf("Requesting %d hash buckets failed: %d/%m\n",
                       params->nbuckets, ret);
index 72a621d9313f37a9f4b6c381727521e9f6a830ff..2dca18fefedcda9827fbfed36d94f821dbb4d474 100644 (file)
@@ -26,13 +26,14 @@ static int counter;
 #ifndef PR_FUTEX_HASH
 #define PR_FUTEX_HASH                  78
 # define PR_FUTEX_HASH_SET_SLOTS       1
+# define FH_FLAG_IMMUTABLE             (1ULL << 0)
 # define PR_FUTEX_HASH_GET_SLOTS       2
 # define PR_FUTEX_HASH_GET_IMMUTABLE   3
 #endif
 
-static int futex_hash_slots_set(unsigned int slots, int immutable)
+static int futex_hash_slots_set(unsigned int slots, int flags)
 {
-       return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, slots, immutable);
+       return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, slots, flags);
 }
 
 static int futex_hash_slots_get(void)
@@ -63,13 +64,13 @@ static void futex_hash_slots_set_verify(int slots)
        ksft_test_result_pass("SET and GET slots %d passed\n", slots);
 }
 
-static void futex_hash_slots_set_must_fail(int slots, int immutable)
+static void futex_hash_slots_set_must_fail(int slots, int flags)
 {
        int ret;
 
-       ret = futex_hash_slots_set(slots, immutable);
+       ret = futex_hash_slots_set(slots, flags);
        ksft_test_result(ret < 0, "futex_hash_slots_set(%d, %d)\n",
-                        slots, immutable);
+                        slots, flags);
 }
 
 static void *thread_return_fn(void *arg)
@@ -254,18 +255,18 @@ int main(int argc, char *argv[])
                ret = futex_hash_slots_set(0, 0);
                ksft_test_result(ret == 0, "Global hash request\n");
        } else {
-               ret = futex_hash_slots_set(4, 1);
+               ret = futex_hash_slots_set(4, FH_FLAG_IMMUTABLE);
                ksft_test_result(ret == 0, "Immutable resize to 4\n");
        }
        if (ret != 0)
                goto out;
 
        futex_hash_slots_set_must_fail(4, 0);
-       futex_hash_slots_set_must_fail(4, 1);
+       futex_hash_slots_set_must_fail(4, FH_FLAG_IMMUTABLE);
        futex_hash_slots_set_must_fail(8, 0);
-       futex_hash_slots_set_must_fail(8, 1);
-       futex_hash_slots_set_must_fail(0, 1);
-       futex_hash_slots_set_must_fail(6, 1);
+       futex_hash_slots_set_must_fail(8, FH_FLAG_IMMUTABLE);
+       futex_hash_slots_set_must_fail(0, FH_FLAG_IMMUTABLE);
+       futex_hash_slots_set_must_fail(6, FH_FLAG_IMMUTABLE);
 
        ret = pthread_barrier_init(&barrier_main, NULL, MAX_THREADS);
        if (ret != 0) {