patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 1/2] hash: fix unlimited cuckoo path
@ 2016-11-09 17:22 Pablo de Lara
  2016-11-09 17:22 ` [dpdk-stable] [PATCH 2/2] hash: fix bucket size usage Pablo de Lara
  2016-11-15  8:55 ` [dpdk-stable] [PATCH 1/2] hash: fix unlimited cuckoo path Yuanhan Liu
  0 siblings, 2 replies; 3+ messages in thread
From: Pablo de Lara @ 2016-11-09 17:22 UTC (permalink / raw)
  To: stable; +Cc: yuanhan.liu, Pablo de Lara

When trying to insert a new entry, if its target bucket is full,
the alternative location (bucket) of one of the entries is checked,
to try to find an empty slot, with make_space_bucket.
This function is called every time a new bucket is checked, recursively.
To avoid having a very long insert operation (and to avoid filling up
the stack), a limit in the number of pushes is introduced.

Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_hash/rte_cuckoo_hash.c | 6 +++++-
 lib/librte_hash/rte_cuckoo_hash.h | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 26e54f6..53363ed 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -408,6 +408,7 @@ rte_hash_reset(struct rte_hash *h)
 static inline int
 make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt)
 {
+	static unsigned int nr_pushes;
 	unsigned i, j;
 	int ret;
 	uint32_t next_bucket_idx;
@@ -444,11 +445,13 @@ make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt)
 			break;
 
 	/* All entries have been pushed, so entry cannot be added */
-	if (i == RTE_HASH_BUCKET_ENTRIES)
+	if (i == RTE_HASH_BUCKET_ENTRIES || nr_pushes > RTE_HASH_MAX_PUSHES)
 		return -ENOSPC;
 
 	/* Set flag to indicate that this entry is going to be pushed */
 	bkt->flag[i] = 1;
+
+	nr_pushes++;
 	/* Need room in alternative bucket to insert the pushed entry */
 	ret = make_space_bucket(h, next_bkt[i]);
 	/*
@@ -458,6 +461,7 @@ make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt)
 	 * or return error
 	 */
 	bkt->flag[i] = 0;
