Re: [RESEND PATCH] fs/pipe: Introduce a check to skip sleeping processes during pipe read/write

From: Linus Torvalds
Date: Thu Dec 26 2024 - 15:30:33 EST


[ Ugh, removed the crazy cc list with tons of old addresses ]

On Thu, 26 Dec 2024 at 12:13, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
>
> I _think_ that
>
> wait_event_whatever(WQ, CONDITION);
>
> vs
>
> CONDITION = 1;
> if (wq_has_sleeper(WQ))
> wake_up_xxx(WQ, ...);
>
> is fine.

Hmm. I guess wq_has_sleeper() does have a memory barrier, so that
worry of mine was wrong.

So the optimization may be valid (the config option definitely is
not), but I think it needs to be explained much better.

I end up being very nervous about this code because we've had bugs in
this area, exactly because people optimize this code for the unixbench
pipe benchmark.

And then very few real loads have that behavior, although there are
some cases where people really use a pipe as a kind of "token
mechanism" (ie GNU make will do that, I think a few others do too).

Linus