Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3300880ybb; Tue, 31 Mar 2020 02:25:43 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsWG60UZg7Kwb0e1zFQ4RAsSatrezN7zXLdhMWA7CEIEsFKg//H30/WbWt1i1fS5tHl/Ofg X-Received: by 2002:a9d:82a:: with SMTP id 39mr2446025oty.82.1585646743698; Tue, 31 Mar 2020 02:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585646743; cv=none; d=google.com; s=arc-20160816; b=HDyadMxzmM0jT1tEgynVosrcT6/i+79O5H6RZ/uBvhljfScrddr+tV7DqoRUV5rksg vawqRnLaA0gZYA2iUkxcH4GT2LcaIaggTdDY9kXXY9lZIONTKGy7PDLFR4qUUlwu/Q44 zp+5Xaz7KHtam4TyD6iS+kP9AMZwwKB0jNd/VNDaM0pTVYKy4ERR8e9yBxjOxuNuZZ/n HPWlts/scxq/dzGVRWN01doTgfAn2U2nQQeduygNilKaGVhsPmxu4jBJCPNudEYYjVSW 0cX8Z/f6XqCCa38XOEb2N5laA11/iD2zzv2GUO8P/dbqLWZPviiFD5jyAJdju9N1mLOc cSxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HLJhQ/8Y4GbQn32XVwqu7aiQyOS43LfVtocVS4jBsXU=; b=j5pRQis2w0o1YOM2tkdKv6SqC098RAn7dwniYB8QT45R7cUW2JJbBVBrcgsP4o6H53 j90gq1J6EGPTZryUCcO0TWNGrEv1ARqs+zGX70FJ5W4+mBBgucaTmi1rETRcOqCdvYwG LeEGPKvOc2wHpyWLRndpKia/38r+BYFtEMdM4FNGZLsisrR1qFEM7+Yulxdn3USLK6ZG om7SX73WWWezDb3ayy7RKdmmDgBL3GTUyzs7rkds1J3r3oZ7WP8Lm2iIaf3GY0bfjJEN Mu+K91GqatBSjHmyjiBtTe4UyKsHgfILEXEDmOvaZvw41aEsijctZ1kAWLF3wID8BDA8 c4fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hh/L+sRi"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f21si7671850otf.31.2020.03.31.02.25.31; Tue, 31 Mar 2020 02:25:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hh/L+sRi"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730412AbgCaJCB (ORCPT + 99 others); Tue, 31 Mar 2020 05:02:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:41368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730633AbgCaJB6 (ORCPT ); Tue, 31 Mar 2020 05:01:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8F09720787; Tue, 31 Mar 2020 09:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645318; bh=Z2eQWQQd09Y24ml54/ptlmTqM1M5MaTLo8/U7dsFmKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hh/L+sRinOYlhCRGjzYDq0aq9zJgsvjwoNHRZZKiIslKHhF6hq2myCqjdIOKtxC2s TZJFy9nUETb/YDAYSpjwJtBGqgcMJgbMIC3pJl4gN+4oWCaGSUJgVqv0Bu+vl6ZNCh KWHqBx6LCZpVO1ea4d4CCTvvmQGoBJKqLb/FIwN4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zh-yuan Ye , Vinicius Costa Gomes , "David S. Miller" Subject: [PATCH 5.5 017/170] net: cbs: Fix software cbs to consider packet sending time Date: Tue, 31 Mar 2020 10:57:11 +0200 Message-Id: <20200331085425.913405950@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zh-yuan Ye [ Upstream commit 961d0e5b32946703125964f9f5b6321d60f4d706 ] Currently the software CBS does not consider the packet sending time when depleting the credits. It caused the throughput to be Idleslope[kbps] * (Port transmit rate[kbps] / |Sendslope[kbps]|) where Idleslope * (Port transmit rate / (Idleslope + |Sendslope|)) = Idleslope is expected. In order to fix the issue above, this patch takes the time when the packet sending completes into account by moving the anchor time variable "last" ahead to the send completion time upon transmission and adding wait when the next dequeue request comes before the send completion time of the previous packet. changelog: V2->V3: - remove unnecessary whitespace cleanup - add the checks if port_rate is 0 before division V1->V2: - combine variable "send_completed" into "last" - add the comment for estimate of the packet sending Fixes: 585d763af09c ("net/sched: Introduce Credit Based Shaper (CBS) qdisc") Signed-off-by: Zh-yuan Ye Reviewed-by: Vinicius Costa Gomes Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/sch_cbs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/net/sched/sch_cbs.c +++ b/net/sched/sch_cbs.c @@ -181,6 +181,11 @@ static struct sk_buff *cbs_dequeue_soft( s64 credits; int len; + /* The previous packet is still being sent */ + if (now < q->last) { + qdisc_watchdog_schedule_ns(&q->watchdog, q->last); + return NULL; + } if (q->credits < 0) { credits = timediff_to_credits(now - q->last, q->idleslope); @@ -212,7 +217,12 @@ static struct sk_buff *cbs_dequeue_soft( credits += q->credits; q->credits = max_t(s64, credits, q->locredit); - q->last = now; + /* Estimate of the transmission of the last byte of the packet in ns */ + if (unlikely(atomic64_read(&q->port_rate) == 0)) + q->last = now; + else + q->last = now + div64_s64(len * NSEC_PER_SEC, + atomic64_read(&q->port_rate)); return skb; }