FAILED: patch "[PATCH] mm/hotplug: fix offline undo_isolate_page_range()" failed to apply to 4.14-stable tree
Subsystems (5)
[email protected]
maintainerThe patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9b7ea46a82b31c74a37e6ff1c2a1df7d53e392ab Mon Sep 17 00:00:00 2001
From: Qian Cai <[email protected]>
Date: Thu, 28 Mar 2019 20:43:34 -0700
Subject: [PATCH] mm/hotplug: fix offline undo_isolate_page_range()
Commit f1dd2cd13c4b ("mm, memory_hotplug: do not associate hotadded memory to zones until online") introduced move_pfn_range_to_zone() which calls memmap_init_zone() during onlining a memory block. memmap_init_zone() will reset pagetype flags and makes migrate type to be MOVABLE.
However, in __offline_pages(), it also call undo_isolate_page_range() after offline_isolated_pages() to do the same thing. Due to commit 2ce13640b3f4 ("mm: __first_valid_page skip over offline pages") changed __first_valid_page() to skip offline pages, undo_isolate_page_range() here just waste CPU cycles looping around the offlining PFN range while doing nothing, because __first_valid_page() will return NULL as offline_isolated_pages() has already marked all memory sections within the pfn range as offline via offline_mem_sections().
Also, after calling the "useless" undo_isolate_page_range() here, it reaches the point of no returning by notifying MEM_OFFLINE. Those pages will be marked as MIGRATE_MOVABLE again once onlining. The only thing left to do is to decrease the number of isolated pageblocks zone counter which would make some paths of the page allocation slower that the above commit introduced.
Even if alloc_contig_range() can be used to isolate 16GB-hugetlb pages on ppc64, an "int" should still be enough to represent the number of pageblocks there. Fix an incorrect comment along the way.
include/linux/page-isolation.h +0 -10
@@ -41,16 +41,6 @@ int move_freepages_block(struct zone *zone, struct page *page,/* * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE. -* If specified range includes migrate types other than MOVABLE or CMA, -* this will fail with -EBUSY. -* -* For isolating all pages in the range finally, the caller have to -* free all pages in the range. test_page_isolated() can be used for -* test it. -* -* The following flags are allowed (they can be combined in a bit mask) -* SKIP_HWPOISON - ignore hwpoison pages -* REPORT_FAILURE - report details about the failure to isolate the range */ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
mm/memory_hotplug.c +13 -4
@@ -1576,7 +1576,7 @@ static int __ref __offline_pages(unsigned long start_pfn, {unsigned long pfn, nr_pages;long offlined_pages; -int ret, node; +int ret, node, nr_isolate_pageblock;unsigned long flags;unsigned long valid_start, valid_end;struct zone *zone;
@@ -1602,10 +1602,11 @@ static int __ref __offline_pages(unsigned long start_pfn, ret =start_isolate_page_range (start_pfn, end_pfn,MIGRATE_MOVABLE ,SKIP_HWPOISON |REPORT_FAILURE ); -if (ret) { +if (ret <0 ) { reason ="failure to isolate range" ; goto failed_removal; } + nr_isolate_pageblock = ret; arg.start_pfn = start_pfn; arg.nr_pages = nr_pages;
@@ -1657,8 +1658,16 @@ static int __ref __offline_pages(unsigned long start_pfn,/* Ok, all of our target is isolated. We cannot do rollback at this point. */ offline_isolated_pages (start_pfn, end_pfn); -/* reset pagetype flags and makes migrate type to be MOVABLE */ -undo_isolate_page_range (start_pfn, end_pfn,MIGRATE_MOVABLE ); + +/* +* Onlining will reset pagetype flags and makes migrate type +* MOVABLE, so just need to decrease the number of isolated +* pageblocks zone counter here. +*/ +spin_lock_irqsave (&zone->lock, flags); + zone->nr_isolate_pageblock -= nr_isolate_pageblock; +spin_unlock_irqrestore (&zone->lock, flags); +/* removal success */ adjust_managed_page_count (pfn_to_page (start_pfn), -offlined_pages); zone->present_pages -= offlined_pages;
mm/page_alloc.c +1 -1
@@ -8233,7 +8233,7 @@ int alloc_contig_range(unsigned long start, unsigned long end, ret =start_isolate_page_range (pfn_max_align_down (start),pfn_max_align_up (end), migratetype,0 ); -if (ret) +if (ret <0 )return ret;/*
mm/page_isolation.c +30 -18
76 lines not on this page · raw message
mm/sparse.c +1 -1
@@ -567,7 +567,7 @@ void online_mem_sections(unsigned long start_pfn, unsigned long end_pfn) }#ifdef CONFIG_MEMORY_HOTREMOVE -/* Mark all memory sections within the pfn range as online */ +/* Mark all memory sections within the pfn range as offline */ void offline_mem_sections (unsigned long start_pfn,unsigned long end_pfn) {unsigned long pfn;