From: Nikolay Borisov <n.borisov.lkml@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Nikolay Borisov <nborisov@suse.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Dave Chinner <david@fromorbit.com>
Subject: Re: [PATCH] lib/string: Bring optimized memcmp from glibc
Date: Thu, 22 Jul 2021 14:28:07 +0300 [thread overview]
Message-ID: <eef30b51-c69f-0e70-11a8-c35f90aeca67@gmail.com> (raw)
In-Reply-To: <CAHk-=wgr3JSoasv3Kyzc0u-L36oAr=hzY9oUrCxaszWaxgLW0A@mail.gmail.com>
On 21.07.21 г. 22:26, Linus Torvalds wrote:
> On Wed, Jul 21, 2021 at 11:45 AM Linus Torvalds
> <torvalds@linux-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>
next prev parent reply other threads:[~2021-07-22 11:28 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 13:59 [PATCH] lib/string: Bring optimized memcmp from glibc Nikolay Borisov
2021-07-21 14:32 ` Christoph Hellwig
2021-07-21 14:35 ` Nikolay Borisov
2021-07-21 14:42 ` Christoph Hellwig
2021-07-21 14:51 ` Matthew Wilcox
2021-07-21 15:17 ` Peter.Enderborg
2021-07-21 15:34 ` Matthew Wilcox
2021-07-21 15:39 ` Peter.Enderborg
2021-07-21 18:00 ` Linus Torvalds
2021-07-21 18:17 ` Nikolay Borisov
2021-07-21 18:45 ` Linus Torvalds
2021-07-21 18:55 ` Linus Torvalds
2021-07-21 19:26 ` Linus Torvalds
2021-07-22 11:28 ` Nikolay Borisov [this message]
2021-07-22 16:40 ` Linus Torvalds
2021-07-22 17:03 ` Nikolay Borisov
2021-08-26 9:03 ` Nikolay Borisov
2021-07-22 8:28 ` Nikolay Borisov
2021-07-23 14:02 ` David Laight
2021-07-21 20:10 ` David Sterba
2021-07-21 20:27 ` Linus Torvalds
2021-07-22 5:54 ` Nikolay Borisov
2021-07-28 20:12 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eef30b51-c69f-0e70-11a8-c35f90aeca67@gmail.com \
--to=n.borisov.lkml@gmail.com \
--cc=david@fromorbit.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nborisov@suse.com \
--cc=ndesaulniers@google.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox