[PATCH 0/2] hugetlb memcg accounting

From: Nhat Pham
Date: Tue Sep 26 2023 - 15:49:56 EST


Currently, hugetlb memory usage is not acounted for in the memory
controller, which could lead to memory overprotection for cgroups with
hugetlb-backed memory. This has been observed in our production system.

This patch series rectifies this issue by charging the memcg when the
hugetlb folio is allocated, and uncharging when the folio is freed. In
addition, a new selftest is added to demonstrate and verify this new
behavior.

Nhat Pham (2):
hugetlb: memcg: account hugetlb-backed memory in memory controller
selftests: add a selftest to verify hugetlb usage in memcg

MAINTAINERS | 2 +
fs/hugetlbfs/inode.c | 2 +-
include/linux/hugetlb.h | 6 +-
include/linux/memcontrol.h | 8 +
mm/hugetlb.c | 23 +-
mm/memcontrol.c | 40 ++++
tools/testing/selftests/cgroup/.gitignore | 1 +
tools/testing/selftests/cgroup/Makefile | 2 +
.../selftests/cgroup/test_hugetlb_memcg.c | 222 ++++++++++++++++++
9 files changed, 297 insertions(+), 9 deletions(-)
create mode 100644 tools/testing/selftests/cgroup/test_hugetlb_memcg.c

--
2.34.1