diff options
| author | Eric Chanudet <echanude@redhat.com> | 2026-01-16 15:05:38 -0500 |
|---|---|---|
| committer | Sumit Semwal <sumit.semwal@linaro.org> | 2026-01-19 19:08:47 +0530 |
| commit | bb33013bdd238129c8f8f29ed2e9bbdfa8caa643 (patch) | |
| tree | bd539c6cf968236d485d8dfed123190170fa4045 | |
| parent | 1c21f240fbc1e47b94e68abfa2da2c01ed29a74d (diff) | |
dma-buf: heaps: add parameter to account allocations using cgroup
Add a parameter to enable dma-buf heaps allocation accounting using
cgroup for heaps that implement it. It is disabled by default as doing
so incurs caveats based on how memcg currently accounts for shared
buffers.
Signed-off-by: Eric Chanudet <echanude@redhat.com>
Reviewed-by: T.J. Mercier <tjmercier@google.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patch.msgid.link/20260116-dmabuf-heap-system-memcg-v3-1-ecc6b62cc446@redhat.com
| -rw-r--r-- | drivers/dma-buf/dma-heap.c | 5 | ||||
| -rw-r--r-- | include/linux/dma-heap.h | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c index 8ab49924f8b7..d230ddeb24e0 100644 --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -49,6 +49,11 @@ static dev_t dma_heap_devt; static struct class *dma_heap_class; static DEFINE_XARRAY_ALLOC(dma_heap_minors); +bool __read_mostly mem_accounting; +module_param(mem_accounting, bool, 0444); +MODULE_PARM_DESC(mem_accounting, + "Enable cgroup-based memory accounting for dma-buf heap allocations (default=false)."); + static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, u32 fd_flags, u64 heap_flags) diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h index 27d15f60950a..648328a64b27 100644 --- a/include/linux/dma-heap.h +++ b/include/linux/dma-heap.h @@ -46,4 +46,6 @@ const char *dma_heap_get_name(struct dma_heap *heap); struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info); +extern bool mem_accounting; + #endif /* _DMA_HEAPS_H */ |
