[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250730014708.1516-4-daijunbing@vivo.com>
Date: Wed, 30 Jul 2025 09:47:04 +0800
From: Dai Junbing <daijunbing@...o.com>
To: Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Jan Kara <jack@...e.cz>,
Miklos Szeredi <miklos@...redi.hu>,
"Theodore Ts'o" <tytso@....edu>,
linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-ext4@...r.kernel.org
Cc: opensource.kernel@...o.com,
Dai Junbing <daijunbing@...o.com>
Subject: [PATCH v1 3/5] pipe: Add TASK_FREEZABLE to read and open sleeps
When a process sleeps during read on pipes or open on FIFOs,
add the TASK_FREEZABLE flag. This prevents premature wakeups during
system suspend/resume operations, avoiding unnecessary wakeup overhead.
In both the pipe read and FIFO open paths, no kernel locks are held
during sleep. Therefore, adding TASK_FREEZABLE is safe.
Signed-off-by: Dai Junbing <daijunbing@...o.com>
---
fs/pipe.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/pipe.c b/fs/pipe.c
index 45077c37bad1..b49e382c59ba 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -385,7 +385,7 @@ anon_pipe_read(struct kiocb *iocb, struct iov_iter *to)
* since we've done any required wakeups and there's no need
* to mark anything accessed. And we've dropped the lock.
*/
- if (wait_event_interruptible_exclusive(pipe->rd_wait, pipe_readable(pipe)) < 0)
+ if (wait_event_freezable_exclusive(pipe->rd_wait, pipe_readable(pipe)) < 0)
return -ERESTARTSYS;
wake_next_reader = true;
@@ -1098,7 +1098,7 @@ static int wait_for_partner(struct pipe_inode_info *pipe, unsigned int *cnt)
int cur = *cnt;
while (cur == *cnt) {
- prepare_to_wait(&pipe->rd_wait, &rdwait, TASK_INTERRUPTIBLE);
+ prepare_to_wait(&pipe->rd_wait, &rdwait, TASK_INTERRUPTIBLE | TASK_FREEZABLE);
pipe_unlock(pipe);
schedule();
finish_wait(&pipe->rd_wait, &rdwait);
--
2.25.1
Powered by blists - more mailing lists