linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PART5 Patch 0/5] introduce a new boot option 'kernelcore_max_addr'
@ 2012-10-31  9:21 Wen Congyang
  2012-10-31  9:21 ` [PART5 Patch 1/5] page_alloc: add kernelcore_max_addr Wen Congyang
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Wen Congyang @ 2012-10-31  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-mm, linux-doc
  Cc: Rob Landley, Andrew Morton, Yasuaki Ishimatsu, Lai Jiangshan,
	Jiang Liu, KOSAKI Motohiro, Minchan Kim, Mel Gorman,
	David Rientjes, Yinghai Lu, rusty@rustcorp.com.au

From: Lai Jiangshan <laijs@cn.fujitsu.com>

This patch is part5 of the following patchset:
    https://lkml.org/lkml/2012/10/29/319

The patchset is based on Linus's tree with these three patches already applied:
    https://lkml.org/lkml/2012/10/24/151
    https://lkml.org/lkml/2012/10/26/150

Part1 is here:
    https://lkml.org/lkml/2012/10/31/30

Part2 is here:
    http://marc.info/?l=linux-kernel&m=135166705909544&w=2

Part3 is here:
    http://marc.info/?l=linux-kernel&m=135167050510527&w=2

Part4 is here:
    http://marc.info/?l=linux-kernel&m=135167344211401&w=2

You can apply this patch without the other parts. But it only can work with
part1-5.

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.

Lai Jiangshan (1):
  page_alloc: add kernelcore_max_addr

Yasuaki Ishimatsu (4):
  x86: get pg_data_t's memory from other node
  x86: use memblock_set_current_limit() to set memblock.current_limit
  memblock: limit memory address from memblock
  memblock: compare current_limit with end variable at
    memblock_find_in_range_node()

 Documentation/kernel-parameters.txt |  9 +++++++++
 arch/x86/kernel/setup.c             |  4 ++--
 arch/x86/mm/numa.c                  |  8 ++++++--
 include/linux/memblock.h            |  1 +
 mm/memblock.c                       | 10 +++++++---
 mm/page_alloc.c                     | 33 ++++++++++++++++++++++++++++++++-
 6 files changed, 57 insertions(+), 8 deletions(-)

-- 
1.8.0

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PART5 Patch 1/5] page_alloc: add kernelcore_max_addr
  2012-10-31  9:21 [PART5 Patch 0/5] introduce a new boot option 'kernelcore_max_addr' Wen Congyang
@ 2012-10-31  9:21 ` Wen Congyang
  2012-12-19 19:26   ` Randy Dunlap
  2012-10-31  9:21 ` [PART5 Patch 2/5] x86: get pg_data_t's memory from other node Wen Congyang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Wen Congyang @ 2012-10-31  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-mm, linux-doc
  Cc: Rob Landley, Andrew Morton, Yasuaki Ishimatsu, Lai Jiangshan,
	Jiang Liu, KOSAKI Motohiro, Minchan Kim, Mel Gorman,
	David Rientjes, Yinghai Lu, rusty@rustcorp.com.au

