All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Wu, Xiaoban" <Xiaoban_Wu@student.uml.edu>
Cc: "users@dpdk.org" <users@dpdk.org>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: A question about the possible race condition in the l3fwd example?
Date: Mon, 27 Nov 2017 20:06:13 -0800	[thread overview]
Message-ID: <20171127200613.74783eff@xeon-e3> (raw)
In-Reply-To: <BN6PR02MB2689B9C9FB7D64F582186747BC3A0@BN6PR02MB2689.namprd02.prod.outlook.com>

On Tue, 28 Nov 2017 02:22:57 +0000
"Wu, Xiaoban" <Xiaoban_Wu@student.uml.edu> wrote:

> Dear All,
> 
> 
> I am studying the source code of the l3fwd example. I am confused about a possible race condition in the l3fwd_lpm_simple_forward().
> 
> 
> In this function it calls send_single_packet(), which executes the following code,
> 
>     len = qconf->tx_mbufs[port].len;
>     qconf->tx_mbufs[port].m_table[len] = m;
>     len++;
> 
> As you can see, if two threads are trying to call send_single_packet() at the same time and send  different packets to the same port, which writes the value to the same array and updates the same counter 'len', then the race condition happens, so we might lose packets.
> 
> Can anybody please clarify if this indeed brings race condition? If yes, then why we want to design it in this way, just for high performance? If no, why?
> 
> Thanks very much for your help.
> 
> Best wishes,
> Xiaoban
> 
> 
> 

qconf is in in a per core data structure, so it is impossible for sharing to happen.

  reply	other threads:[~2017-11-28  4:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-28  2:22 A question about the possible race condition in the l3fwd example? Wu, Xiaoban
2017-11-28  4:06 ` Stephen Hemminger [this message]
2017-11-28  4:39   ` Wu, Xiaoban

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=20171127200613.74783eff@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=Xiaoban_Wu@student.uml.edu \
    --cc=dev@dpdk.org \
    --cc=users@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 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.