DPDK patches and discussions
 help / color / mirror / Atom feed
From: Lazaros Koromilas <l@nofutznetworks.com>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: Olivier MATZ <olivier.matz@6wind.com>,
	dev@dpdk.org,  Thomas Monjalon <thomas.monjalon@6wind.com>
Subject: Re: [dpdk-dev] [PATCH v2] ring: check for zero objects mc dequeue / mp enqueue
Date: Tue, 29 Mar 2016 20:35:29 +0300	[thread overview]
Message-ID: <CAHPNE8gCsqWXyJ5Xmn4b43KxonH8yMrYbjOpysM7hbj_b9sSjg@mail.gmail.com> (raw)
In-Reply-To: <20160329160442.GB15912@bricha3-MOBL3>

On Tue, Mar 29, 2016 at 7:04 PM, Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> On Tue, Mar 29, 2016 at 05:29:12PM +0200, Olivier MATZ wrote:
> > Hi,
> >
> >
> > On 03/29/2016 10:54 AM, Bruce Richardson wrote:
> > >On Mon, Mar 28, 2016 at 06:48:07PM +0300, Lazaros Koromilas wrote:
> > >>Hi Olivier,
> > >>
> > >>We could have two threads (running on different cores in the general
> > >>case) that both succeed the cmpset operation. In the dequeue path,
> > >>when n == 0, then cons_next == cons_head, and cmpset will always
> > >>succeed. Now, if they both see an old r->cons.tail value from a
> > >>previous dequeue, they can get stuck in the while
> > >
> > >Hi,
> > >
> > >I don't see how threads reading an "old r->cons.tail" value is even possible.
> > >The head and tail pointers on the ring are marked in the code as volatile, so
> > >all reads and writes to those values are always done from memory and not cached
> > >in registers. No deadlock should be possible on that while loop, unless a
> > >process crashes in the middle of a ring operation. Each thread which updates
> > >the head pointer from x to y, is responsible for updating the tail pointer in
> > >a similar manner. The loop ensures the tail updates are in the same order as the
> > >head updates.
> > >
> > >If you believe deadlock is possible, can you outline the sequence of operations
> > >which would lead to such a state, because I cannot see how it could occur without
> > >a crash inside one of the threads.
> >
> > I think the deadlock Lazaros describes could occur in the following
> > condition:
> >
> > current ring state
> >  r->prod.head = 0
> >  r->prod.tail = 0
> >
> > core 0                               core 1
> > ====================================================================
> > enqueue 0 object
> >  cmpset(&r->prod.head, 0, 0)
> >  core 0 is interrupted here
> >                                      enqueue 1 object
> >                                       cmpset(&r->prod.head, 0, 1)
> >                                       copy the objects in box 0
> >                                       while (r->prod.tail != prod_head))
> >                                       r->prod.tail = prod_next
> >  copy 0 object (-> nothing to do)
> >  while (r->prod.tail != prod_head))
> >     <loop forever>
> >
> >
> > I think this issue is indeed fixed by Lazaros' patch (I missed it
> > in previous review). However, I don't think this deadlock could
> > happen once we avoided the (n == 0) case.
> >
> Yes, I agree with your scenario. However, I thought the issue was occuring with
> non-zero updates, but I may well be mistaken.
> If it's fixed now, all good... :-)
>
> /Bruce

Hi all,

Bruce, I thought it could be still possible because of my threads
being stuck inside two dequeue(32) calls.  But haven't been able to
reproduce it with non-zero dequeues.  And by trying to find a scenario
of my own, it seems that at least one dequeue(0) is needed, similarly
to Olivier's example on the enqueue path.

Thanks,
Lazaros.

      reply	other threads:[~2016-03-29 17:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17 15:49 Lazaros Koromilas
2016-03-17 16:09 ` Mauricio Vásquez
2016-03-18 10:18   ` Bruce Richardson
2016-03-18 10:27     ` Olivier Matz
2016-03-18 10:35       ` Bruce Richardson
2016-03-18 10:35       ` Thomas Monjalon
2016-03-18 12:47         ` Mauricio Vásquez
2016-03-18 14:16           ` Bruce Richardson
2016-03-21 17:47             ` Xie, Huawei
2016-03-22 10:13               ` Bruce Richardson
2016-03-22 14:38                 ` Xie, Huawei
2016-03-21 12:23 ` Olivier Matz
2016-03-22 16:49   ` Thomas Monjalon
2016-03-25 11:15 ` Olivier Matz
2016-03-28 15:48   ` Lazaros Koromilas
2016-03-29  8:54     ` Bruce Richardson
2016-03-29 15:29       ` Olivier MATZ
2016-03-29 16:04         ` Bruce Richardson
2016-03-29 17:35           ` Lazaros Koromilas [this message]

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=CAHPNE8gCsqWXyJ5Xmn4b43KxonH8yMrYbjOpysM7hbj_b9sSjg@mail.gmail.com \
    --to=l@nofutznetworks.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    --cc=thomas.monjalon@6wind.com \
    /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).