From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id ED654235 for ; Tue, 21 Nov 2017 14:24:27 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 8E7D820AF9; Tue, 21 Nov 2017 08:24:27 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Tue, 21 Nov 2017 08:24:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=xn+LRGOgiqYBO1iFE GVLbhChvXOUmBk2UUx2s5Ys08A=; b=JEK0imVJUeRtC4ednPBV2BuKTeDZ4fL37 +ImiOH+W13BBeHt9CNl1WL1zgshRgPVVmHmtF1/WRaIYgqcNidPvDlapvNqVzeFp 3KA6jy6KBavEgEytZ/lM2bC+rpLCfwZzCq4UibqtOrzcm5zmfoAL6jSlHuQUEa7s uwtKAjnix0N/rEE7lbtSkAYu1U/fxkVVVkiMNm4nTt+tsbwpErwFpJJYhrao2mav 3SdKSzNwwTxTKMBQ3uawSyHQs5U7PNa4IWOnclAnGr0VxQU4QyE0sW9q2dizTslW 7ZB+4OezvCwT5DM3n6oBKfXvYbnLtk/CLu9bLf9UskwuVRWr9qwkw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=xn+LRGOgiqYBO1iFEGVLbhChvXOUmBk2UUx2s5Ys08A=; b=T9R6EZRE LDJuwk2mxYxZ1XOEehsmqj/zUrC778tCAbmIq/GfLUFagfckYpSx1fPQgZVIMegp GPuK0q6tJ+f8ibTBkdC2hewkfPpReLvdOmBNQ0hb/3DQyCfiW2SZprT/nWxl03YW QnuuFa5lqCl2OXYEJ9M3DY2tqLbCoTsI6gKQjVu5KD0w9IRJd7o13dJxEjE5dZOY nGgu2wWtQQTYo602gFc1nAd3+PVfLj6fE550Hhu0vXZfo1Pc4hkJr90fyzk7/SPD 3AV8jRzTitQDqXlFxrbgxhIdI/0ZTST6VXf6UV/6gg1RFj0zITeqXH+beZnCClik HCdXo5K8rN4jhQ== X-ME-Sender: Received: from localhost.localdomain (unknown [180.158.62.0]) by mail.messagingengine.com (Postfix) with ESMTPA id 2A877247A9; Tue, 21 Nov 2017 08:24:24 -0500 (EST) From: Yuanhan Liu To: Pablo de Lara Cc: Bruce Richardson , dpdk stable Date: Tue, 21 Nov 2017 21:17:01 +0800 Message-Id: <1511270333-31002-79-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511270333-31002-1-git-send-email-yliu@fridaylinux.org> References: <1511270333-31002-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'hash: fix eviction counter' has been queued to stable release 17.08.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Nov 2017 13:24:28 -0000 Hi, FYI, your patch has been queued to stable release 17.08.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/24/17. So please shout if anyone has objections. Thanks. --yliu --- >>From b0c63e4bd8d20f48891a29770a0b0955b5fc3d19 Mon Sep 17 00:00:00 2001 From: Pablo de Lara Date: Fri, 22 Sep 2017 05:25:43 +0100 Subject: [PATCH] hash: fix eviction counter [ upstream commit 98b8ec70604065f511aea0a567b039421bc524cc ] When adding a new entry in a hash table, there is a maximum number of evictions that can be performed. When the counter of these evictions reaches this maximum, the entry cannot be added, as it is considered that the algorithm has encountered an infinite loop. The problem with the current implementation, is that this counter was declared as a static variable. If there are multiple threads adding entries in the same table or in different tables, they should access different counters, one per core and per table. Therefore, the variable has been modified to be non-static. Fixes: 243e93a5046f ("hash: fix unlimited cuckoo path") Signed-off-by: Pablo de Lara Acked-by: Bruce Richardson --- lib/librte_hash/rte_cuckoo_hash.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index 87b25c0..e69b911 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -417,9 +417,9 @@ rte_hash_reset(struct rte_hash *h) /* Search for an entry that can be pushed to its alternative location */ static inline int -make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt) +make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt, + unsigned int *nr_pushes) { - static unsigned int nr_pushes; unsigned i, j; int ret; uint32_t next_bucket_idx; @@ -456,15 +456,14 @@ 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 || nr_pushes > RTE_HASH_MAX_PUSHES) + 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]); + ret = make_space_bucket(h, next_bkt[i], nr_pushes); /* * After recursive function. * Clear flags and insert the pushed entry @@ -472,7 +471,6 @@ 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]->sig_alt[ret] = bkt->sig_current[i]; next_bkt[i]->sig_current[ret] = bkt->sig_alt[i]; @@ -515,6 +513,7 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, unsigned n_slots; unsigned lcore_id; struct lcore_cache *cached_free_slots = NULL; + unsigned int nr_pushes = 0; if (h->add_key == ADD_KEY_MULTIWRITER) rte_spinlock_lock(h->multiwriter_lock); @@ -648,7 +647,7 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, * if successful or return error and * store the new slot back in the ring */ - ret = make_space_bucket(h, prim_bkt); + ret = make_space_bucket(h, prim_bkt, &nr_pushes); if (ret >= 0) { prim_bkt->sig_current[ret] = sig; prim_bkt->sig_alt[ret] = alt_hash; -- 2.7.4