* [PATCH] add cpu frequency to cpuinfo in arm64
@ 2022-01-26 9:18 Chao Liu
0 siblings, 0 replies; only message in thread
From: Chao Liu @ 2022-01-26 9:18 UTC (permalink / raw)
To: catalin.marinas, will
Cc: linux-arm-kernel, linux-kernel, hewenliang4, zhoukang7
There is cpu frequency in /proc/cpuinfo in x86 but not in arm64
Signed-off-by: Chao Liu <liuchao173@huawei.com>
---
arch/arm64/kernel/cpuinfo.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
index 591c18a889a5..a5af899bebc9 100644
--- a/arch/arm64/kernel/cpuinfo.c
+++ b/arch/arm64/kernel/cpuinfo.c
@@ -24,6 +24,7 @@
#include <linux/sched.h>
#include <linux/smp.h>
#include <linux/delay.h>
+#include <linux/cpufreq.h>
/*
* In case the boot CPU is hotpluggable, we record its initial state and
@@ -144,6 +145,7 @@ static int c_show(struct seq_file *m, void *v)
for_each_online_cpu(i) {
struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i);
u32 midr = cpuinfo->reg_midr;
+ unsigned int freq = cpufreq_quick_get(i);
/*
* glibc reads /proc/cpuinfo to determine the number of
@@ -159,6 +161,11 @@ static int c_show(struct seq_file *m, void *v)
loops_per_jiffy / (500000UL/HZ),
loops_per_jiffy / (5000UL/HZ) % 100);
+
+ if (cpu_freq)
+ seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
+ freq / 1000, (freq % 1000));
+
/*
* Dump out the common processor features in a single line.
* Userspace should read the hwcaps with getauxval(AT_HWCAP)
--
2.23.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-26 9:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 9:18 [PATCH] add cpu frequency to cpuinfo in arm64 Chao Liu
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).