Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dma-buf: system_heap: account for system heap allocation in memcg

The system dma-buf heap lets userspace allocate buffers from the page
allocator. However, these allocations are not accounted for in memcg,
allowing processes to escape limits that may be configured.

Pass __GFP_ACCOUNT for system heap allocations, based on the
dma_heap.mem_accounting parameter, to use memcg and account for them.

Signed-off-by: Eric Chanudet <echanude@redhat.com>
Reviewed-by: T.J. Mercier <tjmercier@google.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-2-ecc6b62cc446@redhat.com

authored by

Eric Chanudet and committed by
Sumit Semwal
3c227be9 bb33013b

+5 -2
+5 -2
drivers/dma-buf/heaps/system_heap.c
··· 320 320 { 321 321 struct page *page; 322 322 int i; 323 + gfp_t flags; 323 324 324 325 for (i = 0; i < NUM_ORDERS; i++) { 325 326 if (size < (PAGE_SIZE << orders[i])) 326 327 continue; 327 328 if (max_order < orders[i]) 328 329 continue; 329 - 330 - page = alloc_pages(order_flags[i], orders[i]); 330 + flags = order_flags[i]; 331 + if (mem_accounting) 332 + flags |= __GFP_ACCOUNT; 333 + page = alloc_pages(flags, orders[i]); 331 334 if (!page) 332 335 continue; 333 336 return page;