From: Lai Jiangshan <laijs@cn.fujitsu.com>

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 <laijs@cn.fujitsu.com>
---
 Documentation/kernel-parameters.txt |  9 +++++++++
 mm/page_alloc.c                     | 29 ++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 1 deletion(-)

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: <Controller#>[,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 5b74de6..9c35fe5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -200,6 +200,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];
@@ -4715,6 +4716,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_HIGH_MEMORY];
@@ -4743,6 +4745,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;
@@ -4751,6 +4756,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;
@@ -4777,8 +4788,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) {
@@ -4965,6 +4980,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.8.0

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PART5 Patch 2/5] x86: get pg_data_t's memory from other node
  2012-10-31  9:21 [PART5 Patch 0/5] introduce a new boot option 'kernelcore_max_addr' Wen Congyang
  2012-10-31  9:21 ` [PART5 Patch 1/5] page_alloc: add kernelcore_max_addr Wen Congyang
@ 2012-10-31  9:21 ` Wen Congyang
  2012-10-31  9:21 ` [PART5 Patch 3/5] x86: use memblock_set_current_limit() to set memblock.current_limit Wen Congyang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Wen Congyang @ 2012-10-31  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-mm, linux-doc
  Cc: Rob Landley, Andrew Morton, Yasuaki Ishimatsu, Lai Jiangshan,
	Jiang Liu, KOSAKI Motohiro, Minchan Kim, Mel Gorman,
	David Rientjes, Yinghai Lu, rusty@rustcorp.com.au

From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

If system can create movable node which all memory of the
node is allocated as ZONE_MOVABLE, setup_node_data() cannot
allocate memory for the node's pg_data_t.
So when memblock_alloc_nid() fails, setup_node_data() retries
memblock_alloc().

Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 arch/x86/mm/numa.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 2d125be..a86e315 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -223,9 +223,13 @@ static void __init setup_node_data(int nid, u64 start, u64 end)
 		remapped = true;
 	} else {
 		nd_pa = memblock_alloc_nid(nd_size, SMP_CACHE_BYTES, nid);
-		if (!nd_pa) {
-			pr_err("Cannot find %zu bytes in node %d\n",
+		if (!nd_pa)
+			printk(KERN_WARNING "Cannot find %zu bytes in node %d\n",
 			       nd_size, nid);
+		nd_pa = memblock_alloc(nd_size, SMP_CACHE_BYTES);
+		if (!nd_pa) {
+			pr_err("Cannot find %zu bytes in other node\n",
+			       nd_size);
 			return;
 		}
 		nd = __va(nd_pa);
-- 
1.8.0

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PART5 Patch 3/5] x86: use memblock_set_current_limit() to set memblock.current_limit
  2012-10-31  9:21 [PART5 Patch 0/5] introduce a new boot option 'kernelcore_max_addr' Wen Congyang
  2012-10-31  9:21 ` [PART5 Patch 1/5] page_alloc: add kernelcore_max_addr Wen Congyang
  2012-10-31  9:21 ` [PART5 Patch 2/5] x86: get pg_data_t's memory from other node Wen Congyang
@ 2012-10-31  9:21 ` Wen Congyang
  2012-10-31  9:21 ` [PART5 Patch 4/5] memblock: limit memory address from memblock Wen Congyang
  2012-10-31  9:21 ` [PART5 Patch 5/5] memblock: compare current_limit with end variable at memblock_find_in_range_node() Wen Congyang
  4 siblings, 0 replies; 8+ messages in thread
From: Wen Congyang @ 2012-10-31  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-mm, linux-doc
  Cc: Rob Landley, Andrew Morton, Yasuaki Ishimatsu, Lai Jiangshan,
	Jiang Liu, KOSAKI Motohiro, Minchan Kim, Mel Gorman,
	David Rientjes, Yinghai Lu, rusty@rustcorp.com.au

From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

memblock.current_limit is set directly though memblock_set_current_limit()
is prepared. So fix it.

Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 arch/x86/kernel/setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index ca45696..ab3017a 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -890,7 +890,7 @@ void __init setup_arch(char **cmdline_p)
 
 	cleanup_highmap();
 
-	memblock.current_limit = get_max_mapped();
+	memblock_set_current_limit(get_max_mapped());
 	memblock_x86_fill();
 
 	/*
@@ -940,7 +940,7 @@ void __init setup_arch(char **cmdline_p)
 		max_low_pfn = max_pfn;
 	}
 #endif
-	memblock.current_limit = get_max_mapped();
+	memblock_set_current_limit(get_max_mapped());
 	dma_contiguous_reserve(0);
 
 	/*
-- 
1.8.0

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PART5 Patch 4/5] memblock: limit memory address from memblock
  2012-10-31  9:21 [PART5 Patch 0/5] introduce a new boot option 'kernelcore_max_addr' Wen Congyang
                   ` (2 preceding siblings ...)
  2012-10-31  9:21 ` [PART5 Patch 3/5] x86: use memblock_set_current_limit() to set memblock.current_limit Wen Congyang
@ 2012-10-31  9:21 ` Wen Congyang
  2012-10-31  9:21 ` [PART5 Patch 5/5] memblock: compare current_limit with end variable at memblock_find_in_range_node() Wen Congyang
  4 siblings, 0 replies; 8+ messages in thread
From: Wen Congyang @ 2012-10-31  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-mm, linux-doc
  Cc: Rob Landley, Andrew Morton, Yasuaki Ishimatsu, Lai Jiangshan,
	Jiang Liu, KOSAKI Motohiro, Minchan Kim, Mel Gorman,
	David Rientjes, Yinghai Lu, rusty@rustcorp.com.au

From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

Setting kernelcore_max_pfn means all memory which is bigger than
the boot parameter is allocated as ZONE_MOVABLE. So memory which
is allocated by memblock also should be limited by the parameter.

The patch limits memory from memblock.

Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 include/linux/memblock.h | 1 +
 mm/memblock.c            | 5 ++++-
 mm/page_alloc.c          | 6 +++++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index d452ee1..3e52911 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -42,6 +42,7 @@ struct memblock {
 
 extern struct memblock memblock;
 extern int memblock_debug;
+extern phys_addr_t memblock_limit;
 
 #define memblock_dbg(fmt, ...) \
 	if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
diff --git a/mm/memblock.c b/mm/memblock.c
index 6259055..ee2e307 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -957,7 +957,10 @@ void __init_memblock memblock_trim_memory(phys_addr_t align)
 
 void __init_memblock memblock_set_current_limit(phys_addr_t limit)
 {
-	memblock.current_limit = limit;
+	if (!memblock_limit || (memblock_limit > limit))
+		memblock.current_limit = limit;
+	else
+		memblock.current_limit = memblock_limit;
 }
 
 static void __init_memblock memblock_dump(struct memblock_type *type, char *name)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9c35fe5..26f007bd 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -205,6 +205,8 @@ static unsigned long __initdata required_kernelcore;
 static unsigned long __initdata required_movablecore;
 static unsigned long __meminitdata zone_movable_pfn[MAX_NUMNODES];
 
+phys_addr_t memblock_limit;
+
 /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */
 int movable_zone;
 EXPORT_SYMBOL(movable_zone);
