[RFC PATCH 2/4] support: test futex_time64 syscall instead of time32 one
Arnd Bergmann
arnd@arndb.de
Wed Nov 11 13:11:12 GMT 2026
On Wed, Nov 11, 2026, at 13:09, Adhemerval Zanella Netto wrote:
>> {
>> #ifdef __linux__
>> -# ifndef __NR_futex
>> -# define __NR_futex __NR_futex_time64
>> + int r = 0;
>> +# if defined(__ASSUME_TIME64_SYSCALLS) && defined(__NR_futex_time64)
>> + r = syscall (__NR_futex_time64, &(unsigned int){0}, 13 /* FUTEX_LOCK_PI2 */,
>> + 0, NULL);
>> # endif
>> - int r = syscall (__NR_futex, &(unsigned int){0}, 13 /* FUTEX_LOCK_PI2 */,
>> +# ifdef __NR_futex
>> + if (r != 0)
>> + r = syscall (__NR_futex, &(unsigned int){0}, 13 /* FUTEX_LOCK_PI2 */,
>> 0, NULL);
>> +# endif
>> return r == 0;
>> #else
>> return false;
>
> This breaks the probe on every ABI without __NR_futex_time64, where 'r'
> stays 0, the 'if (r != 0)' skips the only syscall, and the function always
> returns true. They would start failing on 64-bit hosts with kernels
> older than 5.14, which lack FUTEX_LOCK_PI2.
>
> There is also no need for __ASSUME_TIME64_SYSCALLS here. FUTEX_LOCK_PI2
> is newer (5.14) than futex_time64 (5.1), so on a 32-bit ABI any kernel
> that can answer 'yes' has futex_time64.
Ok, I see. I guess this simpler version would be sufficient then:
Arnd
diff --git a/support/support_mutex_pi_monotonic.c b/support/support_mutex_pi_monotonic.c
index cbcbd05165d4..36788a81269f 100644
--- a/support/support_mutex_pi_monotonic.c
+++ b/support/support_mutex_pi_monotonic.c
@@ -24,10 +24,10 @@ bool
support_mutex_pi_monotonic (void)
{
#ifdef __linux__
-# ifndef __NR_futex
-# define __NR_futex __NR_futex_time64
+# ifndef __NR_futex_time64
+# define __NR_futex_time64 __NR_futex
# endif
- int r = syscall (__NR_futex, &(unsigned int){0}, 13 /* FUTEX_LOCK_PI2 */,
+ int r = syscall (__NR_futex_time64, &(unsigned int){0}, 13 /* FUTEX_LOCK_PI2 */,
0, NULL);
return r == 0;
#else
More information about the Libc-alpha
mailing list