diff options
author | Kefeng Wang <wangkefeng.wang@huawei.com> | 2019-02-23 10:28:28 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-02-25 08:57:26 +0300 |
commit | 75efc250d2e57c43761890388a92eecd93aa9e45 (patch) | |
tree | 108b0c8bb7987e7c97f5e9e9cfa4b1153e199769 /net/ipv6 | |
parent | 3232a1ef0f0d1b8d3c5bb4d5b3584fa45d29f760 (diff) | |
download | linux-75efc250d2e57c43761890388a92eecd93aa9e45.tar.xz |
ipv6: icmp: use percpu allocation
Use percpu allocation for the ipv6.icmp_sk.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/icmp.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index af520014def5..802faa2fcc0e 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -81,7 +81,7 @@ */ 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, @@ -958,8 +958,8 @@ static void __net_exit icmpv6_sk_exit(struct net *net) int i; for_each_possible_cpu(i) - inet_ctl_sock_destroy(net->ipv6.icmp_sk[i]); - kfree(net->ipv6.icmp_sk); + inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv6.icmp_sk, i)); + free_percpu(net->ipv6.icmp_sk); } 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; int err, i; - net->ipv6.icmp_sk = - kcalloc(nr_cpu_ids, sizeof(struct sock *), GFP_KERNEL); + net->ipv6.icmp_sk = alloc_percpu(struct sock *); if (!net->ipv6.icmp_sk) return -ENOMEM; @@ -981,7 +980,7 @@ static int __net_init icmpv6_sk_init(struct net *net) 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 * sk_buff struct overhead. |