From: Benjamin Gilbert <bgilbert@cs.cmu.edu>
To: Andi Kleen <andi@firstfloor.org>
Cc: akpm@linux-foundation.org, herbert@gondor.apana.org.au,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
linux@horizon.com
Subject: Re: [PATCH 3/3] [CRYPTO] Add optimized SHA-1 implementation for x86_64
Date: Mon, 11 Jun 2007 15:45:36 -0400 [thread overview]
Message-ID: <466DA660.4090102@cs.cmu.edu> (raw)
In-Reply-To: <p73lkeqvgwb.fsf@bingen.suse.de>
Andi Kleen wrote:
> Benjamin Gilbert <bgilbert@cs.cmu.edu> writes:
>> +#define EXPAND(i) \
>> + movl OFFSET(i % 16)(DATA), TMP; \
>> + xorl OFFSET((i + 2) % 16)(DATA), TMP; \
>
> Such overlapping memory accesses are somewhat dangerous as they tend
> to stall some CPUs. Better probably to do a quad load and then extract.
OFFSET(i) is defined as 4*(i), so they don't actually overlap.
(Arguably that macro should go away.)
> I haven't checked in detail if it's possible but it's suspicious you
> never use quad operations for anything. You keep at least half
> the CPU's bits idle all the time.
SHA-1 fundamentally wants to work with 32-bit quantities. It might be
possible to use quad operations for some things, with sufficient
cleverness, but I doubt it'd be worth the effort.
> Gut feeling is that the unroll factor is far too large.
> Have you tried a smaller one? That would save icache
> which is very important in the kernel.
That seems to be the consensus. I'll see if I can find some time to try
linux@horizon.com's suggestion and report back.
I don't think, though, that cache footprint is the *only* thing that
matters. Leaving aside /dev/urandom, there are cases where throughput
matters a lot. This patch set came out of some work on a hashing block
device driver in which SHA is, by far, the biggest CPU user. One could
imagine content-addressable filesystems, or even IPsec under the right
workloads, being in a similar situation.
Would it be more palatable to roll the patch as an optimized CryptoAPI
module rather than as a lib/sha1.c replacement? That wouldn't help
/dev/urandom, of course, but for other cases it would allow the user to
ask for the optimized version if needed, and not pay the footprint costs
otherwise.
--Benjamin Gilbert
next prev parent reply other threads:[~2007-06-11 19:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-08 21:42 [PATCH 0/3] Add optimized SHA-1 implementations for x86 and x86_64 Benjamin Gilbert
2007-06-08 21:42 ` [PATCH 1/3] [CRYPTO] Move sha_init() into cryptohash.h Benjamin Gilbert
2007-06-08 21:42 ` [PATCH 2/3] [CRYPTO] Add optimized SHA-1 implementation for i486+ Benjamin Gilbert
2007-06-09 7:32 ` Jan Engelhardt
2007-06-10 1:15 ` Benjamin Gilbert
2007-06-11 19:47 ` Benjamin Gilbert
2007-06-11 19:50 ` [PATCH] " Benjamin Gilbert
2007-06-11 19:52 ` [PATCH] [CRYPTO] Add optimized SHA-1 implementation for x86_64 Benjamin Gilbert
2007-06-09 20:11 ` [PATCH 2/3] [CRYPTO] Add optimized SHA-1 implementation for i486+ Matt Mackall
2007-06-09 20:23 ` Jeff Garzik
2007-06-09 21:34 ` Matt Mackall
2007-06-10 0:33 ` Benjamin Gilbert
2007-06-10 13:59 ` Matt Mackall
2007-06-10 16:47 ` Benjamin Gilbert
2007-06-10 17:33 ` Matt Mackall
2007-06-11 17:39 ` Benjamin Gilbert
2007-06-11 12:04 ` Andi Kleen
2007-06-08 21:42 ` [PATCH 3/3] [CRYPTO] Add optimized SHA-1 implementation for x86_64 Benjamin Gilbert
2007-06-11 12:01 ` Andi Kleen
2007-06-11 19:45 ` Benjamin Gilbert [this message]
2007-06-11 20:30 ` [PATCH 0/3] Add optimized SHA-1 implementations for x86 and x86_64 Adrian Bunk
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=466DA660.4090102@cs.cmu.edu \
--to=bgilbert@cs.cmu.edu \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@horizon.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.