Skip to contentSkip to conversation

x86_64: Make the NUMA hash function nodemap allocation dynamic and remove NODEMAPSIZE

PATCH In review Amul Shah 3 participants 5 messages Nov 15, 2006 – Nov 27, 2006

lore
Share & tools
lore

Amul Shah

author
#0 lore raw

PATCH 1/1 x86_64: Make the NUMA hash function nodemap allocation dynamic and remove NODEMAPSIZE

This patch removes the statically allocated memory to NUMA node hash map in favor of a dynamically allocated memory to node hash map (it is cache aligned).

This patch has the nice side effect in that it allows the hash map to grow for systems with large amounts of memory (256GB - 1TB), but suffer from having small PCI space tacked onto the boot node (which is somewhere between 192MB to 512MB on the ES7000).

---
Patch applies to 2.6.19-rc4 and has been tested.
This patch needs testing on a K8 NUMA platform.
Thanks to Eric Dumazet and Andi Kleen for their improvement suggestions.

arch/x86_64/kernel/e820.c +6 -0
diff -upNr linux-2.6.19-rc4/arch/x86_64/kernel/e820.c linux-2.6.19-rc4-az/arch/x86_64/kernel/e820.c
@@ -83,6 +83,12 @@ static inline int bad_addr(unsigned long
 		return 1;
 	}
 
+	/* NUMA memory to node map */
+	if (last >= nodemap_addr && addr < nodemap_addr + nodemap_size) {
+		*addrp = nodemap_addr + nodemap_size;
+		return 1;
+	}
+
 	/* XXX ramdisk image here? */ 
 	return 0;
 } 
arch/x86_64/kernel/setup.c +4 -0
diff -upNr linux-2.6.19-rc4/arch/x86_64/kernel/setup.c linux-2.6.19-rc4-az/arch/x86_64/kernel/setup.c
@@ -445,6 +445,10 @@ void __init setup_arch(char **cmdline_p)
 	if (ebda_addr)
 		reserve_bootmem_generic(ebda_addr, ebda_size);
 
+	/* reserve nodemap region */
+	if (nodemap_addr)
+		reserve_bootmem_generic(nodemap_addr, nodemap_size);
+
 #ifdef CONFIG_SMP
 	/*
 	 * But first pinch a few for the stack/trampoline stuff
arch/x86_64/mm/numa.c +64 -9

104 lines not on this page · raw message

include/asm-x86_64/e820.h +1 -0
diff -upNr linux-2.6.19-rc4/include/asm-x86_64/e820.h linux-2.6.19-rc4-az/include/asm-x86_64/e820.h
@@ -56,6 +56,7 @@ extern void finish_e820_parsing(void);
 extern struct e820map e820;
 
 extern unsigned ebda_addr, ebda_size;
+extern unsigned long nodemap_addr, nodemap_size;
 #endif/*!__ASSEMBLY__*/
 
 #endif/*__E820_HEADER*/
include/asm-x86_64/mmzone.h +7 -6
diff -upNr linux-2.6.19-rc4/include/asm-x86_64/mmzone.h linux-2.6.19-rc4-az/include/asm-x86_64/mmzone.h
@@ -11,24 +11,25 @@
 
 #include <asm/smp.h>
 
-/* Should really switch to dynamic allocation at some point */
-#define NODEMAPSIZE 0x4fff
-
 /* Simple perfect hash to map physical addresses to node numbers */
 struct memnode {
 	int shift;
-	u8 map[NODEMAPSIZE];
-} ____cacheline_aligned;
+	unsigned int mapsize;
+	u8 *map;
+	u8 embedded_map[64-16];
+} ____cacheline_aligned; /* total size = 64 bytes */
 extern struct memnode memnode;
 #define memnode_shift memnode.shift
 #define memnodemap memnode.map
+#define memnodemapsize memnode.mapsize
 
 extern struct pglist_data *node_data[];
 
 static inline __attribute__((pure)) int phys_to_nid(unsigned long addr) 
 { 
 	unsigned nid; 
-	VIRTUAL_BUG_ON((addr >> memnode_shift) >= NODEMAPSIZE);
+	VIRTUAL_BUG_ON(!memnodemap);
+	VIRTUAL_BUG_ON((addr >> memnode_shift) >= memnodemapsize);
 	nid = memnodemap[addr >> memnode_shift]; 
 	VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]); 
 	return nid; 
#1 lore raw
Quoted 9 lines · Amul Shah

This patch removes the statically allocated memory to NUMA node hash map in favor of a dynamically allocated memory to node hash map (it is cache aligned).

