Re: [PATCH v2] arm64: clear_user: keep alignment padding out of the zeroing loop

From: Jirka Hladky

Date: Tue Nov 24 2026 - 20:56:41 EST


Hi Will,

Some additional measurements supporting the patch, to quantify the
impact beyond the /dev/zero benchmark. Since the fixed loop is the
generic zero-fill-to-userspace primitive (clear_user() /
iov_iter_zero()), the impact scales with the number of zero-filled
bytes in any workload. Same A/B pair as the commit message (Ampere
Altra, Neoverse N1, two kernels built from one tree, differing only
in the label move):

O_DIRECT read of a sparse NTFS3 file (2 GiB, fully sparse; ntfs3
zero-fills such reads directly into the user buffer via
iov_iter_zero(), no page cache involved):

kernel instructions per MiB: 791.1k -> 528.8k
throughput: 11.9 GB/s -> 25.6 GB/s (+116%)

The instruction delta is again exactly the two removed NOPs (262.3k
per MiB at 8 bytes per iteration). The gain is larger than for
/dev/zero (+92%) because ntfs3 zero-fills the whole 1 MiB read in a
single clear_user() call, while read_zero() clears in 4 KiB chunks.

/proc/kcore read (1 GiB): 1064.4k -> 990.7k kernel instructions per
MiB (-6.9%), throughput unchanged, as the remaining ~72% of kcore
bytes are real memory copies. The arithmetic implies about 28% of
/proc/kcore read bytes are zero-filled holes.

For completeness, tmpfs hole reads do not benefit: mm/shmem.c
deliberately copies the zero page instead of calling clear_user()
("Copy to user tends to be so well optimized, but clear_user() not
so much, that it is noticeably faster to copy the zero page instead
of clearing"), which reads like an existing workaround for exactly
the cost this patch removes.

By code inspection, the same zero-fill path serves sparse reads on
Ceph, SMB and netfs, so those are the likely real-world
beneficiaries.

Jirka