Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Chao Liu <liuchao173@huawei.com>,
	catalin.marinas@arm.com, will@kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, hewenliang4@huawei.com,
	zhoukang7@huawei.com
Subject: Re: [PATCH v2] add cpu frequency to cpuinfo in arm64
Date: Wed, 26 Jan 2022 12:05:22 +0000	[thread overview]
Message-ID: <bf7fdba2-7850-9d38-157d-7a1e726512a5@arm.com> (raw)
In-Reply-To: <20220126092349.285642-1-liuchao173@huawei.com>

On 2022-01-26 09:23, Chao Liu wrote:
> There is cpu frequency in /proc/cpuinfo in 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.

> Signed-off-by: Chao Liu <liuchao173@huawei.com>
> ---
> Change in v2:
> - fix spelling errors and remove remove redundant blank line
> 
>   arch/arm64/kernel/cpuinfo.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
> index 591c18a889a5..39a36e6e8079 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,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)

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-01-26 12:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-26  9:23 [PATCH v2] add cpu frequency to cpuinfo in arm64 Chao Liu
2022-01-26 10:08 ` Sudeep Holla
2022-01-26 12:05 ` Robin Murphy [this message]
2022-01-26 12:29   ` Marc Zyngier

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=bf7fdba2-7850-9d38-157d-7a1e726512a5@arm.com \
    --to=robin.murphy@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=hewenliang4@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuchao173@huawei.com \
    --cc=will@kernel.org \
    --cc=zhoukang7@huawei.com \
    /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