[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251104075544.3243606-3-yubowen8@huawei.com>
Date: Tue, 4 Nov 2025 15:55:43 +0800
From: Bowen Yu <yubowen8@...wei.com>
To: <linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<catalin.marinas@....com>, <will@...nel.org>, <beata.michalska@....com>,
<ptsm@...ux.microsoft.com>, <linuxarm@...wei.com>,
<jonathan.cameron@...wei.com>
CC: <zhanjie9@...ilicon.com>, <prime.zeng@...ilicon.com>,
<wanghuiqiang@...wei.com>, <xuwei5@...wei.com>, <zhenglifeng1@...wei.com>,
<yubowen8@...wei.com>, <zhangpengjie2@...wei.com>
Subject: [PATCH 2/3] arm64: topology: Use current freq in governor for idle cpus in cpuinfo_avg_freq
The current cpuinfo_avg_freq interface returns an error when all CPUs
under a policy are idle, which is relatively common. To address this, it
is better to use the current frequency stored in the governor. This
implementation is also used on x86 architecture.
Since the current frequency in the governor is the last known frequency,
it should be more user-friendly.
This patch also removes redundant !housekeeping_cpu() check since it is
inherently done when checking jiffies.
Original output when all cpus under a policy are idle:
[root@...alhost home]# cat /sys/devices/system/cpu/cpufreq/policy0/
cpuinfo_avg_freq
cat: /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_avg_freq: Resource
temporarily unavailable
Output after changes:
[root@...alhost home]# cat /sys/devices/system/cpu/cpufreq/policy0
/cpuinfo_avg_freq
1200000
Signed-off-by: Bowen Yu <yubowen8@...wei.com>
---
arch/arm64/kernel/topology.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
index c0dbc27289ea..f1370a4a4df9 100644
--- a/arch/arm64/kernel/topology.c
+++ b/arch/arm64/kernel/topology.c
@@ -333,14 +333,13 @@ int arch_freq_get_on_cpu(int cpu)
if (!idle_cpu(ref_cpu))
break;
}
+
+ if (ref_cpu >= nr_cpu_ids) {
+ cpufreq_cpu_put(policy);
+ return cpufreq_quick_get(start_cpu);
+ }
cpufreq_cpu_put(policy);
-
- if (ref_cpu >= nr_cpu_ids)
- /* No alternative to pull info from */
- return -EAGAIN;
-
- cpu = ref_cpu;
} else {
break;
}
--
2.33.0
Powered by blists - more mailing lists