All of lore.kernel.org
 help / color / mirror / Atom feed
* A question about the possible race condition in the l3fwd example?
@ 2017-11-28  2:22 Wu, Xiaoban
  2017-11-28  4:06 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Wu, Xiaoban @ 2017-11-28  2:22 UTC (permalink / raw)
  To: users, dev

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A question about the possible race condition in the l3fwd example?
  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
  2017-11-28  4:39   ` Wu, Xiaoban
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2017-11-28  4:06 UTC (permalink / raw)
  To: Wu, Xiaoban; +Cc: users, dev

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A question about the possible race condition in the l3fwd example?
  2017-11-28  4:06 ` Stephen Hemminger
@ 2017-11-28  4:39   ` Wu, Xiaoban
  0 siblings, 0 replies; 3+ messages in thread
From: Wu, Xiaoban @ 2017-11-28  4:39 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: users, dev

Dear Stephen,


Yes, you are right. Thanks very much for your help, very appreciated. It is much more clear to me now.


extern struct lcore_conf lcore_conf[RTE_MAX_LCORE];


Best wishes,

Xiaoban

________________________________
From: Stephen Hemminger <stephen@networkplumber.org>
Sent: Monday, November 27, 2017 11:06:13 PM
To: Wu, Xiaoban
Cc: users@dpdk.org; dev@dpdk.org
Subject: Re: [dpdk-dev] A question about the possible race condition in the l3fwd example?

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-28  4:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2017-11-28  4:39   ` Wu, Xiaoban

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.