diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-11-08 08:04:43 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-09 16:04:20 -0500 |
commit | acb32ba3dee66d58704caeeb8c6ff95f60efdc66 (patch) | |
tree | b5c1d6d5575a7b75c7c816e0809690f58401715c /net/ipv4/proc.c | |
parent | e56c57d0d3fdbbdf583d3af96bfb803b8dfa713e (diff) |
ipv4: reduce percpu needs for icmpmsg mibs
Reading /proc/net/snmp on a machine with a lot of cpus is very expensive
(can be ~88000 us).
This is because ICMPMSG MIB uses 4096 bytes per cpu, and folding values
for all possible cpus can read 16 Mbytes of memory.
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/ipv4/proc.c')
-rw-r--r-- | net/ipv4/proc.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 466ea8bb7a4d..961eed4f510a 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
@@ -288,7 +288,7 @@ static void icmpmsg_put(struct seq_file *seq) | |||
288 | 288 | ||
289 | count = 0; | 289 | count = 0; |
290 | for (i = 0; i < ICMPMSG_MIB_MAX; i++) { | 290 | for (i = 0; i < ICMPMSG_MIB_MAX; i++) { |
291 | val = snmp_fold_field((void __percpu **) net->mib.icmpmsg_statistics, i); | 291 | val = atomic_long_read(&net->mib.icmpmsg_statistics->mibs[i]); |
292 | if (val) { | 292 | if (val) { |
293 | type[count] = i; | 293 | type[count] = i; |
294 | vals[count++] = val; | 294 | vals[count++] = val; |
@@ -307,6 +307,7 @@ static void icmp_put(struct seq_file *seq) | |||
307 | { | 307 | { |
308 | int i; | 308 | int i; |
309 | struct net *net = seq->private; | 309 | struct net *net = seq->private; |
310 | atomic_long_t *ptr = net->mib.icmpmsg_statistics->mibs; | ||
310 | 311 | ||
311 | seq_puts(seq, "\nIcmp: InMsgs InErrors"); | 312 | seq_puts(seq, "\nIcmp: InMsgs InErrors"); |
312 | for (i=0; icmpmibmap[i].name != NULL; i++) | 313 | for (i=0; icmpmibmap[i].name != NULL; i++) |
@@ -319,15 +320,13 @@ static void icmp_put(struct seq_file *seq) | |||
319 | snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_INERRORS)); | 320 | snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_INERRORS)); |
320 | for (i=0; icmpmibmap[i].name != NULL; i++) | 321 | for (i=0; icmpmibmap[i].name != NULL; i++) |
321 | seq_printf(seq, " %lu", | 322 | seq_printf(seq, " %lu", |
322 | snmp_fold_field((void __percpu **) net->mib.icmpmsg_statistics, | 323 | atomic_long_read(ptr + icmpmibmap[i].index)); |
323 | icmpmibmap[i].index)); | ||
324 | seq_printf(seq, " %lu %lu", | 324 | seq_printf(seq, " %lu %lu", |
325 | snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_OUTMSGS), | 325 | snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_OUTMSGS), |
326 | snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_OUTERRORS)); | 326 | snmp_fold_field((void __percpu **) net->mib.icmp_statistics, ICMP_MIB_OUTERRORS)); |
327 | for (i=0; icmpmibmap[i].name != NULL; i++) | 327 | for (i=0; icmpmibmap[i].name != NULL; i++) |
328 | seq_printf(seq, " %lu", | 328 | seq_printf(seq, " %lu", |
329 | snmp_fold_field((void __percpu **) net->mib.icmpmsg_statistics, | 329 | atomic_long_read(ptr + (icmpmibmap[i].index | 0x100))); |
330 | icmpmibmap[i].index | 0x100)); | ||
331 | } | 330 | } |
332 | 331 | ||
333 | /* | 332 | /* |