Skip to content

Commit 0bbf3fc

Browse files
ctmarinasgregkh
authored andcommitted
arm64: mte: Do not warn if the page is already tagged in copy_highpage()
commit b98c94e upstream. The arm64 copy_highpage() assumes that the destination page is newly allocated and not MTE-tagged (PG_mte_tagged unset) and warns accordingly. However, following commit 0609139 ("mm: migrate: support poisoned recover from migrate folio"), folio_mc_copy() is called before __folio_migrate_mapping(). If the latter fails (-EAGAIN), the copy will be done again to the same destination page. Since copy_highpage() already set the PG_mte_tagged flag, this second copy will warn. Replace the WARN_ON_ONCE(page already tagged) in the arm64 copy_highpage() with a comment. Reported-by: [email protected] Link: https://lore.kernel.org/r/[email protected] Reviewed-by: David Hildenbrand <[email protected]> Cc: Will Deacon <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: [email protected] # 6.12.x Reviewed-by: Yang Shi <[email protected]> Signed-off-by: Catalin Marinas <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9506b5f commit 0bbf3fc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

arch/arm64/mm/copypage.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void copy_highpage(struct page *to, struct page *from)
3535
from != folio_page(src, 0))
3636
return;
3737

38-
WARN_ON_ONCE(!folio_try_hugetlb_mte_tagging(dst));
38+
folio_try_hugetlb_mte_tagging(dst);
3939

4040
/*
4141
* Populate tags for all subpages.
@@ -51,8 +51,13 @@ void copy_highpage(struct page *to, struct page *from)
5151
}
5252
folio_set_hugetlb_mte_tagged(dst);
5353
} else if (page_mte_tagged(from)) {
54-
/* It's a new page, shouldn't have been tagged yet */
55-
WARN_ON_ONCE(!try_page_mte_tagging(to));
54+
/*
55+
* Most of the time it's a new page that shouldn't have been
56+
* tagged yet. However, folio migration can end up reusing the
57+
* same page without untagging it. Ignore the warning if the
58+
* page is already tagged.
59+
*/
60+
try_page_mte_tagging(to);
5661

5762
mte_copy_page_tags(kto, kfrom);
5863
set_page_mte_tagged(to);

0 commit comments

Comments
 (0)