Export cpu topology by sysfs
PATCH 1/1 Export cpu topology by sysfs
From: Zhang, Yanmin <[email protected]>
The second patch against kernel 2.6.15-rc5 is to save thread_id and show it in /proc/cpuinfo for x86_64 architecture.
Signed-off-by Zhang, Yanmin <[email protected]>
#diffstat collect_thread_id_2.6.15-rc5_x86_64.patch
arch/x86_64/kernel/setup.c | 13 ++++++++++++- arch/x86_64/kernel/smpboot.c | 2 ++ include/asm-x86_64/smp.h | 1 + 3 files changed, 15 insertions, 1 deletion
---
arch/x86_64/kernel/setup.c +12 -1
@@ -888,7 +888,7 @@ static void __cpuinit detect_ht(struct c {#ifdef CONFIG_SMP u32 eax, ebx, ecx, edx; -int index_msb, core_bits; +int index_msb, core_bits, thread_bits;int cpu =smp_processor_id ();cpuid (1 , &eax, &ebx, &ecx, &edx);
@@ -928,6 +928,13 @@ static void __cpuinit detect_ht(struct cif (c->x86_max_cores >1 )printk (KERN_INFO "CPU: Processor Core ID: %d\n" , cpu_core_id[cpu]); + + thread_bits = index_msb; + cpu_thread_id[cpu] =phys_pkg_id (0 ) & ((1 << thread_bits) -1 ); + +if (smp_num_siblings >1 ) +printk (KERN_INFO "CPU: Processor Thread ID: %d\n" , + cpu_thread_id[cpu]); }#endif }
@@ -1272,6 +1279,10 @@ static int show_cpuinfo(struct seq_fileseq_printf (m,"core id\t\t: %d\n" , cpu_core_id[cpu]); seq_printf(m, "cpu cores\t: %d\n", c->booted_cores); } +if (smp_num_siblings >1 ) { +int cpu = c - cpu_data; +seq_printf (m,"thread id\t: %d\n" , cpu_thread_id[cpu]); + }#endif seq_printf(m,
arch/x86_64/kernel/smpboot.c +2 -0
@@ -66,6 +66,8 @@ int smp_num_siblings = 1;u8 phys_proc_id[NR_CPUS ]__read_mostly = { [0 ...NR_CPUS -1 ] =BAD_APICID };/* core ID of each logical CPU */ u8 cpu_core_id[NR_CPUS ]__read_mostly = { [0 ...NR_CPUS -1 ] =BAD_APICID }; +/* thread ID of each logical CPU */ +u8 cpu_thread_id[NR_CPUS ]__read_mostly = { [0 ...NR_CPUS -1 ] =BAD_APICID };/* Bitmask of currently online CPUs */ cpumask_t cpu_online_map__read_mostly ;
include/asm-x86_64/smp.h +1 -0
@@ -55,6 +55,7 @@ extern cpumask_t cpu_sibling_map[NR_CPUSextern cpumask_t cpu_core_map[NR_CPUS ];extern u8 phys_proc_id[NR_CPUS ];extern u8 cpu_core_id[NR_CPUS ]; +extern u8 cpu_thread_id[NR_CPUS ];#define SMP_TRAMPOLINE_BASE 0x6000