diff options
| author | Michal Hocko <mhocko@suse.com> | 2019-05-13 20:21:26 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-14 12:47:49 -0400 |
| commit | 940519f0c8b757fdcbc5d14c93cdaada20ded14c (patch) | |
| tree | b6b39399a9ef9914e8c2902b6ffe300d52531913 /include/linux/memory_hotplug.h | |
| parent | 5557c766abad25acc8091ccb9641b96e3b3da06f (diff) | |
mm, memory_hotplug: provide a more generic restrictions for memory hotplug
arch_add_memory, __add_pages take a want_memblock which controls whether
the newly added memory should get the sysfs memblock user API (e.g.
ZONE_DEVICE users do not want/need this interface). Some callers even
want to control where do we allocate the memmap from by configuring
altmap.
Add a more generic hotplug context for arch_add_memory and __add_pages.
struct mhp_restrictions contains flags which contains additional features
to be enabled by the memory hotplug (MHP_MEMBLOCK_API currently) and
altmap for alternative memmap allocator.
This patch shouldn't introduce any functional change.
[akpm@linux-foundation.org: build fix]
Link: http://lkml.kernel.org/r/20190408082633.2864-3-osalvador@suse.de
Signed-off-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Oscar Salvador <osalvador@suse.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/memory_hotplug.h')
| -rw-r--r-- | include/linux/memory_hotplug.h | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 3c8cf347804c..b24aca54353e 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h | |||
| @@ -54,6 +54,16 @@ enum { | |||
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | /* | 56 | /* |
| 57 | * Restrictions for the memory hotplug: | ||
| 58 | * flags: MHP_ flags | ||
| 59 | * altmap: alternative allocator for memmap array | ||
| 60 | */ | ||
| 61 | struct mhp_restrictions { | ||
| 62 | unsigned long flags; | ||
| 63 | struct vmem_altmap *altmap; | ||
| 64 | }; | ||
| 65 | |||
| 66 | /* | ||
| 57 | * Zone resizing functions | 67 | * Zone resizing functions |
| 58 | * | 68 | * |
| 59 | * Note: any attempt to resize a zone should has pgdat_resize_lock() | 69 | * Note: any attempt to resize a zone should has pgdat_resize_lock() |
| @@ -101,6 +111,8 @@ extern void __online_page_free(struct page *page); | |||
| 101 | 111 | ||
| 102 | extern int try_online_node(int nid); | 112 | extern int try_online_node(int nid); |
| 103 | 113 | ||
| 114 | extern int arch_add_memory(int nid, u64 start, u64 size, | ||
| 115 | struct mhp_restrictions *restrictions); | ||
| 104 | extern u64 max_mem_size; | 116 | extern u64 max_mem_size; |
| 105 | 117 | ||
| 106 | extern bool memhp_auto_online; | 118 | extern bool memhp_auto_online; |
| @@ -118,20 +130,27 @@ extern int __remove_pages(struct zone *zone, unsigned long start_pfn, | |||
| 118 | unsigned long nr_pages, struct vmem_altmap *altmap); | 130 | unsigned long nr_pages, struct vmem_altmap *altmap); |
| 119 | #endif /* CONFIG_MEMORY_HOTREMOVE */ | 131 | #endif /* CONFIG_MEMORY_HOTREMOVE */ |
| 120 | 132 | ||
| 133 | /* | ||
| 134 | * Do we want sysfs memblock files created. This will allow userspace to online | ||
| 135 | * and offline memory explicitly. Lack of this bit means that the caller has to | ||
| 136 | * call move_pfn_range_to_zone to finish the initialization. | ||
| 137 | */ | ||
| 138 | |||
| 139 | #define MHP_MEMBLOCK_API (1<<0) | ||
| 140 | |||
| 121 | /* reasonably generic interface to expand the physical pages */ | 141 | /* reasonably generic interface to expand the physical pages */ |
| 122 | extern int __add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages, | 142 | extern int __add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages, |
| 123 | struct vmem_altmap *altmap, bool want_memblock); | 143 | struct mhp_restrictions *restrictions); |
| 124 | 144 | ||
| 125 | #ifndef CONFIG_ARCH_HAS_ADD_PAGES | 145 | #ifndef CONFIG_ARCH_HAS_ADD_PAGES |
| 126 | static inline int add_pages(int nid, unsigned long start_pfn, | 146 | static inline int add_pages(int nid, unsigned long start_pfn, |
| 127 | unsigned long nr_pages, struct vmem_altmap *altmap, | 147 | unsigned long nr_pages, struct mhp_restrictions *restrictions) |
| 128 | bool want_memblock) | ||
| 129 | { | 148 | { |
| 130 | return __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock); | 149 | return __add_pages(nid, start_pfn, nr_pages, restrictions); |
| 131 | } | 150 | } |
| 132 | #else /* ARCH_HAS_ADD_PAGES */ | 151 | #else /* ARCH_HAS_ADD_PAGES */ |
| 133 | int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages, | 152 | int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages, |
| 134 | struct vmem_altmap *altmap, bool want_memblock); | 153 | struct mhp_restrictions *restrictions); |
| 135 | #endif /* ARCH_HAS_ADD_PAGES */ | 154 | #endif /* ARCH_HAS_ADD_PAGES */ |
| 136 | 155 | ||
| 137 | #ifdef CONFIG_NUMA | 156 | #ifdef CONFIG_NUMA |
| @@ -332,8 +351,6 @@ extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn, | |||
| 332 | extern int __add_memory(int nid, u64 start, u64 size); | 351 | extern int __add_memory(int nid, u64 start, u64 size); |
| 333 | extern int add_memory(int nid, u64 start, u64 size); | 352 | extern int add_memory(int nid, u64 start, u64 size); |
| 334 | extern int add_memory_resource(int nid, struct resource *resource); | 353 | extern int add_memory_resource(int nid, struct resource *resource); |
| 335 | extern int arch_add_memory(int nid, u64 start, u64 size, | ||
| 336 | struct vmem_altmap *altmap, bool want_memblock); | ||
| 337 | extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, | 354 | extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, |
| 338 | unsigned long nr_pages, struct vmem_altmap *altmap); | 355 | unsigned long nr_pages, struct vmem_altmap *altmap); |
| 339 | extern bool is_memblock_offlined(struct memory_block *mem); | 356 | extern bool is_memblock_offlined(struct memory_block *mem); |
