From patchwork Thu Jan 20 08:02:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 79648 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 306D2B7043 for ; Thu, 20 Jan 2011 19:02:58 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754654Ab1ATICx (ORCPT ); Thu, 20 Jan 2011 03:02:53 -0500 Received: from mail-wy0-f174.google.com ([74.125.82.174]:61825 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752283Ab1ATICx (ORCPT ); Thu, 20 Jan 2011 03:02:53 -0500 Received: by wyb28 with SMTP id 28so336611wyb.19 for ; Thu, 20 Jan 2011 00:02:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:from:to:cc:content-type:date:message-id :mime-version:x-mailer:content-transfer-encoding; bh=pIto62/WFJmDSpQBf2ogGg+JW3a33SL6a+wagepG0mA=; b=S9+QekNZIW8xsfe3smtxvU6SnS8MkVWBFCFhoD4PTAyGcJ6kbcDm7gVi2C4FfPpkrr GPS/fXCYV6V6VPvYDtPK0A2xuAkbr2ISAbaRHIUPwk0FkgJtAliidf/GRsx2YTMr793i Twxo1n7kboCAoUjbytDwNXqLyPPZFVa2PGvkA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=StQ2FkhC60u99/YaoFeEdvvs7xtmFiATeJbPn66TbaSKvKaeqcTkaXskc9n0YKqNNq p6jh30OXE/CfhCFj2XxUrKT7sF1KZN/939fmZE6mwocqQsZVLQIkZe8FqGRem+QsqzPv mSD1aCVz6syLGAWXCeVbEzKocoXAcTzyK3kj8= Received: by 10.216.205.94 with SMTP id i72mr3340833weo.71.1295510571622; Thu, 20 Jan 2011 00:02:51 -0800 (PST) Received: from [10.150.51.210] (gw0.net.jmsp.net [212.23.165.14]) by mx.google.com with ESMTPS id t11sm4084198wes.17.2011.01.20.00.02.50 (version=SSLv3 cipher=RC4-MD5); Thu, 20 Jan 2011 00:02:50 -0800 (PST) Subject: [PATCH] neigh: __rcu annotations From: Eric Dumazet To: David Miller Cc: netdev Date: Thu, 20 Jan 2011 09:02:47 +0100 Message-ID: <1295510567.2653.487.camel@edumazet-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org fix some minor issues and sparse (__rcu) warnings Signed-off-by: Eric Dumazet --- net/core/neighbour.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- 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 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);