aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
authorTang Chen <tangchen@cn.fujitsu.com>2013-02-22 19:33:46 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-23 20:50:14 -0500
commit27168d38fa209073219abedbe6a9de7ba9acbfad (patch)
tree6c8ff96722ce02b0c01b2ce4078777712e0df339 /mm/page_alloc.c
parente8d1955258091e4c92d5a975ebd7fd8a98f5d30f (diff)
acpi, memory-hotplug: extend movablemem_map ranges to the end of node
When implementing movablemem_map boot option, we introduced an array movablemem_map.map[] to store the memory ranges to be set as ZONE_MOVABLE. Since ZONE_MOVABLE is the latst zone of a node, if user didn't specify the whole node memory range, we need to extend it to the node end so that we can use it to prevent memblock from allocating memory in the ranges user didn't specify. We now implement movablemem_map boot option like this: /* * For movablemem_map=nn[KMG]@ss[KMG]: * * SRAT: |_____| |_____| |_________| |_________| ...... * node id: 0 1 1 2 * user specified: |__| |___| * movablemem_map: |___| |_________| |______| ...... * * Using movablemem_map, we can prevent memblock from allocating memory * on ZONE_MOVABLE at boot time. * * NOTE: In this case, SRAT info will be ingored. */ [akpm@linux-foundation.org: clean up code, fix build warning] Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Jiang Liu <jiang.liu@huawei.com> Cc: Jianguo Wu <wujianguo@huawei.com> Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: Wu Jianguo <wujianguo@huawei.com> Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Len Brown <lenb@kernel.org> Cc: "Brown, Len" <len.brown@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 88b9962c99b3..7ea9a003ad57 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5176,6 +5176,36 @@ early_param("kernelcore", cmdline_parse_kernelcore);
5176early_param("movablecore", cmdline_parse_movablecore); 5176early_param("movablecore", cmdline_parse_movablecore);
5177 5177
5178/** 5178/**
5179 * movablemem_map_overlap() - Check if a range overlaps movablemem_map.map[].
5180 * @start_pfn: start pfn of the range to be checked
5181 * @end_pfn: end pfn of the range to be checked (exclusive)
5182 *
5183 * This function checks if a given memory range [start_pfn, end_pfn) overlaps
5184 * the movablemem_map.map[] array.
5185 *
5186 * Return: index of the first overlapped element in movablemem_map.map[]
5187 * or -1 if they don't overlap each other.
5188 */
5189int __init movablemem_map_overlap(unsigned long start_pfn,
5190 unsigned long end_pfn)
5191{
5192 int overlap;
5193
5194 if (!movablemem_map.nr_map)
5195 return -1;
5196
5197 for (overlap = 0; overlap < movablemem_map.nr_map; overlap++)
5198 if (start_pfn < movablemem_map.map[overlap].end_pfn)
5199 break;
5200
5201 if (overlap == movablemem_map.nr_map ||
5202 end_pfn <= movablemem_map.map[overlap].start_pfn)
5203 return -1;
5204
5205 return overlap;
5206}
5207
5208/**
5179 * insert_movablemem_map - Insert a memory range in to movablemem_map.map. 5209 * insert_movablemem_map - Insert a memory range in to movablemem_map.map.
5180 * @start_pfn: start pfn of the range 5210 * @start_pfn: start pfn of the range
5181 * @end_pfn: end pfn of the range 5211 * @end_pfn: end pfn of the range
@@ -5183,8 +5213,8 @@ early_param("movablecore", cmdline_parse_movablecore);
5183 * This function will also merge the overlapped ranges, and sort the array 5213 * This function will also merge the overlapped ranges, and sort the array
5184 * by start_pfn in monotonic increasing order. 5214 * by start_pfn in monotonic increasing order.
5185 */ 5215 */
5186static void __init insert_movablemem_map(unsigned long start_pfn, 5216void __init insert_movablemem_map(unsigned long start_pfn,
5187 unsigned long end_pfn) 5217 unsigned long end_pfn)
5188{ 5218{
5189 int pos, overlap; 5219 int pos, overlap;
5190 5220