[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <25xfv3p3nwr3isf46jcqhgawkgnbks7u4qofk3g43m6pctriss@35fwcsurb2i6>
Date: Thu, 9 Oct 2025 16:13:36 -0700
From: Shakeel Butt <shakeel.butt@...ux.dev>
To: Kuniyuki Iwashima <kuniyu@...gle.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <martin.lau@...ux.dev>, John Fastabend <john.fastabend@...il.com>,
Stanislav Fomichev <sdf@...ichev.me>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Neal Cardwell <ncardwell@...gle.com>,
Willem de Bruijn <willemb@...gle.com>, Mina Almasry <almasrymina@...gle.com>,
Roman Gushchin <roman.gushchin@...ux.dev>, Kuniyuki Iwashima <kuni1840@...il.com>, bpf@...r.kernel.org,
netdev@...r.kernel.org
Subject: Re: [PATCH bpf-next/net 3/6] net: Introduce net.core.bypass_prot_mem
sysctl.
On Tue, Oct 07, 2025 at 12:07:28AM +0000, Kuniyuki Iwashima wrote:
> If a socket has sk->sk_bypass_prot_mem flagged, the socket opts out
> of the global protocol memory accounting.
>
> Let's control the flag by a new sysctl knob.
>
> The flag is written once during socket(2) and is inherited to child
> sockets.
>
> Tested with a script that creates local socket pairs and send()s a
> bunch of data without recv()ing.
>
> Setup:
>
> # mkdir /sys/fs/cgroup/test
> # echo $$ >> /sys/fs/cgroup/test/cgroup.procs
> # sysctl -q net.ipv4.tcp_mem="1000 1000 1000"
> # ulimit -n 524288
>
> Without net.core.bypass_prot_mem, charged to tcp_mem & memcg
>
> # python3 pressure.py &
> # cat /sys/fs/cgroup/test/memory.stat | grep sock
> sock 22642688 <-------------------------------------- charged to memcg
> # cat /proc/net/sockstat| grep TCP
> TCP: inuse 2006 orphan 0 tw 0 alloc 2008 mem 5376 <-- charged to tcp_mem
> # ss -tn | head -n 5
> State Recv-Q Send-Q Local Address:Port Peer Address:Port
> ESTAB 2000 0 127.0.0.1:34479 127.0.0.1:53188
> ESTAB 2000 0 127.0.0.1:34479 127.0.0.1:49972
> ESTAB 2000 0 127.0.0.1:34479 127.0.0.1:53868
> ESTAB 2000 0 127.0.0.1:34479 127.0.0.1:53554
> # nstat | grep Pressure || echo no pressure
> TcpExtTCPMemoryPressures 1 0.0
>
> With net.core.bypass_prot_mem=1, charged to memcg only:
>
> # sysctl -q net.core.bypass_prot_mem=1
> # python3 pressure.py &
> # cat /sys/fs/cgroup/test/memory.stat | grep sock
> sock 2757468160 <------------------------------------ charged to memcg
> # cat /proc/net/sockstat | grep TCP
> TCP: inuse 2006 orphan 0 tw 0 alloc 2008 mem 0 <- NOT charged to tcp_mem
> # ss -tn | head -n 5
> State Recv-Q Send-Q Local Address:Port Peer Address:Port
> ESTAB 111000 0 127.0.0.1:36019 127.0.0.1:49026
> ESTAB 110000 0 127.0.0.1:36019 127.0.0.1:45630
> ESTAB 110000 0 127.0.0.1:36019 127.0.0.1:44870
> ESTAB 111000 0 127.0.0.1:36019 127.0.0.1:45274
> # nstat | grep Pressure || echo no pressure
> no pressure
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@...gle.com>
Reviewed-by: Shakeel Butt <shakeel.butt@...ux.dev>
Powered by blists - more mailing lists