Skip to contentSkip to conversation

Export Last Level Cache topology to userspace

PATCH In review Arjan van de Ven 2 participants 2 messages Nov 19, 2006 – Nov 20, 2006 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Export Last Level Cache topology to userspace

Hi,

right now the sysfs topology information exports things like sibling maps (which cpu is a hyperthreading peer of another) and which "linux cpus" share the physical package. The patch below adds a bitmap in the same style that exports which "linux cpus" share the last level cache. This is relevant at least for the current line of Intel Quad cores (but also for AMD's dual core offering) where the biggest cache isn't shared on the package level, but only be some cores (Intel) or only one core (AMD).

This information is useful for userspace that wants to do explicit process placement, and in specific, I'm going to need it in the irqbalance rewrite (which is going to balance irqs on the cache domain level).

drivers/base/topology.c +9 -0
Index: linux-2.6.19-rc6/drivers/base/topology.c
===================================================================
@@ -81,11 +81,20 @@ define_one_ro(core_siblings);
 #define ref_core_siblings_attr
 #endif
 
+#ifdef topology_llc_siblings
+define_siblings_show_func(llc_siblings);
+define_one_ro(llc_siblings);
+#define ref_llc_siblings_attr		&attr_llc_siblings.attr,
+#else
+#define ref_llc_siblings_attr
+#endif
+
 static struct attribute *default_attrs[] = {
 	ref_physical_package_id_attr
 	ref_core_id_attr
 	ref_thread_siblings_attr
 	ref_core_siblings_attr
+	ref_llc_siblings_attr
 	NULL
 };
 
include/asm-x86_64/topology.h +1 -0
Index: linux-2.6.19-rc6/include/asm-x86_64/topology.h
===================================================================
@@ -60,6 +60,7 @@ extern int __node_distance(int, int);
 #define topology_core_id(cpu)			(cpu_data[cpu].cpu_core_id)
 #define topology_core_siblings(cpu)		(cpu_core_map[cpu])
 #define topology_thread_siblings(cpu)		(cpu_sibling_map[cpu])
+#define topology_llc_siblings(cpu)		(cpu_data[cpu].llc_shared_map)
 #define mc_capable()			(boot_cpu_data.x86_max_cores > 1)
 #define smt_capable() 			(smp_num_siblings > 1)
 #endif
#1 lore raw
Quoted 4 lines · Arjan van de Ven

right now the sysfs topology information exports things like sibling maps (which cpu is a hyperthreading peer of another) and which "linux cpus" share the physical package. The patch below adds a bitmap in the same style that exports which "linux cpus" share the last level cache.

Arjan, This info is already exported today through

/sys/devices/system/cpu/cpuX/cache/indexY/shared_cpu_map

thanks,
suresh