Skip to contentSkip to conversation

dispose of _alloc_pages

CFT Martin J. Bligh 1 participant 1 message Jul 24, 2002

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

This is a forward port from Andrea's tree of the killing of _alloc_pages (I think it originally came from SGI?). It inverts the loop of "foreach(node) { foreach(zone) }" into "foreach(zone) { foreach(node) }" which seems to make much more sense, and it cleans up a lot of code in the process.

I've touch tested it on my machine, but without NUMA support as yet. If anyone else could / would test it on a different type of NUMA machine, that'd be most helpful. It's against 2.5.25 to avoid the current stability problems we're having with the bleeding edge stuff, but should be dead easy to move forward if you can use 2.5.27.

I need to test this more before submitting it. Comments?

M.

arch/sparc64/mm/init.c +1 -1
diff -urN virgin-2.5.25/arch/sparc64/mm/init.c 2.5.25-A01-numa-mm/arch/sparc64/mm/init.c
@@ -1708,7 +1708,7 @@
 	 * Set up the zero page, mark it reserved, so that page count
 	 * is not manipulated when freeing the page from user ptes.
 	 */
-	mem_map_zero = _alloc_pages(GFP_KERNEL, 0);
+	mem_map_zero = alloc_pages(GFP_KERNEL, 0);
 	if (mem_map_zero == NULL) {
 		prom_printf("paging_init: Cannot alloc zero page.\n");
 		prom_halt();
include/asm-alpha/max_numnodes.h +13 -0
diff -urN virgin-2.5.25/include/asm-alpha/max_numnodes.h 2.5.25-A01-numa-mm/include/asm-alpha/max_numnodes.h
@@ -0,0 +1,13 @@
+#ifndef _ASM_MAX_NUMNODES_H
+#define _ASM_MAX_NUMNODES_H
+
+#include <linux/config.h>
+
+#ifdef CONFIG_ALPHA_WILDFIRE
+#include <asm/core_wildfire.h>
+#define MAX_NUMNODES		WILDFIRE_MAX_QBB
+#else
+#define MAX_NUMNODES		1
+#endif
+
+#endif
include/asm-alpha/mmzone.h +0 -6
diff -urN virgin-2.5.25/include/asm-alpha/mmzone.h 2.5.25-A01-numa-mm/include/asm-alpha/mmzone.h
@@ -37,11 +37,9 @@
 #ifdef CONFIG_ALPHA_WILDFIRE
 # define ALPHA_PA_TO_NID(pa)	((pa) >> 36)	/* 16 nodes max due 43bit kseg */
 #define NODE_MAX_MEM_SIZE	(64L * 1024L * 1024L * 1024L) /* 64 GB */
-#define MAX_NUMNODES		WILDFIRE_MAX_QBB
 #else
 # define ALPHA_PA_TO_NID(pa)	(0)
 #define NODE_MAX_MEM_SIZE	(~0UL)
-#define MAX_NUMNODES		1
 #endif
 
 #define PHYSADDR_TO_NID(pa)		ALPHA_PA_TO_NID(pa)
@@ -63,8 +61,6 @@
 }
 #endif
 
-#ifdef CONFIG_DISCONTIGMEM
-
 /*
  * Following are macros that each numa implmentation must define.
  */
@@ -121,7 +117,5 @@
 
 #define numa_node_id()	cputonode(smp_processor_id())
 #endif /* CONFIG_NUMA */
-
-#endif /* CONFIG_DISCONTIGMEM */
 
 #endif /* _ASM_MMZONE_H_ */
include/linux/gfp.h +7 -2
diff -urN virgin-2.5.25/include/linux/gfp.h 2.5.25-A01-numa-mm/include/linux/gfp.h
@@ -39,7 +39,6 @@
  * can allocate highmem pages, the *get*page*() variants return
  * virtual kernel addresses to the allocated page(s).
  */
