From patchwork Fri Sep 25 17:43:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Lariau X-Patchwork-Id: 78863 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7D84A04C0; Fri, 25 Sep 2020 19:45:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BC34A1E9F9; Fri, 25 Sep 2020 19:44:19 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 198501E9D6 for ; Fri, 25 Sep 2020 19:44:14 +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 99D2F101E; Fri, 25 Sep 2020 10:44:12 -0700 (PDT) Received: from localhost.localdomain (unknown [10.57.54.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C651B3F718; Fri, 25 Sep 2020 10:44:11 -0700 (PDT) From: Steven Lariau To: Gage Eads , Olivier Matz Cc: dev@dpdk.org, nd@arm.com, Steven Lariau Date: Fri, 25 Sep 2020 18:43:37 +0100 Message-Id: <20200925174340.10014-4-steven.lariau@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200925174340.10014-1-steven.lariau@arm.com> References: <20200911152938.8019-1-steven.lariau@arm.com> <20200925174340.10014-1-steven.lariau@arm.com> Subject: [dpdk-dev] [PATCH v2 3/5] lib/stack: remove redundant orderings for list->len 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 load-acquire of list->len on pop function is redundant. Only the CAS success needs to be load-acquire. It synchronizes with the store release in push, to ensure that the updated head is visible when the new length is visible. Without this, one thread in pop could see the increased length but the old list, which doesn't have enough items yet for pop to succeed. Signed-off-by: Steven Lariau Reviewed-by: Dharmik Thakkar Reviewed-by: Ruifeng Wang Acked-by: Gage Eads --- lib/librte_stack/rte_stack_lf_c11.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_stack/rte_stack_lf_c11.h b/lib/librte_stack/rte_stack_lf_c11.h index 82b7287f1..2bc639419 100644 --- a/lib/librte_stack/rte_stack_lf_c11.h +++ b/lib/librte_stack/rte_stack_lf_c11.h @@ -80,7 +80,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list, int success; /* Reserve num elements, if available */ - len = __atomic_load_n(&list->len, __ATOMIC_ACQUIRE); + len = __atomic_load_n(&list->len, __ATOMIC_RELAXED); while (1) { /* Does the list contain enough elements? */ @@ -91,7 +91,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list, if (__atomic_compare_exchange_n(&list->len, &len, len - num, 1, __ATOMIC_ACQUIRE, - __ATOMIC_ACQUIRE)) + __ATOMIC_RELAXED)) break; }