From patchwork Fri Aug 18 20:19:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mstolarchuk X-Patchwork-Id: 27670 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id F25AC7D08; Fri, 18 Aug 2017 22:19:13 +0200 (CEST) Received: from mail-pg0-f52.google.com (mail-pg0-f52.google.com [74.125.83.52]) by dpdk.org (Postfix) with ESMTP id 050EE7D05 for ; Fri, 18 Aug 2017 22:19:11 +0200 (CEST) Received: by mail-pg0-f52.google.com with SMTP id i12so70769657pgr.3 for ; Fri, 18 Aug 2017 13:19:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bigswitch-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=CvD2qRNY4tQdWDL0jgVJjHOMiLioSOoeE6rtAlh/HwY=; b=l7jzv8t8I4ir1110Sx/4Iaev2CIHDIAp2kGbXpOTgRJF9r54nEkG1kB3DppH+aYRfA 4oSJeUKt+ijzeFFNiaa2YAhgEkfekms4gT4k6OImVvwuEJSYngfbQSvmTg+vGr0uKHLj BZXn91CDyf+j2yz+kUiP5CWbPjtcg4DkSQH4eZtl5laefJTRNlsdudorZk/oen5c8jga EOGWA5kxl3mPjNESP/UD0mJNzHK0jKjvw/pTLVAVoKzK/TGS838rlZjHPkIUiKu0ght/ fCpZAgjgfNcrPBVEiAez1iEYg4dRvnC0HvNqlPfeQixmleffpm9c3yNL4q5lootwvBCR 6QMA== 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; bh=CvD2qRNY4tQdWDL0jgVJjHOMiLioSOoeE6rtAlh/HwY=; b=Y8RqlvJ0SKdINbQ5hrro132wiI9FUuQtFikWVs1sxT2kAQu3AS4uTQVtC7LSfzT+wJ Der2v+qRPGaivj7sRKX30plOH2lOdXwMayyO+q5OV4ivlkpg9tGYsX5deD3FYeNF0EMi 66Ba+8bFGKjWcvYizRT9sqG5221BiqEq7+v5nwhOfVFs0Kpj6FHxthZDRQSB3Cvkqc2P dEX9RTV/cO4giNPdNHI3duYPS5chCp/YjBkbA66RQhAEj6eNxTHo2i+dCMCt2Jbut13F yJ1ygNngUyF5MUki73v4WH3BCXY/kUQWGgm/OcLLZKOgAn3phpp0D/YVrw+z6mQ3/CA8 Hygw== X-Gm-Message-State: AHYfb5hj4laPpdzV/cNHsvOcZ7LXwPB+r4oRk+6ba5O3TVbGIX/VDHOk 9hYBRi8VbtohHWHN X-Received: by 10.84.231.140 with SMTP id g12mr11068916plk.256.1503087550898; Fri, 18 Aug 2017 13:19:10 -0700 (PDT) Received: from dpdk-dell-430.sw.bigswitch.com ([173.227.38.50]) by smtp.gmail.com with ESMTPSA id x25sm14870620pfk.80.2017.08.18.13.19.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Aug 2017 13:19:10 -0700 (PDT) From: mstolarchuk To: bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org Date: Fri, 18 Aug 2017 13:19:19 -0700 Message-Id: <1503087559-103390-1-git-send-email-mike.stolarchuk@bigswitch.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH 6/6] static variable whouldn't be used to compute recursion level X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" the 'static nr_pushes' variable creates a single instance of the value across multiple invocations of the same procedure. In the case of a numa machine, this variable is then associated with one specifci numa node, degrading performance. but the more troublesome issue iw when two unrelated threads are inserting into the hash, each of these threads treat this static as their own property. Signed-off-by: mstolarchuk --- lib/librte_hash/rte_cuckoo_hash.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index 946252f..4567eb7 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -417,9 +417,10 @@ struct rte_hash * /* 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 +457,15 @@ struct rte_hash * 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[0] > RTE_HASH_MAX_PUSHES) return -ENOSPC; /* Set flag to indicate that this entry is going to be pushed */ bkt->flag[i] = 1; - nr_pushes++; + nr_pushes[0]++; /* 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 +473,7 @@ struct rte_hash * * or return error */ bkt->flag[i] = 0; - nr_pushes = 0; + nr_pushes[0] = 0; if (ret >= 0) { next_bkt[i]->sig_alt[ret] = bkt->sig_current[i]; next_bkt[i]->sig_current[ret] = bkt->sig_alt[i]; @@ -483,6 +484,14 @@ struct rte_hash * } +static inline int +make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt) +{ + unsigned int nr_pushes = 0; + + return __make_space_bucket(h, bkt, &nr_pushes); +} + /* * Function called to enqueue back an index in the cache/ring, * as slot has not being used and it can be used in the