diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-11-12 20:24:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-14 00:12:26 -0500 |
commit | 2a24444f8f2bea694003e3eac5c2f8d9a386bdc5 (patch) | |
tree | ef283db22c931c518ac6c0b8bca2e23dd62a7736 /net/ipv6/proc.c | |
parent | 3d249d4ca7d0ed6629a135ea1ea21c72286c0d80 (diff) |
ipv6: reduce percpu needs for icmpv6msg mibs
Reading /proc/net/snmp6 on a machine with a lot of cpus is very
expensive (can be ~88000 us).
This is because ICMPV6MSG MIB uses 4096 bytes per cpu, and folding
values for all possible cpus can read 16 Mbytes of memory (32MBytes on
non x86 arches)
ICMP messages are not considered as fast path on a typical server, and
eventually few cpus handle them anyway. We can afford an atomic
operation instead of using percpu data.
This saves 4096 bytes per cpu and per network namespace.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/proc.c')
-rw-r--r-- | net/ipv6/proc.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index 1008ce94bc33..fdeb6d03da81 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
@@ -142,11 +142,7 @@ static const struct snmp_mib snmp6_udplite6_list[] = { | |||
142 | SNMP_MIB_SENTINEL | 142 | SNMP_MIB_SENTINEL |
143 | }; | 143 | }; |
144 | 144 | ||
145 | /* can be called either with percpu mib (pcpumib != NULL), | 145 | static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, atomic_long_t *smib) |
146 | * or shared one (smib != NULL) | ||
147 | */ | ||
148 | static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void __percpu **pcpumib, | ||
149 | atomic_long_t *smib) | ||
150 | { | 146 | { |
151 | char name[32]; | 147 | char name[32]; |
152 | int i; | 148 | int i; |
@@ -163,14 +159,14 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, void __percpu **pcpum | |||
163 | snprintf(name, sizeof(name), "Icmp6%s%s", | 159 | snprintf(name, sizeof(name), "Icmp6%s%s", |
164 | i & 0x100 ? "Out" : "In", p); | 160 | i & 0x100 ? "Out" : "In", p); |
165 | seq_printf(seq, "%-32s\t%lu\n", name, | 161 | seq_printf(seq, "%-32s\t%lu\n", name, |
166 | pcpumib ? snmp_fold_field(pcpumib, i) : atomic_long_read(smib + i)); | 162 | atomic_long_read(smib + i)); |
167 | } | 163 | } |
168 | 164 | ||
169 | /* print by number (nonzero only) - ICMPMsgStat format */ | 165 | /* print by number (nonzero only) - ICMPMsgStat format */ |
170 | for (i = 0; i < ICMP6MSG_MIB_MAX; i++) { | 166 | for (i = 0; i < ICMP6MSG_MIB_MAX; i++) { |
171 | unsigned long val; | 167 | unsigned long val; |
172 | 168 | ||
173 | val = pcpumib ? snmp_fold_field(pcpumib, i) : atomic_long_read(smib + i); | 169 | val = atomic_long_read(smib + i); |
174 | if (!val) | 170 | if (!val) |
175 | continue; | 171 | continue; |
176 | snprintf(name, sizeof(name), "Icmp6%sType%u", | 172 | snprintf(name, sizeof(name), "Icmp6%sType%u", |
@@ -215,8 +211,7 @@ static int snmp6_seq_show(struct seq_file *seq, void *v) | |||
215 | snmp6_ipstats_list, offsetof(struct ipstats_mib, syncp)); | 211 | snmp6_ipstats_list, offsetof(struct ipstats_mib, syncp)); |
216 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.icmpv6_statistics, | 212 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.icmpv6_statistics, |
217 | NULL, snmp6_icmp6_list); | 213 | NULL, snmp6_icmp6_list); |
218 | snmp6_seq_show_icmpv6msg(seq, | 214 | snmp6_seq_show_icmpv6msg(seq, net->mib.icmpv6msg_statistics->mibs); |
219 | (void __percpu **)net->mib.icmpv6msg_statistics, NULL); | ||
220 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.udp_stats_in6, | 215 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.udp_stats_in6, |
221 | NULL, snmp6_udp6_list); | 216 | NULL, snmp6_udp6_list); |
222 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.udplite_stats_in6, | 217 | snmp6_seq_show_item(seq, (void __percpu **)net->mib.udplite_stats_in6, |
@@ -246,7 +241,7 @@ static int snmp6_dev_seq_show(struct seq_file *seq, void *v) | |||
246 | snmp6_ipstats_list); | 241 | snmp6_ipstats_list); |
247 | snmp6_seq_show_item(seq, NULL, idev->stats.icmpv6dev->mibs, | 242 | snmp6_seq_show_item(seq, NULL, idev->stats.icmpv6dev->mibs, |
248 | snmp6_icmp6_list); | 243 | snmp6_icmp6_list); |
249 | snmp6_seq_show_icmpv6msg(seq, NULL, idev->stats.icmpv6msgdev->mibs); | 244 | snmp6_seq_show_icmpv6msg(seq, idev->stats.icmpv6msgdev->mibs); |
250 | return 0; | 245 | return 0; |
251 | } | 246 | } |
252 | 247 | ||