ipvs: properly zero stats and rates
Subsystems (4)
Julian Anastasov
maintainerPATCH 3/6 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.
---
include/net/ip_vs.h renamed from linux/include/net/ip_vs.h +1 -0
@@ -374,6 +374,7 @@ struct ip_vs_stats {struct ip_vs_estimator est;/* estimator */ struct ip_vs_cpu_stats *cpustats;/* per cpu counters */ spinlock_t lock;/* spin lock */ +struct ip_vs_stats_user ustats0;/* reset values */ };/*
net/netfilter/ipvs/ip_vs_ctl.c renamed from linux/net/netfilter/ipvs/ip_vs_ctl.c +60 -36
147 lines not on this page · raw message
net/netfilter/ipvs/ip_vs_est.c renamed from linux/net/netfilter/ipvs/ip_vs_est.c +7 -6
@@ -184,13 +184,14 @@ void ip_vs_kill_estimator(struct net *nevoid ip_vs_zero_estimator (struct ip_vs_stats *stats) {struct ip_vs_estimator *est = &stats->est; +struct ip_vs_stats_user *u = &stats->ustats; -/* 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 ; +/* 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 ;