From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B604041E6D; Fri, 10 Mar 2023 23:16:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4166942D3A; Fri, 10 Mar 2023 23:15:49 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 2FC3C40FAE for ; Fri, 10 Mar 2023 23:15:37 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id B9F28204472C; Fri, 10 Mar 2023 14:15:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B9F28204472C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678486535; bh=7cgDgrLgK/5Yqsswjcs4EDe6KihylHqpm+0X5wjp9x4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YiyXgNtjYZx+B2mw+HXJNnvKProMlsZkXtFv1KIEtzyf1edNWgKc7aTfGwWuJZsRP c1FDqjYVOCjITMfu8SjbHlwzymWzwBzJuX1/UINXYALRIzw1jq5JbrWy0e1JrR4k6M gGxEGOAw/qTYxg9ImFcRccuWwIx1bFQLrdlQKpaw= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 05/16] net/af_xdp: use previous value atomic fetch operations Date: Fri, 10 Mar 2023 14:15:19 -0800 Message-Id: <1678486530-20688-6-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> 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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- drivers/net/af_xdp/rte_eth_af_xdp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index 2a20a69..c7786cc 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -979,7 +979,7 @@ static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags) break; xsk_socket__delete(rxq->xsk); - if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) + if (__atomic_fetch_sub(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) - 1 == 0) { (void)xsk_umem__delete(rxq->umem->umem); xdp_umem_destroy(rxq->umem); @@ -1710,7 +1710,7 @@ struct msg_internal { out_xsk: xsk_socket__delete(rxq->xsk); out_umem: - if (__atomic_sub_fetch(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) == 0) + if (__atomic_fetch_sub(&rxq->umem->refcnt, 1, __ATOMIC_ACQUIRE) - 1 == 0) xdp_umem_destroy(rxq->umem); return ret; -- 1.8.3.1