Commit 75efc250 authored by Kefeng Wang's avatar Kefeng Wang Committed by David S. Miller

ipv6: icmp: use percpu allocation

Use percpu allocation for the ipv6.icmp_sk.
Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3232a1ef
...@@ -83,7 +83,7 @@ struct netns_ipv6 { ...@@ -83,7 +83,7 @@ struct netns_ipv6 {
struct fib6_table *fib6_local_tbl; struct fib6_table *fib6_local_tbl;
struct fib_rules_ops *fib6_rules_ops; struct fib_rules_ops *fib6_rules_ops;
#endif #endif
struct sock **icmp_sk; struct sock * __percpu *icmp_sk;
struct sock *ndisc_sk; struct sock *ndisc_sk;
struct sock *tcp_sk; struct sock *tcp_sk;
struct sock *igmp_sk; struct sock *igmp_sk;
......
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
*/ */
static inline struct sock *icmpv6_sk(struct net *net) static inline struct sock *icmpv6_sk(struct net *net)
{ {
return net->ipv6.icmp_sk[smp_processor_id()]; return *this_cpu_ptr(net->ipv6.icmp_sk);
} }
static int icmpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, static int icmpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
...@@ -958,8 +958,8 @@ static void __net_exit icmpv6_sk_exit(struct net *net) ...@@ -958,8 +958,8 @@ static void __net_exit icmpv6_sk_exit(struct net *net)
int i; int i;
for_each_possible_cpu(i) for_each_possible_cpu(i)
inet_ctl_sock_destroy(net->ipv6.icmp_sk[i]); inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv6.icmp_sk, i));
kfree(net->ipv6.icmp_sk); free_percpu(net->ipv6.icmp_sk);
} }
static int __net_init icmpv6_sk_init(struct net *net) static int __net_init icmpv6_sk_init(struct net *net)
...@@ -967,8 +967,7 @@ static int __net_init icmpv6_sk_init(struct net *net) ...@@ -967,8 +967,7 @@ static int __net_init icmpv6_sk_init(struct net *net)
struct sock *sk; struct sock *sk;
int err, i; int err, i;
net->ipv6.icmp_sk = net->ipv6.icmp_sk = alloc_percpu(struct sock *);
kcalloc(nr_cpu_ids, sizeof(struct sock *), GFP_KERNEL);
if (!net->ipv6.icmp_sk) if (!net->ipv6.icmp_sk)
return -ENOMEM; return -ENOMEM;
...@@ -981,7 +980,7 @@ static int __net_init icmpv6_sk_init(struct net *net) ...@@ -981,7 +980,7 @@ static int __net_init icmpv6_sk_init(struct net *net)
goto fail; goto fail;
} }
net->ipv6.icmp_sk[i] = sk; *per_cpu_ptr(net->ipv6.icmp_sk, i) = sk;
/* Enough space for 2 64K ICMP packets, including /* Enough space for 2 64K ICMP packets, including
* sk_buff struct overhead. * sk_buff struct overhead.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment