add cpu frequency to cpuinfo in arm64
PATCH v2 1/1 add cpu frequency to cpuinfo in arm64
There is cpu frequency in /proc/cpuinfo in x86 but not in arm64
---
Change in v2:
- fix spelling errors and remove remove redundant blank line
arch/arm64/kernel/cpuinfo.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/kernel/cpuinfo.c +6 -0
@@ -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,10 @@ static int c_show(struct seq_file *m, void *v) loops_per_jiffy / (500000UL /HZ ), loops_per_jiffy / (5000UL/HZ) % 100); +if (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)
Signature · 1 line
2.23.0
Quoted 2 lines · Chao Liu
There is cpu frequency in
/proc/cpuinfoin x86 but not in arm64
This has been repeatedly rejected in the past for valid reasons. I could find this link[1] quickly, but I am sure you can find a handful of such attempts in the past.
Signature · 4 lines
Regards, Sudeep [1] https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
Quoted 1 line · Chao Liu
There is cpu frequency in
/proc/cpuinfoin x86 but not in arm64
arm64 cpuinfo also doesn't show the APIC ID or microcode version. Different architectures are different.
Besides, x86 cpuinfo only shows MHz if the CPU has X86_FEATURE_TSC, so for compatibility we should only do this on AArch64 CPUs which have X86_FEATURE_TSC.
Robin.
Quoted 39 lines
Signed-off-by Chao Liu <[email protected]>---
Change in v2:
- fix spelling errors and remove remove redundant blank linearch/arm64/kernel/cpuinfo.c | 6 ++++++ 1 file changed, 6 insertions(+)arch/arm64/kernel/cpuinfo.c +6
-0@@ -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,10 @@ static int c_show(struct seq_file *m, void *v) loops_per_jiffy / (500000UL /HZ ), loops_per_jiffy / (5000UL/HZ) % 100); +if (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)
Quoted 9 lines · Robin Murphy
Quoted 1 line · Chao Liu
There is cpu frequency in
/proc/cpuinfoin x86 but not in arm64arm64 cpuinfo also doesn't show the APIC ID or microcode version. Different architectures are different.
Besides, x86 cpuinfo only shows MHz if the CPU has
X86_FEATURE_TSC, so for compatibility we should only do this on AArch64 CPUs which haveX86_FEATURE_TSC.
/me prepares a patch to be sent in just over 2 months...
M.
Signature · 1 line
Jazz is not dead. It just smells funny...