DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ruifeng Wang <Ruifeng.Wang@arm.com>
To: "Mattias Rönnblom" <hofors@lysator.liu.se>,
	"thomas@monjalon.net" <thomas@monjalon.net>,
	"david.marchand@redhat.com" <david.marchand@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"konstantin.v.ananyev@yandex.ru" <konstantin.v.ananyev@yandex.ru>,
	Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>,
	nd <nd@arm.com>, nd <nd@arm.com>
Subject: RE: [PATCH] eal: add notes to SMP memory barrier APIs
Date: Mon, 3 Jul 2023 06:12:42 +0000	[thread overview]
Message-ID: <AS8PR08MB70804F5793148AB76538AD049E29A@AS8PR08MB7080.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <f57e8ab2-dd7b-9f13-37eb-6818566bdc65@lysator.liu.se>

> -----Original Message-----
> From: Mattias Rönnblom <hofors@lysator.liu.se>
> Sent: Friday, June 30, 2023 3:28 AM
> To: Ruifeng Wang <Ruifeng.Wang@arm.com>; thomas@monjalon.net; david.marchand@redhat.com
> Cc: dev@dpdk.org; konstantin.v.ananyev@yandex.ru; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; nd <nd@arm.com>
> Subject: Re: [PATCH] eal: add notes to SMP memory barrier APIs
> 
> On 2023-06-25 10:17, Ruifeng Wang wrote:
> >> -----Original Message-----
> >> From: Mattias Rönnblom <hofors@lysator.liu.se>
> >> Sent: Friday, June 23, 2023 2:20 AM
> >> To: Ruifeng Wang <Ruifeng.Wang@arm.com>; thomas@monjalon.net;
> >> david.marchand@redhat.com
> >> Cc: dev@dpdk.org; konstantin.v.ananyev@yandex.ru; Honnappa
> >> Nagarahalli <Honnappa.Nagarahalli@arm.com>; nd <nd@arm.com>
> >> Subject: Re: [PATCH] eal: add notes to SMP memory barrier APIs
> >>
> >> On 2023-06-21 08:44, 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>
> >>> ---
> >>>    lib/eal/include/generic/rte_atomic.h | 15 +++++++++++++++
> >>>    1 file changed, 15 insertions(+)
> >>>
> >>> diff --git a/lib/eal/include/generic/rte_atomic.h
> >>> b/lib/eal/include/generic/rte_atomic.h
> >>> index 58df843c54..542a2c16ff 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 adds complexity to the memory
> >>> + model
> >>> + *  used by this project. C11 memory model should always be used.
> >>> + *  rte_atomic_thread_fence() should be used instead.
> >>
> >> It's somewhat confusing to learn I should use the C11 memory model,
> >> and then in the next sentence that I should call a function which is not in C11.
> >
> > I should say "memory order semantics". It will be more specific.
> > The wrapper function rte_atomic_thread_fence is a special case. It
> > provides an optimized implementation for __ATOMIC_SEQ_CST for x86:
> > https://www.dpdk.org/blog/2021/03/26/dpdk-adopts-the-c11-memory-model/
> >
> >>
> >> I think it would be helpful to say which memory_model parameters
> >> should be used to replace the rte_smp_*mb() calls, and if there are
> >> any difference in semantics between the Linux kernel-style barriers and their C11
> (near-)equivalents.
> >
> > As compiler atomic built-ins are being used. The memory model parameters should be the
> ones listed in:
> > https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
> > We are not taking Linux kernel-style barriers. So no need to mention that.
> >
> 
> Yeah, sure. But which one of the C11 memory models, for respective legacy barrier?
> 
> What you are moving from is Linux kernel-style barriers, so if you are to recommend a
> migration path, their semantics will matter.

Got it. I can add the suggested memory_model parameters for respective legacy barrier.

> 
> >>
> >> Is there some particular reason these functions aren't marked
> >> __rte_deprecated? Too many warnings?
> >
> > Yes, warnings will come up. Some occurrences still remain in the project.
> >
> >>
> >>>     */
> >>>    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 adds complexity to the memory
> >>> + model
> >>> + *  used by this project. C11 memory model should always be used.
> >>> + *  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 adds complexity to the memory
> >>> + model
> >>> + *  used by this project. C11 memory model should always be used.
> >>> + *  rte_atomic_thread_fence() should be used instead.
> >>>     */
> >>>    static inline void rte_smp_rmb(void);
> >>>    ///@}

  reply	other threads:[~2023-07-03  6:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-21  6:44 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 [this message]
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
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=AS8PR08MB70804F5793148AB76538AD049E29A@AS8PR08MB7080.eurprd08.prod.outlook.com \
    --to=ruifeng.wang@arm.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=hofors@lysator.liu.se \
    --cc=konstantin.v.ananyev@yandex.ru \
    --cc=nd@arm.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).