On Wed, Feb 18, 2026 at 9:15 AM Eric Chanudet echanude@redhat.com wrote:
Hi Eric,
An earlier series[1] from Maxime introduced dmem to the cma allocator in an attempt to use it generally for dma-buf. Restart from there and apply the charge in the narrower context of the CMA dma-buf heap instead.
In line with introducing cgroup to the system heap[2], this behavior is enabled based on dma_heap.mem_accounting, disabled by default.
dmem is chosen for CMA heaps as it allows limits to be set for each region backing each heap. The charge is only put in the dma-buf heap for now as it guaranties it can be accounted against a userspace process that requested the allocation.
But CMA memory is system memory, and regular (non-CMA) movable allocations can occur out of these CMA areas. So this splits system memory accounting between memcg (from [2]) and dmem. If I want to put a limit on system memory use I have to adjust multiple limits (memcg + dmems) and know how to divide the total between them all.
How do you envision using this combination of different controllers?
Thanks, T.J.
[1] https://lore.kernel.org/all/20250310-dmem-cgroups-v1-0-2984c1bc9312@kernel.o... [2] https://lore.kernel.org/all/20260116-dmabuf-heap-system-memcg-v3-0-ecc6b62cc...
Signed-off-by: Eric Chanudet echanude@redhat.com
Changes in v2:
- Rebase on Maxime's introduction of dmem to the cma allocator: https://lore.kernel.org/all/20250310-dmem-cgroups-v1-0-2984c1bc9312@kernel.o...
- Remove the dmem region registration from the cma dma-buf heap
- Remove the misplaced logic for the default region.
- Link to v1: https://lore.kernel.org/r/20260130-dmabuf-heap-cma-dmem-v1-1-3647ea993e99@re...
Eric Chanudet (1): dma-buf: heaps: cma: charge each cma heap's dmem
Maxime Ripard (2): cma: Register dmem region for each cma region cma: Provide accessor to cma dmem region
drivers/dma-buf/heaps/cma_heap.c | 15 ++++++++++++++- include/linux/cma.h | 9 +++++++++ mm/cma.c | 20 +++++++++++++++++++- mm/cma.h | 3 +++ 4 files changed, 45 insertions(+), 2 deletions(-)
base-commit: 948e195dfaa56e48eabda591f97630502ff7e27e change-id: 20260128-dmabuf-heap-cma-dmem-f4120a2df4a8
Best regards,
Eric Chanudet echanude@redhat.com
On 2/20/26 02:14, T.J. Mercier wrote:
On Wed, Feb 18, 2026 at 9:15 AM Eric Chanudet echanude@redhat.com wrote:
Hi Eric,
An earlier series[1] from Maxime introduced dmem to the cma allocator in an attempt to use it generally for dma-buf. Restart from there and apply the charge in the narrower context of the CMA dma-buf heap instead.
In line with introducing cgroup to the system heap[2], this behavior is enabled based on dma_heap.mem_accounting, disabled by default.
dmem is chosen for CMA heaps as it allows limits to be set for each region backing each heap. The charge is only put in the dma-buf heap for now as it guaranties it can be accounted against a userspace process that requested the allocation.
But CMA memory is system memory, and regular (non-CMA) movable allocations can occur out of these CMA areas. So this splits system memory accounting between memcg (from [2]) and dmem. If I want to put a limit on system memory use I have to adjust multiple limits (memcg + dmems) and know how to divide the total between them all.
How do you envision using this combination of different controllers?
Yeah we have this problem pretty much everywhere.
There are both use cases where you want to account device allocations to memcg and when you don't want that.
From what I know at the moment it would be best if the administrator could say for each dmem if it should account additionally to memcg or not.
Using module parameters to enable/disable it globally is just a workaround as far as I can see.
Regards, Christian.
Thanks, T.J.
[1] https://lore.kernel.org/all/20250310-dmem-cgroups-v1-0-2984c1bc9312@kernel.o... [2] https://lore.kernel.org/all/20260116-dmabuf-heap-system-memcg-v3-0-ecc6b62cc...
Signed-off-by: Eric Chanudet echanude@redhat.com
Changes in v2:
- Rebase on Maxime's introduction of dmem to the cma allocator: https://lore.kernel.org/all/20250310-dmem-cgroups-v1-0-2984c1bc9312@kernel.o...
- Remove the dmem region registration from the cma dma-buf heap
- Remove the misplaced logic for the default region.
- Link to v1: https://lore.kernel.org/r/20260130-dmabuf-heap-cma-dmem-v1-1-3647ea993e99@re...
Eric Chanudet (1): dma-buf: heaps: cma: charge each cma heap's dmem
Maxime Ripard (2): cma: Register dmem region for each cma region cma: Provide accessor to cma dmem region
drivers/dma-buf/heaps/cma_heap.c | 15 ++++++++++++++- include/linux/cma.h | 9 +++++++++ mm/cma.c | 20 +++++++++++++++++++- mm/cma.h | 3 +++ 4 files changed, 45 insertions(+), 2 deletions(-)
base-commit: 948e195dfaa56e48eabda591f97630502ff7e27e change-id: 20260128-dmabuf-heap-cma-dmem-f4120a2df4a8
Best regards,
Eric Chanudet echanude@redhat.com
linaro-mm-sig@lists.linaro.org