Skip to content

Commit 4140e2b

Browse files
Sebastian Andrzej SiewiorPeter Zijlstra
authored andcommitted
tools headers: Synchronize prctl.h ABI header
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: André Almeida <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 279f2c2 commit 4140e2b

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

tools/include/uapi/linux/prctl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ struct prctl_mm_map {
367367
/* FUTEX hash management */
368368
#define PR_FUTEX_HASH 78
369369
# define PR_FUTEX_HASH_SET_SLOTS 1
370+
# define FH_FLAG_IMMUTABLE (1ULL << 0)
370371
# define PR_FUTEX_HASH_GET_SLOTS 2
371372
# define PR_FUTEX_HASH_GET_IMMUTABLE 3
372373

tools/perf/bench/futex.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99

1010
void futex_set_nbuckets_param(struct bench_futex_parameters *params)
1111
{
12+
unsigned long flags;
1213
int ret;
1314

1415
if (params->nbuckets < 0)
1516
return;
1617

17-
ret = prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, params->nbuckets, params->buckets_immutable);
18+
flags = params->buckets_immutable ? FH_FLAG_IMMUTABLE : 0;
19+
ret = prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, params->nbuckets, flags);
1820
if (ret) {
1921
printf("Requesting %d hash buckets failed: %d/%m\n",
2022
params->nbuckets, ret);

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ 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)
2930
# define PR_FUTEX_HASH_GET_SLOTS 2
3031
# define PR_FUTEX_HASH_GET_IMMUTABLE 3
3132
#endif
3233

33-
static int futex_hash_slots_set(unsigned int slots, int immutable)
34+
static int futex_hash_slots_set(unsigned int slots, int flags)
3435
{
35-
return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, slots, immutable);
36+
return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, slots, flags);
3637
}
3738

3839
static int futex_hash_slots_get(void)
@@ -63,13 +64,13 @@ static void futex_hash_slots_set_verify(int slots)
6364
ksft_test_result_pass("SET and GET slots %d passed\n", slots);
6465
}
6566

66-
static void futex_hash_slots_set_must_fail(int slots, int immutable)
67+
static void futex_hash_slots_set_must_fail(int slots, int flags)
6768
{
6869
int ret;
6970

70-
ret = futex_hash_slots_set(slots, immutable);
71+
ret = futex_hash_slots_set(slots, flags);
7172
ksft_test_result(ret < 0, "futex_hash_slots_set(%d, %d)\n",
72-
slots, immutable);
73+
slots, flags);
7374
}
7475

7576
static void *thread_return_fn(void *arg)
@@ -254,18 +255,18 @@ int main(int argc, char *argv[])
254255
ret = futex_hash_slots_set(0, 0);
255256
ksft_test_result(ret == 0, "Global hash request\n");
256257
} else {
257-
ret = futex_hash_slots_set(4, 1);
258+
ret = futex_hash_slots_set(4, FH_FLAG_IMMUTABLE);
258259
ksft_test_result(ret == 0, "Immutable resize to 4\n");
259260
}
260261
if (ret != 0)
261262
goto out;
262263

263264
futex_hash_slots_set_must_fail(4, 0);
264-
futex_hash_slots_set_must_fail(4, 1);
265+
futex_hash_slots_set_must_fail(4, FH_FLAG_IMMUTABLE);
265266
futex_hash_slots_set_must_fail(8, 0);
266-
futex_hash_slots_set_must_fail(8, 1);
267-
futex_hash_slots_set_must_fail(0, 1);
268-
futex_hash_slots_set_must_fail(6, 1);
267+
futex_hash_slots_set_must_fail(8, FH_FLAG_IMMUTABLE);
268+
futex_hash_slots_set_must_fail(0, FH_FLAG_IMMUTABLE);
269+
futex_hash_slots_set_must_fail(6, FH_FLAG_IMMUTABLE);
269270

270271
ret = pthread_barrier_init(&barrier_main, NULL, MAX_THREADS);
271272
if (ret != 0) {

0 commit comments

Comments
 (0)