From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Tyler Retzlaff" <roretzla@linux.microsoft.com>, <dev@dpdk.org>
Cc: techboard@dpdk.org,
"Bruce Richardson" <bruce.richardson@intel.com>,
"Honnappa Nagarahalli" <honnappa.nagarahalli@arm.com>,
"Ruifeng Wang" <ruifeng.wang@arm.com>,
"Jerin Jacob" <jerinj@marvell.com>,
"Sunil Kumar Kori" <skori@marvell.com>,
"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>,
"Joyce Kong" <joyce.kong@arm.com>,
"David Christensen" <drc@linux.vnet.ibm.com>,
"Konstantin Ananyev" <konstantin.v.ananyev@yandex.ru>,
"David Hunt" <david.hunt@intel.com>,
"Thomas Monjalon" <thomas@monjalon.net>,
"David Marchand" <david.marchand@redhat.com>
Subject: RE: [PATCH v2 2/6] eal: adapt EAL to present rte optional atomics API
Date: Mon, 14 Aug 2023 10:00:49 +0200 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D87AEF@smartserver.smartshare.dk> (raw)
In-Reply-To: <1691775136-6460-3-git-send-email-roretzla@linux.microsoft.com>
> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> Sent: Friday, 11 August 2023 19.32
>
> Adapt the EAL public headers to use rte optional atomics API instead of
> directly using and exposing toolchain specific atomic builtin intrinsics.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
[...]
> --- a/app/test/test_mcslock.c
> +++ b/app/test/test_mcslock.c
> @@ -36,9 +36,9 @@
> * lock multiple times.
> */
>
> -rte_mcslock_t *p_ml;
> -rte_mcslock_t *p_ml_try;
> -rte_mcslock_t *p_ml_perf;
> +rte_mcslock_t * __rte_atomic p_ml;
> +rte_mcslock_t * __rte_atomic p_ml_try;
> +rte_mcslock_t * __rte_atomic p_ml_perf;
Although this looks weird, it is pointers themselves, not the structures, that are used atomically. So it is correct.
> diff --git a/lib/eal/include/generic/rte_pause.h
> b/lib/eal/include/generic/rte_pause.h
> index bebfa95..c816e7d 100644
> --- a/lib/eal/include/generic/rte_pause.h
> +++ b/lib/eal/include/generic/rte_pause.h
> @@ -36,13 +36,13 @@
> * A 16-bit expected value to be in the memory location.
> * @param memorder
> * Two different memory orders that can be specified:
> - * __ATOMIC_ACQUIRE and __ATOMIC_RELAXED. These map to
> + * rte_memory_order_acquire and rte_memory_order_relaxed. These map to
> * C++11 memory orders with the same names, see the C++11 standard or
> * the GCC wiki on atomic synchronization for detailed definition.
Delete the last part of the description, starting at "These map to...".
> */
> static __rte_always_inline void
> rte_wait_until_equal_16(volatile uint16_t *addr, uint16_t expected,
> - int memorder);
> + rte_memory_order memorder);
>
> /**
> * Wait for *addr to be updated with a 32-bit expected value, with a relaxed
> @@ -54,13 +54,13 @@
> * A 32-bit expected value to be in the memory location.
> * @param memorder
> * Two different memory orders that can be specified:
> - * __ATOMIC_ACQUIRE and __ATOMIC_RELAXED. These map to
> + * rte_memory_order_acquire and rte_memory_order_relaxed. These map to
> * C++11 memory orders with the same names, see the C++11 standard or
> * the GCC wiki on atomic synchronization for detailed definition.
Delete the last part of the description, starting at "These map to...".
> */
> static __rte_always_inline void
> rte_wait_until_equal_32(volatile uint32_t *addr, uint32_t expected,
> - int memorder);
> + rte_memory_order memorder);
>
> /**
> * Wait for *addr to be updated with a 64-bit expected value, with a relaxed
> @@ -72,42 +72,42 @@
> * A 64-bit expected value to be in the memory location.
> * @param memorder
> * Two different memory orders that can be specified:
> - * __ATOMIC_ACQUIRE and __ATOMIC_RELAXED. These map to
> + * rte_memory_order_acquire and rte_memory_order_relaxed. These map to
> * C++11 memory orders with the same names, see the C++11 standard or
> * the GCC wiki on atomic synchronization for detailed definition.
Delete the last part of the description, starting at "These map to...".
> */
> static __rte_always_inline void
> rte_wait_until_equal_64(volatile uint64_t *addr, uint64_t expected,
> - int memorder);
> + rte_memory_order memorder);
[...]
> @@ -125,16 +125,16 @@
> * An expected value to be in the memory location.
> * @param memorder
> * Two different memory orders that can be specified:
> - * __ATOMIC_ACQUIRE and __ATOMIC_RELAXED. These map to
> + * rte_memory_order_acquire and rte_memory_order_relaxed. These map to
> * C++11 memory orders with the same names, see the C++11 standard or
> * the GCC wiki on atomic synchronization for detailed definition.
Delete the last part of the description, starting at "These map to...".
There might be more similar comments that need removal; I haven't tried searching.
> */
> #define RTE_WAIT_UNTIL_MASKED(addr, mask, cond, expected, memorder) do { \
[...]
> --- a/lib/eal/include/generic/rte_spinlock.h
> +++ b/lib/eal/include/generic/rte_spinlock.h
> @@ -29,7 +29,7 @@
> * The rte_spinlock_t type.
> */
> typedef struct __rte_lockable {
> - volatile int locked; /**< lock status 0 = unlocked, 1 = locked */
> + volatile int __rte_atomic locked; /**< lock status 0 = unlocked, 1 =
> locked */
I think __rte_atomic should be before the type:
volatile __rte_atomic int locked; /**< lock status [...]
Alternatively (just mentioning it, I know we don't use this form):
volatile __rte_atomic(int) locked; /**< lock status [...]
Thinking of where you would put "const" might help.
Maybe your order is also correct, so it is a matter of preference.
The DPDK coding style guidelines doesn't mention where to place "const", but looking at the code, it seems to use "const unsigned int" and "const char *".
> } rte_spinlock_t;
>
> /**
[...]
> --- a/lib/eal/include/rte_mcslock.h
> +++ b/lib/eal/include/rte_mcslock.h
> @@ -33,8 +33,8 @@
> * The rte_mcslock_t type.
> */
> typedef struct rte_mcslock {
> - struct rte_mcslock *next;
> - int locked; /* 1 if the queue locked, 0 otherwise */
> + struct rte_mcslock * __rte_atomic next;
Correct, the pointer is atomic, not the struct.
> + int __rte_atomic locked; /* 1 if the queue locked, 0 otherwise */
Again, I think __rte_atomic should be before the type:
__rte_atomic int locked; /* 1 if the queue locked, 0 otherwise */
> } rte_mcslock_t;
>
[...]
> @@ -101,34 +101,34 @@
> * A pointer to the node of MCS lock passed in rte_mcslock_lock.
> */
> static inline void
> -rte_mcslock_unlock(rte_mcslock_t **msl, rte_mcslock_t *me)
> +rte_mcslock_unlock(rte_mcslock_t * __rte_atomic *msl, rte_mcslock_t *
> __rte_atomic me)
> {
> /* Check if there are more nodes in the queue. */
> - if (likely(__atomic_load_n(&me->next, __ATOMIC_RELAXED) == NULL)) {
> + if (likely(rte_atomic_load_explicit(&me->next, rte_memory_order_relaxed)
> == NULL)) {
> /* No, last member in the queue. */
> - rte_mcslock_t *save_me = __atomic_load_n(&me, __ATOMIC_RELAXED);
> + rte_mcslock_t *save_me = rte_atomic_load_explicit(&me,
> rte_memory_order_relaxed);
>
> /* Release the lock by setting it to NULL */
> - if (likely(__atomic_compare_exchange_n(msl, &save_me, NULL, 0,
> - __ATOMIC_RELEASE, __ATOMIC_RELAXED)))
> + if (likely(rte_atomic_compare_exchange_strong_explicit(msl,
> &save_me, NULL,
> + rte_memory_order_release,
> rte_memory_order_relaxed)))
> return;
>
> /* Speculative execution would be allowed to read in the
> * while-loop first. This has the potential to cause a
> * deadlock. Need a load barrier.
> */
> - __atomic_thread_fence(__ATOMIC_ACQUIRE);
> + __rte_atomic_thread_fence(rte_memory_order_acquire);
> /* More nodes added to the queue by other CPUs.
> * Wait until the next pointer is set.
> */
> - uintptr_t *next;
> - next = (uintptr_t *)&me->next;
> + uintptr_t __rte_atomic *next;
> + next = (uintptr_t __rte_atomic *)&me->next;
This way around, I think:
__rte_atomic uintptr_t *next;
next = (__rte_atomic uintptr_t *)&me->next;
[...]
> --- a/lib/eal/include/rte_pflock.h
> +++ b/lib/eal/include/rte_pflock.h
> @@ -41,8 +41,8 @@
> */
> struct rte_pflock {
> struct {
> - uint16_t in;
> - uint16_t out;
> + uint16_t __rte_atomic in;
> + uint16_t __rte_atomic out;
Again, I think __rte_atomic should be before the type:
__rte_atomic uint16_t in;
__rte_atomic uint16_t out;
> } rd, wr;
> };
[...]
> --- a/lib/eal/include/rte_seqcount.h
> +++ b/lib/eal/include/rte_seqcount.h
> @@ -32,7 +32,7 @@
> * The RTE seqcount type.
> */
> typedef struct {
> - uint32_t sn; /**< A sequence number for the protected data. */
> + uint32_t __rte_atomic sn; /**< A sequence number for the protected data.
> */
Again, I think __rte_atomic should be before the type:
__rte_atomic uint32_t sn; /**< A sequence [...]
> } rte_seqcount_t;
[...]
> --- a/lib/eal/include/rte_ticketlock.h
> +++ b/lib/eal/include/rte_ticketlock.h
> @@ -30,10 +30,10 @@
> * The rte_ticketlock_t type.
> */
> typedef union {
> - uint32_t tickets;
> + uint32_t __rte_atomic tickets;
> struct {
> - uint16_t current;
> - uint16_t next;
> + uint16_t __rte_atomic current;
> + uint16_t __rte_atomic next;
Again, I think __rte_atomic should be before the type:
__rte_atomic uint16_t current;
__rte_atomic uint16_t next;
> } s;
> } rte_ticketlock_t;
> @@ -127,7 +129,7 @@
>
> typedef struct {
> rte_ticketlock_t tl; /**< the actual ticketlock */
> - int user; /**< core id using lock, TICKET_LOCK_INVALID_ID for unused */
> + int __rte_atomic user; /**< core id using lock, TICKET_LOCK_INVALID_ID
> for unused */
Again, I think __rte_atomic should be before the type:
__rte_atomic int user; /**< core id [...]
> unsigned int count; /**< count of time this lock has been called */
> } rte_ticketlock_recursive_t;
[...]
> --- a/lib/eal/include/rte_trace_point.h
> +++ b/lib/eal/include/rte_trace_point.h
> @@ -33,7 +33,7 @@
> #include <rte_stdatomic.h>
>
> /** The tracepoint object. */
> -typedef uint64_t rte_trace_point_t;
> +typedef uint64_t __rte_atomic rte_trace_point_t;
Again, I think __rte_atomic should be before the type:
typedef __rte_atomic uint64_t rte_trace_point_t;
[...]
At the risk of having gone "speed blind" by all the search-replaces along the way...
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
next prev parent reply other threads:[~2023-08-14 8:00 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 1:31 [PATCH 0/6] RFC optional rte optional stdatomics API Tyler Retzlaff
2023-08-11 1:31 ` [PATCH 1/6] eal: provide rte stdatomics optional atomics API Tyler Retzlaff
2023-08-11 8:56 ` Bruce Richardson
2023-08-11 9:42 ` Morten Brørup
2023-08-11 15:54 ` Tyler Retzlaff
2023-08-14 9:04 ` Morten Brørup
2023-08-11 1:31 ` [PATCH 2/6] eal: adapt EAL to present rte " Tyler Retzlaff
2023-08-11 1:31 ` [PATCH 3/6] eal: add rte atomic qualifier with casts Tyler Retzlaff
2023-08-11 1:31 ` [PATCH 4/6] distributor: adapt for EAL optional atomics API changes Tyler Retzlaff
2023-08-11 1:32 ` [PATCH 5/6] bpf: " Tyler Retzlaff
2023-08-11 1:32 ` [PATCH 6/6] devtools: forbid new direct use of GCC atomic builtins Tyler Retzlaff
2023-08-11 8:57 ` Bruce Richardson
2023-08-11 9:51 ` Morten Brørup
2023-08-11 15:56 ` Tyler Retzlaff
2023-08-14 6:37 ` Morten Brørup
2023-08-11 17:32 ` [PATCH v2 0/6] RFC optional rte optional stdatomics API Tyler Retzlaff
2023-08-11 17:32 ` [PATCH v2 1/6] eal: provide rte stdatomics optional atomics API Tyler Retzlaff
2023-08-14 7:06 ` Morten Brørup
2023-08-11 17:32 ` [PATCH v2 2/6] eal: adapt EAL to present rte " Tyler Retzlaff
2023-08-14 8:00 ` Morten Brørup [this message]
2023-08-14 17:47 ` Tyler Retzlaff
2023-08-16 20:13 ` Morten Brørup
2023-08-16 20:32 ` Tyler Retzlaff
2023-08-11 17:32 ` [PATCH v2 3/6] eal: add rte atomic qualifier with casts Tyler Retzlaff
2023-08-14 8:05 ` Morten Brørup
2023-08-11 17:32 ` [PATCH v2 4/6] distributor: adapt for EAL optional atomics API changes Tyler Retzlaff
2023-08-14 8:07 ` Morten Brørup
2023-08-11 17:32 ` [PATCH v2 5/6] bpf: " Tyler Retzlaff
2023-08-14 8:11 ` Morten Brørup
2023-08-11 17:32 ` [PATCH v2 6/6] devtools: forbid new direct use of GCC atomic builtins Tyler Retzlaff
2023-08-14 8:12 ` Morten Brørup
2023-08-16 19:19 ` [PATCH v3 0/6] RFC optional rte optional stdatomics API Tyler Retzlaff
2023-08-16 19:19 ` [PATCH v3 1/6] eal: provide rte stdatomics optional atomics API Tyler Retzlaff
2023-08-16 20:55 ` Morten Brørup
2023-08-16 21:04 ` Tyler Retzlaff
2023-08-16 21:08 ` Morten Brørup
2023-08-16 21:10 ` Tyler Retzlaff
2023-08-16 19:19 ` [PATCH v3 2/6] eal: adapt EAL to present rte " Tyler Retzlaff
2023-08-16 19:19 ` [PATCH v3 3/6] eal: add rte atomic qualifier with casts Tyler Retzlaff
2023-08-16 19:19 ` [PATCH v3 4/6] distributor: adapt for EAL optional atomics API changes Tyler Retzlaff
2023-08-16 19:19 ` [PATCH v3 5/6] bpf: " Tyler Retzlaff
2023-08-16 19:19 ` [PATCH v3 6/6] devtools: forbid new direct use of GCC atomic builtins Tyler Retzlaff
2023-08-16 21:38 ` [PATCH v4 0/6] RFC optional rte optional stdatomics API Tyler Retzlaff
2023-08-16 21:38 ` [PATCH v4 1/6] eal: provide rte stdatomics optional atomics API Tyler Retzlaff
2023-08-17 11:45 ` Morten Brørup
2023-08-17 19:09 ` Tyler Retzlaff
2023-08-18 6:55 ` Morten Brørup
2023-08-16 21:38 ` [PATCH v4 2/6] eal: adapt EAL to present rte " Tyler Retzlaff
2023-08-16 21:38 ` [PATCH v4 3/6] eal: add rte atomic qualifier with casts Tyler Retzlaff
2023-08-16 21:38 ` [PATCH v4 4/6] distributor: adapt for EAL optional atomics API changes Tyler Retzlaff
2023-08-16 21:38 ` [PATCH v4 5/6] bpf: " Tyler Retzlaff
2023-08-16 21:38 ` [PATCH v4 6/6] devtools: forbid new direct use of GCC atomic builtins Tyler Retzlaff
2023-08-17 11:57 ` Morten Brørup
2023-08-17 19:14 ` Tyler Retzlaff
2023-08-18 7:13 ` Morten Brørup
2023-08-22 18:14 ` Tyler Retzlaff
2023-08-17 21:42 ` [PATCH v5 0/6] optional rte optional stdatomics API Tyler Retzlaff
2023-08-17 21:42 ` [PATCH v5 1/6] eal: provide rte stdatomics optional atomics API Tyler Retzlaff
2023-08-17 21:42 ` [PATCH v5 2/6] eal: adapt EAL to present rte " Tyler Retzlaff
2023-08-17 21:42 ` [PATCH v5 3/6] eal: add rte atomic qualifier with casts Tyler Retzlaff
2023-08-17 21:42 ` [PATCH v5 4/6] distributor: adapt for EAL optional atomics API changes Tyler Retzlaff
2023-08-17 21:42 ` [PATCH v5 5/6] bpf: " Tyler Retzlaff
2023-08-17 21:42 ` [PATCH v5 6/6] devtools: forbid new direct use of GCC atomic builtins Tyler Retzlaff
2023-08-21 22:27 ` [PATCH v5 0/6] optional rte optional stdatomics API Konstantin Ananyev
2023-08-22 21:00 ` [PATCH v6 0/6] rte atomics API for optional stdatomic Tyler Retzlaff
2023-08-22 21:00 ` [PATCH v6 1/6] eal: provide rte stdatomics optional atomics API Tyler Retzlaff
2023-09-28 8:06 ` Thomas Monjalon
2023-09-29 8:04 ` David Marchand
2023-09-29 8:54 ` Morten Brørup
2023-09-29 9:02 ` David Marchand
2023-09-29 9:26 ` Bruce Richardson
2023-09-29 9:34 ` David Marchand
2023-09-29 10:26 ` Thomas Monjalon
2023-09-29 11:38 ` David Marchand
2023-09-29 11:51 ` Thomas Monjalon
2023-08-22 21:00 ` [PATCH v6 2/6] eal: adapt EAL to present rte " Tyler Retzlaff
2023-08-22 21:00 ` [PATCH v6 3/6] eal: add rte atomic qualifier with casts Tyler Retzlaff
2023-08-22 21:00 ` [PATCH v6 4/6] distributor: adapt for EAL optional atomics API changes Tyler Retzlaff
2023-08-22 21:00 ` [PATCH v6 5/6] bpf: " Tyler Retzlaff
2023-08-22 21:00 ` [PATCH v6 6/6] devtools: forbid new direct use of GCC atomic builtins Tyler Retzlaff
2023-08-29 15:57 ` [PATCH v6 0/6] rte atomics API for optional stdatomic Tyler Retzlaff
2023-09-29 14:09 ` 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=98CBD80474FA8B44BF855DF32C47DC35D87AEF@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=bruce.richardson@intel.com \
--cc=david.hunt@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=drc@linux.vnet.ibm.com \
--cc=honnappa.nagarahalli@arm.com \
--cc=jerinj@marvell.com \
--cc=joyce.kong@arm.com \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=mattias.ronnblom@ericsson.com \
--cc=roretzla@linux.microsoft.com \
--cc=ruifeng.wang@arm.com \
--cc=skori@marvell.com \
--cc=techboard@dpdk.org \
--cc=thomas@monjalon.net \
/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).