[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YvJOQC7eQBjsHWct@kroah.com>
Date: Tue, 9 Aug 2022 14:08:32 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Jiaxun Yang <jiaxun.yang@...goat.com>
Cc: linux-mips@...r.kernel.org, linux-kernel@...r.kernel.org,
tsbogend@...ha.franken.de, linux-api@...r.kernel.org
Subject: Re: [PATCH] MIPS: Expose prid and globalnumber to sysfs
On Tue, Aug 09, 2022 at 11:34:44AM +0000, Jiaxun Yang wrote:
> Some application would like to know precise model and rev of processor
> to do errata workaround or optimization.
>
> Expose them in sysfs as:
> /sys/devices/system/cpu/cpuX/regs/identification/prid
> /sys/devices/system/cpu/cpuX/regs/identification/globalnumber
>
> Reusing AArch64 CPU registers directory.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@...goat.com>
> ---
> .../ABI/testing/sysfs-devices-system-cpu | 11 +++
> arch/mips/kernel/topology.c | 96 +++++++++++++++++++
> 2 files changed, 107 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu
> index 5bf61881f012..adf855e7bb9b 100644
> --- a/Documentation/ABI/testing/sysfs-devices-system-cpu
> +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu
> @@ -512,6 +512,17 @@ Description: information about CPUs heterogeneity.
>
> cpu_capacity: capacity of cpuX.
>
> +What: /sys/devices/system/cpu/cpuX/regs/
> + /sys/devices/system/cpu/cpuX/regs/identification/
> + /sys/devices/system/cpu/cpuX/regs/identification/prid
> + /sys/devices/system/cpu/cpuX/regs/identification/globalnumber
> +Date: Augest 2022
> +Contact: Linux MIPS Kernel Mailing list <linux-mips@...r.kernel.org>
> +Description: MIPS CPU registers
> +
> + 'identification' directory exposes the Processor ID and Global Number
> + registers for identifying model and revision of the CPU.
> +
> What: /sys/devices/system/cpu/vulnerabilities
> /sys/devices/system/cpu/vulnerabilities/meltdown
> /sys/devices/system/cpu/vulnerabilities/spectre_v1
> diff --git a/arch/mips/kernel/topology.c b/arch/mips/kernel/topology.c
> index 9429d85a4703..90b5136afb63 100644
> --- a/arch/mips/kernel/topology.c
> +++ b/arch/mips/kernel/topology.c
> @@ -5,6 +5,8 @@
> #include <linux/node.h>
> #include <linux/nodemask.h>
> #include <linux/percpu.h>
> +#include <linux/seq_file.h>
> +#include <linux/smp.h>
>
> static DEFINE_PER_CPU(struct cpu, cpu_devices);
>
> @@ -26,3 +28,97 @@ static int __init topology_init(void)
> }
>
> subsys_initcall(topology_init);
> +
> +static struct kobj_type cpuregs_kobj_type = {
> + .sysfs_ops = &kobj_sysfs_ops,
> +};
> +
> +struct cpureg {
> + struct kobject kobj;
> + struct cpuinfo_mips *info;
> +};
> +static DEFINE_PER_CPU(struct cpureg, cpuregs);
static kobjects are nothing you should ever create willingly. That's a
dynamic reference counted structure being declared on the "stack"?
Please no.
thanks,
greg k-h
Powered by blists - more mailing lists