[PATCH 4/5] tools headers: Synchronize prctl.h ABI header

Sebastian Andrzej Siewior posted 5 patches 7 months, 1 week ago
There is a newer version of this series
[PATCH 4/5] tools headers: Synchronize prctl.h ABI header
Posted by Sebastian Andrzej Siewior 7 months, 1 week ago
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.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 tools/include/uapi/linux/prctl.h               |  1 +
 .../futex/functional/futex_priv_hash.c         | 18 +++++++++---------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/include/uapi/linux/prctl.h b/tools/include/uapi/linux/prctl.h
index 21f30b3ded74b..43dec6eed559a 100644
--- a/tools/include/uapi/linux/prctl.h
+++ b/tools/include/uapi/linux/prctl.h
@@ -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
 
diff --git a/tools/testing/selftests/futex/functional/futex_priv_hash.c b/tools/testing/selftests/futex/functional/futex_priv_hash.c
index 72a621d9313f3..32abd9acdf186 100644
--- a/tools/testing/selftests/futex/functional/futex_priv_hash.c
+++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c
@@ -30,9 +30,9 @@ static int counter;
 # 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,11 +63,11 @@ 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);
 }
@@ -254,18 +254,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) {
-- 
2.49.0
Re: [PATCH 4/5] tools headers: Synchronize prctl.h ABI header
Posted by André Almeida 7 months ago
Em 16/05/2025 13:03, Sebastian Andrzej Siewior escreveu:
> 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.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

After fixing the s/immutable/flags and FH_FLAG_IMMUTABLE issues:

Reviewed-by: André Almeida <andrealmeid@igalia.com>
Re: [PATCH 4/5] tools headers: Synchronize prctl.h ABI header
Posted by André Almeida 7 months ago
Hi Sebastian,

Thank you for incorporating my feedback :)

Em 16/05/2025 13:03, Sebastian Andrzej Siewior escreveu:
> 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.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>   tools/include/uapi/linux/prctl.h               |  1 +
>   .../futex/functional/futex_priv_hash.c         | 18 +++++++++---------
>   2 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/include/uapi/linux/prctl.h b/tools/include/uapi/linux/prctl.h
> index 21f30b3ded74b..43dec6eed559a 100644
> --- a/tools/include/uapi/linux/prctl.h
> +++ b/tools/include/uapi/linux/prctl.h
> @@ -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
>   
> diff --git a/tools/testing/selftests/futex/functional/futex_priv_hash.c b/tools/testing/selftests/futex/functional/futex_priv_hash.c
> index 72a621d9313f3..32abd9acdf186 100644
> --- a/tools/testing/selftests/futex/functional/futex_priv_hash.c
> +++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c
> @@ -30,9 +30,9 @@ static int counter;
>   # 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,11 +63,11 @@ 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);

s/immutable/flags

>   }
> @@ -254,18 +254,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);

This breaks the compilation for me.

So `#include <linux/prctl.h>` is not working for me, it's not using the 
local copy at tools/include/uapi/linux/prctl.h
Re: [PATCH 4/5] tools headers: Synchronize prctl.h ABI header
Posted by André Almeida 7 months ago
Em 16/05/2025 17:03, André Almeida escreveu:
> Hi Sebastian,
> 
> Thank you for incorporating my feedback :)
> 
> Em 16/05/2025 13:03, Sebastian Andrzej Siewior escreveu:
>> 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.
>>
>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>> ---
>>   tools/include/uapi/linux/prctl.h               |  1 +
>>   .../futex/functional/futex_priv_hash.c         | 18 +++++++++---------
>>   2 files changed, 10 insertions(+), 9 deletions(-)
>>
>> diff --git a/tools/include/uapi/linux/prctl.h b/tools/include/uapi/ 
>> linux/prctl.h
>> index 21f30b3ded74b..43dec6eed559a 100644
>> --- a/tools/include/uapi/linux/prctl.h
>> +++ b/tools/include/uapi/linux/prctl.h
>> @@ -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
>> diff --git a/tools/testing/selftests/futex/functional/ 
>> futex_priv_hash.c b/tools/testing/selftests/futex/functional/ 
>> futex_priv_hash.c
>> index 72a621d9313f3..32abd9acdf186 100644
>> --- a/tools/testing/selftests/futex/functional/futex_priv_hash.c
>> +++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c
>> @@ -30,9 +30,9 @@ static int counter;
>>   # 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,11 +63,11 @@ 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);
> 
> s/immutable/flags
> 
>>   }
>> @@ -254,18 +254,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);
> 
> This breaks the compilation for me.
> 
> So `#include <linux/prctl.h>` is not working for me, it's not using the 
> local copy at tools/include/uapi/linux/prctl.h

Oh, nevermind, I found the issue:

--- a/tools/testing/selftests/futex/functional/futex_priv_hash.c
+++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c
@@ -26,6 +26,7 @@ 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


Re: [PATCH 4/5] tools headers: Synchronize prctl.h ABI header
Posted by Sebastian Andrzej Siewior 7 months ago
On 2025-05-16 17:06:48 [-0300], André Almeida wrote:
> > > @@ -254,18 +254,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);
> > 
> > This breaks the compilation for me.
> > 
> > So `#include <linux/prctl.h>` is not working for me, it's not using the
> > local copy at tools/include/uapi/linux/prctl.h
> 
> Oh, nevermind, I found the issue:

Yeah, I am not sure what I did. I made here a copy, the copied header is
only used for perf. Anyway, I added the define as I did for the other
members and did the rename.

Sebastian