Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1672641ioo; Sun, 22 May 2022 23:53:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI0j0C0cgAmWgMue9AZDiVLZmBq0hRKK/dxndXe35jq3kUQpC4yf2KJu2UR7sOrTByJ/8h X-Received: by 2002:a17:903:124b:b0:15e:84d0:ded6 with SMTP id u11-20020a170903124b00b0015e84d0ded6mr21261708plh.141.1653288787379; Sun, 22 May 2022 23:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653288787; cv=none; d=google.com; s=arc-20160816; b=xSjpU77/Sqs5g6WPy3hwZeYZNJxe3IkBy5tgorWhjOp1NXRxs1VVypcb+6Qsvyd1ua qKDpG2dePWECEksPW3h35sFG2utMkcIdNpagFpX71RjTEn1UfxEqWW9JAFBstdEWQ6sy TUlL65sb5O9xbfvP33VePLj4CLSwb31bhIKfMV0CYgRzfeFACEA+hmC3ZprQm6h5kVwy ek+CKGmlrRt+WNSGccbEo0Zk3k63os33xMbZrqFvTGK4g5U/EA0DpyNDiClQLAaUQT3q 334TJombZlBM8WdccCo28ikvSqlYsFUPM2M7uCiEdzGv9EEMPIFAzONPxYheEpYdWmU7 esxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5RsrrUIcLxd7wE1ZN1EHer8TNCgmy1gA2oqSx8f1A4U=; b=QS6oFhE9BbXozwmqKUpLQRhIVU1JEm28wuCZ9XKbc/WSTsJ74Z/jBMBJzWG4rXgNA0 qrW1yO6a/AD5sM5+jB1LvTDodyU2g8aMsydPG3T3ome/v1B/X0Jg4gDKB9IU5dYgHmnw rwE7L19/iKlD2Gq4yut4WopfCwd9wz4t+zC3NrxO03cXXgAYVcBwxz7tJYoqirpdWq4g AJHG1EKooYRG+Y31+iO4N4FlL9bI5K1UdCp09VcJYcLL0nm/kqeSb4Mdc+WEs923rWy2 h5XWeq3U1TVNg4pxA8UQsQRJVbCVMg5Ztl/rVzRw5aJPfWTiX0HQi/JIzDBmIZb6h6VH qPgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@natalenko.name header.s=dkim-20170712 header.b=CAZ76pAx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=natalenko.name Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bw26-20020a056a00409a00b005107be11e23si9661082pfb.137.2022.05.22.23.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:53:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@natalenko.name header.s=dkim-20170712 header.b=CAZ76pAx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=natalenko.name Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 668635714B; Sun, 22 May 2022 23:20:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230315AbiEVW3q (ORCPT + 99 others); Sun, 22 May 2022 18:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbiEVW3o (ORCPT ); Sun, 22 May 2022 18:29:44 -0400 Received: from vulcan.natalenko.name (vulcan.natalenko.name [IPv6:2001:19f0:6c00:8846:5400:ff:fe0c:dfa0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 607BA35DFE; Sun, 22 May 2022 15:29:42 -0700 (PDT) Received: from spock.localnet (unknown [83.148.33.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by vulcan.natalenko.name (Postfix) with ESMTPSA id 0F3EDEFB219; Mon, 23 May 2022 00:29:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=natalenko.name; s=dkim-20170712; t=1653258579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5RsrrUIcLxd7wE1ZN1EHer8TNCgmy1gA2oqSx8f1A4U=; b=CAZ76pAxkI/iO9yjqzNcud839rZ1d8coHmFN2PAERvzQf9j7kYZlZwl5cLM4fm/mLKnhBe fVjHf6M6jcbMDLSGiwh3OIx+frgWItdBn3EtDvj+h/kPmYXC4QH5wiBNGe2hr/Q5T4LlyF x5KrUorPIJPSk/xombCixocebHreoDk= From: Oleksandr Natalenko To: Neal Cardwell Cc: Yuchung Cheng , Yousuk Seung , Soheil Hassas Yeganeh , Adithya Abraham Philip , Eric Dumazet , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Konstantin Demin Subject: [RFC] tcp_bbr2: use correct 64-bit division Date: Mon, 23 May 2022 00:29:37 +0200 Message-ID: <4740526.31r3eYUQgx@natalenko.name> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Neal. It was reported to me [1] by Konstantin (in Cc) that BBRv2 code suffers from integer division issue on 32 bit systems. Konstantin suggested a solution available in the same linked merge request and copy-pasted by me below for your convenience: ``` diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c index 664c9e119787..fd3f89e3a8a6 100644 --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c @@ -312,7 +312,7 @@ static u32 bbr_tso_segs_generic(struct sock *sk, unsigned int mss_now, bytes = sk->sk_pacing_rate >> sk->sk_pacing_shift; bytes = min_t(u32, bytes, gso_max_size - 1 - MAX_TCP_HEADER); - segs = max_t(u32, bytes / mss_now, bbr_min_tso_segs(sk)); + segs = max_t(u32, div_u64(bytes, mss_now), bbr_min_tso_segs(sk)); return segs; } diff --git a/net/ipv4/tcp_bbr2.c b/net/ipv4/tcp_bbr2.c index fa49e17c47ca..488429f0f3d0 100644 --- a/net/ipv4/tcp_bbr2.c +++ b/net/ipv4/tcp_bbr2.c @@ -588,7 +588,7 @@ static void bbr_debug(struct sock *sk, u32 acked, bbr_rate_kbps(sk, bbr_max_bw(sk)), /* bw: max bw */ 0ULL, /* lb: [obsolete] */ 0ULL, /* ib: [obsolete] */ - (u64)sk->sk_pacing_rate * 8 / 1000, + div_u64((u64)sk->sk_pacing_rate * 8, 1000), acked, tcp_packets_in_flight(tp), rs->is_ack_delayed ? 'd' : '.', @@ -698,7 +698,7 @@ static u32 bbr_tso_segs_generic(struct sock *sk, unsigned int mss_now, } bytes = min_t(u32, bytes, gso_max_size - 1 - MAX_TCP_HEADER); - segs = max_t(u32, bytes / mss_now, bbr_min_tso_segs(sk)); + segs = max_t(u32, div_u64(bytes, mss_now), bbr_min_tso_segs(sk)); return segs; } ``` Could you please evaluate this report and check whether it is correct, and also check whether the suggested patch is acceptable? Thanks. [1] https://gitlab.com/post-factum/pf-kernel/-/merge_requests/6 -- Oleksandr Natalenko (post-factum)