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>
This commit is contained in:
committed by
David S. Miller
parent
2bb4646fce
commit
7d720c3e4f
+3
-3
@@ -174,9 +174,9 @@ extern struct ipv4_config ipv4_config;
|
||||
#define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd)
|
||||
#define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd)
|
||||
|
||||
extern unsigned long snmp_fold_field(void *mib[], int offt);
|
||||
extern int snmp_mib_init(void *ptr[2], size_t mibsize);
|
||||
extern void snmp_mib_free(void *ptr[2]);
|
||||
extern unsigned long snmp_fold_field(void __percpu *mib[], int offt);
|
||||
extern int snmp_mib_init(void __percpu *ptr[2], size_t mibsize);
|
||||
extern void snmp_mib_free(void __percpu *ptr[2]);
|
||||
|
||||
extern struct local_ports {
|
||||
seqlock_t lock;
|
||||
|
||||
@@ -9,7 +9,7 @@ struct crypto_comp;
|
||||
|
||||
struct ipcomp_data {
|
||||
u16 threshold;
|
||||
struct crypto_comp **tfms;
|
||||
struct crypto_comp * __percpu *tfms;
|
||||
};
|
||||
|
||||
struct ip_comp_hdr;
|
||||
|
||||
@@ -164,7 +164,7 @@ struct neigh_table {
|
||||
rwlock_t lock;
|
||||
unsigned long last_rand;
|
||||
struct kmem_cache *kmem_cachep;
|
||||
struct neigh_statistics *stats;
|
||||
struct neigh_statistics __percpu *stats;
|
||||
struct neighbour **hash_buckets;
|
||||
unsigned int hash_mask;
|
||||
__u32 hash_rnd;
|
||||
|
||||
@@ -17,7 +17,7 @@ struct netns_ct {
|
||||
struct hlist_head *expect_hash;
|
||||
struct hlist_nulls_head unconfirmed;
|
||||
struct hlist_nulls_head dying;
|
||||
struct ip_conntrack_stat *stat;
|
||||
struct ip_conntrack_stat __percpu *stat;
|
||||
int sysctl_events;
|
||||
unsigned int sysctl_events_retry_timeout;
|
||||
int sysctl_acct;
|
||||
|
||||
@@ -10,7 +10,7 @@ struct netns_core {
|
||||
|
||||
int sysctl_somaxconn;
|
||||
|
||||
struct prot_inuse *inuse;
|
||||
struct prot_inuse __percpu *inuse;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ struct rt_cache_stat {
|
||||
unsigned int out_hlist_search;
|
||||
};
|
||||
|
||||
extern struct ip_rt_acct *ip_rt_acct;
|
||||
extern struct ip_rt_acct __percpu *ip_rt_acct;
|
||||
|
||||
struct in_device;
|
||||
extern int ip_rt_init(void);
|
||||
|
||||
+8
-4
@@ -129,9 +129,9 @@ struct linux_xfrm_mib {
|
||||
* nonlocked_atomic_inc() primitives -AK
|
||||
*/
|
||||
#define DEFINE_SNMP_STAT(type, name) \
|
||||
__typeof__(type) *name[2]
|
||||
__typeof__(type) __percpu *name[2]
|
||||
#define DECLARE_SNMP_STAT(type, name) \
|
||||
extern __typeof__(type) *name[2]
|
||||
extern __typeof__(type) __percpu *name[2]
|
||||
|
||||
#define SNMP_STAT_BHPTR(name) (name[0])
|
||||
#define SNMP_STAT_USRPTR(name) (name[1])
|
||||
@@ -148,9 +148,13 @@ struct linux_xfrm_mib {
|
||||
__this_cpu_add(mib[0]->mibs[field], addend)
|
||||
#define SNMP_ADD_STATS_USER(mib, field, addend) \
|
||||
this_cpu_add(mib[1]->mibs[field], addend)
|
||||
/*
|
||||
* Use "__typeof__(*mib[0]) *ptr" instead of "__typeof__(mib[0]) ptr"
|
||||
* to make @ptr a non-percpu pointer.
|
||||
*/
|
||||
#define SNMP_UPD_PO_STATS(mib, basefield, addend) \
|
||||
do { \
|
||||
__typeof__(mib[0]) ptr; \
|
||||
__typeof__(*mib[0]) *ptr; \
|
||||
preempt_disable(); \
|
||||
ptr = this_cpu_ptr((mib)[!in_softirq()]); \
|
||||
ptr->mibs[basefield##PKTS]++; \
|
||||
@@ -159,7 +163,7 @@ struct linux_xfrm_mib {
|
||||
} while (0)
|
||||
#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
|
||||
do { \
|
||||
__typeof__(mib[0]) ptr = \
|
||||
__typeof__(*mib[0]) *ptr = \
|
||||
__this_cpu_ptr((mib)[!in_softirq()]); \
|
||||
ptr->mibs[basefield##PKTS]++; \
|
||||
ptr->mibs[basefield##OCTETS] += addend;\
|
||||
|
||||
+1
-1
@@ -1189,7 +1189,7 @@ extern int tcp_v4_md5_do_del(struct sock *sk,
|
||||
#define tcp_twsk_md5_key(twsk) NULL
|
||||
#endif
|
||||
|
||||
extern struct tcp_md5sig_pool **tcp_alloc_md5sig_pool(struct sock *);
|
||||
extern struct tcp_md5sig_pool * __percpu *tcp_alloc_md5sig_pool(struct sock *);
|
||||
extern void tcp_free_md5sig_pool(void);
|
||||
|
||||
extern struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu);
|
||||
|
||||
Reference in New Issue
Block a user