Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754260Ab0BAMW1 (ORCPT ); Mon, 1 Feb 2010 07:22:27 -0500 Received: from mga02.intel.com ([134.134.136.20]:50019 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753991Ab0BAMW0 (ORCPT ); Mon, 1 Feb 2010 07:22:26 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.49,383,1262592000"; d="scan'208";a="592094062" Date: Mon, 1 Feb 2010 20:22:02 +0800 From: Shaohui Zheng To: Wu Fengguang , akpm@linux-foundation.org, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, y-goto@jp.fujitsu.com, haveblue@us.ibm.com, kamezawa.hiroyu@jp.fujitsu.com, ak@linux.intel.com, fengguang.wu@intel.com, hpa@kernel.org, haicheng.li@intel.com, shaohui.zheng@linux.intel.com Subject: Re: [Patch - Resend v4] Memory-Hotplug: Fix the bug on interface /dev/mem for 64-bit kernel Message-ID: <20100201122202.GA2021@shaohui> Mail-Followup-To: Wu Fengguang , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, y-goto@jp.fujitsu.com, haveblue@us.ibm.com, kamezawa.hiroyu@jp.fujitsu.com, ak@linux.intel.com, hpa@kernel.org, haicheng.li@intel.com, shaohui.zheng@linux.intel.com References: <20100201041253.GA1028@shaohui> <20100201044124.GA29097@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="/04w6evG8XlLl3ft" Content-Disposition: inline In-Reply-To: <20100201044124.GA29097@localhost> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4703 Lines: 162 --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Feb 01, 2010 at 12:41:24PM +0800, Wu Fengguang wrote: > Shaohui, > > Some style nitpicks.. > > > #ifdef CONFIG_MEMORY_HOTPLUG > > +/** > > Should use /* here. Agree. > > > + * After memory hotplug, the variable max_pfn, max_low_pfn and high_memory will > > + * be affected, it will be updated in this function. > > + */ > > +static inline void __meminit update_end_of_memory_vars(u64 start, > > The "inline" and "__meminit" are both redundant here. will remove both. > > > + max_low_pfn = max_pfn = end_pfn; > > One assignment per line is preferred. will change to 2 statements. > > Thanks, > Fengguang Memory-Hotplug: Fix the bug on interface /dev/mem for 64-bit kernel The new added memory can not be access by interface /dev/mem, because we do not update the variables high_memory, max_pfn and max_low_pfn. Add a function update_end_of_memory_vars to update these variables for 64-bit kernel. CC: Andi Kleen CC: Li Haicheng Reviewed-by: Wu Fengguang Reviewed-by: KAMEZAWA Hiroyuki Signed-off-by: Shaohui Zheng diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 5198b9b..e1c9202 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -49,6 +49,7 @@ #include #include #include +#include static unsigned long dma_reserve __initdata; @@ -616,6 +617,21 @@ void __init paging_init(void) */ #ifdef CONFIG_MEMORY_HOTPLUG /* + * After memory hotplug, the variables max_pfn, max_low_pfn and high_memory will + * be affected, they will be updated in this function. + */ +static void update_end_of_memory_vars(u64 start, u64 size) +{ + unsigned long end_pfn = PFN_UP(start + size); + + if (end_pfn > max_pfn) { + max_pfn = end_pfn; + max_low_pfn = end_pfn; + high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1; + } +} + +/* * Memory is added always to NORMAL zone. This means you will never get * additional DMA/DMA32 memory. */ @@ -634,6 +650,9 @@ int arch_add_memory(int nid, u64 start, u64 size) ret = __add_pages(nid, zone, start_pfn, nr_pages); WARN_ON_ONCE(ret); + /* update max_pfn, max_low_pfn and high_memory */ + update_end_of_memory_vars(start, size); + return ret; } EXPORT_SYMBOL_GPL(arch_add_memory); -- Thanks & Regards, Shaohui --/04w6evG8XlLl3ft Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="memory-hotplug-fix-the-bug-on-interface-dev-mem-v5.patch" Memory-Hotplug: Fix the bug on interface /dev/mem for 64-bit kernel The new added memory can not be access by interface /dev/mem, because we do not update the variables high_memory, max_pfn and max_low_pfn. Add a function update_end_of_memory_vars to update these variables for 64-bit kernel. CC: Andi Kleen CC: Li Haicheng Reviewed-by: Wu Fengguang Reviewed-by: KAMEZAWA Hiroyuki Signed-off-by: Shaohui Zheng diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 5198b9b..e1c9202 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -49,6 +49,7 @@ #include #include #include +#include static unsigned long dma_reserve __initdata; @@ -616,6 +617,21 @@ void __init paging_init(void) */ #ifdef CONFIG_MEMORY_HOTPLUG /* + * After memory hotplug, the variables max_pfn, max_low_pfn and high_memory will + * be affected, they will be updated in this function. + */ +static void update_end_of_memory_vars(u64 start, u64 size) +{ + unsigned long end_pfn = PFN_UP(start + size); + + if (end_pfn > max_pfn) { + max_pfn = end_pfn; + max_low_pfn = end_pfn; + high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1; + } +} + +/* * Memory is added always to NORMAL zone. This means you will never get * additional DMA/DMA32 memory. */ @@ -634,6 +650,9 @@ int arch_add_memory(int nid, u64 start, u64 size) ret = __add_pages(nid, zone, start_pfn, nr_pages); WARN_ON_ONCE(ret); + /* update max_pfn, max_low_pfn and high_memory */ + update_end_of_memory_vars(start, size); + return ret; } EXPORT_SYMBOL_GPL(arch_add_memory); --/04w6evG8XlLl3ft-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/