From: Olivier MATZ <olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: "Chen, Bo D" <bo.d.chen-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: dev <dev-VfR2kkLFssw@public.gmane.org>
Subject: Re: 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-0J0gbvR4kTiiAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org>
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 A question of DPDK ring buffer Bob Chen
[not found] ` <tencent_2D9492351C7651E246BF3AA2-9uewiaClKEY@public.gmane.org>
2013-08-20 8:22 ` Olivier MATZ
[not found] ` <5213272C.4060101-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-08-20 9:13 ` Chen, Bo D
[not found] ` <D2837EF4E9C3744B938BFA76D82FC9AB01E0987F-0J0gbvR4kTiiAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org>
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
[not found] ` <tencent_44D597E64569F4DC48205129-9uewiaClKEY@public.gmane.org>
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-pdr9zngts4eavxtiumwx3w@public.gmane.org \
--cc=bo.d.chen-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=dev-VfR2kkLFssw@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.