Re: [PATCH v4] PM / Freezer: Skip zombie/dead processes to reduce freeze latency
From: Oleg Nesterov
Date: Wed Jul 16 2025 - 12:40:03 EST
On 07/16, Zihuan Zhang wrote:
>
> @@ -51,7 +51,15 @@ 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))
> + /*
> + * Zombie and dead tasks are not running anymore and cannot enter
> + * the __refrigerator(). Skipping them avoids unnecessary freeze attempts.
> + *
> + * TODO: Consider using PF_NOFREEZE instead, which may provide
> + * a more generic exclusion mechanism for other non-freezable tasks.
> + * However, for now, exit_state is sufficient to skip user processes.
I don't really understand the comment... The freeze_task() paths already
consider PF_NOFREEZE, although we can check it earlier as Peter suggests.
> + */
> + if (p == current || p->exit_state || !freeze_task(p))
> continue;
I leave this to you and Rafael, but this change doesn't look safe to me.
What if the exiting task does some IO after exit_notify() ?
Oleg.