[ovs-dev] [PATCH] dpif-netdev: Avoid side-effect in argument of atomic_store_relaxed().

Ben Pfaff blp at ovn.org
Sun Sep 10 17:46:00 UTC 2017


Thanks Alin and Darrell, I applied this to master.  I don't think it
needs any backports.

On Wed, Sep 06, 2017 at 10:41:25PM +0300, aserdean at ovn.org wrote:
> Thanks a lot for fixing this!
> 
> Acked-by: Alin Serdean <aserdean at ovn.org>
> 
> > -----Original Message-----
> > From: ovs-dev-bounces at openvswitch.org [mailto:ovs-dev-
> > bounces at openvswitch.org] On Behalf Of Ben Pfaff
> > Sent: Wednesday, September 6, 2017 6:58 PM
> > To: dev at openvswitch.org
> > Cc: Ben Pfaff <blp at ovn.org>; Alin Serdean <aserdean at ovn.org>
> > Subject: [ovs-dev] [PATCH] dpif-netdev: Avoid side-effect in argument of
> > atomic_store_relaxed().
> > 
> > Some of the implementations of atomic_store_relaxed() evaluate their first
> > argument more than once, so arguments with side effects cause strange
> > behavior.  This fixes a problem observed on 64-bit Windows.
> > 
> > Reported-by: Alin Serdean <aserdean at ovn.org>
> > Signed-off-by: Ben Pfaff <blp at ovn.org>
> > ---
> >  lib/dpif-netdev.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index
> > 071ec141f1d1..0ceef9d82914 100644
> > --- a/lib/dpif-netdev.c
> > +++ b/lib/dpif-netdev.c
> > @@ -3201,8 +3201,8 @@ static void
> >  dp_netdev_rxq_set_intrvl_cycles(struct dp_netdev_rxq *rx,
> >                                  unsigned long long cycles)  {
> > -   atomic_store_relaxed(&rx->cycles_intrvl[rx->intrvl_idx++
> > -                                           % PMD_RXQ_INTERVAL_MAX],
> cycles);
> > +    unsigned int idx = rx->intrvl_idx++ % PMD_RXQ_INTERVAL_MAX;
> > +    atomic_store_relaxed(&rx->cycles_intrvl[idx], cycles);
> >  }
> > 
> >  static uint64_t
> > --
> > 2.10.2
> > 
> > _______________________________________________
> > dev mailing list
> > dev at openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> 


More information about the dev mailing list