aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
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 /net/ipv4/tcp.c
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 'net/ipv4/tcp.c')
-rw-r--r--net/ipv4/tcp.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index d5d69ea8f249..e471d037fcc9 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2788,10 +2788,10 @@ EXPORT_SYMBOL(tcp_gro_complete);
2788 2788
2789#ifdef CONFIG_TCP_MD5SIG 2789#ifdef CONFIG_TCP_MD5SIG
2790static unsigned long tcp_md5sig_users; 2790static unsigned long tcp_md5sig_users;
2791static struct tcp_md5sig_pool **tcp_md5sig_pool; 2791static struct tcp_md5sig_pool * __percpu *tcp_md5sig_pool;
2792static DEFINE_SPINLOCK(tcp_md5sig_pool_lock); 2792static DEFINE_SPINLOCK(tcp_md5sig_pool_lock);
2793 2793
2794static void __tcp_free_md5sig_pool(struct tcp_md5sig_pool **pool) 2794static void __tcp_free_md5sig_pool(struct tcp_md5sig_pool * __percpu *pool)
2795{ 2795{
2796 int cpu; 2796 int cpu;
2797 for_each_possible_cpu(cpu) { 2797 for_each_possible_cpu(cpu) {
@@ -2808,7 +2808,7 @@ static void __tcp_free_md5sig_pool(struct tcp_md5sig_pool **pool)
2808 2808
2809void tcp_free_md5sig_pool(void) 2809void tcp_free_md5sig_pool(void)
2810{ 2810{
2811 struct tcp_md5sig_pool **pool = NULL; 2811 struct tcp_md5sig_pool * __percpu *pool = NULL;
2812 2812
2813 spin_lock_bh(&tcp_md5sig_pool_lock); 2813 spin_lock_bh(&tcp_md5sig_pool_lock);
2814 if (--tcp_md5sig_users == 0) { 2814 if (--tcp_md5sig_users == 0) {
@@ -2822,10 +2822,11 @@ void tcp_free_md5sig_pool(void)
2822 2822
2823EXPORT_SYMBOL(tcp_free_md5sig_pool); 2823EXPORT_SYMBOL(tcp_free_md5sig_pool);
2824 2824
2825static struct tcp_md5sig_pool **__tcp_alloc_md5sig_pool(struct sock *sk) 2825static struct tcp_md5sig_pool * __percpu *
2826__tcp_alloc_md5sig_pool(struct sock *sk)
2826{ 2827{
2827 int cpu; 2828 int cpu;
2828 struct tcp_md5sig_pool **pool; 2829 struct tcp_md5sig_pool * __percpu *pool;
2829 2830
2830 pool = alloc_percpu(struct tcp_md5sig_pool *); 2831 pool = alloc_percpu(struct tcp_md5sig_pool *);
2831 if (!pool) 2832 if (!pool)
@@ -2852,9 +2853,9 @@ out_free:
2852 return NULL; 2853 return NULL;
2853} 2854}
2854 2855
2855struct tcp_md5sig_pool **tcp_alloc_md5sig_pool(struct sock *sk) 2856struct tcp_md5sig_pool * __percpu *tcp_alloc_md5sig_pool(struct sock *sk)
2856{ 2857{
2857 struct tcp_md5sig_pool **pool; 2858 struct tcp_md5sig_pool * __percpu *pool;
2858 int alloc = 0; 2859 int alloc = 0;
2859 2860
2860retry: 2861retry:
@@ -2873,7 +2874,9 @@ retry:
2873 2874
2874 if (alloc) { 2875 if (alloc) {
2875 /* we cannot hold spinlock here because this may sleep. */ 2876 /* we cannot hold spinlock here because this may sleep. */
2876 struct tcp_md5sig_pool **p = __tcp_alloc_md5sig_pool(sk); 2877 struct tcp_md5sig_pool * __percpu *p;
2878
2879 p = __tcp_alloc_md5sig_pool(sk);
2877 spin_lock_bh(&tcp_md5sig_pool_lock); 2880 spin_lock_bh(&tcp_md5sig_pool_lock);
2878 if (!p) { 2881 if (!p) {
2879 tcp_md5sig_users--; 2882 tcp_md5sig_users--;
@@ -2897,7 +2900,7 @@ EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
2897 2900
2898struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu) 2901struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu)
2899{ 2902{
2900 struct tcp_md5sig_pool **p; 2903 struct tcp_md5sig_pool * __percpu *p;
2901 spin_lock_bh(&tcp_md5sig_pool_lock); 2904 spin_lock_bh(&tcp_md5sig_pool_lock);
2902 p = tcp_md5sig_pool; 2905 p = tcp_md5sig_pool;
2903 if (p) 2906 if (p)