From patchwork Tue Jan 28 14:06:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 232580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6C3EC2D0DB for ; Tue, 28 Jan 2020 14:34:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7191D207FD for ; Tue, 28 Jan 2020 14:34:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580222041; bh=BDZEEsBK6AX+caJfyrsZPuxiKlFI9f3B0vVgXc6IL9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YAJFzzB9JzPySFarrZA/vN/0EdQXC4Fz4VFdhdDvpe0rxutuhuB56mdf8JlFFsvH9 Ngshg4OVlZggL/8BfjxPjekh8sXkhxZGvcSzMLg2Y3nkI2UccH4AQCru5zhrl8118M AYsjX5ndebK9ZHOnPR1kdHgzSK4AV6AXq3T+GkHo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732613AbgA1OYg (ORCPT ); Tue, 28 Jan 2020 09:24:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:51356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732572AbgA1OYg (ORCPT ); Tue, 28 Jan 2020 09:24:36 -0500 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 AEA112071E; Tue, 28 Jan 2020 14:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221475; bh=BDZEEsBK6AX+caJfyrsZPuxiKlFI9f3B0vVgXc6IL9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Smh+A9SJPuEjbWKEXever5gBTmQObmvfu9X1luRMrz8v/okNnKUAJfsG+isgKUXlz iH9s+i1/K4vKqw8kQwa/kieTxe3EYxoKSzQxSrkHo3LbybdPUY3lwGoC5kVcHfTC12 RGlIhaj8j91Jr6bkGOmIj591XL94filWx2ONahyg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , Eric Dumazet , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , netdev@vger.kernel.org Subject: [PATCH 4.9 240/271] tcp_bbr: improve arithmetic division in bbr_update_bw() Date: Tue, 28 Jan 2020 15:06:29 +0100 Message-Id: <20200128135910.406657627@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Wen Yang [ Upstream commit 5b2f1f3070b6447b76174ea8bfb7390dc6253ebd ] do_div() does a 64-by-32 division. Use div64_long() instead of it if the divisor is long, to avoid truncation to 32-bit. And as a nice side effect also cleans up the function a bit. Signed-off-by: Wen Yang Cc: Eric Dumazet Cc: "David S. Miller" Cc: Alexey Kuznetsov Cc: Hideaki YOSHIFUJI Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_bbr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c @@ -649,8 +649,7 @@ static void bbr_update_bw(struct sock *s * bandwidth sample. Delivered is in packets and interval_us in uS and * ratio will be <<1 for most connections. So delivered is first scaled. */ - bw = (u64)rs->delivered * BW_UNIT; - do_div(bw, rs->interval_us); + bw = div64_long((u64)rs->delivered * BW_UNIT, rs->interval_us); /* If this sample is application-limited, it is likely to have a very * low delivered count that represents application behavior rather than