numam-dpdk/lib/librte_ring
Gavin Hu 85cffb2ecc ring: enforce reading tail before slots
In weak memory models, like arm64, reading the prod.tail may get
reordered after reading the ring slots, which corrupts the ring and
stale data is observed.

This issue was reported by NXP on 8-A72 DPAA2 board. The problem is most
likely caused by missing the acquire semantics when reading
prod.tail (in SC dequeue) which makes it possible to read a
stale value from the ring slots.

For MP (and MC) case, rte_atomic32_cmpset() already provides the required
ordering. For SP case, the control depependency between if-statement (which
depends on the read of r->cons.tail) and the later stores to the ring slots
make RMB unnecessary. About the control dependency, read more at:
https://www.cl.cam.ac.uk/~pes20/ppc-supplemental/test7.pdf

This patch is adding the required read barrier to prevent reading the ring
slots get reordered before reading prod.tail for SC case.

Fixes: c9fb3c6289 ("ring: move code in a new header file")
Cc: stable@dpdk.org

Signed-off-by: Gavin Hu <gavin.hu@arm.com>
Reviewed-by: Ola Liljedahl <ola.liljedahl@arm.com>
Tested-by: Nipun Gupta <nipun.gupta@nxp.com>
Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
2019-03-28 01:22:04 +01:00
..
Makefile ring: relax alignment constraint on ring structure 2018-04-18 00:24:22 +02:00
meson.build ring: add library version to meson build 2018-10-25 14:30:05 +02:00
rte_ring_c11_mem.h ring/c11: relax ordering for load and store of the head 2018-11-13 17:00:58 +01:00
rte_ring_generic.h ring: enforce reading tail before slots 2019-03-28 01:22:04 +01:00
rte_ring_version.map lib: remove unused map symbols 2018-02-13 14:55:01 +01:00
rte_ring.c ring: convert license headers to SPDX tags 2018-02-01 01:46:45 +01:00
rte_ring.h config: rename option for C11 memory model 2018-10-26 18:09:22 +02:00