Subject: Re: [net-next PATCH 1/4] net: sched: make bstats per cpu and estimator RCU safe

From: John Fastabend <[email-masked]>
Date: Fri, 26 Sep 2014 11:21:47 -0700

On 09/26/2014 11:13 AM, John Fastabend wrote:
> From: John Fastabend <[email-masked]>
> 
> In order to run qdisc's without locking statistics and estimators
> need to be handled correctly.
> 
> To resolve bstats make the statistics per cpu. And because this is
> only needed for qdiscs that are running without locks which is not
> the case for most qdiscs in the near future only create percpu
> stats when qdiscs set the TCQ_F_CPUSTATS flag.
> 
> Next because estimators use the bstats to calculate packets per
> second and bytes per second the estimator code paths are updated
> to use the per cpu statistics.
> 
> Signed-off-by: John Fastabend <[email-masked]>
> ---

[...]

>  	return 0;
> diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
> index 37e7d25..2f0ecd7 100644
> --- a/net/sched/sch_mqprio.c
> +++ b/net/sched/sch_mqprio.c
> @@ -234,8 +234,8 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb)
>  		qdisc = rtnl_dereference(netdev_get_tx_queue(dev, i)->qdisc);
>  		spin_lock_bh(qdisc_lock(qdisc));
>  		sch->q.qlen		+= qdisc->q.qlen;
> -		sch->bstats.bytes	+= qdisc->bstats.bytes;
> -		sch->bstats.packets	+= qdisc->bstats.packets;
> +		sch->bstats->bytes	+= qdisc->bstats.bytes;
> +		sch->bstats->packets	+= qdisc->bstats.packets;
>  		sch->qstats.qlen	+= qdisc->qstats.qlen;
>  		sch->qstats.backlog	+= qdisc->qstats.backlog;

OK v2 coming this patch got messed up and then fixed in the third
patch.

If you look at the bstats definition you'll see this obviously
wont compile. The end result is good but it wont bisect.

.John