Commit da024512 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dan Williams

mm: pass the vmem_altmap to arch_remove_memory and __remove_pages

We can just pass this on instead of having to do a radix tree lookup
without proper locking 2 levels into the callchain.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 7b73d978
...@@ -663,7 +663,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, ...@@ -663,7 +663,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
} }
#ifdef CONFIG_MEMORY_HOTREMOVE #ifdef CONFIG_MEMORY_HOTREMOVE
int arch_remove_memory(u64 start, u64 size) int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
{ {
unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT;
...@@ -671,7 +671,7 @@ int arch_remove_memory(u64 start, u64 size) ...@@ -671,7 +671,7 @@ int arch_remove_memory(u64 start, u64 size)
int ret; int ret;
zone = page_zone(pfn_to_page(start_pfn)); zone = page_zone(pfn_to_page(start_pfn));
ret = __remove_pages(zone, start_pfn, nr_pages); ret = __remove_pages(zone, start_pfn, nr_pages, altmap);
if (ret) if (ret)
pr_warn("%s: Problem encountered in __remove_pages() as" pr_warn("%s: Problem encountered in __remove_pages() as"
" ret=%d\n", __func__, ret); " ret=%d\n", __func__, ret);
......
...@@ -149,11 +149,10 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, ...@@ -149,11 +149,10 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
} }
#ifdef CONFIG_MEMORY_HOTREMOVE #ifdef CONFIG_MEMORY_HOTREMOVE
int arch_remove_memory(u64 start, u64 size) int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
{ {
unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT;
struct vmem_altmap *altmap;
struct page *page; struct page *page;
int ret; int ret;
...@@ -162,11 +161,10 @@ int arch_remove_memory(u64 start, u64 size) ...@@ -162,11 +161,10 @@ int arch_remove_memory(u64 start, u64 size)
* when querying the zone. * when querying the zone.
*/ */
page = pfn_to_page(start_pfn); page = pfn_to_page(start_pfn);
altmap = to_vmem_altmap((unsigned long) page);
if (altmap) if (altmap)
page += vmem_altmap_offset(altmap); page += vmem_altmap_offset(altmap);
ret = __remove_pages(page_zone(page), start_pfn, nr_pages); ret = __remove_pages(page_zone(page), start_pfn, nr_pages, altmap);
if (ret) if (ret)
return ret; return ret;
......
...@@ -240,7 +240,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, ...@@ -240,7 +240,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
} }
#ifdef CONFIG_MEMORY_HOTREMOVE #ifdef CONFIG_MEMORY_HOTREMOVE
int arch_remove_memory(u64 start, u64 size) int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
{ {
/* /*
* There is no hardware or firmware interface which could trigger a * There is no hardware or firmware interface which could trigger a
......
...@@ -510,7 +510,7 @@ EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); ...@@ -510,7 +510,7 @@ EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
#endif #endif
#ifdef CONFIG_MEMORY_HOTREMOVE #ifdef CONFIG_MEMORY_HOTREMOVE
int arch_remove_memory(u64 start, u64 size) int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
{ {
unsigned long start_pfn = PFN_DOWN(start); unsigned long start_pfn = PFN_DOWN(start);
unsigned long nr_pages = size >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT;
...@@ -518,7 +518,7 @@ int arch_remove_memory(u64 start, u64 size) ...@@ -518,7 +518,7 @@ int arch_remove_memory(u64 start, u64 size)
int ret; int ret;
zone = page_zone(pfn_to_page(start_pfn)); zone = page_zone(pfn_to_page(start_pfn));
ret = __remove_pages(zone, start_pfn, nr_pages); ret = __remove_pages(zone, start_pfn, nr_pages, altmap);
if (unlikely(ret)) if (unlikely(ret))
pr_warn("%s: Failed, __remove_pages() == %d\n", __func__, pr_warn("%s: Failed, __remove_pages() == %d\n", __func__,
ret); ret);
......
...@@ -839,14 +839,14 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, ...@@ -839,14 +839,14 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
} }
#ifdef CONFIG_MEMORY_HOTREMOVE #ifdef CONFIG_MEMORY_HOTREMOVE
int arch_remove_memory(u64 start, u64 size) int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
{ {
unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT;
struct zone *zone; struct zone *zone;
zone = page_zone(pfn_to_page(start_pfn)); zone = page_zone(pfn_to_page(start_pfn));
return __remove_pages(zone, start_pfn, nr_pages); return __remove_pages(zone, start_pfn, nr_pages, altmap);
} }
#endif #endif
#endif #endif
......
...@@ -1132,21 +1132,19 @@ kernel_physical_mapping_remove(unsigned long start, unsigned long end) ...@@ -1132,21 +1132,19 @@ kernel_physical_mapping_remove(unsigned long start, unsigned long end)
remove_pagetable(start, end, true); remove_pagetable(start, end, true);
} }
int __ref arch_remove_memory(u64 start, u64 size) int __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
{ {
unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT;
struct page *page = pfn_to_page(start_pfn); struct page *page = pfn_to_page(start_pfn);
struct vmem_altmap *altmap;
struct zone *zone; struct zone *zone;
int ret; int ret;
/* With altmap the first mapped page is offset from @start */ /* With altmap the first mapped page is offset from @start */
altmap = to_vmem_altmap((unsigned long) page);
if (altmap) if (altmap)
page += vmem_altmap_offset(altmap); page += vmem_altmap_offset(altmap);
zone = page_zone(page); zone = page_zone(page);
ret = __remove_pages(zone, start_pfn, nr_pages); ret = __remove_pages(zone, start_pfn, nr_pages, altmap);
WARN_ON_ONCE(ret); WARN_ON_ONCE(ret);
kernel_physical_mapping_remove(start, start + size); kernel_physical_mapping_remove(start, start + size);
......
...@@ -126,9 +126,10 @@ static inline bool movable_node_is_enabled(void) ...@@ -126,9 +126,10 @@ static inline bool movable_node_is_enabled(void)
#ifdef CONFIG_MEMORY_HOTREMOVE #ifdef CONFIG_MEMORY_HOTREMOVE
extern bool is_pageblock_removable_nolock(struct page *page); extern bool is_pageblock_removable_nolock(struct page *page);
extern int arch_remove_memory(u64 start, u64 size); extern int arch_remove_memory(u64 start, u64 size,
struct vmem_altmap *altmap);
extern int __remove_pages(struct zone *zone, unsigned long start_pfn, extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
unsigned long nr_pages); unsigned long nr_pages, struct vmem_altmap *altmap);
#endif /* CONFIG_MEMORY_HOTREMOVE */ #endif /* CONFIG_MEMORY_HOTREMOVE */
/* reasonably generic interface to expand the physical pages */ /* reasonably generic interface to expand the physical pages */
......
...@@ -304,7 +304,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data) ...@@ -304,7 +304,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data)
align_size = ALIGN(resource_size(res), SECTION_SIZE); align_size = ALIGN(resource_size(res), SECTION_SIZE);
mem_hotplug_begin(); mem_hotplug_begin();
arch_remove_memory(align_start, align_size); arch_remove_memory(align_start, align_size, pgmap->altmap);
mem_hotplug_done(); mem_hotplug_done();
untrack_pfn(NULL, PHYS_PFN(align_start), align_size); untrack_pfn(NULL, PHYS_PFN(align_start), align_size);
......
...@@ -838,10 +838,10 @@ static void hmm_devmem_release(struct device *dev, void *data) ...@@ -838,10 +838,10 @@ static void hmm_devmem_release(struct device *dev, void *data)
mem_hotplug_begin(); mem_hotplug_begin();
if (resource->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY) if (resource->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY)
__remove_pages(zone, start_pfn, npages); __remove_pages(zone, start_pfn, npages, NULL);
else else
arch_remove_memory(start_pfn << PAGE_SHIFT, arch_remove_memory(start_pfn << PAGE_SHIFT,
npages << PAGE_SHIFT); npages << PAGE_SHIFT, NULL);
mem_hotplug_done(); mem_hotplug_done();
hmm_devmem_radix_release(resource); hmm_devmem_radix_release(resource);
......
...@@ -569,7 +569,7 @@ static int __remove_section(struct zone *zone, struct mem_section *ms, ...@@ -569,7 +569,7 @@ static int __remove_section(struct zone *zone, struct mem_section *ms,
* calling offline_pages(). * calling offline_pages().
*/ */
int __remove_pages(struct zone *zone, unsigned long phys_start_pfn, int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
unsigned long nr_pages) unsigned long nr_pages, struct vmem_altmap *altmap)
{ {
unsigned long i; unsigned long i;
unsigned long map_offset = 0; unsigned long map_offset = 0;
...@@ -577,10 +577,6 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn, ...@@ -577,10 +577,6 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
/* In the ZONE_DEVICE case device driver owns the memory region */ /* In the ZONE_DEVICE case device driver owns the memory region */
if (is_dev_zone(zone)) { if (is_dev_zone(zone)) {
struct page *page = pfn_to_page(phys_start_pfn);
struct vmem_altmap *altmap;
altmap = to_vmem_altmap((unsigned long) page);
if (altmap) if (altmap)
map_offset = vmem_altmap_offset(altmap); map_offset = vmem_altmap_offset(altmap);
} else { } else {
...@@ -1890,7 +1886,7 @@ void __ref remove_memory(int nid, u64 start, u64 size) ...@@ -1890,7 +1886,7 @@ void __ref remove_memory(int nid, u64 start, u64 size)
memblock_free(start, size); memblock_free(start, size);
memblock_remove(start, size); memblock_remove(start, size);
arch_remove_memory(start, size); arch_remove_memory(start, size, NULL);
try_offline_node(nid); try_offline_node(nid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment