Re: [patch 103/147] lib/string: optimized memset

From: Matteo Croce
Date: Thu Sep 09 2021 - 06:27:22 EST


On Wed, 8 Sep 2021 11:34:27 -0700
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> I'm dropping this one just to be consistent, although for memset()
> it's possibly a bit more reasonable to fall back on some default.
>
> But probably not. memcpy and memset really are *so* special that these
> generic versions should be considered to be "stupid placeholders for
> bringup, and nothing more".
>
> On Tue, Sep 7, 2021 at 7:58 PM Andrew Morton
> <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > On a RISC-V machine the speed goes from 140 Mb/s to 241 Mb/s, and
> > this the binary size increase according to bloat-o-meter:
>
> I also react to the benchmark numbers: RISC-V already has
>
> #define __HAVE_ARCH_MEMSET
> #define __HAVE_ARCH_MEMCPY
> #define __HAVE_ARCH_MEMMOVE
>
> in its <asm/string.h> file, so these are just odd.
>
> Did you benchmark these generic functions on their own, rather than
> the ones that actually get *used*?
>
> Linus

I benchmarked against the generic routines. The RISC-V specific are
even slower than the generic ones, because generates lot of unaligned
accesses.

That was the whole point of the series initially. These C routines
should have replaced the risc-v specific assembly ones, but then it was
proposed to use them as generic:

https://lore.kernel.org/linux-riscv/YNChl0tkofSGzvIX@xxxxxxxxxxxxx/

--
per aspera ad upstream