Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3183264ioo; Tue, 24 May 2022 15:28:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwYAHLhTAejLOhb9axRm3Old1v5lgQInI/uFZQS2BapbPWKC2Np4kG2K0TrRPKimnCQzku X-Received: by 2002:a17:902:bf0a:b0:162:201e:1f49 with SMTP id bi10-20020a170902bf0a00b00162201e1f49mr12612519plb.39.1653431302367; Tue, 24 May 2022 15:28:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653431302; cv=none; d=google.com; s=arc-20160816; b=R66ev5CBseA7YMlEI4ExAPyw83AtJE03rgDbhlyfmXxFkomebX6PfYScmodN2KHPx1 tcYnKIuP+vWHoB+9ka3b7UrxcZVJBMy4FIjkylNP+pkdJEulZFDOT1B+E7QcAqmT4V4l Ruk7S65Krwy+HMWMSTiuBvP5qqrLQDQz28j5oMctiENQWqiozTokukEHxiVFqtbC7008 uLhovunGg7gPBs0Mm4L3sG6xStW+Hto0W3PH1mwuCuSjSKIjWem505aXfcrM2SD7Nr3B 1FJyCHapEsGrpkpwMuEnqVhWFqPqUBiYohSLMVagpgbqwHBF0mYZoXQpqmg1czyDCDJ4 zcVQ== 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=Jkbsj8ZwrUi7OObfgCh/4Ar2JNwqZvHZHWjqqEl/+jU=; b=t8Zm45NtYxlxiAjkv1J5/ce0/0zzWP3bJx+/uIspkNeNWQlOmmciRGJ8LmB9pcAeqv mpzg9IqPBtiIW7a56+juWzc51QzmkElHz33B3p3SiDKxHo5Bs7jt9jK+zLODf+zqqbnm EwR4PdthFnINXSVDS0+T5N9RXlD1UpFc5kPlor7cHvbfVLWDJVA+s02ga7C6KxNsreVg hAl4UBj/d2VTsVctuBxhof0XQhTmS0XdU716bnZe1cNvikbQ+NOgK3pelLtyDy1JhVmg pEbry89VM361DTUEQzzdcDZFoBNErfNUwP0iGC+2/pq06Oj0NvCNWWdQVEPyEQ3ch9S3 Cxdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=DcF4IOey; 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 b13-20020a6541cd000000b0039d3f493fb0si15709137pgq.851.2022.05.24.15.28.11; Tue, 24 May 2022 15:28:22 -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=DcF4IOey; 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 S241065AbiEXUXF (ORCPT + 99 others); Tue, 24 May 2022 16:23:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241126AbiEXUXD (ORCPT ); Tue, 24 May 2022 16:23:03 -0400 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E51CC5D5E6 for ; Tue, 24 May 2022 13:23:01 -0700 (PDT) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-2fee010f509so194016147b3.11 for ; Tue, 24 May 2022 13:23:01 -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=Jkbsj8ZwrUi7OObfgCh/4Ar2JNwqZvHZHWjqqEl/+jU=; b=DcF4IOeyC1v9Z+v2nErxKz1G/LVvOm7gwchisLgHi3xQICx+mu9q8u8QSxLDgwtJL7 OASbpLKso3Ab2vBCILTtKzTqwplcynpS/nLv+j0EXAJg+k273y2lNWN6MgWpwZ332kia F6krBjU4uSNwOq/li1dfZwgb3BT/NJtcAV6p818t1T1R3QLXyQ+vECn3AUXir0V0tr98 nINilkpN2pFDLxd8/0NwlHmAzpA/xM2X532i3r7+gAyzrDoXYSALN0p0Yq8IBDWZFNWz YSKW79yB9lklVhZ27eh3a8dhXhyCyJ9vS5G6xa56h5Qht+nUE1h/9n3qQ2RJ4z0Po9MI RnZw== 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=Jkbsj8ZwrUi7OObfgCh/4Ar2JNwqZvHZHWjqqEl/+jU=; b=m6ds9jvJc0AUNNWODwnHoWS9Jvs2On1IvYewPEpDwbiHPFfE7XDDqYOfhePsL2r1z6 hVV2gJ8fVti3V2iu7e9xo6DMzpWHeFR1sJlGNR7mRCDVnu1L4VsldTO+gf+wv3Fg+nFL id7hwN0WOpSERWvLNAICKbB8Vvod/lk2sSsISN+aYLG/y3HS78nZ9UCB8fbETE8jYo+E SOGAN42VmEMKBzQAcZn7TDjAl8OqQqKx9TS6nIQC8zNvK9MIAaAOFv9ZHKaRTAQ6wU5p Ch2dauKLvTjElcCRI9/Wo2SMVGioR5EF+DLZmMVFlmmruVYmwEMLO2bZ6+5XfQWPj2pM eS1g== X-Gm-Message-State: AOAM5303YacJnsK7Bt+Aowz1xX+Py9NBtnH2Mwc/71JH4wJcL4p2Marn qR/QZOq8VZHIBUgJOFHSmEdX+uqeb39+nF7AX5XBKQ== X-Received: by 2002:a81:b401:0:b0:300:2e86:e7e5 with SMTP id h1-20020a81b401000000b003002e86e7e5mr4238965ywi.467.1653423780877; Tue, 24 May 2022 13:23:00 -0700 (PDT) MIME-Version: 1.0 References: <4740526.31r3eYUQgx@natalenko.name> <4bd84c983e77486fbc94dfa2a167afaa@AcuMS.aculab.com> In-Reply-To: From: Eric Dumazet Date: Tue, 24 May 2022 13:22:49 -0700 Message-ID: Subject: Re: [RFC] tcp_bbr2: use correct 64-bit division To: Neal Cardwell Cc: David Laight , Oleksandr Natalenko , Yuchung Cheng , Yousuk Seung , Soheil Hassas Yeganeh , Adithya Abraham Philip , "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 1:06 PM Neal Cardwell wrote: > > 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. > Not sure I follow. sk_pacing_rate is also 'unsigned long' So tcp_tso_autosize() is correct on 32bit and 64bit arches. There is no forced 64bit operation there. > Eric, what do you advise? > > thanks, > neal