From: Bruce Richardson <bruce.richardson@intel.com>
To: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Cc: dev@dpdk.org, edreddy@gmail.com
Subject: Re: [dpdk-dev] [PATCH] hash: fix to support multi process
Date: Fri, 25 Mar 2016 14:41:04 +0000 [thread overview]
Message-ID: <20160325144104.GB7916@bricha3-MOBL3> (raw)
In-Reply-To: <1458827804-25496-1-git-send-email-pablo.de.lara.guarch@intel.com>
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 <pablo.de.lara.guarch@intel.com>
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 <bruce.richardson@intel.com>
> ---
> 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
next prev parent reply other threads:[~2016-03-25 14:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-24 13:56 Pablo de Lara
2016-03-25 14:41 ` Bruce Richardson [this message]
2016-03-25 15:08 ` De Lara Guarch, Pablo
2016-03-30 17:34 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
2016-04-01 13:07 ` Thomas Monjalon
2016-04-01 14:08 ` De Lara Guarch, Pablo
2016-04-01 15:03 ` [dpdk-dev] [PATCH v3 0/2] Multi-process support in hash library Pablo de Lara
2016-04-01 15:03 ` [dpdk-dev] [PATCH v3 1/2] hash: use RTE_ARCH_X86 macro for X86 systems Pablo de Lara
2016-04-01 15:03 ` [dpdk-dev] [PATCH v3 2/2] hash: fix to support multi process Pablo de Lara
2016-04-01 16:57 ` [dpdk-dev] [PATCH v3 0/2] Multi-process support in hash library Thomas Monjalon
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=20160325144104.GB7916@bricha3-MOBL3 \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=edreddy@gmail.com \
--cc=pablo.de.lara.guarch@intel.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).