From: David Hildenbrand <david@redhat.com>
To: Zihuan Zhang <zhangzihuan@kylinos.cn>, Michal Hocko <mhocko@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
rafael@kernel.org, len.brown@intel.com, pavel@kernel.org,
kees@kernel.org, mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, akpm@linux-foundation.org,
lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com,
vbabka@suse.cz, rppt@kernel.org, surenb@google.com,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [RFC PATCH] PM: Optionally block user fork during freeze to improve performance
Date: Wed, 18 Jun 2025 13:54:20 +0200 [thread overview]
Message-ID: <345a04ad-cf25-4af5-802a-bc8826d37b19@redhat.com> (raw)
In-Reply-To: <7d70334a-2e0a-4d1e-b4d0-64d0e3aa5439@kylinos.cn>
On 18.06.25 13:30, Zihuan Zhang wrote:
> Hi David,
>
> 在 2025/6/16 15:45, David Hildenbrand 写道:
>>
>>>> [...]
>>> In our test scenario, although new processes can indeed be created
>>> during the usleep_range() intervals between freeze iterations, it’s
>>> actually difficult to make the freezer fail outright. This is because
>>> user processes are forcibly frozen: when they return to user space and
>>> check for pending signals, they enter try_to_freeze() and transition
>>> into the refrigerator.
>>>
>>> However, since the scheduler is fair by design, it gives both newly
>>> forked tasks and yet-to-be-frozen tasks a chance to run. This
>>> competition for CPU time can slightly delay the overall freeze process.
>>> While this typically doesn’t lead to failure, it does cause more retries
>>> than necessary, especially under CPU pressure.
>>
>> I think that goes back to my original comment: why are we even
>> allowing fork children to run at all when we are currently freezing
>> all tasks?
>>
>> I would imagine that try_to_freeze_tasks() should force any new
>> processes (forked children) to start in the frozen state directly and
>> not get scheduled in the first place.
>>
> Thanks again for your comments and suggestion.
>
> We understand the motivation behind your idea: ideally, newly forked
> tasks during freezing should either be immediately frozen or prevented
> from running at all, to avoid unnecessary retries and delays. That makes
> perfect sense.
>
> However, implementing this seems non-trivial under the current freezer
> model, as it relies on voluntary transitions and lacks a mechanism to
> block forked children from being scheduled.
>
> Any insights or pointers would be greatly appreciated.
I'm afraid I can't provide too much guidance on scheduler logic.
Apparently we have this freezer_active global that forces existing
frozen pages to enter the freezing_slow_path().
There, we perform multiple checks, including "pm_freezing && !(p->flags
& PF_KTHREAD)".
I would have thought that we would want to make fork()/clone() children
while freezing also result in freezing_slow_path()==true, and stop them
from getting scheduled in the first place.
Again, no scheduler expert, but that's something I would look into.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-06-18 11:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-06 6:25 [RFC PATCH] PM: Optionally block user fork during freeze to improve performance Zihuan Zhang
2025-06-06 7:20 ` David Hildenbrand
2025-06-08 7:22 ` zhangzihuan
2025-06-08 15:50 ` Mateusz Guzik
2025-06-09 3:46 ` zhangzihuan
2025-06-06 8:22 ` Peter Zijlstra
2025-06-09 4:05 ` zhangzihuan
2025-06-10 10:50 ` David Hildenbrand
2025-06-13 2:37 ` Zihuan Zhang
2025-06-13 7:05 ` Michal Hocko
2025-06-16 3:46 ` Zihuan Zhang
2025-06-16 7:45 ` David Hildenbrand
2025-06-16 11:24 ` Michal Hocko
2025-06-18 11:30 ` Zihuan Zhang
2025-06-18 11:54 ` David Hildenbrand [this message]
2025-07-28 13:06 ` 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=345a04ad-cf25-4af5-802a-bc8826d37b19@redhat.com \
--to=david@redhat.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kees@kernel.org \
--cc=len.brown@intel.com \
--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=mhocko@suse.com \
--cc=mingo@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=vbabka@suse.cz \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).