diff options
author | Julian Anastasov <ja@ssi.bg> | 2011-03-14 01:37:49 +0200 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2011-03-15 09:36:52 +0900 |
commit | 55a3d4e15c7c953ecc55b96b83d2679abf8a7899 (patch) | |
tree | d1f1c52c77c04b717ca1a26bc7a0e90adb0498df /net/netfilter/ipvs/ip_vs_est.c | |
parent | 2a0751af09c3099cf2837c623ca5d0436317d02d (diff) | |
download | op-kernel-dev-55a3d4e15c7c953ecc55b96b83d2679abf8a7899.zip op-kernel-dev-55a3d4e15c7c953ecc55b96b83d2679abf8a7899.tar.gz |
ipvs: properly zero stats and rates
Currently, the new percpu counters are not zeroed and
the zero commands do not work as expected, we still show the old
sum of percpu values. OTOH, we can not reset the percpu counters
from user context without causing the incrementing to use old
and bogus values.
So, as Eric Dumazet suggested fix that by moving all overhead
to stats reading in user context. Do not introduce overhead in
timer context (estimator) and incrementing (packet handling in
softirqs).
The new ustats0 field holds the zero point for all
counter values, the rates always use 0 as base value as before.
When showing the values to user space just give the difference
between counters and the base values. The only drawback is that
percpu stats are not zeroed, they are accessible only from /proc
and are new interface, so it should not be a compatibility problem
as long as the sum stats are correct after zeroing.
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'net/netfilter/ipvs/ip_vs_est.c')
-rw-r--r-- | net/netfilter/ipvs/ip_vs_est.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/net/netfilter/ipvs/ip_vs_est.c b/net/netfilter/ipvs/ip_vs_est.c index b3751cf..a850087 100644 --- a/net/netfilter/ipvs/ip_vs_est.c +++ b/net/netfilter/ipvs/ip_vs_est.c @@ -184,13 +184,14 @@ void ip_vs_kill_estimator(struct net *net, struct ip_vs_stats *stats) void ip_vs_zero_estimator(struct ip_vs_stats *stats) { struct ip_vs_estimator *est = &stats->est; - - /* set counters zero, caller must hold the stats->lock lock */ - est->last_inbytes = 0; - est->last_outbytes = 0; - est->last_conns = 0; - est->last_inpkts = 0; - est->last_outpkts = 0; + struct ip_vs_stats_user *u = &stats->ustats; + + /* reset counters, caller must hold the stats->lock lock */ + est->last_inbytes = u->inbytes; + est->last_outbytes = u->outbytes; + est->last_conns = u->conns; + est->last_inpkts = u->inpkts; + est->last_outpkts = u->outpkts; est->cps = 0; est->inpps = 0; est->outpps = 0; |