Skip to contentSkip to conversation

sparc64: Setup sysfs to mark LDOM sockets, cores and threads correctly

PATCH Superseded chris hyser 1 participant 1 message Mar 30, 2015 SPARC + UltraSPARC (sparc/sparc64)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sparc64: Setup sysfs to mark LDOM sockets, cores and threads correctly

sparc64: Setup sysfs to mark LDOM sockets, cores and threads correctly

The current sparc kernel has no representation for sockets though tools like lscpu can pull this from sysfs. This patch walks the machine description cache and socket hierarchy and marks sockets as well as cores and threads such that a representative sysfs is created by drivers/base/topology.c.

Before this patch:

$ lscpu
Architecture:          sparc64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Big Endian
CPU(s):                1024
On-line CPU(s) list:   0-1023
Thread(s) per core:    8
Core(s) per socket:    1     <--- wrong
Socket(s):             128   <--- wrong
NUMA node(s):          4
NUMA node0 CPU(s):     0-255
NUMA node1 CPU(s):     256-511
NUMA node2 CPU(s):     512-767
NUMA node3 CPU(s):     768-1023

After this patch:

$ lscpu
Architecture:          sparc64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Big Endian
CPU(s):                1024
On-line CPU(s) list:   0-1023
Thread(s) per core:    8
Core(s) per socket:    32
Socket(s):             4
NUMA node(s):          4
NUMA node0 CPU(s):     0-255
NUMA node1 CPU(s):     256-511
NUMA node2 CPU(s):     512-767
NUMA node3 CPU(s):     768-1023

Most of this patch was done by Chris with updates by David.

arch/sparc/include/asm/cpudata_64.h +2 -1
index a6e424d..a6cfdab 100644
@@ -24,7 +24,8 @@ typedef struct {
  	unsigned int	icache_line_size;
  	unsigned int	ecache_size;
  	unsigned int	ecache_line_size;
-	int		core_id;
+	unsigned short	sock_id;
+	unsigned short	core_id;
  	int		proc_id;
  } cpuinfo_sparc;
 
arch/sparc/include/asm/topology_64.h +2 -1
index ed8f071..d1761df 100644
@@ -40,11 +40,12 @@ static inline int pcibus_to_node(struct pci_bus *pbus)
  #ifdef CONFIG_SMP
  #define topology_physical_package_id(cpu)	(cpu_data(cpu).proc_id)
  #define topology_core_id(cpu)			(cpu_data(cpu).core_id)
-#define topology_core_cpumask(cpu)		(&cpu_core_map[cpu])
+#define topology_core_cpumask(cpu)		(&cpu_core_sib_map[cpu])
  #define topology_thread_cpumask(cpu)		(&per_cpu(cpu_sibling_map, cpu))
  #endif /* CONFIG_SMP */
 
  extern cpumask_t cpu_core_map[NR_CPUS];
+extern cpumask_t cpu_core_sib_map[NR_CPUS];
  static inline const struct cpumask *cpu_coregroup_mask(int cpu)
  {
          return &cpu_core_map[cpu];
arch/sparc/kernel/mdesc.c +105 -26

174 lines not on this page · raw message

arch/sparc/kernel/smp_64.c +13 -0
index 61139d9..19cd08d 100644
@@ -60,8 +60,12 @@ DEFINE_PER_CPU(cpumask_t, cpu_sibling_map) = CPU_MASK_NONE;
  cpumask_t cpu_core_map[NR_CPUS] __read_mostly   	{ [0 ... NR_CPUS-1] = CPU_MASK_NONE };
 
+cpumask_t cpu_core_sib_map[NR_CPUS] __read_mostly = {
+	[0 ... NR_CPUS-1] = CPU_MASK_NONE };
+
  EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
  EXPORT_SYMBOL(cpu_core_map);
+EXPORT_SYMBOL(cpu_core_sib_map);
 
  static cpumask_t smp_commenced_mask;
 
@@ -1243,6 +1247,15 @@ void smp_fill_in_sib_core_maps(void)
  		}
  	}
 
+	for_each_present_cpu(i)  {
+		unsigned int j;
+
+		for_each_present_cpu(j)  {
+			if (cpu_data(i).sock_id = cpu_data(j).sock_id)
+				cpumask_set_cpu(j, &cpu_core_sib_map[i]);
+		}
+	}
+
  	for_each_present_cpu(i) {
  		unsigned int j;