]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.13.6/net_sched-gen_estimator-fix-scaling-error-in-bytes-packets-samples.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.13.6 / net_sched-gen_estimator-fix-scaling-error-in-bytes-packets-samples.patch
CommitLineData
014275a0
GKH
1From foo@baz Mon Oct 9 09:32:35 CEST 2017
2From: Eric Dumazet <edumazet@google.com>
3Date: Wed, 13 Sep 2017 11:16:45 -0700
4Subject: net_sched: gen_estimator: fix scaling error in bytes/packets samples
5
6From: Eric Dumazet <edumazet@google.com>
7
8
9[ Upstream commit ca558e185972d8ecd308760abf972f5d408bcff0 ]
10
11Denys reported wrong rate estimations with HTB classes.
12
13It appears the bug was added in linux-4.10, since my tests
14where using intervals of one second only.
15
16HTB using 4 sec default rate estimators, reported rates
17were 4x higher.
18
19We need to properly scale the bytes/packets samples before
20integrating them in EWMA.
21
22Tested:
23 echo 1 >/sys/module/sch_htb/parameters/htb_rate_est
24
25 Setup HTB with one class with a rate/cail of 5Gbit
26
27 Generate traffic on this class
28
29 tc -s -d cl sh dev eth0 classid 7002:11
30class htb 7002:11 parent 7002:1 prio 5 quantum 200000 rate 5Gbit ceil
315Gbit linklayer ethernet burst 80000b/1 mpu 0b cburst 80000b/1 mpu 0b
32level 0 rate_handle 1
33 Sent 1488215421648 bytes 982969243 pkt (dropped 0, overlimits 0
34requeues 0)
35 rate 5Gbit 412814pps backlog 136260b 2p requeues 0
36 TCP pkts/rtx 982969327/45 bytes 1488215557414/68130
37 lended: 22732826 borrowed: 0 giants: 0
38 tokens: -1684 ctokens: -1684
39
40Fixes: 1c0d32fde5bd ("net_sched: gen_estimator: complete rewrite of rate estimators")
41Signed-off-by: Eric Dumazet <edumazet@google.com>
42Reported-by: Denys Fedoryshchenko <nuclearcat@nuclearcat.com>
43Signed-off-by: David S. Miller <davem@davemloft.net>
44Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
45---
46 net/core/gen_estimator.c | 4 ++--
47 1 file changed, 2 insertions(+), 2 deletions(-)
48
49--- a/net/core/gen_estimator.c
50+++ b/net/core/gen_estimator.c
51@@ -83,10 +83,10 @@ static void est_timer(unsigned long arg)
52 u64 rate, brate;
53
54 est_fetch_counters(est, &b);
55- brate = (b.bytes - est->last_bytes) << (8 - est->ewma_log);
56+ brate = (b.bytes - est->last_bytes) << (10 - est->ewma_log - est->intvl_log);
57 brate -= (est->avbps >> est->ewma_log);
58
59- rate = (u64)(b.packets - est->last_packets) << (8 - est->ewma_log);
60+ rate = (u64)(b.packets - est->last_packets) << (10 - est->ewma_log - est->intvl_log);
61 rate -= (est->avpps >> est->ewma_log);
62
63 write_seqcount_begin(&est->seq);