From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Lukasz Luba <lukasz.luba@arm.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Christian Loehle <christian.loehle@arm.com>,
Yaxiong Tian <tianyaxiong@kylinos.cn>
Subject: [PATCH v2 2/3] cpufreq: intel_pstate: Add and use hybrid_has_l3()
Date: Wed, 15 Oct 2025 15:47:45 +0200 [thread overview]
Message-ID: <13884343.uLZWGnKmhe@rafael.j.wysocki> (raw)
In-Reply-To: <2404176.ElGaqSPkdT@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Introduce a function for checking whether or not a given CPU has L3
cache, called hybrid_has_l3(), and use it in hybrid_get_cost() for
computing cost coefficients associated with a given perf domain.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
v1 -> v2: No changes
---
drivers/cpufreq/intel_pstate.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -951,11 +951,26 @@ static int hybrid_active_power(struct de
return 0;
}
+static bool hybrid_has_l3(unsigned int cpu)
+{
+ struct cpu_cacheinfo *cacheinfo = get_cpu_cacheinfo(cpu);
+ unsigned int i;
+
+ if (!cacheinfo)
+ return false;
+
+ for (i = 0; i < cacheinfo->num_leaves; i++) {
+ if (cacheinfo->info_list[i].level == 3)
+ return true;
+ }
+
+ return false;
+}
+
static int hybrid_get_cost(struct device *dev, unsigned long freq,
unsigned long *cost)
{
struct pstate_data *pstate = &all_cpu_data[dev->id]->pstate;
- struct cpu_cacheinfo *cacheinfo = get_cpu_cacheinfo(dev->id);
/*
* The smaller the perf-to-frequency scaling factor, the larger the IPC
@@ -973,17 +988,8 @@ static int hybrid_get_cost(struct device
* touching it in case some other CPUs of the same type can do the work
* without it.
*/
- if (cacheinfo) {
- unsigned int i;
-
- /* Check if L3 cache is there. */
- for (i = 0; i < cacheinfo->num_leaves; i++) {
- if (cacheinfo->info_list[i].level == 3) {
- *cost += 2;
- break;
- }
- }
- }
+ if (hybrid_has_l3(dev->id))
+ *cost += 2;
return 0;
}
next prev parent reply other threads:[~2025-10-15 13:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 13:45 [PATCH v2 0/3] cpufreq: intel_pstate: Adjust the energy model for hybrid systems Rafael J. Wysocki
2025-10-15 13:46 ` [PATCH v2 1/3] cpufreq: intel_pstate: Add and use hybrid_get_cpu_type() Rafael J. Wysocki
2025-10-15 13:47 ` Rafael J. Wysocki [this message]
2025-10-15 13:48 ` [PATCH v2 3/3] cpufreq: intel_pstate: hybrid: Adjust energy model rules Rafael J. Wysocki
2025-10-15 15:13 ` Christian Loehle
2025-10-15 15:16 ` Rafael J. Wysocki
2025-10-16 7:48 ` Yaxiong Tian
2025-10-16 9:00 ` Christian Loehle
2025-10-16 9:52 ` Rafael J. Wysocki
2025-10-16 13:59 ` Dietmar Eggemann
2025-10-16 16:22 ` [PATCH v3 " Rafael J. Wysocki
2025-10-17 1:15 ` Yaxiong Tian
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=13884343.uLZWGnKmhe@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=tianyaxiong@kylinos.cn \
/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;
as well as URLs for NNTP newsgroup(s).