aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/mm/memblock.c
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2010-08-25 16:39:17 -0400
committerH. Peter Anvin <hpa@zytor.com>2010-08-27 14:11:30 -0400
commite82d42be24bd5d75bf6f81045636e6ca95ab55f2 (patch)
treeae35d2fdb08c9ddd500bbde67e462a2f47399a98 /arch/x86/mm/memblock.c
parentb52c17ce854125700c4e19d4427d39bf2504ff63 (diff)
x86, memblock: Add memblock_x86_memory_in_range()
It will return memory size in specified range according to memblock.memory.region Try to share some code with memblock_x86_free_memory_in_range() by passing get_free to __memblock_x86_memory_in_range(). -v2: Ben want _in_range in the name instead of size Signed-off-by: Yinghai Lu <yinghai@kernel.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/mm/memblock.c')
-rw-r--r--arch/x86/mm/memblock.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index 30d60cf29ce3..32ddad5dc932 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -211,7 +211,7 @@ void __init memblock_x86_to_bootmem(u64 start, u64 end)
211} 211}
212#endif 212#endif
213 213
214u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit) 214static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free)
215{ 215{
216 int i, count; 216 int i, count;
217 struct range *range; 217 struct range *range;
@@ -240,6 +240,10 @@ u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit)
240 } 240 }
241 subtract_range(range, count, 0, addr); 241 subtract_range(range, count, 0, addr);
242 subtract_range(range, count, limit, -1ULL); 242 subtract_range(range, count, limit, -1ULL);
243
244 /* Subtract memblock.reserved.region in range ? */
245 if (!get_free)
246 goto sort_and_count_them;
243 for_each_memblock(reserved, r) { 247 for_each_memblock(reserved, r) {
244 final_start = PFN_DOWN(r->base); 248 final_start = PFN_DOWN(r->base);
245 final_end = PFN_UP(r->base + r->size); 249 final_end = PFN_UP(r->base + r->size);
@@ -250,6 +254,8 @@ u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit)
250 254
251 subtract_range(range, count, final_start, final_end); 255 subtract_range(range, count, final_start, final_end);
252 } 256 }
257
258sort_and_count_them:
253 nr_range = clean_sort_range(range, count); 259 nr_range = clean_sort_range(range, count);
254 260
255 free_size = 0; 261 free_size = 0;
@@ -259,6 +265,16 @@ u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit)
259 return free_size << PAGE_SHIFT; 265 return free_size << PAGE_SHIFT;
260} 266}
261 267
268u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit)
269{
270 return __memblock_x86_memory_in_range(addr, limit, true);
271}
272
273u64 __init memblock_x86_memory_in_range(u64 addr, u64 limit)
274{
275 return __memblock_x86_memory_in_range(addr, limit, false);
276}
277
262void __init memblock_x86_reserve_range(u64 start, u64 end, char *name) 278void __init memblock_x86_reserve_range(u64 start, u64 end, char *name)
263{ 279{
264 if (start == end) 280 if (start == end)