Re: [patch 6/6] futex: Provide FUTEX_LOCK_PI2 to support clock selection
From: Thomas Gleixner
Date: Fri Apr 23 2021 - 18:36:55 EST
André!
On Fri, Apr 23 2021 at 19:20, André Almeida wrote:
>> @@ -21,6 +21,7 @@
>> #define FUTEX_WAKE_BITSET 10
>> #define FUTEX_WAIT_REQUEUE_PI 11
>> #define FUTEX_CMP_REQUEUE_PI 12
>> +#define FUTEX_LOCK_PI2 13
>>
>> #define FUTEX_PRIVATE_FLAG 128
>> #define FUTEX_CLOCK_REALTIME 256
>
> To keep consistency with other operations, maybe add a
> FUTEX_LOCK_PI2_PRIVATE?
Good point! Missed that.
>> --- a/kernel/futex.c
>> +++ b/kernel/futex.c
>> @@ -3711,7 +3711,8 @@ long do_futex(u32 __user *uaddr, int op,
>>
>> if (op & FUTEX_CLOCK_REALTIME) {
>> flags |= FLAGS_CLOCKRT;
>> - if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI)
>> + if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI &&
>> + cmd != FUTEX_LOCK_PI2)
>> return -ENOSYS;
>> }
>
> As FUTEX_LOCK_PI, FUTEX_LOCK_PI2 also requires FUTEX_CMPXCHG right?
> Then, add it here:
>
> switch (cmd) {
> case FUTEX_LOCK_PI:
> + case FUTEX_LOCK_PI2:
> case FUTEX_UNLOCK_PI:
> case FUTEX_TRYLOCK_PI:
> case FUTEX_WAIT_REQUEUE_PI:
> case FUTEX_CMP_REQUEUE_PI:
> if (!futex_cmpxchg_enabled)
> return -ENOSYS;
> }
Indeed. Forgot about that completely.
Thanks for spotting that!
tglx