ipvs: reorganize tot_stats
Subsystems (4)
Julian Anastasov
maintainerPATCH 2/4 ipvs: reorganize tot_stats
The global tot_stats contains cpustats field just like the
stats for dest and svc, so better use it to simplify the usage in estimation_timer. As tot_stats is registered as estimator we can remove the special ip_vs_read_cpu_stats call for tot_stats. Fix ip_vs_read_cpu_stats to be called under stats lock because it is still used as synchronization between estimation timer and user context (the stats readers).
Also, make sure ip_vs_stats_percpu_show reads properly
the u64 stats from user context.
Signed-off-by Julian Anastasov <[email protected]>
---
include/net/ip_vs.h renamed from linux/include/net/ip_vs.h +1 -2
@@ -851,8 +851,7 @@ struct netns_ipvs {atomic_t conn_count;/* connection counter */ /* ip_vs_ctl */ -struct ip_vs_stats *tot_stats;/* Statistics & est. */ -struct ip_vs_cpu_stats __percpu *cpustats;/* Stats per cpu */ +struct ip_vs_stats tot_stats;/* Statistics & est. */ seqcount_t *ustats_seq;/* u64 read retry */ int num_services;/* no of virtual services */
net/netfilter/ipvs/ip_vs_core.c renamed from linux/net/netfilter/ipvs/ip_vs_core.c +3 -3
@@ -132,7 +132,7 @@ ip_vs_in_stats(struct ip_vs_conn *cp, st s->ustats.inbytes += skb->len;u64_stats_update_end (&s->syncp); - s =this_cpu_ptr (ipvs->cpustats); + s =this_cpu_ptr (ipvs->tot_stats.cpustats); s->ustats.inpkts++;u64_stats_update_begin (&s->syncp); s->ustats.inbytes += skb->len;
@@ -162,7 +162,7 @@ ip_vs_out_stats(struct ip_vs_conn *cp, s s->ustats.outbytes += skb->len;u64_stats_update_end (&s->syncp); - s =this_cpu_ptr (ipvs->cpustats); + s =this_cpu_ptr (ipvs->tot_stats.cpustats); s->ustats.outpkts++;u64_stats_update_begin (&s->syncp); s->ustats.outbytes += skb->len;
@@ -183,7 +183,7 @@ ip_vs_conn_stats(struct ip_vs_conn *cp, s =this_cpu_ptr (svc->stats.cpustats); s->ustats.conns++; - s =this_cpu_ptr (ipvs->cpustats); + s =this_cpu_ptr (ipvs->tot_stats.cpustats); s->ustats.conns++; }
net/netfilter/ipvs/ip_vs_ctl.c renamed from linux/net/netfilter/ipvs/ip_vs_ctl.c +24 -21
104 lines not on this page · raw message
net/netfilter/ipvs/ip_vs_est.c renamed from linux/net/netfilter/ipvs/ip_vs_est.c +1 -2
@@ -101,13 +101,12 @@ static void estimation_timer(unsigned lostruct netns_ipvs *ipvs; ipvs =net_ipvs (net); -ip_vs_read_cpu_stats (&ipvs->tot_stats->ustats, ipvs->cpustats);spin_lock (&ipvs->est_lock);list_for_each_entry (e, &ipvs->est_list, list) { s = container_of(e, struct ip_vs_stats, est); -ip_vs_read_cpu_stats (&s->ustats, s->cpustats);spin_lock (&s->lock); +ip_vs_read_cpu_stats (&s->ustats, s->cpustats); n_conns = s->ustats.conns; n_inpkts = s->ustats.inpkts; n_outpkts = s->ustats.outpkts;