Skip to contentSkip to conversation

mem-hotplug: don't clear the only node in new_node_page()

PATCH New [email protected] 1 participant 1 message Sep 19, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/20 mem-hotplug: don't clear the only node in new_node_page()

From: Li Zhong <[email protected]>
Subject: mem-hotplug: don't clear the only node in new_node_page()

394e31d2c ("mem-hotplug: alloc new page from a nearest neighbor node when mem-offline") introduced new_node_page() for memory hotplug.

In new_node_page(), the nid is cleared before calling __alloc_pages_nodemask(). But if it is the only node of the system, and the first round allocation fails, it will not be able to get memory from an empty nodemask, and will trigger oom.

The patch checks whether it is the last node on the system, and if it is, then don't clear the nid in the nodemask.

Fixes 394e31d2ceb4 ("mem-hotplug: alloc new page from a nearest neighbor node when mem-offline")
Cc Xishi Qiu <[email protected]>

---

 mm/memory_hotplug.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
mm/memory_hotplug.c renamed from mm/memory_hotplug.c~mem-hotplug-dont-clear-the-only-node-in-new_node_page +3 -1
diff -puN mm/memory_hotplug.c~mem-hotplug-dont-clear-the-only-node-in-new_node_page mm/memory_hotplug.c
@@ -1567,7 +1567,9 @@ static struct page *new_node_page(struct
 		return alloc_huge_page_node(page_hstate(compound_head(page)),
 					next_node_in(nid, nmask));
 
-	node_clear(nid, nmask);
+	if (nid != next_node_in(nid, nmask))
+		node_clear(nid, nmask);
+
 	if (PageHighMem(page)
 	    || (zone_idx(page_zone(page)) == ZONE_MOVABLE))
 		gfp_mask |= __GFP_HIGHMEM;

_