netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ying Xue <ying.xue@windriver.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: <netdev@vger.kernel.org>, <herbert@gondor.apana.org.au>
Subject: Re: [PATCH net-next] neigh: Add missing rcu_assign_pointer
Date: Fri, 29 May 2015 10:04:10 +0800	[thread overview]
Message-ID: <5567C91A.5060407@windriver.com> (raw)
In-Reply-To: <1432864234.7456.56.camel@edumazet-glaptop2.roam.corp.google.com>

On 05/29/2015 09:50 AM, Eric Dumazet wrote:
> I count 5 places of redundancy. 
> 

Another two places you found are necessary indeed!

Acked-by: Ying Xue <ying.xue@windriver.com>

> diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> index 3a74df750af4044eba0e7d88ae01ca9b4dac0e72..ac3b69183cc982e722d9683d6de7a39f66b50b64 100644
> --- a/net/core/neighbour.c
> +++ b/net/core/neighbour.c
> @@ -141,9 +141,7 @@ static int neigh_forced_gc(struct neigh_table *tbl)
>  			write_lock(&n->lock);
>  			if (atomic_read(&n->refcnt) == 1 &&
>  			    !(n->nud_state & NUD_PERMANENT)) {
> -				rcu_assign_pointer(*np,
> -					rcu_dereference_protected(n->next,
> -						  lockdep_is_held(&tbl->lock)));
> +				*np = n->next;
>  				n->dead = 1;
>  				shrunk	= 1;
>  				write_unlock(&n->lock);
> @@ -210,9 +208,7 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev)
>  				np = &n->next;
>  				continue;
>  			}
> -			rcu_assign_pointer(*np,
> -				   rcu_dereference_protected(n->next,
> -						lockdep_is_held(&tbl->lock)));
> +			*np = n->next;
>  			write_lock(&n->lock);
>  			neigh_del_timer(n);
>  			n->dead = 1;
> @@ -380,10 +376,8 @@ static struct neigh_hash_table *neigh_hash_grow(struct neigh_table *tbl,
>  			next = rcu_dereference_protected(n->next,
>  						lockdep_is_held(&tbl->lock));
>  
> -			rcu_assign_pointer(n->next,
> -					   rcu_dereference_protected(
> -						new_nht->hash_buckets[hash],
> -						lockdep_is_held(&tbl->lock)));
> +			n->next = new_nht->hash_buckets[hash];
> +
>  			rcu_assign_pointer(new_nht->hash_buckets[hash], n);
>  		}
>  	}
> @@ -515,9 +509,7 @@ struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey,
>  	n->dead = 0;
>  	if (want_ref)
>  		neigh_hold(n);
> -	rcu_assign_pointer(n->next,
> -			   rcu_dereference_protected(nht->hash_buckets[hash_val],
> -						     lockdep_is_held(&tbl->lock)));
> +	n->next = nht->hash_buckets[hash_val];
>  	rcu_assign_pointer(nht->hash_buckets[hash_val], n);
>  	write_unlock_bh(&tbl->lock);
>  	neigh_dbg(2, "neigh %p is created\n", n);
> @@ -2381,9 +2373,7 @@ void __neigh_for_each_release(struct neigh_table *tbl,
>  			write_lock(&n->lock);
>  			release = cb(n);
>  			if (release) {
> -				rcu_assign_pointer(*np,
> -					rcu_dereference_protected(n->next,
> -						lockdep_is_held(&tbl->lock)));
> +				*np = n->next;
>  				n->dead = 1;
>  			} else
>  				np = &n->next;

      reply	other threads:[~2015-05-29  2:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-28  8:28 [PATCH net-next] neigh: Add missing rcu_assign_pointer Ying Xue
2015-05-28 10:13 ` Eric Dumazet
2015-05-28 13:50   ` Herbert Xu
2015-05-28 14:38     ` Eric Dumazet
2015-05-29  0:24       ` Herbert Xu
2015-05-29  1:21   ` Ying Xue
2015-05-29  1:50     ` Eric Dumazet
2015-05-29  2:04       ` Ying Xue [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5567C91A.5060407@windriver.com \
    --to=ying.xue@windriver.com \
    --cc=eric.dumazet@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).