Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 2 | #ifndef _LINUX_MEMBLOCK_H |
| 3 | #define _LINUX_MEMBLOCK_H |
| 4 | #ifdef __KERNEL__ |
| 5 | |
| 6 | /* |
| 7 | * Logical memory blocks. |
| 8 | * |
| 9 | * Copyright (C) 2001 Peter Bergner, IBM Corp. |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/mm.h> |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 14 | #include <asm/dma.h> |
| 15 | |
| 16 | extern unsigned long max_low_pfn; |
| 17 | extern unsigned long min_low_pfn; |
| 18 | |
| 19 | /* |
| 20 | * highest page |
| 21 | */ |
| 22 | extern unsigned long max_pfn; |
| 23 | /* |
| 24 | * highest possible page |
| 25 | */ |
| 26 | extern unsigned long long max_possible_pfn; |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 27 | |
Mike Rapoport | 9a0de1b | 2018-06-30 17:55:04 +0300 | [diff] [blame] | 28 | /** |
| 29 | * enum memblock_flags - definition of memory region attributes |
| 30 | * @MEMBLOCK_NONE: no special request |
| 31 | * @MEMBLOCK_HOTPLUG: hotpluggable region |
| 32 | * @MEMBLOCK_MIRROR: mirrored region |
| 33 | * @MEMBLOCK_NOMAP: don't add to kernel direct mapping |
| 34 | */ |
Mike Rapoport | e1720fe | 2018-06-30 17:55:01 +0300 | [diff] [blame] | 35 | enum memblock_flags { |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 36 | MEMBLOCK_NONE = 0x0, /* No special request */ |
| 37 | MEMBLOCK_HOTPLUG = 0x1, /* hotpluggable region */ |
Tony Luck | a3f5baf | 2015-06-24 16:58:12 -0700 | [diff] [blame] | 38 | MEMBLOCK_MIRROR = 0x2, /* mirrored region */ |
Ard Biesheuvel | bf3d3cc | 2015-11-30 13:28:15 +0100 | [diff] [blame] | 39 | MEMBLOCK_NOMAP = 0x4, /* don't add to kernel direct mapping */ |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 40 | }; |
Tang Chen | 66b16ed | 2014-01-21 15:49:23 -0800 | [diff] [blame] | 41 | |
Mike Rapoport | 9a0de1b | 2018-06-30 17:55:04 +0300 | [diff] [blame] | 42 | /** |
| 43 | * struct memblock_region - represents a memory region |
| 44 | * @base: physical address of the region |
| 45 | * @size: size of the region |
| 46 | * @flags: memory region attributes |
| 47 | * @nid: NUMA node id |
| 48 | */ |
Benjamin Herrenschmidt | e3239ff | 2010-08-04 14:06:41 +1000 | [diff] [blame] | 49 | struct memblock_region { |
Benjamin Herrenschmidt | 2898cc4 | 2010-08-04 13:34:42 +1000 | [diff] [blame] | 50 | phys_addr_t base; |
| 51 | phys_addr_t size; |
Mike Rapoport | e1720fe | 2018-06-30 17:55:01 +0300 | [diff] [blame] | 52 | enum memblock_flags flags; |
Tejun Heo | 7c0caeb | 2011-07-14 11:43:42 +0200 | [diff] [blame] | 53 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP |
| 54 | int nid; |
| 55 | #endif |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 56 | }; |
| 57 | |
Mike Rapoport | 9a0de1b | 2018-06-30 17:55:04 +0300 | [diff] [blame] | 58 | /** |
| 59 | * struct memblock_type - collection of memory regions of certain type |
| 60 | * @cnt: number of regions |
| 61 | * @max: size of the allocated array |
| 62 | * @total_size: size of all regions |
| 63 | * @regions: array of regions |
| 64 | * @name: the memory type symbolic name |
| 65 | */ |
Benjamin Herrenschmidt | e3239ff | 2010-08-04 14:06:41 +1000 | [diff] [blame] | 66 | struct memblock_type { |
Mike Rapoport | 9a0de1b | 2018-06-30 17:55:04 +0300 | [diff] [blame] | 67 | unsigned long cnt; |
| 68 | unsigned long max; |
| 69 | phys_addr_t total_size; |
Benjamin Herrenschmidt | bf23c51 | 2010-07-06 15:39:06 -0700 | [diff] [blame] | 70 | struct memblock_region *regions; |
Heiko Carstens | 0262d9c | 2017-02-24 14:55:59 -0800 | [diff] [blame] | 71 | char *name; |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 72 | }; |
| 73 | |
Mike Rapoport | 9a0de1b | 2018-06-30 17:55:04 +0300 | [diff] [blame] | 74 | /** |
| 75 | * struct memblock - memblock allocator metadata |
| 76 | * @bottom_up: is bottom up direction? |
| 77 | * @current_limit: physical address of the current allocation limit |
| 78 | * @memory: usabe memory regions |
| 79 | * @reserved: reserved memory regions |
| 80 | * @physmem: all physical memory |
| 81 | */ |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 82 | struct memblock { |
Tang Chen | 79442ed | 2013-11-12 15:07:59 -0800 | [diff] [blame] | 83 | bool bottom_up; /* is bottom up direction? */ |
Benjamin Herrenschmidt | 2898cc4 | 2010-08-04 13:34:42 +1000 | [diff] [blame] | 84 | phys_addr_t current_limit; |
Benjamin Herrenschmidt | e3239ff | 2010-08-04 14:06:41 +1000 | [diff] [blame] | 85 | struct memblock_type memory; |
| 86 | struct memblock_type reserved; |
Philipp Hachtmann | 70210ed | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 87 | #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP |
| 88 | struct memblock_type physmem; |
| 89 | #endif |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | extern struct memblock memblock; |
Yinghai Lu | 5e63cf4 | 2010-07-28 15:07:21 +1000 | [diff] [blame] | 93 | extern int memblock_debug; |
Yinghai Lu | 5e63cf4 | 2010-07-28 15:07:21 +1000 | [diff] [blame] | 94 | |
Mike Rapoport | 350e88b | 2019-05-13 17:22:59 -0700 | [diff] [blame] | 95 | #ifndef CONFIG_ARCH_KEEP_MEMBLOCK |
Kirill A. Shutemov | 036fbb2 | 2016-01-15 16:57:11 -0800 | [diff] [blame] | 96 | #define __init_memblock __meminit |
| 97 | #define __initdata_memblock __meminitdata |
Pavel Tatashin | 3010f87 | 2017-08-18 15:16:05 -0700 | [diff] [blame] | 98 | void memblock_discard(void); |
Kirill A. Shutemov | 036fbb2 | 2016-01-15 16:57:11 -0800 | [diff] [blame] | 99 | #else |
| 100 | #define __init_memblock |
| 101 | #define __initdata_memblock |
Mike Rapoport | 350e88b | 2019-05-13 17:22:59 -0700 | [diff] [blame] | 102 | static inline void memblock_discard(void) {} |
Kirill A. Shutemov | 036fbb2 | 2016-01-15 16:57:11 -0800 | [diff] [blame] | 103 | #endif |
| 104 | |
Yinghai Lu | 5e63cf4 | 2010-07-28 15:07:21 +1000 | [diff] [blame] | 105 | #define memblock_dbg(fmt, ...) \ |
| 106 | if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 107 | |
Tejun Heo | fc769a8 | 2011-07-12 09:58:10 +0200 | [diff] [blame] | 108 | phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, |
| 109 | phys_addr_t size, phys_addr_t align); |
Tejun Heo | 1aadc05 | 2011-12-08 10:22:08 -0800 | [diff] [blame] | 110 | void memblock_allow_resize(void); |
Tejun Heo | 7fb0bc3 | 2011-12-08 10:22:08 -0800 | [diff] [blame] | 111 | int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid); |
Tejun Heo | 581adcb | 2011-12-08 10:22:06 -0800 | [diff] [blame] | 112 | int memblock_add(phys_addr_t base, phys_addr_t size); |
| 113 | int memblock_remove(phys_addr_t base, phys_addr_t size); |
| 114 | int memblock_free(phys_addr_t base, phys_addr_t size); |
| 115 | int memblock_reserve(phys_addr_t base, phys_addr_t size); |
Anshuman Khandual | 02634a4 | 2020-01-30 22:14:20 -0800 | [diff] [blame] | 116 | #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP |
| 117 | int memblock_physmem_add(phys_addr_t base, phys_addr_t size); |
| 118 | #endif |
Yinghai Lu | 6ede1fd | 2012-10-22 16:35:18 -0700 | [diff] [blame] | 119 | void memblock_trim_memory(phys_addr_t align); |
Tang Chen | 95cf82e | 2015-09-08 15:02:03 -0700 | [diff] [blame] | 120 | bool memblock_overlaps_region(struct memblock_type *type, |
| 121 | phys_addr_t base, phys_addr_t size); |
Tang Chen | 66b16ed | 2014-01-21 15:49:23 -0800 | [diff] [blame] | 122 | int memblock_mark_hotplug(phys_addr_t base, phys_addr_t size); |
| 123 | int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size); |
Tony Luck | a3f5baf | 2015-06-24 16:58:12 -0700 | [diff] [blame] | 124 | int memblock_mark_mirror(phys_addr_t base, phys_addr_t size); |
Ard Biesheuvel | bf3d3cc | 2015-11-30 13:28:15 +0100 | [diff] [blame] | 125 | int memblock_mark_nomap(phys_addr_t base, phys_addr_t size); |
AKASHI Takahiro | 4c546b8 | 2017-04-03 11:23:54 +0900 | [diff] [blame] | 126 | int memblock_clear_nomap(phys_addr_t base, phys_addr_t size); |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 127 | |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 128 | unsigned long memblock_free_all(void); |
| 129 | void reset_node_managed_pages(pg_data_t *pgdat); |
| 130 | void reset_all_zones_managed_pages(void); |
| 131 | |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 132 | /* Low level functions */ |
Mike Rapoport | e1720fe | 2018-06-30 17:55:01 +0300 | [diff] [blame] | 133 | void __next_mem_range(u64 *idx, int nid, enum memblock_flags flags, |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 134 | struct memblock_type *type_a, |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 135 | struct memblock_type *type_b, phys_addr_t *out_start, |
| 136 | phys_addr_t *out_end, int *out_nid); |
| 137 | |
Mike Rapoport | e1720fe | 2018-06-30 17:55:01 +0300 | [diff] [blame] | 138 | void __next_mem_range_rev(u64 *idx, int nid, enum memblock_flags flags, |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 139 | struct memblock_type *type_a, |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 140 | struct memblock_type *type_b, phys_addr_t *out_start, |
| 141 | phys_addr_t *out_end, int *out_nid); |
| 142 | |
Robin Holt | 8e7a7f8 | 2015-06-30 14:56:41 -0700 | [diff] [blame] | 143 | void __next_reserved_mem_region(u64 *idx, phys_addr_t *out_start, |
Chen Gang | ba6c19f | 2016-07-26 15:24:47 -0700 | [diff] [blame] | 144 | phys_addr_t *out_end); |
Robin Holt | 8e7a7f8 | 2015-06-30 14:56:41 -0700 | [diff] [blame] | 145 | |
Pavel Tatashin | 3010f87 | 2017-08-18 15:16:05 -0700 | [diff] [blame] | 146 | void __memblock_free_late(phys_addr_t base, phys_addr_t size); |
| 147 | |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 148 | /** |
| 149 | * for_each_mem_range - iterate through memblock areas from type_a and not |
| 150 | * included in type_b. Or just type_a if type_b is NULL. |
| 151 | * @i: u64 used as loop variable |
| 152 | * @type_a: ptr to memblock_type to iterate |
| 153 | * @type_b: ptr to memblock_type which excludes from the iteration |
| 154 | * @nid: node selector, %NUMA_NO_NODE for all nodes |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 155 | * @flags: pick from blocks based on memory attributes |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 156 | * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL |
| 157 | * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL |
| 158 | * @p_nid: ptr to int for nid of the range, can be %NULL |
| 159 | */ |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 160 | #define for_each_mem_range(i, type_a, type_b, nid, flags, \ |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 161 | p_start, p_end, p_nid) \ |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 162 | for (i = 0, __next_mem_range(&i, nid, flags, type_a, type_b, \ |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 163 | p_start, p_end, p_nid); \ |
| 164 | i != (u64)ULLONG_MAX; \ |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 165 | __next_mem_range(&i, nid, flags, type_a, type_b, \ |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 166 | p_start, p_end, p_nid)) |
| 167 | |
| 168 | /** |
| 169 | * for_each_mem_range_rev - reverse iterate through memblock areas from |
| 170 | * type_a and not included in type_b. Or just type_a if type_b is NULL. |
| 171 | * @i: u64 used as loop variable |
| 172 | * @type_a: ptr to memblock_type to iterate |
| 173 | * @type_b: ptr to memblock_type which excludes from the iteration |
| 174 | * @nid: node selector, %NUMA_NO_NODE for all nodes |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 175 | * @flags: pick from blocks based on memory attributes |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 176 | * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL |
| 177 | * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL |
| 178 | * @p_nid: ptr to int for nid of the range, can be %NULL |
| 179 | */ |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 180 | #define for_each_mem_range_rev(i, type_a, type_b, nid, flags, \ |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 181 | p_start, p_end, p_nid) \ |
| 182 | for (i = (u64)ULLONG_MAX, \ |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 183 | __next_mem_range_rev(&i, nid, flags, type_a, type_b,\ |
Chen Gang | ba6c19f | 2016-07-26 15:24:47 -0700 | [diff] [blame] | 184 | p_start, p_end, p_nid); \ |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 185 | i != (u64)ULLONG_MAX; \ |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 186 | __next_mem_range_rev(&i, nid, flags, type_a, type_b, \ |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 187 | p_start, p_end, p_nid)) |
| 188 | |
Robin Holt | 8e7a7f8 | 2015-06-30 14:56:41 -0700 | [diff] [blame] | 189 | /** |
| 190 | * for_each_reserved_mem_region - iterate over all reserved memblock areas |
| 191 | * @i: u64 used as loop variable |
| 192 | * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL |
| 193 | * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL |
| 194 | * |
| 195 | * Walks over reserved areas of memblock. Available as soon as memblock |
| 196 | * is initialized. |
| 197 | */ |
| 198 | #define for_each_reserved_mem_region(i, p_start, p_end) \ |
Chen Gang | ba6c19f | 2016-07-26 15:24:47 -0700 | [diff] [blame] | 199 | for (i = 0UL, __next_reserved_mem_region(&i, p_start, p_end); \ |
Robin Holt | 8e7a7f8 | 2015-06-30 14:56:41 -0700 | [diff] [blame] | 200 | i != (u64)ULLONG_MAX; \ |
| 201 | __next_reserved_mem_region(&i, p_start, p_end)) |
| 202 | |
Tang Chen | 55ac590 | 2014-01-21 15:49:35 -0800 | [diff] [blame] | 203 | static inline bool memblock_is_hotpluggable(struct memblock_region *m) |
| 204 | { |
| 205 | return m->flags & MEMBLOCK_HOTPLUG; |
| 206 | } |
| 207 | |
Tony Luck | a3f5baf | 2015-06-24 16:58:12 -0700 | [diff] [blame] | 208 | static inline bool memblock_is_mirror(struct memblock_region *m) |
| 209 | { |
| 210 | return m->flags & MEMBLOCK_MIRROR; |
| 211 | } |
| 212 | |
Ard Biesheuvel | bf3d3cc | 2015-11-30 13:28:15 +0100 | [diff] [blame] | 213 | static inline bool memblock_is_nomap(struct memblock_region *m) |
| 214 | { |
| 215 | return m->flags & MEMBLOCK_NOMAP; |
| 216 | } |
| 217 | |
Tejun Heo | 0ee332c | 2011-12-08 10:22:09 -0800 | [diff] [blame] | 218 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP |
Yinghai Lu | e76b63f | 2013-09-11 14:22:17 -0700 | [diff] [blame] | 219 | int memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn, |
| 220 | unsigned long *end_pfn); |
Tejun Heo | 0ee332c | 2011-12-08 10:22:09 -0800 | [diff] [blame] | 221 | void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, |
| 222 | unsigned long *out_end_pfn, int *out_nid); |
| 223 | |
| 224 | /** |
| 225 | * for_each_mem_pfn_range - early memory pfn range iterator |
| 226 | * @i: an integer used as loop variable |
| 227 | * @nid: node selector, %MAX_NUMNODES for all nodes |
| 228 | * @p_start: ptr to ulong for start pfn of the range, can be %NULL |
| 229 | * @p_end: ptr to ulong for end pfn of the range, can be %NULL |
| 230 | * @p_nid: ptr to int for nid of the range, can be %NULL |
| 231 | * |
Wanpeng Li | f2d52fe | 2012-10-08 16:32:24 -0700 | [diff] [blame] | 232 | * Walks over configured memory ranges. |
Tejun Heo | 0ee332c | 2011-12-08 10:22:09 -0800 | [diff] [blame] | 233 | */ |
| 234 | #define for_each_mem_pfn_range(i, nid, p_start, p_end, p_nid) \ |
| 235 | for (i = -1, __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid); \ |
| 236 | i >= 0; __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid)) |
| 237 | #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ |
| 238 | |
Alexander Duyck | 837566e | 2019-05-13 17:21:17 -0700 | [diff] [blame] | 239 | #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT |
| 240 | void __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone, |
| 241 | unsigned long *out_spfn, |
| 242 | unsigned long *out_epfn); |
| 243 | /** |
| 244 | * for_each_free_mem_range_in_zone - iterate through zone specific free |
| 245 | * memblock areas |
| 246 | * @i: u64 used as loop variable |
| 247 | * @zone: zone in which all of the memory blocks reside |
| 248 | * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL |
| 249 | * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL |
| 250 | * |
| 251 | * Walks over free (memory && !reserved) areas of memblock in a specific |
| 252 | * zone. Available once memblock and an empty zone is initialized. The main |
| 253 | * assumption is that the zone start, end, and pgdat have been associated. |
| 254 | * This way we can use the zone to determine NUMA node, and if a given part |
| 255 | * of the memblock is valid for the zone. |
| 256 | */ |
| 257 | #define for_each_free_mem_pfn_range_in_zone(i, zone, p_start, p_end) \ |
| 258 | for (i = 0, \ |
| 259 | __next_mem_pfn_range_in_zone(&i, zone, p_start, p_end); \ |
| 260 | i != U64_MAX; \ |
| 261 | __next_mem_pfn_range_in_zone(&i, zone, p_start, p_end)) |
Alexander Duyck | 0e56aca | 2019-05-13 17:21:20 -0700 | [diff] [blame] | 262 | |
| 263 | /** |
| 264 | * for_each_free_mem_range_in_zone_from - iterate through zone specific |
| 265 | * free memblock areas from a given point |
| 266 | * @i: u64 used as loop variable |
| 267 | * @zone: zone in which all of the memory blocks reside |
| 268 | * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL |
| 269 | * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL |
| 270 | * |
| 271 | * Walks over free (memory && !reserved) areas of memblock in a specific |
| 272 | * zone, continuing from current position. Available as soon as memblock is |
| 273 | * initialized. |
| 274 | */ |
| 275 | #define for_each_free_mem_pfn_range_in_zone_from(i, zone, p_start, p_end) \ |
| 276 | for (; i != U64_MAX; \ |
| 277 | __next_mem_pfn_range_in_zone(&i, zone, p_start, p_end)) |
Alexander Duyck | 837566e | 2019-05-13 17:21:17 -0700 | [diff] [blame] | 278 | #endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */ |
| 279 | |
Tejun Heo | 35fd080 | 2011-07-12 11:15:59 +0200 | [diff] [blame] | 280 | /** |
| 281 | * for_each_free_mem_range - iterate through free memblock areas |
| 282 | * @i: u64 used as loop variable |
Grygorii Strashko | b115423 | 2014-01-21 15:50:16 -0800 | [diff] [blame] | 283 | * @nid: node selector, %NUMA_NO_NODE for all nodes |
Florian Fainelli | d30b554 | 2016-01-14 15:22:04 -0800 | [diff] [blame] | 284 | * @flags: pick from blocks based on memory attributes |
Tejun Heo | 35fd080 | 2011-07-12 11:15:59 +0200 | [diff] [blame] | 285 | * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL |
| 286 | * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL |
| 287 | * @p_nid: ptr to int for nid of the range, can be %NULL |
| 288 | * |
| 289 | * Walks over free (memory && !reserved) areas of memblock. Available as |
| 290 | * soon as memblock is initialized. |
| 291 | */ |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 292 | #define for_each_free_mem_range(i, nid, flags, p_start, p_end, p_nid) \ |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 293 | for_each_mem_range(i, &memblock.memory, &memblock.reserved, \ |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 294 | nid, flags, p_start, p_end, p_nid) |
Tejun Heo | 7bd0b0f | 2011-12-08 10:22:09 -0800 | [diff] [blame] | 295 | |
| 296 | /** |
| 297 | * for_each_free_mem_range_reverse - rev-iterate through free memblock areas |
| 298 | * @i: u64 used as loop variable |
Grygorii Strashko | b115423 | 2014-01-21 15:50:16 -0800 | [diff] [blame] | 299 | * @nid: node selector, %NUMA_NO_NODE for all nodes |
Florian Fainelli | d30b554 | 2016-01-14 15:22:04 -0800 | [diff] [blame] | 300 | * @flags: pick from blocks based on memory attributes |
Tejun Heo | 7bd0b0f | 2011-12-08 10:22:09 -0800 | [diff] [blame] | 301 | * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL |
| 302 | * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL |
| 303 | * @p_nid: ptr to int for nid of the range, can be %NULL |
| 304 | * |
| 305 | * Walks over free (memory && !reserved) areas of memblock in reverse |
| 306 | * order. Available as soon as memblock is initialized. |
| 307 | */ |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 308 | #define for_each_free_mem_range_reverse(i, nid, flags, p_start, p_end, \ |
| 309 | p_nid) \ |
Philipp Hachtmann | f1af9d3 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 310 | for_each_mem_range_rev(i, &memblock.memory, &memblock.reserved, \ |
Tony Luck | fc6daaf | 2015-06-24 16:58:09 -0700 | [diff] [blame] | 311 | nid, flags, p_start, p_end, p_nid) |
Tejun Heo | 7bd0b0f | 2011-12-08 10:22:09 -0800 | [diff] [blame] | 312 | |
Tejun Heo | 7c0caeb | 2011-07-14 11:43:42 +0200 | [diff] [blame] | 313 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP |
Tang Chen | e7e8de5 | 2014-01-21 15:49:26 -0800 | [diff] [blame] | 314 | int memblock_set_node(phys_addr_t base, phys_addr_t size, |
| 315 | struct memblock_type *type, int nid); |
Tejun Heo | 7c0caeb | 2011-07-14 11:43:42 +0200 | [diff] [blame] | 316 | |
| 317 | static inline void memblock_set_region_node(struct memblock_region *r, int nid) |
| 318 | { |
| 319 | r->nid = nid; |
| 320 | } |
| 321 | |
| 322 | static inline int memblock_get_region_node(const struct memblock_region *r) |
| 323 | { |
| 324 | return r->nid; |
| 325 | } |
| 326 | #else |
| 327 | static inline void memblock_set_region_node(struct memblock_region *r, int nid) |
| 328 | { |
| 329 | } |
| 330 | |
| 331 | static inline int memblock_get_region_node(const struct memblock_region *r) |
| 332 | { |
| 333 | return 0; |
| 334 | } |
| 335 | #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ |
| 336 | |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 337 | /* Flags for memblock allocation APIs */ |
| 338 | #define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0) |
| 339 | #define MEMBLOCK_ALLOC_ACCESSIBLE 0 |
Qian Cai | fed84c7 | 2018-12-28 00:36:29 -0800 | [diff] [blame] | 340 | #define MEMBLOCK_ALLOC_KASAN 1 |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 341 | |
| 342 | /* We are using top down, so it is safe to use 0 here */ |
| 343 | #define MEMBLOCK_LOW_LIMIT 0 |
| 344 | |
| 345 | #ifndef ARCH_LOW_ADDRESS_LIMIT |
| 346 | #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL |
| 347 | #endif |
| 348 | |
Mike Rapoport | 8a770c2 | 2019-03-11 23:29:16 -0700 | [diff] [blame] | 349 | phys_addr_t memblock_phys_alloc_range(phys_addr_t size, phys_addr_t align, |
| 350 | phys_addr_t start, phys_addr_t end); |
Mike Rapoport | 9a8dd70 | 2018-10-30 15:07:59 -0700 | [diff] [blame] | 351 | phys_addr_t memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid); |
Benjamin Herrenschmidt | 9d1e249 | 2010-07-06 15:39:17 -0700 | [diff] [blame] | 352 | |
Mike Rapoport | ecc3e77 | 2019-03-11 23:29:26 -0700 | [diff] [blame] | 353 | static inline phys_addr_t memblock_phys_alloc(phys_addr_t size, |
| 354 | phys_addr_t align) |
| 355 | { |
| 356 | return memblock_phys_alloc_range(size, align, 0, |
| 357 | MEMBLOCK_ALLOC_ACCESSIBLE); |
| 358 | } |
Benjamin Herrenschmidt | e63075a | 2010-07-06 15:39:01 -0700 | [diff] [blame] | 359 | |
Yunfeng Ye | 0ac398b | 2019-11-30 17:56:27 -0800 | [diff] [blame] | 360 | void *memblock_alloc_exact_nid_raw(phys_addr_t size, phys_addr_t align, |
| 361 | phys_addr_t min_addr, phys_addr_t max_addr, |
| 362 | int nid); |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 363 | void *memblock_alloc_try_nid_raw(phys_addr_t size, phys_addr_t align, |
| 364 | phys_addr_t min_addr, phys_addr_t max_addr, |
| 365 | int nid); |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 366 | void *memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, |
| 367 | phys_addr_t min_addr, phys_addr_t max_addr, |
| 368 | int nid); |
| 369 | |
| 370 | static inline void * __init memblock_alloc(phys_addr_t size, phys_addr_t align) |
| 371 | { |
| 372 | return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT, |
| 373 | MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE); |
| 374 | } |
| 375 | |
| 376 | static inline void * __init memblock_alloc_raw(phys_addr_t size, |
| 377 | phys_addr_t align) |
| 378 | { |
| 379 | return memblock_alloc_try_nid_raw(size, align, MEMBLOCK_LOW_LIMIT, |
| 380 | MEMBLOCK_ALLOC_ACCESSIBLE, |
| 381 | NUMA_NO_NODE); |
| 382 | } |
| 383 | |
| 384 | static inline void * __init memblock_alloc_from(phys_addr_t size, |
| 385 | phys_addr_t align, |
| 386 | phys_addr_t min_addr) |
| 387 | { |
| 388 | return memblock_alloc_try_nid(size, align, min_addr, |
| 389 | MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE); |
| 390 | } |
| 391 | |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 392 | static inline void * __init memblock_alloc_low(phys_addr_t size, |
| 393 | phys_addr_t align) |
| 394 | { |
| 395 | return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT, |
| 396 | ARCH_LOW_ADDRESS_LIMIT, NUMA_NO_NODE); |
| 397 | } |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 398 | |
| 399 | static inline void * __init memblock_alloc_node(phys_addr_t size, |
| 400 | phys_addr_t align, int nid) |
| 401 | { |
| 402 | return memblock_alloc_try_nid(size, align, MEMBLOCK_LOW_LIMIT, |
| 403 | MEMBLOCK_ALLOC_ACCESSIBLE, nid); |
| 404 | } |
| 405 | |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 406 | static inline void __init memblock_free_early(phys_addr_t base, |
| 407 | phys_addr_t size) |
| 408 | { |
Mike Rapoport | 4d72868 | 2018-12-28 00:35:29 -0800 | [diff] [blame] | 409 | memblock_free(base, size); |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | static inline void __init memblock_free_early_nid(phys_addr_t base, |
| 413 | phys_addr_t size, int nid) |
| 414 | { |
Mike Rapoport | 4d72868 | 2018-12-28 00:35:29 -0800 | [diff] [blame] | 415 | memblock_free(base, size); |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | static inline void __init memblock_free_late(phys_addr_t base, phys_addr_t size) |
| 419 | { |
| 420 | __memblock_free_late(base, size); |
| 421 | } |
| 422 | |
Tang Chen | 79442ed | 2013-11-12 15:07:59 -0800 | [diff] [blame] | 423 | /* |
| 424 | * Set the allocation direction to bottom-up or top-down. |
| 425 | */ |
Fabian Frederick | 2cfb366 | 2014-08-06 16:05:03 -0700 | [diff] [blame] | 426 | static inline void __init memblock_set_bottom_up(bool enable) |
Tang Chen | 79442ed | 2013-11-12 15:07:59 -0800 | [diff] [blame] | 427 | { |
| 428 | memblock.bottom_up = enable; |
| 429 | } |
| 430 | |
| 431 | /* |
| 432 | * Check if the allocation direction is bottom-up or not. |
| 433 | * if this is true, that said, memblock will allocate memory |
| 434 | * in bottom-up direction. |
| 435 | */ |
| 436 | static inline bool memblock_bottom_up(void) |
| 437 | { |
| 438 | return memblock.bottom_up; |
| 439 | } |
Tang Chen | 79442ed | 2013-11-12 15:07:59 -0800 | [diff] [blame] | 440 | |
Tejun Heo | 581adcb | 2011-12-08 10:22:06 -0800 | [diff] [blame] | 441 | phys_addr_t memblock_phys_mem_size(void); |
Srikar Dronamraju | 8907de5 | 2016-10-07 16:59:18 -0700 | [diff] [blame] | 442 | phys_addr_t memblock_reserved_size(void); |
Yinghai Lu | 595ad9a | 2013-01-24 12:20:09 -0800 | [diff] [blame] | 443 | phys_addr_t memblock_mem_size(unsigned long limit_pfn); |
Tejun Heo | 581adcb | 2011-12-08 10:22:06 -0800 | [diff] [blame] | 444 | phys_addr_t memblock_start_of_DRAM(void); |
| 445 | phys_addr_t memblock_end_of_DRAM(void); |
| 446 | void memblock_enforce_memory_limit(phys_addr_t memory_limit); |
AKASHI Takahiro | c9ca9b4 | 2017-04-03 11:23:55 +0900 | [diff] [blame] | 447 | void memblock_cap_memory_range(phys_addr_t base, phys_addr_t size); |
Dennis Chen | a571d4e | 2016-07-28 15:48:26 -0700 | [diff] [blame] | 448 | void memblock_mem_limit_remove_map(phys_addr_t limit); |
Yaowei Bai | b4ad0c7 | 2016-01-14 15:18:54 -0800 | [diff] [blame] | 449 | bool memblock_is_memory(phys_addr_t addr); |
Yaowei Bai | 937f0c2 | 2018-02-06 15:41:18 -0800 | [diff] [blame] | 450 | bool memblock_is_map_memory(phys_addr_t addr); |
| 451 | bool memblock_is_region_memory(phys_addr_t base, phys_addr_t size); |
Yaowei Bai | b4ad0c7 | 2016-01-14 15:18:54 -0800 | [diff] [blame] | 452 | bool memblock_is_reserved(phys_addr_t addr); |
Tang Chen | c5c5c9d | 2015-09-08 15:02:00 -0700 | [diff] [blame] | 453 | bool memblock_is_region_reserved(phys_addr_t base, phys_addr_t size); |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 454 | |
Tejun Heo | 4ff7b82 | 2011-12-08 10:22:06 -0800 | [diff] [blame] | 455 | extern void __memblock_dump_all(void); |
| 456 | |
| 457 | static inline void memblock_dump_all(void) |
| 458 | { |
| 459 | if (memblock_debug) |
| 460 | __memblock_dump_all(); |
| 461 | } |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 462 | |
Benjamin Herrenschmidt | e63075a | 2010-07-06 15:39:01 -0700 | [diff] [blame] | 463 | /** |
| 464 | * memblock_set_current_limit - Set the current allocation limit to allow |
| 465 | * limiting allocations to what is currently |
| 466 | * accessible during boot |
| 467 | * @limit: New limit value (physical address) |
| 468 | */ |
Tejun Heo | 581adcb | 2011-12-08 10:22:06 -0800 | [diff] [blame] | 469 | void memblock_set_current_limit(phys_addr_t limit); |
Benjamin Herrenschmidt | e63075a | 2010-07-06 15:39:01 -0700 | [diff] [blame] | 470 | |
Benjamin Herrenschmidt | 35a1f0b | 2010-07-06 15:38:58 -0700 | [diff] [blame] | 471 | |
Laura Abbott | fec5101 | 2014-02-27 01:23:43 +0100 | [diff] [blame] | 472 | phys_addr_t memblock_get_current_limit(void); |
| 473 | |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 474 | /* |
| 475 | * pfn conversion functions |
| 476 | * |
| 477 | * While the memory MEMBLOCKs should always be page aligned, the reserved |
| 478 | * MEMBLOCKs may not be. This accessor attempt to provide a very clear |
| 479 | * idea of what they return for such non aligned MEMBLOCKs. |
| 480 | */ |
| 481 | |
| 482 | /** |
Mike Rapoport | 47cec44 | 2018-06-30 17:55:02 +0300 | [diff] [blame] | 483 | * memblock_region_memory_base_pfn - get the lowest pfn of the memory region |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 484 | * @reg: memblock_region structure |
Mike Rapoport | 47cec44 | 2018-06-30 17:55:02 +0300 | [diff] [blame] | 485 | * |
| 486 | * Return: the lowest pfn intersecting with the memory region |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 487 | */ |
Yinghai Lu | c7fc2de | 2010-10-12 14:07:09 -0700 | [diff] [blame] | 488 | static inline unsigned long memblock_region_memory_base_pfn(const struct memblock_region *reg) |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 489 | { |
Yinghai Lu | c7fc2de | 2010-10-12 14:07:09 -0700 | [diff] [blame] | 490 | return PFN_UP(reg->base); |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | /** |
Mike Rapoport | 47cec44 | 2018-06-30 17:55:02 +0300 | [diff] [blame] | 494 | * memblock_region_memory_end_pfn - get the end pfn of the memory region |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 495 | * @reg: memblock_region structure |
Mike Rapoport | 47cec44 | 2018-06-30 17:55:02 +0300 | [diff] [blame] | 496 | * |
| 497 | * Return: the end_pfn of the reserved region |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 498 | */ |
Yinghai Lu | c7fc2de | 2010-10-12 14:07:09 -0700 | [diff] [blame] | 499 | static inline unsigned long memblock_region_memory_end_pfn(const struct memblock_region *reg) |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 500 | { |
Yinghai Lu | c7fc2de | 2010-10-12 14:07:09 -0700 | [diff] [blame] | 501 | return PFN_DOWN(reg->base + reg->size); |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 502 | } |
| 503 | |
| 504 | /** |
Mike Rapoport | 47cec44 | 2018-06-30 17:55:02 +0300 | [diff] [blame] | 505 | * memblock_region_reserved_base_pfn - get the lowest pfn of the reserved region |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 506 | * @reg: memblock_region structure |
Mike Rapoport | 47cec44 | 2018-06-30 17:55:02 +0300 | [diff] [blame] | 507 | * |
| 508 | * Return: the lowest pfn intersecting with the reserved region |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 509 | */ |
Yinghai Lu | c7fc2de | 2010-10-12 14:07:09 -0700 | [diff] [blame] | 510 | static inline unsigned long memblock_region_reserved_base_pfn(const struct memblock_region *reg) |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 511 | { |
Yinghai Lu | c7fc2de | 2010-10-12 14:07:09 -0700 | [diff] [blame] | 512 | return PFN_DOWN(reg->base); |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | /** |
Mike Rapoport | 47cec44 | 2018-06-30 17:55:02 +0300 | [diff] [blame] | 516 | * memblock_region_reserved_end_pfn - get the end pfn of the reserved region |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 517 | * @reg: memblock_region structure |
Mike Rapoport | 47cec44 | 2018-06-30 17:55:02 +0300 | [diff] [blame] | 518 | * |
| 519 | * Return: the end_pfn of the reserved region |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 520 | */ |
Yinghai Lu | c7fc2de | 2010-10-12 14:07:09 -0700 | [diff] [blame] | 521 | static inline unsigned long memblock_region_reserved_end_pfn(const struct memblock_region *reg) |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 522 | { |
Yinghai Lu | c7fc2de | 2010-10-12 14:07:09 -0700 | [diff] [blame] | 523 | return PFN_UP(reg->base + reg->size); |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | #define for_each_memblock(memblock_type, region) \ |
Chen Gang | ba6c19f | 2016-07-26 15:24:47 -0700 | [diff] [blame] | 527 | for (region = memblock.memblock_type.regions; \ |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 528 | region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \ |
| 529 | region++) |
| 530 | |
Gioh Kim | 66e8b43 | 2017-11-15 17:33:42 -0800 | [diff] [blame] | 531 | #define for_each_memblock_type(i, memblock_type, rgn) \ |
| 532 | for (i = 0, rgn = &memblock_type->regions[0]; \ |
| 533 | i < memblock_type->cnt; \ |
| 534 | i++, rgn = &memblock_type->regions[i]) |
Benjamin Herrenschmidt | 5b385f2 | 2010-08-04 13:40:38 +1000 | [diff] [blame] | 535 | |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame] | 536 | extern void *alloc_large_system_hash(const char *tablename, |
| 537 | unsigned long bucketsize, |
| 538 | unsigned long numentries, |
| 539 | int scale, |
| 540 | int flags, |
| 541 | unsigned int *_hash_shift, |
| 542 | unsigned int *_hash_mask, |
| 543 | unsigned long low_limit, |
| 544 | unsigned long high_limit); |
| 545 | |
| 546 | #define HASH_EARLY 0x00000001 /* Allocating during early boot? */ |
| 547 | #define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min |
| 548 | * shift passed via *_hash_shift */ |
| 549 | #define HASH_ZERO 0x00000004 /* Zero allocated hash table */ |
| 550 | |
| 551 | /* Only NUMA needs hash distribution. 64bit NUMA architectures have |
| 552 | * sufficient vmalloc space. |
| 553 | */ |
| 554 | #ifdef CONFIG_NUMA |
| 555 | #define HASHDIST_DEFAULT IS_ENABLED(CONFIG_64BIT) |
| 556 | extern int hashdist; /* Distribute hashes across NUMA nodes? */ |
| 557 | #else |
| 558 | #define hashdist (0) |
| 559 | #endif |
| 560 | |
Vladimir Murzin | 4a20799 | 2015-04-14 15:48:27 -0700 | [diff] [blame] | 561 | #ifdef CONFIG_MEMTEST |
Vladimir Murzin | 7f70bae | 2015-04-14 15:48:30 -0700 | [diff] [blame] | 562 | extern void early_memtest(phys_addr_t start, phys_addr_t end); |
Vladimir Murzin | 4a20799 | 2015-04-14 15:48:27 -0700 | [diff] [blame] | 563 | #else |
Vladimir Murzin | 7f70bae | 2015-04-14 15:48:30 -0700 | [diff] [blame] | 564 | static inline void early_memtest(phys_addr_t start, phys_addr_t end) |
Vladimir Murzin | 4a20799 | 2015-04-14 15:48:27 -0700 | [diff] [blame] | 565 | { |
| 566 | } |
| 567 | #endif |
Yinghai Lu | f0b37fad | 2010-07-28 15:28:21 +1000 | [diff] [blame] | 568 | |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 569 | #endif /* __KERNEL__ */ |
| 570 | |
| 571 | #endif /* _LINUX_MEMBLOCK_H */ |