From: Michal Hocko <mhocko@suse.com>
To: Zihuan Zhang <zhangzihuan@kylinos.cn>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Oleg Nesterov <oleg@redhat.com>,
David Hildenbrand <david@redhat.com>,
Jonathan Corbet <corbet@lwn.net>, Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
len brown <len.brown@intel.com>, pavel machek <pavel@kernel.org>,
Kees Cook <kees@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>, Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Nico Pache <npache@redhat.com>, xu xin <xu.xin16@zte.com.cn>,
wangfushuai <wangfushuai@baidu.com>,
Andrii Nakryiko <andrii@kernel.org>,
Christian Brauner <brauner@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Jeff Layton <jlayton@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Adrian Ratiu <adrian.ratiu@collabora.com>,
linux-pm@vger.kernel.org, linux-mm@kvack.org,
linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v1 0/9] freezer: Introduce freeze priority model to address process dependency issues
Date: Thu, 7 Aug 2025 15:25:34 +0200 [thread overview]
Message-ID: <aJSpTpB9_jijiO6m@tiehlicka> (raw)
In-Reply-To: <20250807121418.139765-1-zhangzihuan@kylinos.cn>
On Thu 07-08-25 20:14:09, Zihuan Zhang wrote:
> The Linux task freezer was designed in a much earlier era, when userspace was relatively simple and flat.
> Over the years, as modern desktop and mobile systems have become increasingly complex—with intricate IPC,
> asynchronous I/O, and deep event loops—the original freezer model has shown its age.
A modern userspace might be more complex or convoluted but I do not
think the above statement is accurate or even correct.
> ## Background
>
> Currently, the freezer traverses the task list linearly and attempts to freeze all tasks equally.
> It sends a signal and waits for `freezing()` to become true. While this model works well in many cases, it has several inherent limitations:
>
> - Signal-based logic cannot freeze uninterruptible (D-state) tasks
> - Dependencies between processes can cause freeze retries
> - Retry-based recovery introduces unpredictable suspend latency
>
> ## Real-world problem illustration
>
> Consider the following scenario during suspend:
>
> Freeze Window Begins
>
> [process A] - epoll_wait()
> │
> ▼
> [process B] - event source (already frozen)
>
> → A enters D-state because of waiting for B
I thought opoll_wait was waiting in interruptible sleep.
> → Cannot respond to freezing signal
> → Freezer retries in a loop
> → Suspend latency spikes
>
> In such cases, we observed that a normal 1–2ms freezer cycle could balloon to **tens of milliseconds**.
> Worse, the kernel has no insight into the root cause and simply retries blindly.
>
> ## Proposed solution: Freeze priority model
>
> To address this, we propose a **layered freeze model** based on per-task freeze priorities.
>
> ### Design
>
> We introduce 4 levels of freeze priority:
>
>
> | Priority | Level | Description |
> |----------|-------------------|-----------------------------------|
> | 0 | HIGH | D-state TASKs |
> | 1 | NORMAL | regular use space TASKS |
> | 2 | LOW | not yet used |
> | 4 | NEVER_FREEZE | zombie TASKs , PF_SUSPNED_TASK |
>
>
> The kernel will freeze processes **in priority order**, ensuring that higher-priority tasks are frozen first.
> This avoids dependency inversion scenarios and provides a deterministic path forward for tricky cases.
> By freezing control or event-source threads first, we prevent dependent tasks from entering D-state prematurely — effectively avoiding dependency inversion.
I really fail to see how that is supposed to work to be honest. If a
process is running in the userspace then the priority shouldn't really
matter much. Tasks will get a signal, freeze themselves and you are
done. If they are running in the userspace and e.g. sleeping while not
TASK_FREEZABLE then priority simply makes no difference. And if they are
TASK_FREEZABLE then the priority doens't matter either.
What am I missing?
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2025-08-07 13:25 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-07 12:14 [RFC PATCH v1 0/9] freezer: Introduce freeze priority model to address process dependency issues Zihuan Zhang
2025-08-07 12:14 ` [RFC PATCH v1 1/9] freezer: Introduce freeze_priority field in task_struct Zihuan Zhang
2025-08-07 12:14 ` [RFC PATCH v1 2/9] freezer: Introduce API to set per-task freeze priority Zihuan Zhang
2025-08-07 22:56 ` kernel test robot
2025-08-07 12:14 ` [RFC PATCH v1 3/9] freezer: Add per-priority layered freeze logic Zihuan Zhang
2025-08-07 12:14 ` [RFC PATCH v1 4/9] freezer: Set default freeze priority for userspace tasks Zihuan Zhang
2025-08-07 23:50 ` kernel test robot
2025-08-07 12:14 ` [RFC PATCH v1 5/9] freezer: set default freeze priority for PF_SUSPEND_TASK processes Zihuan Zhang
2025-08-08 14:39 ` Oleg Nesterov
2025-08-11 9:25 ` Zihuan Zhang
2025-08-11 9:32 ` Oleg Nesterov
2025-08-11 9:42 ` Zihuan Zhang
2025-08-11 9:46 ` Oleg Nesterov
2025-08-11 9:54 ` Zihuan Zhang
2025-08-07 12:14 ` [RFC PATCH v1 6/9] freezer: Set default freeze priority for zombie tasks Zihuan Zhang
2025-08-08 0:52 ` kernel test robot
2025-08-08 14:29 ` Oleg Nesterov
2025-08-11 9:29 ` Zihuan Zhang
2025-08-11 9:42 ` Oleg Nesterov
2025-08-12 8:07 ` Zihuan Zhang
2025-08-07 12:14 ` [RFC PATCH v1 7/9] freezer: raise freeze priority of tasks failed to freeze last time Zihuan Zhang
2025-08-08 14:53 ` Oleg Nesterov
2025-08-11 9:31 ` Zihuan Zhang
2025-08-07 12:14 ` [RFC PATCH v1 8/9] freezer: Add retry count statistics for freeze pass iterations Zihuan Zhang
2025-08-07 12:14 ` [RFC PATCH v1 9/9] proc: Add /proc/<pid>/freeze_priority interface Zihuan Zhang
2025-08-07 13:25 ` Michal Hocko [this message]
2025-08-08 1:13 ` [RFC PATCH v1 0/9] freezer: Introduce freeze priority model to address process dependency issues Zihuan Zhang
2025-08-08 7:00 ` Michal Hocko
2025-08-08 7:52 ` Zihuan Zhang
2025-08-08 8:58 ` Michal Hocko
2025-08-11 9:13 ` Zihuan Zhang
2025-08-11 10:58 ` Michal Hocko
2025-08-12 5:57 ` Zihuan Zhang
2025-08-12 17:26 ` Darrick J. Wong
2025-08-13 5:48 ` Zihuan Zhang
2025-08-14 16:43 ` Darrick J. Wong
2025-08-15 8:17 ` Zihuan Zhang
2025-08-08 7:57 ` Oleg Nesterov
2025-08-08 8:40 ` Zihuan Zhang
2025-08-14 14:37 ` Peter Zijlstra
2025-08-15 8:27 ` Zihuan Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aJSpTpB9_jijiO6m@tiehlicka \
--to=mhocko@suse.com \
--cc=Liam.Howlett@oracle.com \
--cc=adrian.ratiu@collabora.com \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=brauner@kernel.org \
--cc=bsegall@google.com \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=dietmar.eggemann@arm.com \
--cc=jlayton@kernel.org \
--cc=juri.lelli@redhat.com \
--cc=kees@kernel.org \
--cc=len.brown@intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=npache@redhat.com \
--cc=oleg@redhat.com \
--cc=pavel@kernel.org \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=tglx@linutronix.de \
--cc=vbabka@suse.cz \
--cc=vincent.guittot@linaro.org \
--cc=viro@zeniv.linux.org.uk \
--cc=vschneid@redhat.com \
--cc=wangfushuai@baidu.com \
--cc=xu.xin16@zte.com.cn \
--cc=zhangzihuan@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.