Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1540128
| From | Linus Torvalds <torvalds@linux-foundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2] siphash: add cryptographically secure hashtable function |
| Date | 2016-12-12 05:10 +0100 |
| Message-ID | <sNq65-80d-3@gated-at.bofh.it> (permalink) |
| References | <sNjeh-3HG-1@gated-at.bofh.it> <sNpMJ-7EK-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sun, Dec 11, 2016 at 7:48 PM, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> + switch (left) {
> + case 7: b |= ((u64)data[6]) << 48;
> + case 6: b |= ((u64)data[5]) << 40;
> + case 5: b |= ((u64)data[4]) << 32;
> + case 4: b |= ((u64)data[3]) << 24;
> + case 3: b |= ((u64)data[2]) << 16;
> + case 2: b |= ((u64)data[1]) << 8;
> + case 1: b |= ((u64)data[0]); break;
> + case 0: break;
> + }
The above is extremely inefficient. Considering that most kernel data
would be expected to be smallish, that matters (ie the usual benchmark
would not be about hashing megabytes of data, but instead millions of
hashes of small data).
I think this could be rewritten (at least for 64-bit architectures) as
#ifdef CONFIG_DCACHE_WORD_ACCESS
if (left)
b |= le64_to_cpu(load_unaligned_zeropad(data) &
bytemask_from_count(left));
#else
.. do the duff's device thing with the switch() ..
#endif
which should give you basically perfect code generation (ie a single
64-bit load and a byte mask).
Totally untested, just looking at the code and trying to make sense of it.
... and obviously, it requires an actual high-performance use-case to
make any difference.
Linus
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] siphash: add cryptographically secure hashtable function "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-09 19:40 +0100
Re: [kernel-hardening] [PATCH] siphash: add cryptographically secure hashtable function Greg KH <gregkh@linuxfoundation.org> - 2016-12-10 13:40 +0100
Re: [kernel-hardening] [PATCH] siphash: add cryptographically secure hashtable function "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-11 16:40 +0100
Re: [kernel-hardening] [PATCH] siphash: add cryptographically secure hashtable function Greg KH <gregkh@linuxfoundation.org> - 2016-12-11 21:50 +0100
[PATCH v2] siphash: add cryptographically secure hashtable function "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-12 04:50 +0100
Re: [PATCH v2] siphash: add cryptographically secure hashtable function Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-12 05:10 +0100
Re: [PATCH v2] siphash: add cryptographically secure hashtable function "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-12 06:50 +0100
Re: [PATCH v2] siphash: add cryptographically secure hashtable function Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-12 22:40 +0100
[PATCH v3] siphash: add cryptographically secure hashtable function "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-12 23:30 +0100
Re: [PATCH v3] siphash: add cryptographically secure hashtable function Andi Kleen <ak@linux.intel.com> - 2016-12-13 00:10 +0100
Re: [PATCH v3] siphash: add cryptographically secure hashtable function Eric Biggers <ebiggers3@gmail.com> - 2016-12-13 09:50 +0100
Re: [PATCH v3] siphash: add cryptographically secure hashtable function Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-13 20:30 +0100
Re: [PATCH v3] siphash: add cryptographically secure hashtable function "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-13 23:50 +0100
[PATCH v4] siphash: add cryptographically secure hashtable function "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-13 23:50 +0100
Re: [PATCH v2] siphash: add cryptographically secure hashtable function Eric Biggers <ebiggers3@gmail.com> - 2016-12-12 06:50 +0100
Re: [PATCH v2] siphash: add cryptographically secure hashtable function "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-12 22:20 +0100
Re: [PATCH] siphash: add cryptographically secure hashtable function Vegard Nossum <vegard.nossum@gmail.com> - 2016-12-10 15:20 +0100
Re: [PATCH] siphash: add cryptographically secure hashtable function "George Spelvin" <linux@sciencehorizons.net> - 2016-12-10 16:50 +0100
csiph-web