From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 07BB21B252 for ; Mon, 30 Oct 2017 16:37:51 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id r68so17328556wmr.3 for ; Mon, 30 Oct 2017 08:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hPmg1x2AbJu2Zhjh9huEwwzrpdBIi9APHxU5PVGJnVI=; b=smYB3SNuqQeoSJnK2od2ih1gS5e3ufj5M3/x2a8dnQubUktM5deoJ6pZ9Q1zC4QAgt 3//HOqsR/oGI2PeqHW+4ctAZEMWQ37uDx9FKMXiz5/sPSfunu+EB5psQpXcCArs91YnH 00kcPeEusAJHyG/WFEkpHLPllbeCZdmezu8uYpWiGT08mWP2CNsmjLm/B2en9RZfMp01 zy9xn1SFfti/X7Prm6cVfZOldklCp2pm9KCKRKv1shQUlABPFhyicagOqvyDBLUKncvL /iVYDfmQJa8OHrnJTSAASLz8vdbhLrUAV9urLXCVvFI4g7hem2/aXwvxamZFE6B7Ybl2 guhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hPmg1x2AbJu2Zhjh9huEwwzrpdBIi9APHxU5PVGJnVI=; b=CkUpD+ESyXYqpxlgHOmN09MrmK2YPMxbWICT7D35E/FP+/NnWTXSRnVjjrQRi54w7D WIk+7We2ZWVrbS71yrVSwgYQTLs/q0+u+fnG4pzisVV8PBmJtmbp2iUC8gcbgs+F3EMO hFlYrbuUT2/ijQFbL3gH7r5CRmjx/tBV5pulqo8sqBBtjwTdPUGie0TpW3wOdudeYRJs q3DkpUHxh5ljQ2OPY0GlJ6HSCEm2f1eCDwT7WNHfvC8RY/TnRDFVyVu1yPN/Dr2lWlvU 5zTGGiGMzgrXhhgVOwPKHGiBkt+fW2Vr4JVwVu8TuiB1ktbvbuY+tLkDb+bPV8Q3evea 4tig== X-Gm-Message-State: AMCzsaVGY5vwWZnm6HiMvSTRcQ/gT4VMIfqU4eJTjwoFFzdJFatL00kq o1ECcjfomhLAEI0n/6fFoQE= X-Google-Smtp-Source: ABhQp+S0f9oqjvjjaWSx+02/yCzmcEA5zpmWHhqMtJOlKNvTQdztxdZC0elw9DvIFh0/3M7Cdtih8g== X-Received: by 10.28.4.150 with SMTP id 144mr261689wme.79.1509377870751; Mon, 30 Oct 2017 08:37:50 -0700 (PDT) Received: from localhost ([2a00:23c5:bef3:400:4a51:b7ff:fe0b:4749]) by smtp.gmail.com with ESMTPSA id o24sm3502950wmi.39.2017.10.30.08.37.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Oct 2017 08:37:50 -0700 (PDT) From: luca.boccassi@gmail.com To: Pablo de Lara Cc: Bruce Richardson , dpdk stable Date: Mon, 30 Oct 2017 15:34:42 +0000 Message-Id: <20171030153511.13322-39-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171030153511.13322-1-luca.boccassi@gmail.com> References: <20171030153511.13322-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'hash: fix eviction counter' has been queued to LTS release 16.11.4 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: Mon, 30 Oct 2017 15:37:51 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.4 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/01/17. So please shout if anyone has objections. Thanks. Kind regards, Luca Boccassi --- >>From 23859b268635a5329f6659a4f5530755050acb07 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 51db006a9..fb462d69e 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); @@ -643,7 +642,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.11.0