forked from luck/tmp_suning_uos_patched
[PATCH] x86_64: Fix overflow in NUMA hash function setup
Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
17158d17aa
commit
b684664fd4
@ -36,34 +36,36 @@ int numa_off __initdata;
|
|||||||
int __init compute_hash_shift(struct node *nodes, int numnodes)
|
int __init compute_hash_shift(struct node *nodes, int numnodes)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int shift = 24;
|
int shift = 20;
|
||||||
u64 addr;
|
unsigned long addr,maxend=0;
|
||||||
|
|
||||||
/* When in doubt use brute force. */
|
for (i = 0; i < numnodes; i++)
|
||||||
while (shift < 48) {
|
if ((nodes[i].start != nodes[i].end) && (nodes[i].end > maxend))
|
||||||
memset(memnodemap,0xff,sizeof(*memnodemap) * NODEMAPSIZE);
|
maxend = nodes[i].end;
|
||||||
for (i = 0; i < numnodes; i++) {
|
|
||||||
if (nodes[i].start == nodes[i].end)
|
while ((1UL << shift) < (maxend / NODEMAPSIZE))
|
||||||
continue;
|
shift++;
|
||||||
for (addr = nodes[i].start;
|
|
||||||
addr < nodes[i].end;
|
printk (KERN_DEBUG"Using %d for the hash shift. Max adder is %lx \n",
|
||||||
addr += (1UL << shift)) {
|
shift,maxend);
|
||||||
if (memnodemap[addr >> shift] != 0xff &&
|
memset(memnodemap,0xff,sizeof(*memnodemap) * NODEMAPSIZE);
|
||||||
memnodemap[addr >> shift] != i) {
|
for (i = 0; i < numnodes; i++) {
|
||||||
printk(KERN_INFO
|
if (nodes[i].start == nodes[i].end)
|
||||||
"node %d shift %d addr %Lx conflict %d\n",
|
continue;
|
||||||
i, shift, addr, memnodemap[addr>>shift]);
|
for (addr = nodes[i].start;
|
||||||
goto next;
|
addr < nodes[i].end;
|
||||||
}
|
addr += (1UL << shift)) {
|
||||||
memnodemap[addr >> shift] = i;
|
if (memnodemap[addr >> shift] != 0xff) {
|
||||||
|
printk(KERN_INFO
|
||||||
|
"Your memory is not aligned you need to rebuild your kernel "
|
||||||
|
"with a bigger NODEMAPSIZE shift=%d adder=%lu\n",
|
||||||
|
shift,addr);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
memnodemap[addr >> shift] = i;
|
||||||
}
|
}
|
||||||
return shift;
|
|
||||||
next:
|
|
||||||
shift++;
|
|
||||||
}
|
}
|
||||||
memset(memnodemap,0,sizeof(*memnodemap) * NODEMAPSIZE);
|
return shift;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SPARSEMEM
|
#ifdef CONFIG_SPARSEMEM
|
||||||
|
Loading…
Reference in New Issue
Block a user