DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Bob Chen" <beef9999@qq.com>
To: dev <dev@dpdk.org>
Subject: [dpdk-dev] A question of DPDK ring buffer
Date: Tue, 20 Aug 2013 12:37:04 +0800	[thread overview]
Message-ID: <tencent_44D597E64569F4DC48205129@qq.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1882 bytes --]

Hi folks,


Is there anyone who has researched the mechanism of DPDK ring buffer by any chance? I was trying to understand the multi-producer and muti-consumer scenario, the CAS(compare and swap) operation is not an obstacle to me, and from what I can tell, the method which DPDK adopts is basically lock-free, not wait-free.


What troubles me is the last wait operation when each core has fulfilled its enqueued objects and then stop there waiting the public structure prod_tail to match its private per core structure prod_head. Only if public prod_tail equals to its private prod_head, it will increase the public prod_tail to private prod_next. See below, from DPDK programmer guide.



	/*
	 * If there are other enqueues in progress that preceeded us,
	 * we need to wait for them to complete
	 */
	while (unlikely(r->prod.tail != prod_head))
		rte_pause();



The final position of public prod_tail is the same to public prod_head. That means they have reached to the initial state.



OK, here is the question: Why DPDK has to maintain that public prod_tail structure? Is it really necessary to endure a while loop here? I think in a circumstance of heavy workload, it might be very likely that a core enqueues its own data in advance, however, it needs to wait the others to finish enqueueing even though it already has nothing to do at that time. It seems to me that even if we remove the public prod_tail structure, the enqueue operation is still able to work. Because each core has known the exact enqueue position from its private prod_head and prod_next. In another word, we just need to assure the correctness of per core pointer and leave the rest of the enqueue work to that particular core. Those per core pointers they never overlap according to the CAS atomic operation, that is our assumption.


What do you reckon?


Regards,
Bob

[-- Attachment #1.2: Type: text/html, Size: 2992 bytes --]

[-- Attachment #2: D8D96AE0@BC70CD7F.70F21252.96F01252 --]
[-- Type: application/octet-stream, Size: 11844 bytes --]

[-- Attachment #3: D8E46A1B@BC70CD7F.70F21252.96F01252 --]
[-- Type: application/octet-stream, Size: 46451 bytes --]

             reply	other threads:[~2013-08-20  4:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-20  4:37 Bob Chen [this message]
2013-08-24 14:34 ` Beef
2013-08-20  4:38 Bob Chen
2013-08-20  8:22 ` Olivier MATZ
2013-08-20  9:13   ` Chen, Bo D
2013-08-21  8:31     ` Olivier MATZ

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=tencent_44D597E64569F4DC48205129@qq.com \
    --to=beef9999@qq.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).