netdev
[Top] [All Lists]

Re: [NET] Fix neighbour tbl->entries race

To: "YOSHIFUJI Hideaki / ?$B5HF#1QL@" <yoshfuji@xxxxxxxxxxxxxx>
Subject: Re: [NET] Fix neighbour tbl->entries race
From: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 3 Nov 2004 12:25:20 +1100
Cc: hadi@xxxxxxxxxx, davem@xxxxxxxxxxxxx, netdev@xxxxxxxxxxx
In-reply-to: <20041103.101403.118617263.yoshfuji@xxxxxxxxxxxxxx>
References: <1099404823.1021.15.camel@xxxxxxxxxxxxxxxx> <20041102203720.GA12108@xxxxxxxxxxxxxxxxxxx> <20041102210259.GA12642@xxxxxxxxxxxxxxxxxxx> <20041103.101403.118617263.yoshfuji@xxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.5.6+20040722i
On Wed, Nov 03, 2004 at 10:14:03AM +0900, YOSHIFUJI Hideaki / ?$B5HF#1QL@ wrote:
> In article <20041102210259.GA12642@xxxxxxxxxxxxxxxxxxx> (at Wed, 3 Nov 2004 
> 08:02:59 +1100), Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> says:
> 
> > -   if (tbl->entries > tbl->gc_thresh3 ||
> > -       (tbl->entries > tbl->gc_thresh2 &&
> > +   entries = atomic_inc_return(&tbl->entries) - 1;
> > +   if (entries >= tbl->gc_thresh3 ||
> > +       (entries >= tbl->gc_thresh2 &&
> 
> Why don't you do something like this?
> 
>         entries = atomic_inc_return(&tbl->entries);
>         if (entries > tbl->gc_thresh3 ||
>             (entries > tbl->gc_thresh2 &&

We could do that.  The first form generates slightly better code on
i386.  However, the situation is probably reversed for other
architectures.

A more serious issue is that some architectures arm/arm26/um/x86_64
don't have atomic_inc_return.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

<Prev in Thread] Current Thread [Next in Thread>