diff options
author | Tejun Heo <tj@kernel.org> | 2010-02-16 10:21:08 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-17 02:05:38 -0500 |
commit | 47d742752df4c1088589d4424840bc761613ab2a (patch) | |
tree | 186eec2c69a1f7149e08d354c36a34c21b58fa4f | |
parent | 7d720c3e4f0c4fc152a6bf17e24244a3c85412d2 (diff) |
percpu: add __percpu sparse annotations to net drivers
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>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/chelsio/sge.c | 2 | ||||
-rw-r--r-- | drivers/net/loopback.c | 16 | ||||
-rw-r--r-- | drivers/net/veth.c | 4 | ||||
-rw-r--r-- | include/linux/if_macvlan.h | 2 |
4 files changed, 13 insertions, 11 deletions
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c index 109d2783e4d8..8e12505ac3aa 100644 --- a/drivers/net/chelsio/sge.c +++ b/drivers/net/chelsio/sge.c | |||
@@ -267,7 +267,7 @@ struct sge { | |||
267 | struct sk_buff *espibug_skb[MAX_NPORTS]; | 267 | struct sk_buff *espibug_skb[MAX_NPORTS]; |
268 | u32 sge_control; /* shadow value of sge control reg */ | 268 | u32 sge_control; /* shadow value of sge control reg */ |
269 | struct sge_intr_counts stats; | 269 | struct sge_intr_counts stats; |
270 | struct sge_port_stats *port_stats[MAX_NPORTS]; | 270 | struct sge_port_stats __percpu *port_stats[MAX_NPORTS]; |
271 | struct sched *tx_sched; | 271 | struct sched *tx_sched; |
272 | struct cmdQ cmdQ[SGE_CMDQ_N] ____cacheline_aligned_in_smp; | 272 | struct cmdQ cmdQ[SGE_CMDQ_N] ____cacheline_aligned_in_smp; |
273 | }; | 273 | }; |
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index b9fcc9819837..72b7949c91b1 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c | |||
@@ -72,7 +72,8 @@ struct pcpu_lstats { | |||
72 | static netdev_tx_t loopback_xmit(struct sk_buff *skb, | 72 | static netdev_tx_t loopback_xmit(struct sk_buff *skb, |
73 | struct net_device *dev) | 73 | struct net_device *dev) |
74 | { | 74 | { |
75 | struct pcpu_lstats *pcpu_lstats, *lb_stats; | 75 | struct pcpu_lstats __percpu *pcpu_lstats; |
76 | struct pcpu_lstats *lb_stats; | ||
76 | int len; | 77 | int len; |
77 | 78 | ||
78 | skb_orphan(skb); | 79 | skb_orphan(skb); |
@@ -80,7 +81,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb, | |||
80 | skb->protocol = eth_type_trans(skb, dev); | 81 | skb->protocol = eth_type_trans(skb, dev); |
81 | 82 | ||
82 | /* it's OK to use per_cpu_ptr() because BHs are off */ | 83 | /* it's OK to use per_cpu_ptr() because BHs are off */ |
83 | pcpu_lstats = dev->ml_priv; | 84 | pcpu_lstats = (void __percpu __force *)dev->ml_priv; |
84 | lb_stats = this_cpu_ptr(pcpu_lstats); | 85 | lb_stats = this_cpu_ptr(pcpu_lstats); |
85 | 86 | ||
86 | len = skb->len; | 87 | len = skb->len; |
@@ -95,14 +96,14 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb, | |||
95 | 96 | ||
96 | static struct net_device_stats *loopback_get_stats(struct net_device *dev) | 97 | static struct net_device_stats *loopback_get_stats(struct net_device *dev) |
97 | { | 98 | { |
98 | const struct pcpu_lstats *pcpu_lstats; | 99 | const struct pcpu_lstats __percpu *pcpu_lstats; |
99 | struct net_device_stats *stats = &dev->stats; | 100 | struct net_device_stats *stats = &dev->stats; |
100 | unsigned long bytes = 0; | 101 | unsigned long bytes = 0; |
101 | unsigned long packets = 0; | 102 | unsigned long packets = 0; |
102 | unsigned long drops = 0; | 103 | unsigned long drops = 0; |
103 | int i; | 104 | int i; |
104 | 105 | ||
105 | pcpu_lstats = dev->ml_priv; | 106 | pcpu_lstats = (void __percpu __force *)dev->ml_priv; |
106 | for_each_possible_cpu(i) { | 107 | for_each_possible_cpu(i) { |
107 | const struct pcpu_lstats *lb_stats; | 108 | const struct pcpu_lstats *lb_stats; |
108 | 109 | ||
@@ -135,19 +136,20 @@ static const struct ethtool_ops loopback_ethtool_ops = { | |||
135 | 136 | ||
136 | static int loopback_dev_init(struct net_device *dev) | 137 | static int loopback_dev_init(struct net_device *dev) |
137 | { | 138 | { |
138 | struct pcpu_lstats *lstats; | 139 | struct pcpu_lstats __percpu *lstats; |
139 | 140 | ||
140 | lstats = alloc_percpu(struct pcpu_lstats); | 141 | lstats = alloc_percpu(struct pcpu_lstats); |
141 | if (!lstats) | 142 | if (!lstats) |
142 | return -ENOMEM; | 143 | return -ENOMEM; |
143 | 144 | ||
144 | dev->ml_priv = lstats; | 145 | dev->ml_priv = (void __force *)lstats; |
145 | return 0; | 146 | return 0; |
146 | } | 147 | } |
147 | 148 | ||
148 | static void loopback_dev_free(struct net_device *dev) | 149 | static void loopback_dev_free(struct net_device *dev) |
149 | { | 150 | { |
150 | struct pcpu_lstats *lstats = dev->ml_priv; | 151 | struct pcpu_lstats __percpu *lstats = |
152 | (void __percpu __force *)dev->ml_priv; | ||
151 | 153 | ||
152 | free_percpu(lstats); | 154 | free_percpu(lstats); |
153 | free_netdev(dev); | 155 | free_netdev(dev); |
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 3a15de56df9c..35609e64f6fd 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c | |||
@@ -34,7 +34,7 @@ struct veth_net_stats { | |||
34 | 34 | ||
35 | struct veth_priv { | 35 | struct veth_priv { |
36 | struct net_device *peer; | 36 | struct net_device *peer; |
37 | struct veth_net_stats *stats; | 37 | struct veth_net_stats __percpu *stats; |
38 | unsigned ip_summed; | 38 | unsigned ip_summed; |
39 | }; | 39 | }; |
40 | 40 | ||
@@ -263,7 +263,7 @@ static int veth_change_mtu(struct net_device *dev, int new_mtu) | |||
263 | 263 | ||
264 | static int veth_dev_init(struct net_device *dev) | 264 | static int veth_dev_init(struct net_device *dev) |
265 | { | 265 | { |
266 | struct veth_net_stats *stats; | 266 | struct veth_net_stats __percpu *stats; |
267 | struct veth_priv *priv; | 267 | struct veth_priv *priv; |
268 | 268 | ||
269 | stats = alloc_percpu(struct veth_net_stats); | 269 | stats = alloc_percpu(struct veth_net_stats); |
diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h index 51f1512045e9..f9cb9ba1475d 100644 --- a/include/linux/if_macvlan.h +++ b/include/linux/if_macvlan.h | |||
@@ -30,7 +30,7 @@ struct macvlan_dev { | |||
30 | struct hlist_node hlist; | 30 | struct hlist_node hlist; |
31 | struct macvlan_port *port; | 31 | struct macvlan_port *port; |
32 | struct net_device *lowerdev; | 32 | struct net_device *lowerdev; |
33 | struct macvlan_rx_stats *rx_stats; | 33 | struct macvlan_rx_stats __percpu *rx_stats; |
34 | enum macvlan_mode mode; | 34 | enum macvlan_mode mode; |
35 | int (*receive)(struct sk_buff *skb); | 35 | int (*receive)(struct sk_buff *skb); |
36 | int (*forward)(struct net_device *dev, struct sk_buff *skb); | 36 | int (*forward)(struct net_device *dev, struct sk_buff *skb); |