[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240603081331.3829278-2-beata.michalska@arm.com>
Date: Mon, 3 Jun 2024 09:13:31 +0100
From: Beata Michalska <beata.michalska@....com>
To: linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org,
rafael@...nel.org,
viresh.kumar@...aro.org,
len.brown@...el.com
Cc: ionela.voinescu@....com,
vanshikonda@...amperecomputing.com,
sumitg@...dia.com
Subject: [PATCH 1/1] cpufreq: Rewire arch specific feedback for cpuinfo/scaling_cur_freq
Some architectures provide a way to determine an average frequency over
a certain period of time, based on available performance monitors (AMU on
ARM or APERF/MPERf on x86). With those at hand, enroll arch_freq_get_on_cpu
into cpuinfo_cur_freq policy sysfs attribute handler, which is expected to
represent the current frequency of a given CPU,as obtained by the hardware.
This is the type of feedback that counters do provide.
At the same time, keep the scaling_cur_freq attribute align with the docs
and make it provide most recently requested frequency, still allowing to
fallback to using arch_freq_get_on_cpu for cases when cpuinfo_cur_freq is
not available.
Signed-off-by: Beata Michalska <beata.michalska@....com>
---
drivers/cpufreq/cpufreq.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index a45aac17c20f..3b0eabe4a983 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -758,7 +758,8 @@ static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf)
ssize_t ret;
unsigned int freq;
- freq = arch_freq_get_on_cpu(policy->cpu);
+ freq = !cpufreq_driver->get ? arch_freq_get_on_cpu(policy->cpu)
+ : 0;
if (freq)
ret = sprintf(buf, "%u\n", freq);
else if (cpufreq_driver->setpolicy && cpufreq_driver->get)
@@ -795,7 +796,10 @@ store_one(scaling_max_freq, max);
static ssize_t show_cpuinfo_cur_freq(struct cpufreq_policy *policy,
char *buf)
{
- unsigned int cur_freq = __cpufreq_get(policy);
+ unsigned int cur_freq = arch_freq_get_on_cpu(policy->cpu);
+
+ if (!cur_freq)
+ cur_freq = __cpufreq_get(policy);
if (cur_freq)
return sprintf(buf, "%u\n", cur_freq);
--
2.25.1
Powered by blists - more mailing lists