-extern struct page * FASTCALL(_alloc_pages(unsigned int gfp_mask, unsigned int order));
 extern struct page * FASTCALL(__alloc_pages(unsigned int gfp_mask, unsigned int order, zonelist_t *zonelist));
 extern struct page * alloc_pages_node(int nid, unsigned int gfp_mask, unsigned int order);
 
@@ -50,7 +49,13 @@
 	 */
 	if (order >= MAX_ORDER)
 		return NULL;
-	return _alloc_pages(gfp_mask, order);
+	/*
+	 * we get the zone list from the current node and the gfp_mask.
+	 * This zone list contains a maximum of MAXNODES*MAX_NR_ZONES zones.
+	 */
+	return __alloc_pages(gfp_mask, order,
+			NODE_DATA(numa_node_id())->node_zonelists + 
+			(gfp_mask & GFP_ZONEMASK));
 }
 
 #define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0)
include/linux/mmzone.h +12 -1
diff -urN virgin-2.5.25/include/linux/mmzone.h 2.5.25-A01-numa-mm/include/linux/mmzone.h
@@ -107,8 +107,18 @@
  * so despite the zonelist table being relatively big, the cache
  * footprint of this construct is very small.
  */
+#ifndef CONFIG_DISCONTIGMEM
+#ifdef CONFIG_MULTIQUAD        /* can have multiple nodes without discontig */
+#define MAX_NUMNODES 16
+#else
+#define MAX_NUMNODES 1
+#endif
+#else
+#include <asm/max_numnodes.h>
+#endif /* !CONFIG_DISCONTIGMEM */
+
 typedef struct zonelist_struct {
-	zone_t * zones [MAX_NR_ZONES+1]; // NULL delimited
+	zone_t * zones [MAX_NUMNODES * MAX_NR_ZONES+1]; // NULL delimited
 } zonelist_t;
 
 #define GFP_ZONEMASK	0x0f
@@ -160,6 +170,7 @@
 extern void free_area_init_core(int nid, pg_data_t *pgdat, struct page **gmap,
   unsigned long *zones_size, unsigned long paddr, unsigned long *zholes_size,
   struct page *pmap);
+extern void build_all_zonelists(void);
 
 extern pg_data_t contig_page_data;
 
init/main.c +1 -0
diff -urN virgin-2.5.25/init/main.c 2.5.25-A01-numa-mm/init/main.c
@@ -342,6 +342,7 @@
 	lock_kernel();
 	printk(linux_banner);
 	setup_arch(&command_line);
+	build_all_zonelists();
 	setup_per_cpu_areas();
 	printk("Kernel command line: %s\n", saved_command_line);
 	parse_options(command_line);
kernel/ksyms.c +3 -1
diff -urN virgin-2.5.25/kernel/ksyms.c 2.5.25-A01-numa-mm/kernel/ksyms.c
@@ -90,7 +90,6 @@
 EXPORT_SYMBOL(exit_mm);
 
 /* internal kernel memory management */
-EXPORT_SYMBOL(_alloc_pages);
 EXPORT_SYMBOL(__alloc_pages);
 EXPORT_SYMBOL(alloc_pages_node);
 EXPORT_SYMBOL(__get_free_pages);
@@ -112,7 +111,10 @@
 EXPORT_SYMBOL(vmalloc);
 EXPORT_SYMBOL(vmalloc_32);
 EXPORT_SYMBOL(vmalloc_to_page);
+#ifndef CONFIG_DISCONTIGMEM
+EXPORT_SYMBOL(contig_page_data);
 EXPORT_SYMBOL(mem_map);
+#endif
 EXPORT_SYMBOL(remap_page_range);
 EXPORT_SYMBOL(max_mapnr);
 EXPORT_SYMBOL(high_memory);
mm/numa.c +0 -45

49 lines not on this page · raw message

mm/page_alloc.c +53 -35

120 lines not on this page · raw message

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/