Skip to content

Commit d33695b

Browse files
davidhildenbrandtorvalds
authored andcommitted
mm/memory_hotplug: poison memmap in remove_pfn_range_from_zone()
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. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: David Hildenbrand <[email protected]> Cc: Michal Hocko <[email protected]> Cc: "Matthew Wilcox (Oracle)" <[email protected]> Cc: "Aneesh Kumar K.V" <[email protected]> Cc: Pavel Tatashin <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Dan Williams <[email protected]> Cc: Logan Gunthorpe <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Pankaj Gupta <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1f8d75c commit d33695b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

mm/memory_hotplug.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ void __ref remove_pfn_range_from_zone(struct zone *zone,
490490
struct pglist_data *pgdat = zone->zone_pgdat;
491491
unsigned long flags;
492492

493+
/* Poison struct pages because they are now uninitialized again. */
494+
page_init_poison(pfn_to_page(start_pfn), sizeof(struct page) * nr_pages);
495+
493496
#ifdef CONFIG_ZONE_DEVICE
494497
/*
495498
* Zone shrinking code cannot properly deal with ZONE_DEVICE. So

mm/memremap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ void memunmap_pages(struct dev_pagemap *pgmap)
120120
nid = page_to_nid(first_page);
121121

122122
mem_hotplug_begin();
123+
remove_pfn_range_from_zone(page_zone(first_page), PHYS_PFN(res->start),
124+
PHYS_PFN(resource_size(res)));
123125
if (pgmap->type == MEMORY_DEVICE_PRIVATE) {
124126
__remove_pages(PHYS_PFN(res->start),
125127
PHYS_PFN(resource_size(res)), NULL);

0 commit comments

Comments
 (0)