Netdev List
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: joamaki@gmail.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] xfrm: xfrm hash to use Jenkins' hash
Date: Wed, 05 Aug 2009 12:08:31 -0700 (PDT)	[thread overview]
Message-ID: <20090805.120831.66033097.davem@davemloft.net> (raw)
In-Reply-To: <ce10d01f0908050041p43c308fav72ac640f665e161f@mail.gmail.com>

From: Jussi Mäki <joamaki@gmail.com>
Date: Wed, 5 Aug 2009 10:41:42 +0300

> Hi,
> 
> The current xfrm hash functions perform very poorly when a number of
> policies have the same
> last byte in source and destination addresses.
> 
> For example with __xfrm_dst_hash, hmask of 0xfff:
> 
> 192.168.0.1-172.16.0.1 hashes to 3258
> 192.168.0.2-172.16.0.2 hashes to 3258
> ... and so on.
> 
> This patch addresses the issue by rewriting the xfrm
> hash functions to use the Jenkins' hash function.
> 
> Signed-off-by: Jussi Maki <joamaki@gmail.com>

jhash expands to a lot of code, and given your description of the
problem, you could have fixed it by adding 2 instructions (see below)
instead of 20 or 30 (jhash instruction count) at every hash
calculation site.

Simply change every instance of:

	(h >> 16)

with

	((h >> 16) ^ (h >> 24))

As much as I love jhash, it's overkill for fixing this problem.

And if we do end up using jhash, it should get inlined into a
seperate non-inline function instead of expanding that monster
4 or 5 times throughout the XFRM code.

I'm not applying this, either make the simple one-liner fix I
suggested above work or move the jhash into a non-inline expansion.

  parent reply	other threads:[~2009-08-05 19:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-05  7:41 [PATCH] xfrm: xfrm hash to use Jenkins' hash Jussi Mäki
2009-08-05  8:39 ` Jussi Maki
2009-08-05 19:08 ` David Miller [this message]
2009-08-06  6:32   ` Jussi Maki
2009-08-06  8:58     ` Jussi Maki
2009-08-06 17:40       ` David Miller
2009-08-07  7:38         ` [PATCH] Fix xfrm hash collisions by changing __xfrm4_daddr_saddr_hash to hash addresses with addition Jussi Maki
2009-08-10  4:52           ` David Miller
2009-08-13  2:06           ` Herbert Xu
2009-08-13  3:42             ` David Miller
2009-08-13  3:53               ` Herbert Xu
2009-08-13  3:56                 ` David Miller
2009-08-13  4:11                   ` Herbert Xu
2009-08-13  4:18                     ` David Miller
2009-08-13  4:19                   ` Herbert Xu
2009-08-06 17:40     ` [PATCH] xfrm: xfrm hash to use Jenkins' hash David Miller

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=20090805.120831.66033097.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=joamaki@gmail.com \
    --cc=netdev@vger.kernel.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