Commit acbd0c81 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

mptcp: use batch snmp operations in mptcp_seq_show()

Using snmp_get_cpu_field_batch() allows for better cpu cache
utilization, especially on hosts with large number of cpus.

Also remove special handling when mptcp mibs where not yet
allocated.

I chose to use temporary storage on the stack to keep this patch simple.
We might in the future use the storage allocated in netstat_seq_show().

Combined with prior patch (inlining snmp_get_cpu_field)
time to fetch and output mptcp counters on a 256 cpu host [1]
goes from 75 usec to 16 usec.

[1] L1 cache size is 32KB, it is not big enough to hold all dataset.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 59f09ae8
...@@ -72,6 +72,7 @@ bool mptcp_mib_alloc(struct net *net) ...@@ -72,6 +72,7 @@ bool mptcp_mib_alloc(struct net *net)
void mptcp_seq_show(struct seq_file *seq) void mptcp_seq_show(struct seq_file *seq)
{ {
unsigned long sum[ARRAY_SIZE(mptcp_snmp_list) - 1];
struct net *net = seq->private; struct net *net = seq->private;
int i; int i;
...@@ -81,17 +82,13 @@ void mptcp_seq_show(struct seq_file *seq) ...@@ -81,17 +82,13 @@ void mptcp_seq_show(struct seq_file *seq)
seq_puts(seq, "\nMPTcpExt:"); seq_puts(seq, "\nMPTcpExt:");
if (!net->mib.mptcp_statistics) { memset(sum, 0, sizeof(sum));
for (i = 0; mptcp_snmp_list[i].name; i++) if (net->mib.mptcp_statistics)
seq_puts(seq, " 0"); snmp_get_cpu_field_batch(sum, mptcp_snmp_list,
net->mib.mptcp_statistics);
seq_putc(seq, '\n');
return;
}
for (i = 0; mptcp_snmp_list[i].name; i++) for (i = 0; mptcp_snmp_list[i].name; i++)
seq_printf(seq, " %lu", seq_printf(seq, " %lu", sum[i]);
snmp_fold_field(net->mib.mptcp_statistics,
mptcp_snmp_list[i].entry));
seq_putc(seq, '\n'); seq_putc(seq, '\n');
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment