[PATCH v2 2/5] support: test futex_time64 syscall instead of time32 one

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Nov 16 17:10:12 GMT 2026



On 16/11/26 09:08, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The old futex syscall is optional and can be disabled in the kernel
> for 32-bit ABIs to force the use of time64 syscalls, which breaks the
> support_mutex_pi_monotonic() detection: Even on __TIMESIZE=64 architectures
> that always use the time64 syscalls, it may report false when __NR_futex
> is defined but turned off.
> 
> Flip the detection and default to futex_time64 with a fallback to
> futex for architectures that only have futex (64-bit ones plus x32).
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>


> ---
>  support/support_mutex_pi_monotonic.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/support/support_mutex_pi_monotonic.c b/support/support_mutex_pi_monotonic.c
> index cbcbd05165d4..65ddb4ad585c 100644
> --- a/support/support_mutex_pi_monotonic.c
> +++ b/support/support_mutex_pi_monotonic.c
> @@ -24,10 +24,14 @@ bool
>  support_mutex_pi_monotonic (void)
>  {
>  #ifdef __linux__
> -# ifndef __NR_futex
> -#  define __NR_futex __NR_futex_time64
> +  /* FUTEX_LOCK_PI2 (Linux 5.14) is newer than futex_time64 (Linux 5.1), so
> +     prefer the latter where it exists.  */
> +# ifdef __NR_futex_time64
> +  long int nr = __NR_futex_time64;
> +# else
> +  long int nr = __NR_futex;
>  # endif
> -  int r = syscall (__NR_futex, &(unsigned int){0}, 13 /* FUTEX_LOCK_PI2  */,
> +  int r = syscall (nr, &(unsigned int){0}, 13 /* FUTEX_LOCK_PI2  */,
>  		   0, NULL);
>    return r == 0;
>  #else



More information about the Libc-alpha mailing list