diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2014-05-05 18:55:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-05-07 16:06:05 -0400 |
commit | 698365fa1874aa7635d51667a34a2842228e9837 (patch) | |
tree | 13230edeac756a36260bb2aef5d1b1da0cada7f9 | |
parent | d1f88a667c16e38d5a796b5fcdfd4ddbac1f638f (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>
-rw-r--r-- | include/net/ip.h | 18 | ||||
-rw-r--r-- | include/net/snmp.h | 32 | ||||
-rw-r--r-- | net/dccp/proto.c | 9 | ||||
-rw-r--r-- | net/ipv4/af_inet.c | 93 | ||||
-rw-r--r-- | net/ipv4/proc.c | 24 | ||||
-rw-r--r-- | net/ipv6/addrconf.c | 17 | ||||
-rw-r--r-- | net/ipv6/addrconf_core.c | 2 | ||||
-rw-r--r-- | net/ipv6/af_inet6.c | 42 | ||||
-rw-r--r-- | net/ipv6/proc.c | 6 | ||||
-rw-r--r-- | net/sctp/protocol.c | 9 | ||||
-rw-r--r-- | net/xfrm/xfrm_policy.c | 10 | ||||
-rw-r--r-- | net/xfrm/xfrm_proc.c | 3 |
12 files changed, 103 insertions, 162 deletions
diff --git a/include/net/ip.h b/include/net/ip.h index 1988cefdbb70..16146b667ddb 100644 --- a/include/net/ip.h +++ b/include/net/ip.h | |||
@@ -196,27 +196,15 @@ void ip_send_unicast_reply(struct net *net, struct sk_buff *skb, __be32 daddr, | |||
196 | #define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd) | 196 | #define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd) |
197 | #define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd) | 197 | #define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd) |
198 | 198 | ||
199 | unsigned long snmp_fold_field(void __percpu *mib[], int offt); | 199 | unsigned long snmp_fold_field(void __percpu *mib, int offt); |
200 | #if BITS_PER_LONG==32 | 200 | #if BITS_PER_LONG==32 |
201 | u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t sync_off); | 201 | u64 snmp_fold_field64(void __percpu *mib, int offt, size_t sync_off); |
202 | #else | 202 | #else |
203 | static inline u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t syncp_off) | 203 | static inline u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_off) |
204 | { | 204 | { |
205 | return snmp_fold_field(mib, offt); | 205 | return snmp_fold_field(mib, offt); |
206 | } | 206 | } |
207 | #endif | 207 | #endif |
208 | int snmp_mib_init(void __percpu *ptr[2], size_t mibsize, size_t align); | ||
209 | |||
210 | static inline void snmp_mib_free(void __percpu *ptr[SNMP_ARRAY_SZ]) | ||
211 | { | ||
212 | int i; | ||
213 | |||
214 | BUG_ON(ptr == NULL); | ||
215 | for (i = 0; i < SNMP_ARRAY_SZ; i++) { | ||
216 | free_percpu(ptr[i]); | ||
217 | ptr[i] = NULL; | ||
218 | } | ||
219 | } | ||
220 | 208 | ||
221 | void inet_get_local_port_range(struct net *net, int *low, int *high); | 209 | void inet_get_local_port_range(struct net *net, int *low, int *high); |
222 | 210 | ||
diff --git a/include/net/snmp.h b/include/net/snmp.h index 71596261fa99..f1f27fdbb0d5 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h | |||
@@ -116,51 +116,49 @@ struct linux_xfrm_mib { | |||
116 | unsigned long mibs[LINUX_MIB_XFRMMAX]; | 116 | unsigned long mibs[LINUX_MIB_XFRMMAX]; |
117 | }; | 117 | }; |
118 | 118 | ||
119 | #define SNMP_ARRAY_SZ 1 | ||
120 | |||
121 | #define DEFINE_SNMP_STAT(type, name) \ | 119 | #define DEFINE_SNMP_STAT(type, name) \ |
122 | __typeof__(type) __percpu *name[SNMP_ARRAY_SZ] | 120 | __typeof__(type) __percpu *name |
123 | #define DEFINE_SNMP_STAT_ATOMIC(type, name) \ | 121 | #define DEFINE_SNMP_STAT_ATOMIC(type, name) \ |
124 | __typeof__(type) *name | 122 | __typeof__(type) *name |
125 | #define DECLARE_SNMP_STAT(type, name) \ | 123 | #define DECLARE_SNMP_STAT(type, name) \ |
126 | extern __typeof__(type) __percpu *name[SNMP_ARRAY_SZ] | 124 | extern __typeof__(type) __percpu *name |
127 | 125 | ||
128 | #define SNMP_INC_STATS_BH(mib, field) \ | 126 | #define SNMP_INC_STATS_BH(mib, field) \ |
129 | __this_cpu_inc(mib[0]->mibs[field]) | 127 | __this_cpu_inc(mib->mibs[field]) |
130 | 128 | ||
131 | #define SNMP_INC_STATS_USER(mib, field) \ | 129 | #define SNMP_INC_STATS_USER(mib, field) \ |
132 | this_cpu_inc(mib[0]->mibs[field]) | 130 | this_cpu_inc(mib->mibs[field]) |
133 | 131 | ||
134 | #define SNMP_INC_STATS_ATOMIC_LONG(mib, field) \ | 132 | #define SNMP_INC_STATS_ATOMIC_LONG(mib, field) \ |
135 | atomic_long_inc(&mib->mibs[field]) | 133 | atomic_long_inc(&mib->mibs[field]) |
136 | 134 | ||
137 | #define SNMP_INC_STATS(mib, field) \ | 135 | #define SNMP_INC_STATS(mib, field) \ |
138 | this_cpu_inc(mib[0]->mibs[field]) | 136 | this_cpu_inc(mib->mibs[field]) |
139 | 137 | ||
140 | #define SNMP_DEC_STATS(mib, field) \ | 138 | #define SNMP_DEC_STATS(mib, field) \ |
141 | this_cpu_dec(mib[0]->mibs[field]) | 139 | this_cpu_dec(mib->mibs[field]) |
142 | 140 | ||
143 | #define SNMP_ADD_STATS_BH(mib, field, addend) \ | 141 | #define SNMP_ADD_STATS_BH(mib, field, addend) \ |
144 | __this_cpu_add(mib[0]->mibs[field], addend) | 142 | __this_cpu_add(mib->mibs[field], addend) |
145 | 143 | ||
146 | #define SNMP_ADD_STATS_USER(mib, field, addend) \ | 144 | #define SNMP_ADD_STATS_USER(mib, field, addend) \ |
147 | this_cpu_add(mib[0]->mibs[field], addend) | 145 | this_cpu_add(mib->mibs[field], addend) |
148 | 146 | ||
149 | #define SNMP_ADD_STATS(mib, field, addend) \ | 147 | #define SNMP_ADD_STATS(mib, field, addend) \ |
150 | this_cpu_add(mib[0]->mibs[field], addend) | 148 | this_cpu_add(mib->mibs[field], addend) |
151 | /* | 149 | /* |
152 | * Use "__typeof__(*mib[0]) *ptr" instead of "__typeof__(mib[0]) ptr" | 150 | * Use "__typeof__(*mib) *ptr" instead of "__typeof__(mib) ptr" |
153 | * to make @ptr a non-percpu pointer. | 151 | * to make @ptr a non-percpu pointer. |
154 | */ | 152 | */ |
155 | #define SNMP_UPD_PO_STATS(mib, basefield, addend) \ | 153 | #define SNMP_UPD_PO_STATS(mib, basefield, addend) \ |
156 | do { \ | 154 | do { \ |
157 | __typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs; \ | 155 | __typeof__(*mib->mibs) *ptr = mib->mibs; \ |
158 | this_cpu_inc(ptr[basefield##PKTS]); \ | 156 | this_cpu_inc(ptr[basefield##PKTS]); \ |
159 | this_cpu_add(ptr[basefield##OCTETS], addend); \ | 157 | this_cpu_add(ptr[basefield##OCTETS], addend); \ |
160 | } while (0) | 158 | } while (0) |
161 | #define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \ | 159 | #define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \ |
162 | do { \ | 160 | do { \ |
163 | __typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs; \ | 161 | __typeof__(*mib->mibs) *ptr = mib->mibs; \ |
164 | __this_cpu_inc(ptr[basefield##PKTS]); \ | 162 | __this_cpu_inc(ptr[basefield##PKTS]); \ |
165 | __this_cpu_add(ptr[basefield##OCTETS], addend); \ | 163 | __this_cpu_add(ptr[basefield##OCTETS], addend); \ |
166 | } while (0) | 164 | } while (0) |
@@ -170,7 +168,7 @@ struct linux_xfrm_mib { | |||
170 | 168 | ||
171 | #define SNMP_ADD_STATS64_BH(mib, field, addend) \ | 169 | #define SNMP_ADD_STATS64_BH(mib, field, addend) \ |
172 | do { \ | 170 | do { \ |
173 | __typeof__(*mib[0]) *ptr = __this_cpu_ptr((mib)[0]); \ | 171 | __typeof__(*mib) *ptr = __this_cpu_ptr(mib); \ |
174 | u64_stats_update_begin(&ptr->syncp); \ | 172 | u64_stats_update_begin(&ptr->syncp); \ |
175 | ptr->mibs[field] += addend; \ | 173 | ptr->mibs[field] += addend; \ |
176 | u64_stats_update_end(&ptr->syncp); \ | 174 | u64_stats_update_end(&ptr->syncp); \ |
@@ -191,8 +189,8 @@ struct linux_xfrm_mib { | |||
191 | #define SNMP_INC_STATS64(mib, field) SNMP_ADD_STATS64(mib, field, 1) | 189 | #define SNMP_INC_STATS64(mib, field) SNMP_ADD_STATS64(mib, field, 1) |
192 | #define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) \ | 190 | #define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) \ |
193 | do { \ | 191 | do { \ |
194 | __typeof__(*mib[0]) *ptr; \ | 192 | __typeof__(*mib) *ptr; \ |
195 | ptr = __this_cpu_ptr((mib)[0]); \ | 193 | ptr = __this_cpu_ptr(mib); \ |
196 | u64_stats_update_begin(&ptr->syncp); \ | 194 | u64_stats_update_begin(&ptr->syncp); \ |
197 | ptr->mibs[basefield##PKTS]++; \ | 195 | ptr->mibs[basefield##PKTS]++; \ |
198 | ptr->mibs[basefield##OCTETS] += addend; \ | 196 | ptr->mibs[basefield##OCTETS] += addend; \ |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index eb892b4f4814..de2c1e719305 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -1084,14 +1084,15 @@ EXPORT_SYMBOL_GPL(dccp_shutdown); | |||
1084 | 1084 | ||
1085 | static inline int dccp_mib_init(void) | 1085 | static inline int dccp_mib_init(void) |
1086 | { | 1086 | { |
1087 | return snmp_mib_init((void __percpu **)dccp_statistics, | 1087 | dccp_statistics = alloc_percpu(struct dccp_mib); |
1088 | sizeof(struct dccp_mib), | 1088 | if (!dccp_statistics) |
1089 | __alignof__(struct dccp_mib)); | 1089 | return -ENOMEM; |
1090 | return 0; | ||
1090 | } | 1091 | } |
1091 | 1092 | ||
1092 | static inline void dccp_mib_exit(void) | 1093 | static inline void dccp_mib_exit(void) |
1093 | { | 1094 | { |
1094 | snmp_mib_free((void __percpu **)dccp_statistics); | 1095 | free_percpu(dccp_statistics); |
1095 | } | 1096 | } |
1096 | 1097 | ||
1097 | static int thash_entries; | 1098 | static int thash_entries; |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 8c54870db792..6765d91b8e75 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -1476,22 +1476,20 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family, | |||
1476 | } | 1476 | } |
1477 | EXPORT_SYMBOL_GPL(inet_ctl_sock_create); | 1477 | EXPORT_SYMBOL_GPL(inet_ctl_sock_create); |
1478 | 1478 | ||
1479 | unsigned long snmp_fold_field(void __percpu *mib[], int offt) | 1479 | unsigned long snmp_fold_field(void __percpu *mib, int offt) |
1480 | { | 1480 | { |
1481 | unsigned long res = 0; | 1481 | unsigned long res = 0; |
1482 | int i, j; | 1482 | int i; |
1483 | 1483 | ||
1484 | for_each_possible_cpu(i) { | 1484 | for_each_possible_cpu(i) |
1485 | for (j = 0; j < SNMP_ARRAY_SZ; j++) | 1485 | res += *(((unsigned long *) per_cpu_ptr(mib, i)) + offt); |
1486 | res += *(((unsigned long *) per_cpu_ptr(mib[j], i)) + offt); | ||
1487 | } | ||
1488 | return res; | 1486 | return res; |
1489 | } | 1487 | } |
1490 | EXPORT_SYMBOL_GPL(snmp_fold_field); | 1488 | EXPORT_SYMBOL_GPL(snmp_fold_field); |
1491 | 1489 | ||
1492 | #if BITS_PER_LONG==32 | 1490 | #if BITS_PER_LONG==32 |
1493 | 1491 | ||
1494 | u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t syncp_offset) | 1492 | u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_offset) |
1495 | { | 1493 | { |
1496 | u64 res = 0; | 1494 | u64 res = 0; |
1497 | int cpu; | 1495 | int cpu; |
@@ -1502,7 +1500,7 @@ u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t syncp_offset) | |||
1502 | u64 v; | 1500 | u64 v; |
1503 | unsigned int start; | 1501 | unsigned int start; |
1504 | 1502 | ||
1505 | bhptr = per_cpu_ptr(mib[0], cpu); | 1503 | bhptr = per_cpu_ptr(mib, cpu); |
1506 | syncp = (struct u64_stats_sync *)(bhptr + syncp_offset); | 1504 | syncp = (struct u64_stats_sync *)(bhptr + syncp_offset); |
1507 | do { | 1505 | do { |
1508 | start = u64_stats_fetch_begin_irq(syncp); | 1506 | start = u64_stats_fetch_begin_irq(syncp); |
@@ -1516,25 +1514,6 @@ u64 snmp_fold_field64(void __percpu *mib[], int offt, size_t syncp_offset) | |||
1516 | EXPORT_SYMBOL_GPL(snmp_fold_field64); | 1514 | EXPORT_SYMBOL_GPL(snmp_fold_field64); |
1517 | #endif | 1515 | #endif |
1518 | 1516 | ||
1519 | int snmp_mib_init(void __percpu *ptr[2], size_t mibsize, size_t align) | ||
1520 | { | ||
1521 | BUG_ON(ptr == NULL); | ||
1522 | ptr[0] = __alloc_percpu(mibsize, align); | ||
1523 | if (!ptr[0]) | ||
1524 | return -ENOMEM; | ||
1525 | |||
1526 | #if SNMP_ARRAY_SZ == 2 | ||
1527 | ptr[1] = __alloc_percpu(mibsize, align); | ||
1528 | if (!ptr[1]) { | ||
1529 | free_percpu(ptr[0]); | ||
1530 | ptr[0] = NULL; | ||
1531 | return -ENOMEM; | ||
1532 | } | ||
1533 | #endif | ||
1534 | return 0; | ||
1535 | } | ||
1536 | EXPORT_SYMBOL_GPL(snmp_mib_init); | ||
1537 | |||
1538 | #ifdef CONFIG_IP_MULTICAST | 1517 | #ifdef CONFIG_IP_MULTICAST |
1539 | static const struct net_protocol igmp_protocol = { | 1518 | static const struct net_protocol igmp_protocol = { |
1540 | .handler = igmp_rcv, | 1519 | .handler = igmp_rcv, |
@@ -1570,40 +1549,30 @@ static __net_init int ipv4_mib_init_net(struct net *net) | |||
1570 | { | 1549 | { |
1571 | int i; | 1550 | int i; |
1572 | 1551 | ||
1573 | if (snmp_mib_init((void __percpu **)net->mib.tcp_statistics, | 1552 | net->mib.tcp_statistics = alloc_percpu(struct tcp_mib); |
1574 | sizeof(struct tcp_mib), | 1553 | if (!net->mib.tcp_statistics) |
1575 | __alignof__(struct tcp_mib)) < 0) | ||
1576 | goto err_tcp_mib; | 1554 | goto err_tcp_mib; |
1577 | if (snmp_mib_init((void __percpu **)net->mib.ip_statistics, | 1555 | net->mib.ip_statistics = alloc_percpu(struct ipstats_mib); |
1578 | sizeof(struct ipstats_mib), | 1556 | if (!net->mib.ip_statistics) |
1579 | __alignof__(struct ipstats_mib)) < 0) | ||
1580 | goto err_ip_mib; | 1557 | goto err_ip_mib; |
1581 | 1558 | ||
1582 | for_each_possible_cpu(i) { | 1559 | for_each_possible_cpu(i) { |
1583 | struct ipstats_mib *af_inet_stats; | 1560 | struct ipstats_mib *af_inet_stats; |
1584 | af_inet_stats = per_cpu_ptr(net->mib.ip_statistics[0], i); | 1561 | af_inet_stats = per_cpu_ptr(net->mib.ip_statistics, i); |
1585 | u64_stats_init(&af_inet_stats->syncp); | 1562 | u64_stats_init(&af_inet_stats->syncp); |
1586 | #if SNMP_ARRAY_SZ == 2 | ||
1587 | af_inet_stats = per_cpu_ptr(net->mib.ip_statistics[1], i); | ||
1588 | u64_stats_init(&af_inet_stats->syncp); | ||
1589 | #endif | ||
1590 | } | 1563 | } |
1591 | 1564 | ||
1592 | if (snmp_mib_init((void __percpu **)net->mib.net_statistics, | 1565 | net->mib.net_statistics = alloc_percpu(struct linux_mib); |
1593 | sizeof(struct linux_mib), | 1566 | if (!net->mib.net_statistics) |
1594 | __alignof__(struct linux_mib)) < 0) | ||
1595 | goto err_net_mib; | 1567 | goto err_net_mib; |
1596 | if (snmp_mib_init((void __percpu **)net->mib.udp_statistics, | 1568 | net->mib.udp_statistics = alloc_percpu(struct udp_mib); |
1597 | sizeof(struct udp_mib), | 1569 | if (!net->mib.udp_statistics) |
1598 | __alignof__(struct udp_mib)) < 0) | ||
1599 | goto err_udp_mib; | 1570 | goto err_udp_mib; |
1600 | if (snmp_mib_init((void __percpu **)net->mib.udplite_statistics, | 1571 | net->mib.udplite_statistics = alloc_percpu(struct udp_mib); |
1601 | sizeof(struct udp_mib), | 1572 | if (!net->mib.udplite_statistics) |
1602 | __alignof__(struct udp_mib)) < 0) | ||
1603 | goto err_udplite_mib; | 1573 | goto err_udplite_mib; |
1604 | if (snmp_mib_init((void __percpu **)net->mib.icmp_statistics, | 1574 | net->mib.icmp_statistics = alloc_percpu(struct icmp_mib); |
1605 | sizeof(struct icmp_mib), | 1575 | if (!net->mib.icmp_statistics) |
1606 | __alignof__(struct icmp_mib)) < 0) | ||
1607 | goto err_icmp_mib; | 1576 | goto err_icmp_mib; |
1608 | net->mib.icmpmsg_statistics = kzalloc(sizeof(struct icmpmsg_mib), | 1577 | net->mib.icmpmsg_statistics = kzalloc(sizeof(struct icmpmsg_mib), |
1609 | GFP_KERNEL); | 1578 | GFP_KERNEL); |
@@ -1614,17 +1583,17 @@ static __net_init int ipv4_mib_init_net(struct net *net) | |||
1614 | return 0; | 1583 | return 0; |
1615 | 1584 | ||
1616 | err_icmpmsg_mib: | 1585 | err_icmpmsg_mib: |
1617 | snmp_mib_free((void __percpu **)net->mib.icmp_statistics); | 1586 | free_percpu(net->mib.icmp_statistics); |
1618 | err_icmp_mib: | 1587 | err_icmp_mib: |
1619 | snmp_mib_free((void __percpu **)net->mib.udplite_statistics); | 1588 | free_percpu(net->mib.udplite_statistics); |
1620 | err_udplite_mib: | 1589 | err_udplite_mib: |
1621 | snmp_mib_free((void __percpu **)net->mib.udp_statistics); | 1590 | free_percpu(net->mib.udp_statistics); |
1622 | err_udp_mib: | 1591 | err_udp_mib: |
1623 | snmp_mib_free((void __percpu **)net->mib.net_statistics); | 1592 | free_percpu(net->mib.net_statistics); |
1624 | err_net_mib: | 1593 | err_net_mib: |
1625 | snmp_mib_free((void __percpu **)net->mib.ip_statistics); | 1594 | free_percpu(net->mib.ip_statistics); |
1626 | err_ip_mib: | 1595 | err_ip_mib: |
1627 | snmp_mib_free((void __percpu **)net->mib.tcp_statistics); | 1596 | free_percpu(net->mib.tcp_statistics); |
1628 | err_tcp_mib: | 1597 | err_tcp_mib: |
1629 | return -ENOMEM; | 1598 | return -ENOMEM; |
1630 | } | 1599 | } |
@@ -1632,12 +1601,12 @@ err_tcp_mib: | |||
1632 | static __net_exit void ipv4_mib_exit_net(struct net *net) | 1601 | static __net_exit void ipv4_mib_exit_net(struct net *net) |
1633 | { | 1602 | { |
1634 | kfree(net->mib.icmpmsg_statistics); | 1603 | kfree(net->mib.icmpmsg_statistics); |
1635 | snmp_mib_free((void __percpu **)net->mib.icmp_statistics); | 1604 | free_percpu(net->mib.icmp_statistics); |
1636 | snmp_mib_free((void __percpu **)net->mib.udplite_statistics); | 1605 | free_percpu(net->mib.udplite_statistics); |
1637 | snmp_mib_free((void __percpu **)net->mib.udp_statistics); | 1606 | free_percpu(net->mib.udp_statistics); |
1638 | snmp_mib_free((void __percpu **)net->mib.net_statistics); | 1607 | free_percpu(net->mib.net_statistics); |
1639 | snmp_mib_free((void __percpu **)net->mib.ip_statistics); | 1608 | free_percpu(net->mib.ip_statistics); |
1640 | snmp_mib_free((void __percpu **)net->mib.tcp_statistics); | 1609 | free_percpu(net->mib.tcp_statistics); |
1641 | } | 1610 | } |
1642 | 1611 | ||
1643 | static __net_initdata struct pernet_operations ipv4_mib_ops = { | 1612 | static __net_initdata struct pernet_operations ipv4_mib_ops = { |
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index ad737fad6d8b..ae0af9386f7c 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
@@ -345,15 +345,15 @@ static void icmp_put(struct seq_file *seq) | |||
345 | for (i = 0; icmpmibmap[i].name != NULL; i++) | 345 | for (i = 0; icmpmibmap[i].name != NULL; i++) |
346 | seq_printf(seq, " Out%s", icmpmibmap[i].name); | 346 | seq_printf(seq, " Out%s", icmpmibmap[i].name); |
347 | seq_printf(seq, "\nIcmp: %lu %lu %lu", | 347 | seq_printf(seq, "\nIcmp: %lu %lu %lu", |
348 | snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_INMSGS), | 348 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_INMSGS), |
349 | snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_INERRORS), | 349 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_INERRORS), |
350 | snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_CSUMERRORS)); | 350 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_CSUMERRORS)); |
351 | for (i = 0; icmpmibmap[i].name != NULL; i++) | 351 | for (i = 0; icmpmibmap[i].name != NULL; i++) |
352 | seq_printf(seq, " %lu", | 352 | seq_printf(seq, " %lu", |
353 | atomic_long_read(ptr + icmpmibmap[i].index)); | 353 | atomic_long_read(ptr + icmpmibmap[i].index)); |
354 | seq_printf(seq, " %lu %lu", | 354 | seq_printf(seq, " %lu %lu", |
355 | snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_OUTMSGS), | 355 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_OUTMSGS), |
356 | snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_OUTERRORS)); | 356 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_OUTERRORS)); |
357 | for (i = 0; icmpmibmap[i].name != NULL; i++) | 357 | for (i = 0; icmpmibmap[i].name != NULL; i++) |
358 | seq_printf(seq, " %lu", | 358 | seq_printf(seq, " %lu", |
359 | atomic_long_read(ptr + (icmpmibmap[i].index | 0x100))); | 359 | atomic_long_read(ptr + (icmpmibmap[i].index | 0x100))); |
@@ -379,7 +379,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v) | |||
379 | BUILD_BUG_ON(offsetof(struct ipstats_mib, mibs) != 0); | 379 | BUILD_BUG_ON(offsetof(struct ipstats_mib, mibs) != 0); |
380 | for (i = 0; snmp4_ipstats_list[i].name != NULL; i++) | 380 | for (i = 0; snmp4_ipstats_list[i].name != NULL; i++) |
381 | seq_printf(seq, " %llu", | 381 | seq_printf(seq, " %llu", |
382 | snmp_fold_field64((void __percpu **)net->mib.ip_statistics, | 382 | snmp_fold_field64(net->mib.ip_statistics, |
383 | snmp4_ipstats_list[i].entry, | 383 | snmp4_ipstats_list[i].entry, |
384 | offsetof(struct ipstats_mib, syncp))); | 384 | offsetof(struct ipstats_mib, syncp))); |
385 | 385 | ||
@@ -395,11 +395,11 @@ static int snmp_seq_show(struct seq_file *seq, void *v) | |||
395 | /* MaxConn field is signed, RFC 2012 */ | 395 | /* MaxConn field is signed, RFC 2012 */ |
396 | if (snmp4_tcp_list[i].entry == TCP_MIB_MAXCONN) | 396 | if (snmp4_tcp_list[i].entry == TCP_MIB_MAXCONN) |
397 | seq_printf(seq, " %ld", | 397 | seq_printf(seq, " %ld", |
398 | snmp_fold_field((void __percpu **)net->mib.tcp_statistics, | 398 | snmp_fold_field(net->mib.tcp_statistics, |
399 | snmp4_tcp_list[i].entry)); | 399 | snmp4_tcp_list[i].entry)); |
400 | else | 400 | else |
401 | seq_printf(seq, " %lu", | 401 | seq_printf(seq, " %lu", |
402 | snmp_fold_field((void __percpu **)net->mib.tcp_statistics, | 402 | snmp_fold_field(net->mib.tcp_statistics, |
403 | snmp4_tcp_list[i].entry)); | 403 | snmp4_tcp_list[i].entry)); |
404 | } | 404 | } |
405 | 405 | ||
@@ -410,7 +410,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v) | |||
410 | seq_puts(seq, "\nUdp:"); | 410 | seq_puts(seq, "\nUdp:"); |
411 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) | 411 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) |
412 | seq_printf(seq, " %lu", | 412 | seq_printf(seq, " %lu", |
413 | snmp_fold_field((void __percpu **)net->mib.udp_statistics, | 413 | snmp_fold_field(net->mib.udp_statistics, |
414 | snmp4_udp_list[i].entry)); | 414 | snmp4_udp_list[i].entry)); |
415 | 415 | ||
416 | /* the UDP and UDP-Lite MIBs are the same */ | 416 | /* the UDP and UDP-Lite MIBs are the same */ |
@@ -421,7 +421,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v) | |||
421 | seq_puts(seq, "\nUdpLite:"); | 421 | seq_puts(seq, "\nUdpLite:"); |
422 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) | 422 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) |
423 | seq_printf(seq, " %lu", | 423 | seq_printf(seq, " %lu", |
424 | snmp_fold_field((void __percpu **)net->mib.udplite_statistics, | 424 | snmp_fold_field(net->mib.udplite_statistics, |
425 | snmp4_udp_list[i].entry)); | 425 | snmp4_udp_list[i].entry)); |
426 | 426 | ||
427 | seq_putc(seq, '\n'); | 427 | seq_putc(seq, '\n'); |
@@ -458,7 +458,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v) | |||
458 | seq_puts(seq, "\nTcpExt:"); | 458 | seq_puts(seq, "\nTcpExt:"); |
459 | for (i = 0; snmp4_net_list[i].name != NULL; i++) | 459 | for (i = 0; snmp4_net_list[i].name != NULL; i++) |
460 | seq_printf(seq, " %lu", | 460 | seq_printf(seq, " %lu", |
461 | snmp_fold_field((void __percpu **)net->mib.net_statistics, | 461 | snmp_fold_field(net->mib.net_statistics, |
462 | snmp4_net_list[i].entry)); | 462 | snmp4_net_list[i].entry)); |
463 | 463 | ||
464 | seq_puts(seq, "\nIpExt:"); | 464 | seq_puts(seq, "\nIpExt:"); |
@@ -468,7 +468,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v) | |||
468 | seq_puts(seq, "\nIpExt:"); | 468 | seq_puts(seq, "\nIpExt:"); |
469 | for (i = 0; snmp4_ipextstats_list[i].name != NULL; i++) | 469 | for (i = 0; snmp4_ipextstats_list[i].name != NULL; i++) |
470 | seq_printf(seq, " %llu", | 470 | seq_printf(seq, " %llu", |
471 | snmp_fold_field64((void __percpu **)net->mib.ip_statistics, | 471 | snmp_fold_field64(net->mib.ip_statistics, |
472 | snmp4_ipextstats_list[i].entry, | 472 | snmp4_ipextstats_list[i].entry, |
473 | offsetof(struct ipstats_mib, syncp))); | 473 | offsetof(struct ipstats_mib, syncp))); |
474 | 474 | ||
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 1ac13c0300b7..5667b3003af9 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -275,19 +275,14 @@ static int snmp6_alloc_dev(struct inet6_dev *idev) | |||
275 | { | 275 | { |
276 | int i; | 276 | int i; |
277 | 277 | ||
278 | if (snmp_mib_init((void __percpu **)idev->stats.ipv6, | 278 | idev->stats.ipv6 = alloc_percpu(struct ipstats_mib); |
279 | sizeof(struct ipstats_mib), | 279 | if (!idev->stats.ipv6) |
280 | __alignof__(struct ipstats_mib)) < 0) | ||
281 | goto err_ip; | 280 | goto err_ip; |
282 | 281 | ||
283 | for_each_possible_cpu(i) { | 282 | for_each_possible_cpu(i) { |
284 | struct ipstats_mib *addrconf_stats; | 283 | struct ipstats_mib *addrconf_stats; |
285 | addrconf_stats = per_cpu_ptr(idev->stats.ipv6[0], i); | 284 | addrconf_stats = per_cpu_ptr(idev->stats.ipv6, i); |
286 | u64_stats_init(&addrconf_stats->syncp); | 285 | u64_stats_init(&addrconf_stats->syncp); |
287 | #if SNMP_ARRAY_SZ == 2 | ||
288 | addrconf_stats = per_cpu_ptr(idev->stats.ipv6[1], i); | ||
289 | u64_stats_init(&addrconf_stats->syncp); | ||
290 | #endif | ||
291 | } | 286 | } |
292 | 287 | ||
293 | 288 | ||
@@ -305,7 +300,7 @@ static int snmp6_alloc_dev(struct inet6_dev *idev) | |||
305 | err_icmpmsg: | 300 | err_icmpmsg: |
306 | kfree(idev->stats.icmpv6dev); | 301 | kfree(idev->stats.icmpv6dev); |
307 | err_icmp: | 302 | err_icmp: |
308 | snmp_mib_free((void __percpu **)idev->stats.ipv6); | 303 | free_percpu(idev->stats.ipv6); |
309 | err_ip: | 304 | err_ip: |
310 | return -ENOMEM; | 305 | return -ENOMEM; |
311 | } | 306 | } |
@@ -4363,7 +4358,7 @@ static inline void __snmp6_fill_statsdev(u64 *stats, atomic_long_t *mib, | |||
4363 | memset(&stats[items], 0, pad); | 4358 | memset(&stats[items], 0, pad); |
4364 | } | 4359 | } |
4365 | 4360 | ||
4366 | static inline void __snmp6_fill_stats64(u64 *stats, void __percpu **mib, | 4361 | static inline void __snmp6_fill_stats64(u64 *stats, void __percpu *mib, |
4367 | int items, int bytes, size_t syncpoff) | 4362 | int items, int bytes, size_t syncpoff) |
4368 | { | 4363 | { |
4369 | int i; | 4364 | int i; |
@@ -4383,7 +4378,7 @@ static void snmp6_fill_stats(u64 *stats, struct inet6_dev *idev, int attrtype, | |||
4383 | { | 4378 | { |
4384 | switch (attrtype) { | 4379 | switch (attrtype) { |
4385 | case IFLA_INET6_STATS: | 4380 | case IFLA_INET6_STATS: |
4386 | __snmp6_fill_stats64(stats, (void __percpu **)idev->stats.ipv6, | 4381 | __snmp6_fill_stats64(stats, idev->stats.ipv6, |
4387 | IPSTATS_MIB_MAX, bytes, offsetof(struct ipstats_mib, syncp)); | 4382 | IPSTATS_MIB_MAX, bytes, offsetof(struct ipstats_mib, syncp)); |
4388 | break; | 4383 | break; |
4389 | case IFLA_INET6_ICMP6STATS: | 4384 | case IFLA_INET6_ICMP6STATS: |
diff --git a/net/ipv6/addrconf_core.c b/net/ipv6/addrconf_core.c index 4c11cbcf8308..e6960457f625 100644 --- a/net/ipv6/addrconf_core.c +++ b/net/ipv6/addrconf_core.c | |||
@@ -123,7 +123,7 @@ static void snmp6_free_dev(struct inet6_dev *idev) | |||
123 | { | 123 | { |
124 | kfree(idev->stats.icmpv6msgdev); | 124 | kfree(idev->stats.icmpv6msgdev); |
125 | kfree(idev->stats.icmpv6dev); | 125 | kfree(idev->stats.icmpv6dev); |
126 | snmp_mib_free((void __percpu **)idev->stats.ipv6); | 126 | free_percpu(idev->stats.ipv6); |
127 | } | 127 | } |
128 | 128 | ||
129 | /* Nobody refers to this device, we may destroy it. */ | 129 | /* Nobody refers to this device, we may destroy it. */ |
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 | ||
752 | err_icmpmsg_mib: | 744 | err_icmpmsg_mib: |
753 | snmp_mib_free((void __percpu **)net->mib.icmpv6_statistics); | 745 | free_percpu(net->mib.icmpv6_statistics); |
754 | err_icmp_mib: | 746 | err_icmp_mib: |
755 | snmp_mib_free((void __percpu **)net->mib.ipv6_statistics); | 747 | free_percpu(net->mib.ipv6_statistics); |
756 | err_ip_mib: | 748 | err_ip_mib: |
757 | snmp_mib_free((void __percpu **)net->mib.udplite_stats_in6); | 749 | free_percpu(net->mib.udplite_stats_in6); |
758 | err_udplite_mib: | 750 | err_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 | ||
763 | static void ipv6_cleanup_mibs(struct net *net) | 755 | static 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 | ||
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index 091d066a57b3..69cb47625df7 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
@@ -201,7 +201,7 @@ static void snmp6_seq_show_item(struct seq_file *seq, void __percpu **pcpumib, | |||
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | static void snmp6_seq_show_item64(struct seq_file *seq, void __percpu **mib, | 204 | static void snmp6_seq_show_item64(struct seq_file *seq, void __percpu *mib, |
205 | const struct snmp_mib *itemlist, size_t syncpoff) | 205 | const struct snmp_mib *itemlist, size_t syncpoff) |
206 | { | 206 | { |
207 | int i; | 207 | int i; |
@@ -215,7 +215,7 @@ static int snmp6_seq_show(struct seq_file *seq, void *v) | |||
215 | { | 215 | { |
216 | struct net *net = (struct net *)seq->private; | 216 | struct net *net = (struct net *)seq->private; |
217 | 217 | ||
218 | snmp6_seq_show_item64(seq, (void __percpu **)net->mib.ipv6_statistics, | 218 | snmp6_seq_show_item64(seq, net->mib.ipv6_statistics, |
219 | snmp6_ipstats_list, offsetof(struct ipstats_mib, syncp)); | 219 | snmp6_ipstats_list, offsetof(struct ipstats_mib, syncp)); |
220 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.icmpv6_statistics, | 220 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.icmpv6_statistics, |
221 | NULL, snmp6_icmp6_list); | 221 | NULL, snmp6_icmp6_list); |
@@ -245,7 +245,7 @@ static int snmp6_dev_seq_show(struct seq_file *seq, void *v) | |||
245 | struct inet6_dev *idev = (struct inet6_dev *)seq->private; | 245 | struct inet6_dev *idev = (struct inet6_dev *)seq->private; |
246 | 246 | ||
247 | seq_printf(seq, "%-32s\t%u\n", "ifIndex", idev->dev->ifindex); | 247 | seq_printf(seq, "%-32s\t%u\n", "ifIndex", idev->dev->ifindex); |
248 | snmp6_seq_show_item64(seq, (void __percpu **)idev->stats.ipv6, | 248 | snmp6_seq_show_item64(seq, idev->stats.ipv6, |
249 | snmp6_ipstats_list, offsetof(struct ipstats_mib, syncp)); | 249 | snmp6_ipstats_list, offsetof(struct ipstats_mib, syncp)); |
250 | snmp6_seq_show_item(seq, NULL, idev->stats.icmpv6dev->mibs, | 250 | snmp6_seq_show_item(seq, NULL, idev->stats.icmpv6dev->mibs, |
251 | snmp6_icmp6_list); | 251 | snmp6_icmp6_list); |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index c09757fbf803..074b60e2faab 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -1100,14 +1100,15 @@ int sctp_register_pf(struct sctp_pf *pf, sa_family_t family) | |||
1100 | 1100 | ||
1101 | static inline int init_sctp_mibs(struct net *net) | 1101 | static inline int init_sctp_mibs(struct net *net) |
1102 | { | 1102 | { |
1103 | return snmp_mib_init((void __percpu **)net->sctp.sctp_statistics, | 1103 | net->sctp.sctp_statistics = alloc_percpu(struct sctp_mib); |
1104 | sizeof(struct sctp_mib), | 1104 | if (!net->sctp.sctp_statistics) |
1105 | __alignof__(struct sctp_mib)); | 1105 | return -ENOMEM; |
1106 | return 0; | ||
1106 | } | 1107 | } |
1107 | 1108 | ||
1108 | static inline void cleanup_sctp_mibs(struct net *net) | 1109 | static inline void cleanup_sctp_mibs(struct net *net) |
1109 | { | 1110 | { |
1110 | snmp_mib_free((void __percpu **)net->sctp.sctp_statistics); | 1111 | free_percpu(net->sctp.sctp_statistics); |
1111 | } | 1112 | } |
1112 | 1113 | ||
1113 | static void sctp_v4_pf_init(void) | 1114 | static void sctp_v4_pf_init(void) |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index c08fbd11ceff..e63f242ae03e 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -2783,21 +2783,19 @@ static struct notifier_block xfrm_dev_notifier = { | |||
2783 | static int __net_init xfrm_statistics_init(struct net *net) | 2783 | static int __net_init xfrm_statistics_init(struct net *net) |
2784 | { | 2784 | { |
2785 | int rv; | 2785 | int rv; |
2786 | 2786 | net->mib.xfrm_statistics = alloc_percpu(struct linux_xfrm_mib); | |
2787 | if (snmp_mib_init((void __percpu **)net->mib.xfrm_statistics, | 2787 | if (!net->mib.xfrm_statistics) |
2788 | sizeof(struct linux_xfrm_mib), | ||
2789 | __alignof__(struct linux_xfrm_mib)) < 0) | ||
2790 | return -ENOMEM; | 2788 | return -ENOMEM; |
2791 | rv = xfrm_proc_init(net); | 2789 | rv = xfrm_proc_init(net); |
2792 | if (rv < 0) | 2790 | if (rv < 0) |
2793 | snmp_mib_free((void __percpu **)net->mib.xfrm_statistics); | 2791 | free_percpu(net->mib.xfrm_statistics); |
2794 | return rv; | 2792 | return rv; |
2795 | } | 2793 | } |
2796 | 2794 | ||
2797 | static void xfrm_statistics_fini(struct net *net) | 2795 | static void xfrm_statistics_fini(struct net *net) |
2798 | { | 2796 | { |
2799 | xfrm_proc_fini(net); | 2797 | xfrm_proc_fini(net); |
2800 | snmp_mib_free((void __percpu **)net->mib.xfrm_statistics); | 2798 | free_percpu(net->mib.xfrm_statistics); |
2801 | } | 2799 | } |
2802 | #else | 2800 | #else |
2803 | static int __net_init xfrm_statistics_init(struct net *net) | 2801 | static int __net_init xfrm_statistics_init(struct net *net) |
diff --git a/net/xfrm/xfrm_proc.c b/net/xfrm/xfrm_proc.c index fc5abd0b456f..9c4fbd8935f4 100644 --- a/net/xfrm/xfrm_proc.c +++ b/net/xfrm/xfrm_proc.c | |||
@@ -54,8 +54,7 @@ static int xfrm_statistics_seq_show(struct seq_file *seq, void *v) | |||
54 | int i; | 54 | int i; |
55 | for (i = 0; xfrm_mib_list[i].name; i++) | 55 | for (i = 0; xfrm_mib_list[i].name; i++) |
56 | seq_printf(seq, "%-24s\t%lu\n", xfrm_mib_list[i].name, | 56 | seq_printf(seq, "%-24s\t%lu\n", xfrm_mib_list[i].name, |
57 | snmp_fold_field((void __percpu **) | 57 | snmp_fold_field(net->mib.xfrm_statistics, |
58 | net->mib.xfrm_statistics, | ||
59 | xfrm_mib_list[i].entry)); | 58 | xfrm_mib_list[i].entry)); |
60 | return 0; | 59 | return 0; |
61 | } | 60 | } |