Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp611182pxb; Tue, 15 Feb 2022 23:44:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqDS1LGE8YbDa66MweR+0zcpaK4yd7TUzQ5CNnhLpkWbcGM1QEmys3grfUJV7F0cxlbDwd X-Received: by 2002:a63:b10:0:b0:373:393f:2015 with SMTP id 16-20020a630b10000000b00373393f2015mr1271719pgl.322.1644997480485; Tue, 15 Feb 2022 23:44:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644997480; cv=none; d=google.com; s=arc-20160816; b=w2WNkG2f516d3xzNjps8ur7qsVqa5dmn7SrbPXUHlcjC9pzHZ+QpoiK0yHMfLVJ/Zq F0+XKQVoAO+TiXUsX8ibhs78jnhILp9EYinex8PDDoRwwusT8AHx4CpA2hQSGOoixU95 Ykh6Z5bG8Jv6i18Ai9uMp8Qa06uo0fGZpZoujV2Xp/Ev4/OoDbxoDJx513e5OipkX6is L4ccIFK95CbflnYrNSwTfcVW8OS3mhaxgkDl52+MAuRFjBiTlc9+p6BbtpNHilMdMfAN h6BaaW0SSDu+G0qfMaOc/IcwWBnIva+jjx6+gJMwSc6FNcjb+zS9xMAFQuLJ9djCMK3q Udog== 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=HPnpyaqK8o0G+BDi3MOPV+BIITLVz5fggVzk9O3L6oE=; b=0Zj52GwpmVsraptl0CxAum8kRWNOnd5T7EG/0wkUa4uj0fAYbdzY/WoO35S7Kx3BzA cneqVQE7Di1lv4ny264ArdHAfJWVRA2h9qEoHz+CnzAqyOQwSBLBUalq0+e5v+OG5a3M Qf1qr43an+dSyJKZA45r8J502GNJaF6bizcFLXrFqm1TaVEZjasSXwfgC96Dz5nQyHGK zO7Xxp9p1WBGxN6VN8j9kz9TCwy+0tpS2DsSlMfwn4TmMC2DNljjfQDcgSYgc5yomg78 vV58djPVVQueHDP5g5WBFSKyfoDZMBmbcwp/8CvaaVrOkbaJZfQLKUbdEzn2OvMpC1RD xRNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XimW3gvA; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pg15si9426121pjb.108.2022.02.15.23.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 23:44:40 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=XimW3gvA; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 38C2DE72B6; Tue, 15 Feb 2022 23:09:55 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbiBPHIE (ORCPT + 99 others); Wed, 16 Feb 2022 02:08:04 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:37334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229664AbiBPHHy (ORCPT ); Wed, 16 Feb 2022 02:07:54 -0500 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 788631E5F0E; Tue, 15 Feb 2022 23:07:11 -0800 (PST) Received: by mail-oi1-x230.google.com with SMTP id ay7so1518286oib.8; Tue, 15 Feb 2022 23:07:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HPnpyaqK8o0G+BDi3MOPV+BIITLVz5fggVzk9O3L6oE=; b=XimW3gvAMYPUVjF2IfQeAZU5JtieMUXI4Mqg4RoDikjeO02qvlF09bWWSj55zjEco4 Dvhvaib85Rsx88hpMqfQ6o5oDVe1xRSc1E4ERx/nrJPlAHsYBcEzyGlfcm0fvNHIEWos bj9Es0ztCnsDrOnEWYAr0PDuAcFUkYCIJCt88bC6e32UiWW6OYfjvMHEbIlEERAo1OeO CvgNC9rP97nYVk3jAull0vPOXprFve6kY+Ehds3LwzHIQKFObmgdJo9NTQipUDl9CW3P HGTPV3BBDyeL3hofNlN5TTtU6jrdz+eGGtEPjdYxof5sZCdZBAGbzXyCepaS1tzbBaXU 03KQ== 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=HPnpyaqK8o0G+BDi3MOPV+BIITLVz5fggVzk9O3L6oE=; b=YzOlwS6GtjvPq186VXq0BHIU8W0cBMgnalkYgcXEqj9VJlcsZCDxzGCA4Eitrn0sai fwNF4K9DXCHnrY1HvIJXl3pZ66sGqvdknqCJwnwFUdZeQR0971gSmhnFUp3UsoRTJUjo 9ZYd8WTCzS49bHh13ZOURdz4bQm0gnhySCYxg9VnjTzi14DOh8E37/Sz6sk+m9309cyh Ksv7xUGbwzat/3v2wLowivtmdZzbZ+/ib2o6KNblpVI1fNK8L+RpP5xHZXRkxAhmeVGz ib3PuiQHFX8tO6kODNiHGomGbkBzqf5cq8CUtGeqQxBpNqjY/zJl9a96ahnvI2n/3YnY obbQ== X-Gm-Message-State: AOAM533Z7idjSKXw7/un+11NKqBstuG/Z70roNQ0JQ19zhhEl1yLaYXa 9BpAOCOYY75fKDwsEYk1m97S6JjqIAiX5/JPL4K+Uy2UcqgQFxZSWG0= X-Received: by 2002:aca:1812:0:b0:2d4:426d:c9e0 with SMTP id h18-20020aca1812000000b002d4426dc9e0mr62879oih.129.1644994686459; Tue, 15 Feb 2022 22:58:06 -0800 (PST) MIME-Version: 1.0 References: <20220216050320.3222-1-kerneljasonxing@gmail.com> In-Reply-To: From: Jason Xing Date: Wed, 16 Feb 2022 14:57:30 +0800 Message-ID: Subject: Re: [PATCH v2 net-next] net: introduce SO_RCVBUFAUTO to let the rcv_buf tune automatically To: Eric Dumazet Cc: David Miller , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Paolo Abeni , Wei Wang , Alexander Aring , Yangbo Lu , Florian Westphal , Tonghao Zhang , Thomas Gleixner , netdev , LKML , bpf , Jason Xing Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 On Wed, Feb 16, 2022 at 2:25 PM Eric Dumazet wrote: > > On Tue, Feb 15, 2022 at 9:03 PM wrote: > > > > From: Jason Xing > > > > Normally, user doesn't care the logic behind the kernel if they're > > trying to set receive buffer via setsockopt. However, once the new > > value of the receive buffer is set even though it's not smaller than > > the initial value which is sysctl_tcp_rmem[1] implemented in > > tcp_rcv_space_adjust(),, the server's wscale will shrink and then > > lead to the bad bandwidth as intended. > > Quite confusing changelog, honestly. > > Users of SO_RCVBUF specifically told the kernel : I want to use _this_ > buffer size, I do not want the kernel to decide for me. > > Also, I think your changelog does not really explain that _if_ you set > SO_RCVBUF to a small value before > connect() or in general the 3WHS, the chosen wscale will be small, and > this won't allow future 10x increase > of the effective RWIN. > Yes, you hit the point really. > > > > > For now, introducing a new socket option to let the receive buffer > > grow automatically no matter what the new value is can solve > > the bad bandwidth issue meanwhile it's not breaking the application > > with SO_RCVBUF option set. > > > > Here are some numbers: > > $ sysctl -a | grep rmem > > net.core.rmem_default = 212992 > > net.core.rmem_max = 40880000 > > net.ipv4.tcp_rmem = 4096 425984 40880000 > > > > Case 1 > > on the server side > > # iperf -s -p 5201 > > on the client side > > # iperf -c [client ip] -p 5201 > > It turns out that the bandwidth is 9.34 Gbits/sec while the wscale of > > server side is 10. It's good. > > > > Case 2 > > on the server side > > #iperf -s -p 5201 -w 425984 > > on the client side > > # iperf -c [client ip] -p 5201 > > It turns out that the bandwidth is reduced to 2.73 Gbits/sec while the > > wcale is 2, even though the receive buffer is not changed at all at the > > very beginning. > > > > After this patch is applied, the bandwidth of case 2 is recovered to > > 9.34 Gbits/sec as expected at the cost of consuming more memory per > > socket. > > How does your patch allow wscale to increase after flow is established ? > > I would remove from the changelog these experimental numbers that look > quite wrong, > maybe copy/pasted from your prior version. > My fault. I should have removed this part. > Instead I would describe why an application might want to clear the > 'receive buffer size is locked' socket attribute. > > > > > Signed-off-by: Jason Xing > > -- > > v2: suggested by Eric > > - introduce new socket option instead of breaking the logic in SO_RCVBUF > > - Adjust the title and description of this patch > > link: https://lore.kernel.org/lkml/CANn89iL8vOUOH9bZaiA-cKcms+PotuKCxv7LpVx3RF0dDDSnmg@mail.gmail.com/ > > --- > > > > I think adding another parallel SO_RCVBUF option is not good. It is > adding confusion (and net/core/filter.c has been unchanged) I'll change the filter.c altogether in the next submission. > > Also we want CRIU to work correctly. > > So if you have a SO_XXXX setsockopt() call, you also need to provide > getsockopt() implementation. > > I would suggest an option to clear or set SOCK_RCVBUF_LOCK, and > getsockopt() would return if the bit is currently set or not. > > Something clearly describing the intent, like SO_RCVBUF_LOCK maybe. Just now, I found out that the latest kernel has merged a similar patch (commit 04190bf89) about three months ago. Is it still necessary to add another separate option to clear the SOCK_RCVBUF_LOCK explicitly? Thanks, Jason