提交 1dbd8d9a 编写于 作者: J Julian Anastasov 提交者: Pablo Neira Ayuso

ipvs: use u64_stats_t for the per-cpu counters

Use the provided u64_stats_t type to avoid
load/store tearing.

Fixes: 316580b6 ("u64_stats: provide u64_stats_t type")
Signed-off-by: NJulian Anastasov <ja@ssi.bg>
Cc: yunhong-cgl jiang <xintian1976@gmail.com>
Cc: "dust.li" <dust.li@linux.alibaba.com>
Reviewed-by: NJiri Wiesner <jwiesner@suse.de>
Tested-by: NJiri Wiesner <jwiesner@suse.de>
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
上级 de39afb3
...@@ -351,11 +351,11 @@ struct ip_vs_seq { ...@@ -351,11 +351,11 @@ struct ip_vs_seq {
/* counters per cpu */ /* counters per cpu */
struct ip_vs_counters { struct ip_vs_counters {
__u64 conns; /* connections scheduled */ u64_stats_t conns; /* connections scheduled */
__u64 inpkts; /* incoming packets */ u64_stats_t inpkts; /* incoming packets */
__u64 outpkts; /* outgoing packets */ u64_stats_t outpkts; /* outgoing packets */
__u64 inbytes; /* incoming bytes */ u64_stats_t inbytes; /* incoming bytes */
__u64 outbytes; /* outgoing bytes */ u64_stats_t outbytes; /* outgoing bytes */
}; };
/* Stats per cpu */ /* Stats per cpu */
struct ip_vs_cpu_stats { struct ip_vs_cpu_stats {
......
...@@ -132,21 +132,21 @@ ip_vs_in_stats(struct ip_vs_conn *cp, struct sk_buff *skb) ...@@ -132,21 +132,21 @@ ip_vs_in_stats(struct ip_vs_conn *cp, struct sk_buff *skb)
s = this_cpu_ptr(dest->stats.cpustats); s = this_cpu_ptr(dest->stats.cpustats);
u64_stats_update_begin(&s->syncp); u64_stats_update_begin(&s->syncp);
s->cnt.inpkts++; u64_stats_inc(&s->cnt.inpkts);
s->cnt.inbytes += skb->len; u64_stats_add(&s->cnt.inbytes, skb->len);
u64_stats_update_end(&s->syncp); u64_stats_update_end(&s->syncp);
svc = rcu_dereference(dest->svc); svc = rcu_dereference(dest->svc);
s = this_cpu_ptr(svc->stats.cpustats); s = this_cpu_ptr(svc->stats.cpustats);
u64_stats_update_begin(&s->syncp); u64_stats_update_begin(&s->syncp);
s->cnt.inpkts++; u64_stats_inc(&s->cnt.inpkts);
s->cnt.inbytes += skb->len; u64_stats_add(&s->cnt.inbytes, skb->len);
u64_stats_update_end(&s->syncp); u64_stats_update_end(&s->syncp);
s = this_cpu_ptr(ipvs->tot_stats->s.cpustats); s = this_cpu_ptr(ipvs->tot_stats->s.cpustats);
u64_stats_update_begin(&s->syncp); u64_stats_update_begin(&s->syncp);
s->cnt.inpkts++; u64_stats_inc(&s->cnt.inpkts);
s->cnt.inbytes += skb->len; u64_stats_add(&s->cnt.inbytes, skb->len);
u64_stats_update_end(&s->syncp); u64_stats_update_end(&s->syncp);
local_bh_enable(); local_bh_enable();
...@@ -168,21 +168,21 @@ ip_vs_out_stats(struct ip_vs_conn *cp, struct sk_buff *skb) ...@@ -168,21 +168,21 @@ ip_vs_out_stats(struct ip_vs_conn *cp, struct sk_buff *skb)
s = this_cpu_ptr(dest->stats.cpustats); s = this_cpu_ptr(dest->stats.cpustats);
u64_stats_update_begin(&s->syncp); u64_stats_update_begin(&s->syncp);
s->cnt.outpkts++; u64_stats_inc(&s->cnt.outpkts);
s->cnt.outbytes += skb->len; u64_stats_add(&s->cnt.outbytes, skb->len);
u64_stats_update_end(&s->syncp); u64_stats_update_end(&s->syncp);
svc = rcu_dereference(dest->svc); svc = rcu_dereference(dest->svc);
s = this_cpu_ptr(svc->stats.cpustats); s = this_cpu_ptr(svc->stats.cpustats);
u64_stats_update_begin(&s->syncp); u64_stats_update_begin(&s->syncp);
s->cnt.outpkts++; u64_stats_inc(&s->cnt.outpkts);
s->cnt.outbytes += skb->len; u64_stats_add(&s->cnt.outbytes, skb->len);
u64_stats_update_end(&s->syncp); u64_stats_update_end(&s->syncp);
s = this_cpu_ptr(ipvs->tot_stats->s.cpustats); s = this_cpu_ptr(ipvs->tot_stats->s.cpustats);
u64_stats_update_begin(&s->syncp); u64_stats_update_begin(&s->syncp);
s->cnt.outpkts++; u64_stats_inc(&s->cnt.outpkts);
s->cnt.outbytes += skb->len; u64_stats_add(&s->cnt.outbytes, skb->len);
u64_stats_update_end(&s->syncp); u64_stats_update_end(&s->syncp);
local_bh_enable(); local_bh_enable();
...@@ -200,17 +200,17 @@ ip_vs_conn_stats(struct ip_vs_conn *cp, struct ip_vs_service *svc) ...@@ -200,17 +200,17 @@ ip_vs_conn_stats(struct ip_vs_conn *cp, struct ip_vs_service *svc)
s = this_cpu_ptr(cp->dest->stats.cpustats); s = this_cpu_ptr(cp->dest->stats.cpustats);
u64_stats_update_begin(&s->syncp); u64_stats_update_begin(&s->syncp);
s->cnt.conns++; u64_stats_inc(&s->cnt.conns);
u64_stats_update_end(&s->syncp); u64_stats_update_end(&s->syncp);
s = this_cpu_ptr(svc->stats.cpustats); s = this_cpu_ptr(svc->stats.cpustats);
u64_stats_update_begin(&s->syncp); u64_stats_update_begin(&s->syncp);
s->cnt.conns++; u64_stats_inc(&s->cnt.conns);
u64_stats_update_end(&s->syncp); u64_stats_update_end(&s->syncp);
s = this_cpu_ptr(ipvs->tot_stats->s.cpustats); s = this_cpu_ptr(ipvs->tot_stats->s.cpustats);
u64_stats_update_begin(&s->syncp); u64_stats_update_begin(&s->syncp);
s->cnt.conns++; u64_stats_inc(&s->cnt.conns);
u64_stats_update_end(&s->syncp); u64_stats_update_end(&s->syncp);
local_bh_enable(); local_bh_enable();
......
...@@ -2335,11 +2335,11 @@ static int ip_vs_stats_percpu_show(struct seq_file *seq, void *v) ...@@ -2335,11 +2335,11 @@ static int ip_vs_stats_percpu_show(struct seq_file *seq, void *v)
do { do {
start = u64_stats_fetch_begin(&u->syncp); start = u64_stats_fetch_begin(&u->syncp);
conns = u->cnt.conns; conns = u64_stats_read(&u->cnt.conns);
inpkts = u->cnt.inpkts; inpkts = u64_stats_read(&u->cnt.inpkts);
outpkts = u->cnt.outpkts; outpkts = u64_stats_read(&u->cnt.outpkts);
inbytes = u->cnt.inbytes; inbytes = u64_stats_read(&u->cnt.inbytes);
outbytes = u->cnt.outbytes; outbytes = u64_stats_read(&u->cnt.outbytes);
} while (u64_stats_fetch_retry(&u->syncp, start)); } while (u64_stats_fetch_retry(&u->syncp, start));
seq_printf(seq, "%3X %8LX %8LX %8LX %16LX %16LX\n", seq_printf(seq, "%3X %8LX %8LX %8LX %16LX %16LX\n",
......
...@@ -67,11 +67,11 @@ static void ip_vs_read_cpu_stats(struct ip_vs_kstats *sum, ...@@ -67,11 +67,11 @@ static void ip_vs_read_cpu_stats(struct ip_vs_kstats *sum,
if (add) { if (add) {
do { do {
start = u64_stats_fetch_begin(&s->syncp); start = u64_stats_fetch_begin(&s->syncp);
conns = s->cnt.conns; conns = u64_stats_read(&s->cnt.conns);
inpkts = s->cnt.inpkts; inpkts = u64_stats_read(&s->cnt.inpkts);
outpkts = s->cnt.outpkts; outpkts = u64_stats_read(&s->cnt.outpkts);
inbytes = s->cnt.inbytes; inbytes = u64_stats_read(&s->cnt.inbytes);
outbytes = s->cnt.outbytes; outbytes = u64_stats_read(&s->cnt.outbytes);
} while (u64_stats_fetch_retry(&s->syncp, start)); } while (u64_stats_fetch_retry(&s->syncp, start));
sum->conns += conns; sum->conns += conns;
sum->inpkts += inpkts; sum->inpkts += inpkts;
...@@ -82,11 +82,11 @@ static void ip_vs_read_cpu_stats(struct ip_vs_kstats *sum, ...@@ -82,11 +82,11 @@ static void ip_vs_read_cpu_stats(struct ip_vs_kstats *sum,
add = true; add = true;
do { do {
start = u64_stats_fetch_begin(&s->syncp); start = u64_stats_fetch_begin(&s->syncp);
sum->conns = s->cnt.conns; sum->conns = u64_stats_read(&s->cnt.conns);
sum->inpkts = s->cnt.inpkts; sum->inpkts = u64_stats_read(&s->cnt.inpkts);
sum->outpkts = s->cnt.outpkts; sum->outpkts = u64_stats_read(&s->cnt.outpkts);
sum->inbytes = s->cnt.inbytes; sum->inbytes = u64_stats_read(&s->cnt.inbytes);
sum->outbytes = s->cnt.outbytes; sum->outbytes = u64_stats_read(&s->cnt.outbytes);
} while (u64_stats_fetch_retry(&s->syncp, start)); } while (u64_stats_fetch_retry(&s->syncp, start));
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册