mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] arm64: mte: use folios in __access_remote_tags()
@ 2026-10-31 20:44 Tal Zussman
  2026-10-31 20:44 ` [PATCH 1/2] arm64: mte: use a folio " Tal Zussman
  2026-10-31 20:44 ` [PATCH 2/2] arm64: mte: drop the huge zero folio check " Tal Zussman
  0 siblings, 2 replies; 5+ messages in thread
From: Tal Zussman @ 2026-10-31 20:44 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Mark Rutland
  Cc: linux-arm-kernel, linux-kernel, Tal Zussman

The first patch converts __access_remote_tags() to use folios. This
removes the last use of set_page_dirty_lock() in arm64. The second
drops an is_huge_zero_folio() check from a branch the huge zero folio
never takes.

---
Tal Zussman (2):
      arm64: mte: use a folio in __access_remote_tags()
      arm64: mte: drop the huge zero folio check in __access_remote_tags()

 arch/arm64/kernel/mte.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
---
base-commit: f46be4da2cbb17574b5369517a9a1e1b414063b4
change-id: 20261015-arm64-mte-folio-cbfb1036edf2

Best regards,
--  
Tal Zussman <tz2294@columbia.edu>


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

* [PATCH 1/2] arm64: mte: use a folio in __access_remote_tags()
  2026-10-31 20:44 [PATCH 0/2] arm64: mte: use folios in __access_remote_tags() Tal Zussman
@ 2026-10-31 20:44 ` Tal Zussman
  2026-11-26 18:15   ` Catalin Marinas
  2026-10-31 20:44 ` [PATCH 2/2] arm64: mte: drop the huge zero folio check " Tal Zussman
  1 sibling, 1 reply; 5+ messages in thread
From: Tal Zussman @ 2026-10-31 20:44 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Mark Rutland
  Cc: linux-arm-kernel, linux-kernel, Tal Zussman

__access_remote_tags() looks up the folio for the hugetlb check but
still uses the page everywhere else it can use the folio. Use the folio
for the rest, which removes the hidden compound_head() calls.

This removes the last use of set_page_dirty_lock() in arm64.

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
 arch/arm64/kernel/mte.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c
index 31f5c6b0510e..f8d39e70857e 100644
--- a/arch/arm64/kernel/mte.c
+++ b/arch/arm64/kernel/mte.c
@@ -467,6 +467,7 @@ static int __access_remote_tags(struct mm_struct *mm, unsigned long addr,
 			err = PTR_ERR(page);
 			break;
 		}
+		folio = page_folio(page);
 
 		/*
 		 * Only copy tags if the page has been mapped as PROT_MTE
@@ -477,16 +478,15 @@ static int __access_remote_tags(struct mm_struct *mm, unsigned long addr,
 		 */
 		if (!(vma->vm_flags & VM_MTE)) {
 			err = -EIO;
-			put_page(page);
+			folio_put(folio);
 			break;
 		}
 
-		folio = page_folio(page);
 		if (folio_test_hugetlb(folio))
 			WARN_ON_ONCE(!folio_test_hugetlb_mte_tagged(folio) &&
 				     !is_huge_zero_folio(folio));
 		else
-			WARN_ON_ONCE(!page_mte_tagged(page) && !is_zero_page(page));
+			WARN_ON_ONCE(!page_mte_tagged(page) && !is_zero_folio(folio));
 
 		/* limit access to the end of the page */
 		offset = offset_in_page(addr);
@@ -495,11 +495,11 @@ static int __access_remote_tags(struct mm_struct *mm, unsigned long addr,
 		maddr = page_address(page);
 		if (write) {
 			tags = mte_copy_tags_from_user(maddr + offset, buf, tags);
-			set_page_dirty_lock(page);
+			folio_mark_dirty_lock(folio);
 		} else {
 			tags = mte_copy_tags_to_user(buf, maddr + offset, tags);
 		}
-		put_page(page);
+		folio_put(folio);
 
 		/* error accessing the tracer's buffer */
 		if (!tags)

-- 
2.39.5


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

* [PATCH 2/2] arm64: mte: drop the huge zero folio check in __access_remote_tags()
  2026-10-31 20:44 [PATCH 0/2] arm64: mte: use folios in __access_remote_tags() Tal Zussman
  2026-10-31 20:44 ` [PATCH 1/2] arm64: mte: use a folio " Tal Zussman
@ 2026-10-31 20:44 ` Tal Zussman
  2026-11-26 18:28   ` Catalin Marinas
  1 sibling, 1 reply; 5+ messages in thread
