From: liuyuan1 <liuyuan1@oppo.com>
To: rafael@kernel.org, len.brown@intel.com, pavel@kernel.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
chenzhengding@oppo.com, liuyuan1 <liuyuan1@oppo.com>
Subject: [PATCH] PM / Wakeup / freezer: Check pm_wakeup_pending() before freeze_task()
Date: Tue, 18 Mar 2025 14:17:44 +0800 [thread overview]
Message-ID: <1742278664-398536-1-git-send-email-liuyuan1@oppo.com> (raw)
Check pm_wakeup_pending() before freeze_task() can reduce
overhead by not freeze tasks in aborted case. freeze_task()
will cause high cpu loading especially when system has a large
number of tasks need to be freeze.
Signed-off-by: liuyuan1 <liuyuan1@oppo.com>
---
kernel/power/process.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/kernel/power/process.c b/kernel/power/process.c
index 66ac067..84704b3 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -49,6 +49,12 @@ static int try_to_freeze_tasks(bool user_only)
while (true) {
todo = 0;
+ if (pm_wakeup_pending()) {
+ wakeup = true;
+ todo++;
+ break;
+ }
+
read_lock(&tasklist_lock);
for_each_process_thread(g, p) {
if (p == current || !freeze_task(p))
@@ -66,11 +72,6 @@ static int try_to_freeze_tasks(bool user_only)
if (!todo || time_after(jiffies, end_time))
break;
- if (pm_wakeup_pending()) {
- wakeup = true;
- break;
- }
-
/*
* We need to retry, but first give the freezing tasks some
* time to enter the refrigerator. Start with an initial
--
2.7.4
next reply other threads:[~2025-03-18 6:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 6:17 liuyuan1 [this message]
2025-04-15 18:33 ` Rafael J. Wysocki
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=1742278664-398536-1-git-send-email-liuyuan1@oppo.com \
--to=liuyuan1@oppo.com \
--cc=chenzhengding@oppo.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=rafael@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®