Linux Documentation
 help / color / mirror / Atom feed
* [PATCH 00/11] mm/cma: charge cma allocation to memcg using per area counters
@ 2026-08-21 18:56 Eric Chanudet
  2026-08-21 18:56 ` [PATCH 01/11] mm/cma: drop const for struct page on release API Eric Chanudet
                   ` (13 more replies)
  0 siblings, 14 replies; 24+ messages in thread
From: Eric Chanudet @ 2026-08-21 18:56 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Tejun Heo, Johannes Weiner,
	Michal Koutný, Jonathan Corbet, Shuah Khan, Michal Hocko,
	Roman Gushchin, Shakeel Butt, Muchun Song, Shuah Khan
  Cc: linux-mm, linux-kernel, cgroups, linux-doc, linux-kselftest,
	Maxime Ripard, Albert Esteve, Eric Chanudet

CMA allocations are currently unaccounted for by cgroup memory
controllers. As system resources, they should fall under memcg, but CMA
areas partition the available space for different purposes and memcg
doesn't have a good representation for that.

Add a memory_cma_accounting cgroupfs option in preparation for the
following new behavior. Make it disabled by default since it will
account for CMA allocations in memcg which may affect existing systems.

Provide CMA charge/uncharge functions to memcg that introduce a CMA area
specific counter per CMA area. Charges are issued to memcg and to a page
counter for the CMA area used. The allocation's folios are marked with
the cgroup via commit_charge() (once for large folios, per-page for
0-order ones) so they can be later uncharged correctly.

Add the new memcg calls into the cma allocator under __cma_alloc_frozen,
for both cma and hugetlb_cma allocations accounting.

Finally register the per-area usage counters in the cgroupfs. Each CMA
area creates a memory.cma.<area>.{current,max} pair for reporting and
limitation for each area.

Selftests and a vmtest script are added to this series for convenience.
The tests are simple accounting and limit enforcement verification using
the default reserved CMA area (cma=) and hugetlb_cma.

Signed-off-by: Eric Chanudet <echanude@redhat.com>
---
Eric Chanudet (11):
      mm/cma: drop const for struct page on release API
      mm/cma: include linux/cma.h in cma.h
      cgroup: add memory_cma_accounting mount option
      memcg: add cma charge/uncharge functions for area counters
      mm/cma: charge cma allocation to memcg per area counters
      memcg: register per-area usage counters in cgroupfs
      selftests: cgroup: add cma configs for cgroup selftest suite
      selftests: cgroup: add memcg cma tests
      selftests: cgroup: add a vmtest script for memcg
      selftests: cgroup: add memcg hugetlb_cma tests
      selftests: cgroup: amend vmtest-memcg to run the hugetlb cma tests

 Documentation/admin-guide/cgroup-v2.rst         |  35 +++
 include/linux/cgroup-defs.h                     |   5 +
 include/linux/cma.h                             |   4 +-
 include/linux/memcontrol.h                      |  19 ++
 kernel/cgroup/cgroup.c                          |  15 +-
 mm/cma.c                                        |  14 +-
 mm/cma.h                                        |   6 +
 mm/cma_debug.c                                  |   1 -
 mm/cma_sysfs.c                                  |   1 -
 mm/memcontrol.c                                 | 205 ++++++++++++
 tools/testing/selftests/cgroup/.gitignore       |   1 +
 tools/testing/selftests/cgroup/Makefile         |   2 +
 tools/testing/selftests/cgroup/config           |   5 +
 tools/testing/selftests/cgroup/test_cma_memcg.c | 402 ++++++++++++++++++++++++
 tools/testing/selftests/cgroup/vmtest-memcg.sh  | 197 ++++++++++++
 15 files changed, 903 insertions(+), 9 deletions(-)
---
base-commit: 98f21c54f99519329c18e2625b0ea6db14524d09
change-id: 20260706-cma-memcg-regions-696cb5ef7998

Best regards,
-- 
Eric Chanudet <echanude@redhat.com>


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2026-08-25 16:26 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21 18:56 [PATCH 00/11] mm/cma: charge cma allocation to memcg using per area counters Eric Chanudet
2026-08-21 18:56 ` [PATCH 01/11] mm/cma: drop const for struct page on release API Eric Chanudet
2026-08-21 18:56 ` [PATCH 02/11] mm/cma: include linux/cma.h in cma.h Eric Chanudet
2026-08-21 18:56 ` [PATCH 03/11] cgroup: add memory_cma_accounting mount option Eric Chanudet
2026-08-24  7:02   ` Maxime Ripard
2026-08-24 22:03     ` Eric Chanudet
2026-08-21 18:56 ` [PATCH 04/11] memcg: add cma charge/uncharge functions for area counters Eric Chanudet
2026-08-21 18:56 ` [PATCH 05/11] mm/cma: charge cma allocation to memcg per " Eric Chanudet
2026-08-21 18:56 ` [PATCH 06/11] memcg: register per-area usage counters in cgroupfs Eric Chanudet
2026-08-21 18:56 ` [PATCH 07/11] selftests: cgroup: add cma configs for cgroup selftest suite Eric Chanudet
2026-08-21 18:57 ` [PATCH 08/11] selftests: cgroup: add memcg cma tests Eric Chanudet
2026-08-21 18:57 ` [PATCH 09/11] selftests: cgroup: add a vmtest script for memcg Eric Chanudet
2026-08-21 18:57 ` [PATCH 10/11] selftests: cgroup: add memcg hugetlb_cma tests Eric Chanudet
2026-08-21 18:57 ` [PATCH 11/11] selftests: cgroup: amend vmtest-memcg to run the hugetlb cma tests Eric Chanudet
2026-08-23  7:02 ` [PATCH 00/11] mm/cma: charge cma allocation to memcg using per area counters Mike Rapoport
2026-08-24 21:58   ` Eric Chanudet
2026-08-25  7:40     ` Michal Hocko
2026-08-24  8:58 ` Michal Hocko
2026-08-25 14:47   ` Eric Chanudet
2026-08-25 14:59     ` Michal Hocko
2026-08-25 15:45     ` David Hildenbrand (Arm)
2026-08-25 16:26       ` Michal Hocko
2026-08-24 13:18 ` Michal Koutný
2026-08-25 14:54   ` Eric Chanudet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox