From: Bradley Morgan <bradley.morgan@linux.dev>
To: wusamuel@google.com
Cc: kernel-team@android.com, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org, pavel@kernel.org, rafael@kernel.org
Subject: Re: [PATCH] freezer: Check frozen() before freezing() in freeze_task()
Date: Sun, 15 Nov 2026 00:49:54 +0000 [thread overview]
Message-ID: <09C404BB-5914-4658-801E-4DADD3411CF2@linux.dev> (raw)
In-Reply-To: <20261115003113.1852160-2-wusamuel@google.com>
On 15 November 2026 00:31:14 GMT, Samuel Wu <wusamuel@google.com> wrote:
>During the freeze stage of suspend, there are multiple passes over the
>same list of tasks. Each pass tries to freeze non-frozen tasks, meaning
>that the number of frozen tasks increase monotonically, and that each
>subsequent pass will mostly be iterating over frozen tasks. Therefore,
>it is faster to *first* check that a task is frozen before other checks,
>especially since the frozen check is computationally trivial.
>
>Check frozen(p) before !freezing(p) to short circuit the more expensive
>freezing_slow_path() calls, while retaining identical return semantics.
>
>On a v7.3 Pixel 9 device, this consistently reduces freeze_processes
>latency by ~10% (~4.5 ms).
7.3 PIXEL 9??? WHAT HOW? THE BASE ON STOCK IS 6.12!!!! WOW! (Please do for
pixel 7, I want flair :c)
>
>Signed-off-by: Samuel Wu <wusamuel@google.com>
>---
> kernel/freezer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/kernel/freezer.c b/kernel/freezer.c
>index a76bf957fb32..1adf09321389 100644
>--- a/kernel/freezer.c
>+++ b/kernel/freezer.c
>@@ -166,7 +166,7 @@ bool freeze_task(struct task_struct *p)
> unsigned long flags;
>
> spin_lock_irqsave(&freezer_lock, flags);
>- if (!freezing(p) || frozen(p) || __freeze_task(p)) {
>+ if (frozen(p) || !freezing(p) || __freeze_task(p)) {
> spin_unlock_irqrestore(&freezer_lock, flags);
> return false;
> }
Good good.
Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>
>
--- Thanks!
prev parent reply other threads:[~2026-11-15 0:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 0:31 [PATCH] freezer: Check frozen() before freezing() in freeze_task() Samuel Wu
2026-11-15 0:49 ` Bradley Morgan [this message]
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=09C404BB-5914-4658-801E-4DADD3411CF2@linux.dev \
--to=bradley.morgan@linux.dev \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=wusamuel@google.com \
/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.