Re: [PATCH 2/2] fs/select: mark select and poll tasks TASK_FREEZABLE
From: Jan Kara
Date: Wed Sep 23 2026 - 07:30:40 EST
On Tue 22-09-26 21:15:59, Sadrul Chowdhury wrote:
> Similar to epoll_wait(), threads sleeping in do_select() and do_poll()
> sleep in TASK_INTERRUPTIBLE via poll_schedule_timeout(). During system
> suspend and resume, these threads are woken up by the freezer solely to
> transition to TASK_FROZEN, and woken again upon thaw only to re-evaluate
> file descriptors with no pending activity and sleep again.
>
> A previous attempt to make select() and poll() freezable in commit
> 9745cdb36da8 ("select: use freezable blocking call") was reverted in
> commit 59612d187912 ("Revert "select: use freezable blocking call"")
> alongside the epoll revert due to issues caused by the legacy freezer
> architecture.
>
> Following the freezer overhaul in commit f5d39b020809 ("freezer,sched:
> Rewrite core freezer logic"), tasks in TASK_FREEZABLE are safely frozen
> in-place into TASK_FROZEN without running userspace code or experiencing
> premature wakeups before resume completes.
>
> Pass TASK_FREEZABLE to poll_schedule_timeout() in do_select() and
> do_poll() (TASK_INTERRUPTIBLE | TASK_FREEZABLE) so that polling threads
> remain asleep undisturbed across suspend/resume cycles.
>
> Signed-off-by: Sadrul Chowdhury <sadrul@xxxxxxxxxx>
I'm by no means system suspend expert but I don't see a reason why this
shouldn't work. So feel free to add:
Reviewed-by: Jan Kara <jack@xxxxxxx>
Honza
> ---
> fs/select.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/select.c b/fs/select.c
> index 8943f20e8300..5cbbe86135bc 100644
> --- a/fs/select.c
> +++ b/fs/select.c
> @@ -601,7 +601,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;
> }
> @@ -961,7 +961,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.55.0.1082.g2b9226bbc0-goog
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR