[RFC,3/3] nptl: Include CLOCK_MONOTONIC in mutex tests
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
Commit Message
Include pthread_mutex_clocklock(MONOTONIC)/PI in the testcases if FUTEX_LOCK_PI2
is available. Add the check at compile time to keep the test implementation
simple.
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
nptl/tst-mutexpi10.c | 8 ++++++++
sysdeps/pthread/tst-mutex5.c | 3 ++-
sysdeps/pthread/tst-mutex9.c | 3 ++-
sysdeps/unix/sysv/linux/kernel-features.h | 8 ++++++++
4 files changed, 20 insertions(+), 2 deletions(-)
Comments
On Mon, 21 Jun 2021, Kurt Kanzenbach via Libc-alpha wrote:
> diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
> index 1680b10ca1b6..eb5c4d5a04bd 100644
> --- a/sysdeps/unix/sysv/linux/kernel-features.h
> +++ b/sysdeps/unix/sysv/linux/kernel-features.h
> @@ -218,4 +218,12 @@
> # define __ASSUME_FACCESSAT2 0
> #endif
>
> +/* The FUTEX_LOCK_PI2 operation was introduced across all architectures in Linux
> + 5.14. */
> +#if __LINUX_KERNEL_VERSION >= 0x051400
0x051400 is 5.20.0, not 5.14.0.
I'd expect this change to appear in an earlier patch, with
__ASSUME_FUTEX_LOCK_PI2 conditionals being used to disable fallback
support for kernels found at runtime not to support the new feature.
On Mon Jun 21 2021, Joseph Myers wrote:
> On Mon, 21 Jun 2021, Kurt Kanzenbach via Libc-alpha wrote:
>
>> diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
>> index 1680b10ca1b6..eb5c4d5a04bd 100644
>> --- a/sysdeps/unix/sysv/linux/kernel-features.h
>> +++ b/sysdeps/unix/sysv/linux/kernel-features.h
>> @@ -218,4 +218,12 @@
>> # define __ASSUME_FACCESSAT2 0
>> #endif
>>
>> +/* The FUTEX_LOCK_PI2 operation was introduced across all architectures in Linux
>> + 5.14. */
>> +#if __LINUX_KERNEL_VERSION >= 0x051400
>
> 0x051400 is 5.20.0, not 5.14.0.
OK.
>
> I'd expect this change to appear in an earlier patch, with
> __ASSUME_FUTEX_LOCK_PI2 conditionals being used to disable fallback
> support for kernels found at runtime not to support the new feature.
Yes, understood.
Thanks,
Kurt
@@ -25,6 +25,8 @@
#include <support/xthread.h>
#include <support/timespec.h>
+#include <kernel-features.h>
+
static int
do_test (void)
{
@@ -56,8 +58,14 @@ do_test (void)
struct timespec tmo = timespec_add (xclock_now (CLOCK_MONOTONIC),
make_timespec (0, 100000000));
+#if __ASSUME_FUTEX_LOCK_PI2
+ TEST_COMPARE (pthread_mutex_clocklock (&mtx, CLOCK_MONOTONIC, &tmo),
+ 0);
+ xpthread_mutex_unlock (&mtx);
+#else
TEST_COMPARE (pthread_mutex_clocklock (&mtx, CLOCK_MONOTONIC, &tmo),
EINVAL);
+#endif
xpthread_mutex_destroy (&mtx);
}
@@ -26,6 +26,7 @@
#include <config.h>
#include <support/check.h>
#include <support/timespec.h>
+#include <kernel-features.h>
#ifdef ENABLE_PP
#include "tst-tpp.h"
@@ -122,7 +123,7 @@ static int do_test (void)
do_test_clock (CLOCK_USE_TIMEDLOCK, "timedlock");
do_test_clock (CLOCK_REALTIME, "clocklock(realtime)");
-#ifndef ENABLE_PI
+#if ! defined(ENABLE_PI) || __ASSUME_FUTEX_LOCK_PI2
do_test_clock (CLOCK_MONOTONIC, "clocklock(monotonic)");
#endif
return 0;
@@ -29,6 +29,7 @@
#include <support/check.h>
#include <support/timespec.h>
#include <support/xunistd.h>
+#include <kernel-features.h>
#ifdef ENABLE_PP
#include "tst-tpp.h"
@@ -144,7 +145,7 @@ do_test (void)
do_test_clock (CLOCK_USE_TIMEDLOCK);
do_test_clock (CLOCK_REALTIME);
-#ifndef ENABLE_PI
+#if ! defined(ENABLE_PI) || __ASSUME_FUTEX_LOCK_PI2
do_test_clock (CLOCK_MONOTONIC);
#endif
return 0;
@@ -218,4 +218,12 @@
# define __ASSUME_FACCESSAT2 0
#endif
+/* The FUTEX_LOCK_PI2 operation was introduced across all architectures in Linux
+ 5.14. */
+#if __LINUX_KERNEL_VERSION >= 0x051400
+# define __ASSUME_FUTEX_LOCK_PI2 1
+#else
+# define __ASSUME_FUTEX_LOCK_PI2 0
+#endif
+
#endif /* kernel-features.h */