[PATCH v5 06/10] mm/memory_hotplug: Poison memmap in remove_pfn_range_from_zone()
David Hildenbrand
david at redhat.com
Wed Oct 2 00:40:07 AEST 2019
Let's poison the pages similar to when adding new memory in
sparse_add_section(). Also call remove_pfn_range_from_zone() from
memunmap_pages(), so we can poison the memmap from there as well.
While at it, calculate the pfn in memunmap_pages() only once.
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: David Hildenbrand <david at redhat.com>
Cc: Oscar Salvador <osalvador at suse.de>
Cc: Michal Hocko <mhocko at suse.com>
Cc: Pavel Tatashin <pasha.tatashin at soleen.com>
Cc: Dan Williams <dan.j.williams at intel.com>
Signed-off-by: David Hildenbrand <david at redhat.com>
---
mm/memory_hotplug.c | 3 +++
mm/memremap.c | 2 ++
2 files changed, 5 insertions(+)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index cef909ebd807..640309236a58 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -464,6 +464,9 @@ void __ref remove_pfn_range_from_zone(struct zone *zone,
struct pglist_data *pgdat = zone->zone_pgdat;
unsigned long flags;
+ /* Poison struct pages because they are now uninitialized again. */
+ page_init_poison(pfn_to_page(start_pfn), sizeof(struct page) * nr_pages);
+
/*
* Zone shrinking code cannot properly deal with ZONE_DEVICE. So
* we will not try to shrink the zones - which is okay as
diff --git a/mm/memremap.c b/mm/memremap.c
index 734afeaad811..371939f92b69 100644
--- a/mm/memremap.c
+++ b/mm/memremap.c
@@ -139,6 +139,8 @@ void memunmap_pages(struct dev_pagemap *pgmap)
nid = page_to_nid(pfn_to_page(start_pfn));
mem_hotplug_begin();
+ remove_pfn_range_from_zone(page_zone(pfn_to_page(start_pfn)),
+ start_pfn, nr_pages);
if (pgmap->type == MEMORY_DEVICE_PRIVATE) {
__remove_pages(start_pfn, nr_pages, NULL);
} else {
--
2.21.0
More information about the Linuxppc-dev
mailing list