From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id A18C62C69 for ; Fri, 25 Mar 2016 15:41:08 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 25 Mar 2016 07:41:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,391,1455004800"; d="scan'208";a="918697035" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.220.58]) by orsmga001.jf.intel.com with SMTP; 25 Mar 2016 07:41:06 -0700 Received: by (sSMTP sendmail emulation); Fri, 25 Mar 2016 14:41:04 +0025 Date: Fri, 25 Mar 2016 14:41:04 +0000 From: Bruce Richardson To: Pablo de Lara Cc: dev@dpdk.org, edreddy@gmail.com Message-ID: <20160325144104.GB7916@bricha3-MOBL3> References: <1458827804-25496-1-git-send-email-pablo.de.lara.guarch@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1458827804-25496-1-git-send-email-pablo.de.lara.guarch@intel.com> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH] hash: fix to support multi process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2016 14:41:09 -0000 On Thu, Mar 24, 2016 at 01:56:44PM +0000, Pablo de Lara wrote: > Hash library used a function pointer to choose a different > key compare function, depending on the key size. > As a result, multiple processes could not use the same hash table, > as the function addresses vary from one process to another. > > Instead, a jump table is used, so each process has its own > function addresses, accessing this table with an index stored > in the hash table (note that using a custom key compare function > is not supported in multi-process mode). > > Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation") > > Signed-off-by: Pablo de Lara This is a hard problem to solve, but this probably looks the least-worst solution to it. Pablo, I assume the performance hit for lookups is pretty small here? One small nit in the code below, and a comment on the doc change. Otherwise, Acked-by: Bruce Richardson > --- > doc/guides/rel_notes/release_16_04.rst | 5 ++ > lib/librte_hash/rte_cuckoo_hash.c | 85 ++++++++++++++++++++++++++-------- > 2 files changed, 71 insertions(+), 19 deletions(-) > > diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst > index 2785b29..c4359dd 100644 > --- a/doc/guides/rel_notes/release_16_04.rst > +++ b/doc/guides/rel_notes/release_16_04.rst > @@ -351,6 +351,11 @@ Libraries > Fix crc32c hash functions to return a valid crc32c value for data lengths > not multiple of 4 bytes. > > +* **hash: Fixed hash library to support multi-process mode.** > + > + Fix hash library to support multi-process mode, using a jump table, > + instead of storing a function pointer to the key compare function. > + You probably need to clarify here and in the other docs (e.g. API doc) that: * multi-process mode only works with the built-in functions and key sizes. * a custom function not in the jump table can be used but only in single-process mode. > * **librte_port: Fixed segmentation fault for ring and ethdev writer nodrop.** > > Fixed core dump issue on txq and swq when dropless is set to yes. > diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c > index 71b5b76..38c19ab 100644 > --- a/lib/librte_hash/rte_cuckoo_hash.c > +++ b/lib/librte_hash/rte_cuckoo_hash.c > @@ -102,6 +102,41 @@ EAL_REGISTER_TAILQ(rte_hash_tailq) > > #define LCORE_CACHE_SIZE 8 > > +/* > + * All different options to select a key compare function, > + * based on the key size and custom function. > + */ > +enum cmp_jump_table_case { > + KEY_CUSTOM = 0, > + KEY_16_BYTES, > + KEY_32_BYTES, > + KEY_48_BYTES, > + KEY_64_BYTES, > + KEY_80_BYTES, > + KEY_96_BYTES, > + KEY_112_BYTES, > + KEY_128_BYTES, > + KEY_OTHER_BYTES, > + NUM_KEY_CMP_CASES, > +}; > + > +/* > + * Table storing all different key compare functions > + * (multi-process supported) > + */ > +rte_hash_cmp_eq_t cmp_jump_table[NUM_KEY_CMP_CASES] = { > + NULL, > + rte_hash_k16_cmp_eq, > + rte_hash_k32_cmp_eq, > + rte_hash_k48_cmp_eq, > + rte_hash_k64_cmp_eq, > + rte_hash_k80_cmp_eq, > + rte_hash_k96_cmp_eq, > + rte_hash_k112_cmp_eq, > + rte_hash_k128_cmp_eq, > + memcmp > +}; Array should be const. /Bruce