mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chung-Kai (Michael) Mei" <chungkai@google.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Ulf Hansson <ulfh@kernel.org>, Tejun Heo <tj@kernel.org>,
	 Lai Jiangshan <jiangshanlai@gmail.com>,
	Pavel Machek <pavel@kernel.org>, Len Brown <lenb@kernel.org>,
	 linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	chungkai@google.com
Subject: [PATCH] PM: runtime: Allocate pm_wq with WQ_HIGHPRI
Date: Tue, 27 Oct 2026 09:06:38 +0000	[thread overview]
Message-ID: <20261027090638.900747-1-chungkai@google.com> (raw)

Asynchronous runtime PM work (pm_runtime_work()) and genpd power-off
work (genpd_power_off_work_fn()) run on pm_wq. While such a work item
executes a ->runtime_suspend() or ->runtime_resume() callback, the
device's runtime_status is RPM_SUSPENDING or RPM_RESUMING with
dev->power.lock dropped, and genpd_power_off_work_fn() holds the genpd
lock.

If another task calls pm_runtime_get_sync() on the device in that
window, rpm_resume() sleeps on dev->power.wait_queue in
TASK_UNINTERRUPTIBLE until the work item completes. A wait queue has
no owner, so the waiter cannot lend its priority to the kworker, and
its latency is bounded by how quickly the pm_wq worker gets CPU time.
Because asynchronous runtime PM work is queued onto pm_wq by the PM
core, individual drivers cannot select a different workqueue.

pm_wq workers run at nice 0 and can be kept off the CPU for a long
time by higher-weight CFS tasks. On an arm64 Android device whose GPU
driver uses runtime PM autosuspend, render threads were observed
blocked in rpm_resume() for 5 to 19 ms while the runtime PM callback
itself needed less than 60 us of CPU time. For more than 99% of that
time the pm_wq worker was runnable, preempted by nice -20 tasks.

Allocate pm_wq with WQ_HIGHPRI so that its work items are served by the
unbound high-priority worker pools (nice -20), like other
latency-sensitive kernel workqueues such as kblockd. This does not
change the ordering or concurrency semantics of pm_wq. It only reduces
the time a runtime PM transition spends waiting for CPU time, and with
it the latency seen by synchronous runtime PM callers.

Signed-off-by: Chung-Kai (Michael) Mei <chungkai@google.com>
---
 kernel/power/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/power/main.c b/kernel/power/main.c
index 5429e9f19b655..1e8ae76356b23 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -1125,7 +1125,7 @@ EXPORT_SYMBOL_GPL(pm_wq);
 
 static int __init pm_start_workqueues(void)
 {
-	pm_wq = alloc_workqueue("pm", WQ_UNBOUND, 0);
+	pm_wq = alloc_workqueue("pm", WQ_UNBOUND | WQ_HIGHPRI, 0);
 	if (!pm_wq)
 		return -ENOMEM;
 

base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
-- 
2.56.0.307.g5fe7bd680c-goog


             reply	other threads:[~2026-10-27  9:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  9:06 Chung-Kai (Michael) Mei [this message]
2026-10-27 10:59 ` Rafael J. Wysocki (Intel)

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=20261027090638.900747-1-chungkai@google.com \
    --to=chungkai@google.com \
    --cc=jiangshanlai@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --cc=tj@kernel.org \
    --cc=ulfh@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

all inboxes | Powered by JetHome®