Skip to content

Commit 656d571

Browse files
davidhildenbrandtorvalds
authored andcommitted
mm/memory_hotplug: fix updating the node span
We recently started updating the node span based on the zone span to avoid touching uninitialized memmaps. Currently, we will always detect the node span to start at 0, meaning a node can easily span too many pages. pgdat_is_empty() will still work correctly if all zones span no pages. We should skip over all zones without spanned pages and properly handle the first detected zone that spans pages. Unfortunately, in contrast to the zone span (/proc/zoneinfo), the node span cannot easily be inspected and tested. The node span gives no real guarantees when an architecture supports memory hotplug, meaning it can easily contain holes or span pages of different nodes. The node span is not really used after init on architectures that support memory hotplug. E.g., we use it in mm/memory_hotplug.c:try_offline_node() and in mm/kmemleak.c:kmemleak_scan(). These users seem to be fine. Link: http://lkml.kernel.org/r/[email protected] Fixes: 00d6c01 ("mm/memory_hotplug: don't access uninitialized memmaps in shrink_pgdat_span()") Signed-off-by: David Hildenbrand <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Dan Williams <[email protected]> Cc: Pavel Tatashin <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8731acc commit 656d571

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mm/memory_hotplug.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,14 @@ static void update_pgdat_span(struct pglist_data *pgdat)
447447
zone->spanned_pages;
448448

449449
/* No need to lock the zones, they can't change. */
450+
if (!zone->spanned_pages)
451+
continue;
452+
if (!node_end_pfn) {
453+
node_start_pfn = zone->zone_start_pfn;
454+
node_end_pfn = zone_end_pfn;
455+
continue;
456+
}
457+
450458
if (zone_end_pfn > node_end_pfn)
451459
node_end_pfn = zone_end_pfn;
452460
if (zone->zone_start_pfn < node_start_pfn)

0 commit comments

Comments
 (0)