Skip to contentSkip to conversation

kanoj-mm19-2.3.22 generic numa-aware pagelists

PATCH New Kanoj Sarcar 1 participant 1 message Oct 19, 1999

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

PATCH 1/1 kanoj-mm19-2.3.22 generic numa-aware pagelists

Linus,

As per our discussions before you left on vacation in September, I have integrated the numa patch with the bigmem stuff. This patch is the generic code that will distribute the page free lists on a per "node" basis. Ralf will probably be using this stuff in the Origin o200/o2000 port.

Let me know if this looks okay, or if you want me to rework the patch.

Thanks.

Kanoj

linux/memacc.h +92 -0
@@ -0,0 +1,92 @@
+/*
+ * Written by Kanoj Sarcar ([email protected]) Aug 99
+ */
+#ifndef _LINUX_MEMACC_H
+#define _LINUX_MEMACC_H
+
+#ifdef __KERNEL__
+#ifndef __ASSEMBLY__
+
+#include <linux/config.h>
+#include <linux/spinlock.h>
+
+#if CONFIG_AP1000
+/* the AP+ needs to allocate 8MB contiguous, aligned chunks of ram
+   for the ring buffers */
+#define NR_MEM_LISTS 12
+#else
+#define NR_MEM_LISTS 10
+#endif
+
+#ifdef CONFIG_BIGMEM
+#define NR_FREE_LISTS	(NR_MEM_LISTS*2)
+#else /* CONFIG_BIGMEM */
+#define NR_FREE_LISTS	NR_MEM_LISTS
+#endif
+
+/* The start of this MUST match the start of "struct page" */
+struct free_area_struct {
+	struct page *next;
+	struct page *prev;
+	unsigned int * map;
+};
+
+#ifndef CONFIG_NUMA
+
+#define LOCAL_BASE_ADDR(kaddr)	PAGE_OFFSET
+#define FREE_AREA_PAGE(page)	free_area
+#define LOCAL_MAP_BASE(page)	mem_map
+#define ADDR_TO_MAPBASE(kaddr)	mem_map
+#define FREE_AREA_NODE(nid)	free_area
+#define NODE_MEM_MAP(nid)	mem_map
+#define NODE_BASE_ADDR(nid)	PAGE_OFFSET
+#define FREELIST_LOCK_PAGE(page) (&page_alloc_lock)
+#define FREELIST_LOCK_NODE(nid)	(&page_alloc_lock)
+#define LOCK_FPAGES()
+#define UNLOCK_FPAGES()
+#define DECLARE_NON_NUMA_FREE_AREA \
+			static struct free_area_struct free_area[NR_FREE_LISTS]
+
+#else /* !CONFIG_NUMA */
+
+#define LOCK_FPAGES()		{ unsigned long fl; \
+				  spin_lock_irqsave(&page_alloc_lock, fl);
+#define UNLOCK_FPAGES()		spin_unlock_irqrestore(&page_alloc_lock, fl); }
+#define DECLARE_NON_NUMA_FREE_AREA
+
+typedef struct pglist_data {
+	struct free_area_struct free_area[NR_FREE_LISTS];
+	spinlock_t node_page_lock;
+	struct page *node_mem_map;
+	unsigned long node_map_size;
+	unsigned long *valid_addr_bitmap;
+} pg_data_t;
+
+extern int numnodes;
+
+#include <asm/memacc.h>
+
+#define MAP_ALIGN(x)	((((x) % sizeof(mem_map_t)) == 0) ? (x) : ((x) + \
+		sizeof(mem_map_t) - ((x) % sizeof(mem_map_t))))
+
+#endif /* !CONFIG_NUMA */
+
+#define LOCAL_MAP_NR(kvaddr) \
+	(((unsigned long)(kvaddr)-LOCAL_BASE_ADDR((kvaddr))) \
+							>> PAGE_SHIFT)
+
+#ifdef CONFIG_NUMA
+
+#define MAP_NR(kaddr)		(LOCAL_MAP_NR((kaddr)) + \
+		(((unsigned long)ADDR_TO_MAPBASE((kaddr)) - PAGE_OFFSET) / \
+		sizeof(mem_map_t)))
+#define kern_addr_valid(addr)	((KVADDR_TO_NID((unsigned long)addr) >= \
+	numnodes) ? 0 : (test_bit(LOCAL_MAP_NR((addr)), \
+	NODE_DATA(KVADDR_TO_NID((unsigned long)addr))->valid_addr_bitmap)))
+
+#endif /* CONFIG_NUMA */
+
+#endif /* !__ASSEMBLY__ */
+#endif /* __KERNEL__ */
+
+#endif /* _LINUX_MEMACC_H */
linux/mm.h renamed from usr/tmp/p_rdiff_a005L5/mm.h +4 -0
@@ -283,7 +283,10 @@
  */
 #define __get_free_page(gfp_mask) __get_free_pages((gfp_mask),0)
 #define __get_dma_pages(gfp_mask, order) __get_free_pages((gfp_mask) | GFP_DMA,(order))
