From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 12FEAA2EEB for ; Mon, 9 Sep 2019 15:52:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C2D401EC8E; Mon, 9 Sep 2019 15:51:59 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id A92EA1EC7A; Mon, 9 Sep 2019 15:51:55 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B06631D31; Mon, 9 Sep 2019 06:51:54 -0700 (PDT) Received: from net-arm-c2400-02.shanghai.arm.com (net-arm-c2400-02.shanghai.arm.com [10.169.40.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 30EC23F59C; Mon, 9 Sep 2019 06:51:53 -0700 (PDT) From: Ruifeng Wang To: honnappa.nagarahalli@arm.com Cc: dev@dpdk.org, gavin.hu@arm.com, nd@arm.com, Ruifeng Wang , stable@dpdk.org Date: Mon, 9 Sep 2019 21:51:42 +0800 Message-Id: <20190909135142.3510-1-ruifeng.wang@arm.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-stable] [PATCH] lib/rcu: fix possible spurious thread unregister 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: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Thread unregister returns success while unregister not been performed. This is due to incorrect thread registration status check. Fix this issue by correcting bitmap check. Fixes: 64994b56cfd7 ("rcu: add RCU library supporting QSBR mechanism") Cc: stable@dpdk.org Signed-off-by: Ruifeng Wang Reviewed-by: Gavin Hu --- lib/librte_rcu/rte_rcu_qsbr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_rcu/rte_rcu_qsbr.c b/lib/librte_rcu/rte_rcu_qsbr.c index ce7f93dd3..8c37c88cd 100644 --- a/lib/librte_rcu/rte_rcu_qsbr.c +++ b/lib/librte_rcu/rte_rcu_qsbr.c @@ -158,7 +158,7 @@ rte_rcu_qsbr_thread_unregister(struct rte_rcu_qsbr *v, unsigned int thread_id) /* Check if the thread is already unregistered */ old_bmap = __atomic_load_n(__RTE_QSBR_THRID_ARRAY_ELM(v, i), __ATOMIC_RELAXED); - if (old_bmap & ~(1UL << id)) + if (!(old_bmap & (1UL << id))) return 0; do { @@ -175,7 +175,7 @@ rte_rcu_qsbr_thread_unregister(struct rte_rcu_qsbr *v, unsigned int thread_id) if (success) __atomic_fetch_sub(&v->num_threads, 1, __ATOMIC_RELAXED); - else if (old_bmap & ~(1UL << id)) + else if (!(old_bmap & (1UL << id))) /* Someone else unregistered this thread. * Counter should not be incremented. */ -- 2.17.1