lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 22 Jul 2021 14:28:07 +0300
From:   Nikolay Borisov <>
To:     Linus Torvalds <>,
        Nikolay Borisov <>
Cc:     Linux Kernel Mailing List <>,
        Nick Desaulniers <>,
        linux-fsdevel <>,
        Dave Chinner <>
Subject: Re: [PATCH] lib/string: Bring optimized memcmp from glibc

On 21.07.21 г. 22:26, Linus Torvalds wrote:
> On Wed, Jul 21, 2021 at 11:45 AM Linus Torvalds
> <> wrote:
>> I can do the mutual alignment too, but I'd actually prefer to do it as
>> a separate patch, for when there are numbers for that.
>> And I wouldn't do it as a byte-by-byte case, because that's just stupid.
> Here's that "try to align one of the pointers in order to avoid the
> lots-of-unaligned case" patch.
> It's not quite as simple, and the generated assembly isn't quite as
> obvious. But it still generates code that looks good, it's just that
> the code to align the first pointer ends up being a bit harder to
> read.

This one also works, tested only on x86-64. Looking at the perf diff:

    30.44%    -28.66%  [kernel.vmlinux]         [k] memcmp

Comparing your 2 version that you submitted the difference is:

     1.05%     +0.72%  [kernel.vmlinux]     [k] memcmp

So the pointer alignment one is slightly more expensive. However those
measurements were done only on x86-64.

Now on a more practical note, IIUC your 2nd version makes sense if the
cost of doing a one unaligned access in the loop body is offset by the
fact we are doing a native word-sized comparison, right?


Powered by blists - more mailing lists