Re: [PATCH] arm64: clear_user: align __arch_clear_user() to 128B for I-cache efficiency

From: Jirka Hladky

Date: Tue Nov 24 2026 - 18:54:41 EST


Hi Norman,

Thank you for the excellent analysis, and for pinpointing that the
root cause is in clear_user.S itself rather than in where the
function lands.

We reproduced your findings on bare-metal Ampere Altra (Neoverse N1,
no FEAT_MOPS) and can confirm them end to end.

Disassembling __arch_clear_user() out of /proc/kcore on the running
kernels, both the ELN 7.3.0-65 and 7.4.0-0.rc3 builds we tested carry
exactly two NOPs between the loop-back branch target and the first
sttr, i.e. the padding you described.

To isolate the change, we built two kernels from the same tree, same
config and toolchain, differing only in the label move (your one-line
fix): the unpatched build has the two NOPs in the loop, the patched
build branches directly to the sttr. Reading 4 GiB from /dev/zero
(performance governor, pinned CPU, median of 3 runs):

unpatched patched
kernel instr/MiB 797.5k 536.4k
throughput 11.6 GB/s 22.3 GB/s

The instruction counts match your measurements almost exactly, and
the delta (261.1k per MiB) is precisely the two NOPs at 8 bytes per
iteration (2 x 131072). On N1 the throughput effect is even larger
than on your A76: +92%.

The unpatched rebuild also reproduces the stock ELN kernel's numbers
exactly, so the only variable in the comparison above is the
one-line fix.

I have posted the reworked patch as [PATCH v2] in this thread:

https://lore.kernel.org/all/20261124233043.1289050-1-jhladky@xxxxxxxxxx/

with your diagnosis credited in the commit message and a Suggested-by
trailer.

Thanks again,
Jirka