Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3264567ioo; Tue, 24 May 2022 18:08:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6kmiNxb0/ePLoUujcPLVEkOLqihQd+sIaVKauBZGFdGzpfWR+KPbQyXEN2tkCIuBAdKxp X-Received: by 2002:a17:90b:4a90:b0:1df:e3af:c6ad with SMTP id lp16-20020a17090b4a9000b001dfe3afc6admr7426772pjb.41.1653440905635; Tue, 24 May 2022 18:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653440905; cv=none; d=google.com; s=arc-20160816; b=S03qqf84HX71GGknA+WXfe/au4cH5hdOvE3fcG8Q9HLhe03C2ZqbpSWC/ov+zMLZEA 9pgOxWT2m76sEjrqI7OKKG4dRtE63W70biqPtEoW0Wm81sJcQvHJ7uiFe8SXQaJQGA5O 3i2v3qHRt2bA+FByXARbJ09aW7+Ef4fTqQWpVsuL6NlpRrmCNMyqNYG8k2lzoFADXq4+ AD6WM//tPKT4Z26cIIa4jugiqBvfeLy8LJxVKsvsMkx9OaTxmL0Pa/CHAxZ6UxKrJkFh 5dUkoLbih9TxZodLpRPlz2FNtwwMo2YbWCaCRl9jrNG9JR1LP83pEa8mBjljQaWRlFmK tEmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Ym/o0L3Nl69cG1A2Xo5lifLxAYgZkmivMwTbScZGC3I=; b=ljBtKM1xOdKABwCJUEVuHRnbbhUek29AhTZUTAWwmN8SewC4bGfWXK+8d/ec+036CI iYBM0eG7hElQtA5PXPybWsNK4qzDmOmGVK5KKUMjqJZbM4SIZbDZMQ0Z5sFbv96bt0Q2 TZPoIJ6YLigtmsvUk8N475aKLuhV6oiFaFUZsYM88WzWMPM5S0CM5vhZwubv3JKdfaZ2 cXOluZNeZwWbKQiSMSqRcywPKDeHTKDIas7/+6dTiPksCPVehL6yNycsxKG62OYJYKIT G0DSsxniS5MfQ05+MR2ZAl511NRxBzK41c3gt8cWbyydspy3wgajqbcy12SuU8A4wXEH R60A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RnI7UYRM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a7-20020a637047000000b003f61820466fsi16079763pgn.578.2022.05.24.18.08.13; Tue, 24 May 2022 18:08:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RnI7UYRM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241393AbiEXUGQ (ORCPT + 99 others); Tue, 24 May 2022 16:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241357AbiEXUGN (ORCPT ); Tue, 24 May 2022 16:06:13 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1422012090 for ; Tue, 24 May 2022 13:06:12 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id i68so14640919qke.11 for ; Tue, 24 May 2022 13:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ym/o0L3Nl69cG1A2Xo5lifLxAYgZkmivMwTbScZGC3I=; b=RnI7UYRMhN/m1uMDa0epxjtwUkq/d8vFEjV1+V/JI8i7DG80dyyRWMqMt1anU+rFFL 42ppoiixx9cPtJEtCRkWdFWPA39J92U89m0UemSsAWVNCOUlQMfYKACbHotgndUOd5rR cNt5VB64ib3tGjHELvxQCr9StabUmLCE1xklVQS2Dv6yVyvhK+Po1d6WFJkAQm93Q5D6 0R4iB9cPAuw1Ui2d8/UOn3xkVfH+PVJYNbkAvz51vsVh4I5hKTJ6P5NCcJTTLdRxA6D7 Th2l4X73mYo139zkEV3Bn7ckNU7zfwaCzsEPmO7yWXQxWjEp0ELAuIxhy2o8x06GgmR4 nbuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ym/o0L3Nl69cG1A2Xo5lifLxAYgZkmivMwTbScZGC3I=; b=RTPIPp3fvzV9hcscD7CpNWndqWciVnnFgrtPV5lXpd9wf8b6EebK6wHPH2Ln86KLO0 s1oIGLrwbPij0WSQel2BYOHg9J4OzF/eFOEUhGenu/2B0HeA76eoGSpJRjqP+30q0SUP 4JLQ4UzcrVWn8jfQ9dHO0chL+PuMFQEx9QvKhhnelj/Bdsn9kWxq5T3h0FaTSys1nVIr FQIN/llPK8DR6IDmyeuDT4kG5KyPbUNL/ss8YgMoYZnRB6cEFyZnUNiyrS/pRA7rTa+W 047id1jKRPNomIkrnxGWIcKxaHI8OyyMqN5zZTYzc+7VLAXLNIeAPm+pJFOQ/XMlxoer V1Wg== X-Gm-Message-State: AOAM533BodJ0/j51jX+9qW9NRFgWoZqq8U31Fe74sRcGb8f4YqFwz034 HUPKCT+joqljSzbqxzWb2qLmYAqfG+0YweSta3BCXg== X-Received: by 2002:a05:620a:1aa1:b0:6a3:8dd8:7173 with SMTP id bl33-20020a05620a1aa100b006a38dd87173mr7921272qkb.434.1653422771014; Tue, 24 May 2022 13:06:11 -0700 (PDT) MIME-Version: 1.0 References: <4740526.31r3eYUQgx@natalenko.name> <4bd84c983e77486fbc94dfa2a167afaa@AcuMS.aculab.com> In-Reply-To: <4bd84c983e77486fbc94dfa2a167afaa@AcuMS.aculab.com> From: Neal Cardwell Date: Tue, 24 May 2022 16:05:55 -0400 Message-ID: Subject: Re: [RFC] tcp_bbr2: use correct 64-bit division To: David Laight Cc: Oleksandr Natalenko , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 On Tue, May 24, 2022 at 4:01 AM David Laight wrote: > > From: Oleksandr Natalenko > > Sent: 22 May 2022 23:30 > > To: Neal Cardwell > > > > Hello Neal. > > > > It was reported to me [1] by Konstantin (in Cc) that BBRv2 code suffers from integer division issue on > > 32 bit systems. > > Do any of these divisions ever actually have 64bit operands? > Even on x86-64 64bit divide is significantly slower than 32bit divide. > > It is quite clear that x * 8 / 1000 is the same as x / (1000 / 8). > So promoting to 64bit cannot be needed. > > David The sk->sk_pacing_rate can definitely be bigger than 32 bits if the network path can support more than 34 Gbit/sec (a pacing rate of 2^32 bytes per sec is roughly 34 Gibt/sec). This definitely happens. So this one seems reasonable to me (and is only in debug code, so the performance is probably fine): - (u64)sk->sk_pacing_rate * 8 / 1000, + div_u64((u64)sk->sk_pacing_rate * 8, 1000), For the other two I agree we should rework them to avoid the 64-bit divide, since we don't need it. There is similar logic in mainline Linux in tcp_tso_autosize(), which is currently using "unsigned long" for bytes. Eric, what do you advise? thanks, neal