@@ -4987,7 +4989,9 @@ static int __init cmdline_parse_core(char *p, unsigned long *core)
  */
 static int __init cmdline_parse_kernelcore_max_addr(char *p)
 {
-	return cmdline_parse_core(p, &required_kernelcore_max_pfn);
+	cmdline_parse_core(p, &required_kernelcore_max_pfn);
+	memblock_limit = required_kernelcore_max_pfn << PAGE_SHIFT;
+	return 0;
 }
 early_param("kernelcore_max_addr", cmdline_parse_kernelcore_max_addr);
 #endif
-- 
1.8.0

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PART5 Patch 5/5] memblock: compare current_limit with end variable at memblock_find_in_range_node()
  2012-10-31  9:21 [PART5 Patch 0/5] introduce a new boot option 'kernelcore_max_addr' Wen Congyang
                   ` (3 preceding siblings ...)
  2012-10-31  9:21 ` [PART5 Patch 4/5] memblock: limit memory address from memblock Wen Congyang
@ 2012-10-31  9:21 ` Wen Congyang
  4 siblings, 0 replies; 8+ messages in thread
From: Wen Congyang @ 2012-10-31  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-mm, linux-doc
  Cc: Rob Landley, Andrew Morton, Yasuaki Ishimatsu, Lai Jiangshan,
	Jiang Liu, KOSAKI Motohiro, Minchan Kim, Mel Gorman,
	David Rientjes, Yinghai Lu, rusty@rustcorp.com.au

From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

memblock_find_in_range_node() does not compare memblock.current_limit
with end variable. Thus even if memblock.current_limit is smaller than
end variable, the function allocates memory address that is bigger than
memblock.current_limit.

The patch adds the check to "memblock_find_in_range_node()"

Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 mm/memblock.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index ee2e307..50ab53c 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -100,11 +100,12 @@ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t start,
 					phys_addr_t align, int nid)
 {
 	phys_addr_t this_start, this_end, cand;
+	phys_addr_t current_limit = memblock.current_limit;
 	u64 i;
 
 	/* pump up @end */
-	if (end == MEMBLOCK_ALLOC_ACCESSIBLE)
-		end = memblock.current_limit;
+	if ((end == MEMBLOCK_ALLOC_ACCESSIBLE) || (end > current_limit))
+		end = current_limit;
 
 	/* avoid allocating the first page */
 	start = max_t(phys_addr_t, start, PAGE_SIZE);
-- 
1.8.0

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PART5 Patch 1/5] page_alloc: add kernelcore_max_addr
  2012-10-31  9:21 ` [PART5 Patch 1/5] page_alloc: add kernelcore_max_addr Wen Congyang
@ 2012-12-19 19:26   ` Randy Dunlap
  2012-12-21  1:54     ` Tang Chen
  0 siblings, 1 reply; 8+ messages in thread
From: Randy Dunlap @ 2012-12-19 19:26 UTC (permalink / raw)
  To: Wen Congyang
  Cc: linux-kernel, linux-mm, linux-doc, Rob Landley, Andrew Morton,
	Yasuaki Ishimatsu, Lai Jiangshan, Jiang Liu, KOSAKI Motohiro,
	Minchan Kim, Mel Gorman, David Rientjes, Yinghai Lu,
	rusty@rustcorp.com.au

