public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] Only use ARCH_PFN_OFFSET once during boot
@ 2006-07-06  9:51 Mel Gorman
  2006-07-06 14:34 ` Franck Bui-Huu
  0 siblings, 1 reply; 10+ messages in thread
From: Mel Gorman @ 2006-07-06  9:51 UTC (permalink / raw)
  To: akpm; +Cc: Mel Gorman, linux-kernel, vagabon.xyz

The FLATMEM memory model assumes that memory is one contiguous region based
at PFN 0 and uses the NODE_DATA(0)->node_mem_map as the global mem_map. As
NODE_DATA(0)->node_mem_map may not be PFN 0, architectures optionally define
ARCH_PFN_OFFSET as the offset between NODE_DATA(0)->node_mem_map and PFN 0.
This offset is used every time page_to_pfn() or pfn_to_page() is called
resulting in a small amount of code bloat and overhead.

This patch changes ARCH_PFN_OFFSET so that it is used only once during
memory initialisation when working out where mem_map is. This gives
a very small reduction in zImage size for architectures using
ARCH_PFN_OFFSET. The patch also adds a small amount of documentation
on what ARCH_PFN_OFFSET is for.

Signed-off-by: Mel Gorman <mel@csn.ul.ie>

 include/asm-generic/memory_model.h |    5 ++---
 mm/page_alloc.c                    |    8 ++++++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.17-mm6-clean/include/asm-generic/memory_model.h linux-2.6.17-mm6-archpfnoffset_optimise/include/asm-generic/memory_model.h
--- linux-2.6.17-mm6-clean/include/asm-generic/memory_model.h	2006-07-05 14:31:17.000000000 +0100
+++ linux-2.6.17-mm6-archpfnoffset_optimise/include/asm-generic/memory_model.h	2006-07-05 14:36:04.000000000 +0100
@@ -28,9 +28,8 @@
  */
 #if defined(CONFIG_FLATMEM)
 
-#define __pfn_to_page(pfn)	(mem_map + ((pfn) - ARCH_PFN_OFFSET))
-#define __page_to_pfn(page)	((unsigned long)((page) - mem_map) + \
-				 ARCH_PFN_OFFSET)
+#define __pfn_to_page(pfn)	(mem_map + (pfn))
+#define __page_to_pfn(page)	((unsigned long)((page) - mem_map))
 #elif defined(CONFIG_DISCONTIGMEM)
 
 #define __pfn_to_page(pfn)			\
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.17-mm6-clean/mm/page_alloc.c linux-2.6.17-mm6-archpfnoffset_optimise/mm/page_alloc.c
--- linux-2.6.17-mm6-clean/mm/page_alloc.c	2006-07-05 14:31:18.000000000 +0100
+++ linux-2.6.17-mm6-archpfnoffset_optimise/mm/page_alloc.c	2006-07-05 17:01:01.000000000 +0100
@@ -2157,10 +2157,14 @@ static void __init alloc_node_mem_map(st
 	}
 #ifdef CONFIG_FLATMEM
 	/*
-	 * With no DISCONTIG, the global mem_map is just set as node 0's
+	 * With FLATMEM, the global mem_map is just set as node 0's. The
+	 * FLATMEM memory model assumes that memory is in one contiguous area
+	 * starting at PFN 0. Architectures that do not start NODE 0 at PFN 0
+	 * must define ARCH_PFN_OFFSET as the offset between
+	 * NODE_DATA(0)->node_mem_map and PFN 0.
 	 */
 	if (pgdat == NODE_DATA(0))
-		mem_map = NODE_DATA(0)->node_mem_map;
+		mem_map = NODE_DATA(0)->node_mem_map - ARCH_PFN_OFFSET;
 #endif
 #endif /* CONFIG_FLAT_NODE_MEM_MAP */
 }
 

^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <BFECAF9E178F144FAEF2BF4CE739C66803EF8299@exmail1.se.axis.com>]

end of thread, other threads:[~2006-07-07 12:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-06  9:51 [PATCH 1/1] Only use ARCH_PFN_OFFSET once during boot Mel Gorman
2006-07-06 14:34 ` Franck Bui-Huu
2006-07-06 16:08   ` Mel Gorman
2006-07-06 18:01     ` Franck Bui-Huu
2006-07-06 19:55       ` Mel Gorman
2006-07-07  8:01         ` Franck Bui-Huu
2006-07-07  9:14           ` Mel Gorman
2006-07-07 11:41             ` Franck Bui-Huu
2006-07-07 12:31               ` Mel Gorman
     [not found] <BFECAF9E178F144FAEF2BF4CE739C66803EF8299@exmail1.se.axis.com>
2006-07-07 12:37 ` Mikael Starvik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox