From patchwork Thu Feb 5 11:14:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KAMEZAWA Hiroyuki X-Patchwork-Id: 22102 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 5785ADDDDB for ; Thu, 5 Feb 2009 22:16:09 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752332AbZBELQG (ORCPT ); Thu, 5 Feb 2009 06:16:06 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752221AbZBELQG (ORCPT ); Thu, 5 Feb 2009 06:16:06 -0500 Received: from fgwmail7.fujitsu.co.jp ([192.51.44.37]:36834 "EHLO fgwmail7.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752057AbZBELQF (ORCPT ); Thu, 5 Feb 2009 06:16:05 -0500 Received: from m5.gw.fujitsu.co.jp ([10.0.50.75]) by fgwmail7.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id n15BFxo8032199 (envelope-from kamezawa.hiroyu@jp.fujitsu.com); Thu, 5 Feb 2009 20:15:59 +0900 Received: from smail (m5 [127.0.0.1]) by outgoing.m5.gw.fujitsu.co.jp (Postfix) with ESMTP id 9CFBA45DE4F; Thu, 5 Feb 2009 20:15:59 +0900 (JST) Received: from s5.gw.fujitsu.co.jp (s5.gw.fujitsu.co.jp [10.0.50.95]) by m5.gw.fujitsu.co.jp (Postfix) with ESMTP id 6FB4245DE4C; Thu, 5 Feb 2009 20:15:59 +0900 (JST) Received: from s5.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s5.gw.fujitsu.co.jp (Postfix) with ESMTP id 506481DB805B; Thu, 5 Feb 2009 20:15:59 +0900 (JST) Received: from ml14.s.css.fujitsu.com (ml14.s.css.fujitsu.com [10.249.87.104]) by s5.gw.fujitsu.co.jp (Postfix) with ESMTP id EE1041DB805E; Thu, 5 Feb 2009 20:15:58 +0900 (JST) Received: from ml14.css.fujitsu.com (ml14 [127.0.0.1]) by ml14.s.css.fujitsu.com (Postfix) with ESMTP id C3BE09F5EB6; Thu, 5 Feb 2009 20:15:58 +0900 (JST) Received: from WIN-WAU6SZB64RR (unknown [10.124.100.143]) by ml14.s.css.fujitsu.com (Postfix) with SMTP id 4D99C9F5EB5; Thu, 5 Feb 2009 20:15:58 +0900 (JST) Date: Thu, 5 Feb 2009 20:14:48 +0900 From: KAMEZAWA Hiroyuki To: Mel Gorman Cc: David Miller , heiko.carstens@de.ibm.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org Subject: [BUGFIX][PATCH] fix memmap init to initialize valid memmap for memory hole. (Was Re: HOLES_IN_ZONE... Message-Id: <20090205201448.3a0f4182.kamezawa.hiroyu@jp.fujitsu.com> In-Reply-To: <20090205103925.GE26878@csn.ul.ie> References: <20090204.222651.26527737.davem@davemloft.net> <20090205180617.8ee3dfb5.kamezawa.hiroyu@jp.fujitsu.com> <20090205.012123.141238531.davem@davemloft.net> <20090205183409.1a12c23b.kamezawa.hiroyu@jp.fujitsu.com> <20090205103925.GE26878@csn.ul.ie> Organization: FUJITSU Co. LTD. X-Mailer: Sylpheed 2.5.0 (GTK+ 2.10.14; i686-pc-mingw32) Mime-Version: 1.0 Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org On Thu, 5 Feb 2009 10:39:25 +0000 Mel Gorman wrote: > ==== > If a PFN is not in early_node_map[] then the struct page for it is not > initialised. If there are holes within a MAX_ORDER_NR_PAGES range of > pages, then PG_reserved will not be set. Code that walks PFNs within > MAX_ORDER_NR_PAGES will then use uninitialised struct pages. > > To avoid any problems, this patch initialises holes within a MAX_ORDER_NR_PAGES > that valid memmap exists but is otherwise unused. > ==== > Thank you, I use this text. == If PFN is not in early_node_map[] then struct page for it is not initialized. If there are holes within a MAX_ORDER_NE_PAGES range of pages, then PG_reserved will not be set. Code that walks PFNs within MAX_ORDER_NR_PAGES will the use uninitialized struct pages. To avoid any problems, this patch initializes holes within a MAX_ORDER_NR_PAGES that valid memmap exists but is otherwise unused. Changelog: - renamed variable from "tmp" to "actual_nid" Reported-by: David Miller Acked-by: Mel Gorman Signed-off-by: KAMEZAWA Hiroyuki --- include/linux/mmzone.h | 6 ------ mm/page_alloc.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6.28-rc3/mm/page_alloc.c =================================================================== --- linux-2.6.28-rc3.orig/mm/page_alloc.c +++ linux-2.6.28-rc3/mm/page_alloc.c @@ -2632,9 +2632,18 @@ void __meminit memmap_init_zone(unsigned * exist on hotplugged memory. */ if (context == MEMMAP_EARLY) { + int nid_from_node_memory_map; + if (!early_pfn_valid(pfn)) continue; - if (!early_pfn_in_nid(pfn, nid)) + /* + * early_pfn_to_nid() returns -1 if the page doesn't + * exist in early_node_map[]. Initialize it in force + * and set PG_reserved at el. + */ + nid_from_node_memory_map = early_pfn_to_nid(pfn); + if (nid_from_node_memory_map > -1 && + nid_from_node_memory_map != nid) continue; } page = pfn_to_page(pfn); @@ -3001,7 +3010,7 @@ int __meminit early_pfn_to_nid(unsigned return early_node_map[i].nid; } - return 0; + return -1; } #endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */ Index: linux-2.6.28-rc3/include/linux/mmzone.h =================================================================== --- linux-2.6.28-rc3.orig/include/linux/mmzone.h +++ linux-2.6.28-rc3/include/linux/mmzone.h @@ -1070,12 +1070,6 @@ void sparse_init(void); #define sparse_index_init(_sec, _nid) do {} while (0) #endif /* CONFIG_SPARSEMEM */ -#ifdef CONFIG_NODES_SPAN_OTHER_NODES -#define early_pfn_in_nid(pfn, nid) (early_pfn_to_nid(pfn) == (nid)) -#else -#define early_pfn_in_nid(pfn, nid) (1) -#endif - #ifndef early_pfn_valid #define early_pfn_valid(pfn) (1) #endif