From patchwork Mon Feb 5 04:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 136378 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DAAD543A70; Mon, 5 Feb 2024 06:00:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 635F4402BE; Mon, 5 Feb 2024 06:00:25 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 5485D400D6; Mon, 5 Feb 2024 06:00:24 +0100 (CET) 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 EAC941FB; Sun, 4 Feb 2024 21:01:05 -0800 (PST) Received: from ampere-altra-2-1.usa.Arm.com (ampere-altra-2-1.usa.arm.com [10.118.91.158]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 796533F5A1; Sun, 4 Feb 2024 21:00:23 -0800 (PST) From: Honnappa Nagarahalli To: dev@dpdk.org Cc: wathsala.vithanage@arm.com, dhruv.tripathi@arm.com, nd@arm.com, Honnappa Nagarahalli , stable@dpdk.org, Ola Liljedahl Subject: [PATCH 1/2] rcu: use atomic operation on acked token Date: Mon, 5 Feb 2024 04:59:48 +0000 Message-Id: <20240205045949.1085128-1-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org acked_token should be read using atomic operation as the the API rte_rcu_qsbr_check is advertised as multi-thread safe. Fixes: 1f90d32ce175 ("rcu: add least acknowledged token optimization") Cc: stable@dpdk.org Reported-by: Ola Liljedahl Signed-off-by: Honnappa Nagarahalli Reviewed-by: Ola Liljedahl --- lib/rcu/rte_rcu_qsbr.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h index 5979fb0efb..f6a3731308 100644 --- a/lib/rcu/rte_rcu_qsbr.h +++ b/lib/rcu/rte_rcu_qsbr.h @@ -667,7 +667,8 @@ rte_rcu_qsbr_check(struct rte_rcu_qsbr *v, uint64_t t, bool wait) RTE_ASSERT(v != NULL); /* Check if all the readers have already acknowledged this token */ - if (likely(t <= v->acked_token)) { + if (likely(t <= rte_atomic_load_explicit(&v->acked_token, + rte_memory_order_relaxed))) { __RTE_RCU_DP_LOG(DEBUG, "%s: check: token = %" PRIu64 ", wait = %d", __func__, t, wait); From patchwork Mon Feb 5 04:59:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 136379 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1046143A70; Mon, 5 Feb 2024 06:00:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C7FE0402DD; Mon, 5 Feb 2024 06:00:30 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id C1770400D6; Mon, 5 Feb 2024 06:00:28 +0100 (CET) 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 ABF1D1FB; Sun, 4 Feb 2024 21:01:10 -0800 (PST) Received: from ampere-altra-2-1.usa.Arm.com (ampere-altra-2-1.usa.arm.com [10.118.91.158]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3BF0A3F5A1; Sun, 4 Feb 2024 21:00:28 -0800 (PST) From: Honnappa Nagarahalli To: dev@dpdk.org Cc: wathsala.vithanage@arm.com, dhruv.tripathi@arm.com, nd@arm.com, Honnappa Nagarahalli , stable@dpdk.org, Nathan Brown Subject: [PATCH 2/2] rcu: use correct value of acked token in debug print Date: Mon, 5 Feb 2024 04:59:49 +0000 Message-Id: <20240205045949.1085128-2-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240205045949.1085128-1-honnappa.nagarahalli@arm.com> References: <20240205045949.1085128-1-honnappa.nagarahalli@arm.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Debug print should use acked token value that was used for comparison. Fixes: bf386ae377aa ("rcu: add additional debug logs") Cc: stable@dpdk.org Reported-by: Nathan Brown Signed-off-by: Honnappa Nagarahalli Reviewed-by: Nathan Brown --- lib/rcu/rte_rcu_qsbr.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h index f6a3731308..a7d6e63560 100644 --- a/lib/rcu/rte_rcu_qsbr.h +++ b/lib/rcu/rte_rcu_qsbr.h @@ -664,17 +664,20 @@ __rte_rcu_qsbr_check_all(struct rte_rcu_qsbr *v, uint64_t t, bool wait) static __rte_always_inline int rte_rcu_qsbr_check(struct rte_rcu_qsbr *v, uint64_t t, bool wait) { + uint64_t acked_token; + RTE_ASSERT(v != NULL); /* Check if all the readers have already acknowledged this token */ - if (likely(t <= rte_atomic_load_explicit(&v->acked_token, - rte_memory_order_relaxed))) { + acked_token = rte_atomic_load_explicit(&v->acked_token, + rte_memory_order_relaxed); + if (likely(t <= acked_token)) { __RTE_RCU_DP_LOG(DEBUG, "%s: check: token = %" PRIu64 ", wait = %d", __func__, t, wait); __RTE_RCU_DP_LOG(DEBUG, "%s: status: least acked token = %" PRIu64, - __func__, v->acked_token); + __func__, acked_token); return 1; }