[dpdk-dev] Deadlock in rte_mempool using multi-process shared memory

陆秋文 luqiuwen at gmail.com
Tue Jan 3 08:10:47 CET 2017


I have some process running in DPDK which uses DPDK multi-process feature
to communicate. Master process captures packets from NIC and put them to a
ring buffer, which is shared between master and slave process. Sometimes,
slave process use rte_pktmbuf_alloc() to alloc pktmbuf from the shared
mempool, and send to master process by a ring buffer.

However, when slave process exit by accident(recv a SIGTERM signal),  the
thread in slave process which using the shared mempool(such as calling
rte_pktmbuf_alloc()) may cause wrong state in a few cases, and other thread
use the mempool may fall into deadlock. like this:

static inline int __attribute__((always_inline))
__rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,
unsigned n, enum rte_ring_queue_behavior behavior)


* If there are other dequeues in progress that preceded us,
* we need to wait for them to complete
while (unlikely(r->cons.tail != cons_head)) {           ============  this
condition cannot be satisfied forever.
rte_pause();                                                ============
 thread may spin at this line.

/* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting
* for other thread finish. It gives pre-empted thread a chance
* to proceed and finish with ring dequeue operation. */
rep = 0;
__RING_STAT_ADD(r, deq_success, n);
r->cons.tail = cons_next;

I tried to enable RTE_RING_PAUSE_REP_COUNT, but it has no effect.

What I can do? Thanks a lot!


More information about the dev mailing list