Re: [Patch] x86, x86_64: Intel dual-core detection
On Wed, Mar 16, 2005 at 06:04:12PM +0100, Andi Kleen wrote: > On Tue, Mar 15, 2005 at 05:36:25PM -0800, Siddha, Suresh B wrote: > > It adds two new fields "core id" and "cpu cores" to x86 /proc/cpuinfo > > and the "core id" field for x86_64("cpu cores" field is already present in > > x86_64). > > Thanks. I have a similar patch for AMD CPUs, unfortuntely it uses > different names ("shared cores" etc.) 2.6.11 already has "cpu cores" for x86_64. I would like to retain that. > > > > This patch also adds cpu_core_map similar to cpu_sibling_map. > Called cpu_sharecore_map in my patch. cpu_sharecore_map sounds like HT logical siblings sharing the core. Initially I was calling it as cpu_coresibling_map but later thought cpu_core_map is a smaller name. > > Hmm, which names should be chosen? For /proc/cpuinfo, I want to stick with "cpu cores" and "core id" But I am open for kernel variable names. Depending on what we decide on kernel variable names, I will see if I have to make any changes to the IPF patch we posted last week. thanks, suresh - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Patch] x86, x86_64: Intel dual-core detection
On Tue, Mar 15, 2005 at 05:36:25PM -0800, Siddha, Suresh B wrote: > Appended patch adds the support for Intel dual-core detection and displaying > the core related information in /proc/cpuinfo. > > It adds two new fields "core id" and "cpu cores" to x86 /proc/cpuinfo > and the "core id" field for x86_64("cpu cores" field is already present in > x86_64). Thanks. I have a similar patch for AMD CPUs, unfortuntely it uses different names ("shared cores" etc.) > > Number of processor cores in a die is detected using cpuid(4) and this > is documented in IA-32 Intel Architecture Software Developer's Manual (vol 2a) > (http://developer.intel.com/design/pentium4/manuals/index_new.htm#sdm_vol2a) > > This patch also adds cpu_core_map similar to cpu_sibling_map. Called cpu_sharecore_map in my patch. Hmm, which names should be chosen? -Andi - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Patch] x86, x86_64: Intel dual-core detection
On Tue, Mar 15, 2005 at 05:36:25PM -0800, Siddha, Suresh B wrote: Appended patch adds the support for Intel dual-core detection and displaying the core related information in /proc/cpuinfo. It adds two new fields core id and cpu cores to x86 /proc/cpuinfo and the core id field for x86_64(cpu cores field is already present in x86_64). Thanks. I have a similar patch for AMD CPUs, unfortuntely it uses different names (shared cores etc.) Number of processor cores in a die is detected using cpuid(4) and this is documented in IA-32 Intel Architecture Software Developer's Manual (vol 2a) (http://developer.intel.com/design/pentium4/manuals/index_new.htm#sdm_vol2a) This patch also adds cpu_core_map similar to cpu_sibling_map. Called cpu_sharecore_map in my patch. Hmm, which names should be chosen? -Andi - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Patch] x86, x86_64: Intel dual-core detection
On Wed, Mar 16, 2005 at 06:04:12PM +0100, Andi Kleen wrote: On Tue, Mar 15, 2005 at 05:36:25PM -0800, Siddha, Suresh B wrote: It adds two new fields core id and cpu cores to x86 /proc/cpuinfo and the core id field for x86_64(cpu cores field is already present in x86_64). Thanks. I have a similar patch for AMD CPUs, unfortuntely it uses different names (shared cores etc.) 2.6.11 already has cpu cores for x86_64. I would like to retain that. This patch also adds cpu_core_map similar to cpu_sibling_map. Called cpu_sharecore_map in my patch. cpu_sharecore_map sounds like HT logical siblings sharing the core. Initially I was calling it as cpu_coresibling_map but later thought cpu_core_map is a smaller name. Hmm, which names should be chosen? For /proc/cpuinfo, I want to stick with cpu cores and core id But I am open for kernel variable names. Depending on what we decide on kernel variable names, I will see if I have to make any changes to the IPF patch we posted last week. thanks, suresh - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[Patch] x86, x86_64: Intel dual-core detection
Appended patch adds the support for Intel dual-core detection and displaying the core related information in /proc/cpuinfo. It adds two new fields "core id" and "cpu cores" to x86 /proc/cpuinfo and the "core id" field for x86_64("cpu cores" field is already present in x86_64). Number of processor cores in a die is detected using cpuid(4) and this is documented in IA-32 Intel Architecture Software Developer's Manual (vol 2a) (http://developer.intel.com/design/pentium4/manuals/index_new.htm#sdm_vol2a) This patch also adds cpu_core_map similar to cpu_sibling_map. Signed-off-by: Suresh Siddha <[EMAIL PROTECTED]> diff -Nru linux-2.6.11/arch/i386/kernel/cpu/amd.c linux-mc/arch/i386/kernel/cpu/amd.c --- linux-2.6.11/arch/i386/kernel/cpu/amd.c 2005-03-01 23:38:26.0 -0800 +++ linux-mc/arch/i386/kernel/cpu/amd.c 2004-11-01 16:13:46.141256624 -0800 @@ -188,6 +188,13 @@ } display_cacheinfo(c); + + if (cpuid_eax(0x8000) >= 0x8008) { + c->x86_num_cores = (cpuid_ecx(0x8008) & 0xff) + 1; + if (c->x86_num_cores & (c->x86_num_cores - 1)) + c->x86_num_cores = 1; + } + detect_ht(c); #ifdef CONFIG_X86_HT @@ -199,12 +206,6 @@ if (cpu_has(c, X86_FEATURE_CMP_LEGACY)) smp_num_siblings = 1; #endif - - if (cpuid_eax(0x8000) >= 0x8008) { - c->x86_num_cores = (cpuid_ecx(0x8008) & 0xff) + 1; - if (c->x86_num_cores & (c->x86_num_cores - 1)) - c->x86_num_cores = 1; - } } static unsigned int amd_size_cache(struct cpuinfo_x86 * c, unsigned int size) diff -Nru linux-2.6.11/arch/i386/kernel/cpu/common.c linux-mc/arch/i386/kernel/cpu/common.c --- linux-2.6.11/arch/i386/kernel/cpu/common.c 2005-03-01 23:37:47.0 -0800 +++ linux-mc/arch/i386/kernel/cpu/common.c 2004-11-07 11:34:10.237802664 -0800 @@ -441,7 +441,7 @@ void __init detect_ht(struct cpuinfo_x86 *c) { u32 eax, ebx, ecx, edx; - int index_lsb, index_msb, tmp; + int index_msb, tmp; int cpu = smp_processor_id(); if (!cpu_has(c, X86_FEATURE_HT)) @@ -453,7 +453,6 @@ if (smp_num_siblings == 1) { printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); } else if (smp_num_siblings > 1 ) { - index_lsb = 0; index_msb = 31; if (smp_num_siblings > NR_CPUS) { @@ -462,21 +461,34 @@ return; } tmp = smp_num_siblings; - while ((tmp & 1) == 0) { - tmp >>=1 ; - index_lsb++; - } - tmp = smp_num_siblings; while ((tmp & 0x8000 ) == 0) { tmp <<=1 ; index_msb--; } - if (index_lsb != index_msb ) + if (smp_num_siblings & (smp_num_siblings - 1)) index_msb++; phys_proc_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb); printk(KERN_INFO "CPU: Physical Processor ID: %d\n", phys_proc_id[cpu]); + + smp_num_siblings = smp_num_siblings / c->x86_num_cores; + + tmp = smp_num_siblings; + index_msb = 31; + while ((tmp & 0x8000) == 0) { + tmp <<=1 ; + index_msb--; + } + + if (smp_num_siblings & (smp_num_siblings - 1)) + index_msb++; + + cpu_core_id[cpu] = phys_pkg_id((ebx >> 24) & 0xFF, index_msb); + + if (c->x86_num_cores > 1) + printk(KERN_INFO "CPU: Processor Core ID: %d\n", + cpu_core_id[cpu]); } } #endif diff -Nru linux-2.6.11/arch/i386/kernel/cpu/intel.c linux-mc/arch/i386/kernel/cpu/intel.c --- linux-2.6.11/arch/i386/kernel/cpu/intel.c 2005-03-01 23:37:52.0 -0800 +++ linux-mc/arch/i386/kernel/cpu/intel.c 2004-11-01 16:13:46.187249632 -0800 @@ -77,6 +77,27 @@ } +/* + * find out the number of processor cores on the die + */ +static int __init num_cpu_cores(struct cpuinfo_x86 *c) +{ + unsigned int eax; + + if (c->cpuid_level < 4) + return 1; + + __asm__("cpuid" + : "=a" (eax) + : "0" (4), "c" (0) + : "bx", "dx"); + + if (eax & 0x1f) + return ((eax >> 26) + 1); + else + return 1; +} + static void __init init_intel(struct cpuinfo_x86 *c) { unsigned int l2 = 0; @@ -139,6 +160,8 @@ if ( p ) strcpy(c->x86_model_id, p); + c->x86_num_cores = num_cpu_cores(c); + detect_ht(c); /* Work around errata */ diff -Nru linux-2.6.11/arch/i386/kernel/cpu/proc.c
[Patch] x86, x86_64: Intel dual-core detection
Appended patch adds the support for Intel dual-core detection and displaying the core related information in /proc/cpuinfo. It adds two new fields core id and cpu cores to x86 /proc/cpuinfo and the core id field for x86_64(cpu cores field is already present in x86_64). Number of processor cores in a die is detected using cpuid(4) and this is documented in IA-32 Intel Architecture Software Developer's Manual (vol 2a) (http://developer.intel.com/design/pentium4/manuals/index_new.htm#sdm_vol2a) This patch also adds cpu_core_map similar to cpu_sibling_map. Signed-off-by: Suresh Siddha [EMAIL PROTECTED] diff -Nru linux-2.6.11/arch/i386/kernel/cpu/amd.c linux-mc/arch/i386/kernel/cpu/amd.c --- linux-2.6.11/arch/i386/kernel/cpu/amd.c 2005-03-01 23:38:26.0 -0800 +++ linux-mc/arch/i386/kernel/cpu/amd.c 2004-11-01 16:13:46.141256624 -0800 @@ -188,6 +188,13 @@ } display_cacheinfo(c); + + if (cpuid_eax(0x8000) = 0x8008) { + c-x86_num_cores = (cpuid_ecx(0x8008) 0xff) + 1; + if (c-x86_num_cores (c-x86_num_cores - 1)) + c-x86_num_cores = 1; + } + detect_ht(c); #ifdef CONFIG_X86_HT @@ -199,12 +206,6 @@ if (cpu_has(c, X86_FEATURE_CMP_LEGACY)) smp_num_siblings = 1; #endif - - if (cpuid_eax(0x8000) = 0x8008) { - c-x86_num_cores = (cpuid_ecx(0x8008) 0xff) + 1; - if (c-x86_num_cores (c-x86_num_cores - 1)) - c-x86_num_cores = 1; - } } static unsigned int amd_size_cache(struct cpuinfo_x86 * c, unsigned int size) diff -Nru linux-2.6.11/arch/i386/kernel/cpu/common.c linux-mc/arch/i386/kernel/cpu/common.c --- linux-2.6.11/arch/i386/kernel/cpu/common.c 2005-03-01 23:37:47.0 -0800 +++ linux-mc/arch/i386/kernel/cpu/common.c 2004-11-07 11:34:10.237802664 -0800 @@ -441,7 +441,7 @@ void __init detect_ht(struct cpuinfo_x86 *c) { u32 eax, ebx, ecx, edx; - int index_lsb, index_msb, tmp; + int index_msb, tmp; int cpu = smp_processor_id(); if (!cpu_has(c, X86_FEATURE_HT)) @@ -453,7 +453,6 @@ if (smp_num_siblings == 1) { printk(KERN_INFO CPU: Hyper-Threading is disabled\n); } else if (smp_num_siblings 1 ) { - index_lsb = 0; index_msb = 31; if (smp_num_siblings NR_CPUS) { @@ -462,21 +461,34 @@ return; } tmp = smp_num_siblings; - while ((tmp 1) == 0) { - tmp =1 ; - index_lsb++; - } - tmp = smp_num_siblings; while ((tmp 0x8000 ) == 0) { tmp =1 ; index_msb--; } - if (index_lsb != index_msb ) + if (smp_num_siblings (smp_num_siblings - 1)) index_msb++; phys_proc_id[cpu] = phys_pkg_id((ebx 24) 0xFF, index_msb); printk(KERN_INFO CPU: Physical Processor ID: %d\n, phys_proc_id[cpu]); + + smp_num_siblings = smp_num_siblings / c-x86_num_cores; + + tmp = smp_num_siblings; + index_msb = 31; + while ((tmp 0x8000) == 0) { + tmp =1 ; + index_msb--; + } + + if (smp_num_siblings (smp_num_siblings - 1)) + index_msb++; + + cpu_core_id[cpu] = phys_pkg_id((ebx 24) 0xFF, index_msb); + + if (c-x86_num_cores 1) + printk(KERN_INFO CPU: Processor Core ID: %d\n, + cpu_core_id[cpu]); } } #endif diff -Nru linux-2.6.11/arch/i386/kernel/cpu/intel.c linux-mc/arch/i386/kernel/cpu/intel.c --- linux-2.6.11/arch/i386/kernel/cpu/intel.c 2005-03-01 23:37:52.0 -0800 +++ linux-mc/arch/i386/kernel/cpu/intel.c 2004-11-01 16:13:46.187249632 -0800 @@ -77,6 +77,27 @@ } +/* + * find out the number of processor cores on the die + */ +static int __init num_cpu_cores(struct cpuinfo_x86 *c) +{ + unsigned int eax; + + if (c-cpuid_level 4) + return 1; + + __asm__(cpuid + : =a (eax) + : 0 (4), c (0) + : bx, dx); + + if (eax 0x1f) + return ((eax 26) + 1); + else + return 1; +} + static void __init init_intel(struct cpuinfo_x86 *c) { unsigned int l2 = 0; @@ -139,6 +160,8 @@ if ( p ) strcpy(c-x86_model_id, p); + c-x86_num_cores = num_cpu_cores(c); + detect_ht(c); /* Work around errata */ diff -Nru linux-2.6.11/arch/i386/kernel/cpu/proc.c linux-mc/arch/i386/kernel/cpu/proc.c --- linux-2.6.11/arch/i386/kernel/cpu/proc.c