From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.12.y 2/4] PM: EM: Slightly reduce em_check_capacity_update() overhead
Date: Tue, 21 Oct 2025 15:22:23 -0400 [thread overview]
Message-ID: <20251021192225.2899605-2-sashal@kernel.org> (raw)
In-Reply-To: <20251021192225.2899605-1-sashal@kernel.org>
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
[ Upstream commit a8e62726ac0dd7b610c87ba1a938a5a9091c34df ]
Every iteration of the loop over all possible CPUs in
em_check_capacity_update() causes get_cpu_device() to be called twice
for the same CPU, once indirectly via em_cpu_get() and once directly.
Get rid of the indirect get_cpu_device() call by moving the direct
invocation of it earlier and using em_pd_get() instead of em_cpu_get()
to get a pd pointer for the dev one returned by it.
This also exposes the fact that dev is needed to get a pd, so the code
becomes somewhat easier to follow after it.
No functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/1925950.tdWV9SEqCh@rjwysocki.net
Stable-dep-of: 1ebe8f7e7825 ("PM: EM: Fix late boot with holes in CPU topology")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/power/energy_model.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
index 8ee72c6c1daf3..a035b030ff734 100644
--- a/kernel/power/energy_model.c
+++ b/kernel/power/energy_model.c
@@ -769,7 +769,8 @@ static void em_check_capacity_update(void)
}
cpufreq_cpu_put(policy);
- pd = em_cpu_get(cpu);
+ dev = get_cpu_device(cpu);
+ pd = em_pd_get(dev);
if (!pd || em_is_artificial(pd))
continue;
@@ -793,7 +794,6 @@ static void em_check_capacity_update(void)
pr_debug("updating cpu%d cpu_cap=%lu old capacity=%lu\n",
cpu, cpu_capacity, em_max_perf);
- dev = get_cpu_device(cpu);
em_adjust_new_capacity(dev, pd);
}
--
2.51.0
next prev parent reply other threads:[~2025-10-21 19:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 12:51 FAILED: patch "[PATCH] PM: EM: Fix late boot with holes in CPU topology" failed to apply to 6.12-stable tree gregkh
2025-10-21 19:22 ` [PATCH 6.12.y 1/4] PM: EM: Drop unused parameter from em_adjust_new_capacity() Sasha Levin
2025-10-21 19:22 ` Sasha Levin [this message]
2025-10-21 19:22 ` [PATCH 6.12.y 3/4] PM: EM: Move CPU capacity check to em_adjust_new_capacity() Sasha Levin
2025-10-21 19:22 ` [PATCH 6.12.y 4/4] PM: EM: Fix late boot with holes in CPU topology Sasha Levin
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=20251021192225.2899605-2-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael.j.wysocki@intel.com \
--cc=stable@vger.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