numam-dpdk/lib
Jia He 9bc2cbb007 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.

Fixes: 50d7690548 ("ring: add burst API")
Cc: stable@dpdk.org

Signed-off-by: Jia He <jia.he@hxt-semitech.com>
Signed-off-by: Jie Liu <jie2.liu@hxt-semitech.com>
Signed-off-by: Bing Zhao <bing.zhao@hxt-semitech.com>
Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Acked-by: Jianbo Liu <jianbo.liu@arm.com>
2017-11-12 18:59:14 +01:00
..
librte_acl remove useless memzone includes 2017-11-06 22:12:08 +01:00
librte_bitratestats mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_cfgfile cfgfile: fix leak on creation error 2017-11-07 02:18:42 +01:00
librte_cmdline mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_compat fix typos using codespell utility 2017-06-14 23:54:13 +02:00
librte_cryptodev cryptodev: remove vdev create function 2017-11-07 16:28:47 +01:00
librte_distributor distributor: fix some typos 2017-11-07 01:50:48 +01:00
librte_eal eal: fix an include guard comment 2017-11-11 15:54:16 +01:00
librte_efd eal/x86: revert select optimized memcpy at run-time 2017-11-07 01:16:03 +01:00
librte_ether bus/vdev: move code from EAL into a new driver 2017-11-07 16:54:07 +01:00
librte_eventdev bus/vdev: move code from EAL into a new driver 2017-11-07 16:54:07 +01:00
librte_flow_classify flow_classify: fix logging 2017-10-27 00:13:51 +02:00
librte_gro mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_gso mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_hash remove useless memzone includes 2017-11-06 22:12:08 +01:00
librte_ip_frag mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_jobstats mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_kni lib: fix some typos 2017-11-07 01:46:22 +01:00
librte_kvargs mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_latencystats mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_lpm remove useless memzone includes 2017-11-06 22:12:08 +01:00
librte_mbuf mbuf: rename data address helpers to IOVA 2017-11-06 22:44:26 +01:00
librte_member remove useless memzone includes 2017-11-06 22:12:08 +01:00
librte_mempool mempool: increase ABI version 2017-11-06 23:59:19 +01:00
librte_meter mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_metrics mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_net use macro to declare constructor functions 2017-11-06 21:56:07 +01:00
librte_pci remove useless memzone includes 2017-11-06 22:12:08 +01:00
librte_pdump pdump: fix possible mbuf leak on failure 2017-11-12 04:15:54 +01:00
librte_pipeline remove useless memzone includes 2017-11-06 22:12:08 +01:00
librte_port mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_power mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_reorder remove useless memzone includes 2017-11-06 22:12:08 +01:00
librte_ring ring: guarantee load/load order in enqueue and dequeue 2017-11-12 18:59:14 +01:00
librte_sched mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_security security: fix anonymous unions in structure definitions 2017-11-10 02:53:05 +01:00
librte_table table: fix LRU hash table parameters check 2017-11-07 02:00:01 +01:00
librte_timer remove useless memzone includes 2017-11-06 22:12:08 +01:00
librte_vhost vhost: add flag to enable IOMMU support 2017-11-07 14:19:11 +01:00
Makefile pci: introduce library and driver 2017-10-26 23:17:31 +02:00