[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1394474774.3607.53.camel@edumazet-glaptop2.roam.corp.google.com>
Date: Mon, 10 Mar 2014 11:06:14 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: John Fastabend <john.fastabend@...il.com>
Cc: xiyou.wangcong@...il.com, jhs@...atatu.com, netdev@...r.kernel.org,
davem@...emloft.net
Subject: Re: [RCU PATCH 13/14] net: sched: make bstats per cpu and estimator
RCU safe
On Mon, 2014-03-10 at 10:08 -0700, John Fastabend wrote:
> +void
> +__gnet_stats_copy_basic_cpu(struct gnet_stats_basic_packed *bstats,
> + struct gnet_stats_basic_cpu *b)
> +{
> + int i;
> +
> + for_each_possible_cpu(i) {
> + struct gnet_stats_basic_cpu *bcpu = per_cpu_ptr(b, i);
> + unsigned int start;
> +
> + do {
> + start = u64_stats_fetch_begin_bh(&bcpu->syncp);
> + bstats->bytes += bcpu->bstats.bytes;
> + bstats->packets += bcpu->bstats.packets;
> + } while (u64_stats_fetch_retry_bh(&bcpu->syncp, start));
> + }
> +}
This is buggy. You need to use temporary variables, otherwise if the
retry is done, you add bcpu->bstats.bytes/packets multiple times.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists