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 15FEB43215; Fri, 27 Oct 2023 15:03:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D6B09402E4; Fri, 27 Oct 2023 15:03:13 +0200 (CEST) Received: from forward500b.mail.yandex.net (forward500b.mail.yandex.net [178.154.239.144]) by mails.dpdk.org (Postfix) with ESMTP id D3250402B9 for ; Fri, 27 Oct 2023 15:03:12 +0200 (CEST) Received: from mail-nwsmtp-smtp-production-main-90.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-90.myt.yp-c.yandex.net [IPv6:2a02:6b8:c00:27aa:0:640:91ff:0]) by forward500b.mail.yandex.net (Yandex) with ESMTP id 296A861228; Fri, 27 Oct 2023 16:03:12 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-90.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 53R7Sh1WqeA0-wHIQEjiV; Fri, 27 Oct 2023 16:03:10 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1698411790; bh=LyAn92Ls8HafqfPm/gpXjEzyOjSCUfO3xjgrjGCHKmM=; h=From:In-Reply-To:Cc:Date:References:To:Subject:Message-ID; b=Z1lhWQ82b/18gkDWVNGemn9i5SpeSMo+t3PpC4P4Vao/5QKfGuIEeuucvI1d1s1KR w/ISzwM6ZPbVKisYMJqxGrInKDqrweg46xJh2zvcDhSKwW1RHoHpjdRlUgYZrJA5hP pW2lAGCC6Gkc+o4k8obgpoEGaZJcj81n4vaAcqJI= Authentication-Results: mail-nwsmtp-smtp-production-main-90.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: Date: Fri, 27 Oct 2023 14:03:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 07/19] mbuf: use rte optional stdatomic API Content-Language: en-US, ru-RU To: Tyler Retzlaff , dev@dpdk.org Cc: Akhil Goyal , Anatoly Burakov , Andrew Rybchenko , Bruce Richardson , Chenbo Xia , Ciara Power , David Christensen , David Hunt , Dmitry Kozlyuk , Dmitry Malloy , Elena Agostini , Erik Gabriel Carrillo , Fan Zhang , Ferruh Yigit , Harman Kalra , Harry van Haaren , Honnappa Nagarahalli , Jerin Jacob , Matan Azrad , Maxime Coquelin , Narcisa Ana Maria Vasile , Nicolas Chautru , Olivier Matz , Ori Kam , Pallavi Kadam , Pavan Nikhilesh , Reshma Pattan , Sameh Gobriel , Shijith Thotton , Sivaprasad Tummala , Stephen Hemminger , Suanming Mou , Sunil Kumar Kori , Thomas Monjalon , Viacheslav Ovsiienko , Vladimir Medvedkin , Yipeng Wang References: <1697497745-20664-1-git-send-email-roretzla@linux.microsoft.com> <1698280314-25861-1-git-send-email-roretzla@linux.microsoft.com> <1698280314-25861-8-git-send-email-roretzla@linux.microsoft.com> From: Konstantin Ananyev In-Reply-To: <1698280314-25861-8-git-send-email-roretzla@linux.microsoft.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 26.10.2023 01:31, Tyler Retzlaff пишет: > Replace the use of gcc builtin __atomic_xxx intrinsics with > corresponding rte_atomic_xxx optional stdatomic API > > Signed-off-by: Tyler Retzlaff > --- > lib/mbuf/rte_mbuf.h | 20 ++++++++++---------- > lib/mbuf/rte_mbuf_core.h | 5 +++-- > 2 files changed, 13 insertions(+), 12 deletions(-) > > diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h > index 913c459..b8ab477 100644 > --- a/lib/mbuf/rte_mbuf.h > +++ b/lib/mbuf/rte_mbuf.h > @@ -361,7 +361,7 @@ struct rte_pktmbuf_pool_private { > static inline uint16_t > rte_mbuf_refcnt_read(const struct rte_mbuf *m) > { > - return __atomic_load_n(&m->refcnt, __ATOMIC_RELAXED); > + return rte_atomic_load_explicit(&m->refcnt, rte_memory_order_relaxed); > } > > /** > @@ -374,15 +374,15 @@ struct rte_pktmbuf_pool_private { > static inline void > rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value) > { > - __atomic_store_n(&m->refcnt, new_value, __ATOMIC_RELAXED); > + rte_atomic_store_explicit(&m->refcnt, new_value, rte_memory_order_relaxed); > } > > /* internal */ > static inline uint16_t > __rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value) > { > - return __atomic_fetch_add(&m->refcnt, value, > - __ATOMIC_ACQ_REL) + value; > + return rte_atomic_fetch_add_explicit(&m->refcnt, value, > + rte_memory_order_acq_rel) + value; > } > > /** > @@ -463,7 +463,7 @@ struct rte_pktmbuf_pool_private { > static inline uint16_t > rte_mbuf_ext_refcnt_read(const struct rte_mbuf_ext_shared_info *shinfo) > { > - return __atomic_load_n(&shinfo->refcnt, __ATOMIC_RELAXED); > + return rte_atomic_load_explicit(&shinfo->refcnt, rte_memory_order_relaxed); > } > > /** > @@ -478,7 +478,7 @@ struct rte_pktmbuf_pool_private { > rte_mbuf_ext_refcnt_set(struct rte_mbuf_ext_shared_info *shinfo, > uint16_t new_value) > { > - __atomic_store_n(&shinfo->refcnt, new_value, __ATOMIC_RELAXED); > + rte_atomic_store_explicit(&shinfo->refcnt, new_value, rte_memory_order_relaxed); > } > > /** > @@ -502,8 +502,8 @@ struct rte_pktmbuf_pool_private { > return (uint16_t)value; > } > > - return __atomic_fetch_add(&shinfo->refcnt, value, > - __ATOMIC_ACQ_REL) + value; > + return rte_atomic_fetch_add_explicit(&shinfo->refcnt, value, > + rte_memory_order_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_fetch_add(&shinfo->refcnt, -1, > - __ATOMIC_ACQ_REL) - 1)) > + if (likely(rte_atomic_fetch_add_explicit(&shinfo->refcnt, -1, > + rte_memory_order_acq_rel) - 1)) > return 1; > > /* Reinitialize counter before mbuf freeing. */ > diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h > index e9bc0d1..5688683 100644 > --- a/lib/mbuf/rte_mbuf_core.h > +++ b/lib/mbuf/rte_mbuf_core.h > @@ -19,6 +19,7 @@ > #include > > #include > +#include > > #ifdef __cplusplus > extern "C" { > @@ -497,7 +498,7 @@ struct rte_mbuf { > * rte_mbuf_refcnt_set(). The functionality of these functions (atomic, > * or non-atomic) is controlled by the RTE_MBUF_REFCNT_ATOMIC flag. > */ > - uint16_t refcnt; > + RTE_ATOMIC(uint16_t) refcnt; > > /** > * Number of segments. Only valid for the first segment of an mbuf > @@ -674,7 +675,7 @@ struct rte_mbuf { > struct rte_mbuf_ext_shared_info { > rte_mbuf_extbuf_free_callback_t free_cb; /**< Free callback function */ > void *fcb_opaque; /**< Free callback argument */ > - uint16_t refcnt; > + RTE_ATOMIC(uint16_t) refcnt; Just hope that stdatomic for uint16 would never anctualluy increase the field size. Otherwise it could cause a lot of troubles with dyn mbuf fileds, etc.. Acked-by: Konstantin Ananyev > }; > > /** Maximum number of nb_segs allowed. */