Message ID | 1505326605.15310.193.camel@edumazet-glaptop3.roam.corp.google.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
Series | [net] net_sched: gen_estimator: fix scaling error in bytes/packets samples | expand |
From: Eric Dumazet <eric.dumazet@gmail.com> Date: Wed, 13 Sep 2017 11:16:45 -0700 > From: Eric Dumazet <edumazet@google.com> > > Denys reported wrong rate estimations with HTB classes. > > It appears the bug was added in linux-4.10, since my tests > where using intervals of one second only. > > HTB using 4 sec default rate estimators, reported rates > were 4x higher. > > We need to properly scale the bytes/packets samples before > integrating them in EWMA. > > Tested: ... > Fixes: 1c0d32fde5bd ("net_sched: gen_estimator: complete rewrite of rate estimators") > Signed-off-by: Eric Dumazet <edumazet@google.com> > Reported-by: Denys Fedoryshchenko <nuclearcat@nuclearcat.com> Applied and queued up for -stable, thanks Eric.
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c index 0385dece1f6fe5e26df1ce5f40956a79a2eebbf4..7c1ffd6f950172c1915d8e5fa2b5e3f77e4f4c78 100644 --- a/net/core/gen_estimator.c +++ b/net/core/gen_estimator.c @@ -83,10 +83,10 @@ static void est_timer(unsigned long arg) u64 rate, brate; est_fetch_counters(est, &b); - brate = (b.bytes - est->last_bytes) << (8 - est->ewma_log); + brate = (b.bytes - est->last_bytes) << (10 - est->ewma_log - est->intvl_log); brate -= (est->avbps >> est->ewma_log); - rate = (u64)(b.packets - est->last_packets) << (8 - est->ewma_log); + rate = (u64)(b.packets - est->last_packets) << (10 - est->ewma_log - est->intvl_log); rate -= (est->avpps >> est->ewma_log); write_seqcount_begin(&est->seq);