netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: Jason Xing <kerneljasonxing@gmail.com>
Cc: David Miller <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Wei Wang <weiwan@google.com>,
	Alexander Aring <aahringo@redhat.com>,
	Yangbo Lu <yangbo.lu@nxp.com>, Florian Westphal <fw@strlen.de>,
	Tonghao Zhang <xiangxia.m.yue@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	netdev <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Jason Xing <xingwanli@kuaishou.com>
Subject: Re: [PATCH v2 net-next] net: introduce SO_RCVBUFAUTO to let the rcv_buf tune automatically
Date: Tue, 15 Feb 2022 22:24:57 -0800	[thread overview]
Message-ID: <CANn89i+6Hc7q-a=zh_jcTn9_GM5xP6fzv2RcHY+tneqzE3UnHw@mail.gmail.com> (raw)
In-Reply-To: <20220216050320.3222-1-kerneljasonxing@gmail.com>

On Tue, Feb 15, 2022 at 9:03 PM <kerneljasonxing@gmail.com> wrote:
>
> From: Jason Xing <xingwanli@kuaishou.com>
>
> 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.


>
> 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.

Instead I would describe why an application might want to clear the
'receive buffer size is locked' socket attribute.

>
> Signed-off-by: Jason Xing <xingwanli@kuaishou.com>
> --
> 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)

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.

  reply	other threads:[~2022-02-16  6:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16  5:03 [PATCH v2 net-next] net: introduce SO_RCVBUFAUTO to let the rcv_buf tune automatically kerneljasonxing
2022-02-16  6:24 ` Eric Dumazet [this message]
2022-02-16  6:57   ` Jason Xing
2022-02-16 16:56     ` Eric Dumazet
2022-02-17  2:15       ` Jason Xing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANn89i+6Hc7q-a=zh_jcTn9_GM5xP6fzv2RcHY+tneqzE3UnHw@mail.gmail.com' \
    --to=edumazet@google.com \
    --cc=aahringo@redhat.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=fw@strlen.de \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kerneljasonxing@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=songliubraving@fb.com \
    --cc=tglx@linutronix.de \
    --cc=weiwan@google.com \
    --cc=xiangxia.m.yue@gmail.com \
    --cc=xingwanli@kuaishou.com \
    --cc=yangbo.lu@nxp.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).