[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080109094637.GA28874@gondor.apana.org.au>
Date: Wed, 9 Jan 2008 20:46:37 +1100
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Eric Dumazet <dada1@...mosbay.com>
Cc: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
davem@...emloft.net, dipankar@...ibm.com, netdev@...r.kernel.org
Subject: Re: [NET] ROUTE: fix rcu_dereference() uses in /proc/net/rt_cache
On Wed, Jan 09, 2008 at 08:38:56AM +0100, Eric Dumazet wrote:
>
> I am not sure this is valid, since it will do this :
>
> r = rt_hash_table[st->bucket].chain;
> if (r)
> return rcu_dereference(r);
>
> So compiler might be dumb enough do dereference
> &rt_hash_table[st->bucket].chain two times.
That wouldn't be a problem at all. The key is to add a barrier between
reading the pointer:
r = rt_hash_table[st->bucket].chain
and dereferencing it later, e.g.,
r->u.dst.rt_next
The barrier is there so that when we dereference r we don't read
stale cache that was there before the memory at r was initialised.
How many times you read the pointer value before the barrier is
irrelevant to the effectiveness of the barrier preceding the
dereference.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists