Skip to contentSkip to conversation

fix race condition in enqueue/dequeue because of cpu reorder

PATCH Superseded Jia He 7 participants 40 messages Nov 8, 2017 – Jan 16, 2018 1 message not in the archive

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Jia He

author
#1 lore raw

v4 cover fix race condition in enqueue/dequeue because of cpu reorder

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server due to a possible race condition.

To fix this race, there are 2 options as suggested by Jerin:
1. use rte_smp_rmb
2. use load_acquire/store_release(refer to [2]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines.

Already fuctionally tested on the machines as follows:
- on X86
- on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
- on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=n

---
Changelog:
V4: split into small patches
V3: arch specific implementation for enqueue/dequeue barrier
V2: let users choose whether using load_acquire/store_release
V1: rte_smp_rmb() between 2 loads

Jia He (4):
eal/arm64: remove the braces {} for dmb() and dsb()
ring: guarantee load/load order in enqueue and dequeue
ring: introduce new header file to include common functions
ring: introduce new header file to support C11 memory model

 config/common_armv8a_linuxapp                      |   2 +
 .../common/include/arch/arm/rte_atomic_64.h        |   4 +-
 lib/librte_eventdev/rte_event_ring.h               |   6 +-
 lib/librte_ring/Makefile                           |   4 +-
 lib/librte_ring/rte_ring.h                         | 161 ++---------------
 lib/librte_ring/rte_ring_c11_mem.h                 | 185 ++++++++++++++++++++
 lib/librte_ring/rte_ring_generic.h                 | 194 +++++++++++++++++++++
 7 files changed, 404 insertions(+), 152 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_c11_mem.h
 create mode 100644 lib/librte_ring/rte_ring_generic.h
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH v4 1/4 eal/arm64: remove the braces {} for dmb() and dsb()

for the code as follows:
if (condition)

	rte_smp_rmb();
else
	rte_smp_wmb();

Without this patch, compiler will report this error:
error: 'else' without a previous 'if'

Fixes 84733fd0d75e ("eal/arm64: fix memory barrier definition")
---
 lib/librte_eal/common/include/arch/arm/rte_atomic_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/common/include/arch/arm/rte_atomic_64.h +2 -2
index 0b70d62..71da29c 100644
@@ -43,8 +43,8 @@ extern "C" {
 
 #include "generic/rte_atomic.h"
 
-#define dsb(opt)  { asm volatile("dsb " #opt : : : "memory"); }
-#define dmb(opt)  { asm volatile("dmb " #opt : : : "memory"); }
+#define dsb(opt) asm volatile("dsb " #opt : : : "memory")
+#define dmb(opt) asm volatile("dmb " #opt : : : "memory")
 
 #define rte_mb() dsb(sy)
 
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH v4 2/4 ring: guarantee load/load order in enqueue and dequeue

In reply to Jia He

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server. In __rte_ring_move_cons_head()
...

        do {
                /* Restore n as it may change every loop */
                n = max;

                *old_head = r->cons.head;                //1st load
                const uint32_t prod_tail = r->prod.tail; //2nd load

In weak memory order architectures(powerpc,arm), the 2nd load might be reodered before the 1st load, that makes *entries is bigger than we wanted. This nasty reording messed enque/deque up.

cpu1(producer) cpu2(consumer) cpu3(consumer)

                        load r->prod.tail

in enqueue:
load r->cons.tail
load r->prod.head

store r->prod.tail

                                                load r->cons.head
                                                load r->prod.tail
                                                ...
                                                store r->cons.{head,tail}
                        load r->cons.head

Then, r->cons.head will be bigger than prod_tail, then make *entries very big and the consumer will go forward incorrectly.

After this patch, the old cons.head will be recaculated after failure of rte_atomic32_cmpset

There is no such issue on X86, because X86 is strong memory order model.

Signed-off-by [email protected]
Signed-off-by [email protected]
---
 lib/librte_ring/rte_ring.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/librte_ring/rte_ring.h +10 -0
index 5e9b3b7..3e8085a 100644
@@ -409,6 +409,11 @@ __rte_ring_move_prod_head(struct rte_ring *r, int is_sp,
 		n = max;
 
 		*old_head = r->prod.head;
+
+		/* add rmb barrier to avoid load/load reorder in weak
+		 * memory model. It is noop on x86 */
+		rte_smp_rmb();
+
 		const uint32_t cons_tail = r->cons.tail;
 		/*
 		 *  The subtraction is done between two unsigned 32bits value
@@ -517,6 +522,11 @@ __rte_ring_move_cons_head(struct rte_ring *r, int is_sc,
 		n = max;
 
 		*old_head = r->cons.head;
+
+		/* add rmb barrier to avoid load/load reorder in weak
+		 * memory model. It is noop on x86 */
+		rte_smp_rmb();
+
 		const uint32_t prod_tail = r->prod.tail;
 		/* The subtraction is done between two unsigned 32bits value
 		 * (the result is always modulo 32 bits even if we have
Signature · 1 line
2.7.4
author
#4 lore raw

PATCH v4 3/4 ring: introduce new header file to include common functions

In reply to Jia He

move the common part of rte_ring.h into rte_ring_generic.h move the memory barrier part into update_tail() no functional changes here

---
 lib/librte_eventdev/rte_event_ring.h |   6 +-
 lib/librte_ring/Makefile             |   3 +-
 lib/librte_ring/rte_ring.h           | 159 +---------------------------
 lib/librte_ring/rte_ring_generic.h   | 194 +++++++++++++++++++++++++++++++++++
 4 files changed, 202 insertions(+), 160 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_generic.h
lib/librte_eventdev/rte_event_ring.h +2 -4
index ea9b688..3e49458 100644
@@ -126,9 +126,8 @@ rte_event_ring_enqueue_burst(struct rte_event_ring *r,
 		goto end;
 
 	ENQUEUE_PTRS(&r->r, &r[1], prod_head, events, n, struct rte_event);
-	rte_smp_wmb();
 
-	update_tail(&r->r.prod, prod_head, prod_next, 1);
+	update_tail(&r->r.prod, prod_head, prod_next, 1, 1);
 end:
 	if (free_space != NULL)
 		*free_space = free_entries - n;
@@ -168,9 +167,8 @@ rte_event_ring_dequeue_burst(struct rte_event_ring *r,
 		goto end;
 
 	DEQUEUE_PTRS(&r->r, &r[1], cons_head, events, n, struct rte_event);
-	rte_smp_rmb();
 
-	update_tail(&r->r.cons, cons_head, cons_next, 1);
+	update_tail(&r->r.cons, cons_head, cons_next, 1, 0);
 
 end:
 	if (available != NULL)
lib/librte_ring/Makefile +2 -1
index e34d9d9..c959945 100644
@@ -45,6 +45,7 @@ LIBABIVER := 1
 SRCS-$(CONFIG_RTE_LIBRTE_RING) := rte_ring.c
 
 # install includes
-SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h \
+					rte_ring_generic.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_ring/rte_ring.h +4 -155

185 lines not on this page · raw message

lib/librte_ring/rte_ring_generic.h new file +194 -0

194 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#5 lore raw

PATCH v4 4/4 ring: introduce new header file to support C11 memory model

In reply to Jia He

To fix the cpu reorder race condition in enque/deque, there are 2 options suggested by Jerin:
1. use rte_smp_rmb
2. use load_acquire/store_release(refer to [1]).
for the 2nd option, CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines, refer to [2].

We haven't tested on ppc64. If anyone verifies it, he can add CONFIG_RTE_RING_USE_C11_MEM_MODEL=y to ppc64 config files.

[1] https://github.com/freebsd/freebsd/blob/master/sys/sys/buf_ring.h#L170
[2] http://dpdk.org/ml/archives/dev/2017-October/080861.html

---
 config/common_armv8a_linuxapp      |   2 +
 lib/librte_ring/Makefile           |   3 +-
 lib/librte_ring/rte_ring.h         |  14 ++-
 lib/librte_ring/rte_ring_c11_mem.h | 185 +++++++++++++++++++++++++++++++++++++
 4 files changed, 202 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_c11_mem.h
config/common_armv8a_linuxapp +2 -0
index 6732d1e..5b7b2eb 100644
@@ -49,3 +49,5 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n
 CONFIG_RTE_LIBRTE_AVP_PMD=n
 
 CONFIG_RTE_SCHED_VECTOR=n
+
+CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
lib/librte_ring/Makefile +2 -1
index c959945..a2682e7 100644
@@ -46,6 +46,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_RING) := rte_ring.c
 
 # install includes
 SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h \
-					rte_ring_generic.h
+					rte_ring_generic.h \
+					rte_ring_c11_mem.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_ring/rte_ring.h +13 -1
index 519614c..3343eba 100644
@@ -356,8 +356,20 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);
 	} \
 } while (0)
 
-/* Move common functions to generic file */
+/* Between load and load. there might be cpu reorder in weak model
+ * (powerpc/arm).
+ * There are 2 choices for the users
+ * 1.use rmb() memory barrier
+ * 2.use one-direcion load_acquire/store_release barrier,defined by
+ * CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
+ * It depends on performance test results.
+ * By default, move common functions to rte_ring_generic.h
+ */
+#ifdef RTE_RING_USE_C11_MEM_MODEL
+#include "rte_ring_c11_mem.h"
+#else
 #include "rte_ring_generic.h"
+#endif
 
 /**
  * @internal Enqueue several objects on the ring
lib/librte_ring/rte_ring_c11_mem.h new file +185 -0

185 lines not on this page · raw message

Signature · 1 line
2.7.4
#6 lore raw
In reply to Jia He
Quoted 20 lines · Jia He

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server due to a possible race condition.

To fix this race, there are 2 options as suggested by Jerin: 1. use rte_smp_rmb 2. use load_acquire/store_release(refer to [2]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines.

Already fuctionally tested on the machines as follows: - on X86 - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=y - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=n

--- Changelog: V4: split into small patches V3: arch specific implementation for enqueue/dequeue barrier V2: let users choose whether using load_acquire/store_release V1: rte_smp_rmb() between 2 loads

Quoted 5 lines

Jia He (4): eal/arm64: remove the braces {} for dmb() and dsb() ring:
guarantee load/load order in enqueue and dequeue ring: introduce new header file to include common functions ring: introduce new header file to support C11 memory model

I'm wondering what the merge plans are for this set, given we are now past RC3 in 17.11? As the rings are broken on ARM machines we need to merge in some fix, but I'm a little concerned about the scope of the changes from the 3rd and 4th patches. Would it be acceptable to just merge in patches 1 & 2 in 17.11 and leave the rework and C11 memory model additions in patches 3 & 4 to 18.02 release?

Regards,
/Bruce

author
#7 lore raw

Hi Bruce

On 11/8/2017 8:15 PM, Bruce Richardson Wrote:

Quoted 26 lines · Jia He
Quoted 20 lines

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server due to a possible race condition.

To fix this race, there are 2 options as suggested by Jerin: 1. use rte_smp_rmb 2. use load_acquire/store_release(refer to [2]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines.

Already fuctionally tested on the machines as follows: - on X86 - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=y - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=n

--- Changelog: V4: split into small patches V3: arch specific implementation for enqueue/dequeue barrier V2: let users choose whether using load_acquire/store_release V1: rte_smp_rmb() between 2 loads

Quoted 5 lines

Jia He (4): eal/arm64: remove the braces {} for dmb() and dsb() ring:
guarantee load/load order in enqueue and dequeue ring: introduce new header file to include common functions ring: introduce new header file to support C11 memory model

Quoted 6 lines

I'm wondering what the merge plans are for this set, given we are now past RC3 in 17.11? As the rings are broken on ARM machines we need to merge in some fix, but I'm a little concerned about the scope of the changes from the 3rd and 4th patches. Would it be acceptable to just merge in patches 1 & 2 in 17.11 and leave the rework and C11 memory model additions in patches 3 & 4 to 18.02 release?

As far as I'm concerned, it is ok.

Cheers,
Jia

#8 lore raw

-----Original Message-----

Quoted 40 lines

Date: Wed, 8 Nov 2017 23:11:32 +0800
From: Jia He <[email protected]>
To: Bruce Richardson <[email protected]>
Cc: [email protected], [email protected], [email protected],
[email protected], [email protected], [email protected]
Subject: Re: [PATCH v4 0/4] fix race condition in enqueue/dequeue because
of cpu reorder
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.4.0

Hi Bruce

On 11/8/2017 8:15 PM, Bruce Richardson Wrote:

Quoted 26 lines · Jia He
Quoted 25 lines

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server due to a possible race condition.

To fix this race, there are 2 options as suggested by Jerin: 1. use rte_smp_rmb 2. use load_acquire/store_release(refer to [2]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines.

Already fuctionally tested on the machines as follows: - on X86 - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=y - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=n

--- Changelog: V4: split into small patches V3: arch specific implementation for enqueue/dequeue barrier V2: let users choose whether using load_acquire/store_release V1: rte_smp_rmb() between 2 loads

Jia He (4): eal/arm64: remove the braces {} for dmb() and dsb() ring:
guarantee load/load order in enqueue and dequeue ring: introduce new header file to include common functions ring: introduce new header file to support C11 memory model

Quoted 7 lines
Quoted 6 lines

I'm wondering what the merge plans are for this set, given we are now past RC3 in 17.11? As the rings are broken on ARM machines we need to merge in some fix, but I'm a little concerned about the scope of the changes from the 3rd and 4th patches. Would it be acceptable to just merge in patches 1 & 2 in 17.11 and leave the rework and C11 memory model additions in patches 3 & 4 to 18.02 release?

As far as I'm concerned, it is ok.

It is OK to me as well. May be Jia can send 0-1 and 2-3 as separate series with exiting comments.

Quoted 4 lines

Cheers,
Jia

#9 lore raw
In reply to Jia He
Quoted 40 lines

-----Original Message-----
From: Jia He [mailto:[email protected]]
Sent: Wednesday, November 8, 2017 3:12 PM
To: Richardson, Bruce <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Ananyev, Konstantin <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v4 0/4] fix race condition in enqueue/dequeue because of cpu reorder

Hi Bruce

On 11/8/2017 8:15 PM, Bruce Richardson Wrote:

Quoted 26 lines · Jia He
Quoted 25 lines

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server due to a possible race condition.

To fix this race, there are 2 options as suggested by Jerin: 1. use rte_smp_rmb 2. use load_acquire/store_release(refer to [2]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines.

Already fuctionally tested on the machines as follows: - on X86 - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=y - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=n

--- Changelog: V4: split into small patches V3: arch specific implementation for enqueue/dequeue barrier V2: let users choose whether using load_acquire/store_release V1: rte_smp_rmb() between 2 loads

Jia He (4): eal/arm64: remove the braces {} for dmb() and dsb() ring:
guarantee load/load order in enqueue and dequeue ring: introduce new header file to include common functions ring: introduce new header file to support C11 memory model

Quoted 7 lines
Quoted 6 lines

I'm wondering what the merge plans are for this set, given we are now past RC3 in 17.11? As the rings are broken on ARM machines we need to merge in some fix, but I'm a little concerned about the scope of the changes from the 3rd and 4th patches. Would it be acceptable to just merge in patches 1 & 2 in 17.11 and leave the rework and C11 memory model additions in patches 3 & 4 to 18.02 release?

As far as I'm concerned, it is ok.

Sounds good to me too.
Konstantin

author
#10 lore raw
In reply to Jia He

Hi Bruce

I knew little about DPDK's milestone

I read some hints from http://dpdk.org/dev/roadmap

18.02

* Proposal deadline: November 24, 2017
* Integration deadline: January 5, 2018

I wonder whether I need to resend the patchset(the 2nd part) again after November 24? Thanks for any suggestions

Cheers,
Jia
On 11/8/2017 11:11 PM, Jia He Wrote:

Quoted 40 lines

Hi Bruce

On 11/8/2017 8:15 PM, Bruce Richardson Wrote:

Quoted 26 lines · Jia He
Quoted 20 lines

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server due to a possible race condition.

To fix this race, there are 2 options as suggested by Jerin: 1. use rte_smp_rmb 2. use load_acquire/store_release(refer to [2]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines.

Already fuctionally tested on the machines as follows: - on X86 - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=y - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=n

--- Changelog: V4: split into small patches V3: arch specific implementation for enqueue/dequeue barrier V2: let users choose whether using load_acquire/store_release V1: rte_smp_rmb() between 2 loads

Quoted 5 lines

Jia He (4): eal/arm64: remove the braces {} for dmb() and dsb() ring:
guarantee load/load order in enqueue and dequeue ring: introduce new header file to include common functions ring: introduce new header file to support C11 memory model

Quoted 6 lines

I'm wondering what the merge plans are for this set, given we are now past RC3 in 17.11? As the rings are broken on ARM machines we need to merge in some fix, but I'm a little concerned about the scope of the changes from the 3rd and 4th patches. Would it be acceptable to just merge in patches 1 & 2 in 17.11 and leave the rework and C11 memory model additions in patches 3 & 4 to 18.02 release?

As far as I'm concerned, it is ok.

Cheers,
Jia

#11 lore raw
Quoted 11 lines · Jia He

Hi Bruce

I knew little about DPDK's milestone

I read some hints from http://dpdk.org/dev/roadmap

18.02

* Proposal deadline: November 24, 2017
* Integration deadline: January 5, 2018

Quoted 6 lines

I wonder whether I need to resend the patchset(the 2nd part) again after November 24?
Thanks for any suggestions

Cheers,
Jia

It depends upon the status in patchwork. Right now I see three patches listed from you there, but strangely, despite being a set of 3, 2 are at v5, and the last is at v6. If this set is not correct, please send a new revision of the patches and mark the old ones in patchwork as superceded. The main objective is to ensure that you have one copy of the patches listed there that the committers can apply.

/Bruce

Quoted 42 lines

On 11/8/2017 11:11 PM, Jia He Wrote:

Quoted 40 lines

Hi Bruce

On 11/8/2017 8:15 PM, Bruce Richardson Wrote:

Quoted 26 lines · Jia He
Quoted 20 lines

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server due to a possible race condition.

To fix this race, there are 2 options as suggested by Jerin: 1. use rte_smp_rmb 2. use load_acquire/store_release(refer to [2]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines.

Already fuctionally tested on the machines as follows: - on X86 - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=y - on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=n

--- Changelog: V4: split into small patches V3: arch specific implementation for enqueue/dequeue barrier V2: let users choose whether using load_acquire/store_release V1: rte_smp_rmb() between 2 loads

Quoted 5 lines

Jia He (4): eal/arm64: remove the braces {} for dmb() and dsb() ring:
guarantee load/load order in enqueue and dequeue ring: introduce new header file to include common functions ring: introduce new header file to support C11 memory model

Quoted 6 lines

I'm wondering what the merge plans are for this set, given we are now past RC3 in 17.11? As the rings are broken on ARM machines we need to merge in some fix, but I'm a little concerned about the scope of the changes from the 3rd and 4th patches. Would it be acceptable to just merge in patches 1 & 2 in 17.11 and leave the rework and C11 memory model additions in patches 3 & 4 to 18.02 release?

As far as I'm concerned, it is ok.

Cheers,
Jia

author
#12 lore raw

v5 cover fix race condition in enqueue/dequeue because of cpu reorder

In reply to a message not in the archive

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server due to a possible race condition. To fix this race condition, rmb() is needed to add between the 2 loads.

Already fuctionally tested on the machines as follows:
- on X86
- on arm64

---
Changelog
V5: split it into 2 patchset due to the milestone concerns, this is the 1st one
V4: split into small patches
V3: arch specific implementation for enqueue/dequeue barrier
V2: let users choose whether using load_acquire/store_release
V1: rte_smp_rmb() between 2 loads

Jia He (4):
eal/arm64: remove the braces {} for dmb() and dsb()
ring: guarantee load/load order in enqueue and dequeue
ring: introduce new header file to include common functions
ring: introduce new header file to support C11 memory model

 config/common_armv8a_linuxapp                      |   2 +
 .../common/include/arch/arm/rte_atomic_64.h        |   4 +-
 lib/librte_eventdev/rte_event_ring.h               |   6 +-
 lib/librte_ring/Makefile                           |   4 +-
 lib/librte_ring/rte_ring.h                         | 161 ++---------------
 lib/librte_ring/rte_ring_c11_mem.h                 | 185 ++++++++++++++++++++
 lib/librte_ring/rte_ring_generic.h                 | 194 +++++++++++++++++++++
 7 files changed, 404 insertions(+), 152 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_c11_mem.h
 create mode 100644 lib/librte_ring/rte_ring_generic.h
Signature · 1 line
2.7.4
author
#13 lore raw

PATCH v5 1/1 ring: guarantee load/load order in enqueue and dequeue

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server. In __rte_ring_move_cons_head()
...

        do {
                /* Restore n as it may change every loop */
                n = max;

                *old_head = r->cons.head;                //1st load
                const uint32_t prod_tail = r->prod.tail; //2nd load

cpu1(producer) cpu2(consumer) cpu3(consumer)

                        load r->prod.tail

in enqueue:
load r->cons.tail
load r->prod.head

store r->prod.tail

                                                load r->cons.head
                                                load r->prod.tail
                                                ...
                                                store r->cons.{head,tail}
                        load r->cons.head

In weak memory order architectures(powerpc,arm), the 2nd load might be reodered before the 1st load, that makes *entries is bigger than we wanted. This nasty reording messed enque/deque up. Then, r->cons.head will be bigger than prod_tail, then make *entries very big and the consumer will go forward incorrectly.

After this patch, even with above context switches, the old cons.head will be recaculated after failure of rte_atomic32_cmpset. So no race conditions left.

There is no such issue on X86, because X86 is strong memory order model. But rte_smp_rmb() doesn't have impact on runtime performance on X86, so keep the same code without architectures specific concerns.

Signed-off-by [email protected]
Signed-off-by [email protected]
---
 lib/librte_ring/rte_ring.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/librte_ring/rte_ring.h +10 -0
index 5e9b3b7..3e8085a 100644
@@ -409,6 +409,11 @@ __rte_ring_move_prod_head(struct rte_ring *r, int is_sp,
 		n = max;
 
 		*old_head = r->prod.head;
+
+		/* add rmb barrier to avoid load/load reorder in weak
+		 * memory model. It is noop on x86 */
+		rte_smp_rmb();
+
 		const uint32_t cons_tail = r->cons.tail;
 		/*
 		 *  The subtraction is done between two unsigned 32bits value
@@ -517,6 +522,11 @@ __rte_ring_move_cons_head(struct rte_ring *r, int is_sc,
 		n = max;
 
 		*old_head = r->cons.head;
+
+		/* add rmb barrier to avoid load/load reorder in weak
+		 * memory model. It is noop on x86 */
+		rte_smp_rmb();
+
 		const uint32_t prod_tail = r->prod.tail;
 		/* The subtraction is done between two unsigned 32bits value
 		 * (the result is always modulo 32 bits even if we have
Signature · 1 line
2.7.4
Acked-by on v5 1/1
#14 lore raw

Re: [PATCH v5 1/1] ring: guarantee load/load order in enqueue and dequeue

-----Original Message-----

Quoted 11 lines

Date: Fri, 10 Nov 2017 01:51:09 +0000
From: Jia He <[email protected]>
To: [email protected], [email protected], [email protected]
Cc: [email protected], [email protected],
[email protected], [email protected], Jia He <[email protected]>, Jia He <[email protected]>, [email protected], [email protected]
Subject: [PATCH v5 1/1] ring: guarantee load/load order in enqueue and
dequeue
X-Mailer: git-send-email 2.7.4

Quoted 1 line

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server.

I think, the above text can be improved. Something like below.

Fix for the rte_panic() in mbuf_autotest on qualcomm arm64 server(...SoC name...)

Root cause:

Quoted 33 lines

In __rte_ring_move_cons_head()
...

        do {
                /* Restore n as it may change every loop */
                n = max;

                *old_head = r->cons.head;                //1st load
                const uint32_t prod_tail = r->prod.tail; //2nd load

cpu1(producer) cpu2(consumer) cpu3(consumer)

                        load r->prod.tail

in enqueue:
load r->cons.tail
load r->prod.head

store r->prod.tail

                                                load r->cons.head
                                                load r->prod.tail
                                                ...
                                                store r->cons.{head,tail}
                        load r->cons.head

In weak memory order architectures(powerpc,arm), the 2nd load might be reodered before the 1st load, that makes *entries is bigger than we wanted. This nasty reording messed enque/deque up. Then, r->cons.head will be bigger than prod_tail, then make *entries very big and the consumer will go forward incorrectly.

After this patch, even with above context switches, the old cons.head will be recaculated after failure of rte_atomic32_cmpset. So no race conditions left.

Quoted 7 lines

There is no such issue on X86, because X86 is strong memory order model. But rte_smp_rmb() doesn't have impact on runtime performance on X86, so keep the same code without architectures specific concerns.

Signed-off-by [email protected]
Signed-off-by [email protected]

➜ [master][dpdk.org] $ ./devtools/checkpatches.sh

### ring: guarantee load/load order in enqueue and dequeue

WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line
#58: FILE: lib/librte_ring/rte_ring.h:414:
+ * memory model. It is noop on x86 */

WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line
#70: FILE: lib/librte_ring/rte_ring.h:527:
+ * memory model. It is noop on x86 */

total: 0 errors, 2 warnings, 22 lines checked

0/1 valid patch
➜ [master][dpdk.org] $ ./devtools/check-git-log.sh Wrong tag:

Signed-off-by [email protected]
Signed-off-by [email protected]

With above fixes:

Acked-by
#15 lore raw

Re: [PATCH v5 1/1] ring: guarantee load/load order in enqueue and dequeue

Quoted 81 lines · Jerin Jacob

-----Original Message-----

Quoted 11 lines

Date: Fri, 10 Nov 2017 01:51:09 +0000
From: Jia He <[email protected]>
To: [email protected], [email protected], [email protected]
Cc: [email protected], [email protected],
[email protected], [email protected], Jia He <[email protected]>, Jia He <[email protected]>, [email protected], [email protected]
Subject: [PATCH v5 1/1] ring: guarantee load/load order in enqueue and
dequeue
X-Mailer: git-send-email 2.7.4

Quoted 1 line

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server.

I think, the above text can be improved. Something like below.

Fix for the rte_panic() in mbuf_autotest on qualcomm arm64 server(...SoC name...)

Root cause:

Quoted 33 lines

In __rte_ring_move_cons_head()
...

        do {
                /* Restore n as it may change every loop */
                n = max;

                *old_head = r->cons.head;                //1st load
                const uint32_t prod_tail = r->prod.tail; //2nd load

cpu1(producer) cpu2(consumer) cpu3(consumer)

                        load r->prod.tail

in enqueue:
load r->cons.tail
load r->prod.head

store r->prod.tail

                                                load r->cons.head
                                                load r->prod.tail
                                                ...
                                                store r->cons.{head,tail}
                        load r->cons.head

In weak memory order architectures(powerpc,arm), the 2nd load might be reodered before the 1st load, that makes *entries is bigger than we wanted. This nasty reording messed enque/deque up. Then, r->cons.head will be bigger than prod_tail, then make *entries very big and the consumer will go forward incorrectly.

After this patch, even with above context switches, the old cons.head will be recaculated after failure of rte_atomic32_cmpset. So no race conditions left.

Quoted 7 lines

There is no such issue on X86, because X86 is strong memory order model. But rte_smp_rmb() doesn't have impact on runtime performance on X86, so keep the same code without architectures specific concerns.

Signed-off-by [email protected]
Signed-off-by [email protected]

➜ [master][dpdk.org] $ ./devtools/checkpatches.sh

### ring: guarantee load/load order in enqueue and dequeue

WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line
#58: FILE: lib/librte_ring/rte_ring.h:414:
+ * memory model. It is noop on x86 */

WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line
#70: FILE: lib/librte_ring/rte_ring.h:527:
+ * memory model. It is noop on x86 */

total: 0 errors, 2 warnings, 22 lines checked

0/1 valid patch
➜ [master][dpdk.org] $ ./devtools/check-git-log.sh Wrong tag:

Quoted 9 lines
Signed-off-by [email protected]
Signed-off-by [email protected]

With above fixes:

And add it to stable.
Cc: [email protected]

--
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Acked-by on v5 1/1
#16 lore raw

Re: [PATCH v5 1/1] ring: guarantee load/load order in enqueue and dequeue

In reply to Jia He
Quoted 75 lines

-----Original Message-----
From: Jia He [mailto:[email protected]]
Sent: Friday, November 10, 2017 1:51 AM
To: [email protected]; [email protected]; [email protected]
Cc: Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; [email protected]; Jia He <[email protected]>; Jia He <[email protected]>; [email protected]; bing.zhao@hxt- semitech.com
Subject: [PATCH v5 1/1] ring: guarantee load/load order in enqueue and dequeue

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server. In __rte_ring_move_cons_head()
...

        do {
                /* Restore n as it may change every loop */
                n = max;

                *old_head = r->cons.head;                //1st load
                const uint32_t prod_tail = r->prod.tail; //2nd load

cpu1(producer) cpu2(consumer) cpu3(consumer)

                        load r->prod.tail

in enqueue:
load r->cons.tail
load r->prod.head

store r->prod.tail

                                                load r->cons.head
                                                load r->prod.tail
                                                ...
                                                store r->cons.{head,tail}
                        load r->cons.head

In weak memory order architectures(powerpc,arm), the 2nd load might be reodered before the 1st load, that makes *entries is bigger than we wanted. This nasty reording messed enque/deque up. Then, r->cons.head will be bigger than prod_tail, then make *entries very big and the consumer will go forward incorrectly.

After this patch, even with above context switches, the old cons.head will be recaculated after failure of rte_atomic32_cmpset. So no race conditions left.

There is no such issue on X86, because X86 is strong memory order model. But rte_smp_rmb() doesn't have impact on runtime performance on X86, so keep the same code without architectures specific concerns.

Signed-off-by [email protected]
Signed-off-by [email protected]
---
 lib/librte_ring/rte_ring.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/librte_ring/rte_ring.h +5 -0
index 5e9b3b7..3e8085a 100644
@@ -409,6 +409,11 @@ __rte_ring_move_prod_head(struct rte_ring *r, int is_sp,
 		n = max;
 
 		*old_head = r->prod.head;
+
+		/* add rmb barrier to avoid load/load reorder in weak
+		 * memory model. It is noop on x86 */
+		rte_smp_rmb();
+
 		const uint32_t cons_tail = r->cons.tail;
 		/*
 		 *  The subtraction is done between two unsigned 32bits value
@@ -517,6 +522,11 @@ __rte_ring_move_cons_head(struct rte_ring *r, int is_sc,
 		n = max;
 

lib/librte_ring/rte_ring.h __rte_ring_move_cons_head(struct rte_ring *r, int is_sc,

Quoted 10 lines
lib/librte_ring/rte_ring.h +5 -1
 		*old_head = r->cons.head;
+
+		/* add rmb barrier to avoid load/load reorder in weak
+		 * memory model. It is noop on x86 */
+		rte_smp_rmb();
+
 		const uint32_t prod_tail = r->prod.tail;
 		/* The subtraction is done between two unsigned 32bits value
 		 * (the result is always modulo 32 bits even if we have
--
Quoted 1 line

2.7.4

author
#17 lore raw

PATCH v6 1/1 guarantee load/load order in enqueue and dequeue

In reply to Jia He

From: Jia He <[email protected]>

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server (Amberwing) due to a possible race condition. To fix this race condition, rmb() is needed to add between the 2 loads.

Already fuctionally tested on the machines as follows:
- on X86
- on arm64

---
Changelog
V6: improve the text description and fix the checkpatch warnings
V5: split it into 2 patchset due to the milestone concerns, this is the 1st one
V4: split into small patches
V3: arch specific implementation for enqueue/dequeue barrier
V2: let users choose whether using load_acquire/store_release
V1: rte_smp_rmb() between 2 loads

Jia He (1):
ring: guarantee load/load order in enqueue and dequeue

 lib/librte_ring/rte_ring.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Signature · 1 line
2.7.4
author
#18 lore raw

PATCH v6 1/1 ring: guarantee load/load order in enqueue and dequeue

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server (Amberwing).

Root cause:
In __rte_ring_move_cons_head()
...

        do {
                /* Restore n as it may change every loop */
                n = max;

                *old_head = r->cons.head;                //1st load
                const uint32_t prod_tail = r->prod.tail; //2nd load

In weak memory order architectures(powerpc,arm), the 2nd load might be reodered before the 1st load, that makes *entries is bigger than we wanted. This nasty reording messed enque/deque up.

cpu1(producer) cpu2(consumer) cpu3(consumer)

                        load r->prod.tail

in enqueue:
load r->cons.tail
load r->prod.head

store r->prod.tail

                                                load r->cons.head
                                                load r->prod.tail
                                                ...
                                                store r->cons.{head,tail}
                        load r->cons.head

Then, r->cons.head will be bigger than prod_tail, then make *entries very big and the consumer will go forward incorrectly.

After this patch, the old cons.head will be recaculated after failure of rte_atomic32_cmpset

There is no such issue on X86, because X86 is strong memory order model. But rte_smp_rmb() doesn't have impact on runtime performance on X86, so keep the same code without architectures specific concerns.

---
 lib/librte_ring/rte_ring.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
lib/librte_ring/rte_ring.h +12 -0
index 5e9b3b7..e924438 100644
@@ -409,6 +409,12 @@ __rte_ring_move_prod_head(struct rte_ring *r, int is_sp,
 		n = max;
 
 		*old_head = r->prod.head;
+
+		/* add rmb barrier to avoid load/load reorder in weak
+		 * memory model. It is noop on x86
+		 */
+		rte_smp_rmb();
+
 		const uint32_t cons_tail = r->cons.tail;
 		/*
 		 *  The subtraction is done between two unsigned 32bits value
@@ -517,6 +523,12 @@ __rte_ring_move_cons_head(struct rte_ring *r, int is_sc,
 		n = max;
 
 		*old_head = r->cons.head;
+
+		/* add rmb barrier to avoid load/load reorder in weak
+		 * memory model. It is noop on x86
+		 */
+		rte_smp_rmb();
+
 		const uint32_t prod_tail = r->prod.tail;
 		/* The subtraction is done between two unsigned 32bits value
 		 * (the result is always modulo 32 bits even if we have
Signature · 1 line
2.7.4
#19 lore raw

Re: [dpdk-stable] [PATCH v6] ring: guarantee load/load order in enqueue and dequeue

10/11/2017 04:30, Jia He:

Quoted 41 lines

We watched a rte panic of mbuf_autotest in our qualcomm arm64 server (Amberwing).

Root cause:
In __rte_ring_move_cons_head()
...

        do {
                /* Restore n as it may change every loop */
                n = max;

                *old_head = r->cons.head;                //1st load
                const uint32_t prod_tail = r->prod.tail; //2nd load

In weak memory order architectures(powerpc,arm), the 2nd load might be reodered before the 1st load, that makes *entries is bigger than we wanted. This nasty reording messed enque/deque up.

cpu1(producer) cpu2(consumer) cpu3(consumer)

                        load r->prod.tail

in enqueue:
load r->cons.tail
load r->prod.head

store r->prod.tail

                                                load r->cons.head
                                                load r->prod.tail
                                                ...
                                                store r->cons.{head,tail}
                        load r->cons.head

Then, r->cons.head will be bigger than prod_tail, then make *entries very big and the consumer will go forward incorrectly.

After this patch, the old cons.head will be recaculated after failure of rte_atomic32_cmpset

There is no such issue on X86, because X86 is strong memory order model. But rte_smp_rmb() doesn't have impact on runtime performance on X86, so keep the same code without architectures specific concerns.

Quoted 6 lines

Applied, thanks

author
#20 lore raw

v5 cover support c11 memory model barrier in librte_ring

In reply to Jia He

From: Jia He <[email protected]>

To support C11 memory model barrier, 2 options are suggested by Jerin:
1. use rte_smp_rmb
2. use load_acquire/store_release CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines.

Already fuctionally tested on the machines as follows:
- on X86
- on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
- on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=n

---
Changelog:
V5: split it into 2 patchset due to the milestone concerns, this is the 2st
one. Also fix checkpatch.pl warnings
V4: split into small patches
V3: arch specific implementation for enqueue/dequeue barrier
V2: let users choose whether using load_acquire/store_release
V1: rte_smp_rmb() between 2 loads

*** BLURB HERE ***

Jia He (3):
eal/arm64: remove the braces {} for dmb() and dsb()
ring: introduce new header file to include common functions
ring: introduce new header file to support C11 memory model

 config/common_armv8a_linuxapp                      |   2 +
 .../common/include/arch/arm/rte_atomic_64.h        |   4 +-
 lib/librte_eventdev/rte_event_ring.h               |   6 +-
 lib/librte_ring/Makefile                           |   4 +-
 lib/librte_ring/rte_ring.h                         | 173 ++----------------
 lib/librte_ring/rte_ring_c11_mem.h                 | 186 ++++++++++++++++++++
 lib/librte_ring/rte_ring_generic.h                 | 195 +++++++++++++++++++++
 7 files changed, 406 insertions(+), 164 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_c11_mem.h
 create mode 100644 lib/librte_ring/rte_ring_generic.h
Signature · 1 line
2.7.4
author
#21 lore raw

PATCH v5 1/3 eal/arm64: remove the braces {} for dmb() and dsb()

for the code as follows:
if (condition)

	rte_smp_rmb();
else
	rte_smp_wmb();

Without this patch, compiler will report this error:
error: 'else' without a previous 'if'

Fixes 84733fd0d75e ("eal/arm64: fix memory barrier definition")
---
 lib/librte_eal/common/include/arch/arm/rte_atomic_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/common/include/arch/arm/rte_atomic_64.h +2 -2
index 0b70d62..71da29c 100644
@@ -43,8 +43,8 @@ extern "C" {
 
 #include "generic/rte_atomic.h"
 
-#define dsb(opt)  { asm volatile("dsb " #opt : : : "memory"); }
-#define dmb(opt)  { asm volatile("dmb " #opt : : : "memory"); }
+#define dsb(opt) asm volatile("dsb " #opt : : : "memory")
+#define dmb(opt) asm volatile("dmb " #opt : : : "memory")
 
 #define rte_mb() dsb(sy)
 
Signature · 1 line
2.7.4
author
#22 lore raw

PATCH v5 2/3 ring: introduce new header file to include common functions

In reply to Jia He

From: Jia He <[email protected]>

move the common part of rte_ring.h into rte_ring_generic.h move the memory barrier part into update_tail() no functional changes here

---
 lib/librte_eventdev/rte_event_ring.h |   6 +-
 lib/librte_ring/Makefile             |   3 +-
 lib/librte_ring/rte_ring.h           | 161 +----------------------------
 lib/librte_ring/rte_ring_generic.h   | 195 +++++++++++++++++++++++++++++++++++
 4 files changed, 203 insertions(+), 162 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_generic.h
lib/librte_eventdev/rte_event_ring.h +2 -4
index ea9b688..3e49458 100644
@@ -126,9 +126,8 @@ rte_event_ring_enqueue_burst(struct rte_event_ring *r,
 		goto end;
 
 	ENQUEUE_PTRS(&r->r, &r[1], prod_head, events, n, struct rte_event);
-	rte_smp_wmb();
 
-	update_tail(&r->r.prod, prod_head, prod_next, 1);
+	update_tail(&r->r.prod, prod_head, prod_next, 1, 1);
 end:
 	if (free_space != NULL)
 		*free_space = free_entries - n;
@@ -168,9 +167,8 @@ rte_event_ring_dequeue_burst(struct rte_event_ring *r,
 		goto end;
 
 	DEQUEUE_PTRS(&r->r, &r[1], cons_head, events, n, struct rte_event);
-	rte_smp_rmb();
 
-	update_tail(&r->r.cons, cons_head, cons_next, 1);
+	update_tail(&r->r.cons, cons_head, cons_next, 1, 0);
 
 end:
 	if (available != NULL)
lib/librte_ring/Makefile +2 -1
index e34d9d9..c959945 100644
@@ -45,6 +45,7 @@ LIBABIVER := 1
 SRCS-$(CONFIG_RTE_LIBRTE_RING) := rte_ring.c
 
 # install includes
-SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h \
+					rte_ring_generic.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_ring/rte_ring.h +4 -157

187 lines not on this page · raw message

lib/librte_ring/rte_ring_generic.h new file +195 -0

195 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#23 lore raw

PATCH v6 3/3 ring: introduce new header file to support C11 memory model

In reply to Jia He

To support C11 memory model barrier, 2 options are suggested by Jerin:
1. use rte_smp_rmb
2. use load_acquire/store_release(refer to [1]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines, refer to [2].

We haven't tested on ppc64. If anyone verifies it, he can add CONFIG_RTE_RING_USE_C11_MEM_MODEL=y to ppc64 config files.

[1] https://github.com/freebsd/freebsd/blob/master/sys/sys/buf_ring.h#L170
[2] http://dpdk.org/ml/archives/dev/2017-October/080861.html

---
 config/common_armv8a_linuxapp      |   2 +
 lib/librte_ring/Makefile           |   3 +-
 lib/librte_ring/rte_ring.h         |  14 ++-
 lib/librte_ring/rte_ring_c11_mem.h | 186 +++++++++++++++++++++++++++++++++++++
 4 files changed, 203 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_c11_mem.h
config/common_armv8a_linuxapp +2 -0
index 6732d1e..5b7b2eb 100644
@@ -49,3 +49,5 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n
 CONFIG_RTE_LIBRTE_AVP_PMD=n
 
 CONFIG_RTE_SCHED_VECTOR=n
+
+CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
lib/librte_ring/Makefile +2 -1
index c959945..a2682e7 100644
@@ -46,6 +46,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_RING) := rte_ring.c
 
 # install includes
 SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h \
-					rte_ring_generic.h
+					rte_ring_generic.h \
+					rte_ring_c11_mem.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_ring/rte_ring.h +13 -1
index 519614c..3343eba 100644
@@ -356,8 +356,20 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);
 	} \
 } while (0)
 
-/* Move common functions to generic file */
+/* Between load and load. there might be cpu reorder in weak model
+ * (powerpc/arm).
+ * There are 2 choices for the users
+ * 1.use rmb() memory barrier
+ * 2.use one-direcion load_acquire/store_release barrier,defined by
+ * CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
+ * It depends on performance test results.
+ * By default, move common functions to rte_ring_generic.h
+ */
+#ifdef RTE_RING_USE_C11_MEM_MODEL
+#include "rte_ring_c11_mem.h"
+#else
 #include "rte_ring_generic.h"
+#endif
 
 /**
  * @internal Enqueue several objects on the ring
lib/librte_ring/rte_ring_c11_mem.h new file +186 -0

186 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#24 lore raw

v6 cover support c11 memory model barrier in librte_ring

In reply to Jia He

To support C11 memory model barrier, 2 options are suggested by Jerin:
1. use rte_smp_rmb
2. use load_acquire/store_release CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines.

Already fuctionally tested on the machines as follows:
- on X86
- on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
- on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=n

---
Changelog:
V6: minor change in subject and log
V5: split it into 2 patchset due to the milestone concerns, this is the 2st
one. Also fix checkpatch.pl warnings
V4: split into small patches
V3: arch specific implementation for enqueue/dequeue barrier
V2: let users choose whether using load_acquire/store_release
V1: rte_smp_rmb() between 2 loads

Jia He (3):
eal/arm64: remove the braces {} for dmb(),dsb()
ring: introduce new header file to include common functions
ring: introduce new header file to support C11 memory model

 config/common_armv8a_linuxapp                      |   2 +
 .../common/include/arch/arm/rte_atomic_64.h        |   4 +-
 lib/librte_eventdev/rte_event_ring.h               |   6 +-
 lib/librte_ring/Makefile                           |   4 +-
 lib/librte_ring/rte_ring.h                         | 173 ++----------------
 lib/librte_ring/rte_ring_generic.h                 | 195 +++++++++++++++++++++
 6 files changed, 220 insertions(+), 164 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_generic.h
Signature · 1 line
2.7.4
author
#25 lore raw

PATCH v6 1/3 eal/arm64: remove the braces {} for dmb() and dsb()

for the code as follows:
if (condition)

	rte_smp_rmb();
else
	rte_smp_wmb();

Without this patch, compiler will report this error:
error: 'else' without a previous 'if'

Fixes 84733fd0d75e ("eal/arm: fix memory barrier definition")
---
 lib/librte_eal/common/include/arch/arm/rte_atomic_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/common/include/arch/arm/rte_atomic_64.h +2 -2
index 0b70d62..71da29c 100644
@@ -43,8 +43,8 @@ extern "C" {
 
 #include "generic/rte_atomic.h"
 
-#define dsb(opt)  { asm volatile("dsb " #opt : : : "memory"); }
-#define dmb(opt)  { asm volatile("dmb " #opt : : : "memory"); }
+#define dsb(opt) asm volatile("dsb " #opt : : : "memory")
+#define dmb(opt) asm volatile("dmb " #opt : : : "memory")
 
 #define rte_mb() dsb(sy)
 
Signature · 1 line
2.7.4
Acked-by on v6 1/3
#26 lore raw

Re: [PATCH V6 1/3] eal/arm64: remove the braces {} for dmb() and dsb()

-----Original Message-----

Quoted 14 lines

Date: Sun, 26 Nov 2017 18:00:22 -0800
From: Jia He <[email protected]>
To: [email protected], [email protected],
[email protected], [email protected]
Cc: [email protected], [email protected], [email protected], Jia
He <[email protected]>, [email protected], Jia He <[email protected]>
Subject: [PATCH V6 1/3] eal/arm64: remove the braces {} for dmb() and dsb()
X-Mailer: git-send-email 2.7.4

for the code as follows:
if (condition)

	rte_smp_rmb();
else
	rte_smp_wmb();
Quoted 6 lines

Without this patch, compiler will report this error:
error: 'else' without a previous 'if'

Fixes 84733fd0d75e ("eal/arm: fix memory barrier definition")

Please fix the below checkpatch errors.

Wrong tag:

Wrong 'Fixes' reference:

Fixes 84733fd0d75e ("eal/arm: fix memory barrier definition")

With above fix:

author
#27 lore raw

PATCH v6 2/3 ring: introduce new header file to include common functions

In reply to Jia He

move the common part of rte_ring.h into rte_ring_generic.h. move the memory barrier part into update_tail().

no functional changes here.

---
 lib/librte_eventdev/rte_event_ring.h |   6 +-
 lib/librte_ring/Makefile             |   3 +-
 lib/librte_ring/rte_ring.h           | 161 +----------------------------
 lib/librte_ring/rte_ring_generic.h   | 195 +++++++++++++++++++++++++++++++++++
 4 files changed, 203 insertions(+), 162 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_generic.h
lib/librte_eventdev/rte_event_ring.h +2 -4
index ea9b688..3e49458 100644
@@ -126,9 +126,8 @@ rte_event_ring_enqueue_burst(struct rte_event_ring *r,
 		goto end;
 
 	ENQUEUE_PTRS(&r->r, &r[1], prod_head, events, n, struct rte_event);
-	rte_smp_wmb();
 
-	update_tail(&r->r.prod, prod_head, prod_next, 1);
+	update_tail(&r->r.prod, prod_head, prod_next, 1, 1);
 end:
 	if (free_space != NULL)
 		*free_space = free_entries - n;
@@ -168,9 +167,8 @@ rte_event_ring_dequeue_burst(struct rte_event_ring *r,
 		goto end;
 
 	DEQUEUE_PTRS(&r->r, &r[1], cons_head, events, n, struct rte_event);
-	rte_smp_rmb();
 
-	update_tail(&r->r.cons, cons_head, cons_next, 1);
+	update_tail(&r->r.cons, cons_head, cons_next, 1, 0);
 
 end:
 	if (available != NULL)
lib/librte_ring/Makefile +2 -1
index e34d9d9..c959945 100644
@@ -45,6 +45,7 @@ LIBABIVER := 1
 SRCS-$(CONFIG_RTE_LIBRTE_RING) := rte_ring.c
 
 # install includes
-SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h \
+					rte_ring_generic.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_ring/rte_ring.h +4 -157

187 lines not on this page · raw message

lib/librte_ring/rte_ring_generic.h new file +195 -0

195 lines not on this page · raw message

Signature · 1 line
2.7.4
Acked-by on v6 2/3
#28 lore raw

Re: [PATCH V6 2/3] ring: introduce new header file to include common functions

-----Original Message-----

Quoted 10 lines

Date: Sun, 26 Nov 2017 18:00:23 -0800
From: Jia He <[email protected]>
To: [email protected], [email protected],
[email protected], [email protected]
Cc: [email protected], [email protected], [email protected], Jia
He <[email protected]>, Jia He <[email protected]>
Subject: [PATCH V6 2/3] ring: introduce new header file to include common
functions
X-Mailer: git-send-email 2.7.4

Quoted 8 lines

move the common part of rte_ring.h into rte_ring_generic.h. move the memory barrier part into update_tail().

no functional changes here.

Wrong tag: complaint from checkpatch.

lib/librte_ring/rte_ring_generic.h line 39

Quoted 10 lines

---
+ */

lib/librte_ring/rte_ring_generic.h new file +8 -0
+
+#ifndef _RTE_RING_GENERIC_H_
+#define _RTE_RING_GENERIC_H_
+
+static __rte_always_inline void
+update_tail(struct rte_ring_headtail *ht, uint32_t old_val, uint32_t new_val,
+		uint32_t single, uint32_t enqueue)
+{

How about making enqueue as const. ie. const uint32_t enqueue ?

lib/librte_ring/rte_ring_generic.h line 43

Quoted 4 lines
lib/librte_ring/rte_ring_generic.h new file +4 -0
+	if (enqueue)
+		rte_smp_wmb();
+	else
+		rte_smp_rmb();

Other than that, it looks good to me.

author
#29 lore raw

PATCH v6 3/3 ring: introduce new header file to support C11 memory model

In reply to Jia He

To support C11 memory model barrier, 2 options are suggested by Jerin:
1. use rte_smp_rmb
2. use load_acquire/store_release(refer to [1]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines, refer to [2].

We haven't tested on ppc64. If anyone verifies it, he can add CONFIG_RTE_RING_USE_C11_MEM_MODEL=y to ppc64 config files.

[1] https://github.com/freebsd/freebsd/blob/master/sys/sys/buf_ring.h#L170
[2] http://dpdk.org/ml/archives/dev/2017-October/080861.html

---
 config/common_armv8a_linuxapp      |   2 +
 lib/librte_ring/Makefile           |   3 +-
 lib/librte_ring/rte_ring.h         |  14 ++-
 lib/librte_ring/rte_ring_c11_mem.h | 186 +++++++++++++++++++++++++++++++++++++
 4 files changed, 203 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_c11_mem.h
config/common_armv8a_linuxapp +2 -0
index 6732d1e..5b7b2eb 100644
@@ -49,3 +49,5 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n
 CONFIG_RTE_LIBRTE_AVP_PMD=n
 
 CONFIG_RTE_SCHED_VECTOR=n
+
+CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
lib/librte_ring/Makefile +2 -1
index c959945..a2682e7 100644
@@ -46,6 +46,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_RING) := rte_ring.c
 
 # install includes
 SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h \
-					rte_ring_generic.h
+					rte_ring_generic.h \
+					rte_ring_c11_mem.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_ring/rte_ring.h +13 -1
index 519614c..3343eba 100644
@@ -356,8 +356,20 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);
 	} \
 } while (0)
 
-/* Move common functions to generic file */
+/* Between load and load. there might be cpu reorder in weak model
+ * (powerpc/arm).
+ * There are 2 choices for the users
+ * 1.use rmb() memory barrier
+ * 2.use one-direcion load_acquire/store_release barrier,defined by
+ * CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
+ * It depends on performance test results.
+ * By default, move common functions to rte_ring_generic.h
+ */
+#ifdef RTE_RING_USE_C11_MEM_MODEL
+#include "rte_ring_c11_mem.h"
+#else
 #include "rte_ring_generic.h"
+#endif
 
 /**
  * @internal Enqueue several objects on the ring
lib/librte_ring/rte_ring_c11_mem.h new file +186 -0

186 lines not on this page · raw message

Signature · 1 line
2.7.4
Acked-by on v6 3/3
#30 lore raw

Re: [PATCH V6 3/3] ring: introduce new header file to support C11 memory model

-----Original Message-----

Quoted 19 lines

Date: Sun, 26 Nov 2017 18:00:24 -0800
From: Jia He <[email protected]>
To: [email protected], [email protected],
[email protected], [email protected]
Cc: [email protected], [email protected], [email protected], Jia
He <[email protected]>, Jia He <[email protected]>
Subject: [PATCH V6 3/3] ring: introduce new header file to support C11
memory model
X-Mailer: git-send-email 2.7.4

To support C11 memory model barrier, 2 options are suggested by Jerin:
1. use rte_smp_rmb
2. use load_acquire/store_release(refer to [1]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines, refer to [2].

Quoted 8 lines

We haven't tested on ppc64. If anyone verifies it, he can add CONFIG_RTE_RING_USE_C11_MEM_MODEL=y to ppc64 config files.

[1] https://github.com/freebsd/freebsd/blob/master/sys/sys/buf_ring.h#L170
[2] http://dpdk.org/ml/archives/dev/2017-October/080861.html

author
#31 lore raw

v7 cover support c11 memory model barrier in librte_ring

In reply to Jia He

To support C11 memory model barrier, 2 options are suggested by Jerin:
1. use rte_smp_rmb
2. use load_acquire/store_release CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines.

Already fuctionally tested on the machines as follows:
- on X86
- on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
- on arm64 with CONFIG_RTE_RING_USE_C11_MEM_MODEL=n

---
Changelog:
V7: fix check-git-log warnings which is suggested by Jerin
V6: minor change in subject and log
V5: split it into 2 patchset due to the milestone concerns, this is the 2st
one. Also fix checkpatch.pl warnings
V4: split into small patches
V3: arch specific implementation for enqueue/dequeue barrier
V2: let users choose whether using load_acquire/store_release
V1: rte_smp_rmb() between 2 loads

Jia He (3):
eal/arm64: remove the braces {} for dmb() and dsb()
ring: introduce new header file to include common functions
ring: introduce new header file to support C11 memory model

 config/common_armv8a_linuxapp                      |   2 +
 .../common/include/arch/arm/rte_atomic_64.h        |   4 +-
 lib/librte_eventdev/rte_event_ring.h               |   6 +-
 lib/librte_ring/Makefile                           |   4 +-
 lib/librte_ring/rte_ring.h                         | 173 ++----------------
 lib/librte_ring/rte_ring_c11_mem.h                 | 186 ++++++++++++++++++++
 lib/librte_ring/rte_ring_generic.h                 | 195 +++++++++++++++++++++
 7 files changed, 406 insertions(+), 164 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_c11_mem.h
 create mode 100644 lib/librte_ring/rte_ring_generic.h
Signature · 1 line
2.7.4
author
#32 lore raw

PATCH v7 1/3 eal/arm64: remove the braces {} for dmb() and dsb()

for the code as follows:
if (condition)

	rte_smp_rmb();
else
	rte_smp_wmb();

Without this patch, compiler will report this error:
error: 'else' without a previous 'if'

Fixes 84733fd0d75e ("eal/arm64: fix memory barrier definition")
---
 lib/librte_eal/common/include/arch/arm/rte_atomic_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/common/include/arch/arm/rte_atomic_64.h +2 -2
index 0b70d62..71da29c 100644
@@ -43,8 +43,8 @@ extern "C" {
 
 #include "generic/rte_atomic.h"
 
-#define dsb(opt)  { asm volatile("dsb " #opt : : : "memory"); }
-#define dmb(opt)  { asm volatile("dmb " #opt : : : "memory"); }
+#define dsb(opt) asm volatile("dsb " #opt : : : "memory")
+#define dmb(opt) asm volatile("dmb " #opt : : : "memory")
 
 #define rte_mb() dsb(sy)
 
Signature · 1 line
2.7.4
author
#33 lore raw

PATCH v7 2/3 ring: introduce new header file to include common functions

In reply to Jia He

move the common part of rte_ring.h into rte_ring_generic.h. move the memory barrier part into update_tail().

no functional changes here.

---
 lib/librte_eventdev/rte_event_ring.h |   6 +-
 lib/librte_ring/Makefile             |   3 +-
 lib/librte_ring/rte_ring.h           | 161 +----------------------------
 lib/librte_ring/rte_ring_generic.h   | 195 +++++++++++++++++++++++++++++++++++
 4 files changed, 203 insertions(+), 162 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_generic.h
lib/librte_eventdev/rte_event_ring.h +2 -4
index ea9b688..3e49458 100644
@@ -126,9 +126,8 @@ rte_event_ring_enqueue_burst(struct rte_event_ring *r,
 		goto end;
 
 	ENQUEUE_PTRS(&r->r, &r[1], prod_head, events, n, struct rte_event);
-	rte_smp_wmb();
 
-	update_tail(&r->r.prod, prod_head, prod_next, 1);
+	update_tail(&r->r.prod, prod_head, prod_next, 1, 1);
 end:
 	if (free_space != NULL)
 		*free_space = free_entries - n;
@@ -168,9 +167,8 @@ rte_event_ring_dequeue_burst(struct rte_event_ring *r,
 		goto end;
 
 	DEQUEUE_PTRS(&r->r, &r[1], cons_head, events, n, struct rte_event);
-	rte_smp_rmb();
 
-	update_tail(&r->r.cons, cons_head, cons_next, 1);
+	update_tail(&r->r.cons, cons_head, cons_next, 1, 0);
 
 end:
 	if (available != NULL)
lib/librte_ring/Makefile +2 -1
index e34d9d9..c959945 100644
@@ -45,6 +45,7 @@ LIBABIVER := 1
 SRCS-$(CONFIG_RTE_LIBRTE_RING) := rte_ring.c
 
 # install includes
-SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h \
+					rte_ring_generic.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_ring/rte_ring.h +4 -157

187 lines not on this page · raw message

lib/librte_ring/rte_ring_generic.h new file +195 -0

195 lines not on this page · raw message

Signature · 1 line
2.7.4
#34 lore raw

Re: [PATCH V7 2/3] ring: introduce new header file to include common functions

04/12/2017 02:50, Jia He:

Quoted 4 lines

move the common part of rte_ring.h into rte_ring_generic.h. move the memory barrier part into update_tail().

no functional changes here.

[...]

lib/librte_ring/rte_ring_generic.h line 4

Quoted 7 lines
lib/librte_ring/rte_ring_generic.h new file +4 -0
@@ -0,0 +1,195 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 hxt-semitech. All rights reserved.

As you are moving existing code, I think you should keep the original copyright.

author
#35 lore raw

Re: [PATCH V7 2/3] ring: introduce new header file to include common functions

On 1/13/2018 1:09 AM, Thomas Monjalon Wrote:

Quoted 6 lines

04/12/2017 02:50, Jia He:

Quoted 4 lines

move the common part of rte_ring.h into rte_ring_generic.h. move the memory barrier part into update_tail().

no functional changes here.

[...]

Quoted 9 lines

lib/librte_ring/rte_ring_generic.h line 4

Quoted 7 lines
lib/librte_ring/rte_ring_generic.h new file +4 -0
@@ -0,0 +1,195 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 hxt-semitech. All rights reserved.

As you are moving existing code, I think you should keep the original copyright.

Ok, thanks for the comments

Signature · 2 lines
Cheers,
Jia
Acked-by on v7 2/3
#36 lore raw

Re: [PATCH V7 2/3] ring: introduce new header file to include common functions

In reply to Jia He
Quoted 9 lines · Jia He

move the common part of rte_ring.h into rte_ring_generic.h. move the memory barrier part into update_tail().

no functional changes here.

author
#37 lore raw

PATCH v7 3/3 ring: introduce new header file to support C11 memory model

In reply to Jia He

To support C11 memory model barrier, 2 options are suggested by Jerin:
1. use rte_smp_rmb
2. use load_acquire/store_release(refer to [1]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines, refer to [2].

We haven't tested on ppc64. If anyone verifies it, he can add CONFIG_RTE_RING_USE_C11_MEM_MODEL=y to ppc64 config files.

[1] https://github.com/freebsd/freebsd/blob/master/sys/sys/buf_ring.h#L170
[2] http://dpdk.org/ml/archives/dev/2017-October/080861.html

---
 config/common_armv8a_linuxapp      |   2 +
 lib/librte_ring/Makefile           |   3 +-
 lib/librte_ring/rte_ring.h         |  14 ++-
 lib/librte_ring/rte_ring_c11_mem.h | 186 +++++++++++++++++++++++++++++++++++++
 4 files changed, 203 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_c11_mem.h
config/common_armv8a_linuxapp +2 -0
index 6732d1e..5b7b2eb 100644
@@ -49,3 +49,5 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n
 CONFIG_RTE_LIBRTE_AVP_PMD=n
 
 CONFIG_RTE_SCHED_VECTOR=n
+
+CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
lib/librte_ring/Makefile +2 -1
index c959945..a2682e7 100644
@@ -46,6 +46,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_RING) := rte_ring.c
 
 # install includes
 SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h \
-					rte_ring_generic.h
+					rte_ring_generic.h \
+					rte_ring_c11_mem.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_ring/rte_ring.h +13 -1
index 519614c..3343eba 100644
@@ -356,8 +356,20 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);
 	} \
 } while (0)
 
-/* Move common functions to generic file */
+/* Between load and load. there might be cpu reorder in weak model
+ * (powerpc/arm).
+ * There are 2 choices for the users
+ * 1.use rmb() memory barrier
+ * 2.use one-direcion load_acquire/store_release barrier,defined by
+ * CONFIG_RTE_RING_USE_C11_MEM_MODEL=y
+ * It depends on performance test results.
+ * By default, move common functions to rte_ring_generic.h
+ */
+#ifdef RTE_RING_USE_C11_MEM_MODEL
+#include "rte_ring_c11_mem.h"
+#else
 #include "rte_ring_generic.h"
+#endif
 
 /**
  * @internal Enqueue several objects on the ring
lib/librte_ring/rte_ring_c11_mem.h new file +186 -0

186 lines not on this page · raw message

Signature · 1 line
2.7.4
Acked-by on v7 3/3
#38 lore raw

Re: [PATCH V7 3/3] ring: introduce new header file to support C11 memory model

Quoted 12 lines · Jia He

To support C11 memory model barrier, 2 options are suggested by Jerin:
1. use rte_smp_rmb
2. use load_acquire/store_release(refer to [1]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines, refer to [2].

We haven't tested on ppc64. If anyone verifies it, he can add CONFIG_RTE_RING_USE_C11_MEM_MODEL=y to ppc64 config files.

Quoted 6 lines

[1] https://github.com/freebsd/freebsd/blob/master/sys/sys/buf_ring.h#L170
[2] http://dpdk.org/ml/archives/dev/2017-October/080861.html

Quoted 8 lines
---
 config/common_armv8a_linuxapp      |   2 +
 lib/librte_ring/Makefile           |   3 +-
 lib/librte_ring/rte_ring.h         |  14 ++-
 lib/librte_ring/rte_ring_c11_mem.h | 186 +++++++++++++++++++++++++++++++++++++
 4 files changed, 203 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_ring/rte_ring_c11_mem.h

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

#39 lore raw

Re: [PATCH V7 3/3] ring: introduce new header file to support C11 memory model

In reply to Jia He

Hi,
Please find few comments.
Sorry for the late review.
We need also to get the acknowledgement from Olivier.

04/12/2017 02:50, Jia He:

config/common_armv8a_linuxapp CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n · line 53

Quoted 8 lines
config/common_armv8a_linuxapp +2 -0
@@ -49,3 +49,5 @@ CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n
 CONFIG_RTE_LIBRTE_AVP_PMD=n
 
 CONFIG_RTE_SCHED_VECTOR=n
+
+CONFIG_RTE_RING_USE_C11_MEM_MODEL=y

This config option should be added in the common file (as disabled).

Quoted 24 lines
lib/librte_ring/rte_ring_c11_mem.h new file +21 -0
@@ -0,0 +1,186 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 hxt-semitech. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of hxt-semitech nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

lib/librte_ring/rte_ring_c11_mem.h line 31

Quoted 10 lines
lib/librte_ring/rte_ring_c11_mem.h new file +10 -0
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */

If you have to spin a v8, please use SPDX tag for the license.

Acked-by on v7 3/3
#40 lore raw

Re: [PATCH V7 3/3] ring: introduce new header file to support C11 memory model

In reply to Jia He
Quoted 12 lines · Jia He

To support C11 memory model barrier, 2 options are suggested by Jerin:
1. use rte_smp_rmb
2. use load_acquire/store_release(refer to [1]). CONFIG_RTE_RING_USE_C11_MEM_MODEL is provided, and by default it is "y" only on arm64 so far.

The reason why providing 2 options is due to the performance benchmark difference in different arm machines, refer to [2].

We haven't tested on ppc64. If anyone verifies it, he can add CONFIG_RTE_RING_USE_C11_MEM_MODEL=y to ppc64 config files.

Quoted 6 lines

[1] https://github.com/freebsd/freebsd/blob/master/sys/sys/buf_ring.h#L170
[2] http://dpdk.org/ml/archives/dev/2017-October/080861.html