[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251007001120.2661442-1-kuniyu@google.com>
Date: Tue, 7 Oct 2025 00:07:25 +0000
From: Kuniyuki Iwashima <kuniyu@...gle.com>
To: Alexei Starovoitov <ast@...nel.org>, Andrii Nakryiko <andrii@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Martin KaFai Lau <martin.lau@...ux.dev>
Cc: 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 <kuniyu@...gle.com>, Kuniyuki Iwashima <kuni1840@...il.com>, bpf@...r.kernel.org,
netdev@...r.kernel.org
Subject: [PATCH bpf-next/net 0/6] bpf: Allow opt-out from sk->sk_prot->memory_allocated.
This series allows opting out of the global per-protocol memory
accounting if socket is configured as such by sysctl or BPF prog.
This series is v11 of the series below [0], but I start as a new series
because the changes now fall in net and bpf subsystems only.
I discussed with Roman Gushchin offlist, and he suggested not mixing
two independent subsystems and it would be cleaner not to depend on
memcg.
So, sk->sk_memcg and memcg code are no longer touched, and instead we
use another hole near sk->sk_prot to store a flag for the net feature.
Overview of the series:
patch 1 is misc cleanup
patch 2 allows opt-out from sk->sk_prot->memory_allocated
patch 3 introduces net.core.bypass_prot_mem
patch 4 & 5 supports flagging sk->sk_bypass_prot_mem via bpf_setsockopt()
patch 6 is selftest
[0]: https://lore.kernel.org/bpf/20250920000751.2091731-1-kuniyu@google.com/
Note: de7342228b73 is needed to build selftest on bpf-next/net.
Kuniyuki Iwashima (6):
tcp: Save lock_sock() for memcg in inet_csk_accept().
net: Allow opt-out from global protocol memory accounting.
net: Introduce net.core.bypass_prot_mem sysctl.
bpf: Support bpf_setsockopt() for BPF_CGROUP_INET_SOCK_CREATE.
bpf: Introduce SK_BPF_BYPASS_PROT_MEM.
selftest: bpf: Add test for sk->sk_bypass_prot_mem.
Documentation/admin-guide/sysctl/net.rst | 8 +
include/net/netns/core.h | 1 +
include/net/proto_memory.h | 3 +
include/net/sock.h | 3 +
include/net/tcp.h | 3 +
include/uapi/linux/bpf.h | 2 +
net/core/filter.c | 79 +++++
net/core/sock.c | 37 ++-
net/core/sysctl_net_core.c | 9 +
net/ipv4/af_inet.c | 22 ++
net/ipv4/inet_connection_sock.c | 25 --
net/ipv4/tcp.c | 3 +-
net/ipv4/tcp_output.c | 7 +-
net/mptcp/protocol.c | 7 +-
net/tls/tls_device.c | 3 +-
tools/include/uapi/linux/bpf.h | 1 +
.../bpf/prog_tests/sk_bypass_prot_mem.c | 282 ++++++++++++++++++
.../selftests/bpf/progs/sk_bypass_prot_mem.c | 104 +++++++
18 files changed, 561 insertions(+), 38 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/sk_bypass_prot_mem.c
create mode 100644 tools/testing/selftests/bpf/progs/sk_bypass_prot_mem.c
--
2.51.0.710.ga91ca5db03-goog
Powered by blists - more mailing lists