ring: guarantee load/load order in enqueue and dequeue
[dpdk.git] / lib / librte_ring / rte_ring.h
index 5e9b3b7..e924438 100644 (file)
@@ -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