+#define __get_free_page_node(gfp_mask, node) __get_free_pages_node((gfp_mask),0,node)
+#define __get_dma_pages_node(gfp_mask, order, node) __get_free_pages_node((gfp_mask) | GFP_DMA,(order),node)
 extern unsigned long FASTCALL(__get_free_pages(int gfp_mask, unsigned long gfp_order));
+extern unsigned long FASTCALL(__get_free_pages_node(int gfp_mask, unsigned long gfp_order, int));
 
 extern inline unsigned long get_free_page(int gfp_mask)
 {
@@ -302,6 +305,7 @@
 extern int FASTCALL(__free_page(struct page *));
 
 extern void show_free_areas(void);
+extern void show_free_areas_node(int);
 extern unsigned long put_dirty_page(struct task_struct * tsk,unsigned long page,
 	unsigned long address);
 
linux/pagemap.h renamed from usr/tmp/p_rdiff_a005LF/pagemap.h +4 -1
@@ -11,10 +11,13 @@
 
 #include <linux/mm.h>
 #include <linux/fs.h>
+#include <linux/memacc.h>
 
 static inline unsigned long page_address(struct page * page)
 {
-	return PAGE_OFFSET + ((page - mem_map) << PAGE_SHIFT);
+	return LOCAL_BASE_ADDR(page) + PAGE_SIZE * \
+		(((unsigned long)page - (unsigned long)LOCAL_MAP_BASE(page)) \
+			/ sizeof(struct page));
 }
 
 /*
Makefile renamed from usr/tmp/p_rdiff_a005Lk/Makefile +1 -1
@@ -13,7 +13,7 @@
 O_TARGET := kernel.o
 O_OBJS    = sched.o dma.o fork.o exec_domain.o panic.o printk.o sys.o \
 	    module.o exit.o itimer.o info.o time.o softirq.o resource.o \
-	    sysctl.o acct.o capability.o ptrace.o
+	    sysctl.o acct.o capability.o ptrace.o numa.o
 
 OX_OBJS  += signal.o
 
ksyms.c renamed from usr/tmp/p_rdiff_a005M5/ksyms.c +1 -0
@@ -91,6 +91,7 @@
 
 /* internal kernel memory management */
 EXPORT_SYMBOL(__get_free_pages);
+EXPORT_SYMBOL(__get_free_pages_node);
 EXPORT_SYMBOL(free_pages);
 EXPORT_SYMBOL(__free_page);
 EXPORT_SYMBOL(kmem_find_general_cachep);
numa.c +106 -0

106 lines not on this page · raw message

page_alloc.c renamed from usr/tmp/p_rdiff_a005Mb/page_alloc.c +88 -61

319 lines not on this page · raw message

swap.c renamed from usr/tmp/p_rdiff_a005Mw/swap.c +5 -5
@@ -30,13 +30,13 @@
  * start background swapping if we fall below freepages.high free
  * pages, and we begin intensive swapping below freepages.low.
  *
- * These values are there to keep GCC from complaining. Actual
- * initialization is done in mm/page_alloc.c or arch/sparc(64)/mm/init.c.
+ * Actual initialization is done in mm/page_alloc.c or 
+ * arch/sparc(64)/mm/init.c.
  */
 freepages_t freepages = {
-	48,	/* freepages.min */
-	96,	/* freepages.low */
-	144	/* freepages.high */
+	0,	/* freepages.min */
+	0,	/* freepages.low */
+	0	/* freepages.high */
 };
 
 /* How many pages do we try to swap or page in/out together? */

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