On 10/31/12 02:21, Wen Congyang wrote:
> From: Lai Jiangshan <laijs@cn.fujitsu.com>
> 
> 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 <laijs@cn.fujitsu.com>
> ---
>  Documentation/kernel-parameters.txt |  9 +++++++++
>  mm/page_alloc.c                     | 29 ++++++++++++++++++++++++++++-
>  2 files changed, 37 insertions(+), 1 deletion(-)
> 
> 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

			              upper (or maximum)

> +			usable by the kernel for non-movable allocations.
> +			If both kernelcore and kernelcore_max_addr are
> +			specified, this requested's priority is higher than

			specified, this parameter has a higher priority than
			the kernelcore parameter.

> +			kernelcore's.
> +			See the kernelcore parameter.
> +
>  	kgdbdbgp=	[KGDB,HW] kgdb over EHCI usb debug port.
>  			Format: <Controller#>[,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 5b74de6..9c35fe5 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -200,6 +200,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];
> @@ -4715,6 +4716,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_HIGH_MEMORY];
> @@ -4743,6 +4745,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;
> @@ -4751,6 +4756,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;
> @@ -4777,8 +4788,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) {
> @@ -4965,6 +4980,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

                                        upper

> + * 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.
> 


-- 
~Randy

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PART5 Patch 1/5] page_alloc: add kernelcore_max_addr
  2012-12-19 19:26   ` Randy Dunlap
@ 2012-12-21  1:54     ` Tang Chen
  0 siblings, 0 replies; 8+ messages in thread
From: Tang Chen @ 2012-12-21  1:54 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Wen Congyang, linux-kernel, linux-mm, linux-doc, Rob Landley,
	Andrew Morton, Yasuaki Ishimatsu, Lai Jiangshan, Jiang Liu,
	KOSAKI Motohiro, Minchan Kim, Mel Gorman, David Rientjes,
	Yinghai Lu, rusty@rustcorp.com.au

Hi Randy,

Thank you for your reviewing. :)

I think this boot option has been dropped. And we are implementing a new
boot option called "movablecore_map" to replace it.

Please refer to the following url if you like:
https://lkml.org/lkml/2012/12/19/51

Thanks. :)



On 12/20/2012 03:26 AM, Randy Dunlap wrote:
> On 10/31/12 02:21, Wen Congyang wrote:
>> From: Lai Jiangshan<laijs@cn.fujitsu.com>
>>
>> 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<laijs@cn.fujitsu.com>
>> ---
>>   Documentation/kernel-parameters.txt |  9 +++++++++
>>   mm/page_alloc.c                     | 29 ++++++++++++++++++++++++++++-
>>   2 files changed, 37 insertions(+), 1 deletion(-)
>>
>> 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
>
> 			upper (or maximum)
>
>> +			usable by the kernel for non-movable allocations.
>> +			If both kernelcore and kernelcore_max_addr are
>> +			specified, this requested's priority is higher than
>
> 			specified, this parameter has a higher priority than
> 			the kernelcore parameter.
>
>> +			kernelcore's.
>> +			See the kernelcore parameter.
>> +
>>   	kgdbdbgp=	[KGDB,HW] kgdb over EHCI usb debug port.
>>   			Format:<Controller#>[,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 5b74de6..9c35fe5 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -200,6 +200,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];
>> @@ -4715,6 +4716,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_HIGH_MEMORY];
>> @@ -4743,6 +4745,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;
>> @@ -4751,6 +4756,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;
>> @@ -4777,8 +4788,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) {
>> @@ -4965,6 +4980,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
>
>                                          upper
>
>> + * 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.
>>
>
>

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-12-21  1:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-31  9:21 [PART5 Patch 0/5] introduce a new boot option 'kernelcore_max_addr' Wen Congyang
2012-10-31  9:21 ` [PART5 Patch 1/5] page_alloc: add kernelcore_max_addr Wen Congyang
2012-12-19 19:26   ` Randy Dunlap
2012-12-21  1:54     ` Tang Chen
2012-10-31  9:21 ` [PART5 Patch 2/5] x86: get pg_data_t's memory from other node Wen Congyang
2012-10-31  9:21 ` [PART5 Patch 3/5] x86: use memblock_set_current_limit() to set memblock.current_limit Wen Congyang
2012-10-31  9:21 ` [PART5 Patch 4/5] memblock: limit memory address from memblock Wen Congyang
2012-10-31  9:21 ` [PART5 Patch 5/5] memblock: compare current_limit with end variable at memblock_find_in_range_node() Wen Congyang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).