[PATCH 33/49] memblock: Add memblock_find_in_range()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Yinghai Lu
Date: Monday, July 19, 2010 - 4:56 pm

it is a wrapper for memblock_find_base

make it more easy for x86 to use memblock. ( rebase )
x86 early_res is using find/reserve pattern instead of alloc.

keep it in weak version, so later We can use x86 own version if needed.
also We need it in mm/memblock.c, so one caller mm/page_alloc.c could get compiled

-v2: Change name to memblock_find_in_range() according to Michael Ellerman
-v3: Add generic weak version __memblock_find_in_range()
     so keep the path for fallback to x86 version that handle from low
-v4: use 0 for failing path
-v5: use MEMBLOCK_ERROR again
-v6: remove __memblock_find_in_range()

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 include/linux/memblock.h |    2 ++
 mm/memblock.c            |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 751a4eb..61b22eb 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -48,6 +48,8 @@ extern struct memblock_region memblock_reserved_init_regions[];
 #define memblock_dbg(fmt, ...) \
 	if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
 
+u64 memblock_find_in_range(u64 start, u64 end, u64 size, u64 align);
+
 extern void __init memblock_init(void);
 extern void __init memblock_analyze(void);
 extern long memblock_add(phys_addr_t base, phys_addr_t size);
diff --git a/mm/memblock.c b/mm/memblock.c
index 7471dac..ca7de91 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -156,6 +156,14 @@ static phys_addr_t __init memblock_find_base(phys_addr_t size, phys_addr_t align
 	return MEMBLOCK_ERROR;
 }
 
+/*
+ * Find a free area with specified alignment in a specific range.
+ */
+u64 __init __weak memblock_find_in_range(u64 start, u64 end, u64 size, u64 align)
+{
+	return memblock_find_base(size, align, start, end);
+}
+
 static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r)
 {
 	unsigned long i;
-- 
1.6.4.2

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH -v25 00/49] Use memblock with x86, Yinghai Lu, (Mon Jul 19, 4:56 pm)
[PATCH 02/49] x86,mm: fix 32bit numa sparsemem, Yinghai Lu, (Mon Jul 19, 4:56 pm)
[PATCH 33/49] memblock: Add memblock_find_in_range(), Yinghai Lu, (Mon Jul 19, 4:56 pm)
[PATCH 40/49] memblock: Add find_memory_core_early(), Yinghai Lu, (Mon Jul 19, 4:56 pm)
[PATCH 45/49] x86: Use memblock to replace early_res, Yinghai Lu, (Mon Jul 19, 4:56 pm)
[PATCH 47/49] x86: Remove not used early_res code, Yinghai Lu, (Mon Jul 19, 4:56 pm)
[PATCH 49/49] x86: remove old bootmem code, Yinghai Lu, (Mon Jul 19, 4:56 pm)
Re: [PATCH -v25 00/49] Use memblock with x86, Linus Torvalds, (Mon Jul 19, 5:14 pm)
Re: [PATCH -v25 00/49] Use memblock with x86, Yinghai Lu, (Mon Jul 19, 5:35 pm)
Re: [PATCH -v25 00/49] Use memblock with x86, H. Peter Anvin, (Tue Jul 20, 11:29 am)