From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org
Cc: Akhil Goyal <gakhil@marvell.com>,
Anatoly Burakov <anatoly.burakov@intel.com>,
Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
Bruce Richardson <bruce.richardson@intel.com>,
Chenbo Xia <chenbo.xia@intel.com>,
Ciara Power <ciara.power@intel.com>,
David Christensen <drc@linux.vnet.ibm.com>,
David Hunt <david.hunt@intel.com>,
Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
Dmitry Malloy <dmitrym@microsoft.com>,
Elena Agostini <eagostini@nvidia.com>,
Erik Gabriel Carrillo <erik.g.carrillo@intel.com>,
Fan Zhang <fanzhang.oss@gmail.com>,
Ferruh Yigit <ferruh.yigit@amd.com>,
Harman Kalra <hkalra@marvell.com>,
Harry van Haaren <harry.van.haaren@intel.com>,
Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>,
Jerin Jacob <jerinj@marvell.com>,
Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>,
Matan Azrad <matan@nvidia.com>,
Maxime Coquelin <maxime.coquelin@redhat.com>,
Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
Nicolas Chautru <nicolas.chautru@intel.com>,
Olivier Matz <olivier.matz@6wind.com>, Ori Kam <orika@nvidia.com>,
Pallavi Kadam <pallavi.kadam@intel.com>,
Pavan Nikhilesh <pbhagavatula@marvell.com>,
Reshma Pattan <reshma.pattan@intel.com>,
Sameh Gobriel <sameh.gobriel@intel.com>,
Shijith Thotton <sthotton@marvell.com>,
Sivaprasad Tummala <sivaprasad.tummala@amd.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Suanming Mou <suanmingm@nvidia.com>,
Sunil Kumar Kori <skori@marvell.com>,
Thomas Monjalon <thomas@monjalon.net>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
Yipeng Wang <yipeng1.wang@intel.com>,
Tyler Retzlaff <roretzla@linux.microsoft.com>
Subject: [PATCH v2 04/19] eventdev: use rte optional stdatomic API
Date: Tue, 17 Oct 2023 13:31:02 -0700 [thread overview]
Message-ID: <1697574677-16578-5-git-send-email-roretzla@linux.microsoft.com> (raw)
In-Reply-To: <1697574677-16578-1-git-send-email-roretzla@linux.microsoft.com>
Replace the use of gcc builtin __atomic_xxx intrinsics with
corresponding rte_atomic_xxx optional stdatomic API
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
drivers/event/cnxk/cnxk_tim_worker.h | 4 +--
lib/eventdev/rte_event_timer_adapter.c | 66 +++++++++++++++++-----------------
lib/eventdev/rte_event_timer_adapter.h | 2 +-
3 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/drivers/event/cnxk/cnxk_tim_worker.h b/drivers/event/cnxk/cnxk_tim_worker.h
index f0857f2..f530d8c 100644
--- a/drivers/event/cnxk/cnxk_tim_worker.h
+++ b/drivers/event/cnxk/cnxk_tim_worker.h
@@ -314,7 +314,7 @@
tim->impl_opaque[0] = (uintptr_t)chunk;
tim->impl_opaque[1] = (uintptr_t)bkt;
- __atomic_store_n(&tim->state, RTE_EVENT_TIMER_ARMED, __ATOMIC_RELEASE);
+ rte_atomic_store_explicit(&tim->state, RTE_EVENT_TIMER_ARMED, rte_memory_order_release);
cnxk_tim_bkt_inc_nent(bkt);
cnxk_tim_bkt_dec_lock_relaxed(bkt);
@@ -425,7 +425,7 @@
tim->impl_opaque[0] = (uintptr_t)chunk;
tim->impl_opaque[1] = (uintptr_t)bkt;
- __atomic_store_n(&tim->state, RTE_EVENT_TIMER_ARMED, __ATOMIC_RELEASE);
+ rte_atomic_store_explicit(&tim->state, RTE_EVENT_TIMER_ARMED, rte_memory_order_release);
cnxk_tim_bkt_inc_nent(bkt);
cnxk_tim_bkt_dec_lock_relaxed(bkt);
diff --git a/lib/eventdev/rte_event_timer_adapter.c b/lib/eventdev/rte_event_timer_adapter.c
index 427c4c6..2746670 100644
--- a/lib/eventdev/rte_event_timer_adapter.c
+++ b/lib/eventdev/rte_event_timer_adapter.c
@@ -630,12 +630,12 @@ struct swtim {
uint32_t timer_data_id;
/* Track which cores have actually armed a timer */
struct {
- uint16_t v;
+ RTE_ATOMIC(uint16_t) v;
} __rte_cache_aligned in_use[RTE_MAX_LCORE];
/* Track which cores' timer lists should be polled */
- unsigned int poll_lcores[RTE_MAX_LCORE];
+ RTE_ATOMIC(unsigned int) poll_lcores[RTE_MAX_LCORE];
/* The number of lists that should be polled */
- int n_poll_lcores;
+ RTE_ATOMIC(int) n_poll_lcores;
/* Timers which have expired and can be returned to a mempool */
struct rte_timer *expired_timers[EXP_TIM_BUF_SZ];
/* The number of timers that can be returned to a mempool */
@@ -669,10 +669,10 @@ struct swtim {
if (unlikely(sw->in_use[lcore].v == 0)) {
sw->in_use[lcore].v = 1;
- n_lcores = __atomic_fetch_add(&sw->n_poll_lcores, 1,
- __ATOMIC_RELAXED);
- __atomic_store_n(&sw->poll_lcores[n_lcores], lcore,
- __ATOMIC_RELAXED);
+ n_lcores = rte_atomic_fetch_add_explicit(&sw->n_poll_lcores, 1,
+ rte_memory_order_relaxed);
+ rte_atomic_store_explicit(&sw->poll_lcores[n_lcores], lcore,
+ rte_memory_order_relaxed);
}
ret = event_buffer_add(&sw->buffer, &evtim->ev);
@@ -719,8 +719,8 @@ struct swtim {
sw->stats.evtim_exp_count++;
if (type == SINGLE)
- __atomic_store_n(&evtim->state, RTE_EVENT_TIMER_NOT_ARMED,
- __ATOMIC_RELEASE);
+ rte_atomic_store_explicit(&evtim->state, RTE_EVENT_TIMER_NOT_ARMED,
+ rte_memory_order_release);
}
if (event_buffer_batch_ready(&sw->buffer)) {
@@ -846,7 +846,7 @@ struct swtim {
if (swtim_did_tick(sw)) {
rte_timer_alt_manage(sw->timer_data_id,
- sw->poll_lcores,
+ (unsigned int *)(uintptr_t)sw->poll_lcores,
sw->n_poll_lcores,
swtim_callback);
@@ -1027,7 +1027,7 @@ struct swtim {
/* Free outstanding timers */
rte_timer_stop_all(sw->timer_data_id,
- sw->poll_lcores,
+ (unsigned int *)(uintptr_t)sw->poll_lcores,
sw->n_poll_lcores,
swtim_free_tim,
sw);
@@ -1142,7 +1142,7 @@ struct swtim {
uint64_t cur_cycles;
/* Check that timer is armed */
- n_state = __atomic_load_n(&evtim->state, __ATOMIC_ACQUIRE);
+ n_state = rte_atomic_load_explicit(&evtim->state, rte_memory_order_acquire);
if (n_state != RTE_EVENT_TIMER_ARMED)
return -EINVAL;
@@ -1201,15 +1201,15 @@ struct swtim {
* The atomic compare-and-swap operation can prevent the race condition
* on in_use flag between multiple non-EAL threads.
*/
- if (unlikely(__atomic_compare_exchange_n(&sw->in_use[lcore_id].v,
- &exp_state, 1, 0,
- __ATOMIC_RELAXED, __ATOMIC_RELAXED))) {
+ if (unlikely(rte_atomic_compare_exchange_strong_explicit(&sw->in_use[lcore_id].v,
+ &exp_state, 1,
+ rte_memory_order_relaxed, rte_memory_order_relaxed))) {
EVTIM_LOG_DBG("Adding lcore id = %u to list of lcores to poll",
lcore_id);
- n_lcores = __atomic_fetch_add(&sw->n_poll_lcores, 1,
- __ATOMIC_RELAXED);
- __atomic_store_n(&sw->poll_lcores[n_lcores], lcore_id,
- __ATOMIC_RELAXED);
+ n_lcores = rte_atomic_fetch_add_explicit(&sw->n_poll_lcores, 1,
+ rte_memory_order_relaxed);
+ rte_atomic_store_explicit(&sw->poll_lcores[n_lcores], lcore_id,
+ rte_memory_order_relaxed);
}
ret = rte_mempool_get_bulk(sw->tim_pool, (void **)tims,
@@ -1223,7 +1223,7 @@ struct swtim {
type = get_timer_type(adapter);
for (i = 0; i < nb_evtims; i++) {
- n_state = __atomic_load_n(&evtims[i]->state, __ATOMIC_ACQUIRE);
+ n_state = rte_atomic_load_explicit(&evtims[i]->state, rte_memory_order_acquire);
if (n_state == RTE_EVENT_TIMER_ARMED) {
rte_errno = EALREADY;
break;
@@ -1235,9 +1235,9 @@ struct swtim {
if (unlikely(check_destination_event_queue(evtims[i],
adapter) < 0)) {
- __atomic_store_n(&evtims[i]->state,
+ rte_atomic_store_explicit(&evtims[i]->state,
RTE_EVENT_TIMER_ERROR,
- __ATOMIC_RELAXED);
+ rte_memory_order_relaxed);
rte_errno = EINVAL;
break;
}
@@ -1250,15 +1250,15 @@ struct swtim {
ret = get_timeout_cycles(evtims[i], adapter, &cycles);
if (unlikely(ret == -1)) {
- __atomic_store_n(&evtims[i]->state,
+ rte_atomic_store_explicit(&evtims[i]->state,
RTE_EVENT_TIMER_ERROR_TOOLATE,
- __ATOMIC_RELAXED);
+ rte_memory_order_relaxed);
rte_errno = EINVAL;
break;
} else if (unlikely(ret == -2)) {
- __atomic_store_n(&evtims[i]->state,
+ rte_atomic_store_explicit(&evtims[i]->state,
RTE_EVENT_TIMER_ERROR_TOOEARLY,
- __ATOMIC_RELAXED);
+ rte_memory_order_relaxed);
rte_errno = EINVAL;
break;
}
@@ -1267,9 +1267,9 @@ struct swtim {
type, lcore_id, NULL, evtims[i]);
if (ret < 0) {
/* tim was in RUNNING or CONFIG state */
- __atomic_store_n(&evtims[i]->state,
+ rte_atomic_store_explicit(&evtims[i]->state,
RTE_EVENT_TIMER_ERROR,
- __ATOMIC_RELEASE);
+ rte_memory_order_release);
break;
}
@@ -1277,8 +1277,8 @@ struct swtim {
/* RELEASE ordering guarantees the adapter specific value
* changes observed before the update of state.
*/
- __atomic_store_n(&evtims[i]->state, RTE_EVENT_TIMER_ARMED,
- __ATOMIC_RELEASE);
+ rte_atomic_store_explicit(&evtims[i]->state, RTE_EVENT_TIMER_ARMED,
+ rte_memory_order_release);
}
if (i < nb_evtims)
@@ -1320,7 +1320,7 @@ struct swtim {
/* ACQUIRE ordering guarantees the access of implementation
* specific opaque data under the correct state.
*/
- n_state = __atomic_load_n(&evtims[i]->state, __ATOMIC_ACQUIRE);
+ n_state = rte_atomic_load_explicit(&evtims[i]->state, rte_memory_order_acquire);
if (n_state == RTE_EVENT_TIMER_CANCELED) {
rte_errno = EALREADY;
break;
@@ -1346,8 +1346,8 @@ struct swtim {
* to make sure the state update data observed between
* threads.
*/
- __atomic_store_n(&evtims[i]->state, RTE_EVENT_TIMER_CANCELED,
- __ATOMIC_RELEASE);
+ rte_atomic_store_explicit(&evtims[i]->state, RTE_EVENT_TIMER_CANCELED,
+ rte_memory_order_release);
}
return i;
diff --git a/lib/eventdev/rte_event_timer_adapter.h b/lib/eventdev/rte_event_timer_adapter.h
index fbdddf8..49e646a 100644
--- a/lib/eventdev/rte_event_timer_adapter.h
+++ b/lib/eventdev/rte_event_timer_adapter.h
@@ -498,7 +498,7 @@ struct rte_event_timer {
* implementation specific values to share between the arm and cancel
* operations. The application should not modify this field.
*/
- enum rte_event_timer_state state;
+ RTE_ATOMIC(enum rte_event_timer_state) state;
/**< State of the event timer. */
uint8_t user_meta[];
/**< Memory to store user specific metadata.
--
1.8.3.1
next prev parent reply other threads:[~2023-10-17 20:31 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 23:08 [PATCH 00/21] " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 01/21] power: fix use of rte stdatomic Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 02/21] event/cnxk: remove single " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 03/21] power: use rte optional stdatomic API Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 04/21] bbdev: " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 05/21] eal: " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 06/21] eventdev: " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 07/21] gpudev: " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 08/21] ipsec: " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 09/21] mbuf: " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 10/21] mempool: " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 11/21] rcu: " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 12/21] pdump: " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 13/21] stack: " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 14/21] telemetry: " Tyler Retzlaff
2023-10-16 23:08 ` [PATCH 15/21] vhost: " Tyler Retzlaff
2023-10-16 23:09 ` [PATCH 16/21] cryptodev: " Tyler Retzlaff
2023-10-16 23:09 ` [PATCH 17/21] distributor: " Tyler Retzlaff
2023-10-16 23:09 ` [PATCH 18/21] ethdev: " Tyler Retzlaff
2023-10-16 23:09 ` [PATCH 19/21] hash: " Tyler Retzlaff
2023-10-16 23:09 ` [PATCH 20/21] timer: " Tyler Retzlaff
2023-10-16 23:09 ` [PATCH 21/21] ring: " Tyler Retzlaff
2023-10-17 20:30 ` [PATCH v2 00/19] " Tyler Retzlaff
2023-10-17 20:30 ` [PATCH v2 01/19] power: " Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 02/19] bbdev: " Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 03/19] eal: " Tyler Retzlaff
2023-10-17 20:31 ` Tyler Retzlaff [this message]
2023-10-17 20:31 ` [PATCH v2 05/19] gpudev: " Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 06/19] ipsec: " Tyler Retzlaff
2023-10-24 8:45 ` Konstantin Ananyev
2023-10-17 20:31 ` [PATCH v2 07/19] mbuf: " Tyler Retzlaff
2023-10-24 8:46 ` Konstantin Ananyev
2023-10-17 20:31 ` [PATCH v2 08/19] mempool: " Tyler Retzlaff
2023-10-24 8:47 ` Konstantin Ananyev
2023-10-17 20:31 ` [PATCH v2 09/19] rcu: " Tyler Retzlaff
2023-10-25 9:41 ` Ruifeng Wang
2023-10-25 22:38 ` Tyler Retzlaff
2023-10-26 4:24 ` Ruifeng Wang
2023-10-26 16:36 ` Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 10/19] pdump: " Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 11/19] stack: " Tyler Retzlaff
2023-10-24 8:48 ` Konstantin Ananyev
2023-10-17 20:31 ` [PATCH v2 12/19] telemetry: " Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 13/19] vhost: " Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 14/19] cryptodev: " Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 15/19] distributor: " Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 16/19] ethdev: " Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 17/19] hash: " Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 18/19] timer: " Tyler Retzlaff
2023-10-17 20:31 ` [PATCH v2 19/19] ring: " Tyler Retzlaff
2023-10-24 8:43 ` Konstantin Ananyev
2023-10-24 9:56 ` Morten Brørup
2023-10-24 15:58 ` Tyler Retzlaff
2023-10-24 16:36 ` Morten Brørup
2023-10-24 16:29 ` Tyler Retzlaff
2023-10-25 10:06 ` Konstantin Ananyev
2023-10-25 22:49 ` Tyler Retzlaff
2023-10-25 23:22 ` Tyler Retzlaff
2023-10-17 23:55 ` [PATCH v2 00/19] " Stephen Hemminger
2023-10-26 0:31 ` [PATCH v3 " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 01/19] power: " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 02/19] bbdev: " Tyler Retzlaff
2023-10-26 11:57 ` Maxime Coquelin
2023-10-26 0:31 ` [PATCH v3 03/19] eal: " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 04/19] eventdev: " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 05/19] gpudev: " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 06/19] ipsec: " Tyler Retzlaff
2023-10-26 15:54 ` [EXT] " Akhil Goyal
2023-10-27 12:59 ` Konstantin Ananyev
2023-10-26 0:31 ` [PATCH v3 07/19] mbuf: " Tyler Retzlaff
2023-10-27 13:03 ` Konstantin Ananyev
2023-10-26 0:31 ` [PATCH v3 08/19] mempool: " Tyler Retzlaff
2023-10-27 13:01 ` Konstantin Ananyev
2023-10-26 0:31 ` [PATCH v3 09/19] rcu: " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 10/19] pdump: " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 11/19] stack: " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 12/19] telemetry: " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 13/19] vhost: " Tyler Retzlaff
2023-10-26 11:57 ` Maxime Coquelin
2023-10-26 0:31 ` [PATCH v3 14/19] cryptodev: " Tyler Retzlaff
2023-10-26 15:53 ` [EXT] " Akhil Goyal
2023-10-27 13:05 ` Konstantin Ananyev
2023-10-26 0:31 ` [PATCH v3 15/19] distributor: " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 16/19] ethdev: " Tyler Retzlaff
2023-10-27 13:04 ` Konstantin Ananyev
2023-10-26 0:31 ` [PATCH v3 17/19] hash: " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 18/19] timer: " Tyler Retzlaff
2023-10-26 0:31 ` [PATCH v3 19/19] ring: " Tyler Retzlaff
2023-10-27 12:58 ` Konstantin Ananyev
2023-10-26 13:47 ` [PATCH v3 00/19] " David Marchand
2023-10-30 15:34 ` David Marchand
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=1697574677-16578-5-git-send-email-roretzla@linux.microsoft.com \
--to=roretzla@linux.microsoft.com \
--cc=anatoly.burakov@intel.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=bruce.richardson@intel.com \
--cc=chenbo.xia@intel.com \
--cc=ciara.power@intel.com \
--cc=david.hunt@intel.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=dmitrym@microsoft.com \
--cc=drc@linux.vnet.ibm.com \
--cc=eagostini@nvidia.com \
--cc=erik.g.carrillo@intel.com \
--cc=fanzhang.oss@gmail.com \
--cc=ferruh.yigit@amd.com \
--cc=gakhil@marvell.com \
--cc=harry.van.haaren@intel.com \
--cc=hkalra@marvell.com \
--cc=honnappa.nagarahalli@arm.com \
--cc=jerinj@marvell.com \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=matan@nvidia.com \
--cc=maxime.coquelin@redhat.com \
--cc=navasile@linux.microsoft.com \
--cc=nicolas.chautru@intel.com \
--cc=olivier.matz@6wind.com \
--cc=orika@nvidia.com \
--cc=pallavi.kadam@intel.com \
--cc=pbhagavatula@marvell.com \
--cc=reshma.pattan@intel.com \
--cc=sameh.gobriel@intel.com \
--cc=sivaprasad.tummala@amd.com \
--cc=skori@marvell.com \
--cc=stephen@networkplumber.org \
--cc=sthotton@marvell.com \
--cc=suanmingm@nvidia.com \
--cc=thomas@monjalon.net \
--cc=viacheslavo@nvidia.com \
--cc=vladimir.medvedkin@intel.com \
--cc=yipeng1.wang@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).