Re: [PATCH] pipe: fix empty pipe check in pipe_write()

From: Linus Torvalds
Date: Sun Dec 22 2019 - 12:51:16 EST


On Sun, Dec 22, 2019 at 4:35 AM Jan Stancek <jstancek@xxxxxxxxxx> wrote:
> Problem is that after pipe_write() reacquires pipe lock, it
> re-checks for empty pipe with potentially stale 'head' and
> doesn't wake up read side anymore. pipe->tail can advance
> beyond 'head', because there are multiple writers.

Thank you. Patch is obviously correct, applied.

I wonder how much that whole "cache head/tail/mask" really helps, and
if we should strive to get rid of it entirely (and just make
"pipe_emptuy()" and friends take a 'const struct pipe_inode_info *"
argument).

Oh well. I've apple your one-liner, but next time I might decide the
cleverness and slight code generation advantage might not be worth it.

Hopefully there won't _be_ a next time, of course ;)

Linus