[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <eef30b51-c69f-0e70-11a8-c35f90aeca67@gmail.com>
Date: Thu, 22 Jul 2021 14:28:07 +0300
From: Nikolay Borisov <n.borisov.lkml@...il.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>,
Nikolay Borisov <nborisov@...e.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Dave Chinner <david@...morbit.com>
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
> <torvalds@...ux-foundation.org> 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?
<snip>
Powered by blists - more mailing lists