Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759828Ab2J2QDY (ORCPT ); Mon, 29 Oct 2012 12:03:24 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:31364 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1759617Ab2J2QDT (ORCPT ); Mon, 29 Oct 2012 12:03:19 -0400 X-IronPort-AV: E=Sophos;i="4.80,673,1344182400"; d="scan'208";a="6093402" From: Lai Jiangshan To: Mel Gorman , David Rientjes , LKML , x86 maintainers Cc: Jiang Liu , Rusty Russell , Yinghai Lu , KAMEZAWA Hiroyuki , Yasuaki ISIMATU , Andrew Morton , Lai Jiangshan , Rob Landley , Minchan Kim , Michal Hocko , linux-doc@vger.kernel.org, linux-mm@kvack.org Subject: [V5 PATCH 21/26] page_alloc: add kernelcore_max_addr Date: Mon, 29 Oct 2012 23:21:11 +0800 Message-Id: <1351524078-20363-20-git-send-email-laijs@cn.fujitsu.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1351523301-20048-1-git-send-email-laijs@cn.fujitsu.com> References: <1351523301-20048-1-git-send-email-laijs@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/10/29 23:19:41, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/10/29 23:19:45, Serialize complete at 2012/10/29 23:19:45 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4881 Lines: 124 Current ZONE_MOVABLE (kernelcore=) setting policy with boot option doesn't meet our requirement. We need something like kernelcore_max_addr=XX boot option to limit the kernelcore upper address. The memory with higher address will be migratable(movable) and they are easier to be offline(always ready to be offline when the system don't require so much memory). It makes things easy when we dynamic hot-add/remove memory, make better utilities of memories, and helps for THP. All kernelcore_max_addr=, kernelcore= and movablecore= can be safely specified at the same time(or any 2 of them). Signed-off-by: Lai Jiangshan --- Documentation/kernel-parameters.txt | 9 +++++++++ mm/page_alloc.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 9776f06..2b72ffb 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -1223,6 +1223,15 @@ bytes respectively. Such letter suffixes can also be entirely omitted. use the HighMem zone if it exists, and the Normal zone if it does not. + kernelcore_max_addr=nn[KMG] [KNL,X86,IA-64,PPC] This parameter + is the same effect as kernelcore parameter, except it + specifies the up physical address of memory range + usable by the kernel for non-movable allocations. + If both kernelcore and kernelcore_max_addr are + specified, this requested's priority is higher than + kernelcore's. + See the kernelcore parameter. + kgdbdbgp= [KGDB,HW] kgdb over EHCI usb debug port. Format: [,poll interval] The controller # is the number of the ehci usb debug diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a42337f..11df8b5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -203,6 +203,7 @@ static unsigned long __meminitdata dma_reserve; #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_NR_ZONES]; static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_NR_ZONES]; +static unsigned long __initdata required_kernelcore_max_pfn; static unsigned long __initdata required_kernelcore; static unsigned long __initdata required_movablecore; static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES]; @@ -4700,6 +4701,7 @@ static void __init find_zone_movable_pfns_for_nodes(void) { int i, nid; unsigned long usable_startpfn; + unsigned long kernelcore_max_pfn; unsigned long kernelcore_node, kernelcore_remaining; /* save the state before borrow the nodemask */ nodemask_t saved_node_state = node_states[N_MEMORY]; @@ -4728,6 +4730,9 @@ static void __init find_zone_movable_pfns_for_nodes(void) required_kernelcore = max(required_kernelcore, corepages); } + if (required_kernelcore_max_pfn && !required_kernelcore) + required_kernelcore = totalpages; + /* If kernelcore was not specified, there is no ZONE_MOVABLE */ if (!required_kernelcore) goto out; @@ -4736,6 +4741,12 @@ static void __init find_zone_movable_pfns_for_nodes(void) find_usable_zone_for_movable(); usable_startpfn = arch_zone_lowest_possible_pfn[movable_zone]; + if (required_kernelcore_max_pfn) + kernelcore_max_pfn = required_kernelcore_max_pfn; + else + kernelcore_max_pfn = ULONG_MAX >> PAGE_SHIFT; + kernelcore_max_pfn = max(kernelcore_max_pfn, usable_startpfn); + restart: /* Spread kernelcore memory as evenly as possible throughout nodes */ kernelcore_node = required_kernelcore / usable_nodes; @@ -4762,8 +4773,12 @@ restart: unsigned long size_pages; start_pfn = max(start_pfn, zone_movable_pfn[nid]); - if (start_pfn >= end_pfn) + end_pfn = min(kernelcore_max_pfn, end_pfn); + if (start_pfn >= end_pfn) { + if (!zone_movable_pfn[nid]) + zone_movable_pfn[nid] = start_pfn; continue; + } /* Account for what is only usable for kernelcore */ if (start_pfn < usable_startpfn) { @@ -4954,6 +4969,18 @@ static int __init cmdline_parse_core(char *p, unsigned long *core) return 0; } +#ifdef CONFIG_MOVABLE_NODE +/* + * kernelcore_max_addr=addr sets the up physical address of memory range + * for use for allocations that cannot be reclaimed or migrated. + */ +static int __init cmdline_parse_kernelcore_max_addr(char *p) +{ + return cmdline_parse_core(p, &required_kernelcore_max_pfn); +} +early_param("kernelcore_max_addr", cmdline_parse_kernelcore_max_addr); +#endif + /* * kernelcore=size sets the amount of memory for use for allocations that * cannot be reclaimed or migrated. -- 1.7.4.4 -- 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/