linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: mte: Do not warn if the page is already tagged in copy_highpage()
@ 2025-10-21 18:13 Catalin Marinas
  2025-10-21 18:23 ` David Hildenbrand
  2025-10-21 19:00 ` Yang Shi
  0 siblings, 2 replies; 6+ messages in thread
From: Catalin Marinas @ 2025-10-21 18:13 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-mm, syzbot+d1974fc28545a3e6218b, Will Deacon,
	David Hildenbrand, Kefeng Wang

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 060913999d7a ("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(page already tagged) in the arm64 copy_highpage()
with a comment.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Reported-by: syzbot+d1974fc28545a3e6218b@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/68dda1ae.a00a0220.102ee.0065.GAE@google.com
Cc: <stable@vger.kernel.org> # 6.12.x
Cc: Will Deacon <will@kernel.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 arch/arm64/mm/copypage.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/mm/copypage.c b/arch/arm64/mm/copypage.c
index a86c897017df..40749d0a385c 100644
--- a/arch/arm64/mm/copypage.c
+++ b/arch/arm64/mm/copypage.c
@@ -51,8 +51,13 @@ void copy_highpage(struct page *to, struct page *from)
 		}
 		folio_set_hugetlb_mte_tagged(dst);
 	} else if (page_mte_tagged(from)) {
-		/* It's a new page, shouldn't have been tagged yet */
-		WARN_ON_ONCE(!try_page_mte_tagging(to));
+		/*
+		 * Most of the time it's a new page that shouldn't have been
+		 * tagged yet. However, folio migration can end up reusing the
+		 * same page without untagging it. Ignore the warning if the
+		 * page is already tagged.
+		 */
+		try_page_mte_tagging(to);
 
 		mte_copy_page_tags(kto, kfrom);
 		set_page_mte_tagged(to);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64: mte: Do not warn if the page is already tagged in copy_highpage()
  2025-10-21 18:13 [PATCH] arm64: mte: Do not warn if the page is already tagged in copy_highpage() Catalin Marinas
@ 2025-10-21 18:23 ` David Hildenbrand
  2025-10-21 19:00 ` Yang Shi
  1 sibling, 0 replies; 6+ messages in thread
From: David Hildenbrand @ 2025-10-21 18:23 UTC (permalink / raw)
  To: Catalin Marinas, linux-arm-kernel
  Cc: linux-mm, syzbot+d1974fc28545a3e6218b, Will Deacon, Kefeng Wang

On 21.10.25 20:13, Catalin Marinas wrote:
> 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 060913999d7a ("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(page already tagged) in the arm64 copy_highpage()
> with a comment.
> 
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> Reported-by: syzbot+d1974fc28545a3e6218b@syzkaller.appspotmail.com
> Link: https://lore.kernel.org/r/68dda1ae.a00a0220.102ee.0065.GAE@google.com
> Cc: <stable@vger.kernel.org> # 6.12.x
> Cc: Will Deacon <will@kernel.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>   arch/arm64/mm/copypage.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/mm/copypage.c b/arch/arm64/mm/copypage.c
> index a86c897017df..40749d0a385c 100644
> --- a/arch/arm64/mm/copypage.c
> +++ b/arch/arm64/mm/copypage.c
> @@ -51,8 +51,13 @@ void copy_highpage(struct page *to, struct page *from)
>   		}
>   		folio_set_hugetlb_mte_tagged(dst);
>   	} else if (page_mte_tagged(from)) {
> -		/* It's a new page, shouldn't have been tagged yet */
> -		WARN_ON_ONCE(!try_page_mte_tagging(to));
> +		/*
> +		 * Most of the time it's a new page that shouldn't have been
> +		 * tagged yet. However, folio migration can end up reusing the
> +		 * same page without untagging it. Ignore the warning if the
> +		 * page is already tagged.
> +		 */
> +		try_page_mte_tagging(to);
>   
>   		mte_copy_page_tags(kto, kfrom);
>   		set_page_mte_tagged(to);
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers

David / dhildenb



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64: mte: Do not warn if the page is already tagged in copy_highpage()
  2025-10-21 18:13 [PATCH] arm64: mte: Do not warn if the page is already tagged in copy_highpage() Catalin Marinas
  2025-10-21 18:23 ` David Hildenbrand
@ 2025-10-21 19:00 ` Yang Shi
  2025-10-22  6:19   ` Kefeng Wang
  2025-10-22  9:57   ` Catalin Marinas
  1 sibling, 2 replies; 6+ messages in thread
From: Yang Shi @ 2025-10-21 19:00 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: linux-arm-kernel, linux-mm, syzbot+d1974fc28545a3e6218b,
	Will Deacon, David Hildenbrand, Kefeng Wang

On Tue, Oct 21, 2025 at 11:14 AM Catalin Marinas
<catalin.marinas@arm.com> wrote:
>
> 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 060913999d7a ("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(page already tagged) in the arm64 copy_highpage()
> with a comment.
>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> Reported-by: syzbot+d1974fc28545a3e6218b@syzkaller.appspotmail.com
> Link: https://lore.kernel.org/r/68dda1ae.a00a0220.102ee.0065.GAE@google.com
> Cc: <stable@vger.kernel.org> # 6.12.x
> Cc: Will Deacon <will@kernel.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  arch/arm64/mm/copypage.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/mm/copypage.c b/arch/arm64/mm/copypage.c
> index a86c897017df..40749d0a385c 100644
> --- a/arch/arm64/mm/copypage.c
> +++ b/arch/arm64/mm/copypage.c
> @@ -51,8 +51,13 @@ void copy_highpage(struct page *to, struct page *from)
>                 }
>                 folio_set_hugetlb_mte_tagged(dst);
>         } else if (page_mte_tagged(from)) {
> -               /* It's a new page, shouldn't have been tagged yet */
> -               WARN_ON_ONCE(!try_page_mte_tagging(to));

I think you should remove the WARN_ON_ONCE in the above hugetlb chunk
too IIUC. migrate_huge_page_move_mapping() does the similar thing.

Thanks,
Yang

> +               /*
> +                * Most of the time it's a new page that shouldn't have been
> +                * tagged yet. However, folio migration can end up reusing the
> +                * same page without untagging it. Ignore the warning if the
> +                * page is already tagged.
> +                */
> +               try_page_mte_tagging(to);
>
>                 mte_copy_page_tags(kto, kfrom);
>                 set_page_mte_tagged(to);
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64: mte: Do not warn if the page is already tagged in copy_highpage()
  2025-10-21 19:00 ` Yang Shi
@ 2025-10-22  6:19   ` Kefeng Wang
  2025-10-22 10:00     ` Catalin Marinas
  2025-10-22  9:57   ` Catalin Marinas
  1 sibling, 1 reply; 6+ messages in thread
From: Kefeng Wang @ 2025-10-22  6:19 UTC (permalink / raw)
  To: Yang Shi, Catalin Marinas
  Cc: linux-arm-kernel, linux-mm, syzbot+d1974fc28545a3e6218b,
	Will Deacon, David Hildenbrand



On 2025/10/22 3:00, Yang Shi wrote:
> On Tue, Oct 21, 2025 at 11:14 AM Catalin Marinas
> <catalin.marinas@arm.com> wrote:
>>
>> 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 060913999d7a ("mm: migrate:
>> support poisoned recover from migrate folio"), __folio_mc_copy() is

no "__" prefix

>> 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(page already tagged) in the arm64 copy_highpage()
>> with a comment.
>>
>> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
>> Reported-by: syzbot+d1974fc28545a3e6218b@syzkaller.appspotmail.com
>> Link: https://lore.kernel.org/r/68dda1ae.a00a0220.102ee.0065.GAE@google.com
>> Cc: <stable@vger.kernel.org> # 6.12.x
>> Cc: Will Deacon <will@kernel.org>
>> Cc: David Hildenbrand <david@redhat.com>
>> Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>>   arch/arm64/mm/copypage.c | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm64/mm/copypage.c b/arch/arm64/mm/copypage.c
>> index a86c897017df..40749d0a385c 100644
>> --- a/arch/arm64/mm/copypage.c
>> +++ b/arch/arm64/mm/copypage.c
>> @@ -51,8 +51,13 @@ void copy_highpage(struct page *to, struct page *from)
>>                  }
>>                  folio_set_hugetlb_mte_tagged(dst);
>>          } else if (page_mte_tagged(from)) {
>> -               /* It's a new page, shouldn't have been tagged yet */
>> -               WARN_ON_ONCE(!try_page_mte_tagging(to));
> 
> I think you should remove the WARN_ON_ONCE in the above hugetlb chunk
> too IIUC. migrate_huge_page_move_mapping() does the similar thing.
> 

Yes, it's better to remove WARN_ON_ONCE for hugetlb too.

> Thanks,
> Yang
> 
>> +               /*
>> +                * Most of the time it's a new page that shouldn't have been
>> +                * tagged yet. However, folio migration can end up reusing the
>> +                * same page without untagging it. Ignore the warning if the
>> +                * page is already tagged.
>> +                */
>> +               try_page_mte_tagging(to);
>>
>>                  mte_copy_page_tags(kto, kfrom);
>>                  set_page_mte_tagged(to);
>>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64: mte: Do not warn if the page is already tagged in copy_highpage()
  2025-10-21 19:00 ` Yang Shi
  2025-10-22  6:19   ` Kefeng Wang
@ 2025-10-22  9:57   ` Catalin Marinas
  1 sibling, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2025-10-22  9:57 UTC (permalink / raw)
  To: Yang Shi
  Cc: linux-arm-kernel, linux-mm, syzbot+d1974fc28545a3e6218b,
	Will Deacon, David Hildenbrand, Kefeng Wang

On Tue, Oct 21, 2025 at 12:00:04PM -0700, Yang Shi wrote:
> On Tue, Oct 21, 2025 at 11:14 AM Catalin Marinas
> <catalin.marinas@arm.com> wrote:
> > 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 060913999d7a ("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(page already tagged) in the arm64 copy_highpage()
> > with a comment.
> >
> > Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> > Reported-by: syzbot+d1974fc28545a3e6218b@syzkaller.appspotmail.com
> > Link: https://lore.kernel.org/r/68dda1ae.a00a0220.102ee.0065.GAE@google.com
> > Cc: <stable@vger.kernel.org> # 6.12.x
> > Cc: Will Deacon <will@kernel.org>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
> > ---
> >  arch/arm64/mm/copypage.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm64/mm/copypage.c b/arch/arm64/mm/copypage.c
> > index a86c897017df..40749d0a385c 100644
> > --- a/arch/arm64/mm/copypage.c
> > +++ b/arch/arm64/mm/copypage.c
> > @@ -51,8 +51,13 @@ void copy_highpage(struct page *to, struct page *from)
> >                 }
> >                 folio_set_hugetlb_mte_tagged(dst);
> >         } else if (page_mte_tagged(from)) {
> > -               /* It's a new page, shouldn't have been tagged yet */
> > -               WARN_ON_ONCE(!try_page_mte_tagging(to));
> 
> I think you should remove the WARN_ON_ONCE in the above hugetlb chunk
> too IIUC. migrate_huge_page_move_mapping() does the similar thing.

Good point. Thanks!

-- 
Catalin


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64: mte: Do not warn if the page is already tagged in copy_highpage()
  2025-10-22  6:19   ` Kefeng Wang
@ 2025-10-22 10:00     ` Catalin Marinas
  0 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2025-10-22 10:00 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: Yang Shi, linux-arm-kernel, linux-mm,
	syzbot+d1974fc28545a3e6218b, Will Deacon, David Hildenbrand

On Wed, Oct 22, 2025 at 02:19:19PM +0800, Kefeng Wang wrote:
> On 2025/10/22 3:00, Yang Shi wrote:
> > On Tue, Oct 21, 2025 at 11:14 AM Catalin Marinas
> > <catalin.marinas@arm.com> wrote:
> > > 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 060913999d7a ("mm: migrate:
> > > support poisoned recover from migrate folio"), __folio_mc_copy() is
> 
> no "__" prefix

Yes, I got lost in underscores. Thanks.

-- 
Catalin


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-10-22 10:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-21 18:13 [PATCH] arm64: mte: Do not warn if the page is already tagged in copy_highpage() Catalin Marinas
2025-10-21 18:23 ` David Hildenbrand
2025-10-21 19:00 ` Yang Shi
2025-10-22  6:19   ` Kefeng Wang
2025-10-22 10:00     ` Catalin Marinas
2025-10-22  9:57   ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox