From: "Mattias Rönnblom" <hofors@lysator.liu.se>
To: Ruifeng Wang <Ruifeng.Wang@arm.com>,
"thomas@monjalon.net" <thomas@monjalon.net>,
"david.marchand@redhat.com" <david.marchand@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
"roretzla@linux.microsoft.com" <roretzla@linux.microsoft.com>,
"konstantin.v.ananyev@yandex.ru" <konstantin.v.ananyev@yandex.ru>,
Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>,
nd <nd@arm.com>
Subject: Re: [PATCH v2] eal: add notes to SMP memory barrier APIs
Date: Tue, 4 Jul 2023 14:08:26 +0200 [thread overview]
Message-ID: <7d352cdc-5395-49b3-c8a6-1d2dcc80864a@lysator.liu.se> (raw)
In-Reply-To: <AS8PR08MB70808751FC7FBB7A837EE48E9E29A@AS8PR08MB7080.eurprd08.prod.outlook.com>
On 2023-07-03 09:02, Ruifeng Wang wrote:
>> -----Original Message-----
>> From: Mattias Rönnblom <hofors@lysator.liu.se>
>> Sent: Friday, June 30, 2023 3:44 AM
>> To: Ruifeng Wang <Ruifeng.Wang@arm.com>; thomas@monjalon.net; david.marchand@redhat.com
>> Cc: dev@dpdk.org; roretzla@linux.microsoft.com; konstantin.v.ananyev@yandex.ru; Honnappa
>> Nagarahalli <Honnappa.Nagarahalli@arm.com>; nd <nd@arm.com>
>> Subject: Re: [PATCH v2] eal: add notes to SMP memory barrier APIs
>>
>> On 2023-06-26 09:12, Ruifeng Wang wrote:
>>> The rte_smp_xx() APIs are deprecated. But it is not mentioned in the
>>> function header.
>>> Added notes in function header for clarification.
>>>
>>> Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
>>> ---
>>> v2: Made the notes more specific.
>>>
>>> lib/eal/include/generic/rte_atomic.h | 19 +++++++++++++++++++
>>> 1 file changed, 19 insertions(+)
>>>
>>> diff --git a/lib/eal/include/generic/rte_atomic.h
>>> b/lib/eal/include/generic/rte_atomic.h
>>> index 58df843c54..35e0041ce6 100644
>>> --- a/lib/eal/include/generic/rte_atomic.h
>>> +++ b/lib/eal/include/generic/rte_atomic.h
>>> @@ -55,6 +55,11 @@ static inline void rte_rmb(void);
>>> * Guarantees that the LOAD and STORE operations that precede the
>>> * rte_smp_mb() call are globally visible across the lcores
>>> * before the LOAD and STORE operations that follows it.
>>> + *
>>> + * @note
>>> + * This function is deprecated. It provides fence synchronization
>>> + * primitive but doesn't take memory order parameter.
>>> + * rte_atomic_thread_fence() should be used instead.
>>
>> I can't see why coding the memory model semantics into the name, rather than by
>> specification-by-means-of-a-parameter, could be the real issue.
>> Could you explain? Seems like just different syntax to me.
>
> Yes, rte_smp_xx and rte_atomic_thread_fence have different syntaxes.
>
> The compiler atomic builtins were accepted for memory ordering. It comprises atomic arithmetic,
> atomic load/store, and atomic fence. It is simpler and clearer to do memory ordering by using
> the atomic builtins whenever possible.
> rte_smp_xx has functionality overlap with atomic fence builtins but with different memory model
> semantics and different syntaxes. Because of the differences, it will make memory ordering a little
> more complex if rte_smp_xx is kept aside atomic builtins suite.
>
I wasn't arguing for keeping Linux kernel-style barriers. It was just
the rationale that seemed flawed to me.
If Linux kernel-style memory barriers took a memory model parameter, we
would still prefer C11-style GCC barrier intrinsics (for this release).
>>
>> The old <rte_atomic.h> atomic arithmetic and atomic load/store operations suffered from
>> unspecified semantics in regards to any ordering they imposed on other memory accesses. I
>> guess that shortcoming could be described as a "missing parameter", although that too
>> would be misleading. Unclear semantics seems not be the case for the kernel-style barriers
>> though.
>>
>>> */
>>> static inline void rte_smp_mb(void);
>>>
>>> @@ -64,6 +69,11 @@ static inline void rte_smp_mb(void);
>>> * Guarantees that the STORE operations that precede the
>>> * rte_smp_wmb() call are globally visible across the lcores
>>> * before the STORE operations that follows it.
>>> + *
>>> + * @note
>>> + * This function is deprecated. It provides fence synchronization
>>> + * primitive but doesn't take memory order parameter.
>>> + * rte_atomic_thread_fence() should be used instead.
>>> */
>>> static inline void rte_smp_wmb(void);
>>>
>>> @@ -73,6 +83,11 @@ static inline void rte_smp_wmb(void);
>>> * Guarantees that the LOAD operations that precede the
>>> * rte_smp_rmb() call are globally visible across the lcores
>>> * before the LOAD operations that follows it.
>>> + *
>>> + * @note
>>> + * This function is deprecated. It provides fence synchronization
>>> + * primitive but doesn't take memory order parameter.
>>> + * rte_atomic_thread_fence() should be used instead.
>>> */
>>> static inline void rte_smp_rmb(void);
>>> ///@}
>>> @@ -122,6 +137,10 @@ static inline void rte_io_rmb(void);
>>>
>>> /**
>>> * Synchronization fence between threads based on the specified memory order.
>>> + *
>>> + * @param memorder
>>> + * The memory order defined by compiler atomic builtin at:
>>> + * https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
>>> */
>>> static inline void rte_atomic_thread_fence(int memorder);
>>>
next prev parent reply other threads:[~2023-07-04 12:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-21 6:44 [PATCH] " Ruifeng Wang
2023-06-21 7:29 ` Thomas Monjalon
2023-06-25 7:55 ` Ruifeng Wang
2023-06-22 18:19 ` Mattias Rönnblom
2023-06-23 21:51 ` Tyler Retzlaff
2023-06-25 8:45 ` Ruifeng Wang
2023-06-25 15:40 ` Thomas Monjalon
2023-06-25 8:17 ` Ruifeng Wang
2023-06-29 19:28 ` Mattias Rönnblom
2023-07-03 6:12 ` Ruifeng Wang
2023-06-26 7:12 ` [PATCH v2] " Ruifeng Wang
2023-06-29 19:43 ` Mattias Rönnblom
2023-07-03 7:02 ` Ruifeng Wang
2023-07-04 12:08 ` Mattias Rönnblom [this message]
2023-07-03 9:56 ` [PATCH v3] " Ruifeng Wang
2023-07-28 9:17 ` Thomas Monjalon
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=7d352cdc-5395-49b3-c8a6-1d2dcc80864a@lysator.liu.se \
--to=hofors@lysator.liu.se \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=Ruifeng.Wang@arm.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=nd@arm.com \
--cc=roretzla@linux.microsoft.com \
--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).