[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250311065401.GD26382@redhat.com>
Date: Tue, 11 Mar 2025 07:54:02 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Hillf Danton <hdanton@...a.com>
Cc: K Prateek Nayak <kprateek.nayak@....com>,
Mateusz Guzik <mjguzik@...il.com>,
"Sapkal, Swapnil" <swapnil.sapkal@....com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] pipe_read: don't wake up the writer if the pipe is still
full
On 03/11, Hillf Danton wrote:
>
> On Mon, 10 Mar 2025 13:43:42 +0100 Oleg Nesterov
> >
> > Hmm. I don't understand you, again.
> >
> > OK, once some writer writes at least one byte (this will make the
> > pipe_empty() condition false) and wakes this reader up.
> >
> > If you meant something else, say, if you referred to you previous
> > scenario, please clarify your question.
> >
> The step-03 in my scenario [1] shows a reader sleeps at line-370 after
> making the pipe empty, so after your change that cuts the chance for
> waking up writer,
We are circling.
Once again, in this case "wake_writer" can't be true when the reader does
wait_event(rd_wait), this code can be replaced with BUG_ON(wake_writer).
So that change cuts nothing. It simply has no effect in this case.
> who will wake up the sleeping reader? Nobody.
>
> Feel free to check my scenario again.
>
> step-03
> task-118766 new reader
> makes pipe empty
> sleeps
>
> [1] https://lore.kernel.org/lkml/20250307060827.3083-1-hdanton@sina.com/
First of all, task-118766 won't sleep unless it calls read() again.
>From https://lore.kernel.org/all/20250307123442.GD5963@redhat.com/
Note also that pipe_read() won't sleep if it has read even one byte.
but this doesn't really matter.
>From https://lore.kernel.org/all/20250307112619.GA5963@redhat.com/
> step-03
> task-118766 new reader
> makes pipe empty
> sleeps
but since the pipe was full, this reader should wake up the
writer task-118768 once it updates the tail the 1st time during
the read.
> step-04
> task-118740 reader
> sleeps as pipe is empty
this is fine.
> [ Tasks 118740 and 118768 can then indefinitely wait on each other. ]
118768 should be woken at step 3
Now, when the writer task-118768 does write() it will wake the reader,
task-118740.
Oleg.
Powered by blists - more mailing lists