aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTang Chen <tangchen@cn.fujitsu.com>2013-02-22 19:33:42 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-23 20:50:14 -0500
commitfb06bc8e5f42f38c011de0e59481f464a82380f6 (patch)
treeac55622da0b397e57cdb426f634441939187f99d
parent42f47e27e761fee07da69e04612ec7dd0d490edd (diff)
page_alloc: bootmem limit with movablecore_map
Ensure the bootmem will not allocate memory from areas that may be ZONE_MOVABLE. The map info is from movablecore_map boot option. Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com> Reviewed-by: Wen Congyang <wency@cn.fujitsu.com> Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com> Tested-by: Lin Feng <linfeng@cn.fujitsu.com> Cc: Wu Jianguo <wujianguo@huawei.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Ingo Molnar <mingo@elte.hu> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/memblock.h1
-rw-r--r--mm/memblock.c18
2 files changed, 18 insertions, 1 deletions
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index f388203db7e8..dfefaf111c0e 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -42,6 +42,7 @@ struct memblock {
42 42
43extern struct memblock memblock; 43extern struct memblock memblock;
44extern int memblock_debug; 44extern int memblock_debug;
45extern struct movablemem_map movablemem_map;
45 46
46#define memblock_dbg(fmt, ...) \ 47#define memblock_dbg(fmt, ...) \
47 if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) 48 if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
diff --git a/mm/memblock.c b/mm/memblock.c
index b8d9147e5c08..c83ff97f57f4 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -101,6 +101,7 @@ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t start,
101{ 101{
102 phys_addr_t this_start, this_end, cand; 102 phys_addr_t this_start, this_end, cand;
103 u64 i; 103 u64 i;
104 int curr = movablemem_map.nr_map - 1;
104 105
105 /* pump up @end */ 106 /* pump up @end */
106 if (end == MEMBLOCK_ALLOC_ACCESSIBLE) 107 if (end == MEMBLOCK_ALLOC_ACCESSIBLE)
@@ -114,13 +115,28 @@ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t start,
114 this_start = clamp(this_start, start, end); 115 this_start = clamp(this_start, start, end);
115 this_end = clamp(this_end, start, end); 116 this_end = clamp(this_end, start, end);
116 117
117 if (this_end < size) 118restart:
119 if (this_end <= this_start || this_end < size)
118 continue; 120 continue;
119 121
122 for (; curr >= 0; curr--) {
123 if ((movablemem_map.map[curr].start_pfn << PAGE_SHIFT)
124 < this_end)
125 break;
126 }
127
120 cand = round_down(this_end - size, align); 128 cand = round_down(this_end - size, align);
129 if (curr >= 0 &&
130 cand < movablemem_map.map[curr].end_pfn << PAGE_SHIFT) {
131 this_end = movablemem_map.map[curr].start_pfn
132 << PAGE_SHIFT;
133 goto restart;
134 }
135
121 if (cand >= this_start) 136 if (cand >= this_start)
122 return cand; 137 return cand;
123 } 138 }
139
124 return 0; 140 return 0;
125} 141}
126 142