This patch has the nice side effect in that it allows the hash map to grow for systems with large amounts of memory (256GB - 1TB), but suffer from having small PCI space tacked onto the boot node (which is somewhere between 192MB to 512MB on the ES7000).

Quoted 6 lines

---
Patch applies to 2.6.19-rc4 and has been tested.
This patch needs testing on a K8 NUMA platform.
Thanks to Eric Dumazet and Andi Kleen for their improvement suggestions.

I had the patch in, but had to drop it again because it makes one of my test system triple fault. Haven't done much investigation yet.

BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000e6000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 000000003ef30000 (usable)
BIOS-e820: 000000003ef30000 - 000000003ef40000 (ACPI data)
BIOS-e820: 000000003ef40000 - 000000003eff0000 (ACPI NVS)
BIOS-e820: 000000003eff0000 - 000000003f000000 (reserved)
BIOS-e820: 00000000fecf0000 - 00000000fecf1000 (reserved)
BIOS-e820: 00000000fed20000 - 00000000feda0000 (reserved)
end_pfn_map = 1043872
kernel direct mapping tables up to feda0000 @ 8000-d000 DMI 2.3 present.
No NUMA configuration found
Faking a node at 0000000000000000-000000003ef30000 <triple fault>

-Andi

#2 lore raw
Quoted 20 lines · Andi Kleen
Quoted 9 lines · Amul Shah

This patch removes the statically allocated memory to NUMA node hash map in favor of a dynamically allocated memory to node hash map (it is cache aligned).

This patch has the nice side effect in that it allows the hash map to grow for systems with large amounts of memory (256GB - 1TB), but suffer from having small PCI space tacked onto the boot node (which is somewhere between 192MB to 512MB on the ES7000).

Quoted 6 lines

---
Patch applies to 2.6.19-rc4 and has been tested.
This patch needs testing on a K8 NUMA platform.
Thanks to Eric Dumazet and Andi Kleen for their improvement suggestions.

I had the patch in, but had to drop it again because it makes one of my test system triple fault. Haven't done much investigation yet.

Quoted 17 lines

BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000e6000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 000000003ef30000 (usable)
BIOS-e820: 000000003ef30000 - 000000003ef40000 (ACPI data)
BIOS-e820: 000000003ef40000 - 000000003eff0000 (ACPI NVS)
BIOS-e820: 000000003eff0000 - 000000003f000000 (reserved)
BIOS-e820: 00000000fecf0000 - 00000000fecf1000 (reserved)
BIOS-e820: 00000000fed20000 - 00000000feda0000 (reserved)
end_pfn_map = 1043872
kernel direct mapping tables up to feda0000 @ 8000-d000 DMI 2.3 present.
No NUMA configuration found
Faking a node at 0000000000000000-000000003ef30000 <triple fault>

Well, I dont have currently an AMD64 test machine so I cannot really help.

With previous implementation, the nimimum shift value was 20 (one megabytes)

If a memnode had a finer range (with chunks not multiple of megabytes), some bits of memory could be ignored.

But with your fake node (0-3ef30000), Amul patch may give a shift value of 16.
Maybe this breaks something in the kernel...

Eric

author
#3 lore raw
Quoted 11 lines · Eric Dumazet
Quoted 7 lines · Andi Kleen

I had the patch in, but had to drop it again because it makes one of my test system triple fault. Haven't done much investigation yet.

No NUMA configuration found
Faking a node at 0000000000000000-000000003ef30000 <triple fault>

Well, I dont have currently an AMD64 test machine so I cannot really help.

Quoted 7 lines

With previous implementation, the nimimum shift value was 20 (one megabytes)

If a memnode had a finer range (with chunks not multiple of megabytes), some bits of memory could be ignored.

But with your fake node (0-3ef30000), Amul patch may give a shift value of 16.
Maybe this breaks something in the kernel...

I believe that this problem is related to a new patch that enhances the fake NUMA code (see http://article.gmane.org/gmane.linux.kernel/469457).
I'll work with the submitter of said patches to make them compatible. Hopefully that will fix the problem.

thanks,
Amul

#4 lore raw
Quoted 3 lines

I believe that this problem is related to a new patch that enhances the fake NUMA code (see http://article.gmane.org/gmane.linux.kernel/469457).

I haven't got these patches applied, so that's unlikely.

BTW if you resubmit make sure to keep the #ifdefs I added -- your original version didn't compile without CONFIG_NUMA

Does it work for you when you boot the kernel on a non NUMA system (like a normal small Intel platform)?

-Andi