Re: [RESEND PATCH] fs/pipe: Introduce a check to skip sleeping processes during pipe read/write
From: Oleg Nesterov
Date: Tue Dec 31 2024 - 15:25:18 EST
On 12/31, Linus Torvalds wrote:
>
> Oleg's patch to only wake up writers when readers have actually opened
> up a slot may not make any actual difference (because readers in
> *practice* always do big reads),
Yes, yes, that patch is mostly cleanup/simplification. I'll write the
changelog and send it after the holidays. Plus probably another one to fix
the theoretical problem (I need to recheck) in wakeup_pipe_readers/writers.
But let me ask another question right now. what do you think about another
minor change below?
Again, mostly to make this logic more understandable. Although I am not
sure I really understand it...
Oleg.
diff --git a/fs/pipe.c b/fs/pipe.c
index 82fede0f2111..ac3e7584726a 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -661,8 +661,11 @@ pipe_poll(struct file *filp, poll_table *wait)
struct pipe_inode_info *pipe = filp->private_data;
unsigned int head, tail;
+#ifdef CONFIG_EPOLL
/* Epoll has some historical nasty semantics, this enables them */
- WRITE_ONCE(pipe->poll_usage, true);
+ if ((filp->f_mode & FMODE_READ) && filp->f_ep)
+ WRITE_ONCE(pipe->poll_usage, true);
+#endif
/*
* Reading pipe state only -- no need for acquiring the semaphore.