mbuf: use c11 atomics for refcnt operations
PATCH 1/1 mbuf: use c11 atomics for refcnt operations
Use c11 atomics with explicit ordering instead of rte_atomic ops which enforce unnecessary barriers on aarch64.
--- lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 19 ++++++++++--------- lib/librte_mbuf/rte_mbuf_core.h | 11 +++-------- 3 files changed, 13 insertions(+), 18 deletions(-)
lib/librte_mbuf/rte_mbuf.c +0 -1
@@ -22,7 +22,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
lib/librte_mbuf/rte_mbuf.h +10 -9
@@ -37,7 +37,6 @@#include <rte_config.h> #include <rte_mempool.h> #include <rte_memory.h> -#include <rte_atomic.h> #include <rte_prefetch.h> #include <rte_branch_prediction.h> #include <rte_byteorder.h>
@@ -365,7 +364,7 @@ rte_pktmbuf_priv_flags(struct rte_mempool *mp)static inline uint16_t rte_mbuf_refcnt_read (const struct rte_mbuf *m) { -return (uint16_t )(rte_atomic16_read (&m->refcnt_atomic)); +return __atomic_load_n (&m->refcnt, __ATOMIC_RELAXED); }/**
@@ -378,14 +377,15 @@ rte_mbuf_refcnt_read(const struct rte_mbuf *m)static inline void rte_mbuf_refcnt_set (struct rte_mbuf *m,uint16_t new_value) { -rte_atomic16_set (&m->refcnt_atomic, (int16_t )new_value); +__atomic_store_n (&m->refcnt, new_value, __ATOMIC_RELAXED); }/* internal */ static inline uint16_t __rte_mbuf_refcnt_update (struct rte_mbuf *m,int16_t value) { -return (uint16_t )(rte_atomic16_add_return (&m->refcnt_atomic, value)); +return (uint16_t )(__atomic_add_fetch ((int16_t *)&m->refcnt, value, + __ATOMIC_ACQ_REL)); }/**
@@ -466,7 +466,7 @@ rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value)static inline uint16_t rte_mbuf_ext_refcnt_read (const struct rte_mbuf_ext_shared_info *shinfo) { -return (uint16_t )(rte_atomic16_read (&shinfo->refcnt_atomic)); +return __atomic_load_n (&shinfo->refcnt, __ATOMIC_RELAXED); }/**
@@ -481,7 +481,7 @@ static inline void rte_mbuf_ext_refcnt_set(struct rte_mbuf_ext_shared_info *shinfo, uint16_t new_value) { - rte_atomic16_set(&shinfo->refcnt_atomic, (int16_t)new_value); + __atomic_store_n(&shinfo->refcnt, new_value, __ATOMIC_RELAXED); }/**
@@ -505,7 +505,8 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo,return (uint16_t )value; } -return (uint16_t )rte_atomic16_add_return (&shinfo->refcnt_atomic, value); +return (uint16_t )(__atomic_add_fetch ((int16_t *)&shinfo->refcnt, value, + __ATOMIC_ACQ_REL)); }/** Mbuf prefetch */
@@ -1304,8 +1305,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 (rte_atomic16_add_return - (&shinfo->refcnt_atomic,-1 ))) +if (likely (__atomic_add_fetch ((int *)&shinfo->refcnt,-1 , + __ATOMIC_ACQ_REL)))return 1 ;/* Reinitialize counter before mbuf freeing. */
lib/librte_mbuf/rte_mbuf_core.h +3 -8
@@ -16,7 +16,6 @@#include <stdint.h> #include <rte_compat.h> -#include <generic/rte_atomic.h> #ifdef __cplusplusextern "C" {
@@ -493,12 +492,8 @@ struct rte_mbuf {* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC * config option. */ -RTE_STD_C11 - union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ -/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; +uint16_t refcnt; +uint16_t nb_segs;/**< Number of segments. */ /** Input port (16 bits to support more than 256 virtual ports).
@@ -676,7 +671,7 @@ typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);struct rte_mbuf_ext_shared_info {rte_mbuf_extbuf_free_callback_t free_cb;/**< Free callback function */ void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +uint16_t refcnt;/**< Atomically accessed refcnt */ };/**< Maximum number of nb_segs allowed. */
Signature · 1 line
2.7.4
Quoted 6 lines · Phil Yang
Use c11 atomics with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
I did not look at the details, but this patch is refused by the ABI check in Travis.
Signature · 1 line
David Marchand
Quoted 12 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Friday, July 3, 2020 11:39 PM
To: Phil Yang <[email protected]>
Cc: dev <[email protected]>; Olivier Matz <[email protected]>; David Christensen <[email protected]>; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] mbuf: use c11 atomics for refcnt operationsQuoted 1 line · Phil Yang
Quoted 8 lines
Quoted 5 lines
Use c11 atomics with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>I did not look at the details, but this patch is refused by the ABI check in Travis.
Thanks, David.
The ABI issue is the name of 'rte_mbuf_ext_shared_info::refcnt_atomic' changed to 'rte_mbuf_ext_shared_info::refcnt' at rte_mbuf_core.h. I made this change just to simplify the name of the variable.
Revert the 'rte_mbuf_ext_shared_info::refcnt' to refcnt_atomic can fix this issue. I will update it in v2.
Thanks,
Phil
Quoted 4 lines
--
David Marchand
PATCH v2 1/1 mbuf: use C11 atomics for refcnt operations
In reply to Phil YangUse C11 atomics with explicit ordering instead of rte_atomic ops which enforce unnecessary barriers on aarch64.
---
v2:
Fix ABI issue: revert the rte_mbuf_ext_shared_info struct refcnt field to refcnt_atomic.
lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 19 ++++++++++--------- lib/librte_mbuf/rte_mbuf_core.h | 11 +++-------- 3 files changed, 13 insertions(+), 18 deletions(-)
lib/librte_mbuf/rte_mbuf.c +0 -1
@@ -22,7 +22,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
lib/librte_mbuf/rte_mbuf.h +10 -9
@@ -37,7 +37,6 @@#include <rte_config.h> #include <rte_mempool.h> #include <rte_memory.h> -#include <rte_atomic.h> #include <rte_prefetch.h> #include <rte_branch_prediction.h> #include <rte_byteorder.h>
@@ -365,7 +364,7 @@ rte_pktmbuf_priv_flags(struct rte_mempool *mp)static inline uint16_t rte_mbuf_refcnt_read (const struct rte_mbuf *m) { -return (uint16_t )(rte_atomic16_read (&m->refcnt_atomic)); +return __atomic_load_n (&m->refcnt, __ATOMIC_RELAXED); }/**
@@ -378,14 +377,15 @@ rte_mbuf_refcnt_read(const struct rte_mbuf *m)static inline void rte_mbuf_refcnt_set (struct rte_mbuf *m,uint16_t new_value) { -rte_atomic16_set (&m->refcnt_atomic, (int16_t )new_value); +__atomic_store_n (&m->refcnt, new_value, __ATOMIC_RELAXED); }/* internal */ static inline uint16_t __rte_mbuf_refcnt_update (struct rte_mbuf *m,int16_t value) { -return (uint16_t )(rte_atomic16_add_return (&m->refcnt_atomic, value)); +return (uint16_t )(__atomic_add_fetch ((int16_t *)&m->refcnt, value, + __ATOMIC_ACQ_REL)); }/**
@@ -466,7 +466,7 @@ rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value)static inline uint16_t rte_mbuf_ext_refcnt_read (const struct rte_mbuf_ext_shared_info *shinfo) { -return (uint16_t )(rte_atomic16_read (&shinfo->refcnt_atomic)); +return __atomic_load_n (&shinfo->refcnt_atomic, __ATOMIC_RELAXED); }/**
@@ -481,7 +481,7 @@ static inline void rte_mbuf_ext_refcnt_set(struct rte_mbuf_ext_shared_info *shinfo, uint16_t new_value) { - rte_atomic16_set(&shinfo->refcnt_atomic, (int16_t)new_value); + __atomic_store_n(&shinfo->refcnt_atomic, new_value, __ATOMIC_RELAXED); }/**
@@ -505,7 +505,8 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo,return (uint16_t )value; } -return (uint16_t )rte_atomic16_add_return (&shinfo->refcnt_atomic, value); +return (uint16_t )(__atomic_add_fetch ((int16_t *)&shinfo->refcnt_atomic, + value, __ATOMIC_ACQ_REL)); }/** Mbuf prefetch */
@@ -1304,8 +1305,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 (rte_atomic16_add_return - (&shinfo->refcnt_atomic,-1 ))) +if (likely (__atomic_add_fetch ((int *)&shinfo->refcnt_atomic,-1 , + __ATOMIC_ACQ_REL)))return 1 ;/* Reinitialize counter before mbuf freeing. */
lib/librte_mbuf/rte_mbuf_core.h +3 -8
@@ -18,7 +18,6 @@#include <stdint.h> #include <rte_compat.h> -#include <generic/rte_atomic.h> #ifdef __cplusplusextern "C" {
@@ -495,12 +494,8 @@ struct rte_mbuf {* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC * config option. */ -RTE_STD_C11 - union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ -/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; +uint16_t refcnt; +uint16_t nb_segs;/**< Number of segments. */ /** Input port (16 bits to support more than 256 virtual ports).
@@ -679,7 +674,7 @@ typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);struct rte_mbuf_ext_shared_info {rte_mbuf_extbuf_free_callback_t free_cb;/**< Free callback function */ void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +uint16_t refcnt_atomic;/**< Atomically accessed refcnt */ };/**< Maximum number of nb_segs allowed. */
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operations
Review
Quoted 2 lines · On Tue, 7 Jul 2020 18:10:33 +0800 Phil Yang <[email protected]> wrote:
(quoted diff) +2
-0+ return (uint16_t)(__atomic_add_fetch((int16_t *)&shinfo->refcnt_atomic, +
Why do you need so many casts here?
The type of refcnt_atomic is now uint16 after your patch.
Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operations
Quoted 14 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, July 8, 2020 1:13 AM
To: Phil Yang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operationsOn Tue, 7 Jul 2020 18:10:33 +0800
Phil Yang <[email protected]> wrote:
Quoted 6 lines
Quoted 3 lines
(quoted diff) +1
-0+ return (uint16_t)(__atomic_add_fetch((int16_t *)&shinfo-
refcnt_atomic,
+Why do you need so many casts here?
The type ofrefcnt_atomicis now uint16 after your patch.
In the existing code, the input parameter type for this API is signed integer. For example:drivers/net/netvsc/hn_rxtx.c:531lib/librte_mbuf/rte_mbuf.h:1194
However, the output type of rte_mbuf_ext_refcnt related APIs is not uniform. We use these typecast to consistent with the current API definition.
Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operations
Quoted 21 lines · Phil Yang
Quoted 14 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, July 8, 2020 1:13 AM
To: Phil Yang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operationsOn Tue, 7 Jul 2020 18:10:33 +0800
Phil Yang <[email protected]> wrote:Quoted 6 lines
Quoted 3 lines
(quoted diff) +1
-0+ return (uint16_t)(__atomic_add_fetch((int16_t *)&shinfo-
refcnt_atomic,
+Why do you need so many casts here?
The type ofrefcnt_atomicis now uint16 after your patch.
Quoted 5 lines
In the existing code, the input parameter type for this API is signed integer. For example:
drivers/net/netvsc/hn_rxtx.c:531lib/librte_mbuf/rte_mbuf.h:1194However, the output type of
rte_mbuf_ext_refcntrelated APIs is not uniform. We use these typecast to consistent with the current API definition.
Would it make sense to cast the increment instead?
I mean:
return __atomic_add_fetch(&m->refcnt, (uint16_t)value, __ATOMIC_ACQ_REL);
instead of:
return (uint16_t)(__atomic_add_fetch((int16_t *)&m->refcnt, value, __ATOMIC_ACQ_REL));
The same could apply to __rte_pktmbuf_pinned_extbuf_decref() I think:
lib/librte_mbuf/rte_mbuf.h static inline int __rte_pktmbuf_pinned_extbuf_decref(struct rte_mbuf *m) · line 1309
Quoted 4 lines
lib/librte_mbuf/rte_mbuf.h +2
-2-if (likely (rte_atomic16_add_return - (&shinfo->refcnt_atomic,-1 ))) +if (likely (__atomic_add_fetch ((int *)&shinfo->refcnt_atomic,-1 , + __ATOMIC_ACQ_REL)))
By the way, why was the cast was to (int *) in this case? I think it can overwrite fields beside refcnt.
Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operations
Quoted 35 lines
-----Original Message-----
From: Olivier Matz <[email protected]>
Sent: Wednesday, July 8, 2020 7:43 PM
To: Phil Yang <[email protected]>
Cc: Stephen Hemminger <[email protected]>; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operationsQuoted 5 lines · Phil Yang
Quoted 5 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, July 8, 2020 1:13 AM
To: Phil Yang <[email protected]>
Cc: [email protected]; [email protected];Quoted 9 lines
Quoted 9 lines
Honnappa Nagarahalli <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operationsOn Tue, 7 Jul 2020 18:10:33 +0800
Phil Yang <[email protected]> wrote:Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
(quoted diff) +1
-0+ return (uint16_t)(__atomic_add_fetch((int16_t *)&shinfo-
refcnt_atomic,
+Why do you need so many casts here?
The type ofrefcnt_atomicis now uint16 after your patch.In the existing code, the input parameter type for this API is signed integer.
Quoted 8 lines
For example:
Quoted 4 lines
drivers/net/netvsc/hn_rxtx.c:531lib/librte_mbuf/rte_mbuf.h:1194However, the output type of
rte_mbuf_ext_refcntrelated APIs is notuniform. We use these typecast to consistent with the current API definition.
Would it make sense to cast the increment instead?
Yes. It is better.
Thanks.
Quoted 14 lines
I mean:
return __atomic_add_fetch(&m->refcnt, (uint16_t)value,
__ATOMIC_ACQ_REL);instead of:
return (uint16_t)(__atomic_add_fetch((int16_t *)&m->refcnt, value, __ATOMIC_ACQ_REL));The same could apply to
__rte_pktmbuf_pinned_extbuf_decref()I think:
Quoted 7 lines
lib/librte_mbuf/rte_mbuf.h static inline int __rte_pktmbuf_pinned_extbuf_decref(struct rte_mbuf *m) · line 1309
Quoted 4 lines
lib/librte_mbuf/rte_mbuf.h +2
-2-if (likely (rte_atomic16_add_return - (&shinfo->refcnt_atomic,-1 ))) +if (likely (__atomic_add_fetch ((int *)&shinfo->refcnt_atomic,-1 , + __ATOMIC_ACQ_REL)))By the way, why was the cast was to (int *) in this case? I think it can overwrite fields beside refcnt.
Fixed in the next version.
Thanks,
Phil
Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operations
In reply to Phil YangQuoted 19 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Phil Yang
Sent: Tuesday, July 7, 2020 6:11 PM
To: [email protected]; [email protected]
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>; nd <[email protected]>
Subject: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operationsUse C11 atomics with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v2:
Fix ABI issue: revert therte_mbuf_ext_shared_infostruct refcnt field torefcnt_atomic.
<snip>
Quoted 35 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-1@@ -18,7 +18,6 @@#include <stdint.h> #include <rte_compat.h> -#include <generic/rte_atomic.h> #ifdef __cplusplusextern "C" {@@ -495,12 +494,8 @@ struct rte_mbuf {* or non-atomic) is controlled by the
CONFIG_RTE_MBUF_REFCNT_ATOMIClib/librte_mbuf/rte_mbuf_core.h +0
-3* config option. */ -RTE_STD_C11 - union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */
lib/librte_mbuf/rte_mbuf_core.h +2
-3-/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; +uint16_t refcnt; +uint16_t nb_segs;/**< Number of segments. */ /** Input port (16 bits to support more than 256 virtual ports). @@ -679,7 +674,7 @@ typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);struct rte_mbuf_ext_shared_info {rte_mbuf_extbuf_free_callback_t free_cb;/**< Free callback function */
lib/librte_mbuf/rte_mbuf_core.h typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque); · line 677
Quoted 3 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-1void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +uint16_t refcnt_atomic;/**< Atomically accessed refcnt */
It still causes an ABI check failure in Travis CI on this type change. I think we need an exception in libabigail.abignore for this.
Thanks,
Phil
Quoted 5 lines
};
/**< Maximum number of
nb_segsallowed. */
--
2.7.4
Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operations
In reply to Phil YangHi,
Quoted 119 lines · Phil Yang
Use C11 atomics with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v2:
Fix ABI issue: revert therte_mbuf_ext_shared_infostruct refcnt field torefcnt_atomic.lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 19 ++++++++++--------- lib/librte_mbuf/rte_mbuf_core.h | 11 +++-------- 3 files changed, 13 insertions(+), 18 deletions(-)lib/librte_mbuf/rte_mbuf.c +0
-1@@ -22,7 +22,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h> lib/librte_mbuf/rte_mbuf.h +10
-9@@ -37,7 +37,6 @@#include <rte_config.h> #include <rte_mempool.h> #include <rte_memory.h> -#include <rte_atomic.h> #include <rte_prefetch.h> #include <rte_branch_prediction.h> #include <rte_byteorder.h> @@ -365,7 +364,7 @@ rte_pktmbuf_priv_flags(struct rte_mempool *mp)static inline uint16_t rte_mbuf_refcnt_read (const struct rte_mbuf *m) { -return (uint16_t )(rte_atomic16_read (&m->refcnt_atomic)); +return __atomic_load_n (&m->refcnt, __ATOMIC_RELAXED); }/** @@ -378,14 +377,15 @@ rte_mbuf_refcnt_read(const struct rte_mbuf *m)static inline void rte_mbuf_refcnt_set (struct rte_mbuf *m,uint16_t new_value) { -rte_atomic16_set (&m->refcnt_atomic, (int16_t )new_value); +__atomic_store_n (&m->refcnt, new_value, __ATOMIC_RELAXED); }/* internal */ static inline uint16_t __rte_mbuf_refcnt_update (struct rte_mbuf *m,int16_t value) { -return (uint16_t )(rte_atomic16_add_return (&m->refcnt_atomic, value)); +return (uint16_t )(__atomic_add_fetch ((int16_t *)&m->refcnt, value, + __ATOMIC_ACQ_REL)); }/** @@ -466,7 +466,7 @@ rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value)static inline uint16_t rte_mbuf_ext_refcnt_read (const struct rte_mbuf_ext_shared_info *shinfo) { -return (uint16_t )(rte_atomic16_read (&shinfo->refcnt_atomic)); +return __atomic_load_n (&shinfo->refcnt_atomic, __ATOMIC_RELAXED); }/** @@ -481,7 +481,7 @@ static inline void rte_mbuf_ext_refcnt_set(struct rte_mbuf_ext_shared_info *shinfo, uint16_t new_value) { - rte_atomic16_set(&shinfo->refcnt_atomic, (int16_t)new_value); + __atomic_store_n(&shinfo->refcnt_atomic, new_value, __ATOMIC_RELAXED); }/** @@ -505,7 +505,8 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo,return (uint16_t )value; } -return (uint16_t )rte_atomic16_add_return (&shinfo->refcnt_atomic, value); +return (uint16_t )(__atomic_add_fetch ((int16_t *)&shinfo->refcnt_atomic, + value, __ATOMIC_ACQ_REL)); }/** Mbuf prefetch */ @@ -1304,8 +1305,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 (rte_atomic16_add_return - (&shinfo->refcnt_atomic,-1 ))) +if (likely (__atomic_add_fetch ((int *)&shinfo->refcnt_atomic,-1 , + __ATOMIC_ACQ_REL)))return 1 ;/* Reinitialize counter before mbuf freeing. */ lib/librte_mbuf/rte_mbuf_core.h +0
-1@@ -18,7 +18,6 @@#include <stdint.h> #include <rte_compat.h> -#include <generic/rte_atomic.h> #ifdef __cplusplusextern "C" {@@ -495,12 +494,8 @@ struct rte_mbuf {* or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC
lib/librte_mbuf/rte_mbuf_core.h struct rte_mbuf { · line 498
Quoted 10 lines
lib/librte_mbuf/rte_mbuf_core.h +2
-6* config option. */ -RTE_STD_C11 - union { -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ -/** Non-atomically accessed refcnt */ -uint16_t refcnt; - }; +uint16_t refcnt; +
It seems this patch does 2 things:
- remove refcnt_atomic
- use C11 atomics
The first change is an API break. I think it should be announced in a deprecation notice. The one about atomic does not talk about it.
So I suggest to keep refcnt_atomic until next version.
Quoted 15 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-1uint16_t nb_segs;/**< Number of segments. */ /** Input port (16 bits to support more than 256 virtual ports). @@ -679,7 +674,7 @@ typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);struct rte_mbuf_ext_shared_info {rte_mbuf_extbuf_free_callback_t free_cb;/**< Free callback function */ void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +uint16_t refcnt_atomic;/**< Atomically accessed refcnt */ };/**< Maximum number of nb_segs allowed. */ Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v2] mbuf: use C11 atomics for refcnt operations
Quoted 27 lines
-----Original Message-----
From: Olivier Matz <[email protected]>
Sent: Wednesday, July 8, 2020 7:44 PM
To: Phil Yang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v2] mbuf: use C11 atomics for refcnt operationsHi,
Quoted 15 lines · Phil Yang
Use C11 atomics with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v2:
Fix ABI issue: revert therte_mbuf_ext_shared_infostruct refcnt field torefcnt_atomic.lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 19 ++++++++++--------- lib/librte_mbuf/rte_mbuf_core.h | 11 +++-------- 3 files changed, 13 insertions(+), 18 deletions(-)
<snip>
Quoted 10 lines
It seems this patch does 2 things:
- removerefcnt_atomic
- use C11 atomicsThe first change is an API break. I think it should be announced in a deprecation
notice. The one about atomic does not talk about it.So I suggest to keep
refcnt_atomicuntil next version.
Agreed.
I did a local test, this approach doesn't have any ABI breakage issue. I will update in the next version.
Thanks,
Phil
Quoted 19 lines
lib/librte_mbuf/rte_mbuf_core.h typedef void
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-0uint16_t nb_segs;/**< Number of segments. */ /** Input port (16 bits to support more than 256 virtual ports). @@ -679,7 +674,7 @@ typedef void(*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);
Review typedef void · line 675
Quoted 2 lines
(quoted diff) +0
-0struct rte_mbuf_ext_shared_info { rte_mbuf_extbuf_free_callback_t free_cb; /**< Free callbackfunction */
Quoted 9 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-2void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +uint16_t refcnt_atomic;/**< Atomically accessed refcnt */ };/**< Maximum number of nb_segs allowed. */ --2.7.4
PATCH v3 1/1 mbuf: use C11 atomic built-ins for refcnt operations
In reply to Phil YangUse C11 atomic built-ins with explicit ordering instead of rte_atomic ops which enforce unnecessary barriers on aarch64.
---
v3:
1.Fix ABI breakage.
2.Simplify data type cast.
v2:
Fix ABI issue: revert the rte_mbuf_ext_shared_info struct refcnt field to refcnt_atomic.
lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 19 ++++++++++--------- lib/librte_mbuf/rte_mbuf_core.h | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-)
lib/librte_mbuf/rte_mbuf.c +0 -1
@@ -22,7 +22,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
lib/librte_mbuf/rte_mbuf.h +10 -9
@@ -37,7 +37,6 @@#include <rte_config.h> #include <rte_mempool.h> #include <rte_memory.h> -#include <rte_atomic.h> #include <rte_prefetch.h> #include <rte_branch_prediction.h> #include <rte_byteorder.h>
@@ -365,7 +364,7 @@ rte_pktmbuf_priv_flags(struct rte_mempool *mp)static inline uint16_t rte_mbuf_refcnt_read (const struct rte_mbuf *m) { -return (uint16_t )(rte_atomic16_read (&m->refcnt_atomic)); +return __atomic_load_n (&m->refcnt, __ATOMIC_RELAXED); }/**
@@ -378,14 +377,15 @@ rte_mbuf_refcnt_read(const struct rte_mbuf *m)static inline void rte_mbuf_refcnt_set (struct rte_mbuf *m,uint16_t new_value) { -rte_atomic16_set (&m->refcnt_atomic, (int16_t )new_value); +__atomic_store_n (&m->refcnt, new_value, __ATOMIC_RELAXED); }/* internal */ static inline uint16_t __rte_mbuf_refcnt_update (struct rte_mbuf *m,int16_t value) { -return (uint16_t )(rte_atomic16_add_return (&m->refcnt_atomic, value)); +return __atomic_add_fetch (&m->refcnt, (uint16_t )value, + __ATOMIC_ACQ_REL); }/**
@@ -466,7 +466,7 @@ rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value)static inline uint16_t rte_mbuf_ext_refcnt_read (const struct rte_mbuf_ext_shared_info *shinfo) { -return (uint16_t )(rte_atomic16_read (&shinfo->refcnt_atomic)); +return __atomic_load_n (&shinfo->refcnt_atomic, __ATOMIC_RELAXED); }/**
@@ -481,7 +481,7 @@ static inline void rte_mbuf_ext_refcnt_set(struct rte_mbuf_ext_shared_info *shinfo, uint16_t new_value) { - rte_atomic16_set(&shinfo->refcnt_atomic, (int16_t)new_value); + __atomic_store_n(&shinfo->refcnt_atomic, new_value, __ATOMIC_RELAXED); }/**
@@ -505,7 +505,8 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo,return (uint16_t )value; } -return (uint16_t )rte_atomic16_add_return (&shinfo->refcnt_atomic, value); +return __atomic_add_fetch (&shinfo->refcnt_atomic, (uint16_t )value, + __ATOMIC_ACQ_REL); }/** Mbuf prefetch */
@@ -1304,8 +1305,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 (rte_atomic16_add_return - (&shinfo->refcnt_atomic,-1 ))) +if (likely (__atomic_add_fetch (&shinfo->refcnt_atomic, (uint16_t )-1 , + __ATOMIC_ACQ_REL)))return 1 ;/* Reinitialize counter before mbuf freeing. */
lib/librte_mbuf/rte_mbuf_core.h +1 -1
@@ -679,7 +679,7 @@ typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);struct rte_mbuf_ext_shared_info {rte_mbuf_extbuf_free_callback_t free_cb;/**< Free callback function */ void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +uint16_t refcnt_atomic;/**< Atomically accessed refcnt */ };/**< Maximum number of nb_segs allowed. */
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v3] mbuf: use C11 atomic built-ins for refcnt operations
Hi Phil,
Quoted 114 lines · Phil Yang
Use C11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v3:
1.Fix ABI breakage.
2.Simplify data type cast.v2:
Fix ABI issue: revert therte_mbuf_ext_shared_infostruct refcnt field torefcnt_atomic.lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 19 ++++++++++--------- lib/librte_mbuf/rte_mbuf_core.h | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-)lib/librte_mbuf/rte_mbuf.c +0
-1@@ -22,7 +22,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h> lib/librte_mbuf/rte_mbuf.h +10
-9@@ -37,7 +37,6 @@#include <rte_config.h> #include <rte_mempool.h> #include <rte_memory.h> -#include <rte_atomic.h> #include <rte_prefetch.h> #include <rte_branch_prediction.h> #include <rte_byteorder.h> @@ -365,7 +364,7 @@ rte_pktmbuf_priv_flags(struct rte_mempool *mp)static inline uint16_t rte_mbuf_refcnt_read (const struct rte_mbuf *m) { -return (uint16_t )(rte_atomic16_read (&m->refcnt_atomic)); +return __atomic_load_n (&m->refcnt, __ATOMIC_RELAXED); }/** @@ -378,14 +377,15 @@ rte_mbuf_refcnt_read(const struct rte_mbuf *m)static inline void rte_mbuf_refcnt_set (struct rte_mbuf *m,uint16_t new_value) { -rte_atomic16_set (&m->refcnt_atomic, (int16_t )new_value); +__atomic_store_n (&m->refcnt, new_value, __ATOMIC_RELAXED); }/* internal */ static inline uint16_t __rte_mbuf_refcnt_update (struct rte_mbuf *m,int16_t value) { -return (uint16_t )(rte_atomic16_add_return (&m->refcnt_atomic, value)); +return __atomic_add_fetch (&m->refcnt, (uint16_t )value, + __ATOMIC_ACQ_REL); }/** @@ -466,7 +466,7 @@ rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value)static inline uint16_t rte_mbuf_ext_refcnt_read (const struct rte_mbuf_ext_shared_info *shinfo) { -return (uint16_t )(rte_atomic16_read (&shinfo->refcnt_atomic)); +return __atomic_load_n (&shinfo->refcnt_atomic, __ATOMIC_RELAXED); }/** @@ -481,7 +481,7 @@ static inline void rte_mbuf_ext_refcnt_set(struct rte_mbuf_ext_shared_info *shinfo, uint16_t new_value) { - rte_atomic16_set(&shinfo->refcnt_atomic, (int16_t)new_value); + __atomic_store_n(&shinfo->refcnt_atomic, new_value, __ATOMIC_RELAXED); }/** @@ -505,7 +505,8 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo,return (uint16_t )value; } -return (uint16_t )rte_atomic16_add_return (&shinfo->refcnt_atomic, value); +return __atomic_add_fetch (&shinfo->refcnt_atomic, (uint16_t )value, + __ATOMIC_ACQ_REL); }/** Mbuf prefetch */ @@ -1304,8 +1305,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 (rte_atomic16_add_return - (&shinfo->refcnt_atomic,-1 ))) +if (likely (__atomic_add_fetch (&shinfo->refcnt_atomic, (uint16_t )-1 , + __ATOMIC_ACQ_REL)))return 1 ;/* Reinitialize counter before mbuf freeing. */ lib/librte_mbuf/rte_mbuf_core.h +0
-0
lib/librte_mbuf/rte_mbuf_core.h typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque); · line 683
Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-1@@ -679,7 +679,7 @@ typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);struct rte_mbuf_ext_shared_info {rte_mbuf_extbuf_free_callback_t free_cb;/**< Free callback function */ void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +uint16_t refcnt_atomic;/**< Atomically accessed refcnt */ };
To avoid an API breakage (i.e. currently, an application that accesses to refcnt_atomic expects that its type is rte_atomic16_t), I suggest to do the same than in the mbuf struct:
union {
rte_atomic16_t refcnt_atomic;
uint16_t refcnt;
};I hope the ABI checker won't complain.
It will also be better for 20.11 when the deprecated fields will be
renamed: the remaining one will be called 'refcnt' in both mbuf and mbuf_ext_shared_info.
Olivier
Re: [dpdk-dev] [PATCH v3] mbuf: use C11 atomic built-ins for refcnt operations
Hi Oliver,
Quoted 32 lines
-----Original Message-----
From: Olivier Matz <[email protected]>
Sent: Thursday, July 9, 2020 7:04 PM
To: Phil Yang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v3] mbuf: use C11 atomic built-ins for refcnt operationsHi Phil,
Quoted 19 lines · Phil Yang
Use C11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v3:
1.Fix ABI breakage.
2.Simplify data type cast.v2:
Fix ABI issue: revert therte_mbuf_ext_shared_infostruct refcnt field torefcnt_atomic.lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 19 ++++++++++--------- lib/librte_mbuf/rte_mbuf_core.h | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-)
<snip>
Quoted 26 lines
Review
Quoted 3 lines
lib/librte_mbuf/rte_mbuf.h +0
-0/* Reinitialize counter before mbuf freeing. */ (quoted diff) +0
-0
b/lib/librte_mbuf/rte_mbuf_core.hlib/librte_mbuf/rte_mbuf_core.h typedef void
Quoted 4 lines
index 16600f1..d65d1c8 100644
lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -679,7 +679,7 @@ typedef void(*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);
lib/librte_mbuf/rte_mbuf_core.h typedef void · line 680
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-0struct rte_mbuf_ext_shared_info {rte_mbuf_extbuf_free_callback_t free_cb;/**< Free callback function */
lib/librte_mbuf/rte_mbuf_core.h typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque); · line 683
Quoted 4 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-1void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +uint16_t refcnt_atomic;/**< Atomically accessed refcnt */ };To avoid an API breakage (i.e. currently, an application that accesses to
refcnt_atomicexpects that its type isrte_atomic16_t), I suggest to do the same than in the mbuf struct:union { rte_atomic16_t refcnt_atomic; uint16_t refcnt; };
Quoted 5 lines
I hope the ABI checker won't complain.
It will also be better for 20.11 when the deprecated fields will be
renamed: the remaining one will be called 'refcnt' in both mbuf andmbuf_ext_shared_info.
Got it. I agree with you.
It should work. In my local test machine, the ABI checker happy with this approach. Once the test is done, I will upstream the new patch.
Appreciate your comments.
Thanks,
Phil
Re: [dpdk-dev] [PATCH v3] mbuf: use C11 atomic built-ins for refcnt operations
<snip>
Quoted 50 lines
Quoted 23 lines
Hi Phil,
Quoted 19 lines · Phil Yang
Use C11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v3:
1.Fix ABI breakage.
2.Simplify data type cast.v2:
Fix ABI issue: revert therte_mbuf_ext_shared_infostruct refcnt field torefcnt_atomic.lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 19 ++++++++++--------- lib/librte_mbuf/rte_mbuf_core.h | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-)<snip>
Quoted 26 lines
Quoted 3 lines
/* Reinitialize counter before mbuf freeing. */ diff --git
a/lib/librte_mbuf/rte_mbuf_core.h
b/lib/librte_mbuf/rte_mbuf_core.hlib/librte_mbuf/rte_mbuf_core.h typedef void
Quoted 4 lines
index 16600f1..d65d1c8 100644
lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -679,7 +679,7 @@ typedef void(*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);
lib/librte_mbuf/rte_mbuf_core.h typedef void · line 680
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-0struct rte_mbuf_ext_shared_info {rte_mbuf_extbuf_free_callback_t free_cb;/**< Free callback function */
lib/librte_mbuf/rte_mbuf_core.h typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque); · line 683
Quoted 4 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-1void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +uint16_t refcnt_atomic;/**< Atomically accessed refcnt */ };To avoid an API breakage (i.e. currently, an application that accesses to
refcnt_atomicexpects that its type isrte_atomic16_t), I suggest to do the same than in the mbuf struct:union {
rte_atomic16_trefcnt_atomic;uint16_trefcnt;
};
Quoted 5 lines
Quoted 5 lines
I hope the ABI checker won't complain.
It will also be better for 20.11 when the deprecated fields will be
renamed: the remaining one will be called 'refcnt' in both mbuf andmbuf_ext_shared_info.
Does this need a deprecation notice in 20.08?
Quoted 10 lines
Got it. I agree with you.
It should work. In my local test machine, the ABI checker happy with this approach.
Once the test is done, I will upstream the new patch.Appreciate your comments.
Thanks,
Phil
Re: [dpdk-dev] [PATCH v3] mbuf: use C11 atomic built-ins for refcnt operations
<snip>
Quoted 51 lines
Quoted 51 lines
Quoted 24 lines
Hi Phil,
Quoted 19 lines · Phil Yang
Use C11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v3:
1.Fix ABI breakage.
2.Simplify data type cast.v2:
Fix ABI issue: revert therte_mbuf_ext_shared_infostruct refcnt field torefcnt_atomic.lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 19 ++++++++++--------- lib/librte_mbuf/rte_mbuf_core.h | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-)<snip>
Quoted 26 lines
Quoted 3 lines
/* Reinitialize counter before mbuf freeing. */ diff --git
a/lib/librte_mbuf/rte_mbuf_core.h
b/lib/librte_mbuf/rte_mbuf_core.hlib/librte_mbuf/rte_mbuf_core.h typedef void
Quoted 4 lines
index 16600f1..d65d1c8 100644
lib/librte_mbuf/rte_mbuf_core.h +0
-0@@ -679,7 +679,7 @@ typedef void(*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);
lib/librte_mbuf/rte_mbuf_core.h typedef void · line 680
Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +0
-0struct rte_mbuf_ext_shared_info {rte_mbuf_extbuf_free_callback_t free_cb;/**< Free callback function */
lib/librte_mbuf/rte_mbuf_core.h typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque); · line 683
Quoted 4 lines
lib/librte_mbuf/rte_mbuf_core.h +1
-1void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +uint16_t refcnt_atomic;/**< Atomically accessed refcnt */ };To avoid an API breakage (i.e. currently, an application that accesses to
refcnt_atomicexpects that its type isrte_atomic16_t), I suggest to do the same than in the mbuf struct:union {
rte_atomic16_trefcnt_atomic;uint16_trefcnt;
};
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
I hope the ABI checker won't complain.
It will also be better for 20.11 when the deprecated fields will be
renamed: the remaining one will be called 'refcnt' in both mbuf andmbuf_ext_shared_info.Does this need a deprecation notice in 20.08?
Yes. We'd better do that.
I will add a notice for it in this patch. Thanks.
Quoted 11 lines
Quoted 11 lines
Got it. I agree with you.
It should work. In my local test machine, the ABI checker happy with this approach.
Once the test is done, I will upstream the new patch.Appreciate your comments.
Thanks,
Phil
PATCH v4 1/2 mbuf: use C11 atomic built-ins for refcnt operations
In reply to Phil YangUse C11 atomic built-ins with explicit ordering instead of rte_atomic ops which enforce unnecessary barriers on aarch64.
---
v4:
1. Add union for refcnt_atomic and refcnt in rte_mbuf_ext_shared_info to avoid ABI breakage. (Olivier)
2. Add notice of refcnt_atomic deprecation. (Honnappa)
v3:
1.Fix ABI breakage.
2.Simplify data type cast.
v2:
Fix ABI issue: revert the rte_mbuf_ext_shared_info struct refcnt field to refcnt_atomic.
lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 19 ++++++++++--------- lib/librte_mbuf/rte_mbuf_core.h | 6 +++++- 3 files changed, 15 insertions(+), 11 deletions(-)
lib/librte_mbuf/rte_mbuf.c +0 -1
@@ -22,7 +22,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
lib/librte_mbuf/rte_mbuf.h +10 -9
@@ -37,7 +37,6 @@#include <rte_config.h> #include <rte_mempool.h> #include <rte_memory.h> -#include <rte_atomic.h> #include <rte_prefetch.h> #include <rte_branch_prediction.h> #include <rte_byteorder.h>
@@ -365,7 +364,7 @@ rte_pktmbuf_priv_flags(struct rte_mempool *mp)static inline uint16_t rte_mbuf_refcnt_read (const struct rte_mbuf *m) { -return (uint16_t )(rte_atomic16_read (&m->refcnt_atomic)); +return __atomic_load_n (&m->refcnt, __ATOMIC_RELAXED); }/**
@@ -378,14 +377,15 @@ rte_mbuf_refcnt_read(const struct rte_mbuf *m)static inline void rte_mbuf_refcnt_set (struct rte_mbuf *m,uint16_t new_value) { -rte_atomic16_set (&m->refcnt_atomic, (int16_t )new_value); +__atomic_store_n (&m->refcnt, new_value, __ATOMIC_RELAXED); }/* internal */ static inline uint16_t __rte_mbuf_refcnt_update (struct rte_mbuf *m,int16_t value) { -return (uint16_t )(rte_atomic16_add_return (&m->refcnt_atomic, value)); +return __atomic_add_fetch (&m->refcnt, (uint16_t )value, + __ATOMIC_ACQ_REL); }/**
@@ -466,7 +466,7 @@ rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value)static inline uint16_t rte_mbuf_ext_refcnt_read (const struct rte_mbuf_ext_shared_info *shinfo) { -return (uint16_t )(rte_atomic16_read (&shinfo->refcnt_atomic)); +return __atomic_load_n (&shinfo->refcnt, __ATOMIC_RELAXED); }/**
@@ -481,7 +481,7 @@ static inline void rte_mbuf_ext_refcnt_set(struct rte_mbuf_ext_shared_info *shinfo, uint16_t new_value) { - rte_atomic16_set(&shinfo->refcnt_atomic, (int16_t)new_value); + __atomic_store_n(&shinfo->refcnt, new_value, __ATOMIC_RELAXED); }/**
@@ -505,7 +505,8 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo,return (uint16_t )value; } -return (uint16_t )rte_atomic16_add_return (&shinfo->refcnt_atomic, value); +return __atomic_add_fetch (&shinfo->refcnt, (uint16_t )value, + __ATOMIC_ACQ_REL); }/** Mbuf prefetch */
@@ -1304,8 +1305,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 (rte_atomic16_add_return - (&shinfo->refcnt_atomic,-1 ))) +if (likely (__atomic_add_fetch (&shinfo->refcnt, (uint16_t )-1 , + __ATOMIC_ACQ_REL)))return 1 ;/* Reinitialize counter before mbuf freeing. */
lib/librte_mbuf/rte_mbuf_core.h +5 -1
@@ -679,7 +679,11 @@ typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);struct rte_mbuf_ext_shared_info {rte_mbuf_extbuf_free_callback_t free_cb;/**< Free callback function */ void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +RTE_STD_C11 + union { + rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */ +uint16_t refcnt; + }; };/**< Maximum number of nb_segs allowed. */
Signature · 1 line
2.7.4
PATCH v4 2/2 doc: announce deprecation of refcnt atomic member
refcnt_atomic member in structures rte_mbuf and rte_mbuf_ext_shared_info will be deprecated in 20.11 release.
--- doc/guides/rel_notes/deprecation.rst | 6 ++++++ 1 file changed, 6 insertions(+)
doc/guides/rel_notes/deprecation.rst +6 -0
@@ -123,6 +123,12 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. +* mbuf: ``refcnt_atomic`` member in structures ``rte_mbuf`` and + ``rte_mbuf_ext_shared_info`` is of type ``rte_atomic16_t``. Due to adoption + of C11 atomic built-ins it will be of type ``uint16_t``. ``refcnt_atomic`` + will be removed in 20.11. It will be replaced with ``refcnt`` of type + ``uint16_t``. + * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v4 2/2] doc: announce deprecation of refcnt atomic member
Quoted 11 lines
-----Original Message-----
From: Phil Yang <[email protected]>
Sent: Thursday, July 9, 2020 11:59 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; nd <[email protected]>
Subject: [PATCH v4 2/2] doc: announce deprecation of refcnt atomic member
Quoted 2 lines
refcnt_atomicmember in structuresrte_mbufandrte_mbuf_ext_shared_infowill be deprecated in 20.11 release.
The plan should be deprecate it in 20.08 release and remove it in 20.11 release.
Quoted 29 lines
Signed-off-by Phil Yang <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 6 ++++++ 1 file changed, 6 insertions(+)doc/guides/rel_notes/deprecation.rst +0
-0@@ -123,6 +123,12 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested inthe
RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html.doc/guides/rel_notes/deprecation.rst +8
-1+* mbuf: ``refcnt_atomic`` member in structures ``rte_mbuf`` and + ``rte_mbuf_ext_shared_info`` is of type ``rte_atomic16_t``. Due to +adoption + of C11 atomic built-ins it will be of type ``uint16_t``. +``refcnt_atomic`` + will be removed in 20.11. It will be replaced with ``refcnt`` of type + ``uint16_t``. + * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``. --2.7.4
Re: [dpdk-dev] [PATCH v4 2/2] doc: announce deprecation of refcnt atomic member
Ruifeng Wang <[email protected]> writes:
<snip>
Quoted 7 lines
Quoted 1 line
Subject: [PATCH v4 2/2] doc: announce deprecation of refcnt atomic
member
Quoted 3 lines
refcnt_atomicmember in structuresrte_mbufandrte_mbuf_ext_shared_infowill be deprecated in 20.11 release.The plan should be deprecate it in 20.08 release and remove it in 20.11 release.
Yes. Just like Oliver suggested, we will deprecate it in 20.08 release and remove it in 20.11.
http://patchwork.dpdk.org/patch/73632/
Let's see if we have any other comments.
+Jerin and Konstantin.
Thanks,
Phil
Quoted 31 lines
Quoted 13 lines
Signed-off-by Phil Yang <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 6 ++++++ 1 file changed, 6 insertions(+)doc/guides/rel_notes/deprecation.rst +0
-0doc/guides/rel_notes/deprecation.rst Deprecation Notices · line 123
Quoted 1 line
doc/guides/rel_notes/deprecation.rst +0
-0@@ -123,6 +123,12 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggestedin
Quoted 16 lines
the
RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html.doc/guides/rel_notes/deprecation.rst +8
-1+* mbuf: ``refcnt_atomic`` member in structures ``rte_mbuf`` and + ``rte_mbuf_ext_shared_info`` is of type ``rte_atomic16_t``. Due to +adoption + of C11 atomic built-ins it will be of type ``uint16_t``. +``refcnt_atomic`` + will be removed in 20.11. It will be replaced with ``refcnt`` of type + ``uint16_t``. + * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``. --2.7.4
Re: [dpdk-dev] [PATCH v4 2/2] doc: announce deprecation of refcnt atomic member
In reply to Phil YangQuoted 17 lines
refcnt_atomicmember in structuresrte_mbufandrte_mbuf_ext_shared_infowill be deprecated in 20.11 release.Signed-off-by Phil Yang <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 6 ++++++ 1 file changed, 6 insertions(+)doc/guides/rel_notes/deprecation.rst +0
-0@@ -123,6 +123,12 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html.
doc/guides/rel_notes/deprecation.rst Deprecation Notices
Quoted 10 lines
doc/guides/rel_notes/deprecation.rst +6
-1+* mbuf: ``refcnt_atomic`` member in structures ``rte_mbuf`` and + ``rte_mbuf_ext_shared_info`` is of type ``rte_atomic16_t``. Due to adoption + of C11 atomic built-ins it will be of type ``uint16_t``. ``refcnt_atomic`` + will be removed in 20.11. It will be replaced with ``refcnt`` of type + ``uint16_t``. + * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``. --
Quoted 1 line
2.7.4
Re: [dpdk-dev] [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations
In reply to Phil YangQuoted 11 lines · Phil Yang
Use C11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v4:
1. Add union forrefcnt_atomicand refcnt inrte_mbuf_ext_shared_infoto avoid ABI breakage. (Olivier)
2. Add notice ofrefcnt_atomicdeprecation. (Honnappa)
v4 does not pass the checks (in both my env, and Travis).
https://travis-ci.com/github/ovsrobot/dpdk/jobs/359393389#L2405
It seems the robot had a hiccup as I can't see a report in the test-report ml.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations
Quoted 13 lines · David Marchand
Quoted 11 lines · Phil Yang
Use C11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v4:
1. Add union forrefcnt_atomicand refcnt inrte_mbuf_ext_shared_infoto avoid ABI breakage. (Olivier)
2. Add notice ofrefcnt_atomicdeprecation. (Honnappa)
Quoted 4 lines
v4 does not pass the checks (in both my env, and Travis).
https://travis-ci.com/github/ovsrobot/dpdk/jobs/359393389#L2405It seems the robot had a hiccup as I can't see a report in the test-report ml.
Hrrm... that has been happening quite a bit. I'll investigate.
Re: [dpdk-dev] [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations
In reply to David MarchandQuoted 26 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Wednesday, July 15, 2020 8:29 PM
To: Phil Yang <[email protected]>
Cc: Olivier Matz <[email protected]>; dev <[email protected]>; Stephen Hemminger <[email protected]>; David Christensen <[email protected]>; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; nd <[email protected]>; Dodji Seketeli <[email protected]>; Aaron Conole <[email protected]>
Subject: Re: [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operationsQuoted 11 lines · Phil Yang
Use C11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v4:
1. Add union forrefcnt_atomicand refcnt inrte_mbuf_ext_shared_infoto avoid ABI breakage. (Olivier)
2. Add notice ofrefcnt_atomicdeprecation. (Honnappa)
Quoted 2 lines
v4 does not pass the checks (in both my env, and Travis).
https://travis-ci.com/github/ovsrobot/dpdk/jobs/359393389#L2405
I had tested with test-meson-builds in my env and it didn't give any error message. The reference version is v20.05.
$ DPDK_ABI_REF_DIR=$PWD/reference DPDK_ABI_REF_VERSION=v20.05 ./devtools/test-meson-builds.sh
It seems to be a problem with my test environment. I will fix this problem as soon as possible.
Quoted 6 lines
It seems the robot had a hiccup as I can't see a report in the test-report ml.
--
David Marchand
Re: [dpdk-dev] [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations
In reply to David MarchandQuoted 16 lines · David Marchand
Subject: Re: [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations
Quoted 11 lines · Phil Yang
Use C11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v4:
1. Add union forrefcnt_atomicand refcnt inrte_mbuf_ext_shared_infoto avoid ABI breakage. (Olivier)
2. Add notice ofrefcnt_atomicdeprecation. (Honnappa)
Quoted 2 lines
v4 does not pass the checks (in both my env, and Travis).
https://travis-ci.com/github/ovsrobot/dpdk/jobs/359393389#L2405
I think we need an exception in 'libabigail.abignore' for this change. Is that OK with you?
Thanks,
Phil
Quoted 6 lines
It seems the robot had a hiccup as I can't see a report in the test-report ml.
--
David Marchand
Re: [dpdk-dev] [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations
Quoted 19 lines · Phil Yang
Quoted 16 lines · David Marchand
Subject: Re: [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations
Quoted 11 lines · Phil Yang
Use C11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
v4:
1. Add union forrefcnt_atomicand refcnt inrte_mbuf_ext_shared_infoto avoid ABI breakage. (Olivier)
2. Add notice ofrefcnt_atomicdeprecation. (Honnappa)
Quoted 5 lines
Quoted 2 lines
v4 does not pass the checks (in both my env, and Travis).
https://travis-ci.com/github/ovsrobot/dpdk/jobs/359393389#L2405I think we need an exception in 'libabigail.abignore' for this change. Is that OK with you?
Testing the series with libabigail 1.7.0:
Functions changes summary: 0 Removed, 1 Changed (6 filtered out), 0 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function unsigned int rte_reorder_drain(rte_reorder_buffer*,
rte_mbuf**, unsigned int)' at rte_reorder.c:367:1 has some indirect sub-type changes:
parameter 2 of type 'rte_mbuf**' has sub-type changes:
in pointed to type 'rte_mbuf*':
in pointed to type 'struct rte_mbuf' at rte_mbuf_core.h:469:1:
type size hasn't changed
1 data member changes (1 filtered):
type of 'rte_mbuf_ext_shared_info* rte_mbuf::shinfo' changed:
in pointed to type 'struct rte_mbuf_ext_shared_info' at
rte_mbuf_core.h:679:1:
type size hasn't changed
1 data member change:
data member rte_atomic16_trte_mbuf_ext_shared_info::refcnt_atomic at offset 128 (in bits) became anonymous data member 'union {rte_atomic16_t refcnt_atomic; uint16_t refcnt;}'
Error: ABI issue reported for 'abidiff --suppr /home/dmarchan/dpdk/devtools/../devtools/libabigail.abignore --no-added-syms --headers-dir1 /home/dmarchan/abi/v20.05/build-gcc-static/usr/local/include --headers-dir2 /home/dmarchan/builds/build-gcc-static/install/usr/local/include /home/dmarchan/abi/v20.05/build-gcc-static/dump/librte_reorder.dump /home/dmarchan/builds/build-gcc-static/install/dump/librte_reorder.dump'
ABIDIFF_ABI_CHANGE, this change requires a review (abidiff flagged this as a potential issue).
We will have no other update on mbuf for 20.08, so the following rule can do the job for 20.08 and we will remove it in 20.11.
devtools/libabigail.abignore +4 -0
@@ -52,6 +52,10 @@ [suppress_type] type_kind = struct name = rte_epoll_event +; Ignore updates of rte_mbuf_ext_shared_info +[suppress_type] + type_kind = struct + name = rte_mbuf_ext_shared_info ;;;;;;;;;;;;;;;;;;;;;; ; Temporary exceptions till DPDK 20.11
Olivier, Dodji, Ray?
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations
Hello,
David Marchand <[email protected]> writes:
[...]
Quoted 6 lines · Phil Yang
Quoted 6 lines
Quoted 3 lines
v4 does not pass the checks (in both my env, and Travis).
https://travis-ci.com/github/ovsrobot/dpdk/jobs/359393389#L2405I think we need an exception in 'libabigail.abignore' for this change. Is that OK with you?
David Marchand <[email protected]> writes:
[...]
Quoted 5 lines
Testing the series with libabigail 1.7.0:
Functions changes summary: 0 Removed, 1 Changed (6 filtered out), 0 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
[...]
Quoted 6 lines
in pointed to type 'struct
rte_mbuf_ext_shared_info' at rte_mbuf_core.h:679:1:
type size hasn't changed
1 data member change:
data memberrte_atomic16_trte_mbuf_ext_shared_info::refcnt_atomicat offset 128 (in bits) became anonymous data member 'union {rte_atomic16_trefcnt_atomic;uint16_trefcnt;}'
[...]
Quoted 15 lines
We will have no other update on mbuf for 20.08, so the following rule can do the job for 20.08 and we will remove it in 20.11.
devtools/libabigail.abignore +4
-0@@ -52,6 +52,10 @@ [suppress_type] type_kind = struct name = rte_epoll_event +; Ignore updates of rte_mbuf_ext_shared_info +[suppress_type] + type_kind = struct + name = rte_mbuf_ext_shared_info
[...]
Quoted 1 line
Olivier, Dodji, Ray?
Yes, that should work.
Just for the sake of precision, I'd like to say that in the coming 1.8 version of libabigail, this change won't be reported by the tooling as a problem anymore. This is thanks to David filing the feature request
https://sourceware.org/bugzilla/show_bug.cgi?id=25661 a while ago.
Until then, I understand that the current tooling needs to work with libabigail 1.6.
So maybe a more specific suppression rule (that you could still remove for the 20.11 stable branch) could look like:
[suppress_type]
name = rte_mbuf_ext_shared_info
has_data_member_inserted_between = {offset_of(refcnt_atomic), offset_of(refcnt_atomic)}
It's a "hack" that will only suppress change reports on the rte_mbuf_ext_shared_info type if:
1/ it it has a data member inserted at the
offset of its data member 'refcnt_atomic',
AND
2/ the size of rte_mbuf_ext_shared_info doesn't change.
There are cases where this won't work, though. But it might work for this case. If it does, then great. I think it'd be a better solution than a blanket suppression of all the changes on the type.
Cheers,
Signature · 1 line
Dodji
Re: [dpdk-dev] [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations
Quoted 7 lines · Dodji Seketeli
Just for the sake of precision, I'd like to say that in the coming 1.8 version of libabigail, this change won't be reported by the tooling as a problem anymore. This is thanks to David filing the feature request
https://sourceware.org/bugzilla/show_bug.cgi?id=25661 a while ago.Until then, I understand that the current tooling needs to work with libabigail 1.6.
That's what we have in the CI with a 1.6 libabigail compiled in Ubuntu 18.04.
I tested 20.04 in Travis (I can send a patch later), but it still has a 1.6 version.
We will have to live with a "not that recent" version for some time.
Quoted 15 lines
So maybe a more specific suppression rule (that you could still remove for the 20.11 stable branch) could look like:
[
suppress_type]
name =rte_mbuf_ext_shared_info
has_data_member_inserted_between= {offset_of(refcnt_atomic),offset_of(refcnt_atomic)}It's a "hack" that will only suppress change reports on the
rte_mbuf_ext_shared_infotype if:1/ it it has a data member inserted at the
offset of its data member 'refcnt_atomic',
Quoted 8 lines
AND
2/ the size of
rte_mbuf_ext_shared_infodoesn't change.There are cases where this won't work, though. But it might work for this case. If it does, then great. I think it'd be a better solution than a blanket suppression of all the changes on the type.
Nice, thanks Dodji.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations
<snip>
Quoted 34 lines · Dodji Seketeli
Quoted 7 lines
Just for the sake of precision, I'd like to say that in the coming 1.8 version of libabigail, this change won't be reported by the tooling as a problem anymore. This is thanks to David filing the feature request
https://sourceware.org/bugzilla/show_bug.cgi?id=25661 a while ago.Until then, I understand that the current tooling needs to work with libabigail 1.6.
That's what we have in the CI with a 1.6 libabigail compiled in Ubuntu 18.04.
I tested 20.04 in Travis (I can send a patch later), but it still has a 1.6 version.
We will have to live with a "not that recent" version for some time.Quoted 7 lines
So maybe a more specific suppression rule (that you could still remove for the 20.11 stable branch) could look like:
[
suppress_type]
name =rte_mbuf_ext_shared_infohas_data_member_inserted_between= {offset_of(refcnt_atomic),
offset_of(refcnt_atomic)}Quoted 10 lines
It's a "hack" that will only suppress change reports on the
rte_mbuf_ext_shared_infotype if:1/ it it has a data member inserted at the
offset of its data member 'refcnt_atomic',AND
Quoted 8 lines
Quoted 6 lines
2/ the size of
rte_mbuf_ext_shared_infodoesn't change.There are cases where this won't work, though. But it might work for this case. If it does, then great. I think it'd be a better solution than a blanket suppression of all the changes on the type.
Nice, thanks Dodji.
Thanks, David and Dodji.
Updated in v5.
Thanks,
Phil
Re: [dpdk-dev] [PATCH v4 1/2] mbuf: use C11 atomic built-ins for refcnt operations
In reply to Phil YangQuoted 5 lines · Phil Yang
Use C11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
Thanks
PATCH v5 1/2 mbuf: use C11 atomic builtins for refcnt operations
In reply to Phil YangUse C11 atomic builtins with explicit ordering instead of rte_atomic ops which enforce unnecessary barriers on aarch64.
---
v5:
1. Change built-ins to builtins.
2. Ignore updates of rte_mbuf_ext_shared_info refcnt_atomic in ABI checker.
v4:
1. Add union for refcnt_atomic and refcnt in rte_mbuf_ext_shared_info to avoid ABI breakage. (Olivier)
2. Add notice of refcnt_atomic deprecation. (Honnappa)
v3:
1.Fix ABI breakage.
2.Simplify data type cast.
v2:
Fix ABI issue: revert the rte_mbuf_ext_shared_info struct refcnt field to refcnt_atomic.
devtools/libabigail.abignore | 4 ++++ lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 19 ++++++++++--------- lib/librte_mbuf/rte_mbuf_core.h | 6 +++++- 4 files changed, 19 insertions(+), 11 deletions(-)
devtools/libabigail.abignore +4 -0
@@ -52,6 +52,10 @@ [suppress_type] type_kind = struct name = rte_epoll_event +; Ignore updates of rte_mbuf_ext_shared_info refcnt_atomic +[suppress_type] + name = rte_mbuf_ext_shared_info + has_data_member_inserted_between = {offset_of(refcnt_atomic), offset_of(refcnt_atomic)} ;;;;;;;;;;;;;;;;;;;;;; ; Temporary exceptions till DPDK 20.11
lib/librte_mbuf/rte_mbuf.c +0 -1
@@ -22,7 +22,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_mempool.h> #include <rte_mbuf.h>
lib/librte_mbuf/rte_mbuf.h +10 -9
@@ -37,7 +37,6 @@#include <rte_config.h> #include <rte_mempool.h> #include <rte_memory.h> -#include <rte_atomic.h> #include <rte_prefetch.h> #include <rte_branch_prediction.h> #include <rte_byteorder.h>
@@ -365,7 +364,7 @@ rte_pktmbuf_priv_flags(struct rte_mempool *mp)static inline uint16_t rte_mbuf_refcnt_read (const struct rte_mbuf *m) { -return (uint16_t )(rte_atomic16_read (&m->refcnt_atomic)); +return __atomic_load_n (&m->refcnt, __ATOMIC_RELAXED); }/**
@@ -378,14 +377,15 @@ rte_mbuf_refcnt_read(const struct rte_mbuf *m)static inline void rte_mbuf_refcnt_set (struct rte_mbuf *m,uint16_t new_value) { -rte_atomic16_set (&m->refcnt_atomic, (int16_t )new_value); +__atomic_store_n (&m->refcnt, new_value, __ATOMIC_RELAXED); }/* internal */ static inline uint16_t __rte_mbuf_refcnt_update (struct rte_mbuf *m,int16_t value) { -return (uint16_t )(rte_atomic16_add_return (&m->refcnt_atomic, value)); +return __atomic_add_fetch (&m->refcnt, (uint16_t )value, + __ATOMIC_ACQ_REL); }/**
@@ -466,7 +466,7 @@ rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value)static inline uint16_t rte_mbuf_ext_refcnt_read (const struct rte_mbuf_ext_shared_info *shinfo) { -return (uint16_t )(rte_atomic16_read (&shinfo->refcnt_atomic)); +return __atomic_load_n (&shinfo->refcnt, __ATOMIC_RELAXED); }/**
@@ -481,7 +481,7 @@ static inline void rte_mbuf_ext_refcnt_set(struct rte_mbuf_ext_shared_info *shinfo, uint16_t new_value) { - rte_atomic16_set(&shinfo->refcnt_atomic, (int16_t)new_value); + __atomic_store_n(&shinfo->refcnt, new_value, __ATOMIC_RELAXED); }/**
@@ -505,7 +505,8 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo,return (uint16_t )value; } -return (uint16_t )rte_atomic16_add_return (&shinfo->refcnt_atomic, value); +return __atomic_add_fetch (&shinfo->refcnt, (uint16_t )value, + __ATOMIC_ACQ_REL); }/** Mbuf prefetch */
@@ -1304,8 +1305,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 (rte_atomic16_add_return - (&shinfo->refcnt_atomic,-1 ))) +if (likely (__atomic_add_fetch (&shinfo->refcnt, (uint16_t )-1 , + __ATOMIC_ACQ_REL)))return 1 ;/* Reinitialize counter before mbuf freeing. */
lib/librte_mbuf/rte_mbuf_core.h +5 -1
@@ -679,7 +679,11 @@ typedef void (*rte_mbuf_extbuf_free_callback_t)(void *addr, void *opaque);struct rte_mbuf_ext_shared_info {rte_mbuf_extbuf_free_callback_t free_cb;/**< Free callback function */ void *fcb_opaque;/**< Free callback argument */ -rte_atomic16_t refcnt_atomic;/**< Atomically accessed refcnt */ +RTE_STD_C11 + union { + rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */ +uint16_t refcnt; + }; };/**< Maximum number of nb_segs allowed. */
Signature · 1 line
2.7.4
PATCH v5 2/2 doc: announce deprecation of refcnt atomic member
refcnt_atomic member in structures rte_mbuf and rte_mbuf_ext_shared_info will be deprecated in 20.11 release.
--- doc/guides/rel_notes/deprecation.rst | 6 ++++++ 1 file changed, 6 insertions(+)
doc/guides/rel_notes/deprecation.rst +6 -0
@@ -129,6 +129,12 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. +* mbuf: ``refcnt_atomic`` member in structures ``rte_mbuf`` and + ``rte_mbuf_ext_shared_info`` is of type ``rte_atomic16_t``. Due to adoption + of C11 atomic builtins it will be of type ``uint16_t``. ``refcnt_atomic`` + will be removed in 20.11. It will be replaced with ``refcnt`` of type + ``uint16_t``. + * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v5 2/2] doc: announce deprecation of refcnt atomic member
Quoted 6 lines · Phil Yang
refcnt_atomicmember in structuresrte_mbufandrte_mbuf_ext_shared_infowill be deprecated in 20.11 release.Suggested-by Honnappa Nagarahalli <[email protected]>Signed-off-by Phil Yang <[email protected]>
Re: [dpdk-dev] [PATCH v5 2/2] doc: announce deprecation of refcnt atomic member
In reply to Phil YangQuoted 29 lines · Phil Yang
refcnt_atomicmember in structuresrte_mbufandrte_mbuf_ext_shared_infowill be deprecated in 20.11 release.Suggested-by Honnappa Nagarahalli <[email protected]>Signed-off-by Phil Yang <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 6 ++++++ 1 file changed, 6 insertions(+)doc/guides/rel_notes/deprecation.rst +6
-1@@ -129,6 +129,12 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. +* mbuf: ``refcnt_atomic`` member in structures ``rte_mbuf`` and + ``rte_mbuf_ext_shared_info`` is of type ``rte_atomic16_t``. Due to adoption + of C11 atomic builtins it will be of type ``uint16_t``. ``refcnt_atomic`` + will be removed in 20.11. It will be replaced with ``refcnt`` of type + ``uint16_t``. + * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``. --
Quoted 2 lines
2.7.4
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v5 2/2] doc: announce deprecation of refcnt atomic member
Quoted 30 lines · David Marchand
Quoted 28 lines · Phil Yang
refcnt_atomicmember in structuresrte_mbufandrte_mbuf_ext_shared_infowill be deprecated in 20.11 release.Suggested-by Honnappa Nagarahalli <[email protected]>Signed-off-by Phil Yang <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 6 ++++++ 1 file changed, 6 insertions(+)doc/guides/rel_notes/deprecation.rst +6
-0@@ -129,6 +129,12 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. +* mbuf: ``refcnt_atomic`` member in structures ``rte_mbuf`` and + ``rte_mbuf_ext_shared_info`` is of type ``rte_atomic16_t``. Due to adoption + of C11 atomic builtins it will be of type ``uint16_t``. ``refcnt_atomic`` + will be removed in 20.11. It will be replaced with ``refcnt`` of type + ``uint16_t``. + * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.
Quoted 5 lines
Quoted 3 lines
--
2.7.4Acked-by David Marchand <[email protected]>
Bruce, Konstantin,
This precedes the first open source release so trying with you guys:
what is the purpose of the RTE_MBUF_REFCNT_ATOMIC build flag? Thanks.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v5 2/2] doc: announce deprecation of refcnt atomic member
Hi David,
Quoted 38 lines
Quoted 30 lines · David Marchand
Quoted 28 lines · Phil Yang
refcnt_atomicmember in structuresrte_mbufandrte_mbuf_ext_shared_infowill be deprecated in 20.11 release.Suggested-by Honnappa Nagarahalli <[email protected]>Signed-off-by Phil Yang <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 6 ++++++ 1 file changed, 6 insertions(+)doc/guides/rel_notes/deprecation.rst +6
-0@@ -129,6 +129,12 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. +* mbuf: ``refcnt_atomic`` member in structures ``rte_mbuf`` and + ``rte_mbuf_ext_shared_info`` is of type ``rte_atomic16_t``. Due to adoption + of C11 atomic builtins it will be of type ``uint16_t``. ``refcnt_atomic`` + will be removed in 20.11. It will be replaced with ``refcnt`` of type + ``uint16_t``. + * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.Quoted 5 lines
Quoted 3 lines
--
2.7.4Acked-by David Marchand <[email protected]>
Quoted 6 lines
Bruce, Konstantin,
This precedes the first open source release so trying with you guys:
what is the purpose of theRTE_MBUF_REFCNT_ATOMICbuild flag? Thanks.
As I remember it was possible to build/run DPDK with non-atomic refcnt, i.e. each lcore manages/works with its own mempools.
Don't know does anyone yet rely on that feature.
Re: [dpdk-dev] [PATCH v5 2/2] doc: announce deprecation of refcnt atomic member
In reply to David MarchandQuoted 38 lines · David Marchand
Quoted 30 lines · David Marchand
Quoted 28 lines · Phil Yang
refcnt_atomicmember in structuresrte_mbufandrte_mbuf_ext_shared_infowill be deprecated in 20.11 release.Suggested-by Honnappa Nagarahalli <[email protected]>Signed-off-by Phil Yang <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 6 ++++++ 1 file changed, 6 insertions(+)doc/guides/rel_notes/deprecation.rst +6
-0@@ -129,6 +129,12 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. +* mbuf: ``refcnt_atomic`` member in structures ``rte_mbuf`` and + ``rte_mbuf_ext_shared_info`` is of type ``rte_atomic16_t``. Due to adoption + of C11 atomic builtins it will be of type ``uint16_t``. ``refcnt_atomic`` + will be removed in 20.11. It will be replaced with ``refcnt`` of type + ``uint16_t``. + * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.Quoted 5 lines
Quoted 3 lines
--
2.7.4Acked-by David Marchand <[email protected]>
Quoted 6 lines
Bruce, Konstantin,
This precedes the first open source release so trying with you guys:
what is the purpose of theRTE_MBUF_REFCNT_ATOMICbuild flag? Thanks.
That's indeed going back a long way!
IIRC When we first introduced a reference count, I believe we considered cases where we would not need atomics to work on the ref count, and added the build macro to remove the cost of the atomic in those instances. For example, if a TCP stack wanted to hold on to an mbuf after transmission rather than having it freed to the mempool (in case it needed to be retransmitted), it could increment the reference count to ensure that did not occur. Later if an ack for the TCP packet was received the buffer could be freed. So long as the same thread that did the TX freed the buffer later, no atomic increment or decrement was necessary.
Similarly for a run-to-completion app which fragmented packets using multiple mbufs referencing a single packet buffer. So long as only a single thread worked on the buffer, the reference counters need not be atomic.
In practice, the general case needs to be atomic ref-counts, and I'm not sure who, if anyone, uses this setting in their apps. It should be convertable to a runtime setting if needed.
/Bruce
Re: [dpdk-dev] [PATCH v5 2/2] doc: announce deprecation of refcnt atomic member
Quoted 58 lines · Bruce Richardson
Quoted 38 lines · David Marchand
Quoted 30 lines · David Marchand
Quoted 28 lines · Phil Yang
refcnt_atomicmember in structuresrte_mbufandrte_mbuf_ext_shared_infowill be deprecated in 20.11 release.Suggested-by Honnappa Nagarahalli <[email protected]>Signed-off-by Phil Yang <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 6 ++++++ 1 file changed, 6 insertions(+)doc/guides/rel_notes/deprecation.rst +6
-0@@ -129,6 +129,12 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. +* mbuf: ``refcnt_atomic`` member in structures ``rte_mbuf`` and + ``rte_mbuf_ext_shared_info`` is of type ``rte_atomic16_t``. Due to adoption + of C11 atomic builtins it will be of type ``uint16_t``. ``refcnt_atomic`` + will be removed in 20.11. It will be replaced with ``refcnt`` of type + ``uint16_t``. + * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.Quoted 5 lines
Quoted 3 lines
--
2.7.4Acked-by David Marchand <[email protected]>Quoted 6 lines
Bruce, Konstantin,
This precedes the first open source release so trying with you guys:
what is the purpose of theRTE_MBUF_REFCNT_ATOMICbuild flag? Thanks.That's indeed going back a long way!
IIRC When we first introduced a reference count, I believe we considered cases where we would not need atomics to work on the ref count, and added the build macro to remove the cost of the atomic in those instances. For example, if a TCP stack wanted to hold on to an mbuf after transmission rather than having it freed to the mempool (in case it needed to be retransmitted), it could increment the reference count to ensure that did not occur. Later if an ack for the TCP packet was received the buffer could be freed. So long as the same thread that did the TX freed the buffer later, no atomic increment or decrement was necessary.
Quoted 7 lines
Similarly for a run-to-completion app which fragmented packets using multiple mbufs referencing a single packet buffer. So long as only a single thread worked on the buffer, the reference counters need not be atomic.
In practice, the general case needs to be atomic ref-counts, and I'm not sure who, if anyone, uses this setting in their apps. It should be convertable to a runtime setting if needed.
Thanks Bruce and Konstantin.
With the switch to meson and not being able to enable/disable this build flag, we will lose this feature.
It seems to be a quite special use case, so we might need a new dedicated API?
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v5 2/2] doc: announce deprecation of refcnt atomic member
Quoted 69 lines
Quoted 58 lines · Bruce Richardson
Quoted 38 lines · David Marchand
Quoted 30 lines · David Marchand
Quoted 28 lines · Phil Yang
refcnt_atomicmember in structuresrte_mbufandrte_mbuf_ext_shared_infowill be deprecated in 20.11 release.Suggested-by Honnappa Nagarahalli <[email protected]>Signed-off-by Phil Yang <[email protected]>--- doc/guides/rel_notes/deprecation.rst | 6 ++++++ 1 file changed, 6 insertions(+)doc/guides/rel_notes/deprecation.rst +6
-0@@ -129,6 +129,12 @@ Deprecation Notices in "rte_sched.h". These changes are aligned to improvements suggested in the RFC https://mails.dpdk.org/archives/dev/2018-November/120035.html. +* mbuf: ``refcnt_atomic`` member in structures ``rte_mbuf`` and + ``rte_mbuf_ext_shared_info`` is of type ``rte_atomic16_t``. Due to adoption + of C11 atomic builtins it will be of type ``uint16_t``. ``refcnt_atomic`` + will be removed in 20.11. It will be replaced with ``refcnt`` of type + ``uint16_t``. + * metrics: The function ``rte_metrics_init`` will have a non-void return in order to notify errors instead of calling ``rte_exit``.Quoted 5 lines
Quoted 3 lines
--
2.7.4Acked-by David Marchand <[email protected]>Quoted 6 lines
Bruce, Konstantin,
This precedes the first open source release so trying with you guys:
what is the purpose of theRTE_MBUF_REFCNT_ATOMICbuild flag? Thanks.That's indeed going back a long way!
IIRC When we first introduced a reference count, I believe we considered cases where we would not need atomics to work on the ref count, and added the build macro to remove the cost of the atomic in those instances. For example, if a TCP stack wanted to hold on to an mbuf after transmission rather than having it freed to the mempool (in case it needed to be retransmitted), it could increment the reference count to ensure that did not occur. Later if an ack for the TCP packet was received the buffer could be freed. So long as the same thread that did the TX freed the buffer later, no atomic increment or decrement was necessary.
Quoted 7 lines
Similarly for a run-to-completion app which fragmented packets using multiple mbufs referencing a single packet buffer. So long as only a single thread worked on the buffer, the reference counters need not be atomic.
In practice, the general case needs to be atomic ref-counts, and I'm not sure who, if anyone, uses this setting in their apps. It should be convertable to a runtime setting if needed.
Quoted 6 lines
Thanks Bruce and Konstantin.
With the switch to meson and not being able to enable/disable this build flag, we will lose this feature.
It seems to be a quite special use case, so we might need a new dedicated API?
I'd better go for deprecate and remove it completely. Konstantin
Re: [dpdk-dev] [PATCH v5 1/2] mbuf: use C11 atomic builtins for refcnt operations
In reply to Phil YangQuoted 9 lines · Phil Yang
Use C11 atomic builtins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Suggested-by Olivier Matz <[email protected]>Suggested-by Dodji Seketeli <[email protected]>Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Acked-by Olivier Matz <[email protected]>
Series applied, thanks Phil.
Signature · 1 line
David Marchand