[PATCH v1 1/5] epoll: Make epoll_wait sleep freezable

Dai Junbing posted 5 patches 2 months, 1 week ago
[PATCH v1 1/5] epoll: Make epoll_wait sleep freezable
Posted by Dai Junbing 2 months, 1 week ago
When a user process enters TASK_INTERRUPTIBLE using the epoll_wait(2)
system call and its variants, add the TASK_FREEZABLE flag to prevent the
process from being prematurely awakened during suspend/resume, thus
avoiding unnecessary wakeups and overhead.

ep_poll is only used within the paths of epoll_wait-related system
calls.
In this path, after the process enters sleep, no kernel locks are held.
Therefore, adding TASK_FREEZABLE is safe.

Signed-off-by: Dai Junbing <daijunbing@vivo.com>
---
 fs/eventpoll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 0fbf5dfedb24..d52bd9838ef5 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -2094,7 +2094,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
 		 * the same lock on wakeup ep_poll_callback() side, so it
 		 * is safe to avoid an explicit barrier.
 		 */
-		__set_current_state(TASK_INTERRUPTIBLE);
+		__set_current_state(TASK_INTERRUPTIBLE | TASK_FREEZABLE);
 
 		/*
 		 * Do the final check under the lock. ep_start/done_scan()
-- 
2.25.1