Re: [PATCH v2 1/2] sched/wait: Queue non-exclusive waiters at the head in do_wait_intr*()

From: Linus Torvalds

Date: Wed Nov 25 2026 - 18:31:51 EST


On Tue, 24 Nov 2026 at 03:54, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
>
> This will change the current behaviour if ret < 0. Say wake_page_function() does
>
> if (flags & WQ_FLAG_EXCLUSIVE) {
> if (test_bit(key->bit_nr, &key->folio->flags.f))
> return -1;

So I looked into this. We only have a couple of cases where waiters
return -1 to break out of the loop, and none of them have other
waiters.

In fact, I think that's pretty fundamental. The reason you'd return -1
is because you have made any other wakeups pointless.

The wake_page_function() is a good example of that: it returns -1 when
it has taken over the lock. That means that the page simply isn't
unlocked any more, and there is nothing else to wake up, because the
*reason* for the wakeup has fundamentally gone away.

But you're right that it's a differen tkind of case, so there's a
slightly expanded comment about it now in that "always queue new
waiters at the tail" commit.

And:

> Can't we at least cleanup __wake_up_common() ? See the patch below, I already
> sent it but it was ignored.

Yes. I've added that to the branch too. Maybe I should have added it
to the head, but I was lazy.

And I've updated some of the commits with reviewed-by and acked-by.
Maybe I should have added it to the head, but I was lazy.

Linus