All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] neigh: __rcu annotations
@ 2011-01-20  8:02 Eric Dumazet
  2011-01-21  0:56 ` David Miller
  2011-01-22  1:36 ` Paul E. McKenney
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2011-01-20  8:02 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

fix some minor issues and sparse (__rcu) warnings

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 net/core/neighbour.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 60a9029..799f06e 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -316,7 +316,7 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int entries)
 {
 	size_t size = entries * sizeof(struct neighbour *);
 	struct neigh_hash_table *ret;
-	struct neighbour **buckets;
+	struct neighbour __rcu **buckets;
 
 	ret = kmalloc(sizeof(*ret), GFP_ATOMIC);
 	if (!ret)
@@ -324,14 +324,14 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int entries)
 	if (size <= PAGE_SIZE)
 		buckets = kzalloc(size, GFP_ATOMIC);
 	else
-		buckets = (struct neighbour **)
+		buckets = (struct neighbour __rcu **)
 			  __get_free_pages(GFP_ATOMIC | __GFP_ZERO,
 					   get_order(size));
 	if (!buckets) {
 		kfree(ret);
 		return NULL;
 	}
-	rcu_assign_pointer(ret->hash_buckets, buckets);
+	ret->hash_buckets = buckets;
 	ret->hash_mask = entries - 1;
 	get_random_bytes(&ret->hash_rnd, sizeof(ret->hash_rnd));
 	return ret;
@@ -343,7 +343,7 @@ static void neigh_hash_free_rcu(struct rcu_head *head)
 						    struct neigh_hash_table,
 						    rcu);
 	size_t size = (nht->hash_mask + 1) * sizeof(struct neighbour *);
-	struct neighbour **buckets = nht->hash_buckets;
+	struct neighbour __rcu **buckets = nht->hash_buckets;
 
 	if (size <= PAGE_SIZE)
 		kfree(buckets);
@@ -1540,7 +1540,7 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
 		panic("cannot create neighbour proc dir entry");
 #endif
 
-	tbl->nht = neigh_hash_alloc(8);
+	RCU_INIT_POINTER(tbl->nht, neigh_hash_alloc(8));
 
 	phsize = (PNEIGH_HASHMASK + 1) * sizeof(struct pneigh_entry *);
 	tbl->phash_buckets = kzalloc(phsize, GFP_KERNEL);
@@ -1602,7 +1602,8 @@ int neigh_table_clear(struct neigh_table *tbl)
 	}
 	write_unlock(&neigh_tbl_lock);
 
-	call_rcu(&tbl->nht->rcu, neigh_hash_free_rcu);
+	call_rcu(&rcu_dereference_protected(tbl->nht, 1)->rcu,
+		 neigh_hash_free_rcu);
 	tbl->nht = NULL;
 
 	kfree(tbl->phash_buckets);



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] neigh: __rcu annotations
  2011-01-20  8:02 [PATCH] neigh: __rcu annotations Eric Dumazet
@ 2011-01-21  0:56 ` David Miller
  2011-01-22  1:36 ` Paul E. McKenney
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2011-01-21  0:56 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 20 Jan 2011 09:02:47 +0100

> fix some minor issues and sparse (__rcu) warnings
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] neigh: __rcu annotations
  2011-01-20  8:02 [PATCH] neigh: __rcu annotations Eric Dumazet
  2011-01-21  0:56 ` David Miller
@ 2011-01-22  1:36 ` Paul E. McKenney
  1 sibling, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2011-01-22  1:36 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev

On Thu, Jan 20, 2011 at 09:02:47AM +0100, Eric Dumazet wrote:
> fix some minor issues and sparse (__rcu) warnings
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> ---
>  net/core/neighbour.c |   13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> index 60a9029..799f06e 100644
> --- a/net/core/neighbour.c
> +++ b/net/core/neighbour.c
> @@ -316,7 +316,7 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int entries)
>  {
>  	size_t size = entries * sizeof(struct neighbour *);
>  	struct neigh_hash_table *ret;
> -	struct neighbour **buckets;
> +	struct neighbour __rcu **buckets;
> 
>  	ret = kmalloc(sizeof(*ret), GFP_ATOMIC);
>  	if (!ret)
> @@ -324,14 +324,14 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int entries)
>  	if (size <= PAGE_SIZE)
>  		buckets = kzalloc(size, GFP_ATOMIC);
>  	else
> -		buckets = (struct neighbour **)
> +		buckets = (struct neighbour __rcu **)
>  			  __get_free_pages(GFP_ATOMIC | __GFP_ZERO,
>  					   get_order(size));
>  	if (!buckets) {
>  		kfree(ret);
>  		return NULL;
>  	}
> -	rcu_assign_pointer(ret->hash_buckets, buckets);
> +	ret->hash_buckets = buckets;
>  	ret->hash_mask = entries - 1;
>  	get_random_bytes(&ret->hash_rnd, sizeof(ret->hash_rnd));
>  	return ret;
> @@ -343,7 +343,7 @@ static void neigh_hash_free_rcu(struct rcu_head *head)
>  						    struct neigh_hash_table,
>  						    rcu);
>  	size_t size = (nht->hash_mask + 1) * sizeof(struct neighbour *);
> -	struct neighbour **buckets = nht->hash_buckets;
> +	struct neighbour __rcu **buckets = nht->hash_buckets;
> 
>  	if (size <= PAGE_SIZE)
>  		kfree(buckets);
> @@ -1540,7 +1540,7 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
>  		panic("cannot create neighbour proc dir entry");
>  #endif
> 
> -	tbl->nht = neigh_hash_alloc(8);
> +	RCU_INIT_POINTER(tbl->nht, neigh_hash_alloc(8));
> 
>  	phsize = (PNEIGH_HASHMASK + 1) * sizeof(struct pneigh_entry *);
>  	tbl->phash_buckets = kzalloc(phsize, GFP_KERNEL);
> @@ -1602,7 +1602,8 @@ int neigh_table_clear(struct neigh_table *tbl)
>  	}
>  	write_unlock(&neigh_tbl_lock);
> 
> -	call_rcu(&tbl->nht->rcu, neigh_hash_free_rcu);
> +	call_rcu(&rcu_dereference_protected(tbl->nht, 1)->rcu,
> +		 neigh_hash_free_rcu);

Hello, Eric,

Any chance of a comment?  Perhaps something like:

	/*
	 * Because this has been removed from the list, no other updater
	 * can access this element.
	 */

							Thanx, Paul

>  	tbl->nht = NULL;
> 
>  	kfree(tbl->phash_buckets);
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-22  8:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-20  8:02 [PATCH] neigh: __rcu annotations Eric Dumazet
2011-01-21  0:56 ` David Miller
2011-01-22  1:36 ` Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.