Message ID | 20250606060604.16237-1-zhangzihuan@kylinos.cn |
---|---|
State | New |
Headers | show |
Series | [RESEND,v2] PM / Freezer: Skip dead/zombie processes | expand |
diff --git a/kernel/power/process.c b/kernel/power/process.c index a6f7ba2d283d..2bbe22610522 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c @@ -51,7 +51,7 @@ static int try_to_freeze_tasks(bool user_only) todo = 0; read_lock(&tasklist_lock); for_each_process_thread(g, p) { - if (p == current || !freeze_task(p)) + if (p == current || p->exit_state || !freeze_task(p)) continue; todo++;
ZOMBIE (exit_state == EXIT_ZOMBIE) and DEAD (exit_state == EXIT_DEAD) processes have already finished execution and will not be scheduled again. In the context of system suspend (e.g., S3), attempting to freeze such processes is unnecessary. Moreover, freezing them can obscure suspend diagnostics and delay resume if they appear "stuck" in logs. This patch introduces an early check for `p->exit_state != 0` in `try_to_freeze_tasks()` and skips freezing for such tasks. This is a safe optimization because: - They hold no running resources - Their `task_struct` is only waiting to be collected or freed Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn> Changes in v2: - Simplified code, added judgment of dead processes - Rewrite changelogs --- kernel/power/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)