diff options
author | Tejun Heo <tj@kernel.org> | 2010-02-16 10:20:26 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-17 02:05:38 -0500 |
commit | 7d720c3e4f0c4fc152a6bf17e24244a3c85412d2 (patch) | |
tree | 36e037187ce79acb211702bea22e99c625787757 /net/ipv6 | |
parent | 2bb4646fce8d09916b351d1a62f98db7cec6fc41 (diff) |
percpu: add __percpu sparse annotations to net
Add __percpu sparse annotations to net.
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.
The macro and type tricks around snmp stats make things a bit
interesting. DEFINE/DECLARE_SNMP_STAT() macros mark the target field
as __percpu and SNMP_UPD_PO_STATS() macro is updated accordingly. All
snmp_mib_*() users which used to cast the argument to (void **) are
updated to cast it to (void __percpu **).
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Vlad Yasevich <vladislav.yasevich@hp.com>
Cc: netdev@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/addrconf.c | 24 | ||||
-rw-r--r-- | net/ipv6/af_inet6.c | 28 | ||||
-rw-r--r-- | net/ipv6/proc.c | 23 |
3 files changed, 39 insertions, 36 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index c79cbff54370..b0d4a4b23db5 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -278,31 +278,31 @@ static void addrconf_mod_timer(struct inet6_ifaddr *ifp, | |||
278 | 278 | ||
279 | static int snmp6_alloc_dev(struct inet6_dev *idev) | 279 | static int snmp6_alloc_dev(struct inet6_dev *idev) |
280 | { | 280 | { |
281 | if (snmp_mib_init((void **)idev->stats.ipv6, | 281 | if (snmp_mib_init((void __percpu **)idev->stats.ipv6, |
282 | sizeof(struct ipstats_mib)) < 0) | 282 | sizeof(struct ipstats_mib)) < 0) |
283 | goto err_ip; | 283 | goto err_ip; |
284 | if (snmp_mib_init((void **)idev->stats.icmpv6, | 284 | if (snmp_mib_init((void __percpu **)idev->stats.icmpv6, |
285 | sizeof(struct icmpv6_mib)) < 0) | 285 | sizeof(struct icmpv6_mib)) < 0) |
286 | goto err_icmp; | 286 | goto err_icmp; |
287 | if (snmp_mib_init((void **)idev->stats.icmpv6msg, | 287 | if (snmp_mib_init((void __percpu **)idev->stats.icmpv6msg, |
288 | sizeof(struct icmpv6msg_mib)) < 0) | 288 | sizeof(struct icmpv6msg_mib)) < 0) |
289 | goto err_icmpmsg; | 289 | goto err_icmpmsg; |
290 | 290 | ||
291 | return 0; | 291 | return 0; |
292 | 292 | ||
293 | err_icmpmsg: | 293 | err_icmpmsg: |
294 | snmp_mib_free((void **)idev->stats.icmpv6); | 294 | snmp_mib_free((void __percpu **)idev->stats.icmpv6); |
295 | err_icmp: | 295 | err_icmp: |
296 | snmp_mib_free((void **)idev->stats.ipv6); | 296 | snmp_mib_free((void __percpu **)idev->stats.ipv6); |
297 | err_ip: | 297 | err_ip: |
298 | return -ENOMEM; | 298 | return -ENOMEM; |
299 | } | 299 | } |
300 | 300 | ||
301 | static void snmp6_free_dev(struct inet6_dev *idev) | 301 | static void snmp6_free_dev(struct inet6_dev *idev) |
302 | { | 302 | { |
303 | snmp_mib_free((void **)idev->stats.icmpv6msg); | 303 | snmp_mib_free((void __percpu **)idev->stats.icmpv6msg); |
304 | snmp_mib_free((void **)idev->stats.icmpv6); | 304 | snmp_mib_free((void __percpu **)idev->stats.icmpv6); |
305 | snmp_mib_free((void **)idev->stats.ipv6); | 305 | snmp_mib_free((void __percpu **)idev->stats.ipv6); |
306 | } | 306 | } |
307 | 307 | ||
308 | /* Nobody refers to this device, we may destroy it. */ | 308 | /* Nobody refers to this device, we may destroy it. */ |
@@ -3766,8 +3766,8 @@ static inline size_t inet6_if_nlmsg_size(void) | |||
3766 | ); | 3766 | ); |
3767 | } | 3767 | } |
3768 | 3768 | ||
3769 | static inline void __snmp6_fill_stats(u64 *stats, void **mib, int items, | 3769 | static inline void __snmp6_fill_stats(u64 *stats, void __percpu **mib, |
3770 | int bytes) | 3770 | int items, int bytes) |
3771 | { | 3771 | { |
3772 | int i; | 3772 | int i; |
3773 | int pad = bytes - sizeof(u64) * items; | 3773 | int pad = bytes - sizeof(u64) * items; |
@@ -3786,10 +3786,10 @@ static void snmp6_fill_stats(u64 *stats, struct inet6_dev *idev, int attrtype, | |||
3786 | { | 3786 | { |
3787 | switch(attrtype) { | 3787 | switch(attrtype) { |
3788 | case IFLA_INET6_STATS: | 3788 | case IFLA_INET6_STATS: |
3789 | __snmp6_fill_stats(stats, (void **)idev->stats.ipv6, IPSTATS_MIB_MAX, bytes); | 3789 | __snmp6_fill_stats(stats, (void __percpu **)idev->stats.ipv6, IPSTATS_MIB_MAX, bytes); |
3790 | break; | 3790 | break; |
3791 | case IFLA_INET6_ICMP6STATS: | 3791 | case IFLA_INET6_ICMP6STATS: |
3792 | __snmp6_fill_stats(stats, (void **)idev->stats.icmpv6, ICMP6_MIB_MAX, bytes); | 3792 | __snmp6_fill_stats(stats, (void __percpu **)idev->stats.icmpv6, ICMP6_MIB_MAX, bytes); |
3793 | break; | 3793 | break; |
3794 | } | 3794 | } |
3795 | } | 3795 | } |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index e29160ff4a0f..37d14e735c27 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -971,41 +971,41 @@ static void ipv6_packet_cleanup(void) | |||
971 | 971 | ||
972 | static int __net_init ipv6_init_mibs(struct net *net) | 972 | static int __net_init ipv6_init_mibs(struct net *net) |
973 | { | 973 | { |
974 | if (snmp_mib_init((void **)net->mib.udp_stats_in6, | 974 | if (snmp_mib_init((void __percpu **)net->mib.udp_stats_in6, |
975 | sizeof (struct udp_mib)) < 0) | 975 | sizeof (struct udp_mib)) < 0) |
976 | return -ENOMEM; | 976 | return -ENOMEM; |
977 | if (snmp_mib_init((void **)net->mib.udplite_stats_in6, | 977 | if (snmp_mib_init((void __percpu **)net->mib.udplite_stats_in6, |
978 | sizeof (struct udp_mib)) < 0) | 978 | sizeof (struct udp_mib)) < 0) |
979 | goto err_udplite_mib; | 979 | goto err_udplite_mib; |
980 | if (snmp_mib_init((void **)net->mib.ipv6_statistics, | 980 | if (snmp_mib_init((void __percpu **)net->mib.ipv6_statistics, |
981 | sizeof(struct ipstats_mib)) < 0) | 981 | sizeof(struct ipstats_mib)) < 0) |
982 | goto err_ip_mib; | 982 | goto err_ip_mib; |
983 | if (snmp_mib_init((void **)net->mib.icmpv6_statistics, | 983 | if (snmp_mib_init((void __percpu **)net->mib.icmpv6_statistics, |
984 | sizeof(struct icmpv6_mib)) < 0) | 984 | sizeof(struct icmpv6_mib)) < 0) |
985 | goto err_icmp_mib; | 985 | goto err_icmp_mib; |
986 | if (snmp_mib_init((void **)net->mib.icmpv6msg_statistics, | 986 | if (snmp_mib_init((void __percpu **)net->mib.icmpv6msg_statistics, |
987 | sizeof(struct icmpv6msg_mib)) < 0) | 987 | sizeof(struct icmpv6msg_mib)) < 0) |
988 | goto err_icmpmsg_mib; | 988 | goto err_icmpmsg_mib; |
989 | return 0; | 989 | return 0; |
990 | 990 | ||
991 | err_icmpmsg_mib: | 991 | err_icmpmsg_mib: |
992 | snmp_mib_free((void **)net->mib.icmpv6_statistics); | 992 | snmp_mib_free((void __percpu **)net->mib.icmpv6_statistics); |
993 | err_icmp_mib: | 993 | err_icmp_mib: |
994 | snmp_mib_free((void **)net->mib.ipv6_statistics); | 994 | snmp_mib_free((void __percpu **)net->mib.ipv6_statistics); |
995 | err_ip_mib: | 995 | err_ip_mib: |
996 | snmp_mib_free((void **)net->mib.udplite_stats_in6); | 996 | snmp_mib_free((void __percpu **)net->mib.udplite_stats_in6); |
997 | err_udplite_mib: | 997 | err_udplite_mib: |
998 | snmp_mib_free((void **)net->mib.udp_stats_in6); | 998 | snmp_mib_free((void __percpu **)net->mib.udp_stats_in6); |
999 | return -ENOMEM; | 999 | return -ENOMEM; |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | static void ipv6_cleanup_mibs(struct net *net) | 1002 | static void ipv6_cleanup_mibs(struct net *net) |
1003 | { | 1003 | { |
1004 | snmp_mib_free((void **)net->mib.udp_stats_in6); | 1004 | snmp_mib_free((void __percpu **)net->mib.udp_stats_in6); |
1005 | snmp_mib_free((void **)net->mib.udplite_stats_in6); | 1005 | snmp_mib_free((void __percpu **)net->mib.udplite_stats_in6); |
1006 | snmp_mib_free((void **)net->mib.ipv6_statistics); | 1006 | snmp_mib_free((void __percpu **)net->mib.ipv6_statistics); |
1007 | snmp_mib_free((void **)net->mib.icmpv6_statistics); | 1007 | snmp_mib_free((void __percpu **)net->mib.icmpv6_statistics); |
1008 | snmp_mib_free((void **)net->mib.icmpv6msg_statistics); | 1008 | snmp_mib_free((void __percpu **)net->mib.icmpv6msg_statistics); |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | static int __net_init inet6_net_init(struct net *net) | 1011 | static int __net_init inet6_net_init(struct net *net) |
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index bfe2598dd563..58344c0fbd13 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
@@ -136,7 +136,7 @@ static const struct snmp_mib snmp6_udplite6_list[] = { | |||
136 | SNMP_MIB_SENTINEL | 136 | SNMP_MIB_SENTINEL |
137 | }; | 137 | }; |
138 | 138 | ||
139 | static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib) | 139 | static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void __percpu **mib) |
140 | { | 140 | { |
141 | char name[32]; | 141 | char name[32]; |
142 | int i; | 142 | int i; |
@@ -170,7 +170,7 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void **mib) | |||
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | 172 | ||
173 | static void snmp6_seq_show_item(struct seq_file *seq, void **mib, | 173 | static void snmp6_seq_show_item(struct seq_file *seq, void __percpu **mib, |
174 | const struct snmp_mib *itemlist) | 174 | const struct snmp_mib *itemlist) |
175 | { | 175 | { |
176 | int i; | 176 | int i; |
@@ -183,14 +183,15 @@ static int snmp6_seq_show(struct seq_file *seq, void *v) | |||
183 | { | 183 | { |
184 | struct net *net = (struct net *)seq->private; | 184 | struct net *net = (struct net *)seq->private; |
185 | 185 | ||
186 | snmp6_seq_show_item(seq, (void **)net->mib.ipv6_statistics, | 186 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.ipv6_statistics, |
187 | snmp6_ipstats_list); | 187 | snmp6_ipstats_list); |
188 | snmp6_seq_show_item(seq, (void **)net->mib.icmpv6_statistics, | 188 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.icmpv6_statistics, |
189 | snmp6_icmp6_list); | 189 | snmp6_icmp6_list); |
190 | snmp6_seq_show_icmpv6msg(seq, (void **)net->mib.icmpv6msg_statistics); | 190 | snmp6_seq_show_icmpv6msg(seq, |
191 | snmp6_seq_show_item(seq, (void **)net->mib.udp_stats_in6, | 191 | (void __percpu **)net->mib.icmpv6msg_statistics); |
192 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.udp_stats_in6, | ||
192 | snmp6_udp6_list); | 193 | snmp6_udp6_list); |
193 | snmp6_seq_show_item(seq, (void **)net->mib.udplite_stats_in6, | 194 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.udplite_stats_in6, |
194 | snmp6_udplite6_list); | 195 | snmp6_udplite6_list); |
195 | return 0; | 196 | return 0; |
196 | } | 197 | } |
@@ -213,9 +214,11 @@ static int snmp6_dev_seq_show(struct seq_file *seq, void *v) | |||
213 | struct inet6_dev *idev = (struct inet6_dev *)seq->private; | 214 | struct inet6_dev *idev = (struct inet6_dev *)seq->private; |
214 | 215 | ||
215 | seq_printf(seq, "%-32s\t%u\n", "ifIndex", idev->dev->ifindex); | 216 | seq_printf(seq, "%-32s\t%u\n", "ifIndex", idev->dev->ifindex); |
216 | snmp6_seq_show_item(seq, (void **)idev->stats.ipv6, snmp6_ipstats_list); | 217 | snmp6_seq_show_item(seq, (void __percpu **)idev->stats.ipv6, |
217 | snmp6_seq_show_item(seq, (void **)idev->stats.icmpv6, snmp6_icmp6_list); | 218 | snmp6_ipstats_list); |
218 | snmp6_seq_show_icmpv6msg(seq, (void **)idev->stats.icmpv6msg); | 219 | snmp6_seq_show_item(seq, (void __percpu **)idev->stats.icmpv6, |
220 | snmp6_icmp6_list); | ||
221 | snmp6_seq_show_icmpv6msg(seq, (void __percpu **)idev->stats.icmpv6msg); | ||
219 | return 0; | 222 | return 0; |
220 | } | 223 | } |
221 | 224 | ||