From: Matthew Wilcox <willy@infradead.org>
To: Nikolay Borisov <nborisov@suse.com>
Cc: Dave Chinner <david@fromorbit.com>,
linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
djwong@kernel.org
Subject: Re: [PATCH] vfs: Optimize dedupe comparison
Date: Tue, 20 Jul 2021 16:12:01 +0100 [thread overview]
Message-ID: <YPbnwbXUw1dVbQIF@casper.infradead.org> (raw)
In-Reply-To: <dba60154-874e-b6b9-21c4-5c2d9735029a@suse.com>
On Tue, Jul 20, 2021 at 05:58:39PM +0300, Nikolay Borisov wrote:
>
>
> On 16.07.21 г. 1:33, Dave Chinner wrote:
> > On Thu, Jul 15, 2021 at 04:09:06PM +0100, Matthew Wilcox wrote:
> >> On Thu, Jul 15, 2021 at 05:44:15PM +0300, Nikolay Borisov wrote:
> >>> I was wondering the same thing, but AFAICS it seems to be possible i.e
> >>> if userspace spaces bad offsets, while all kinds of internal fs
> >>> synchronization ops are going to be performed on aligned offsets, that
> >>> doesn't mean the original ones, passed from userspace are themselves
> >>> aligned explicitly.
> >>
> >> Ah, I thought it'd be failed before we got to this point.
> >>
> >> But honestly, I think x86-64 needs to be fixed to either use
> >> __builtin_memcmp() or to have a nicely written custom memcmp(). I
> >> tried to find the gcc implementation of __builtin_memcmp() on
> >> x86-64, but I can't.
> >
> > Yup, this. memcmp() is widley used in hot paths through all the
> > filesystem code and the rest of the kernel. We should fix the
> > generic infrastructure problem, not play whack-a-mole to with custom
> > one-off fixes that avoid the problem just where it shows up in some
> > profile...
>
> I ported glibc's implementation of memcmp to the kernel and after
> running the same workload I get the same performance as with the basic
> memcmp implementation of doing byte comparison ...
That's bizarre because the glibc memcmp that you pointed to earlier
basically does what your open-coded solution did. Is it possible
you have a bug in one of the tests and it's falling back to the byte
loop?
Specifically for the dedup case, we only need the optimisation that
if ((p1 | p2 | length) & 7)
... do the byte loop ...
... do the long-based comparison ...
so another possibility is that memcmp is doing too many tests.
next prev parent reply other threads:[~2021-07-20 15:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-15 14:13 [PATCH] vfs: Optimize dedupe comparison Nikolay Borisov
2021-07-15 14:30 ` Matthew Wilcox
2021-07-15 14:44 ` Nikolay Borisov
2021-07-15 15:09 ` Matthew Wilcox
2021-07-15 22:33 ` Dave Chinner
2021-07-20 14:58 ` Nikolay Borisov
2021-07-20 15:12 ` Matthew Wilcox [this message]
2021-07-16 12:10 ` Nikolay Borisov
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=YPbnwbXUw1dVbQIF@casper.infradead.org \
--to=willy@infradead.org \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=nborisov@suse.com \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).