diff options
author | Tejun Heo <tj@kernel.org> | 2011-12-08 13:22:09 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2011-12-08 13:22:09 -0500 |
commit | 7bd0b0f0da3b1ec11cbcc798eb0ef747a1184077 (patch) | |
tree | ef285a020ffc04250b7327f0e9876a5988aa600e /include/linux/memblock.h | |
parent | 0ee332c1451869963626bf9cac88f165a90990e1 (diff) |
memblock: Reimplement memblock allocation using reverse free area iterator
Now that all early memory information is in memblock when enabled, we
can implement reverse free area iterator and use it to implement NUMA
aware allocator which is then wrapped for simpler variants instead of
the confusing and inefficient mending of information in separate NUMA
aware allocator.
Implement for_each_free_mem_range_reverse(), use it to reimplement
memblock_find_in_range_node() which in turn is used by all allocators.
The visible allocator interface is inconsistent and can probably use
some cleanup too.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Diffstat (limited to 'include/linux/memblock.h')
-rw-r--r-- | include/linux/memblock.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/include/linux/memblock.h b/include/linux/memblock.h index cd7606b71e5a..a6bb10235148 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h | |||
@@ -46,6 +46,8 @@ extern int memblock_debug; | |||
46 | #define memblock_dbg(fmt, ...) \ | 46 | #define memblock_dbg(fmt, ...) \ |
47 | if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | 47 | if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) |
48 | 48 | ||
49 | phys_addr_t memblock_find_in_range_node(phys_addr_t start, phys_addr_t end, | ||
50 | phys_addr_t size, phys_addr_t align, int nid); | ||
49 | phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, | 51 | phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, |
50 | phys_addr_t size, phys_addr_t align); | 52 | phys_addr_t size, phys_addr_t align); |
51 | int memblock_free_reserved_regions(void); | 53 | int memblock_free_reserved_regions(void); |
@@ -98,6 +100,26 @@ void __next_free_mem_range(u64 *idx, int nid, phys_addr_t *out_start, | |||
98 | i != (u64)ULLONG_MAX; \ | 100 | i != (u64)ULLONG_MAX; \ |
99 | __next_free_mem_range(&i, nid, p_start, p_end, p_nid)) | 101 | __next_free_mem_range(&i, nid, p_start, p_end, p_nid)) |
100 | 102 | ||
103 | void __next_free_mem_range_rev(u64 *idx, int nid, phys_addr_t *out_start, | ||
104 | phys_addr_t *out_end, int *out_nid); | ||
105 | |||
106 | /** | ||
107 | * for_each_free_mem_range_reverse - rev-iterate through free memblock areas | ||
108 | * @i: u64 used as loop variable | ||
109 | * @nid: node selector, %MAX_NUMNODES for all nodes | ||
110 | * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL | ||
111 | * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL | ||
112 | * @p_nid: ptr to int for nid of the range, can be %NULL | ||
113 | * | ||
114 | * Walks over free (memory && !reserved) areas of memblock in reverse | ||
115 | * order. Available as soon as memblock is initialized. | ||
116 | */ | ||
117 | #define for_each_free_mem_range_reverse(i, nid, p_start, p_end, p_nid) \ | ||
118 | for (i = (u64)ULLONG_MAX, \ | ||
119 | __next_free_mem_range_rev(&i, nid, p_start, p_end, p_nid); \ | ||
120 | i != (u64)ULLONG_MAX; \ | ||
121 | __next_free_mem_range_rev(&i, nid, p_start, p_end, p_nid)) | ||
122 | |||
101 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP | 123 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP |
102 | int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid); | 124 | int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid); |
103 | 125 | ||
@@ -121,8 +143,6 @@ static inline int memblock_get_region_node(const struct memblock_region *r) | |||
121 | } | 143 | } |
122 | #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ | 144 | #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ |
123 | 145 | ||
124 | phys_addr_t memblock_find_in_range_node(phys_addr_t start, phys_addr_t end, | ||
125 | phys_addr_t size, phys_addr_t align, int nid); | ||
126 | phys_addr_t memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid); | 146 | phys_addr_t memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid); |
127 | phys_addr_t memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid); | 147 | phys_addr_t memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid); |
128 | 148 | ||