From: Olivier MATZ <olivier.matz@6wind.com>
To: "Chen, Bo D" <bo.d.chen@intel.com>
Cc: dev <dev@dpdk.org>
Subject: Re: [dpdk-dev] A question of DPDK ring buffer
Date: Wed, 21 Aug 2013 10:31:29 +0200 [thread overview]
Message-ID: <52147AE1.4030000@6wind.com> (raw)
In-Reply-To: <D2837EF4E9C3744B938BFA76D82FC9AB01E0987F@SHSMSX102.ccr.corp.intel.com>
Hi Bob,
> do {
> prod_head = r->prod.head;
> cons_tail = r->cons.tail;
> prod_next = prod_head + n;
> success = rte_atomic32_cmpset(&r->prod.head, prod_head, prod_next);
>
> /*
> * Why not enqueue data here? It would be just a couple of pointers assignment, not taking too much time.
> * Then the entire CAS loop contains both pointer adjustment and data enqueue, and the dequeue operation would not have a chance to interfere data producing.
> * The next wait loop can be removed accordingly.
> /*
You cannot enqueue your data here: before writing the objects, you must
first check that the cmpset is succesful. In your example, if the cmpset
fails, it would write the objects pointer in a zone already reserved
by another producer core.
The writing of objects must be done after the "do - while" loop, once
cmpset is succesful. But even with that, you cannot remove the wait
loop (r->prod.tail != prod_head) for the reasons described in my
previous mail.
The ring test in app/test/test_ring.c is quite stressful for the rings
so you can use it to check that your solution is working.
Regards,
Olivier
next prev parent reply other threads:[~2013-08-21 8:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-08-20 4:37 Bob Chen
2013-08-24 14:34 ` Beef
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=52147AE1.4030000@6wind.com \
--to=olivier.matz@6wind.com \
--cc=bo.d.chen@intel.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).