From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: Tom Herbert <therbert@google.com>,
davem@davemloft.net, netdev@vger.kernel.org,
jesse.brandeburg@intel.com
Subject: RE: [PATCH 1/2] net: Toeplitz library functions
Date: Tue, 24 Sep 2013 05:24:34 -0700 [thread overview]
Message-ID: <1380025474.3165.46.camel@edumazet-glaptop> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B7355@saturn3.aculab.com>
On Tue, 2013-09-24 at 09:32 +0100, David Laight wrote:
> > +static inline unsigned int
> > +toeplitz_hash(const unsigned char *bytes,
> > + struct toeplitz *toeplitz, int n)
> > +{
> > + int i;
> > + unsigned int result = 0;
> > +
> > + for (i = 0; i < n; i++)
> > + result ^= toeplitz->key_cache[i][bytes[i]];
> > +
> > + return result;
> > +};
>
> That is a horrid hash function to be calculating in software.
>
> The code looks very much like a simple 32bit CRC.
> It isn't entirely clears exactly where the 'key' gets included,
> but I suspect it is just xored with the data bytes.
>
> Using in it hardware is probably fine - the hardware can do
> it cheaply (in dedicated logic) as the frame arrives.
> The CRC polynomial probably collapses to a few XOR operations
> when done byte by byte (the hdlc crc16 collapses to 3 levels
> of xor).
>
> IIRC jhash() works on 32bit quantities - so has far fewer
> maths operations and well as not having all the random data
> accesses (cache misses and displacing other parts of the
> working set from the cache).
Anyway, I really hope Toeplitz hash is not restricted to 0-255 range
Tom implementation is not Toeplitz, but a degenerated hash.
next prev parent reply other threads:[~2013-09-24 12:24 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-23 22:41 [PATCH 1/2] net: Toeplitz library functions Tom Herbert
2013-09-24 0:03 ` Eric Dumazet
2013-09-24 1:39 ` David Miller
2013-09-24 2:30 ` Hannes Frederic Sowa
2013-09-24 3:35 ` Hannes Frederic Sowa
2013-09-24 5:38 ` Eric Dumazet
2013-09-24 5:45 ` Hannes Frederic Sowa
2013-09-24 13:19 ` [PATCH] net: net_secret should not depend on TCP Eric Dumazet
2013-09-24 15:13 ` Hannes Frederic Sowa
2013-09-24 15:22 ` Eric Dumazet
2013-09-24 15:28 ` Hannes Frederic Sowa
2013-09-24 15:46 ` Eric Dumazet
2013-09-24 23:51 ` Hannes Frederic Sowa
2013-09-28 22:20 ` David Miller
2013-09-25 9:00 ` [PATCH RFC] random: introduce get_random_bytes_busy_wait_initialized Hannes Frederic Sowa
2013-09-25 12:06 ` Eric Dumazet
2013-09-25 13:35 ` Hannes Frederic Sowa
2013-10-02 15:10 ` Theodore Ts'o
2013-10-02 17:18 ` Hannes Frederic Sowa
2013-10-02 19:40 ` Theodore Ts'o
2013-09-24 16:01 ` [PATCH 1/2] net: Toeplitz library functions Hannes Frederic Sowa
2013-09-24 16:14 ` Eric Dumazet
2013-09-24 16:35 ` Tom Herbert
2013-09-24 16:46 ` Eric Dumazet
2013-09-24 17:02 ` Ben Hutchings
2013-09-24 17:03 ` Tom Herbert
2013-09-24 17:34 ` Eric Dumazet
2013-09-24 17:37 ` Rick Jones
2013-09-24 17:44 ` Eric Dumazet
2013-09-24 18:02 ` Tom Herbert
2013-09-24 18:48 ` David Miller
2013-09-24 19:42 ` Hannes Frederic Sowa
2013-09-24 8:32 ` David Laight
2013-09-24 12:24 ` Eric Dumazet [this message]
2013-09-24 15:22 ` Tom Herbert
2013-09-24 15:29 ` Eric Dumazet
2013-09-24 15:39 ` David Miller
2013-09-24 15:54 ` Tom Herbert
2013-09-24 16:00 ` Hannes Frederic Sowa
2013-09-24 16:10 ` Eric Dumazet
2013-09-24 18:03 ` David Miller
2013-09-24 18:06 ` Tom Herbert
2013-09-24 18:10 ` Ben Hutchings
2013-09-24 18:24 ` Tom Herbert
2013-09-24 19:14 ` Eric Dumazet
2013-09-24 18:49 ` David Miller
2013-09-24 18:48 ` Jesse Brandeburg
2013-09-24 19:04 ` Tom Herbert
2013-09-24 16:38 ` Ben Hutchings
2013-09-24 16:32 ` Ben Hutchings
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=1380025474.3165.46.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=David.Laight@ACULAB.COM \
--cc=davem@davemloft.net \
--cc=jesse.brandeburg@intel.com \
--cc=netdev@vger.kernel.org \
--cc=therbert@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox