Re: [PATCH v12 03/21] futex: Move futex_queue() into futex_wait_setup()
From: Sebastian Andrzej Siewior
Date: Fri May 16 2025 - 08:53:47 EST
On 2025-05-05 18:43:16 [-0300], André Almeida wrote:
> > --- a/kernel/futex/waitwake.c
> > +++ b/kernel/futex/waitwake.c
> > @@ -339,18 +339,8 @@ static long futex_wait_restart(struct restart_block *restart);
> > * @q: the futex_q to queue up on
> > * @timeout: the prepared hrtimer_sleeper, or null for no timeout
> > */
> > -void futex_wait_queue(struct futex_hash_bucket *hb, struct futex_q *q,
> > - struct hrtimer_sleeper *timeout)
> > +void futex_do_wait(struct futex_q *q, struct hrtimer_sleeper *timeout)
>
> Update the name in the kernel doc comment as well. Also drop from the
> comment the part that says "futex_queue() and ..."
This has been done.
…
> > @@ -636,10 +629,25 @@ int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags,
> > }
> > if (uval != val) {
> > - futex_q_unlock(*hb);
> > - ret = -EWOULDBLOCK;
> > + futex_q_unlock(hb);
> > + return -EWOULDBLOCK;
> > }
> > + if (key2 && futex_match(&q->key, key2)) {
> > + futex_q_unlock(hb);
> > + return -EINVAL;
>
> Please add this new ret value in the kernel doc too.
I'm going to add this:
--- a/kernel/futex/waitwake.c
+++ b/kernel/futex/waitwake.c
@@ -585,7 +585,8 @@ int futex_wait_multiple(struct futex_vector *vs, unsigned int count,
*
* Return:
* - 0 - uaddr contains val and hb has been locked;
- * - <1 - -EFAULT or -EWOULDBLOCK (uaddr does not contain val) and hb is unlocked
+ * - <0 - On error and the hb is unlocked. A possible reason: the uaddr can not
+ * be read, does not contain the expected value or is not properly aligned.
*/
int futex_wait_setup(u32 __user *uaddr, u32 val, unsigned int flags,
struct futex_q *q, union futex_key *key2,
Sebastian