sysfs: add sysfs based cpuinfo
Subsystems (5)
v5 cover sysfs: add sysfs based cpuinfo
I picked up Felix Schnizlein's work from 2017.
It was already reviewed by Greg-KH at this time and even pushed into linux-next tree, when it came out that the mails never reached lkml, even the list was added to CC.
ARM people then correctly complained that this needs more review by ARCH people. It got reverted, Felix had no time anymore and this nice patcheset was hanging around nowhere...
Changes (by trenn) since v4:
- Do not separate bug and flag list via comma, but by space
- Adjust renamed cpu_data(c).x86_mask to cpu_data(c).x86_stepping due to commit b399151cb48db30ad1e0
- Introduce
config CPUINFO_SYSFS
and use config HAVE_CPUINFO_SYSFS as a pre-set helper only
- Set CPUINFO_SYSFS
def_bool y
=============================================
Tested on x86_64 and aarch64 (see below).
Tested on x86_64 (virtual machine):
------------------------------------------------------------
/sys/devices/system/cpu/cpu1/info/:[0]# ls
bogomips bugs cpu_family flags model model_name stepping vendor_id
for file in *;do echo $file; cat $file;echo;done
bogomips
5187.72
bugscpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit
cpu_family
6
flags
fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip
model
60
model_name
Intel Core Processor (Haswell, no TSX, IBRS)
stepping
1
vendor_id
GenuineIntel
=============================================
Tested on aarch64:
/sys/devices/system/cpu/cpu1/info/:[0]# ls
architecture bogomips flags implementer part revision variant
------------------------------------------------------------
for file in *;do echo $file; cat $file;echo;done
architecture
8
bogomips
40.00
flags
fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdm
implementer0x51
part0xc00
revision
1
variant0x0
Felix Schnizlein (3):
cpuinfo: add sysfs based arch independent cpuinfo framework x86 cpuinfo: implement sysfs nodes for x86
arm64 cpuinfo: implement sysfs nodes for arm64
Documentation/ABI/testing/sysfs-devices-system-cpu | 52 ++++++++++++ arch/Kconfig | 11 +++ arch/arm64/Kconfig | 1 + arch/arm64/kernel/cpuinfo.c | 55 ++++++++++++ arch/x86/Kconfig | 1 + arch/x86/kernel/Makefile | 2 + arch/x86/kernel/cpuinfo.c | 99 ++++++++++++++++++++++ drivers/base/Makefile | 1 + drivers/base/cpuinfo.c | 48 +++++++++++ include/linux/cpuhotplug.h | 1 + include/linux/cpuinfo.h | 43 ++++++++++ 11 files changed, 314 insertions(+) create mode 100644 arch/x86/kernel/cpuinfo.c create mode 100644 drivers/base/cpuinfo.c create mode 100644 include/linux/cpuinfo.h
Signature · 1 line
2.16.4
PATCH v5 1/3 cpuinfo: add sysfs based arch independent cpuinfo framework
From: Felix Schnizlein <[email protected]>
Create a new sysfs attribute group called 'info' for each online cpu. The cleaned up cpuinfo shows up in a sysfs subdirectory here: /sys/devices/system/cpu/cpu#/info.
Define preprocessor macros (CPUINFO_DEFINE_* and CPUINFO_ATTR) to make defining new sysfs attributes for cpuinfo more easy.
Add basic documentation for the info sysfs tree.
--- Documentation/ABI/testing/sysfs-devices-system-cpu | 7 ++++ arch/Kconfig | 11 +++++ drivers/base/Makefile | 1 + drivers/base/cpuinfo.c | 48 ++++++++++++++++++++++ include/linux/cpuhotplug.h | 1 + include/linux/cpuinfo.h | 43 +++++++++++++++++++ 6 files changed, 111 insertions(+) create mode 100644 drivers/base/cpuinfo.c create mode 100644 include/linux/cpuinfo.h
Documentation/ABI/testing/sysfs-devices-system-cpu +7 -0
@@ -574,3 +574,10 @@ Description: Secure Virtual Machine If 1, it means the system is using the Protected Execution Facility in POWER9 and newer processors. i.e., it is a Secure Virtual Machine. + +What: /sys/devices/system/cpu/cpu#/info/ +Date: June 2019 +Contact: Linux kernel mailing list <[email protected]> +Description: Various information about the online cpu. Which attributes are + available depends on the architecture, kernel configuration and + cpu model.
arch/Kconfig +11 -0
@@ -882,6 +882,17 @@ config STRICT_MODULE_RWX and non-text memory will be made non-executable. This provides protection against certain security exploits (e.g. writing to text) +config CPUINFO_SYSFS + bool "Provides processor information in sysfs. Successor of /proc/cpuinfo" + def_bool y + depends on HAVE_CPUINFO_SYSFS + help + Provides architecture specific processor information in /sys/devices/system/cpu/info + Use this instead of /proc/cpuinfo + +config HAVE_CPUINFO_SYSFS + bool + # select if the architecture provides an asm/dma-direct.h header config ARCH_HAS_PHYS_TO_DMA bool
drivers/base/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_PINCTRL) += pinctrl.o obj-$(CONFIG_DEV_COREDUMP) += devcoredump.o obj-$(CONFIG_GENERIC_MSI_IRQ_DOMAIN) += platform-msi.o obj-$(CONFIG_GENERIC_ARCH_TOPOLOGY) += arch_topology.o +obj-$(CONFIG_CPUINFO_SYSFS) += cpuinfo.o obj-y += test/
drivers/base/cpuinfo.c new file +48 -0
48 lines not on this page · raw message
include/linux/cpuhotplug.h +1 -0
@@ -78,6 +78,7 @@ enum cpuhp_state {CPUHP_SH_SH3X_PREPARE ,CPUHP_NET_FLOW_PREPARE ,CPUHP_TOPOLOGY_PREPARE , +CPUHP_CPUINFO_PREPARE ,CPUHP_NET_IUCV_PREPARE ,CPUHP_ARM_BL_PREPARE , CPUHP_TRACE_RB_PREPARE,
include/linux/cpuinfo.h new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.16.4
Greg KH
maintainerRe: [PATCH 1/3] cpuinfo: add sysfs based arch independent cpuinfo framework
Quoted 7 lines · Thomas Renninger
drivers/base/cpuinfo.c new file +4
-0@@ -0,0 +1,48 @@ +/* +* Copyright (C) 2017 SUSE Linux GmbH +* Written by: Felix Schnizlein <[email protected]> +*
drivers/base/cpuinfo.c line 14
Quoted 10 lines
drivers/base/cpuinfo.c new file +10
-0+* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version +* 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +*/
No SPDX line? And you can drop the license boilerplate text as well too.
Quoted 5 lines
drivers/base/cpuinfo.c new file +5
-0+ +#include <linux/cpu.h> +#include <linux/module.h> +#include <linux/cpuinfo.h> +
drivers/base/cpuinfo.c line 29
Quoted 10 lines
drivers/base/cpuinfo.c new file +10
-0+static struct attribute_group cpuinfo_attr_group = { + .attrs = cpuinfo_attrs, + .name ="info" +}; + +static int cpuinfo_add_dev (unsigned int cpu) +{ +struct device *dev =get_cpu_device (cpu); + +return sysfs_create_group (&dev->kobj, &cpuinfo_attr_group);
Why are a set of attributes being added _after_ the device is created? We have fixed up a lot of the "default attribute" logic since 2017, perhaps you should be using that instead?
drivers/base/cpuinfo.c line 36
Quoted 7 lines
drivers/base/cpuinfo.c new file +7
-0+} + +static int cpuinfo_remove_dev (unsigned int cpu) +{ +struct device *dev =get_cpu_device (cpu); + +sysfs_remove_group (&dev->kobj, &cpuinfo_attr_group);
Same here, I don't think this is needed.
Quoted 32 lines
drivers/base/cpuinfo.c new file +12
-0+return 0 ; +} + +static int cpuinfo_sysfs_init (void ) +{ +return cpuhp_setup_state (CPUHP_CPUINFO_PREPARE , +"base/cpuinfo:prepare" , + cpuinfo_add_dev, + cpuinfo_remove_dev); +} + +device_initcall (cpuinfo_sysfs_init);include/linux/cpuhotplug.h +1
-0@@ -78,6 +78,7 @@ enum cpuhp_state {CPUHP_SH_SH3X_PREPARE ,CPUHP_NET_FLOW_PREPARE ,CPUHP_TOPOLOGY_PREPARE , +CPUHP_CPUINFO_PREPARE ,CPUHP_NET_IUCV_PREPARE ,CPUHP_ARM_BL_PREPARE , CPUHP_TRACE_RB_PREPARE,include/linux/cpuinfo.h new file +2
-0@@ -0,0 +1,43 @@ +/* +* Copyright (C) 2017 SUSE Linux GmbH
include/linux/cpuinfo.h line 12
Quoted 10 lines
include/linux/cpuinfo.h new file +10
-0+* Written by: Felix Schnizlein <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version +* 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details.
SPDX and boilerplate.
include/linux/cpuinfo.h line 18
Quoted 6 lines
include/linux/cpuinfo.h new file +6
-0+*/ +#ifndef _LINUX_CPUINFO_H +#define _LINUX_CPUINFO_H + +#ifdef CONFIG_HAVE_CPUINFO_SYSFS +extern struct attribute *cpuinfo_attrs[];
No need for thie #ifdef really, right?
thanks,
greg k-h
Re: [PATCH 1/3] cpuinfo: add sysfs based arch independent cpuinfo framework
In reply to Thomas Renningerarch/Kconfig config STRICT_MODULE_RWX · line 886
Quoted 10 lines · Thomas Renninger
arch/Kconfig +2
-0@@ -882,6 +882,17 @@ config STRICT_MODULE_RWX and non-text memory will be made non-executable. This provides protection against certain security exploits (e.g. writing to text) +config CPUINFO_SYSFS + bool "Provides processor information in sysfs. Successor of /proc/cpuinfo"
Provide
arch/Kconfig config STRICT_MODULE_RWX
Quoted 4 lines
arch/Kconfig +4
-0+ def_bool y + depends on HAVE_CPUINFO_SYSFS + help + Provides architecture specific processor information in /sys/devices/system/cpu/info> + Use this instead of /proc/cpuinfo
End those 2 sentences with periods (full stop), please.
Quoted 7 lines
arch/Kconfig +4
-0+ +config HAVE_CPUINFO_SYSFS + bool + # select if the architecture provides an asm/dma-direct.h header config ARCH_HAS_PHYS_TO_DMA bool
Signature · 1 line
~Randy
PATCH v5 2/3 x86 cpuinfo: implement sysfs nodes for x86
In reply to Thomas RenningerFrom: Felix Schnizlein <[email protected]>
Enable sysfs cpuinfo for x86 based cpus. Export often used cpu information to sysfs:
stepping, flags, bugs, bogomips, family, vendor_id, model, and model_name are exported.
Sysfs documentation is updated to reflect changes.
Example (on a kvm instance running no an intel cpu):
/sys/devices/system/cpu/cpu1/info/:[0]# head * ==> bogomips <==
5187.72
==> bugs <==cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit
==> cpu_family <==
6
==> flags <==
fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm cpuid_fault invpcid_single pti ssbd ibrs ibpb fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip
==> model <==
60
==> model_name <==
Intel Core Processor (Haswell, no TSX, IBRS)
==> stepping <==
1
==> vendor_id <==
GenuineIntel
--- Documentation/ABI/testing/sysfs-devices-system-cpu | 23 +++++ arch/x86/Kconfig | 1 + arch/x86/kernel/Makefile | 2 + arch/x86/kernel/cpuinfo.c | 99 ++++++++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 arch/x86/kernel/cpuinfo.c
Documentation/ABI/testing/sysfs-devices-system-cpu +23 -0
@@ -581,3 +581,26 @@ Contact: Linux kernel mailing list <[email protected]> Description: Various information about the online cpu. Which attributes are available depends on the architecture, kernel configuration and cpu model. + +What: /sys/devices/system/cpu/cpu#/info/ + /sys/devices/system/cpu/cpu#/info/vendor_id + /sys/devices/system/cpu/cpu#/info/cpu_family + /sys/devices/system/cpu/cpu#/info/model + /sys/devices/system/cpu/cpu#/info/model_name + /sys/devices/system/cpu/cpu#/info/stepping + /sys/devices/system/cpu/cpu#/info/flags + /sys/devices/system/cpu/cpu#/info/bugs + /sys/devices/system/cpu/cpu#/info/bogomips +Date: June 2017 +Contact: Linux kernel mailing list <[email protected]> +Description: Expose information about x86 cpu information. + + vendor_id, + cpu_family, + model, + model_name, + stepping: Cpu identification depending on each vendor + + flags: Extended capabilities supported by the cpu + bugs: Known bugs by cpu + bogomips: calculated bogomips
arch/x86/Kconfig +1 -0
@@ -154,6 +154,7 @@ config X86 select HAVE_CMPXCHG_LOCAL select HAVE_CONTEXT_TRACKING if X86_64 select HAVE_COPY_THREAD_TLS + select HAVE_CPUINFO_SYSFS if SYSFS select HAVE_C_RECORDMCOUNT select HAVE_DEBUG_KMEMLEAK select HAVE_DMA_CONTIGUOUS
arch/x86/kernel/Makefile +2 -0
@@ -146,6 +146,8 @@ obj-$(CONFIG_UNWINDER_ORC) += unwind_orc.o obj-$(CONFIG_UNWINDER_FRAME_POINTER) += unwind_frame.o obj-$(CONFIG_UNWINDER_GUESS) += unwind_guess.o +obj-$(CONFIG_CPUINFO_SYSFS) += cpuinfo.o + ### # 64 bit specific files ifeq ($(CONFIG_X86_64),y)
arch/x86/kernel/cpuinfo.c new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
2.16.4
Greg KH
maintainerRe: [PATCH 2/3] x86 cpuinfo: implement sysfs nodes for x86
Quoted 14 lines · Thomas Renninger
From: Felix Schnizlein <[email protected]>
Enable sysfs cpuinfo for x86 based cpus. Export often used cpu information to sysfs:
stepping, flags, bugs, bogomips, family,vendor_id, model, andmodel_nameare exported.Sysfs documentation is updated to reflect changes.
Example (on a kvm instance running no an intel cpu):
/sys/devices/system/cpu/cpu1/info/:[0]# head * ==> bogomips <==
5187.72
Quoted 8 lines
==> bugs <==
cpu_meltdownspectre_v1spectre_v2spec_store_bypassl1tf mds swapgsitlb_multihit==>
cpu_family<==
6==> flags <==
fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lmconstant_tscrep_goodnopl xtopology cpuidtsc_known_freqpni pclmulqdq ssse3 fma cx16 pcidsse4_1sse4_2x2apic movbe popcnttsc_deadline_timeraes xsave avx f16c rdrand hypervisorlahf_lmabmcpuid_faultinvpcid_singlepti ssbd ibrs ibpb fsgsbasetsc_adjustbmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip
One file with all of that? We are going to run into problems eventually, that should be split up.
Just like bugs, that's going to just grow over time and eventually overflow PAGE_SIZE :(
Make this:
├── flags │ ├── fpu │ ├── vme
...
Much simpler to parse, right?
sysfs files need to be one-value-per-file, and that's a lot of different values in a single file.
How did I miss that before?
arch/x86/kernel/cpuinfo.c line 12
Quoted 13 lines
arch/x86/kernel/cpuinfo.c new file +12
-0@@ -0,0 +1,99 @@ +/* +* Copyright (C) 2017 SUSE Linux GmbH +* Written by: Felix Schnizlein <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version +* 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details.
Boilerplate and SPDX.
You did run these through checkpatch.pl, right? It should have complained about this.
thanks,
greg k-h
Re: [PATCH 2/3] x86 cpuinfo: implement sysfs nodes for x86
Quoted 11 lines · Greg KH
Quoted 3 lines · Thomas Renninger
From: Felix Schnizlein <[email protected]>
==> flags <==
fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lmconstant_tscrep_goodnopl xtopology cpuidtsc_known_freqpni pclmulqdq ssse3 fma cx16 pcidsse4_1sse4_2x2apic movbe popcnttsc_deadline_timeraes xsave avx f16c rdrand hypervisorlahf_lmabmcpuid_faultinvpcid_singlepti ssbd ibrs ibpb fsgsbasetsc_adjustbmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umipOne file with all of that? We are going to run into problems eventually, that should be split up.
Just like bugs, that's going to just grow over time and eventually overflow
PAGE_SIZE:(
Quoted 7 lines
Make this:
├── flags │ ├── fpu │ ├── vme...
Much simpler to parse, right?
Well, I'm not really sure whether 100+ files are simpler to parse.
Aside of that I really don't see the value for 100+ files per CPU which are just returning 1 or True or whatever as long as you are not suggesting to provide real feature files which have 0/1 or True/False content.
But I still don't get the whole thing. The only "argument" I've seen so far is the 'proc moves to sys' mantra, but that does not make it any better.
We won't get rid of /proc/cpuinfo for a very long time simply because too much userspace uses it. Introducing a mess in /sys/ in parallel just for following the mantra does not help much.
Also IF we ever expose feature flags in sys then this needs to be a split ino
cpu/common_features
and
cpu/CPU$N/unique_features
On most systems unique_features wont exist, but there is such stuff on the horizon.
Thanks,
tglx
Greg KH
maintainerRe: [PATCH 2/3] x86 cpuinfo: implement sysfs nodes for x86
Quoted 22 lines · Thomas Gleixner
Quoted 11 lines · Greg KH
Quoted 3 lines · Thomas Renninger
From: Felix Schnizlein <[email protected]>
==> flags <==
fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lmconstant_tscrep_goodnopl xtopology cpuidtsc_known_freqpni pclmulqdq ssse3 fma cx16 pcidsse4_1sse4_2x2apic movbe popcnttsc_deadline_timeraes xsave avx f16c rdrand hypervisorlahf_lmabmcpuid_faultinvpcid_singlepti ssbd ibrs ibpb fsgsbasetsc_adjustbmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umipOne file with all of that? We are going to run into problems eventually, that should be split up.
Just like bugs, that's going to just grow over time and eventually overflow
PAGE_SIZE:(Quoted 7 lines
Make this:
├── flags │ ├── fpu │ ├── vme...
Much simpler to parse, right?
Well, I'm not really sure whether 100+ files are simpler to parse.
Quoted 8 lines
Aside of that I really don't see the value for 100+ files per CPU which are just returning 1 or True or whatever as long as you are not suggesting to provide real feature files which have 0/1 or True/False content.
But I still don't get the whole thing. The only "argument" I've seen so far is the 'proc moves to sys' mantra, but that does not make it any better.
That is not a valid mantra, as I tried to explain later in this thread.
I don't understand the need for this patchset either, all I was trying to do was to at least make it sane from a sysfs-point-of-view if people really wanted to do this type of thing.
Quoted 3 lines
We won't get rid of
/proc/cpuinfofor a very long time simply because too much userspace uses it. Introducing a mess in/sys/in parallel just for following the mantra does not help much.
Again, invalid mantra, not a valid reason :)
I think this is a patchset in search of a problem, which is why it was dropped all those years ago...
thanks,
greg k-h
Re: [PATCH 2/3] x86 cpuinfo: implement sysfs nodes for x86
In reply to Thomas GleixnerQuoted 24 lines · CET Thomas Gleixner
Quoted 23 lines · Greg KH
Quoted 9 lines · Thomas Renninger
From: Felix Schnizlein <[email protected]>
==> flags <==
fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lmconstant_tscrep_goodnopl xtopology cpuidtsc_known_freqpni pclmulqdq ssse3 fma cx16 pcidsse4_1sse4_2x2apic movbe popcnttsc_deadline_timeraes xsave avx f16c rdrand hypervisorlahf_lmabmcpuid_faultinvpcid_singlepti ssbd ibrs ibpb fsgsbasetsc_adjustbmi1 avx2 smep bmi2 erms invpcid xsaveopt arat umip>One file with all of that? We are going to run into problems eventually, that should be split up.
Just like bugs, that's going to just grow over time and eventually overflow
PAGE_SIZE:(Make this:
├── flags │ ├── fpu │ ├── vme...
Quoted 8 lines
Quoted 1 line
Much simpler to parse, right?
Well, I'm not really sure whether 100+ files are simpler to parse.
Aside of that I really don't see the value for 100+ files per CPU which are just returning 1 or True or whatever as long as you are not suggesting to provide real feature files which have 0/1 or True/False content.
I also do not like the one file per cpu flag approach.
This still is one "data"/"info" per sysfs file.
Similar to:
cpu/cpufreq/policy1/scaling_available_governors
and probably a lot others. If PAGE_SIZE overflow has to be cared for, then be it.
Quoted 6 lines
But I still don't get the whole thing. The only "argument" I've seen so far is the 'proc moves to sys' mantra, but that does not make it any better.
We won't get rid of
/proc/cpuinfofor a very long time simply because too much userspace uses it.
The reason we will never get rid of it is:
Newly written userspace tools still (have to) make use it. This is because of a small set of remaining info which is convenient to have in userspace but which is not avail in sysfs yet.
Therefore only x of the 26 /proc/cpuinfo data has been picked up.
For decades unused info like:
fpu : yesfpu_exception : yes
cpuid level : 13
wp : yes
power management:
shall die at (long but) some point of time.
It's quite some years ago when acpi and cpufreq proc info first got deprecated and duplicated in sys.
It has been said that it needs years of deprecation that the event file on which damons were listening for acpi events can ever be removed... It has been 2013 when the removal has been done, more than 5 years ago:1696d9dc57e062ce5200f6a42a6aaada15b434bb
ACPI: Remove the old /proc/acpi/event interface
/proc/cpuinfo may need some years more, but there should be no reason it is still getting used.
Quoted 11 lines
Introducing a mess in
/sys/in parallel just
for following the mantra does not help much.Also IF we ever expose feature flags in sys then this needs to be a split ino
cpu/common_features
and
cpu/CPU$N/unique_features
Makes sense.
feature (without common/unique) is also a better naming than flags.
If Greg (and others) are ok, I would add "page size exceeding" handling. Hm, quick searching for an example I realize that debugfs can exceed page size. Is it that hard to expose a sysfs file larger than page size?
Quoted 2 lines
On most systems
unique_featureswont exist, but there is such stuff on the horizon.
I still wait a bit before doing work for nothing.
I hope everybody agrees, that remaining useful info in /proc/cpuinfo should show up in /sys if that did not happen yet. And that userspace tools should not (need to) make use of /proc/cpuinfo anymore.
Thomas
Greg KH
maintainerRe: [PATCH 2/3] x86 cpuinfo: implement sysfs nodes for x86
Quoted 3 lines · Thomas Renninger
If Greg (and others) are ok, I would add "page size exceeding" handling. Hm, quick searching for an example I realize that debugfs can exceed page size. Is it that hard to expose a sysfs file larger than page size?
No, there is a simple way to do it, but I'm not going to show you how as it is NOT how to use sysfs at all :)
Why are you wanting to dump this whole mess into one file and then parse it, it's no different from having 100+ different sysfs files and then doing a readdir(3) on the thing, right?
greg k-h
Re: [PATCH 2/3] x86 cpuinfo: implement sysfs nodes for x86
Quoted 9 lines · CET Greg KH
Quoted 3 lines · Thomas Renninger
If Greg (and others) are ok, I would add "page size exceeding" handling. Hm, quick searching for an example I realize that debugfs can exceed page size. Is it that hard to expose a sysfs file larger than page size?
No, there is a simple way to do it, but I'm not going to show you how as it is NOT how to use sysfs at all :)
Why are you wanting to dump this whole mess into one file
I wouldn't call a whitespace separated list of CPU feature flags a mess...
Quoted 3 lines
and then parse
it, it's no different from having 100+ different sysfs files and then doing a readdir(3) on the thing, right?
If this is the way it "has to"/should/"is designed for" to export such (not that complex) data via sysfs...
I do not have such a strong opinion on the how, this is up to maintainers to discuss.
I hope it is agreed that this info is worth exporting via sysfs. So I wait for the "how are CPU feature flags/bugs data" to be exported via sysfs and I volunteer to pick it up and submit a patch out of it.
Thanks,
Thomas
Greg KH
maintainerRe: [PATCH 2/3] x86 cpuinfo: implement sysfs nodes for x86
Quoted 6 lines · Thomas Renninger
Quoted 5 lines · CET Greg KH
Quoted 3 lines · Thomas Renninger
If Greg (and others) are ok, I would add "page size exceeding" handling. Hm, quick searching for an example I realize that debugfs can exceed page size. Is it that hard to expose a sysfs file larger than page size?
Quoted 6 lines
Quoted 4 lines
No, there is a simple way to do it, but I'm not going to show you how as it is NOT how to use sysfs at all :)
Why are you wanting to dump this whole mess into one file
I wouldn't call a whitespace separated list of CPU feature flags a mess...
It's a mess in that it's more than one value and you want to overflow a PAGE_SIZE sometime in the future with it :(
Quoted 11 lines
Quoted 3 lines
and then parse
it, it's no different from having 100+ different sysfs files and then doing a readdir(3) on the thing, right?If this is the way it "has to"/should/"is designed for" to export such (not that complex) data via sysfs...
I do not have such a strong opinion on the how, this is up to maintainers to discuss.
I hope it is agreed that this info is worth exporting via sysfs.
I don't think anyone is saying it is worth exporting this information via sysfs at all here.
thanks,
greg k-h
Re: [PATCH 2/3] x86 cpuinfo: implement sysfs nodes for x86
Quoted 3 lines · CET Greg KH
Quoted 2 lines · Thomas Renninger
Quoted 1 line · CET Greg KH
On Wed, Dec 11, 2019 at 11:42:35AM +0100, Thomas Renninger wrote:
...
Quoted 4 lines
Quoted 1 line
I hope it is agreed that this info is worth exporting via sysfs.
I don't think anyone is saying it is worth exporting this information via sysfs at all here.
Ok. I go for cpuid userspace tool then.
I'd still say general files like:
cpu/info/{name,vendor}
make sense, so that if exported by an arch like in cpuinfo, it should show up in the same file.
Every cpu has a model name and a vendor and cpuid is x86 only.
If there should be need for /sys/devices/cpu/cpu0.. info/feature/name whatever in the future..., let me know ;)
Thomas
Greg KH
maintainerRe: [PATCH 2/3] x86 cpuinfo: implement sysfs nodes for x86
Quoted 12 lines · Thomas Renninger
Quoted 3 lines · CET Greg KH
Quoted 2 lines · Thomas Renninger
Quoted 1 line · CET Greg KH
On Wed, Dec 11, 2019 at 11:42:35AM +0100, Thomas Renninger wrote:
...
Quoted 4 lines
Quoted 1 line
I hope it is agreed that this info is worth exporting via sysfs.
I don't think anyone is saying it is worth exporting this information via sysfs at all here.
Quoted 7 lines
Ok. I go for cpuid userspace tool then.
I'd still say general files like:
cpu/info/{name,vendor}
make sense, so that if exported by an arch like in cpuinfo, it should show up in the same file.
Every cpu has a model name and a vendor and cpuid is x86 only.
I think you just saw the ARM developers arguing about model names, so I don't think people will agree with that :)
goo dluck!
greg k-h
PATCH v5 3/3 arm64 cpuinfo: implement sysfs nodes for arm64
In reply to Thomas RenningerFrom: Felix Schnizlein <[email protected]>
Export all information from /proc/cpuinfo to sysfs:
implementer, architecture, variant, part, revision, bogomips and flags are exported.
Example:
/sys/devices/system/cpu/cpu1/info/:[0]# head *
==> architecture <==
8
==> bogomips <==
40.00
==> flags <==
fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdm
==> implementer <==0x51
==> part <==0xc00
==> revision <==
1
==> variant <==0x0
--- Documentation/ABI/testing/sysfs-devices-system-cpu | 22 +++++++++ arch/arm64/Kconfig | 1 + arch/arm64/kernel/cpuinfo.c | 55 ++++++++++++++++++++++ 3 files changed, 78 insertions(+)
Documentation/ABI/testing/sysfs-devices-system-cpu +22 -0
@@ -604,3 +604,25 @@ Description: Expose information about x86 cpu information. flags: Extended capabilities supported by the cpu bugs: Known bugs by cpu bogomips: calculated bogomips + + +What: /sys/devices/system/cpu/cpu#/info/ + /sys/devices/system/cpu/cpu#/info/implementer + /sys/devices/system/cpu/cpu#/info/architecture + /sys/devices/system/cpu/cpu#/info/variant + /sys/devices/system/cpu/cpu#/info/part + /sys/devices/system/cpu/cpu#/info/revision + /sys/devices/system/cpu/cpu#/info/flags + /sys/devices/system/cpu/cpu#/info/bogomips +Date: August 2017 +Contact: Linux kernel mailing list <[email protected]> +Description: Expose information about arm64 cpu. + + implementer, + architecture, + variant, + part, + revision: Cpu identification depending on each vendor + + flags: Extended capabilities supported by the cpu + bogomips: calculated bogomips
arch/arm64/Kconfig +1 -0
@@ -169,6 +169,7 @@ config ARM64 select HAVE_KPROBES select HAVE_KRETPROBES select HAVE_GENERIC_VDSO + select HAVE_CPUINFO_SYSFS if SYSFS select IOMMU_DMA if IOMMU_SUPPORT select IRQ_DOMAIN select IRQ_FORCED_THREADING
arch/arm64/kernel/cpuinfo.c +55 -0
73 lines not on this page · raw message
Signature · 1 line
2.16.4
Greg KH
maintainerRe: [PATCH 3/3] arm64 cpuinfo: implement sysfs nodes for arm64
Quoted 11 lines · Thomas Renninger
From: Felix Schnizlein <[email protected]>
Export all information from
/proc/cpuinfoto sysfs:
implementer, architecture, variant, part, revision, bogomips and flags are exported.Example:
/sys/devices/system/cpu/cpu1/info/:[0]# head *
==> architecture <==
8
Quoted 5 lines
==> bogomips <==
40.00==> flags <==
fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdm
Same comments as on the x86 patch :(
Will Deacon
maintainerRe: [PATCH 3/3] arm64 cpuinfo: implement sysfs nodes for arm64
In reply to Thomas RenningerQuoted 29 lines · Thomas Renninger
From: Felix Schnizlein <[email protected]>
Export all information from
/proc/cpuinfoto sysfs:
implementer, architecture, variant, part, revision, bogomips and flags are exported.Example:
/sys/devices/system/cpu/cpu1/info/:[0]# head *
==> architecture <==
8==> bogomips <==
40.00==> flags <==
fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdm==> implementer <==
0x51==> part <==
0xc00==> revision <==
1==> variant <==
0x0
Quoted 7 lines
Signed-off-by Thomas Renninger <[email protected]>Signed-off-by Felix Schnizlein <[email protected]>--- Documentation/ABI/testing/sysfs-devices-system-cpu | 22 +++++++++ arch/arm64/Kconfig | 1 + arch/arm64/kernel/cpuinfo.c | 55 ++++++++++++++++++++++ 3 files changed, 78 insertions(+)
I don't understand why we need this on arm64 and why it's an improvement over all the other schemes we already support for identifying CPU features.
Given the pain we've endured over the years exposing this sort of stuff to userspace, I'm relucant to add more just for the fun of it.
Will
Re: [PATCH 3/3] arm64 cpuinfo: implement sysfs nodes for arm64
Quoted 9 lines · CET Will Deacon
Quoted 8 lines · Thomas Renninger
From: Felix Schnizlein <[email protected]>
Export all information from
/proc/cpuinfoto sysfs:
implementer, architecture, variant, part, revision, bogomips and flags are exported.Example:
/sys/devices/system/cpu/cpu1/info/:[0]# head *
...
Quoted 2 lines
Quoted 2 lines
==> flags <==
fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdm
...
Quoted 1 line
I don't understand why we need this on arm64
The first intention of these patches is to port x86 /proc/cpuinfo.
Because of the divergence of /proc/cpuinfo and the totally different info exported there across architectures,
therefore it is also tried to get a unified interface across architectures where possible.
So for flags and bugs this may work out, right?
For the rest, it looks like people again only had their CPU in mind and exported to userspace what currently was needed...
Quoted 2 lines
and why it's an improvement
over all the other schemes we already support for identifying CPU features.
Sigh...
Quoted 2 lines
Given the pain we've endured over the years exposing this sort of stuff to userspace, I'm relucant to add more just for the fun of it.
If there should ever be something like a string describing the CPU... In x86 it comes from the CPU itself.
Maybe we get a model description at some point as well...
Or any other entity which may also get exported on other archs..
Please remember this interface and watch out whether you could export things under the same name as done on other architectures.
I'll revert everything but flags for ARM now.
But this is the best example for the need of a generic interface:
x86 - /proc/cpuinfo:
flags : ...
arm64 - /proc/cpuinfo:
Features : ...
even it is exactly the same kernel interface, even x86 flags are used according to arch/arm64/include/asm/cpufeature.h:
* We use arm64_cpu_capabilities to represent system features, errata work
But it is named differently in /proc/cpuinfo.
This should not happen again in /sys/...
Thomas
Will Deacon
maintainerRe: [PATCH 3/3] arm64 cpuinfo: implement sysfs nodes for arm64
Quoted 13 lines · Thomas Renninger
Quoted 9 lines · CET Will Deacon
Quoted 8 lines · Thomas Renninger
From: Felix Schnizlein <[email protected]>
Export all information from
/proc/cpuinfoto sysfs:
implementer, architecture, variant, part, revision, bogomips and flags are exported.Example:
/sys/devices/system/cpu/cpu1/info/:[0]# head *...
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
==> flags <==
fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdm...
Quoted 1 line
I don't understand why we need this on arm64
The first intention of these patches is to port x86
/proc/cpuinfo.
That doesn't answer my question. Why do we want a port of x86 /proc/cpuinfo on arm64? Or do you mean something else?
Quoted 4 lines
Because of the divergence of
/proc/cpuinfoand the totally different info exported there across architectures,
therefore it is also tried to get a unified interface across architectures where possible.
But as you say, the information is totally different, so I think the scope for a unified interface is somewhat questionable. Can you give some examples of when a piece of architecture-agnostic software can sensibly benefit from this interface in a way that couldn't be achieved already using a userspace library, please?
Quoted 1 line
So for flags and bugs this may work out, right?
We don't have a 'bugs' entry on arm64, so I don't understand why you're mentioning that as an example of something that works well here. The flags thing is a set of architecture-specific strings, so why is having a common interface at all useful there? Even if we exposed them via sysfs, existing software will continue to grep them out of /proc/cpuinfo because it's more reliable and new software would still be encouraged to use either the HWCAPs directly or, even better, our CPUID (MRS) emulation.
Quoted 2 lines
For the rest, it looks like people again only had their CPU in mind and exported to userspace what currently was needed...
Cool story: we tried to tidy up our /proc/cpuinfo format for arm64 because we were aware that it was an ABI nightmare that wasn't fully understood, so we played it very cautiously. Unfortunately, it turned out that real applications got in the way and we basically had to follow an arm32-like format to avoid breaking userspace. But it is what it is and I don't really fancy exposing more stuff without decent rationale...
Quoted 4 lines
Quoted 2 lines
and why it's an improvement
over all the other schemes we already support for identifying CPU features.Sigh...
... which this isn't. :/
Quoted 8 lines
Quoted 2 lines
Given the pain we've endured over the years exposing this sort of stuff to userspace, I'm relucant to add more just for the fun of it.
If there should ever be something like a string describing the CPU... In x86 it comes from the CPU itself.
Maybe we get a model description at some point as well...Or any other entity which may also get exported on other archs..
Not sure who this is aimed at tbh.
Quoted 4 lines
Please remember this interface and watch out whether you could export things under the same name as done on other architectures.
I'll revert everything but flags for ARM now.
Please revert the whole lot for arm64, I don't even want to see the iCPU feature flags exposed like this without a good justification.
Quoted 7 lines
But this is the best example for the need of a generic interface:
x86 -
/proc/cpuinfo:
flags : ...
arm64 -/proc/cpuinfo:
Features : ...
Quoted 6 lines
even it is exactly the same kernel interface, even x86 flags are used according to
arch/arm64/include/asm/cpufeature.h:* We use
arm64_cpu_capabilitiesto represent system features, errata workBut it is named differently in
/proc/cpuinfo.
As I said earlier, that's the least of your worries. The *contents of the string* is entirely different based on the architecture. Here's a quiz for you:
arm32 Feature arm64 Feature x86 flag Same thing?
"vfp" "fp" "fpu"
"idivt" "cpuid" "cpuid"
"edsp" "sve2" "sse2"
"aes" "ssbs" "ssbd"
"swp" "sb" "ss"So it's all well and good having everybody call these either "Features" or "flags", but I think you're missing the real issue which is that the values themselves are meaningless without architecture-specific knowledge, at which point you can parse /proc/cpuinfo accordingly.
Unless I missed it, you also don't seem to handle compat tasks at all in your patch.
Quoted 1 line
This should not happen again in
/sys/...
I wish I could believe you.
Will
Re: [PATCH 3/3] arm64 cpuinfo: implement sysfs nodes for arm64
Quoted 12 lines · CET Will Deacon
Quoted 11 lines · Thomas Renninger
Quoted 9 lines · CET Will Deacon
Quoted 8 lines · Thomas Renninger
From: Felix Schnizlein <[email protected]>
Export all information from
/proc/cpuinfoto sysfs:
implementer, architecture, variant, part, revision, bogomips and flags are exported.Example:
/sys/devices/system/cpu/cpu1/info/:[0]# head *
Quoted 8 lines
Quoted 8 lines
...
Quoted 2 lines
Quoted 2 lines
==> flags <==
fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdm...
Quoted 1 line
I don't understand why we need this on arm64
Again: proc is moving to sys.
You probably export feature flags in /proc/cpuinfo for a good reason. So where in sysfs should this show up?
Quoted 4 lines
Even if we exposed them via sysfs, existing
software will continue to grep them out of/proc/cpuinfobecause it's more reliable and new software would still be encouraged to use either the HWCAPs directly or, even better, our CPUID (MRS) emulation.
Ok, so /proc/cpuinfo
Features:
is deprecated on arm64. Is that correct?
Then it would indeed not make sense to port it/anything to sys.
It is this comment you are referring to:
arch/arm64/kernel/cpuinfo.c
* Dump out the common processor features in a single line.
* Userspace should read the hwcaps with getauxval(AT_HWCAP)
* rather than attempting to parse this, but there's a body of
* software which does already (at least for 32-bit).
Then let's shorten this.
Sorry for keep digging/asking.
Felix made this up rather neat, so that other archs can implement to expose sysfs CPU info easy and consistent.
While x86 also ported parts of cpuinfo, e.g. microcode version, most general info is still missing in sysfs.
If I find the time, I may check for other archs like ppc64le or s390x to find data which still should show up in sysfs and could then be put in the same directory/file structure.
ARM people may still want to make use of this at some point of time, if appropriate. I'll drop patch 3/3.
Thanks for explaining me the ARM details,
Thomas
Greg KH
maintainerRe: [PATCH 3/3] arm64 cpuinfo: implement sysfs nodes for arm64
Quoted 15 lines · Thomas Renninger
Quoted 14 lines · CET Will Deacon
Quoted 13 lines · Thomas Renninger
Quoted 9 lines · CET Will Deacon
Quoted 8 lines · Thomas Renninger
From: Felix Schnizlein <[email protected]>
Export all information from
/proc/cpuinfoto sysfs:
implementer, architecture, variant, part, revision, bogomips and flags are exported.Example:
/sys/devices/system/cpu/cpu1/info/:[0]# head *...
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
==> flags <==
fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdm...
Quoted 1 line
I don't understand why we need this on arm64
Again: proc is moving to sys.
No. New stuff is to be added to /sys/, don't add new things to /proc unless it deals with processes.
There is no mass-migration of existing /proc files to sysfs for no good reason.
Quoted 2 lines
You probably export feature flags in
/proc/cpuinfofor a good reason. So where in sysfs should this show up?
Why does it have to live in sysfs if it is already in /proc and parsed properly by tools?
thanks,
greg k-h
Re: [PATCH 3/3] arm64 cpuinfo: implement sysfs nodes for arm64
Quoted 28 lines · CET Greg KH
Quoted 15 lines · Thomas Renninger
Quoted 14 lines · CET Will Deacon
Quoted 13 lines · Thomas Renninger
Quoted 9 lines · CET Will Deacon
Quoted 8 lines · Thomas Renninger
From: Felix Schnizlein <[email protected]>
Export all information from
/proc/cpuinfoto sysfs:
implementer, architecture, variant, part, revision, bogomips and flags are exported.Example:
/sys/devices/system/cpu/cpu1/info/:[0]# head *...
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
==> flags <==
fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdm...
Quoted 1 line
I don't understand why we need this on arm64
Again: proc is moving to sys.
No. New stuff is to be added to
/sys/, don't add new things to /proc unless it deals with processes.
Quoted 8 lines
There is no mass-migration of existing /proc files to sysfs for no good reason.
Quoted 2 lines
You probably export feature flags in
/proc/cpuinfofor a good reason. So where in sysfs should this show up?Why does it have to live in sysfs if it is already in /proc and parsed properly by tools?
Parsing /proc/cpuinfo is the best example why we have sysfs... Most important things have already been ported:
microcode : 0x10
cat /sys/devices/system/cpu/cpu1/microcode/version 0x10
physical id : 0
siblings : 8
core id : 1
cpu cores : 4
.../sys/devices/system/cpu/cpu1/topology/
clflush size : 64cache_alignment : 64
.../sys/devices/system/cpu/cpu1/cache/
Only missing important info which still is needed is family/model/stepping, name, bugs and flags
cpufreq also got ported to sysfs quite some time ago already.
I am aware that /proc/cpuinfo won't vanish...
...the next decade. Still I am confident I will still see this.
Still relevant info which is accessed by (newly written) userspace tools should read out info via sysfs.
Beside microcode, topology, cache, cpufreq,...
info, there now is also family, model, stepping, bugs, flags and name
There rest is (from my perspective) really old ugly stuff and not needed anymore by recent tools.
Thomas
Mark Rutland
reviewerHi Thomas,
Quoted 9 lines · Thomas Renninger
I picked up Felix Schnizlein's work from 2017.
It was already reviewed by Greg-KH at this time and even pushed into linux-next tree, when it came out that the mails never reached lkml, even the list was added to CC.
ARM people then correctly complained that this needs more review by ARCH people. It got reverted, Felix had no time anymore and this nice patcheset was hanging around nowhere...
Can you please provide a rationale for this?
It's not entirely clear to me what information people need or want, and there's some data in /proc/cpuinfo that I think makes no sense to try to export export in a structured way (e.g. bogomips).
Quoted 21 lines
Tested on aarch64:
/sys/devices/system/cpu/cpu1/info/:[0]# ls
architecture bogomips flags implementer part revision variant------------------------------------------------------------
for file in *;do echo $file; cat $file;echo;done
architecture
8bogomips
40.00flags
fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdmimplementer
0x51
Quoted 8 lines
part
0xc00revision
1variant
0x0
For arm64 we already expose the MIDR and REVIDR register values under /sys/devices/system/cpu/cpu*/regs/identification, and that's the bulk of the useful information above (aside from the flags/hwcaps).
Thanks,
Mark.
Quoted 9 lines · CET Mark Rutland
Hi Thomas,
Quoted 6 lines · Thomas Renninger
I picked up Felix Schnizlein's work from 2017.
It was already reviewed by Greg-KH at this time and even pushed into linux-next tree, when it came out that the mails never reached lkml, even the list was added to CC.
Quoted 5 lines
Quoted 3 lines
ARM people then correctly complained that this needs more review by ARCH people. It got reverted, Felix had no time anymore and this nice patcheset was hanging around nowhere...
Can you please provide a rationale for this?
/proc moves to /sys. For years already, some data needs longer...
If you compare /proc/cpuinfo between different archs, you realize that it is rather different and a huge mess of arbitrary info.
It would be great if people think a bit more about this... What else could show up on which architecture to avoid different interfaces (sys files) with the same info across architectures.
I'd like to have general CPU identification, and other info like bugs, flags or whatever info that exists across architectures in one sysfs file/directory.
arch=$(uname -m)
case $arch in
x86_64)
cat /sys/devices/system/cpu/cpu0/info/name
;;
aarch64)
cat /sys/devices/system/cpu/cpu0/regs/identification
:: ...
esac
This is better than grepping on different identifiers in huge /proc/cpuinfo, but it still is lame.
Ideal would be:/sys/devices/system/cpu/cpu0/info/{name,vendor,flags,bugs,base_freq,...} being avail for all CPUs on all archs.
if it does not exist yet..., it should at least show up there if it gets implemented at some point of time.
Quoted 2 lines
there's some data in
/proc/cpuinfothat I think makes no sense to try to export export in a structured way (e.g. bogomips).
I'd be happy to remove bogomips if nobody needs this.
Quoted 27 lines
Quoted 27 lines
Tested on aarch64:
/sys/devices/system/cpu/cpu1/info/:[0]# ls
architecture bogomips flags implementer part revision variant------------------------------------------------------------
for file in *;do echo $file; cat $file;echo;done
architecture
8bogomips
40.00flags
fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid asimdrdmimplementer
0x51part
0xc00revision
1
Quoted 6 lines
Quoted 2 lines
variant
0x0For arm64 we already expose the MIDR and REVIDR register values under
/sys/devices/system/cpu/cpu*/regs/identification, and that's the bulk of the useful information above
I'd like to come up with an extra CONFIG which parses:
arch/arm64/include/asm/cputype.h:
#define ARM_CPU_PART_AEM_V8 0xD0F #define ARM_CPU_PART_FOUNDATION 0xD00 #define ARM_CPU_PART_CORTEX_A57 0xD07 #define ARM_CPU_PART_CORTEX_A72 0xD08
and
#define ARM_CPU_IMP_ARM 0x41 #define ARM_CPU_IMP_APM 0x50 #define ARM_CPU_IMP_CAVIUM 0x43 #define ARM_CPU_IMP_BRCM 0x42 #define ARM_CPU_IMP_QCOM 0x51 #define ARM_CPU_IMP_NVIDIA 0x4E
and converts the defines to strings, same as here:
arch/x86/include/asm/intel-family.h
#define INTEL_FAM6_SKYLAKE_L 0x4E #define INTEL_FAM6_SKYLAKE 0x5E #define INTEL_FAM6_SKYLAKE_X 0x55 #define INTEL_FAM6_KABYLAKE_L 0x8E #define INTEL_FAM6_KABYLAKE 0x9E
and provide the model name (and for ARM the vendor name) compiled in a module.
At least for aarch64 and x86 it seem to be possible to get a vendor/model string from the same defined file:/sys/devices/system/cpu/cpu0/info/{model_name,vendor}
Quoted 1 line
(aside from the flags/hwcaps).
which make sense to add there, right?
Thanks,
Thomas
Mark Rutland
reviewerQuoted 18 lines · Thomas Renninger
Quoted 5 lines · CET Mark Rutland
On Fri, Dec 06, 2019 at 05:24:18PM +0100, Thomas Renninger wrote:
For arm64 we already expose the MIDR and REVIDR register values under
/sys/devices/system/cpu/cpu*/regs/identification, and that's the bulk of the useful information aboveI'd like to come up with an extra CONFIG which parses:
arch/arm64/include/asm/cputype.h:#define ARM_CPU_PART_AEM_V8 0xD0F #define ARM_CPU_PART_FOUNDATION 0xD00 #define ARM_CPU_PART_CORTEX_A57 0xD07 #define ARM_CPU_PART_CORTEX_A72 0xD08and
Quoted 8 lines
#define ARM_CPU_IMP_ARM 0x41 #define ARM_CPU_IMP_APM 0x50 #define ARM_CPU_IMP_CAVIUM 0x43 #define ARM_CPU_IMP_BRCM 0x42 #define ARM_CPU_IMP_QCOM 0x51 #define ARM_CPU_IMP_NVIDIA 0x4Eand converts the defines to strings, same as here:
A similar approach for /proc/cpuinfo has been NAK'd repeatedly in the past. While some arguments against that don't apply here, I don't think that we want to have to maintain an ever-growing list of strings that end up being ABI which we cannot manage in a forwards-compatible manner.
When it is necessary to reliably and unambiguously identify a CPU, it'll always end up being necessary to look at the MIDR (and possibly REVIDR), so that's what applications should always do, and it's what users will necessarily have to do when the kernel doesn't have a string for a CPU, as is the case for all existing kernels.
I don't think that in-kernel stringification of the MIDR is a good idea, and I would suggest not wasting your time on that.
Thanks,
Mark.