DPDK patches and discussions
 help / color / mirror / Atom feed
* rte_ring move head  question for machines with relaxed MO (arm/ppc)
@ 2024-10-08 12:58 Konstantin Ananyev
  2024-10-08 15:09 ` Wathsala Wathawana Vithanage
  0 siblings, 1 reply; 13+ messages in thread
From: Konstantin Ananyev @ 2024-10-08 12:58 UTC (permalink / raw)
  To: dev; +Cc: honnappa.nagarahalli, Jerin Jacob, Wathsala Vithanage, drc

Hi lads,

Looking at rte_ring move_head functions I noticed that all of them
use slightly different approach to guarantee desired order of memory accesses:


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?
b) if yes, is there any difference in terms of performance between:
     "ldr; dmb; ldr;"   vs "lda; ldr;"
      ?
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?
I.E.- for reading tail value - we don't need to use load(acquire).
Or probably I do miss something obvious here?

Thanks
Konstantin

For convenience, I created a godbot page with all these variants:
https://godbolt.org/z/Yjj73b8xa
   
#1 - __rte_ring_headtail_move_head()
#2 - __rte_ring_headtail_move_head_c11_v1  
#3 - __rte_ring_headtail_move_head_c11_v2
#2 with c) -  __rte_ring_headtail_move_head_c11_v3
 
          
  


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-10-15 15:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-08 12:58 rte_ring move head question for machines with relaxed MO (arm/ppc) 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 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).