From patchwork Wed Sep 13 18:16:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 813552 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X7plgPOS"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xsqcg1K21z9s7g for ; Thu, 14 Sep 2017 04:16:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751413AbdIMSQs (ORCPT ); Wed, 13 Sep 2017 14:16:48 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:37693 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312AbdIMSQr (ORCPT ); Wed, 13 Sep 2017 14:16:47 -0400 Received: by mail-pg0-f68.google.com with SMTP id v5so460772pgn.4 for ; Wed, 13 Sep 2017 11:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=3AZFesWB4/daoQ80nHIPCkD8LxbM6xH/K45LSIWspkY=; b=X7plgPOSU+AbxgAgWZWnG4FcdqavMrUv+fXhF8eD7qUXfjJDDjqCqlFlbI1ipV6NAn LXMtt9b3oB35LQZTB0hAHMjYIWu5qjskGU9UbrV5yTK9bOjvbvs3Vzi56trMX/IKX4cM EMTSf3nmqg6MzCk3Fb1k/p2XwADMZNN5gtz0WXoTumwE93ojnUpKGHNMYIRaCPDe4SfI MonKuN2E4aB2UFDk34SEtRU0O3ch6wuEkV5oJPO8tK+8+FtykcTrWkFH/oMzMp1urkoM fJjxacSxHRmAq0eUO8tD1ZIV4GTwx+yqKnZlnCuaIpH3VG6vrMT0Yyi9vOGvNJGucoPp EY6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=3AZFesWB4/daoQ80nHIPCkD8LxbM6xH/K45LSIWspkY=; b=HhYhw6o4qaJPoGVqUsixyzcQHfUTvJCccA3jUV3FU/6Vz3ReggNhjwWmVWOrEMrlpx MOLoL2RIpm8Oyx1lh/iZm5wT1pOJF4TnnyhLsb1etpVyuPLFj1AA7rFj8z+UPSVi6pWc C3f21SiE4wJV3IQ7TVurkxHGUyTX3IZ/bYQgvyVD9Jw2v9kng/faXspeOU1JGZx9OVE2 MGwVbUD6PqNsDl5eOaa9SSPxruIxCb/eeQoW7VZgNOAvKxz+YJwLqYFnRMhbdubJ4h7X 4VRbZ5a03lVH1e7dbJJJK/z24zSNQS0l4LHMGf7FyPn8tMBTLYjOReBg20J1dvFbn4Df hwdw== X-Gm-Message-State: AHPjjUj3/1STO1Y6gRE2KuojL1o8pSdpG19cfKf4cjMRjSjEdhhX8ysK Axx4XcNsnlSo3w== X-Google-Smtp-Source: ADKCNb4TZrj3ERmwUxiaAizwoCHvQCo4tHC/CLchEZyWiGZ5A8i7oBEC+Iyg4fXKK09LvvIpmgVz5A== X-Received: by 10.98.26.74 with SMTP id a71mr19049150pfa.286.1505326606894; Wed, 13 Sep 2017 11:16:46 -0700 (PDT) Received: from ?IPv6:2620:15c:2c1:100:6921:9c23:58e7:1e7? ([2620:15c:2c1:100:6921:9c23:58e7:1e7]) by smtp.googlemail.com with ESMTPSA id f24sm26026719pfk.137.2017.09.13.11.16.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:16:45 -0700 (PDT) Message-ID: <1505326605.15310.193.camel@edumazet-glaptop3.roam.corp.google.com> Subject: [PATCH net] net_sched: gen_estimator: fix scaling error in bytes/packets samples From: Eric Dumazet To: Denys Fedoryshchenko Cc: David Miller , netdev , Jamal Hadi Salim , Cong Wang , Jiri Pirko Date: Wed, 13 Sep 2017 11:16:45 -0700 In-Reply-To: <1505320949.15310.173.camel@edumazet-glaptop3.roam.corp.google.com> References: <4cd23914d8cc2cf5caf78cb5654fb245@nuclearcat.com> <1505319370.15310.169.camel@edumazet-glaptop3.roam.corp.google.com> <9b8cdc2b39fdd2d0be7b5f559b2034e7@nuclearcat.com> <1505320949.15310.173.camel@edumazet-glaptop3.roam.corp.google.com> X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet 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: echo 1 >/sys/module/sch_htb/parameters/htb_rate_est Setup HTB with one class with a rate/cail of 5Gbit Generate traffic on this class tc -s -d cl sh dev eth0 classid 7002:11 class htb 7002:11 parent 7002:1 prio 5 quantum 200000 rate 5Gbit ceil 5Gbit linklayer ethernet burst 80000b/1 mpu 0b cburst 80000b/1 mpu 0b level 0 rate_handle 1 Sent 1488215421648 bytes 982969243 pkt (dropped 0, overlimits 0 requeues 0) rate 5Gbit 412814pps backlog 136260b 2p requeues 0 TCP pkts/rtx 982969327/45 bytes 1488215557414/68130 lended: 22732826 borrowed: 0 giants: 0 tokens: -1684 ctokens: -1684 Fixes: 1c0d32fde5bd ("net_sched: gen_estimator: complete rewrite of rate estimators") Signed-off-by: Eric Dumazet Reported-by: Denys Fedoryshchenko --- net/core/gen_estimator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);