The patch titled Subject: mm-compaction-update-pageblock-skip-when-first-migration-candidate-is-not-at-the-start-fix has been added to the -mm mm-unstable branch. Its filename is mm-compaction-update-pageblock-skip-when-first-migration-candidate-is-not-at-the-start-fix.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-compaction-update-pageblock-skip-when-first-migration-candidate-is-not-at-the-start-fix.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm 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 via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Subject: mm-compaction-update-pageblock-skip-when-first-migration-candidate-is-not-at-the-start-fix Date: Fri, 2 Jun 2023 12:16:22 +0100 Vlastimil Babka pointed out the following problem with mm-compaction-update-pageblock-skip-when-first-migration-candidate-is-not-at-the-start.patch I wonder if this has an unintended side-effect that if we resume isolate_migratepages_block() of a partially compacted pageblock to finish it, test_and_set_skip() will now tell us to abort, because we already set the skip bit in the previous call. This would include the cc->finish_pageblock rescan cases. He is correct and a partial rescan as implemented in "mm, compaction: finish pageblocks on complete migration failure" would abort prematurely. Test and set the skip bit when acquiring "exclusive access" to a pageblock for migration but only abort if the calling context is not rescanning to finish a pageblock. This is a fix for the mmotm patch mm-compaction-update-pageblock-skip-when-first-migration-candidate-is-not-at-the-start.patch Link: https://lkml.kernel.org/r/20230602111622.swtxhn6lu2qwgrwq@xxxxxxxxxxxxxxxxxxx Signed-off-by: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Acked-by: Vlastimil Babka <vbabka@xxxxxxx> Cc: Chuyi Zhou <zhouchuyi@xxxxxxxxxxxxx> Cc: Jiri Slaby <jirislaby@xxxxxxxxxx> Cc: Maxim Levitsky <mlevitsk@xxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx> Cc: Pedro Falcato <pedro.falcato@xxxxxxxxx> Cc: Raghavendra K T <raghavendra.kt@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/compaction.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/mm/compaction.c~mm-compaction-update-pageblock-skip-when-first-migration-candidate-is-not-at-the-start-fix +++ a/mm/compaction.c @@ -1069,11 +1069,17 @@ isolate_migratepages_block(struct compac lruvec_memcg_debug(lruvec, page_folio(page)); - /* Try get exclusive access under lock */ + /* + * Try get exclusive access under lock. If marked for + * skip, the scan is aborted unless the current context + * is a rescan to reach the end of the pageblock. + */ if (!skip_updated && valid_page) { skip_updated = true; - if (test_and_set_skip(cc, valid_page)) + if (test_and_set_skip(cc, valid_page) && + !cc->finish_pageblock) { goto isolate_abort; + } } /* _ Patches currently in -mm which might be from mgorman@xxxxxxxxxxxxxxxxxxx are mm-compaction-ensure-rescanning-only-happens-on-partially-scanned-pageblocks.patch mm-compaction-only-force-pageblock-scan-completion-when-skip-hints-are-obeyed.patch mm-compaction-update-pageblock-skip-when-first-migration-candidate-is-not-at-the-start.patch mm-compaction-update-pageblock-skip-when-first-migration-candidate-is-not-at-the-start-fix.patch revert-revert-mm-compaction-fix-set-skip-in-fast_find_migrateblock.patch