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

From: Oleg Nesterov
Date: Sun Dec 29 2024 - 08:14:22 EST


Sorry for the noise...

and currently this is fine. But if we want to add the wq_has_sleeper()
checks into fs/pipe.c then pipe_poll() needs smp_mb() after it calls
poll_wait().

Agreed?

On 12/29, Oleg Nesterov wrote:
>
> On 12/29, Manfred Spraul wrote:
> >
> > >I think that your patch (and the original patch from WangYuli) has the same
> > >proble with pipe_poll()->poll_wait()->__pollwait().
> >
> > What is the memory barrier for pipe_poll()?
> >
> > There is poll_wait()->__pollwait()->add_wait_queue()->spin_unlock(). thus
> > only store_release.
> >
> > And then READ_ONCE(), i.e. no memory barrier.
> >
> > Thus the CPU would be free to load pipe->head and pipe->tail before adding
> > the entry to the poll table.
> >
> > Correct?
>
> Yes, this was my thinking.
>
> See also my initial reply to WangYuli
> https://lore.kernel.org/all/20241226160007.GA11118@xxxxxxxxxx/
>
> Do you agree?
>
> Oleg.