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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 4 Mar 2025 at 18:41, K Prateek Nayak <kprateek.nayak@xxxxxxx> wrote:
>
> >          spin_lock_irq(&pipe->rd_wait.lock);
> >           ...
> >          pipe->tail = ++tail;
> >          ...
> >          spin_unlock_irq(&pipe->rd_wait.lock);
>
>  From my understanding, this is still done with "pipe->mutex" held. Both
> anon_pipe_read() and pipe_resize_ring() will lock "pipe->mutex" first
> and then take the "pipe->rd_wait.lock" when updating "pipe->tail".
> "pipe->head" is always updated with "pipe->mutex" held.

No, see the actual watch_queue code: post_one_notification() in
fs/watch_queue.c.

It's isn't the exact sequence I posted, it looks like

        smp_store_release(&pipe->head, head + 1); /* vs pipe_read() */

instead, and it's pipe->head there vs pipe->tail in pipe_read().

And I do think we end up having exclusion thanks to pipe_update_tail()
taking that spinlock if the pipe is actually a watchqueue thing, so it
might all be ok on alpha too.

So *maybe* we can just make it all be two 16-bit words in a 32-bit
thing, but somebody needs to walk through it all to make sure.

              Linus




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux