Subject: Re: [RCU PATCH 13/14] net: sched: make bstats per cpu and estimator RCU safe

From: John Fastabend <[email-masked]>
Date: Mon, 10 Mar 2014 12:36:38 -0700

On 03/10/2014 11:06 AM, Eric Dumazet wrote:
> 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.
>
>

Yep I'll fix this and your other comments when I respin this set. Thanks
for taking a look over the patches.

-- 
John Fastabend         Intel Corporation