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 E64EE427E5; Mon, 20 Mar 2023 20:02:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D92142D52; Mon, 20 Mar 2023 20:01:25 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id AF67240A80 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 85BD920FB437; Mon, 20 Mar 2023 12:01:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 85BD920FB437 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=mpSF6toydLOaRcCI8rrJlK3A6g1p4Qo5bMr0DmGSxkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y9O5SzjedqzAlJAkyAk0h6SexLUOENGMBKfMwIwGJukWw9JkmGGeNfcTOsE0htNAP gxOY5N7QeNX8ggJh0Gc/xTTMVuE7VDUW/gkpZ+iAMgDtLGKZgZJ0MXLBEp1mMbabeD NCjEBumcdSc8g5ALSvYdt3TW5yZVJK61oEIWmF4s= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 15/16] mbuf: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:35 -0700 Message-Id: <1679338836-21321-16-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- lib/mbuf/rte_mbuf.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h index bc41eac..913c459 100644 --- a/lib/mbuf/rte_mbuf.h +++ b/lib/mbuf/rte_mbuf.h @@ -381,8 +381,8 @@ struct rte_pktmbuf_pool_private { static inline uint16_t __rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value) { - return __atomic_add_fetch(&m->refcnt, (uint16_t)value, - __ATOMIC_ACQ_REL); + return __atomic_fetch_add(&m->refcnt, value, + __ATOMIC_ACQ_REL) + value; } /** @@ -502,8 +502,8 @@ struct rte_pktmbuf_pool_private { return (uint16_t)value; } - return __atomic_add_fetch(&shinfo->refcnt, (uint16_t)value, - __ATOMIC_ACQ_REL); + return __atomic_fetch_add(&shinfo->refcnt, value, + __ATOMIC_ACQ_REL) + value; } /** Mbuf prefetch */ @@ -1315,8 +1315,8 @@ static inline int __rte_pktmbuf_pinned_extbuf_decref(struct rte_mbuf *m) * Direct usage of add primitive to avoid * duplication of comparing with one. */ - if (likely(__atomic_add_fetch(&shinfo->refcnt, (uint16_t)-1, - __ATOMIC_ACQ_REL))) + if (likely(__atomic_fetch_add(&shinfo->refcnt, -1, + __ATOMIC_ACQ_REL) - 1)) return 1; /* Reinitialize counter before mbuf freeing. */ -- 1.8.3.1