The patch titled Subject: mm-hotplug-fix-offline-undo_isolate_page_range-v4 has been added to the -mm tree. Its filename is mm-hotplug-fix-offline-undo_isolate_page_range-v4.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-hotplug-fix-offline-undo_isolate_page_range-v4.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-hotplug-fix-offline-undo_isolate_page_range-v4.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Qian Cai <cai@xxxxxx> Subject: mm-hotplug-fix-offline-undo_isolate_page_range-v4 v4: Further consolidate comments. Turn on kernel-doc and add a stable tag per Michal. Link: http://lkml.kernel.org/r/20190314150641.59358-1-cai@xxxxxx Signed-off-by: Qian Cai <cai@xxxxxx> Acked-by: Michal Hocko <mhocko@xxxxxxxx> Reviewed-by: Oscar Salvador <osalvador@xxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/include/linux/page-isolation.h~mm-hotplug-fix-offline-undo_isolate_page_range-v4 +++ a/include/linux/page-isolation.h @@ -41,16 +41,6 @@ int move_freepages_block(struct zone *zo /* * 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, --- a/mm/memory_hotplug.c~mm-hotplug-fix-offline-undo_isolate_page_range-v4 +++ a/mm/memory_hotplug.c @@ -1576,7 +1576,7 @@ static int __ref __offline_pages(unsigne { unsigned long pfn, nr_pages; long offlined_pages; - int ret, node, count; + int ret, node, nr_isolate_pageblock; unsigned long flags; unsigned long valid_start, valid_end; struct zone *zone; @@ -1606,7 +1606,7 @@ static int __ref __offline_pages(unsigne reason = "failure to isolate range"; goto failed_removal; } - count = ret; + nr_isolate_pageblock = ret; arg.start_pfn = start_pfn; arg.nr_pages = nr_pages; @@ -1665,7 +1665,7 @@ static int __ref __offline_pages(unsigne * pageblocks zone counter here. */ spin_lock_irqsave(&zone->lock, flags); - zone->nr_isolate_pageblock -= count; + zone->nr_isolate_pageblock -= nr_isolate_pageblock; spin_unlock_irqrestore(&zone->lock, flags); /* removal success */ --- a/mm/page_isolation.c~mm-hotplug-fix-offline-undo_isolate_page_range-v4 +++ a/mm/page_isolation.c @@ -160,28 +160,36 @@ __first_valid_page(unsigned long pfn, un return NULL; } -/* - * start_isolate_page_range() -- make page-allocation-type of range of pages - * to be MIGRATE_ISOLATE. - * @start_pfn: The lower PFN of the range to be isolated. - * @end_pfn: The upper PFN of the range to be isolated. - * @migratetype: migrate type to set in error recovery. +/** + * start_isolate_page_range() - make page-allocation-type of range of pages to + * be MIGRATE_ISOLATE. + * @start_pfn: The lower PFN of the range to be isolated. + * @end_pfn: The upper PFN of the range to be isolated. + * start_pfn/end_pfn must be aligned to pageblock_order. + * @migratetype: Migrate type to set in error recovery. + * @flags: 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 * * Making page-allocation-type to be MIGRATE_ISOLATE means free pages in * the range will never be allocated. Any free pages and pages freed in the - * future will not be allocated again. - * - * start_pfn/end_pfn must be aligned to pageblock_order. - * Return the number of isolated pageblocks on success and -EBUSY if any part of - * range cannot be isolated. + * future will not be allocated again. 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. * * There is no high level synchronization mechanism that prevents two threads - * from trying to isolate overlapping ranges. If this happens, one thread + * from trying to isolate overlapping ranges. If this happens, one thread * will notice pageblocks in the overlapping range already set to isolate. * This happens in set_migratetype_isolate, and set_migratetype_isolate - * returns an error. We then clean up by restoring the migration type on - * pageblocks we may have modified and return -EBUSY to caller. This + * returns an error. We then clean up by restoring the migration type on + * pageblocks we may have modified and return -EBUSY to caller. This * prevents two threads from simultaneously working on overlapping ranges. + * + * Return: the number of isolated pageblocks on success and -EBUSY if any part + * of range cannot be isolated. */ int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, unsigned migratetype, int flags) @@ -189,7 +197,7 @@ int start_isolate_page_range(unsigned lo unsigned long pfn; unsigned long undo_pfn; struct page *page; - int count = 0; + int nr_isolate_pageblock = 0; BUG_ON(!IS_ALIGNED(start_pfn, pageblock_nr_pages)); BUG_ON(!IS_ALIGNED(end_pfn, pageblock_nr_pages)); @@ -203,10 +211,10 @@ int start_isolate_page_range(unsigned lo undo_pfn = pfn; goto undo; } - count++; + nr_isolate_pageblock++; } } - return count; + return nr_isolate_pageblock; undo: for (pfn = start_pfn; pfn < undo_pfn; _ Patches currently in -mm which might be from cai@xxxxxx are kasan-fix-variable-tag-set-but-not-used-warning.patch mm-debug-add-a-cast-to-u64-for-atomic64_read.patch kmemleak-skip-scanning-holes-in-the-bss-section.patch kmemleak-skip-scanning-holes-in-the-bss-section-v2.patch mm-hotplug-fix-offline-undo_isolate_page_range.patch mm-hotplug-fix-offline-undo_isolate_page_range-v4.patch mm-compaction-abort-search-if-isolation-fails-v2.patch mm-hotplug-fix-notification-in-offline-error-path.patch mm-fix-a-wrong-flag-in-set_migratetype_isolate.patch mm-compaction-fix-an-undefined-behaviour.patch