[PATCH 2/5] arm64: Use STZGM in __mte_tag_clear_page()
Pierre-Clément Tosi
ptosi at google.com
Tue Dec 1 07:00:53 PST 2026
Prefer STZGM over STZ2G when DC GZVA isn't available (DCZID_EL0.DZP=1).
This speeds up mte_clear_page() by ~1.7-2.0x on Cortex-A7xx and C1-Pro
and ~1.85-1.95x on Cortex-X3/X4 with warm caches. With cold caches,
STZGM stalls seem to be slightly worse (~0.90-0.96x) on these.
The big gains are with the C1-Ultra: ~8.15x (!!) with warm caches and
~4-5x (!) when cold, probably because it now enters streaming mode.
Unfortunately, there is a non-negligible regression on Cortex-A5xx of
~0.68-0.75x (warm) and ~0.85-1.03x (cold) but this seems to be worth the
gains on the larger cores.
Signed-off-by: Pierre-Clément Tosi <ptosi at google.com>
---
arch/arm64/include/asm/mte-tagging.h | 4 ++--
arch/arm64/lib/mte.S | 6 ++----
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/arch/arm64/include/asm/mte-tagging.h b/arch/arm64/include/asm/mte-tagging.h
index f491682ba418..9c8b39d2dd97 100644
--- a/arch/arm64/include/asm/mte-tagging.h
+++ b/arch/arm64/include/asm/mte-tagging.h
@@ -24,13 +24,13 @@ static __always_inline void mte_tag_pages(void *addr, unsigned long npages,
} while (--npages);
}
-void __mte_tag_clear_page(void *p);
+void __mte_tag_clear_page(void *p, u64 t);
static __always_inline void mte_tag_clear_pages(void *addr,
unsigned long npages, u8 tag)
{
addr = mte_tagged(addr, tag);
do {
- __mte_tag_clear_page(addr);
+ __mte_tag_clear_page(addr, tag);
addr += PAGE_SIZE;
} while (--npages);
}
diff --git a/arch/arm64/lib/mte.S b/arch/arm64/lib/mte.S
index 1b1b76472f62..0b753db99114 100644
--- a/arch/arm64/lib/mte.S
+++ b/arch/arm64/lib/mte.S
@@ -67,15 +67,13 @@ SYM_FUNC_END(__mte_tag_page)
/*
* Tag a page and clear its data.
* x0 - page address (pre-tagged)
+ * x1 - tag
*/
SYM_FUNC_START(__mte_tag_clear_page)
dczid_bs x5, x6, x7, 1f
blk_ops dc, gzva, x0, x5
1:
- stz2g x0, [x0], #(MTE_GRANULE_SIZE * 2)
- tst x0, #(PAGE_SIZE - 1)
- b.ne 1b
- ret
+ blk_ops stzgm, x1, x0, x5
SYM_FUNC_END(__mte_tag_clear_page)
/*
--
2.56.1.839.g22a8290db9-goog
More information about the linux-arm-kernel
mailing list