* [patch] x86_64: fix cpu_to_node setup for sparse apic_ids
@ 2005-07-28 1:15 Ravikiran G Thirumalai
2005-07-28 1:24 ` Andrew Morton
0 siblings, 1 reply; 6+ messages in thread
From: Ravikiran G Thirumalai @ 2005-07-28 1:15 UTC (permalink / raw)
To: Andrew Morton; +Cc: Andi Kleen, linux-kernel
While booting with SMT disabled in bios, when using acpi srat to setup
cpu_to_node[], sparse apic_ids create problems. Here's a fix for that.
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Signed-off-by: Shai Fultheim <shai@scalex86.org>
Index: linux-2.6.13-rc3/arch/x86_64/mm/srat.c
===================================================================
--- linux-2.6.13-rc3.orig/arch/x86_64/mm/srat.c 2005-06-17 12:48:29.000000000 -0700
+++ linux-2.6.13-rc3/arch/x86_64/mm/srat.c 2005-07-27 15:36:23.000000000 -0700
@@ -20,6 +20,9 @@
static struct acpi_table_slit *acpi_slit;
+/* Internal processor count */
+static unsigned int __initdata num_processors = 0;
+
static nodemask_t nodes_parsed __initdata;
static nodemask_t nodes_found __initdata;
static struct node nodes[MAX_NUMNODES] __initdata;
@@ -101,16 +104,18 @@
bad_srat();
return;
}
- if (pa->apic_id >= NR_CPUS) {
- printk(KERN_ERR "SRAT: lapic %u too large.\n",
- pa->apic_id);
+ if (num_processors >= NR_CPUS) {
+ printk(KERN_ERR "SRAT: Processor #%d (lapic %u) INVALID. (Max ID: %d).\n",
+ num_processors, pa->apic_id, NR_CPUS);
bad_srat();
return;
}
- cpu_to_node[pa->apic_id] = node;
+ cpu_to_node[num_processors] = node;
acpi_numa = 1;
- printk(KERN_INFO "SRAT: PXM %u -> APIC %u -> Node %u\n",
- pxm, pa->apic_id, node);
+ printk(KERN_INFO "SRAT: PXM %u -> APIC %u -> CPU %u -> Node %u\n",
+ pxm, pa->apic_id, num_processors, node);
+
+ num_processors++;
}
/* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [patch] x86_64: fix cpu_to_node setup for sparse apic_ids 2005-07-28 1:15 [patch] x86_64: fix cpu_to_node setup for sparse apic_ids Ravikiran G Thirumalai @ 2005-07-28 1:24 ` Andrew Morton 2005-07-28 1:50 ` Ravikiran G Thirumalai 2005-07-29 7:46 ` Andi Kleen 0 siblings, 2 replies; 6+ messages in thread From: Andrew Morton @ 2005-07-28 1:24 UTC (permalink / raw) To: Ravikiran G Thirumalai; +Cc: akpm, ak, linux-kernel Ravikiran G Thirumalai <kiran@scalex86.org> wrote: > > While booting with SMT disabled in bios, when using acpi srat to setup > cpu_to_node[], sparse apic_ids create problems. Here's a fix for that. > Again, I don't have enough info here to judge the urgency of this patch. What are the consequences and risks of not having this patch in 2.6.13, and to how many machines? > > Index: linux-2.6.13-rc3/arch/x86_64/mm/srat.c > =================================================================== > --- linux-2.6.13-rc3.orig/arch/x86_64/mm/srat.c 2005-06-17 12:48:29.000000000 -0700 > +++ linux-2.6.13-rc3/arch/x86_64/mm/srat.c 2005-07-27 15:36:23.000000000 -0700 > @@ -20,6 +20,9 @@ > > static struct acpi_table_slit *acpi_slit; > > +/* Internal processor count */ > +static unsigned int __initdata num_processors = 0; > + > static nodemask_t nodes_parsed __initdata; > static nodemask_t nodes_found __initdata; > static struct node nodes[MAX_NUMNODES] __initdata; > @@ -101,16 +104,18 @@ > bad_srat(); > return; > } > - if (pa->apic_id >= NR_CPUS) { > - printk(KERN_ERR "SRAT: lapic %u too large.\n", > - pa->apic_id); > + if (num_processors >= NR_CPUS) { > + printk(KERN_ERR "SRAT: Processor #%d (lapic %u) INVALID. (Max ID: %d).\n", > + num_processors, pa->apic_id, NR_CPUS); > bad_srat(); > return; > } > - cpu_to_node[pa->apic_id] = node; > + cpu_to_node[num_processors] = node; > acpi_numa = 1; > - printk(KERN_INFO "SRAT: PXM %u -> APIC %u -> Node %u\n", > - pxm, pa->apic_id, node); > + printk(KERN_INFO "SRAT: PXM %u -> APIC %u -> CPU %u -> Node %u\n", > + pxm, pa->apic_id, num_processors, node); > + > + num_processors++; > } > > /* Callback for parsing of the Proximity Domain <-> Memory Area mappings */ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] x86_64: fix cpu_to_node setup for sparse apic_ids 2005-07-28 1:24 ` Andrew Morton @ 2005-07-28 1:50 ` Ravikiran G Thirumalai 2005-07-29 7:46 ` Andi Kleen 1 sibling, 0 replies; 6+ messages in thread From: Ravikiran G Thirumalai @ 2005-07-28 1:50 UTC (permalink / raw) To: Andrew Morton; +Cc: akpm, ak, linux-kernel, shai On Wed, Jul 27, 2005 at 06:24:45PM -0700, Andrew Morton wrote: > Ravikiran G Thirumalai <kiran@scalex86.org> wrote: > > > > While booting with SMT disabled in bios, when using acpi srat to setup > > cpu_to_node[], sparse apic_ids create problems. Here's a fix for that. > > > > Again, I don't have enough info here to judge the urgency of this patch. > > What are the consequences and risks of not having this patch in 2.6.13, and > to how many machines? > Without this patch, intel x86_64 boxes with hyperthreading disabled in the bios (and which rely on srat for numa setup) endup having incorrect values in cpu_to_node[] arrays, causing sched domains to be built incorrectly etc. Thanks, Kiran ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] x86_64: fix cpu_to_node setup for sparse apic_ids 2005-07-28 1:24 ` Andrew Morton 2005-07-28 1:50 ` Ravikiran G Thirumalai @ 2005-07-29 7:46 ` Andi Kleen 2005-08-01 22:07 ` [PATCH] MM, NUMA : sys_set_mempolicy() doesnt check if mode < 0 Eric Dumazet 1 sibling, 1 reply; 6+ messages in thread From: Andi Kleen @ 2005-07-29 7:46 UTC (permalink / raw) To: Andrew Morton; +Cc: Ravikiran G Thirumalai, akpm, ak, linux-kernel On Wed, Jul 27, 2005 at 06:24:45PM -0700, Andrew Morton wrote: > Ravikiran G Thirumalai <kiran@scalex86.org> wrote: > > > > While booting with SMT disabled in bios, when using acpi srat to setup > > cpu_to_node[], sparse apic_ids create problems. Here's a fix for that. > > > > Again, I don't have enough info here to judge the urgency of this patch. The patch is broken, don't apply please. Ravi, there is no reason the order of CPUs in SRAT has anything to do with the order CPUs are brought up. -Andi ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] MM, NUMA : sys_set_mempolicy() doesnt check if mode < 0 2005-07-29 7:46 ` Andi Kleen @ 2005-08-01 22:07 ` Eric Dumazet 2005-08-03 9:13 ` Andi Kleen 0 siblings, 1 reply; 6+ messages in thread From: Eric Dumazet @ 2005-08-01 22:07 UTC (permalink / raw) To: Andi Kleen; +Cc: linux-kernel [-- Attachment #1: Type: text/plain, Size: 921 bytes --] MM, NUMA : sys_set_mempolicy() doesnt check if mode < 0 A kernel BUG() is triggered by a call to set_mempolicy() with a negative first argument. This is because the mode is declared as an int, and the validity check doesnt check < 0 values. Alternatively, mode could be declared as unsigned int or unsigned long. Thank you Eric --------------------------------- Test program for x86_64: --------------------------------- #include <unistd.h> #include <stdio.h> #include <errno.h> #include <linux/unistd.h> #define __NR_set_mempolicy 238 #define __sys_set_mempolicy(mode, nmask, maxnode) _syscall3(int, set_mempolicy, int, mode, unsigned long *, nmask, unsigned long, maxnode) static __sys_set_mempolicy(mode, nmask, maxnode) unsigned long nodes = 3; int main() { int ret = set_mempolicy(-6, &nodes, 2); printf("result=%d errno=%d\n", ret, errno); return 0; } Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> [-- Attachment #2: mempolicy.patch --] [-- Type: text/plain, Size: 371 bytes --] --- linux-2.6.13-rc4/mm/mempolicy.c 2005-07-29 00:44:44.000000000 +0200 +++ linux-2.6.13-rc4-ed/mm/mempolicy.c 2005-08-01 23:52:43.000000000 +0200 @@ -443,7 +443,7 @@ struct mempolicy *new; DECLARE_BITMAP(nodes, MAX_NUMNODES); - if (mode > MPOL_MAX) + if ((unsigned int)mode > MPOL_MAX) return -EINVAL; err = get_nodes(nodes, nmask, maxnode, mode); if (err) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] MM, NUMA : sys_set_mempolicy() doesnt check if mode < 0 2005-08-01 22:07 ` [PATCH] MM, NUMA : sys_set_mempolicy() doesnt check if mode < 0 Eric Dumazet @ 2005-08-03 9:13 ` Andi Kleen 0 siblings, 0 replies; 6+ messages in thread From: Andi Kleen @ 2005-08-03 9:13 UTC (permalink / raw) To: Eric Dumazet; +Cc: Andi Kleen, linux-kernel, akpm On Tue, Aug 02, 2005 at 12:07:23AM +0200, Eric Dumazet wrote: > MM, NUMA : sys_set_mempolicy() doesnt check if mode < 0 > > A kernel BUG() is triggered by a call to set_mempolicy() with a negative > first argument. > This is because the mode is declared as an int, and the validity check > doesnt check < 0 values. > Alternatively, mode could be declared as unsigned int or unsigned long. Thanks looks good. Andrew, can you apply that one? -Andi > > Thank you > Eric > --------------------------------- > Test program for x86_64: > --------------------------------- > #include <unistd.h> > #include <stdio.h> > #include <errno.h> > #include <linux/unistd.h> > > #define __NR_set_mempolicy 238 > #define __sys_set_mempolicy(mode, nmask, maxnode) _syscall3(int, > set_mempolicy, int, mode, unsigned long *, nmask, unsigned long, maxnode) > static __sys_set_mempolicy(mode, nmask, maxnode) > > unsigned long nodes = 3; > > int main() > { > int ret = set_mempolicy(-6, &nodes, 2); > printf("result=%d errno=%d\n", ret, errno); > return 0; > } > > > Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> > > --- linux-2.6.13-rc4/mm/mempolicy.c 2005-07-29 00:44:44.000000000 +0200 > +++ linux-2.6.13-rc4-ed/mm/mempolicy.c 2005-08-01 23:52:43.000000000 +0200 > @@ -443,7 +443,7 @@ > struct mempolicy *new; > DECLARE_BITMAP(nodes, MAX_NUMNODES); > > - if (mode > MPOL_MAX) > + if ((unsigned int)mode > MPOL_MAX) > return -EINVAL; > err = get_nodes(nodes, nmask, maxnode, mode); > if (err) ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-08-03 9:15 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-07-28 1:15 [patch] x86_64: fix cpu_to_node setup for sparse apic_ids Ravikiran G Thirumalai 2005-07-28 1:24 ` Andrew Morton 2005-07-28 1:50 ` Ravikiran G Thirumalai 2005-07-29 7:46 ` Andi Kleen 2005-08-01 22:07 ` [PATCH] MM, NUMA : sys_set_mempolicy() doesnt check if mode < 0 Eric Dumazet 2005-08-03 9:13 ` Andi Kleen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox