netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Francesco Fusco <ffusco@redhat.com>
To: jesse@nicira.com
Cc: netdev@vger.kernel.org, dev@openvswitch.org,
	Daniel Borkmann <dborkman@redhat.com>,
	Thomas Graf <tgraf@redhat.com>
Subject: [PATCH net-next v2 2/2] net: ovs: use CRC32 accelerated flow hash if available
Date: Thu, 12 Dec 2013 16:09:06 +0100	[thread overview]
Message-ID: <1386860946-1621-3-git-send-email-ffusco@redhat.com> (raw)
In-Reply-To: <1386860946-1621-1-git-send-email-ffusco@redhat.com>

Currently OVS uses jhash2() for calculating flow hashes in its
internal flow_hash() function. The performance of the flow_hash()
function is critical, as the input data can be hundreds of bytes
long.

OVS is largely deployed in x86_64 based datacenters.  Therefore,
we argue that the performance critical fast path of OVS should
exploit underlying CPU features in order to reduce the per packet
processing costs. We replace jhash2 with the hash implementation
provided by the kernel hash lib, which exploits the crc32l
instruction to achieve high performance

Our patch greatly reduces the hash footprint from ~200 cycles of
jhash2() to around ~90 cycles in case of ovs_flow_hash_crc()
(measured with rdtsc over maximum length flow keys on an i7 Intel
CPU).

Additionally, we wrote a microbenchmark to stress the flow table
performance. The benchmark inserts random flows into the flow
hash and then performs lookups. Our hash deployed on a CRC32
capable CPU reduces the lookup for 1000 flows, 100 masks from
~10,100us to ~6,700us, for example.

Thus, simply use the newly introduced arch_fast_hash2() as a
drop-in replacement.

Signed-off-by: Francesco Fusco <ffusco@redhat.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Thomas Graf <tgraf@redhat.com>
---
 net/openvswitch/flow_table.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c
index e425427..0e720c3 100644
--- a/net/openvswitch/flow_table.c
+++ b/net/openvswitch/flow_table.c
@@ -25,7 +25,7 @@
 #include <linux/if_vlan.h>
 #include <net/llc_pdu.h>
 #include <linux/kernel.h>
-#include <linux/jhash.h>
+#include <linux/hash.h>
 #include <linux/jiffies.h>
 #include <linux/llc.h>
 #include <linux/module.h>
@@ -362,7 +362,7 @@ static u32 flow_hash(const struct sw_flow_key *key, int key_start,
 	/* Make sure number of hash bytes are multiple of u32. */
 	BUILD_BUG_ON(sizeof(long) % sizeof(u32));
 
-	return jhash2(hash_key, hash_u32s, 0);
+	return arch_fast_hash2(hash_key, hash_u32s, 0);
 }
 
 static int flow_key_start(const struct sw_flow_key *key)
-- 
1.8.3.1

  reply	other threads:[~2013-12-12 15:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-12 15:09 [PATCH net-next v2 0/2] ovs: introduce arch-specific fast hashing improvements Francesco Fusco
2013-12-12 15:09 ` Francesco Fusco [this message]
2013-12-12 20:20   ` [PATCH net-next v2 2/2] net: ovs: use CRC32 accelerated flow hash if available Jesse Gross
2013-12-13  9:55     ` Francesco Fusco
2013-12-13 21:12       ` Jesse Gross
     [not found]     ` <CAEP_g=-JBT_XVvwSa4xOwVoTysoL0Z8zJc-ERSHJc96+qrA99Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-12-13 10:01       ` David Laight
2013-12-13 14:53         ` Francesco Fusco
2013-12-12 21:12 ` [PATCH net-next v2 0/2] ovs: introduce arch-specific fast hashing improvements David Miller
     [not found] ` <1386860946-1621-1-git-send-email-ffusco-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-12-12 15:09   ` [PATCH net-next v2 1/2] lib: introduce arch optimized hash library Francesco Fusco
2013-12-12 17:54     ` Nicolas Dichtel
     [not found]       ` <52A9F84F.8060500-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-12-12 18:04         ` Daniel Borkmann
2013-12-17 19:28   ` [PATCH net-next v2 0/2] ovs: introduce arch-specific fast hashing improvements 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=1386860946-1621-3-git-send-email-ffusco@redhat.com \
    --to=ffusco@redhat.com \
    --cc=dborkman@redhat.com \
    --cc=dev@openvswitch.org \
    --cc=jesse@nicira.com \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@redhat.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;
as well as URLs for NNTP newsgroup(s).