From: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
To: bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com
Cc: dev@dpdk.org, gavin.hu@arm.com, dharmik.thakkar@arm.com,
nd@arm.com, yipeng1.wang@intel.com, sameh.gobriel@intel.com,
Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Subject: [dpdk-dev] [PATCH v2 2/4] hash: deprecate lock ellision and read/write concurreny flags
Date: Thu, 1 Nov 2018 18:25:20 -0500 [thread overview]
Message-ID: <20181101232522.702-3-honnappa.nagarahalli@arm.com> (raw)
In-Reply-To: <20181101232522.702-1-honnappa.nagarahalli@arm.com>
Hash library should provide read/write concurrency by default
as most of the use cases require read/write concurrency. Hence
the flag RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY is deprecated.
The library will decide if locking is required to provide
the concurrency based on other configuration flags.
If a lock is used to provide the read/write concurrency, best
possible locking mechanism available on the platform should
be used. Hence, the flag RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT
is deprecated. The library will use transactional memory
if the platform supports it.
Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
---
lib/librte_hash/rte_cuckoo_hash.c | 46 +++++++++++-----------------
lib/librte_hash/rte_hash.h | 20 ++++++++++--
lib/librte_hash/rte_hash_version.map | 7 +++++
3 files changed, 43 insertions(+), 30 deletions(-)
diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index ec3b519ba..7f97cddd4 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -121,7 +121,7 @@ get_alt_bucket_index(const struct rte_hash *h,
}
struct rte_hash *
-rte_hash_create(const struct rte_hash_parameters *params)
+rte_hash_create_v20(const struct rte_hash_parameters *params)
{
struct rte_hash *h = NULL;
struct rte_tailq_entry *te = NULL;
@@ -446,6 +446,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
rte_free(tbl_chng_cnt);
return NULL;
}
+VERSION_SYMBOL(rte_hash_create, _v20, 2.0);
struct rte_hash *
rte_hash_create_v1811(const struct rte_hash_parameters *params)
@@ -463,10 +464,10 @@ rte_hash_create_v1811(const struct rte_hash_parameters *params)
char ext_ring_name[RTE_RING_NAMESIZE];
unsigned num_key_slots;
unsigned i;
- unsigned int hw_trans_mem_support = 0, use_local_cache = 0;
+ unsigned int use_local_cache = 0;
unsigned int ext_table_support = 0;
- unsigned int readwrite_concur_support = 0;
- unsigned int writer_takes_lock = 0;
+ unsigned int readwrite_concur_support = 1;
+ unsigned int writer_takes_lock = 1;
unsigned int no_free_on_del = 0;
uint32_t *tbl_chng_cnt = NULL;
unsigned int readwrite_concur_lf_support = 0;
@@ -490,14 +491,6 @@ rte_hash_create_v1811(const struct rte_hash_parameters *params)
}
/* Validate correct usage of extra options */
- if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) &&
- (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) {
- rte_errno = EINVAL;
- RTE_LOG(ERR, HASH, "rte_hash_create: choose rw concurrency or "
- "rw concurrency lock free\n");
- return NULL;
- }
-
if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF) &&
(params->extra_flag & RTE_HASH_EXTRA_FLAGS_EXT_TABLE)) {
rte_errno = EINVAL;
@@ -506,18 +499,8 @@ rte_hash_create_v1811(const struct rte_hash_parameters *params)
}
/* Check extra flags field to check extra options. */
- if (params->extra_flag & RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT)
- hw_trans_mem_support = 1;
-
- if (params->extra_flag & RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD) {
+ if (params->extra_flag & RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD)
use_local_cache = 1;
- writer_takes_lock = 1;
- }
-
- if (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) {
- readwrite_concur_support = 1;
- writer_takes_lock = 1;
- }
if (params->extra_flag & RTE_HASH_EXTRA_FLAGS_EXT_TABLE)
ext_table_support = 1;
@@ -526,11 +509,17 @@ rte_hash_create_v1811(const struct rte_hash_parameters *params)
no_free_on_del = 1;
if (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF) {
+ /* Do not use lock for RW concurrency */
+ readwrite_concur_support = 0;
readwrite_concur_lf_support = 1;
/* Enable not freeing internal memory/index on delete */
no_free_on_del = 1;
}
+ if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF) &&
+ !(params->extra_flag & RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD))
+ writer_takes_lock = 0;
+
/* Store all keys and leave the first entry as a dummy entry
* for lookup_bulk.
*/
@@ -725,7 +714,7 @@ rte_hash_create_v1811(const struct rte_hash_parameters *params)
h->free_slots = r;
h->tbl_chng_cnt = tbl_chng_cnt;
*h->tbl_chng_cnt = 0;
- h->hw_trans_mem_support = hw_trans_mem_support;
+ h->hw_trans_mem_support = rte_tm_supported();
h->use_local_cache = use_local_cache;
h->readwrite_concur_support = readwrite_concur_support;
h->ext_table_support = ext_table_support;
@@ -740,10 +729,6 @@ rte_hash_create_v1811(const struct rte_hash_parameters *params)
#endif
h->sig_cmp_fn = RTE_HASH_COMPARE_SCALAR;
- /* Writer threads need to take the lock when:
- * 1) RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY is enabled OR
- * 2) RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD is enabled
- */
if (h->writer_takes_lock) {
h->readwrite_lock = rte_malloc(NULL, sizeof(rte_rwlock_t),
RTE_CACHE_LINE_SIZE);
@@ -775,6 +760,11 @@ rte_hash_create_v1811(const struct rte_hash_parameters *params)
rte_free(tbl_chng_cnt);
return NULL;
}
+BIND_DEFAULT_SYMBOL(rte_hash_create, _v1811, 18.11);
+MAP_STATIC_SYMBOL(
+ struct rte_hash *rte_hash_create(
+ const struct rte_hash_parameters *params),
+ rte_hash_create_v1811);
void
rte_hash_free(struct rte_hash *h)
diff --git a/lib/librte_hash/rte_hash.h b/lib/librte_hash/rte_hash.h
index f049b9dd0..93c7019ec 100644
--- a/lib/librte_hash/rte_hash.h
+++ b/lib/librte_hash/rte_hash.h
@@ -30,13 +30,27 @@ extern "C" {
#define RTE_HASH_LOOKUP_BULK_MAX 64
#define RTE_HASH_LOOKUP_MULTI_MAX RTE_HASH_LOOKUP_BULK_MAX
-/** Enable Hardware transactional memory support. */
+/**
+ * @deprecated
+ * This define will be removed in the next release.
+ * If the target platform supports hardware transactional memory
+ * it will be used without user consent as it provides the best possible
+ * performance.
+ *
+ * Enable Hardware transactional memory support.
+ */
#define RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT 0x01
/** Default behavior of insertion, single writer/multi writer */
#define RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD 0x02
-/** Flag to support reader writer concurrency */
+/**
+ * @deprecated
+ * This define will be removed in the next release.
+ * This library should be thread-safe by default.
+ *
+ * Flag to support reader writer concurrency
+ */
#define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY 0x04
/** Flag to indicate the extendabe bucket table feature should be used */
@@ -106,6 +120,8 @@ struct rte_hash;
struct rte_hash *
rte_hash_create(const struct rte_hash_parameters *params);
struct rte_hash *
+rte_hash_create_v20(const struct rte_hash_parameters *params);
+struct rte_hash *
rte_hash_create_v1811(const struct rte_hash_parameters *params);
/**
diff --git a/lib/librte_hash/rte_hash_version.map b/lib/librte_hash/rte_hash_version.map
index 734ae28b0..c72469099 100644
--- a/lib/librte_hash/rte_hash_version.map
+++ b/lib/librte_hash/rte_hash_version.map
@@ -54,6 +54,13 @@ DPDK_18.08 {
} DPDK_16.07;
+DPDK_18.11 {
+ global:
+
+ rte_hash_create;
+
+} DPDK_18.08;
+
EXPERIMENTAL {
global:
--
2.17.1
next prev parent reply other threads:[~2018-11-01 23:25 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 21:48 [dpdk-dev] [PATCH v1 0/3] Improvements over rte hash and tests Yipeng Wang
2018-10-10 21:48 ` [dpdk-dev] [PATCH v1 1/3] hash: fix unnecessary pause Yipeng Wang
2018-10-10 21:48 ` [dpdk-dev] [PATCH v1 2/3] test/hash: change multiwriter test to use jhash Yipeng Wang
2018-10-11 11:27 ` Bruce Richardson
2018-10-10 21:48 ` [dpdk-dev] [PATCH v1 3/3] test/hash: add readwrite test for ext table Yipeng Wang
2018-10-24 20:36 ` Bruce Richardson
2018-10-25 1:06 ` Wang, Yipeng1
2018-10-26 0:23 ` Honnappa Nagarahalli
2018-10-26 10:12 ` Bruce Richardson
2018-10-29 5:54 ` Honnappa Nagarahalli
2018-10-31 4:21 ` Honnappa Nagarahalli
2018-11-01 4:54 ` [dpdk-dev] [PATCH 0/3] hash: deprecate lock ellision and read/write concurreny flags Honnappa Nagarahalli
2018-11-01 4:54 ` [dpdk-dev] [PATCH 1/3] " Honnappa Nagarahalli
2018-11-01 9:45 ` Bruce Richardson
2018-11-01 9:48 ` Bruce Richardson
2018-11-01 19:43 ` Honnappa Nagarahalli
2018-11-02 11:11 ` Bruce Richardson
2018-11-01 23:25 ` [dpdk-dev] [PATCH v2 0/4] " Honnappa Nagarahalli
2018-11-01 23:25 ` [dpdk-dev] [PATCH v2 1/4] hash: prepare for deprecation of flags Honnappa Nagarahalli
2018-11-02 11:14 ` Bruce Richardson
2018-11-01 23:25 ` Honnappa Nagarahalli [this message]
2018-11-01 23:25 ` [dpdk-dev] [PATCH v2 3/4] test/hash: stop using lock ellision and read/write concurreny flags Honnappa Nagarahalli
2018-11-01 23:25 ` [dpdk-dev] [PATCH v2 4/4] doc/hash: deprecate " Honnappa Nagarahalli
2018-11-02 11:21 ` Bruce Richardson
2018-11-02 11:25 ` [dpdk-dev] [PATCH v2 0/4] hash: " Bruce Richardson
2018-11-02 17:38 ` Honnappa Nagarahalli
2018-12-20 20:10 ` Yigit, Ferruh
2018-11-01 4:54 ` [dpdk-dev] [PATCH 2/3] test/hash: stop using " Honnappa Nagarahalli
2018-11-01 4:54 ` [dpdk-dev] [PATCH 3/3] doc/hash: deprecate " Honnappa Nagarahalli
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=20181101232522.702-3-honnappa.nagarahalli@arm.com \
--to=honnappa.nagarahalli@arm.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=dharmik.thakkar@arm.com \
--cc=gavin.hu@arm.com \
--cc=nd@arm.com \
--cc=pablo.de.lara.guarch@intel.com \
--cc=sameh.gobriel@intel.com \
--cc=yipeng1.wang@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).