Linux Power Management development
 help / color / mirror / Atom feed
From: Samuel Wu <wusamuel@google.com>
To: Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>
Cc: linux-pm@vger.kernel.org, Samuel Wu <wusamuel@google.com>,
	kernel-team@android.com,  linux-kernel@vger.kernel.org
Subject: [PATCH] workqueue: Skip non-freezable workqueues in freeze and thaw
Date: Sat, 14 Nov 2026 16:29:16 -0800	[thread overview]
Message-ID: <20261115002915.1849847-2-wusamuel@google.com> (raw)

In wq_adjust_max_active(), non-freezable workqueues always keep
saved_max_active and saved_min_active, so updating them during freeze
and thaw is a no-op. However, both freeze and thaw acquire mutexes and
adjust max_active for every wq on the wq list, which is extra work and
could increase contention.

Skip workqueues without WQ_FREEZABLE in freeze and thaw.

On a v7.3 Pixel 9 device, this consistently reduces thaw_processes
latency during system suspend by 4-5% (~0.7ms).

Signed-off-by: Samuel Wu <wusamuel@google.com>
---
 kernel/workqueue.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index edbb2aa9c950..902f84bcfd24 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -7370,6 +7370,8 @@ void freeze_workqueues_begin(void)
 	workqueue_freezing = true;
 
 	list_for_each_entry(wq, &workqueues, list) {
+		if (!(wq->flags & WQ_FREEZABLE))
+			continue;
 		mutex_lock(&wq->mutex);
 		wq_adjust_max_active(wq);
 		mutex_unlock(&wq->mutex);
@@ -7446,6 +7448,8 @@ void thaw_workqueues(void)
 
 	/* restore max_active and repopulate worklist */
 	list_for_each_entry(wq, &workqueues, list) {
+		if (!(wq->flags & WQ_FREEZABLE))
+			continue;
 		mutex_lock(&wq->mutex);
 		wq_adjust_max_active(wq);
 		mutex_unlock(&wq->mutex);
-- 
2.56.0.679.gc527c65306-goog


             reply	other threads:[~2026-11-15  0:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15  0:29 Samuel Wu [this message]
2026-11-15 15:29 ` [PATCH] workqueue: Skip non-freezable workqueues in freeze and thaw Tejun Heo

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=20261115002915.1849847-2-wusamuel@google.com \
    --to=wusamuel@google.com \
    --cc=jiangshanlai@gmail.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=tj@kernel.org \
    /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