From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mel Gorman Message-Id: <20060519134321.29021.99360.sendpatchset@skynet> In-Reply-To: <20060519134241.29021.84756.sendpatchset@skynet> References: <20060519134241.29021.84756.sendpatchset@skynet> Subject: [PATCH 2/2] FLATMEM relax requirement for memory to start at pfn 0 Date: Fri, 19 May 2006 14:43:21 +0100 (IST) Sender: owner-linux-mm@kvack.org Return-Path: To: akpm@osdl.org Cc: Mel Gorman , nickpiggin@yahoo.com.au, haveblue@us.ibm.com, linux-kernel@vger.kernel.org, bob.picco@hp.com, ak@suse.de, linux-mm@kvack.org, apw@shadowen.org, mingo@elte.hu, mbligh@mbligh.org List-ID: From: Andy Whitcroft The FLATMEM memory model assumes that memory is in one contigious area based at pfn 0. If we initialise node 0 to start at any other offset we will incorrectly map pfn's to the wrong struct page *. The key to the memory model is the contigious nature of the memory not the location of it. Relax the requirement for the area to start at 0. page_alloc.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) Signed-off-by: Andy Whitcroft Acked-by: Mel Gorman diff -rup -X /usr/src/patchset-0.5/bin//dontdiff linux-2.6.17-rc4-mm1-101-bob-node-alignment/mm/page_alloc.c linux-2.6.17-rc4-mm1-102-FLATMEM-relax-requirement-for-memory-to-start-at-pfn-0/mm/page_alloc.c --- linux-2.6.17-rc4-mm1-101-bob-node-alignment/mm/page_alloc.c 2006-05-18 17:58:10.000000000 +0100 +++ linux-2.6.17-rc4-mm1-102-FLATMEM-relax-requirement-for-memory-to-start-at-pfn-0/mm/page_alloc.c 2006-05-18 19:14:44.000000000 +0100 @@ -2477,15 +2477,16 @@ static void __meminit free_area_init_cor static void __init alloc_node_mem_map(struct pglist_data *pgdat) { +#ifdef CONFIG_FLAT_NODE_MEM_MAP + struct page *map = pgdat->node_mem_map; + /* Skip empty nodes */ if (!pgdat->node_spanned_pages) return; -#ifdef CONFIG_FLAT_NODE_MEM_MAP /* ia64 gets its own node_mem_map, before this, without bootmem */ - if (!pgdat->node_mem_map) { + if (!map) { unsigned long size, start, end; - struct page *map; /* * The zone's endpoints aren't required to be MAX_ORDER @@ -2500,13 +2501,21 @@ static void __init alloc_node_mem_map(st if (!map) map = alloc_bootmem_node(pgdat, size); pgdat->node_mem_map = map + (pgdat->node_start_pfn - start); + + /* + * With FLATMEM the global mem_map is used. This is assumed + * to be based at pfn 0 such that 'pfn = page* - mem_map' + * is true. Adjust map relative to node_mem_map to + * maintain this relationship. + */ + map -= pgdat->node_start_pfn; } #ifdef CONFIG_FLATMEM /* * With no DISCONTIG, the global mem_map is just set as node 0's */ if (pgdat == NODE_DATA(0)) - mem_map = NODE_DATA(0)->node_mem_map; + mem_map = map; #endif #endif /* CONFIG_FLAT_NODE_MEM_MAP */ } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org