net: account socket and multicast allocations to memcg
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | net: multicast: keep source filter state when a source update failsnet/ net/ net/ +1 more | +92 | 0 replies | |
| 2/3 | net: account IPV6_2292PKTOPTIONS and multicast socket state to memcgnet/ net/ net/ | +9 | 0 replies | |
| 3/3 | net: multicast: account group and source allocations to memcgnet/ net/ | +19 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH net 0/3] net: account socket and multicast allocations to memcg
Several allocations retained by sockets or multicast device state are not charged to memory cgroups. A task can retain substantially more kernel memory than its memory.max limit permits.
With the default optmem_max, an unprivileged user retaining 2,000 IPV6_2292PKTOPTIONS buffers consumed about 254 MiB of slab while a cgroup limited to 64 MiB reported about 5.5 MiB in memory.current. In a user and network namespace with raised multicast limits, 1,200 IPv4 memberships with 1,024 sources each retained about 85 MiB of slab while the cgroup reported less than 1 MiB. Both were measured on the base of this series.
Patch 1 fixes source-filter error handling before making more allocations failable at a memcg limit. Removing a never-added source from an any-source membership returns EADDRNOTAVAIL but changes the empty filter to INCLUDE, so the socket stops receiving the group. The patch restores the old mode on failure, checks device-side source allocation errors before publishing the socket filter, and removes a membership created by a failed source join.
Patch 2 accounts IPV6_2292PKTOPTIONS buffers and IPv4/IPv6 socket membership and source-list allocations. It leaves sock_kmalloc() unchanged because its other callers have different execution contexts and charge attribution. Patch 3 accounts device source and tomb entries, deleted IPv6 group records, and live IPv6 device groups created by socket joins. Live groups created by automatic address configuration keep their existing allocation policy. IPv4 keeps GFP_ATOMIC, so its charges are forced and can temporarily exceed memory.max. IPv6 uses GFP_KERNEL_ACCOUNT.
IPv4 device group records remain unaccounted: their allocation helper cannot report failure and has callers with different GFP constraints. Accounting socket memberships limits the membership-only case, but each socket record can still pin a larger unaccounted device group when every membership uses a different group. This series does not close that case.
The pending patch "igmp: use copy-on-write RCU updates in ip_mc_source()"
(https://lore.kernel.org/r/[email protected])
also changes the IPv4 function. It is not in this base; this series leaves the existing in-place RCU update races to that work.
Validation on this base and the corresponding patched tree:
- full x86_64 W=1 bzImage builds;
- affected-object W=1 builds at each intermediate commit, plus final allmodconfig, i386 and CONFIG_IP_MULTICAST=n builds;
- IPv4/IPv6 group reception changed from 4/4 to 0/4 after an invalid source leave on the base, and stayed 4/4 with the series;
- valid source join/leave sequences passed, and FAILSLAB tests confirmed ENOBUFS with preserved filter/membership state on the patched kernel;
- large option, membership and source-filter cases were constrained by a 64 MiB cgroup limit; small operations succeeded;
- with delayed MLD reports and a 16 MiB cgroup limit on both kernels, the base completed 200,000 IPv6 join/leave operations without a memory.max event; the memcg OOM killer stopped the patched run after at least 60,000 operations;
- no unexpected BUG, WARNING, Oops or panic in the guest consoles.
Kernel selftests were not run, and the large membership case was run only on the patched kernel.
Patch 1 is an independent correctness fix suitable for stable. Patches 2 and 3 change charging behaviour and are marked noautosel. If you would rather take patches 2 and 3 through net-next, I can resend them there once patch 1 has been merged.
Yingjie Wang (3):
net: multicast: keep source filter state when a source update fails
net: account IPV6_2292PKTOPTIONS and multicast socket state to memcg
net: multicast: account group and source allocations to memcg
net/ipv4/igmp.c | 88 ++++++++++++++++++++++++++-------------- net/ipv4/ip_sockglue.c | 33 ++++++++------- net/ipv6/ipv6_sockglue.c | 13 +++++- net/ipv6/mcast.c | 50 +++++++++++++++-------- 4 files changed, 120 insertions(+), 64 deletions(-)
base-commit: e203d8a4751d48aa00eda31e3b320ba8e0d47dbf
Signature · 1 line
2.43.0