Skip to content

memcg: Backport some useful upstream patches

Waiman Long requested to merge llong1/centos-stream-9:bz2138950_memcg into main

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2138950
MR: !1557 (merged)
Omitted-fix: c59cd507fb64 ("RISC-V: nommu_virt: Drop unused SLAB_MERGE_DEFAULT")
Omitted-fix: b508128bb0d1 ("m68k: defconfig: Update defconfigs for v5.19-rc1")
Omitted-fix: 36e2da11254d ("ARM: shmobile: defconfig: Refresh for v5.19-rc1")

This MR contains 3 main set of patches plus some additional prerequisite patches to reduce merge conflicts.

The first set is commit 68aaee147e59 ("mm: memcontrol: fix potential oom_lock recursion deadlock") which help prevents a livelock situation when there is a memcg OOM and a global OOM.

The second set is the patch series "memcg: optimize charge codepath" which improves performance in the memcg charge codepath. It increases the size of the page_counter structure from 112 bytes to 192 bytes and hence the size of mem_cgroup structure.

The last set is the series "memcg: reduce memory overhead of memory cgroups". It is the last 3 patches of this series which reduce the size of memcg_vmstats_percpu and memcg_vmstats structures. Before the patches, the sizes of memcg_vmstats and memcg_vmstats_percpu are 2384 bytes and 2408 bytes respectively. After the patches, the new sizes are 1040 bytes and 1064 bytes. There is over 50% size reduction. Unfortunately, with a size slightly more than 1024, the memcg_vmstats structure will need to use a kmalloc-2k slab. The mem_cgroup structure is now 2240 bytes which can use kmalloc-4k slab instead of kmalloc-8k slab with an old size of 4224 bytes. So there is a saving of 2 kB per memory cgroup plus the saving in the percpu area.

Signed-off-by: Waiman Long longman@redhat.com

Edited by Waiman Long

Merge request reports