From: "Nakajima, Jun" <jun.nakajima@intel.com>
To: "'alan@redhat.com'" <alan@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] threads in /proc/cpuinfo and cpu_num_threads (fka smp_num _siblings)
Date: Tue, 20 Aug 2002 19:15:38 -0700 [thread overview]
Message-ID: <F2DBA543B89AD51184B600508B68D40004BA468B@fmsmsx103.fm.intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 4801 bytes --]
I think this may have been our mistake, but "siblings" sometimes can be
misleading, in the sense that the number of the siblings usually/often does
not include yourself.
At the same time, as Alan pointed out, using cpu_num_threads is clearer than
smp_num_sibling because there are going to be non X86 CPUs around one day
with similar properties and it's a more generic name.
So here is a patch against linux-2.4.20-pre2-ac5.
===========================================================================
diff -urN linux-2.4.20-pre2-ac5/arch/i386/kernel/setup.c
linux-1/arch/i386/kernel/setup.c
--- linux-2.4.20-pre2-ac5/arch/i386/kernel/setup.c Tue Aug 20 15:35:18
2002
+++ linux-1/arch/i386/kernel/setup.c Tue Aug 20 16:45:20 2002
@@ -2331,29 +2331,29 @@
int cpu = smp_processor_id();
cpuid(1, &eax, &ebx, &ecx, &edx);
- smp_num_siblings = (ebx & 0xff0000) >> 16;
+ cpu_num_threads = (ebx & 0xff0000) >> 16;
- if (smp_num_siblings == 1) {
+ if (cpu_num_threads == 1) {
printk(KERN_INFO "CPU: Hyper-Threading is
disabled\n");
- } else if (smp_num_siblings > 1 ) {
+ } else if (cpu_num_threads > 1 ) {
index_lsb = 0;
index_msb = 31;
/*
- * At this point we only support two siblings per
+ * At this point we only support two threads per
* processor package.
*/
-#define NR_SIBLINGS 2
- if (smp_num_siblings != NR_SIBLINGS) {
- printk(KERN_WARNING "CPU: Unsupported number
of the siblings %d", smp_num_siblings);
- smp_num_siblings = 1;
+#define NR_XEON_THREADS 2
+ if (cpu_num_threads != NR_XEON_THREADS) {
+ printk(KERN_WARNING "CPU: Unsupported number
of SMT threads %d", cpu_num_threads);
+ cpu_num_threads = 1;
return;
}
- tmp = smp_num_siblings;
+ tmp = cpu_num_threads;
while ((tmp & 1) == 0) {
tmp >>=1 ;
index_lsb++;
}
- tmp = smp_num_siblings;
+ tmp = cpu_num_threads;
while ((tmp & 0x80000000 ) == 0) {
tmp <<=1 ;
index_msb--;
@@ -2962,7 +2962,7 @@
#ifdef CONFIG_SMP
seq_printf(m, "physical id\t: %d\n",phys_proc_id[n]);
- seq_printf(m, "siblings\t: %d\n",smp_num_siblings);
+ seq_printf(m, "threads\t\t: %d\n",cpu_num_threads);
#endif
/* We use exception 16 if we have hardware math and we've either
seen it or the CPU claims it is internal */
diff -urN linux-2.4.20-pre2-ac5/arch/i386/kernel/smpboot.c
linux-1/arch/i386/kernel/smpboot.c
--- linux-2.4.20-pre2-ac5/arch/i386/kernel/smpboot.c Tue Aug 20 15:35:18
2002
+++ linux-1/arch/i386/kernel/smpboot.c Tue Aug 20 15:39:56 2002
@@ -56,8 +56,8 @@
/* Total count of live CPUs */
int smp_num_cpus = 1;
-/* Number of siblings per CPU package */
-int smp_num_siblings = 1;
+/* Number of threads per CPU package */
+int cpu_num_threads = 1;
int phys_proc_id[NR_CPUS]; /* Package ID of each logical CPU */
/* Bitmask of currently online CPUs */
@@ -1158,7 +1158,7 @@
* that we can tell the sibling CPU efficiently.
*/
if (test_bit(X86_FEATURE_HT, boot_cpu_data.x86_capability)
- && smp_num_siblings > 1) {
+ && cpu_num_threads > 1) {
for (cpu = 0; cpu < NR_CPUS; cpu++)
cpu_sibling_map[cpu] = NO_PROC_ID;
@@ -1175,7 +1175,7 @@
}
}
if (cpu_sibling_map[cpu] == NO_PROC_ID) {
- smp_num_siblings = 1;
+ cpu_num_threads = 1;
printk(KERN_WARNING "WARNING: No sibling
found for CPU %d.\n", cpu);
}
}
diff -urN linux-2.4.20-pre2-ac5/fs/binfmt_elf.c linux-1/fs/binfmt_elf.c
--- linux-2.4.20-pre2-ac5/fs/binfmt_elf.c Tue Aug 20 15:35:20 2002
+++ linux-1/fs/binfmt_elf.c Tue Aug 20 15:39:56 2002
@@ -150,7 +150,7 @@
* removed for 2.5
*/
- if(smp_num_siblings > 1)
+ if(cpu_num_threads > 1)
u_platform = u_platform - ((current->pid % 64) << 7);
#endif
diff -urN linux-2.4.20-pre2-ac5/include/asm-i386/smp.h
linux-1/include/asm-i386/smp.h
--- linux-2.4.20-pre2-ac5/include/asm-i386/smp.h Tue Aug 20 15:35:20
2002
+++ linux-1/include/asm-i386/smp.h Tue Aug 20 16:48:22 2002
@@ -74,7 +74,7 @@
extern unsigned long cpu_online_map;
extern volatile unsigned long smp_invalidate_needed;
extern int pic_mode;
-extern int smp_num_siblings;
+extern int cpu_num_threads;
extern int cpu_sibling_map[];
extern void smp_flush_tlb(void);
diff -urN linux-2.4.20-pre2-ac5/include/asm-i386/smp_balance.h
linux-1/include/asm-i386/smp_balance.h
--- linux-2.4.20-pre2-ac5/include/asm-i386/smp_balance.h Tue Aug 20
15:35:20 2002
+++ linux-1/include/asm-i386/smp_balance.h Tue Aug 20 15:39:56 2002
@@ -28,7 +28,7 @@
static inline int arch_load_balance(int this_cpu, int idle)
{
/* Special hack for hyperthreading */
- if (smp_num_siblings > 1 && idle &&
!idle_cpu(cpu_sibling_map[this_cpu])) {
+ if (cpu_num_threads > 1 && idle &&
!idle_cpu(cpu_sibling_map[this_cpu])) {
int found;
struct runqueue *rq_target;
[-- Attachment #2: cpu_num_threads.patch --]
[-- Type: application/octet-stream, Size: 4424 bytes --]
diff -urN linux-2.4.20-pre2-ac5/arch/i386/kernel/setup.c linux-1/arch/i386/kernel/setup.c
--- linux-2.4.20-pre2-ac5/arch/i386/kernel/setup.c Tue Aug 20 15:35:18 2002
+++ linux-1/arch/i386/kernel/setup.c Tue Aug 20 16:45:20 2002
@@ -2331,29 +2331,29 @@
int cpu = smp_processor_id();
cpuid(1, &eax, &ebx, &ecx, &edx);
- smp_num_siblings = (ebx & 0xff0000) >> 16;
+ cpu_num_threads = (ebx & 0xff0000) >> 16;
- if (smp_num_siblings == 1) {
+ if (cpu_num_threads == 1) {
printk(KERN_INFO "CPU: Hyper-Threading is disabled\n");
- } else if (smp_num_siblings > 1 ) {
+ } else if (cpu_num_threads > 1 ) {
index_lsb = 0;
index_msb = 31;
/*
- * At this point we only support two siblings per
+ * At this point we only support two threads per
* processor package.
*/
-#define NR_SIBLINGS 2
- if (smp_num_siblings != NR_SIBLINGS) {
- printk(KERN_WARNING "CPU: Unsupported number of the siblings %d", smp_num_siblings);
- smp_num_siblings = 1;
+#define NR_XEON_THREADS 2
+ if (cpu_num_threads != NR_XEON_THREADS) {
+ printk(KERN_WARNING "CPU: Unsupported number of SMT threads %d", cpu_num_threads);
+ cpu_num_threads = 1;
return;
}
- tmp = smp_num_siblings;
+ tmp = cpu_num_threads;
while ((tmp & 1) == 0) {
tmp >>=1 ;
index_lsb++;
}
- tmp = smp_num_siblings;
+ tmp = cpu_num_threads;
while ((tmp & 0x80000000 ) == 0) {
tmp <<=1 ;
index_msb--;
@@ -2962,7 +2962,7 @@
#ifdef CONFIG_SMP
seq_printf(m, "physical id\t: %d\n",phys_proc_id[n]);
- seq_printf(m, "siblings\t: %d\n",smp_num_siblings);
+ seq_printf(m, "threads\t\t: %d\n",cpu_num_threads);
#endif
/* We use exception 16 if we have hardware math and we've either seen it or the CPU claims it is internal */
diff -urN linux-2.4.20-pre2-ac5/arch/i386/kernel/smpboot.c linux-1/arch/i386/kernel/smpboot.c
--- linux-2.4.20-pre2-ac5/arch/i386/kernel/smpboot.c Tue Aug 20 15:35:18 2002
+++ linux-1/arch/i386/kernel/smpboot.c Tue Aug 20 15:39:56 2002
@@ -56,8 +56,8 @@
/* Total count of live CPUs */
int smp_num_cpus = 1;
-/* Number of siblings per CPU package */
-int smp_num_siblings = 1;
+/* Number of threads per CPU package */
+int cpu_num_threads = 1;
int phys_proc_id[NR_CPUS]; /* Package ID of each logical CPU */
/* Bitmask of currently online CPUs */
@@ -1158,7 +1158,7 @@
* that we can tell the sibling CPU efficiently.
*/
if (test_bit(X86_FEATURE_HT, boot_cpu_data.x86_capability)
- && smp_num_siblings > 1) {
+ && cpu_num_threads > 1) {
for (cpu = 0; cpu < NR_CPUS; cpu++)
cpu_sibling_map[cpu] = NO_PROC_ID;
@@ -1175,7 +1175,7 @@
}
}
if (cpu_sibling_map[cpu] == NO_PROC_ID) {
- smp_num_siblings = 1;
+ cpu_num_threads = 1;
printk(KERN_WARNING "WARNING: No sibling found for CPU %d.\n", cpu);
}
}
diff -urN linux-2.4.20-pre2-ac5/fs/binfmt_elf.c linux-1/fs/binfmt_elf.c
--- linux-2.4.20-pre2-ac5/fs/binfmt_elf.c Tue Aug 20 15:35:20 2002
+++ linux-1/fs/binfmt_elf.c Tue Aug 20 15:39:56 2002
@@ -150,7 +150,7 @@
* removed for 2.5
*/
- if(smp_num_siblings > 1)
+ if(cpu_num_threads > 1)
u_platform = u_platform - ((current->pid % 64) << 7);
#endif
diff -urN linux-2.4.20-pre2-ac5/include/asm-i386/smp.h linux-1/include/asm-i386/smp.h
--- linux-2.4.20-pre2-ac5/include/asm-i386/smp.h Tue Aug 20 15:35:20 2002
+++ linux-1/include/asm-i386/smp.h Tue Aug 20 16:48:22 2002
@@ -74,7 +74,7 @@
extern unsigned long cpu_online_map;
extern volatile unsigned long smp_invalidate_needed;
extern int pic_mode;
-extern int smp_num_siblings;
+extern int cpu_num_threads;
extern int cpu_sibling_map[];
extern void smp_flush_tlb(void);
diff -urN linux-2.4.20-pre2-ac5/include/asm-i386/smp_balance.h linux-1/include/asm-i386/smp_balance.h
--- linux-2.4.20-pre2-ac5/include/asm-i386/smp_balance.h Tue Aug 20 15:35:20 2002
+++ linux-1/include/asm-i386/smp_balance.h Tue Aug 20 15:39:56 2002
@@ -28,7 +28,7 @@
static inline int arch_load_balance(int this_cpu, int idle)
{
/* Special hack for hyperthreading */
- if (smp_num_siblings > 1 && idle && !idle_cpu(cpu_sibling_map[this_cpu])) {
+ if (cpu_num_threads > 1 && idle && !idle_cpu(cpu_sibling_map[this_cpu])) {
int found;
struct runqueue *rq_target;
reply other threads:[~2002-08-21 2:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=F2DBA543B89AD51184B600508B68D40004BA468B@fmsmsx103.fm.intel.com \
--to=jun.nakajima@intel.com \
--cc=alan@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®