Skip to content

Commit 9bb627b

Browse files
Li Zhongtorvalds
Li Zhong
authored andcommitted
mem-hotplug: don't clear the only node in new_node_page()
Commit 394e31d ("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: 394e31d ("mem-hotplug: alloc new page from a nearest neighbor node when mem-offline") Link: http://lkml.kernel.org/r/1473044391.4250.19.camel@TP420 Signed-off-by: Li Zhong <[email protected]> Reported-by: John Allen <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Xishi Qiu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3be7988 commit 9bb627b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mm/memory_hotplug.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,9 @@ static struct page *new_node_page(struct page *page, unsigned long private,
15671567
return alloc_huge_page_node(page_hstate(compound_head(page)),
15681568
next_node_in(nid, nmask));
15691569

1570-
node_clear(nid, nmask);
1570+
if (nid != next_node_in(nid, nmask))
1571+
node_clear(nid, nmask);
1572+
15711573
if (PageHighMem(page)
15721574
|| (zone_idx(page_zone(page)) == ZONE_MOVABLE))
15731575
gfp_mask |= __GFP_HIGHMEM;

0 commit comments

Comments
 (0)