Skip to content

Commit ab28e94

Browse files
aeglsuryasaimadhu
authored andcommitted
topology/sysfs: Add PPIN in sysfs under cpu topology
PPIN is the Protected Processor Identification Number. This is used to identify the socket as a Field Replaceable Unit (FRU). Existing code only displays this when reporting errors. But this makes it inconvenient for large clusters to use it for its intended purpose of inventory control. Add ppin to /sys/devices/system/cpu/cpu*/topology to make what is already available using RDMSR more easily accessible. Make the file read only for root in case there are still people concerned about making a unique system "serial number" available. Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 182ecfa commit ab28e94

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

Documentation/ABI/stable/sysfs-devices-system-cpu

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ What: /sys/devices/system/cpu/cpuX/topology/die_cpus
8686
Description: internal kernel map of CPUs within the same die.
8787
Values: hexadecimal bitmask.
8888

89+
What: /sys/devices/system/cpu/cpuX/topology/ppin
90+
Description: per-socket protected processor inventory number
91+
Values: hexadecimal.
92+
8993
What: /sys/devices/system/cpu/cpuX/topology/die_cpus_list
9094
Description: human-readable list of CPUs within the same die.
9195
The format is like 0-3, 8-11, 14,17.

Documentation/ABI/testing/sysfs-devices-system-cpu

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ What: /sys/devices/system/cpu/cpuX/topology/core_id
7373
/sys/devices/system/cpu/cpuX/topology/physical_package_id
7474
/sys/devices/system/cpu/cpuX/topology/thread_siblings
7575
/sys/devices/system/cpu/cpuX/topology/thread_siblings_list
76+
/sys/devices/system/cpu/cpuX/topology/ppin
7677
Date: December 2008
7778
Contact: Linux kernel mailing list <[email protected]>
7879
Description: CPU topology files that describe a logical CPU's relationship
@@ -103,6 +104,11 @@ Description: CPU topology files that describe a logical CPU's relationship
103104
thread_siblings_list: human-readable list of cpuX's hardware
104105
threads within the same core as cpuX
105106

107+
ppin: human-readable Protected Processor Identification
108+
Number of the socket the cpu# belongs to. There should be
109+
one per physical_package_id. File is readable only to
110+
admin.
111+
106112
See Documentation/admin-guide/cputopology.rst for more information.
107113

108114

arch/x86/include/asm/topology.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ extern const struct cpumask *cpu_clustergroup_mask(int cpu);
110110
#define topology_logical_die_id(cpu) (cpu_data(cpu).logical_die_id)
111111
#define topology_die_id(cpu) (cpu_data(cpu).cpu_die_id)
112112
#define topology_core_id(cpu) (cpu_data(cpu).cpu_core_id)
113+
#define topology_ppin(cpu) (cpu_data(cpu).ppin)
113114

114115
extern unsigned int __max_die_per_package;
115116

drivers/base/topology.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ static DEVICE_ATTR_RO(cluster_id);
5858
define_id_show_func(core_id, "%d");
5959
static DEVICE_ATTR_RO(core_id);
6060

61+
define_id_show_func(ppin, "0x%llx");
62+
static DEVICE_ATTR_ADMIN_RO(ppin);
63+
6164
define_siblings_read_func(thread_siblings, sibling_cpumask);
6265
static BIN_ATTR_RO(thread_siblings, 0);
6366
static BIN_ATTR_RO(thread_siblings_list, 0);
@@ -145,6 +148,7 @@ static struct attribute *default_attrs[] = {
145148
#ifdef TOPOLOGY_DRAWER_SYSFS
146149
&dev_attr_drawer_id.attr,
147150
#endif
151+
&dev_attr_ppin.attr,
148152
NULL
149153
};
150154

include/linux/topology.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ static inline int cpu_to_mem(int cpu)
211211
#ifndef topology_drawer_id
212212
#define topology_drawer_id(cpu) ((void)(cpu), -1)
213213
#endif
214+
#ifndef topology_ppin
215+
#define topology_ppin(cpu) ((void)(cpu), 0ull)
216+
#endif
214217
#ifndef topology_sibling_cpumask
215218
#define topology_sibling_cpumask(cpu) cpumask_of(cpu)
216219
#endif

0 commit comments

Comments
 (0)