Re: [RFC PATCH 01/13] futex2: Implement wait and wake functions

From: Gabriel Krisman Bertazi
Date: Thu Feb 18 2021 - 13:16:07 EST


André Almeida <andrealmeid@xxxxxxxxxxxxx> writes:

>>> + if (unlikely(ret)) {
>>> + spin_unlock(&bucket->lock);
>>> +
>>> + bucket_dec_waiters(bucket);
>>> + __set_current_state(TASK_RUNNING);
>>> + *awakened = futex_dequeue_multiple(futexv, i);
>>> +
>>> + if (__get_user(uval, uaddr))
>>> + return -EFAULT;
>>> +
>>> + if (*awakened >= 0)
>>> + return 1;
>> If you are awakened, you don't need to waste time with trying to get
>> the
>> next key.
>>
>
> Yes, and this is what this return is supposed to do. What I'm missing?

you don't need to do that __get_user if some other key was already awoke.

[...]
if (*awakened >= 0)
return 1;

if (__get_user(uval, uaddr))
return -EFAULT;
[...]

--
Gabriel Krisman Bertazi