[PATCH v1 2/5] select/poll: Make sleep freezable

From: Dai Junbing
Date: Tue Jul 29 2025 - 21:50:51 EST


When processes sleep in TASK_INTERRUPTIBLE state during select(2)
or poll(2) system calls, add the TASK_FREEZABLE flag. This prevents
them from being prematurely awakened during system suspend/resume
operations, avoiding unnecessary wakeup overhead.

The functions do_select() and do_poll() are exclusively used within
their respective system call paths. During sleep in these paths, no
kernel locks are held. Therefore, adding TASK_FREEZABLE is safe.

Signed-off-by: Dai Junbing <daijunbing@xxxxxxxx>
---
fs/select.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/select.c b/fs/select.c
index 9fb650d03d52..8a1e9fe12650 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -600,7 +600,7 @@ static noinline_for_stack int do_select(int n, fd_set_bits *fds, struct timespec
to = &expire;
}

- if (!poll_schedule_timeout(&table, TASK_INTERRUPTIBLE,
+ if (!poll_schedule_timeout(&table, TASK_INTERRUPTIBLE | TASK_FREEZABLE,
to, slack))
timed_out = 1;
}
@@ -955,7 +955,7 @@ static int do_poll(struct poll_list *list, struct poll_wqueues *wait,
to = &expire;
}

- if (!poll_schedule_timeout(wait, TASK_INTERRUPTIBLE, to, slack))
+ if (!poll_schedule_timeout(wait, TASK_INTERRUPTIBLE | TASK_FREEZABLE, to, slack))
timed_out = 1;
}
return count;
--
2.25.1