DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wathsala Wathawana Vithanage <wathsala.vithanage@arm.com>
To: Konstantin Ananyev <konstantin.ananyev@huawei.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>,
	"jerinj@marvell.com" <jerinj@marvell.com>,
	"drc@linux.ibm.com" <drc@linux.ibm.com>, nd <nd@arm.com>,
	nd <nd@arm.com>
Subject: RE: rte_ring move head  question for machines with relaxed MO (arm/ppc)
Date: Wed, 9 Oct 2024 02:22:09 +0000	[thread overview]
Message-ID: <PAWPR08MB8909B9DE91915A9C0D9D3BF29F7F2@PAWPR08MB8909.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <0badc1b8ea524bf3b69d0b7b316bdc8f@huawei.com>

> > > 1. rte_ring_generic_pvt.h:
> > > =====================
> > >
> > > pseudo-c-code                                      //        related armv8 instructions
> > > --------------------                                                 --------------------------------------
> > >  head.load()                                          //        ldr [head]
> > >  rte_smp_rmb()                                    //        dmb ishld
> > >  opposite_tail.load()                            //        ldr [opposite_tail]
> > >  ...
> > >  rte_atomic32_cmpset(head, ...)      //        ldrex[head];... stlex[head]
> > >
> > >
> > > 2. rte_ring_c11_pvt.h
> > > =====================
> > >
> > > pseudo-c-code                                       //        related armv8 instructions
> > > --------------------                                                 --------------------------------------
> > > head.atomic_load(relaxed)                 //        ldr[head]
> > > atomic_thread_fence(acquire)           //        dmb ish
> > > opposite_tail.atomic_load(acquire)   //        lda[opposite_tail]
> > > ...
> > > head.atomic_cas(..., relaxed)              //        ldrex[haed]; ... strex[head]
> > >
> > >
> > > 3.   rte_ring_hts_elem_pvt.h
> > > ==========================
> > >
> > > pseudo-c-code                                       //        related armv8 instructions
> > > --------------------                                                 --------------------------------------
> > > head.atomic_load(acquire)                //        lda [head]
> > > opposite_tail.load()                             //        ldr [opposite_tail]
> > > ...
> > > head.atomic_cas(..., acquire)            //         ldaex[head]; ... strex[head]
> > >
> > > The questions that arose from these observations:
> > > a) are all 3 approaches equivalent in terms of functionality?
> > Different, lda (Load with acquire semantics) and ldr (load) are different.
> 
> I understand that, my question was:
> lda {head]; ldr[tail]
> vs
> ldr [head]; dmb ishld; ldr [tail];
> 
> Is there any difference in terms of functionality (memory ops
> ordering/observability)?
> 
> >
> > > b) if yes, is there any difference in terms of performance between:
> > >      "ldr; dmb; ldr;"   vs "lda; ldr;"
> > >       ?
> > dmb is a full barrier, performance is poor.
> > I would assume (haven't measured) ldr; dmb; ldr to be less performant
> > than lda;ldr;
> 
> Through all this mail am talking about 'dmb ishld', sorry for not being clear
> upfront.
>
A: ldr; dmb ishld; ldr; -> load before the dmb ishld should be observed by the inner shareable 
domain before execution of the second ldr.
(Also applies to stores program order after dmb ishld.)

B: lda; ldr; -> second load cannot execute before the load acquire.
(Also applies to stores program order after lda.)

In theory, I would assume them to be at least roughly equal in performance if not B is more
performant than A.


> >
> > > c) Comapring at 1) and 2) above, combination of
> > >    ldr [head]; dmb; lda [opposite_tail]:
> > >    looks     like an overkill to me.  Wouldn't just:
> > >    ldr [head]; dmb; ldr[opposite_tail];
> > >    be sufficient here?
> > lda [opposite_tail]: synchronizes with stlr in tail update that happens after
> array update.
> > So, it cannot be changed to ldr.
> 
> Can you explain me a bit more here why it is not possible?
> From here:
> https://developer.arm.com/documentation/dui0802/b/A32-and-T32-
> Instructions/LDA-and-STL
> "There is no requirement that a load-acquire and store-release be paired."
> Do I misinterpret this statement somehow?
> 
> > lda can be replaced with ldapr (LDA with release consistency -
> > processor consistency) which is more performant as lda is allowed to
> > rise above stlr. Can be done with -mcpu=+rcpc
> >
> > --wathsala
> >


      parent reply	other threads:[~2024-10-09  2:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08 12:58 Konstantin Ananyev
2024-10-08 15:09 ` Wathsala Wathawana Vithanage
2024-10-08 15:12   ` Wathsala Wathawana Vithanage
2024-10-08 15:45   ` Konstantin Ananyev
2024-10-08 15:56     ` Konstantin Ananyev
2024-10-09 17:27       ` Wathsala Wathawana Vithanage
2024-10-10 16:54         ` Konstantin Ananyev
2024-10-11  0:11           ` Wathsala Wathawana Vithanage
2024-10-11 14:08             ` Konstantin Ananyev
2024-10-11 15:48               ` Wathsala Wathawana Vithanage
2024-10-15 15:11                 ` Konstantin Ananyev
2024-10-09  1:41     ` Wathsala Wathawana Vithanage
2024-10-09  2:22     ` Wathsala Wathawana Vithanage [this message]

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=PAWPR08MB8909B9DE91915A9C0D9D3BF29F7F2@PAWPR08MB8909.eurprd08.prod.outlook.com \
    --to=wathsala.vithanage@arm.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=dev@dpdk.org \
    --cc=drc@linux.ibm.com \
    --cc=jerinj@marvell.com \
    --cc=konstantin.ananyev@huawei.com \
    --cc=nd@arm.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).