From: Arnd Bergmann <arnd@arndb.de>
To: linuxppc-dev@lists.ozlabs.org
Cc: paulus@samba.org, Anton Blanchard <anton@samba.org>
Subject: Re: [PATCH 1/2] powerpc: Add 64bit optimised memcmp
Date: Wed, 21 Jan 2015 10:26:15 +0100 [thread overview]
Message-ID: <3008920.kfIvkVJRyU@wuerfel> (raw)
In-Reply-To: <1421803659-10678-1-git-send-email-anton@samba.org>
On Wednesday 21 January 2015 12:27:38 Anton Blanchard wrote:
> I noticed ksm spending quite a lot of time in memcmp on a large
> KVM box. The current memcmp loop is very unoptimised - byte at a
> time compares with no loop unrolling. We can do much much better.
>
> Optimise the loop in a few ways:
>
> - Unroll the byte at a time loop
>
> - For large (at least 32 byte) comparisons that are also 8 byte
> aligned, use an unrolled modulo scheduled loop using 8 byte
> loads. This is similar to our glibc memcmp.
>
> A simple microbenchmark testing 10000000 iterations of an 8192 byte
> memcmp was used to measure the performance:
>
> baseline: 29.93 s
>
> modified: 1.70 s
>
> Just over 17x faster.
>
> v2: Incorporated some suggestions from Segher:
>
> - Use andi. instead of rdlicl.
>
> - Convert bdnzt eq, to bdnz. It's just duplicating the earlier compare
> and was a relic from a previous version.
>
> - Don't use cr5, we have plans to use that CR field for fast local
> atomics.
>
> Signed-off-by: Anton Blanchard <anton@samba.org>
Would it help to also add a way for an architecture to override
memcmp_pages() with its own implementation? That way you could
skip the unaligned part, hardcode the loop counter and avoid the
preempt_disable() in kmap_atomic().
Arnd
next prev parent reply other threads:[~2015-01-21 9:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-21 1:27 [PATCH 1/2] powerpc: Add 64bit optimised memcmp Anton Blanchard
2015-01-21 1:27 ` [PATCH 2/2] powerpc: Add memcmp testcase Anton Blanchard
2015-01-21 9:26 ` Arnd Bergmann [this message]
2015-01-21 12:06 ` [PATCH 1/2] powerpc: Add 64bit optimised memcmp Anton Blanchard
-- strict thread matches above, loose matches on Subject: below --
2015-01-09 1:56 Anton Blanchard
2015-01-09 10:06 ` David Laight
2015-01-12 0:55 ` Anton Blanchard
2015-01-12 6:55 ` Joakim Tjernlund
2015-01-12 9:45 ` David Laight
2015-01-09 11:01 ` Adhemerval Zanella
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=3008920.kfIvkVJRyU@wuerfel \
--to=arnd@arndb.de \
--cc=anton@samba.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.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;
as well as URLs for NNTP newsgroup(s).