From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v5 13/24] event/sw: convert from rte_atomic32 to stdatomic
Date: Fri, 19 Jun 2026 19:28:38 -0700 [thread overview]
Message-ID: <20260620023134.42877-14-stephen@networkplumber.org> (raw)
In-Reply-To: <20260620023134.42877-1-stephen@networkplumber.org>
Use stdatomic to keep track of inflights.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/event/sw/sw_evdev.c | 8 +++++---
drivers/event/sw/sw_evdev.h | 4 ++--
drivers/event/sw/sw_evdev_worker.c | 16 +++++++++++-----
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index 3ad82e94ac..a2f760a98d 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -153,7 +153,9 @@ sw_port_setup(struct rte_eventdev *dev, uint8_t port_id,
* the sum to no leak credits
*/
int possible_inflights = p->inflight_credits + p->inflights;
- rte_atomic32_sub(&sw->inflights, possible_inflights);
+ rte_atomic_fetch_sub_explicit(&sw->inflights,
+ possible_inflights,
+ rte_memory_order_release);
}
*p = (struct sw_port){0}; /* zero entire structure */
@@ -512,7 +514,7 @@ sw_dev_configure(const struct rte_eventdev *dev)
sw->qid_count = conf->nb_event_queues;
sw->port_count = conf->nb_event_ports;
sw->nb_events_limit = conf->nb_events_limit;
- rte_atomic32_set(&sw->inflights, 0);
+ sw->inflights = 0;
/* Number of chunks sized for worst-case spread of events across IQs */
num_chunks = ((SW_INFLIGHT_EVENTS_TOTAL/SW_EVS_PER_Q_CHUNK)+1) +
@@ -633,7 +635,7 @@ sw_dump(struct rte_eventdev *dev, FILE *f)
fprintf(f, "\tsched cq/qid call: %"PRIu64"\n", sw->sched_cq_qid_called);
fprintf(f, "\tsched no IQ enq: %"PRIu64"\n", sw->sched_no_iq_enqueues);
fprintf(f, "\tsched no CQ enq: %"PRIu64"\n", sw->sched_no_cq_enqueues);
- uint32_t inflights = rte_atomic32_read(&sw->inflights);
+ uint32_t inflights = rte_atomic_load_explicit(&sw->inflights, rte_memory_order_relaxed);
uint32_t credits = sw->nb_events_limit - inflights;
fprintf(f, "\tinflight %d, credits: %d\n", inflights, credits);
diff --git a/drivers/event/sw/sw_evdev.h b/drivers/event/sw/sw_evdev.h
index c159be21be..5e49b08030 100644
--- a/drivers/event/sw/sw_evdev.h
+++ b/drivers/event/sw/sw_evdev.h
@@ -8,7 +8,7 @@
#include "sw_evdev_log.h"
#include <rte_eventdev.h>
#include <eventdev_pmd_vdev.h>
-#include <rte_atomic.h>
+#include <rte_stdatomic.h>
#define SW_DEFAULT_CREDIT_QUANTA 32
#define SW_DEFAULT_SCHED_QUANTA 128
@@ -233,7 +233,7 @@ struct sw_evdev {
/* Contains all ports - load balanced and directed */
alignas(RTE_CACHE_LINE_SIZE) struct sw_port ports[SW_PORTS_MAX];
- alignas(RTE_CACHE_LINE_SIZE) rte_atomic32_t inflights;
+ alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(uint32_t) inflights;
/*
* max events in this instance. Cached here for performance.
diff --git a/drivers/event/sw/sw_evdev_worker.c b/drivers/event/sw/sw_evdev_worker.c
index 4215726513..0755def367 100644
--- a/drivers/event/sw/sw_evdev_worker.c
+++ b/drivers/event/sw/sw_evdev_worker.c
@@ -56,7 +56,7 @@ sw_event_enqueue_burst(void *port, const struct rte_event ev[], uint16_t num)
uint8_t new_ops[PORT_ENQUEUE_MAX_BURST_SIZE];
struct sw_port *p = port;
struct sw_evdev *sw = (void *)p->sw;
- uint32_t sw_inflights = rte_atomic32_read(&sw->inflights);
+ uint32_t sw_inflights = rte_atomic_load_explicit(&sw->inflights, rte_memory_order_relaxed);
uint32_t credit_update_quanta = sw->credit_update_quanta;
int new = 0;
@@ -74,8 +74,10 @@ sw_event_enqueue_burst(void *port, const struct rte_event ev[], uint16_t num)
if (sw_inflights + credit_update_quanta > sw->nb_events_limit)
return 0;
- rte_atomic32_add(&sw->inflights, credit_update_quanta);
- p->inflight_credits += (credit_update_quanta);
+ rte_atomic_fetch_add_explicit(&sw->inflights,
+ credit_update_quanta,
+ rte_memory_order_acquire);
+ p->inflight_credits += credit_update_quanta;
/* If there are fewer inflight credits than new events, limit
* the number of enqueued events.
@@ -124,7 +126,9 @@ sw_event_enqueue_burst(void *port, const struct rte_event ev[], uint16_t num)
/* Replenish credits if enough releases are performed */
if (p->inflight_credits >= credit_update_quanta * 2) {
- rte_atomic32_sub(&sw->inflights, credit_update_quanta);
+ rte_atomic_fetch_sub_explicit(&sw->inflights,
+ credit_update_quanta,
+ rte_memory_order_release);
p->inflight_credits -= credit_update_quanta;
}
@@ -150,7 +154,9 @@ sw_event_dequeue_burst(void *port, struct rte_event *ev, uint16_t num,
/* Replenish credits if enough releases are performed */
if (p->inflight_credits >= credit_update_quanta * 2) {
- rte_atomic32_sub(&sw->inflights, credit_update_quanta);
+ rte_atomic_fetch_sub_explicit(&sw->inflights,
+ credit_update_quanta,
+ rte_memory_order_release);
p->inflight_credits -= credit_update_quanta;
}
}
--
2.53.0
next prev parent reply other threads:[~2026-06-20 2:32 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <https://inbox.dpdk.org/dev/20260521042043.1590536-1-stephen@networkplumber.org>
2026-06-20 2:28 ` [PATCH v5 00/24] deprecate rte_atomic functions Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 01/24] bpf: use C11 atomics in BPF_ST_ATOMIC_REG Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 02/24] net/bonding: use stdatomic Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 03/24] net/nbl: remove unused rte_atomic16 field Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 04/24] net/ena: replace use of rte_atomicNN Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 05/24] net/failsafe: convert to stdatomic Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 06/24] net/enic: do not use deprecated rte_atomic64 Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 07/24] net/pfe: use ethdev linkstatus helpers Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 08/24] net/sfc: replace rte_atomic with stdatomic Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 09/24] crypto/ccp: replace use of rte_atomic64 " Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 10/24] bus/dpaa: replace rte_atomic16 " Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 11/24] drivers: " Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 12/24] net/netvsc: replace rte_atomic32 " Stephen Hemminger
2026-06-20 2:28 ` Stephen Hemminger [this message]
2026-06-20 2:28 ` [PATCH v5 14/24] bus/vmbus: convert from rte_atomic to stdatomic Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 15/24] common/dpaax: use stdatomic instead of rte_atomic Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 16/24] net/bnx2x: convert from rte_atomic32 to stdatomic Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 17/24] bus/fslmc: replace rte_atomic32 with stdatomic Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 18/24] drivers/event: replace rte_atomic32 in selftests Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 19/24] net/hinic: replace rte_atomic32 with stdatomic Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 20/24] net/txgbe: " Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 21/24] net/vhost: use stdatomic instead of rte_atomic32 Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 22/24] vdpa/ifc: replace rte_atomic32 with stdatomic Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 23/24] test/atomic: suppress deprecation warnings for legacy APIs Stephen Hemminger
2026-06-20 2:28 ` [PATCH v5 24/24] eal: deprecate rte_atomicNN functions 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=20260620023134.42877-14-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.