From: Wathsala Vithanage <wathsala.vithanage@arm.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org, Konstantin Ananyev <konstantin.ananyev@huawei.com>,
Marat Khalili <qm2k21@gmail.com>
Subject: Re: [PATCH v3 01/29] bpf: replace deprecated SMP barriers with C11 fences
Date: Mon, 12 Oct 2026 10:40:27 -0500 [thread overview]
Message-ID: <7355c1fe-b9d3-493e-b8ee-c518ddbc58e5@arm.com> (raw)
In-Reply-To: <20261009084744.046a7200@phoenix.local>
On 10/9/26 10:48, Stephen Hemminger wrote:
> On Fri, 9 Oct 2026 01:05:56 -0500
> Wathsala Vithanage <wathsala.vithanage@arm.com> wrote:
>
>>> /*
>>> * Marks given callback as used by datapath.
>>> */
>>> static __rte_always_inline void
>>> bpf_eth_cbi_inuse(struct bpf_eth_cbi *cbi)
>>> {
>>> - cbi->use++;
>>> - /* make sure no store/load reordering could happen */
>>> - rte_smp_mb();
>>> + rte_atomic_store_explicit(&cbi->use,
>>> + rte_atomic_load_explicit(&cbi->use, rte_memory_order_relaxed) + 1,
>>> + rte_memory_order_relaxed);
>>> +
>>> + /* full barrier: count must be visible before cb is read */
>>> + rte_atomic_thread_fence(rte_memory_order_seq_cst);
>> This is correct but why use a barrier when the above store itself could
>> be SEQ_CST that
>> synchronizes with load in bpf_eth_cbi_wait?
> There are two different things be covered for safety here.
> The counter and the callback pointer. The counter uses atomic
> operations and the callback pointer is referenced without atomic.
> AI explains it as:
>
> A seq_cst store on the counter is not enough. This is a store/load
> pattern across two objects:
>
> datapath: store use, load cb
> unload: store cb, load use
>
> At least one side has to see the other's store. Making the store
> of use seq_cst does not order the datapath's later load of cb,
> which is a plain load. On arm64 that compiles to stlr followed by
> ldr, and the ldr can be satisfied before the stlr is visible.
> Only stlr/ldar pairs are kept in order.
>
> It can be done without fences by making cb atomic and using
> seq_cst for all four accesses (stlr + ldar on arm64). That touches
> every callback and is a bigger change than replacing the barriers,
> so I would rather do it as a follow-up if at all.
>
> There is no cost difference on x86. A seq_cst store is xchg and
> the fence is lock addl, one locked instruction per burst either
> way.
Agreed, barrier is the better implementation than converting
everything into seq_cst.
Reviewed-by: Wathsala Vithanage <wathsala.vithanage@arm.com>
--wathsala
next prev parent reply other threads:[~2026-10-12 15:40 UTC|newest]
Thread overview: 169+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 17:53 [RFC 00/32] remove rte_smp barrier functions Stephen Hemminger
2026-07-29 17:53 ` [RFC 01/32] bpf: replace deprecated SMP barriers with C11 fences Stephen Hemminger
2026-07-30 8:48 ` Marat Khalili
2026-07-30 11:19 ` Marat Khalili
2026-07-30 12:51 ` Konstantin Ananyev
2026-07-30 9:23 ` Konstantin Ananyev
2026-07-29 17:53 ` [RFC 02/32] test: remove test for rte_smp_mb Stephen Hemminger
2026-07-30 7:25 ` Konstantin Ananyev
2026-07-29 17:53 ` [RFC 03/32] bus/vmbus: fix ring buffer ordering on weakly ordered CPUs Stephen Hemminger
2026-08-05 1:22 ` [EXTERNAL] " Long Li
2026-07-29 17:53 ` [RFC 04/32] bus/vmbus: fix missing acquire on receive ring index Stephen Hemminger
2026-08-05 1:23 ` [EXTERNAL] " Long Li
2026-07-29 17:53 ` [RFC 05/32] bus/vmbus: replace SMP barriers with C11 memory fences Stephen Hemminger
2026-08-13 21:41 ` [EXTERNAL] " Long Li
2026-07-29 17:53 ` [RFC 06/32] baseband: convert rte_smp_rmb to fence Stephen Hemminger
2026-07-29 17:54 ` [RFC 07/32] net/hinic: replace rte_smp_rmb Stephen Hemminger
2026-07-29 17:54 ` [RFC 08/32] net/intel: " Stephen Hemminger
2026-08-13 10:17 ` Bruce Richardson
2026-07-29 17:54 ` [RFC 09/32] crypto_caam_jr: " Stephen Hemminger
2026-08-06 6:10 ` Hemant Agrawal
2026-07-29 17:54 ` [RFC 10/32] net/virtio: replcae rte_smp_rmb Stephen Hemminger
2026-07-29 17:54 ` [RFC 11/32] net/thunderx: replace rte_smp_rmb Stephen Hemminger
2026-07-29 17:54 ` [RFC 12/32] stack: always use C11 memory model implementation Stephen Hemminger
2026-07-31 14:53 ` Morten Brørup
2026-08-01 15:25 ` Stephen Hemminger
2026-08-01 17:01 ` Stephen Hemminger
2026-08-02 6:33 ` Morten Brørup
2026-07-29 17:54 ` [RFC 13/32] ring: replace SMP read barrier with C11 acquire fence Stephen Hemminger
2026-07-30 8:16 ` Konstantin Ananyev
2026-07-31 14:47 ` Morten Brørup
2026-07-29 17:54 ` [RFC 14/32] crypto/virtio: update comment reference to rte_smp_rmb Stephen Hemminger
2026-07-29 17:54 ` [RFC 15/32] event/sw: fix unlinks in progress counter races Stephen Hemminger
2026-08-13 10:38 ` Bruce Richardson
2026-07-29 17:54 ` [RFC 16/32] event/sw: replace SMP barriers with C11 atomics Stephen Hemminger
2026-07-29 17:54 ` [RFC 17/32] eal/x86: move optimized fence out of SMP barrier Stephen Hemminger
2026-07-30 7:27 ` Konstantin Ananyev
2026-07-29 17:54 ` [RFC 18/32] common/octeontx: remove redundant barrier in mbox Stephen Hemminger
2026-07-29 17:54 ` [RFC 19/32] crypto/caam_jr: use IO barrier before job ring doorbell Stephen Hemminger
2026-08-06 6:11 ` Hemant Agrawal
2026-07-29 17:54 ` [RFC 20/32] crypto/octeontx: use IO barrier before doorbell Stephen Hemminger
2026-07-29 17:54 ` [RFC 21/32] mempool/octeontx: use IO barrier in pool destroy Stephen Hemminger
2026-07-29 17:54 ` [RFC 22/32] event/octeontx: replace deprecated SMP barriers Stephen Hemminger
2026-07-29 17:54 ` [RFC 23/32] event/dpaa2: replace deprecated barrier in selftest Stephen Hemminger
2026-08-06 6:11 ` Hemant Agrawal
2026-07-29 17:54 ` [RFC 24/32] event/dsw: replace SMP barriers with release fences Stephen Hemminger
2026-07-31 4:37 ` Mattias Rönnblom
2026-07-29 17:54 ` [RFC 25/32] event/opdl: replace SMP barriers with C11 atomics Stephen Hemminger
2026-07-29 17:54 ` [RFC 26/32] net/netvsc: replace SMP barrier in RNDIS response Stephen Hemminger
2026-07-29 17:54 ` [RFC 27/32] net/thunderx: replace deprecated SMP barriers Stephen Hemminger
2026-07-29 17:54 ` [RFC 28/32] net/virtio: replace deprecated barrier in avail index update Stephen Hemminger
2026-07-29 17:54 ` [RFC 29/32] eal: remove stale SMP barrier in rte_service Stephen Hemminger
2026-07-29 17:54 ` [RFC 30/32] eal: remove rte_smp_XX Stephen Hemminger
2026-07-29 17:54 ` [RFC 31/32] checkpatches: no longer warn about rte_smp_XX Stephen Hemminger
2026-07-29 17:54 ` [RFC 32/32] doc: update release notes about rte_smp_XX removal Stephen Hemminger
2026-09-20 18:09 ` [PATCH v2 00/33] remove rte_smp_XX barrier Stephen Hemminger
2026-09-20 18:09 ` [PATCH v2 01/33] bpf: replace deprecated SMP barriers with C11 fences Stephen Hemminger
2026-09-21 8:36 ` Marat Khalili
2026-09-23 9:49 ` Konstantin Ananyev
2026-09-20 18:09 ` [PATCH v2 02/33] bus/vmbus: remove packed attribute from ring buffer Stephen Hemminger
2026-09-21 8:37 ` [EXTERNAL] " Wei Hu
2026-09-20 18:09 ` [PATCH v2 03/33] bus/vmbus: fix ring buffer ordering on weakly ordered CPUs Stephen Hemminger
2026-09-21 8:39 ` [EXTERNAL] " Wei Hu
2026-09-20 18:09 ` [PATCH v2 04/33] bus/vmbus: fix missing acquire on receive ring index Stephen Hemminger
2026-09-21 8:40 ` [EXTERNAL] " Wei Hu
2026-09-20 18:09 ` [PATCH v2 05/33] bus/vmbus: replace SMP barriers with C11 memory fences Stephen Hemminger
2026-09-21 8:40 ` [EXTERNAL] " Wei Hu
2026-09-20 18:09 ` [PATCH v2 06/33] drivers/baseband: convert rte_smp_rmb to fence Stephen Hemminger
2026-09-20 18:09 ` [PATCH v2 07/33] net/hinic: replace rte_smp_rmb Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 08/33] net/intel: " Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 09/33] net/virtio: " Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 10/33] net/thunderx: " Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 11/33] stack: always use C11 memory model implementation Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 12/33] ring: replace SMP read barrier with C11 acquire fence Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 13/33] crypto/virtio: update comment reference to rte_smp_rmb Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 14/33] crypto/caam_jr: replace rte_smp_rmb Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 15/33] crypto/caam_jr: use IO barrier before job ring doorbell Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 16/33] crypto/octeontx: use IO barrier before doorbell Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 17/33] event/sw: fix unlinks in progress counter races Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 18/33] event/sw: replace SMP barriers with C11 atomics Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 19/33] test/barrier: test sequentially consistent fence only Stephen Hemminger
2026-10-04 12:57 ` Konstantin Ananyev
2026-10-05 13:45 ` Sun Yuechi
2026-09-20 18:10 ` [PATCH v2 20/33] eal/x86: move optimized fence out of SMP barrier Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 21/33] common/octeontx: remove redundant barrier in mbox Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 22/33] mempool/octeontx: use IO barrier in pool destroy Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 23/33] event/octeontx: replace deprecated SMP barriers Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 24/33] event/dpaa2: replace deprecated barrier in selftest Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 25/33] event/dsw: replace SMP barriers with release fences Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 26/33] event/opdl: replace SMP barriers with C11 atomics Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 27/33] net/netvsc: replace SMP barrier in RNDIS response Stephen Hemminger
2026-09-21 9:00 ` [EXTERNAL] " Wei Hu
2026-09-20 18:10 ` [PATCH v2 28/33] net/thunderx: replace deprecated SMP barriers Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 29/33] net/virtio: replace deprecated barrier in avail index update Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 30/33] eal: remove stale SMP barrier in rte_service Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 31/33] eal: remove rte_smp_XX Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 32/33] checkpatches: no longer warn about rte_smp_XX Stephen Hemminger
2026-09-20 18:10 ` [PATCH v2 33/33] doc: update release notes about rte_smp_XX removal Stephen Hemminger
2026-10-07 15:29 ` [PATCH v2 00/33] remove rte_smp_XX barrier David Marchand
2026-10-08 23:34 ` [PATCH v3 00/29] remove rte_smp_XX barriers Stephen Hemminger
2026-10-08 23:34 ` [PATCH v3 01/29] bpf: replace deprecated SMP barriers with C11 fences Stephen Hemminger
2026-10-09 6:05 ` Wathsala Vithanage
2026-10-09 15:48 ` Stephen Hemminger
2026-10-12 15:40 ` Wathsala Vithanage [this message]
2026-10-12 18:52 ` Marat Khalili
2026-10-13 7:54 ` David Marchand
2026-10-13 16:04 ` Marat Khalili
2026-10-13 16:31 ` Stephen Hemminger
2026-10-13 21:11 ` Marat Khalili
2026-10-13 22:05 ` Stephen Hemminger
2026-10-08 23:34 ` [PATCH v3 02/29] bus/vmbus: remove packed attribute from ring buffer Stephen Hemminger
2026-10-08 23:34 ` [PATCH v3 03/29] bus/vmbus: fix ring buffer ordering on weakly ordered CPUs Stephen Hemminger
2026-10-08 23:34 ` [PATCH v3 04/29] bus/vmbus: fix missing acquire on receive ring index Stephen Hemminger
2026-10-08 23:34 ` [PATCH v3 05/29] bus/vmbus: replace SMP barriers with C11 memory fences Stephen Hemminger
2026-10-08 23:34 ` [PATCH v3 06/29] drivers/baseband: convert rte_smp_rmb to fence Stephen Hemminger
2026-10-13 18:15 ` Chautru, Nicolas
2026-10-08 23:35 ` [PATCH v3 07/29] net/hinic: replace rte_smp_rmb Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 08/29] net/intel: " Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 09/29] net/virtio: " Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 10/29] net/thunderx: replace deprecated SMP barriers Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 11/29] stack: always use C11 memory model implementation Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 12/29] ring: replace SMP read barrier with C11 acquire fence Stephen Hemminger
2026-10-09 4:05 ` Wathsala Vithanage
2026-10-08 23:35 ` [PATCH v3 13/29] crypto/virtio: update comment reference to rte_smp_rmb Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 14/29] crypto/caam_jr: replace rte_smp_rmb Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 15/29] crypto/caam_jr: use IO barrier before job ring doorbell Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 16/29] crypto/octeontx: use IO barrier before doorbell Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 17/29] event/sw: fix unlinks in progress counter races Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 18/29] event/sw: replace SMP barriers with C11 atomics Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 19/29] test/barrier: convert to " Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 20/29] eal/x86: move optimized fence out of SMP barrier Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 21/29] common/octeontx: remove redundant barrier in mbox Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 22/29] mempool/octeontx: use IO barrier in pool destroy Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 23/29] event/octeontx: replace deprecated SMP barriers Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 24/29] event/dpaa2: replace deprecated barrier in selftest Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 25/29] event/dsw: replace SMP barriers with release fences Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 26/29] event/opdl: replace SMP barriers with C11 atomics Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 27/29] net/virtio: replace deprecated barrier in avail index update Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 28/29] eal: remove stale SMP barrier in rte_service Stephen Hemminger
2026-10-08 23:35 ` [PATCH v3 29/29] eal: remove rte_smp_XX Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 00/29] remove rte_smp_XX barriers Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 01/29] bpf: replace deprecated SMP barriers with C11 fences Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 02/29] bus/vmbus: remove packed attribute from ring buffer Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 03/29] bus/vmbus: fix ring buffer ordering on weakly ordered CPUs Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 04/29] bus/vmbus: fix missing acquire on receive ring index Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 05/29] bus/vmbus: replace SMP barriers with C11 memory fences Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 06/29] drivers/baseband: convert rte_smp_rmb to fence Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 07/29] net/hinic: replace rte_smp_rmb Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 08/29] net/intel: " Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 09/29] net/virtio: " Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 10/29] net/thunderx: replace deprecated SMP barriers Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 11/29] stack: always use C11 memory model implementation Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 12/29] ring: replace SMP read barrier with C11 acquire fence Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 13/29] crypto/virtio: update comment reference to rte_smp_rmb Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 14/29] crypto/caam_jr: replace rte_smp_rmb Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 15/29] crypto/caam_jr: use IO barrier before job ring doorbell Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 16/29] crypto/octeontx: use IO barrier before doorbell Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 17/29] event/sw: fix unlinks in progress counter races Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 18/29] event/sw: replace SMP barriers with C11 atomics Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 19/29] test/barrier: convert to " Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 20/29] eal/x86: move optimized fence out of SMP barrier Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 21/29] common/octeontx: remove redundant barrier in mbox Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 22/29] mempool/octeontx: use IO barrier in pool destroy Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 23/29] event/octeontx: replace deprecated SMP barriers Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 24/29] event/dpaa2: replace deprecated barrier in selftest Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 25/29] event/dsw: replace SMP barriers with release fences Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 26/29] event/opdl: replace SMP barriers with C11 atomics Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 27/29] net/virtio: replace deprecated barrier in avail index update Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 28/29] eal: remove stale SMP barrier in rte_service Stephen Hemminger
2026-10-13 22:22 ` [PATCH v4 29/29] eal: remove rte_smp_XX Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7355c1fe-b9d3-493e-b8ee-c518ddbc58e5@arm.com \
--to=wathsala.vithanage@arm.com \
--cc=dev@dpdk.org \
--cc=konstantin.ananyev@huawei.com \
--cc=qm2k21@gmail.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox