Skip to content

net: fix memcg overhead caused by sk->sk_forward_alloc size

Cathy Zhang cgroups linux-mm netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 63 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2net: Keep sk->sk_forward_alloc as a proper sizeinclude/net/sock.h+22 -160 replies
2/2net: Add sysctl_reclaim_thresholdDocumentation/admin-guide/sysctl/net.rst include/net/sock.h net/core/sysctl_net_core.c+37 -23 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchLong TaoJesse BrandeburgTim ChenSuresh Srinivas
1/2T-b R-b R-b R-b
2/2R-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH net-next 0/2] net: fix memcg overhead caused by sk->sk_forward_alloc size

Dear Reviewers,

memcg charge overhead is observed while we benchmark memcached with memtier by running containers. It's caused by commit 4890b686f408 ("net:
Keep sk->sk_forward_alloc as small as possible"), which aims to reduce system memory pressure, but makes the per-socket forward allocated memory too small. The impact of this change is to trigger more frequently memory allocation during TCP connection lifecycle and leads to memcg charge overhead finally.

To avoid memcg charge overhead mentioned above, this series defines 64KB as reclaim threshold when uncharging per-socket memory. It reduces the frequency of memory allocation and charging during TCP connection, and it's much less than the original 2MB per-socket reserved memory before commit 4890b686f408 ("net: keep sk->sk_forward_alloc as small as possibile"). Run memcached/memtier test with the 64KB reclaim threshold, RPS gains around 2.07x.

This series also provides a new ABI /proc/sys/net/core/reclaim_threshold with flexibility to tune the reclaim threshold according to system running status.

This series is based on the latest net-next/main tree.

Thanks for your time to help review and your feedback will be greatly!

Cathy Zhang (2):
net: Keep sk->sk_forward_alloc as a proper size
net: Add sysctl_reclaim_threshold

 Documentation/admin-guide/sysctl/net.rst | 12 +++++++++
 include/net/sock.h                       | 32 +++++++++++++++++++++++-
 net/core/sysctl_net_core.c               | 14 +++++++++++
 3 files changed, 57 insertions(+), 1 deletion(-)

base-commit: ed23734c23d2fc1e6a1ff80f8c2b82faeed0ed0c 2.34.1