DPDK patches and discussions
 help / color / mirror / Atom feed
From: 陆秋文 <luqiuwen@gmail.com>
To: dev@dpdk.org
Subject: [dpdk-dev] Deadlock in rte_mempool using multi-process shared memory
Date: Tue, 3 Jan 2017 15:10:47 +0800	[thread overview]
Message-ID: <CAH1gxTu=k8qXUU0AmOW6SCv3j6X4G3O+_byXVRkbnRRCerhOiw@mail.gmail.com> (raw)

Hi,

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. */
if (RTE_RING_PAUSE_REP_COUNT &&
   ++rep == RTE_RING_PAUSE_REP_COUNT) {
rep = 0;
sched_yield();
}
}
__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!

Qiuwen
2017/1/3

                 reply	other threads:[~2017-01-03  7:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH1gxTu=k8qXUU0AmOW6SCv3j6X4G3O+_byXVRkbnRRCerhOiw@mail.gmail.com' \
    --to=luqiuwen@gmail.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).