From: Tal Zussman @ 2026-10-31 20:44 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Mark Rutland
  Cc: linux-arm-kernel, linux-kernel, Tal Zussman

Commit adfb6609c680 ("mm/huge_memory: initialise the tags of the huge
zero folio") added an is_huge_zero_folio() check to the hugetlb branch,
but the huge zero folio is a THP, so it is never reached. It doesn't
need to be checked in the other branch either, as its pages are tagged
by __GFP_ZEROTAGS on allocation. Remove the check.

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
 arch/arm64/kernel/mte.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c
index f8d39e70857e..8615732567e6 100644
--- a/arch/arm64/kernel/mte.c
+++ b/arch/arm64/kernel/mte.c
@@ -483,8 +483,7 @@ static int __access_remote_tags(struct mm_struct *mm, unsigned long addr,
 		}
 
 		if (folio_test_hugetlb(folio))
-			WARN_ON_ONCE(!folio_test_hugetlb_mte_tagged(folio) &&
-				     !is_huge_zero_folio(folio));
+			WARN_ON_ONCE(!folio_test_hugetlb_mte_tagged(folio));
 		else
 			WARN_ON_ONCE(!page_mte_tagged(page) && !is_zero_folio(folio));
 

-- 
2.39.5


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

* Re: [PATCH 1/2] arm64: mte: use a folio in __access_remote_tags()
  2026-10-31 20:44 ` [PATCH 1/2] arm64: mte: use a folio " Tal Zussman
@ 2026-11-26 18:15   ` Catalin Marinas
  0 siblings, 0 replies; 5+ messages in thread
From: Catalin Marinas @ 2026-11-26 18:15 UTC (permalink / raw)
  To: Tal Zussman; +Cc: Will Deacon, Mark Rutland, linux-arm-kernel, linux-kernel

On Sat, Oct 31, 2026 at 04:44:53PM -0400, Tal Zussman wrote:
> __access_remote_tags() looks up the folio for the hugetlb check but
> still uses the page everywhere else it can use the folio. Use the folio
> for the rest, which removes the hidden compound_head() calls.
> 
> This removes the last use of set_page_dirty_lock() in arm64.
> 
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

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

* Re: [PATCH 2/2] arm64: mte: drop the huge zero folio check in __access_remote_tags()
  2026-10-31 20:44 ` [PATCH 2/2] arm64: mte: drop the huge zero folio check " Tal Zussman
@ 2026-11-26 18:28   ` Catalin Marinas
  0 siblings, 0 replies; 5+ messages in thread
From: Catalin Marinas @ 2026-11-26 18:28 UTC (permalink / raw)
  To: Tal Zussman; +Cc: Will Deacon, Mark Rutland, linux-arm-kernel, linux-kernel

On Sat, Oct 31, 2026 at 04:44:54PM -0400, Tal Zussman wrote:
> Commit adfb6609c680 ("mm/huge_memory: initialise the tags of the huge
> zero folio") added an is_huge_zero_folio() check to the hugetlb branch,
> but the huge zero folio is a THP, so it is never reached. It doesn't
> need to be checked in the other branch either, as its pages are tagged
> by __GFP_ZEROTAGS on allocation. Remove the check.
> 
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
> ---
>  arch/arm64/kernel/mte.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c
> index f8d39e70857e..8615732567e6 100644
> --- a/arch/arm64/kernel/mte.c
> +++ b/arch/arm64/kernel/mte.c
> @@ -483,8 +483,7 @@ static int __access_remote_tags(struct mm_struct *mm, unsigned long addr,
>  		}
>  
>  		if (folio_test_hugetlb(folio))
> -			WARN_ON_ONCE(!folio_test_hugetlb_mte_tagged(folio) &&
> -				     !is_huge_zero_folio(folio));
> +			WARN_ON_ONCE(!folio_test_hugetlb_mte_tagged(folio));
>  		else
>  			WARN_ON_ONCE(!page_mte_tagged(page) && !is_zero_folio(folio));

Hmm, I added it to the wrong branch but it wasn't needed anyway since
the huge zero folio has PG_mte_tagged set. Patch looks fine:

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

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

end of thread, other threads:[~2026-11-26 18:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31 20:44 [PATCH 0/2] arm64: mte: use folios in __access_remote_tags() Tal Zussman
2026-10-31 20:44 ` [PATCH 1/2] arm64: mte: use a folio " Tal Zussman
2026-11-26 18:15   ` Catalin Marinas
2026-10-31 20:44 ` [PATCH 2/2] arm64: mte: drop the huge zero folio check " Tal Zussman
2026-11-26 18:28   ` Catalin Marinas

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

all inboxes | Powered by JetHome®