From: Tejun Heo <tj@kernel.org>
To: linux-kernel@vger.kernel.org, axboe@kernel.dk,
rusty@rustcorp.com.au, akpm@linux-foundation.org,
ebiederm@xmission.com, tytso@mit.edu, Trond.Myklebust@netapp.com,
aelder@sgi.com, hch@infradead.org, viro@zeniv.linux.org.uk,
davem@davemloft.net, netdev@vger.kernel.org, x86@kernel.org,
mingo@redhat.com, fweisbec@gmail.com, dan.j.williams@intel.com,
borislav.petkov@amd.com, ying.huang@intel.com, lenb@kernel.org,
neilb@suse.de, cl@linux-foundation.org
Cc: Tejun Heo <tj@kernel.org>, Eric Dumazet <eric.dumazet@gmail.com>,
Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 4/8] percpu: add __percpu sparse annotations to net drivers
Date: Tue, 26 Jan 2010 00:22:11 +0900 [thread overview]
Message-ID: <1264432935-10453-5-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1264432935-10453-1-git-send-email-tj@kernel.org>
Add __percpu sparse annotations to net drivers.
These annotations are to make sparse consider percpu variables to be
in a different address space and warn if accessed without going
through percpu accessors. This patch doesn't affect normal builds.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/chelsio/sge.c | 2 +-
drivers/net/loopback.c | 16 +++++++++-------
drivers/net/macvlan.c | 2 +-
drivers/net/veth.c | 4 ++--
4 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index 109d278..8e12505 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -267,7 +267,7 @@ struct sge {
struct sk_buff *espibug_skb[MAX_NPORTS];
u32 sge_control; /* shadow value of sge control reg */
struct sge_intr_counts stats;
- struct sge_port_stats *port_stats[MAX_NPORTS];
+ struct sge_port_stats __percpu *port_stats[MAX_NPORTS];
struct sched *tx_sched;
struct cmdQ cmdQ[SGE_CMDQ_N] ____cacheline_aligned_in_smp;
};
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index b9fcc98..72b7949 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -72,7 +72,8 @@ struct pcpu_lstats {
static netdev_tx_t loopback_xmit(struct sk_buff *skb,
struct net_device *dev)
{
- struct pcpu_lstats *pcpu_lstats, *lb_stats;
+ struct pcpu_lstats __percpu *pcpu_lstats;
+ struct pcpu_lstats *lb_stats;
int len;
skb_orphan(skb);
@@ -80,7 +81,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
skb->protocol = eth_type_trans(skb, dev);
/* it's OK to use per_cpu_ptr() because BHs are off */
- pcpu_lstats = dev->ml_priv;
+ pcpu_lstats = (void __percpu __force *)dev->ml_priv;
lb_stats = this_cpu_ptr(pcpu_lstats);
len = skb->len;
@@ -95,14 +96,14 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
static struct net_device_stats *loopback_get_stats(struct net_device *dev)
{
- const struct pcpu_lstats *pcpu_lstats;
+ const struct pcpu_lstats __percpu *pcpu_lstats;
struct net_device_stats *stats = &dev->stats;
unsigned long bytes = 0;
unsigned long packets = 0;
unsigned long drops = 0;
int i;
- pcpu_lstats = dev->ml_priv;
+ pcpu_lstats = (void __percpu __force *)dev->ml_priv;
for_each_possible_cpu(i) {
const struct pcpu_lstats *lb_stats;
@@ -135,19 +136,20 @@ static const struct ethtool_ops loopback_ethtool_ops = {
static int loopback_dev_init(struct net_device *dev)
{
- struct pcpu_lstats *lstats;
+ struct pcpu_lstats __percpu *lstats;
lstats = alloc_percpu(struct pcpu_lstats);
if (!lstats)
return -ENOMEM;
- dev->ml_priv = lstats;
+ dev->ml_priv = (void __force *)lstats;
return 0;
}
static void loopback_dev_free(struct net_device *dev)
{
- struct pcpu_lstats *lstats = dev->ml_priv;
+ struct pcpu_lstats __percpu *lstats =
+ (void __percpu __force *)dev->ml_priv;
free_percpu(lstats);
free_netdev(dev);
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 21a9c9a..4d2040c 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -59,7 +59,7 @@ struct macvlan_dev {
struct hlist_node hlist;
struct macvlan_port *port;
struct net_device *lowerdev;
- struct macvlan_rx_stats *rx_stats;
+ struct macvlan_rx_stats __percpu *rx_stats;
enum macvlan_mode mode;
};
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 3a15de5..35609e6 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -34,7 +34,7 @@ struct veth_net_stats {
struct veth_priv {
struct net_device *peer;
- struct veth_net_stats *stats;
+ struct veth_net_stats __percpu *stats;
unsigned ip_summed;
};
@@ -263,7 +263,7 @@ static int veth_change_mtu(struct net_device *dev, int new_mtu)
static int veth_dev_init(struct net_device *dev)
{
- struct veth_net_stats *stats;
+ struct veth_net_stats __percpu *stats;
struct veth_priv *priv;
stats = alloc_percpu(struct veth_net_stats);
--
1.6.4.2
next prev parent reply other threads:[~2010-01-25 15:20 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-25 15:22 [PATCHSET] percpu: add __percpu sparse annotations Tejun Heo
2010-01-25 15:22 ` [PATCH 1/8] percpu: add __percpu sparse annotations to core kernel subsystems Tejun Heo
2010-01-25 21:58 ` Christoph Lameter
2010-01-31 11:42 ` Paul E. McKenney
2010-01-25 15:22 ` [PATCH 2/8] percpu: add __percpu sparse annotations to fs Tejun Heo
2010-01-25 15:22 ` [PATCH 3/8] percpu: add __percpu sparse annotations to net Tejun Heo
2010-01-25 21:32 ` David Miller
2010-01-25 15:22 ` Tejun Heo [this message]
2010-01-25 21:33 ` [PATCH 4/8] percpu: add __percpu sparse annotations to net drivers David Miller
2010-01-25 15:22 ` [PATCH 5/8] percpu: add __percpu sparse annotations to x86 Tejun Heo
2010-01-26 1:06 ` H. Peter Anvin
2010-01-26 2:17 ` Tejun Heo
2010-02-01 3:30 ` H. Peter Anvin
2010-01-25 15:22 ` [PATCH 6/8] percpu: add __percpu sparse annotations to trace Tejun Heo
2010-01-25 15:35 ` Steven Rostedt
2010-01-25 15:22 ` [PATCH 7/8] percpu: add __percpu sparse annotations to hw_breakpoint Tejun Heo
2010-01-26 0:19 ` Frederic Weisbecker
2010-01-26 0:48 ` Tejun Heo
2010-01-26 1:02 ` Frederic Weisbecker
2010-01-26 1:19 ` Tejun Heo
2010-01-26 2:01 ` Frederic Weisbecker
2010-01-26 2:10 ` Frederic Weisbecker
2010-01-26 2:13 ` Tejun Heo
2010-01-26 2:18 ` Frederic Weisbecker
2010-01-26 2:22 ` Frederic Weisbecker
2010-01-26 2:34 ` Tejun Heo
2010-01-26 2:35 ` Frederic Weisbecker
2010-01-26 2:47 ` Tejun Heo
2010-01-26 1:02 ` H. Peter Anvin
2010-01-26 2:06 ` Tejun Heo
2010-01-26 2:04 ` Al Viro
2010-01-26 2:16 ` Tejun Heo
2010-01-26 2:32 ` Al Viro
2010-01-26 2:43 ` Tejun Heo
2010-01-26 2:48 ` Al Viro
2010-01-26 3:10 ` Tejun Heo
2010-01-26 3:56 ` Al Viro
2010-01-26 1:06 ` H. Peter Anvin
2010-01-26 1:12 ` Frederic Weisbecker
2010-01-26 2:10 ` Tejun Heo
2010-01-25 15:22 ` [PATCH 8/8] percpu: add __percpu sparse annotations to what's left Tejun Heo
2010-01-25 15:54 ` Borislav Petkov
2010-01-25 23:14 ` [PATCHSET] percpu: add __percpu sparse annotations Al Viro
2010-01-26 0:30 ` Tejun Heo
2010-02-02 5:37 ` Tejun Heo
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=1264432935-10453-5-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=Trond.Myklebust@netapp.com \
--cc=aelder@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=borislav.petkov@amd.com \
--cc=cl@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=eric.dumazet@gmail.com \
--cc=fweisbec@gmail.com \
--cc=hch@infradead.org \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=neilb@suse.de \
--cc=netdev@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@kernel.org \
--cc=ying.huang@intel.com \
/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