[PATCH] arm64: clear_page[s] using memset

Linus Walleij linusw at kernel.org
Tue Apr 7 02:25:55 PDT 2026


On Thu, Apr 2, 2026 at 10:57 PM Catalin Marinas <catalin.marinas at arm.com> wrote:
> On Fri, Mar 06, 2026 at 09:57:50AM +0100, Linus Walleij wrote:
> > There is no need to try to second-guess the compiler when
> > clearing memory. Just call memset() like everyone else.
>
> Hmm, that "like everyone else" made me think - why not move this to
> generic code and only the 1-2 platforms that need their own should
> override it? Could we do the same with copy_page()?
>
> Sorry, more work all of a sudden ;).

I actually had that planned, I just wanted to know if this would
be fine for arm64 first so that there is a user.

It seems you are on board so I will send a 2-patch series
next.

> > Since memset() already has an architecture-local MOPS
> > optimization, we do not need to do anything else to preserve
> > the MOPS optimization.
>
> The custom clear_page() had the (very small) advantage that it can skip
> the length/alignment checks as they are always page-size.

Yeah, it seems that is so fast that it doesn't really matter.

> > While at it, implement the shorthand for directly calling
> > the new prototype clear_pages() for larger page chunks.
> >
> > No performance regressions can be seen, the fastpath
> > benchmarks differences are in the noise.
>
> I assume the benchmarks ran on real hardware (had to ask, last time you
> mentioned qemu ;)).

Quoting my own commit message hehe:

> No performance regressions can be seen, the fastpath
> benchmarks differences are in the noise.

This was tested on hardware with Ryan Robert's fastpath tool.

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list