Re: [PATCH] pipe_read: don't wake up the writer if the pipe is still full

From: Oleg Nesterov
Date: Fri Mar 07 2025 - 07:35:38 EST


In case I wasn't clear...

On 03/07, Oleg Nesterov wrote:
>
> On 03/07, Hillf Danton wrote:
> >
> > On Fri, 7 Mar 2025 11:54:56 +0530 K Prateek Nayak <kprateek.nayak@xxxxxxx>
> > >> step-03
> > >> task-118766 new reader
> > >> makes pipe empty
> > >
> > >Reader seeing a pipe full should wake up a writer allowing 118768 to
> > >wakeup again and fill the pipe. Am I missing something?
> > >
> > Good catch, but that wakeup was cut off [2,3]

Please note that "that wakeup" was _not_ removed by the patch below.

"That wakeup" is another wakeup pipe_read() does before return:

if (wake_writer)
wake_up_interruptible_sync_poll(&pipe->wr_wait, ...);

And wake_writer must be true if this reader changed the pipe_full()
condition from T to F.

Note also that pipe_read() won't sleep if it has read even one byte.

> > [2] https://lore.kernel.org/lkml/20250304123457.GA25281@xxxxxxxxxx/
> > [3] https://lore.kernel.org/all/20250210114039.GA3588@xxxxxxxxxx/
>
> Why do you think
>
> [PATCH v2 1/1] pipe: change pipe_write() to never add a zero-sized buffer
> https://lore.kernel.org/all/20250210114039.GA3588@xxxxxxxxxx/
>
> can make any difference ???
>
> Where do you think a zero-sized buffer with ->len == 0 can come from?

Oleg.