+	nr_pushes = 0;
 	if (ret >= 0) {
 		next_bkt[i]->signatures[ret].alt = bkt->signatures[i].current;
 		next_bkt[i]->signatures[ret].current = bkt->signatures[i].alt;
diff --git a/lib/librte_hash/rte_cuckoo_hash.h b/lib/librte_hash/rte_cuckoo_hash.h
index 6c76700..9625fff 100644
--- a/lib/librte_hash/rte_cuckoo_hash.h
+++ b/lib/librte_hash/rte_cuckoo_hash.h
@@ -138,6 +138,8 @@ enum add_key_case {
 
 #define LCORE_CACHE_SIZE		64
 
+#define RTE_HASH_MAX_PUSHES             100
+
 #define RTE_HASH_BFS_QUEUE_MAX_LEN       1000
 
 #define RTE_XABORT_CUCKOO_PATH_INVALIDED 0x4
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-stable] [PATCH 2/2] hash: fix bucket size usage
  2016-11-09 17:22 [dpdk-stable] [PATCH 1/2] hash: fix unlimited cuckoo path Pablo de Lara
@ 2016-11-09 17:22 ` Pablo de Lara
  2016-11-15  8:55 ` [dpdk-stable] [PATCH 1/2] hash: fix unlimited cuckoo path Yuanhan Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo de Lara @ 2016-11-09 17:22 UTC (permalink / raw)
  To: stable; +Cc: yuanhan.liu, Pablo de Lara

Multiwriter insert function was using a fixed value for
the bucket size, instead of using the
RTE_HASH_BUCKET_ENTRIES macro, which value was changed
recently (making it inconsistent in this case).

Fixes: be856325cba3 ("hash: add scalable multi-writer insertion with Intel TSX")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_hash/rte_cuckoo_hash_x86.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_hash/rte_cuckoo_hash_x86.h b/lib/librte_hash/rte_cuckoo_hash_x86.h
index fa5630b..ace1bd2 100644
--- a/lib/librte_hash/rte_cuckoo_hash_x86.h
+++ b/lib/librte_hash/rte_cuckoo_hash_x86.h
@@ -168,7 +168,8 @@ rte_hash_cuckoo_make_space_mw_tm(const struct rte_hash *h,
 
 	/* Cuckoo bfs Search */
 	while (likely(tail != head && head <
-					queue + RTE_HASH_BFS_QUEUE_MAX_LEN - 4)) {
+					queue + RTE_HASH_BFS_QUEUE_MAX_LEN -
+					RTE_HASH_BUCKET_ENTRIES)) {
 		curr_bkt = tail->bkt;
 		for (i = 0; i < RTE_HASH_BUCKET_ENTRIES; i++) {
 			if (curr_bkt->signatures[i].sig == NULL_SIGNATURE) {
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH 1/2] hash: fix unlimited cuckoo path
  2016-11-09 17:22 [dpdk-stable] [PATCH 1/2] hash: fix unlimited cuckoo path Pablo de Lara
  2016-11-09 17:22 ` [dpdk-stable] [PATCH 2/2] hash: fix bucket size usage Pablo de Lara
@ 2016-11-15  8:55 ` Yuanhan Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Yuanhan Liu @ 2016-11-15  8:55 UTC (permalink / raw)
  To: Pablo de Lara; +Cc: stable

Both are applied to dpdk stable branch 16.07.

Thanks.

	--yliu

On Wed, Nov 09, 2016 at 05:22:03PM +0000, Pablo de Lara wrote:
> When trying to insert a new entry, if its target bucket is full,
> the alternative location (bucket) of one of the entries is checked,
> to try to find an empty slot, with make_space_bucket.
> This function is called every time a new bucket is checked, recursively.
> To avoid having a very long insert operation (and to avoid filling up
> the stack), a limit in the number of pushes is introduced.
> 
> Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>  lib/librte_hash/rte_cuckoo_hash.c | 6 +++++-
>  lib/librte_hash/rte_cuckoo_hash.h | 2 ++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
> index 26e54f6..53363ed 100644
> --- a/lib/librte_hash/rte_cuckoo_hash.c
> +++ b/lib/librte_hash/rte_cuckoo_hash.c
> @@ -408,6 +408,7 @@ rte_hash_reset(struct rte_hash *h)
>  static inline int
>  make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt)
>  {
> +	static unsigned int nr_pushes;
>  	unsigned i, j;
>  	int ret;
>  	uint32_t next_bucket_idx;
> @@ -444,11 +445,13 @@ make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt)
>  			break;
>  
>  	/* All entries have been pushed, so entry cannot be added */
> -	if (i == RTE_HASH_BUCKET_ENTRIES)
> +	if (i == RTE_HASH_BUCKET_ENTRIES || nr_pushes > RTE_HASH_MAX_PUSHES)
>  		return -ENOSPC;
>  
>  	/* Set flag to indicate that this entry is going to be pushed */
>  	bkt->flag[i] = 1;
> +
> +	nr_pushes++;
>  	/* Need room in alternative bucket to insert the pushed entry */
>  	ret = make_space_bucket(h, next_bkt[i]);
>  	/*
> @@ -458,6 +461,7 @@ make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt)
>  	 * or return error
>  	 */
>  	bkt->flag[i] = 0;
> +	nr_pushes = 0;
>  	if (ret >= 0) {
>  		next_bkt[i]->signatures[ret].alt = bkt->signatures[i].current;
>  		next_bkt[i]->signatures[ret].current = bkt->signatures[i].alt;
> diff --git a/lib/librte_hash/rte_cuckoo_hash.h b/lib/librte_hash/rte_cuckoo_hash.h
> index 6c76700..9625fff 100644
> --- a/lib/librte_hash/rte_cuckoo_hash.h
> +++ b/lib/librte_hash/rte_cuckoo_hash.h
> @@ -138,6 +138,8 @@ enum add_key_case {
>  
>  #define LCORE_CACHE_SIZE		64
>  
> +#define RTE_HASH_MAX_PUSHES             100
> +
>  #define RTE_HASH_BFS_QUEUE_MAX_LEN       1000
>  
>  #define RTE_XABORT_CUCKOO_PATH_INVALIDED 0x4
> -- 
> 2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-15  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-09 17:22 [dpdk-stable] [PATCH 1/2] hash: fix unlimited cuckoo path Pablo de Lara
2016-11-09 17:22 ` [dpdk-stable] [PATCH 2/2] hash: fix bucket size usage Pablo de Lara
2016-11-15  8:55 ` [dpdk-stable] [PATCH 1/2] hash: fix unlimited cuckoo path Yuanhan Liu

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).