[dpdk-dev] [memnic PATCH v2] pmd: fix race condition

Olivier MATZ olivier.matz at 6wind.com
Fri Apr 11 16:41:42 CEST 2014


On Thursday, April 03, 2014 06:35:06 AM Hiroshi Shimamoto wrote:
> From: Hiroshi Shimamoto <h-shimamoto at ct.jp.nec.com>
> 
> There is a race condition, on transmit to host.
> 
> Guest PMD                 Host
> Thread-A     Thread-B     vSwitch
> 
>    |idx=0       |idx=0       |p[0] st!=2
>    |cmpxchg     |            |
>    |p[0] st->1  |            |
>    |idx=1       |            |
>    |fill data   |            |
>    |p[0] st->2  |            |p[0] st==2
>    |
>    |            |            |receive data
>    |            |            |p[0] st->0
>    |            |
>    |            |cmpxchg     |
>    |            |success     |p[1] st!=2
>    |            |p[0] st->1  |
> 
>                   This is BAD
> 
> That causes traffic stop.
> 
> We have to take care about that race condition with checking
> whether current index is correct.
> 
> Signed-off-by: Hiroshi Shimamoto <h-shimamoto at ct.jp.nec.com>
> Reviewed-by: Hayato Momma <h-momma at ce.jp.nec.com>
> ---
>  pmd/pmd_memnic.c | 9 +++++++++
>  1 file changed, 9 insertions(+)

Reviewed-by: Olivier Matz <olivier.matz at 6wind.com>



More information about the dev mailing list