aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-02-16 10:20:26 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-17 02:05:38 -0500
commit7d720c3e4f0c4fc152a6bf17e24244a3c85412d2 (patch)
tree36e037187ce79acb211702bea22e99c625787757 /include/net
parent2bb4646fce8d09916b351d1a62f98db7cec6fc41 (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 'include/net')
-rw-r--r--include/net/ip.h6
-rw-r--r--include/net/ipcomp.h2
-rw-r--r--include/net/neighbour.h2
-rw-r--r--include/net/netns/conntrack.h2
-rw-r--r--include/net/netns/core.h2
-rw-r--r--include/net/route.h2
-rw-r--r--include/net/snmp.h12
-rw-r--r--include/net/tcp.h2
8 files changed, 17 insertions, 13 deletions
diff --git a/include/net/ip.h b/include/net/ip.h
index 7bc47873e3fc..503994a38ed1 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -174,9 +174,9 @@ extern struct ipv4_config ipv4_config;
174#define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd) 174#define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd)
175#define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd) 175#define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd)
176 176
177extern unsigned long snmp_fold_field(void *mib[], int offt); 177extern unsigned long snmp_fold_field(void __percpu *mib[], int offt);
178extern int snmp_mib_init(void *ptr[2], size_t mibsize); 178extern int snmp_mib_init(void __percpu *ptr[2], size_t mibsize);
179extern void snmp_mib_free(void *ptr[2]); 179extern void snmp_mib_free(void __percpu *ptr[2]);
180 180
181extern struct local_ports { 181extern struct local_ports {
182 seqlock_t lock; 182 seqlock_t lock;
diff --git a/include/net/ipcomp.h b/include/net/ipcomp.h
index 2a1092abaa07..cc4f30cd7315 100644
--- a/include/net/ipcomp.h
+++ b/include/net/ipcomp.h
@@ -9,7 +9,7 @@ struct crypto_comp;
9 9
10struct ipcomp_data { 10struct ipcomp_data {
11 u16 threshold; 11 u16 threshold;
12 struct crypto_comp **tfms; 12 struct crypto_comp * __percpu *tfms;
13}; 13};
14 14
15struct ip_comp_hdr; 15struct ip_comp_hdr;
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 7834f470d14a..da1d58be31b7 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -164,7 +164,7 @@ struct neigh_table {
164 rwlock_t lock; 164 rwlock_t lock;
165 unsigned long last_rand; 165 unsigned long last_rand;
166 struct kmem_cache *kmem_cachep; 166 struct kmem_cache *kmem_cachep;
167 struct neigh_statistics *stats; 167 struct neigh_statistics __percpu *stats;
168 struct neighbour **hash_buckets; 168 struct neighbour **hash_buckets;
169 unsigned int hash_mask; 169 unsigned int hash_mask;
170 __u32 hash_rnd; 170 __u32 hash_rnd;
diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
index 63d449807d9b..d4958d4c6574 100644
--- a/include/net/netns/conntrack.h
+++ b/include/net/netns/conntrack.h
@@ -17,7 +17,7 @@ struct netns_ct {
17 struct hlist_head *expect_hash; 17 struct hlist_head *expect_hash;
18 struct hlist_nulls_head unconfirmed; 18 struct hlist_nulls_head unconfirmed;
19 struct hlist_nulls_head dying; 19 struct hlist_nulls_head dying;
20 struct ip_conntrack_stat *stat; 20 struct ip_conntrack_stat __percpu *stat;
21 int sysctl_events; 21 int sysctl_events;
22 unsigned int sysctl_events_retry_timeout; 22 unsigned int sysctl_events_retry_timeout;
23 int sysctl_acct; 23 int sysctl_acct;
diff --git a/include/net/netns/core.h b/include/net/netns/core.h
index 24d4be76bbd1..78eb1ff75475 100644
--- a/include/net/netns/core.h
+++ b/include/net/netns/core.h
@@ -10,7 +10,7 @@ struct netns_core {
10 10
11 int sysctl_somaxconn; 11 int sysctl_somaxconn;
12 12
13 struct prot_inuse *inuse; 13 struct prot_inuse __percpu *inuse;
14}; 14};
15 15
16#endif 16#endif
diff --git a/include/net/route.h b/include/net/route.h
index bce6dd68d27b..2c9fba7f7731 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -101,7 +101,7 @@ struct rt_cache_stat {
101 unsigned int out_hlist_search; 101 unsigned int out_hlist_search;
102}; 102};
103 103
104extern struct ip_rt_acct *ip_rt_acct; 104extern struct ip_rt_acct __percpu *ip_rt_acct;
105 105
106struct in_device; 106struct in_device;
107extern int ip_rt_init(void); 107extern int ip_rt_init(void);
diff --git a/include/net/snmp.h b/include/net/snmp.h
index da02ee027d69..692ee0061dc4 100644
--- a/include/net/snmp.h
+++ b/include/net/snmp.h
@@ -129,9 +129,9 @@ struct linux_xfrm_mib {
129 * nonlocked_atomic_inc() primitives -AK 129 * nonlocked_atomic_inc() primitives -AK
130 */ 130 */
131#define DEFINE_SNMP_STAT(type, name) \ 131#define DEFINE_SNMP_STAT(type, name) \
132 __typeof__(type) *name[2] 132 __typeof__(type) __percpu *name[2]
133#define DECLARE_SNMP_STAT(type, name) \ 133#define DECLARE_SNMP_STAT(type, name) \
134 extern __typeof__(type) *name[2] 134 extern __typeof__(type) __percpu *name[2]
135 135
136#define SNMP_STAT_BHPTR(name) (name[0]) 136#define SNMP_STAT_BHPTR(name) (name[0])
137#define SNMP_STAT_USRPTR(name) (name[1]) 137#define SNMP_STAT_USRPTR(name) (name[1])
@@ -148,9 +148,13 @@ struct linux_xfrm_mib {
148 __this_cpu_add(mib[0]->mibs[field], addend) 148 __this_cpu_add(mib[0]->mibs[field], addend)
149#define SNMP_ADD_STATS_USER(mib, field, addend) \ 149#define SNMP_ADD_STATS_USER(mib, field, addend) \
150 this_cpu_add(mib[1]->mibs[field], addend) 150 this_cpu_add(mib[1]->mibs[field], addend)
151/*
152 * Use "__typeof__(*mib[0]) *ptr" instead of "__typeof__(mib[0]) ptr"
153 * to make @ptr a non-percpu pointer.
154 */
151#define SNMP_UPD_PO_STATS(mib, basefield, addend) \ 155#define SNMP_UPD_PO_STATS(mib, basefield, addend) \
152 do { \ 156 do { \
153 __typeof__(mib[0]) ptr; \ 157 __typeof__(*mib[0]) *ptr; \
154 preempt_disable(); \ 158 preempt_disable(); \
155 ptr = this_cpu_ptr((mib)[!in_softirq()]); \ 159 ptr = this_cpu_ptr((mib)[!in_softirq()]); \
156 ptr->mibs[basefield##PKTS]++; \ 160 ptr->mibs[basefield##PKTS]++; \
@@ -159,7 +163,7 @@ struct linux_xfrm_mib {
159 } while (0) 163 } while (0)
160#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \ 164#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
161 do { \ 165 do { \
162 __typeof__(mib[0]) ptr = \ 166 __typeof__(*mib[0]) *ptr = \
163 __this_cpu_ptr((mib)[!in_softirq()]); \ 167 __this_cpu_ptr((mib)[!in_softirq()]); \
164 ptr->mibs[basefield##PKTS]++; \ 168 ptr->mibs[basefield##PKTS]++; \
165 ptr->mibs[basefield##OCTETS] += addend;\ 169 ptr->mibs[basefield##OCTETS] += addend;\
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 87d164b9bd8f..75a00c80bdda 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1189,7 +1189,7 @@ extern int tcp_v4_md5_do_del(struct sock *sk,
1189#define tcp_twsk_md5_key(twsk) NULL 1189#define tcp_twsk_md5_key(twsk) NULL
1190#endif 1190#endif
1191 1191
1192extern struct tcp_md5sig_pool **tcp_alloc_md5sig_pool(struct sock *); 1192extern struct tcp_md5sig_pool * __percpu *tcp_alloc_md5sig_pool(struct sock *);
1193extern void tcp_free_md5sig_pool(void); 1193extern void tcp_free_md5sig_pool(void);
1194 1194
1195extern struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu); 1195extern struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu);