aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/af_inet6.c
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2014-05-05 18:55:55 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-07 16:06:05 -0400
commit698365fa1874aa7635d51667a34a2842228e9837 (patch)
tree13230edeac756a36260bb2aef5d1b1da0cada7f9 /net/ipv6/af_inet6.c
parentd1f88a667c16e38d5a796b5fcdfd4ddbac1f638f (diff)
net: clean up snmp stats code
commit 8f0ea0fe3a036a47767f9c80e (snmp: reduce percpu needs by 50%) reduced snmp array size to 1, so technically it doesn't have to be an array any more. What's more, after the following commit: commit 933393f58fef9963eac61db8093689544e29a600 Date: Thu Dec 22 11:58:51 2011 -0600 percpu: Remove irqsafe_cpu_xxx variants We simply say that regular this_cpu use must be safe regardless of preemption and interrupt state. That has no material change for x86 and s390 implementations of this_cpu operations. However, arches that do not provide their own implementation for this_cpu operations will now get code generated that disables interrupts instead of preemption. probably no arch wants to have SNMP_ARRAY_SZ == 2. At least after almost 3 years, no one complains. So, just convert the array to a single pointer and remove snmp_mib_init() and snmp_mib_free() as well. Cc: Christoph Lameter <cl@linux.com> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/af_inet6.c')
-rw-r--r--net/ipv6/af_inet6.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index d935889f1008..dc47cc757b80 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -715,33 +715,25 @@ static int __net_init ipv6_init_mibs(struct net *net)
715{ 715{
716 int i; 716 int i;
717 717
718 if (snmp_mib_init((void __percpu **)net->mib.udp_stats_in6, 718 net->mib.udp_stats_in6 = alloc_percpu(struct udp_mib);
719 sizeof(struct udp_mib), 719 if (!net->mib.udp_stats_in6)
720 __alignof__(struct udp_mib)) < 0)
721 return -ENOMEM; 720 return -ENOMEM;
722 if (snmp_mib_init((void __percpu **)net->mib.udplite_stats_in6, 721 net->mib.udplite_stats_in6 = alloc_percpu(struct udp_mib);
723 sizeof(struct udp_mib), 722 if (!net->mib.udplite_stats_in6)
724 __alignof__(struct udp_mib)) < 0)
725 goto err_udplite_mib; 723 goto err_udplite_mib;
726 if (snmp_mib_init((void __percpu **)net->mib.ipv6_statistics, 724 net->mib.ipv6_statistics = alloc_percpu(struct ipstats_mib);
727 sizeof(struct ipstats_mib), 725 if (!net->mib.ipv6_statistics)
728 __alignof__(struct ipstats_mib)) < 0)
729 goto err_ip_mib; 726 goto err_ip_mib;
730 727
731 for_each_possible_cpu(i) { 728 for_each_possible_cpu(i) {
732 struct ipstats_mib *af_inet6_stats; 729 struct ipstats_mib *af_inet6_stats;
733 af_inet6_stats = per_cpu_ptr(net->mib.ipv6_statistics[0], i); 730 af_inet6_stats = per_cpu_ptr(net->mib.ipv6_statistics, i);
734 u64_stats_init(&af_inet6_stats->syncp); 731 u64_stats_init(&af_inet6_stats->syncp);
735#if SNMP_ARRAY_SZ == 2
736 af_inet6_stats = per_cpu_ptr(net->mib.ipv6_statistics[1], i);
737 u64_stats_init(&af_inet6_stats->syncp);
738#endif
739 } 732 }
740 733
741 734
742 if (snmp_mib_init((void __percpu **)net->mib.icmpv6_statistics, 735 net->mib.icmpv6_statistics = alloc_percpu(struct icmpv6_mib);
743 sizeof(struct icmpv6_mib), 736 if (!net->mib.icmpv6_statistics)
744 __alignof__(struct icmpv6_mib)) < 0)
745 goto err_icmp_mib; 737 goto err_icmp_mib;
746 net->mib.icmpv6msg_statistics = kzalloc(sizeof(struct icmpv6msg_mib), 738 net->mib.icmpv6msg_statistics = kzalloc(sizeof(struct icmpv6msg_mib),
747 GFP_KERNEL); 739 GFP_KERNEL);
@@ -750,22 +742,22 @@ static int __net_init ipv6_init_mibs(struct net *net)
750 return 0; 742 return 0;
751 743
752err_icmpmsg_mib: 744err_icmpmsg_mib:
753 snmp_mib_free((void __percpu **)net->mib.icmpv6_statistics); 745 free_percpu(net->mib.icmpv6_statistics);
754err_icmp_mib: 746err_icmp_mib:
755 snmp_mib_free((void __percpu **)net->mib.ipv6_statistics); 747 free_percpu(net->mib.ipv6_statistics);
756err_ip_mib: 748err_ip_mib:
757 snmp_mib_free((void __percpu **)net->mib.udplite_stats_in6); 749 free_percpu(net->mib.udplite_stats_in6);
758err_udplite_mib: 750err_udplite_mib:
759 snmp_mib_free((void __percpu **)net->mib.udp_stats_in6); 751 free_percpu(net->mib.udp_stats_in6);
760 return -ENOMEM; 752 return -ENOMEM;
761} 753}
762 754
763static void ipv6_cleanup_mibs(struct net *net) 755static void ipv6_cleanup_mibs(struct net *net)
764{ 756{
765 snmp_mib_free((void __percpu **)net->mib.udp_stats_in6); 757 free_percpu(net->mib.udp_stats_in6);
766 snmp_mib_free((void __percpu **)net->mib.udplite_stats_in6); 758 free_percpu(net->mib.udplite_stats_in6);
767 snmp_mib_free((void __percpu **)net->mib.ipv6_statistics); 759 free_percpu(net->mib.ipv6_statistics);
768 snmp_mib_free((void __percpu **)net->mib.icmpv6_statistics); 760 free_percpu(net->mib.icmpv6_statistics);
769 kfree(net->mib.icmpv6msg_statistics); 761 kfree(net->mib.icmpv6msg_statistics);
770} 762}
771 763