Thread (38 messages) 38 messages, 5 authors, 2025-08-15

Re: [RFC PATCH v1 0/9] freezer: Introduce freeze priority model to address process dependency issues

From: Michal Hocko <mhocko@suse.com>
Date: 2025-08-08 08:58:31
Also in: linux-fsdevel, linux-mm, linux-pm, lkml

On Fri 08-08-25 15:52:31, Zihuan Zhang wrote:
在 2025/8/8 15:00, Michal Hocko 写道:
quoted
On Fri 08-08-25 09:13:30, Zihuan Zhang wrote:
[...]
quoted
However, in practice, we’ve observed cases where tasks appear stuck in
uninterruptible sleep (D state) during the freeze phase  — and thus cannot
respond to signals or enter the refrigerator. These tasks are technically
TASK_FREEZABLE, but due to the nature of their sleep state, they don’t
freeze promptly, and may require multiple retry rounds, or cause the entire
suspend to fail.
Right, but that is an inherent problem of the freezer implemenatation.
It is not really clear to me how priorities or layers improve on that.
Could you please elaborate on that?
Thanks for the follow-up.

From our observations, we’ve seen processes like Xorg that are in a normal
state before freezing begins, but enter D state during the freeze window.
Upon investigation,

we found that these processes often depend on other user processes (e.g.,
I/O helpers or system services), and when those dependencies are frozen
first, the dependent process (like Xorg) gets stuck and can’t be frozen
itself.
OK, I see.
This led us to treat such processes as “hard to freeze” tasks — not because
they’re inherently unfreezable, but because they are more likely to become
problematic if not frozen early enough.

So our model works as follows:
    •    By default, freezer tries to freeze all freezable tasks in each
round.
    •    With our approach, we only attempt to freeze tasks whose
freeze_priority is less than or equal to the current round number.
    •    This ensures that higher-priority (i.e., harder-to-freeze) tasks
are attempted earlier, increasing the chance that they freeze before being
blocked by others.

Since we cannot know in advance which tasks will be difficult to freeze, we
use heuristics:
    •    Any task that causes freeze failure or is found in D state during
the freeze window is treated as hard-to-freeze in the next attempt and its
priority is increased.
    •    Additionally, users can manually raise/reduce the freeze priority
of known problematic tasks via an exposed sysfs interface, giving them
fine-grained control.
This would have been a very useful information for the changelog so that
we can understand what you are trying to achieve.
This doesn’t change the fundamental logic of the freezer — it still retries
until all tasks are frozen — but by adjusting the traversal order,

 we’ve observed significantly fewer retries and more reliable success in
scenarios where these D state transitions occur.
 
OK, I believe I do understand what you are trying to achieve but I am
not conviced this is a robust way to deal with the problem. This all
seems highly timing specific that might work in very specific usecase
but you are essentially trying to fight tiny race windows with a very
probabilitistic interface.

Also the interface seems to be really coarse grained and it can easily
turn out insufficient for other usecases while it is not entirely clear
to me how this could be extended for those.

I believe it would be more useful to find sources of those freezer
blockers and try to address those. Making more blocked tasks
__set_task_frozen compatible sounds like a general improvement in
itself.

Thanks
-- 
Michal Hocko
SUSE Labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help