Re: [PATCH] pipe: wakeup writer only if pipe buffer is at least half empty

From: Linus Torvalds
Date: Sun Oct 27 2019 - 12:14:42 EST

On Sun, Oct 27, 2019 at 11:46 AM Konstantin Khlebnikov
<khlebnikov@xxxxxxxxxxxxxx> wrote:
> There is no reason to wakeup writer if pipe has only one empty page.
> This means reader consumes data slower then writer produces it.
> This patch waits until buffer is at least half empty before waking writer.

This is a bit dangerous, at least with David's other changes.

In particular, there's now a "max_usage" in his series means that the
writer might be blocked even if there's lots of free slots, because
the writer is only allowed to use part of those slots.

So I'd rather not see this logic particularly now that David is
working on modifying the overall pipe logic.

I do agree with the overall idea, but I'm not entirely happy about the
"half full" logic, because it gets subtle with David's changes.

Also, I'm a bit worried about cases where the readers and writers
block on each other, and depend on "there's enough space in the pipe
that we won't deadlock". Maybe the writer is blocked (because it
filled the pipe), the reader reads just part of the pipe, and then the
reader blocks on the writer doing something else, knowing that it just
free'd up resources for the writer. But the writer is still blocked,
and not woken up, because the pipe is still more than half full. See
what I'm saying?

I'm not sure anything like that exists, but it's an example of a "hmm"