]>
Commit | Line | Data |
---|---|---|
014275a0 GKH |
1 | From foo@baz Mon Oct 9 09:32:35 CEST 2017 |
2 | From: Eric Dumazet <edumazet@google.com> | |
3 | Date: Wed, 13 Sep 2017 11:16:45 -0700 | |
4 | Subject: net_sched: gen_estimator: fix scaling error in bytes/packets samples | |
5 | ||
6 | From: Eric Dumazet <edumazet@google.com> | |
7 | ||
8 | ||
9 | [ Upstream commit ca558e185972d8ecd308760abf972f5d408bcff0 ] | |
10 | ||
11 | Denys reported wrong rate estimations with HTB classes. | |
12 | ||
13 | It appears the bug was added in linux-4.10, since my tests | |
14 | where using intervals of one second only. | |
15 | ||
16 | HTB using 4 sec default rate estimators, reported rates | |
17 | were 4x higher. | |
18 | ||
19 | We need to properly scale the bytes/packets samples before | |
20 | integrating them in EWMA. | |
21 | ||
22 | Tested: | |
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 | |
30 | class htb 7002:11 parent 7002:1 prio 5 quantum 200000 rate 5Gbit ceil | |
31 | 5Gbit linklayer ethernet burst 80000b/1 mpu 0b cburst 80000b/1 mpu 0b | |
32 | level 0 rate_handle 1 | |
33 | Sent 1488215421648 bytes 982969243 pkt (dropped 0, overlimits 0 | |
34 | requeues 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 | ||
40 | Fixes: 1c0d32fde5bd ("net_sched: gen_estimator: complete rewrite of rate estimators") | |
41 | Signed-off-by: Eric Dumazet <edumazet@google.com> | |
42 | Reported-by: Denys Fedoryshchenko <nuclearcat@nuclearcat.com> | |
43 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
44 | Signed-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); |