[PATCH v3 1/8] memcg: Add MEMCG_DMABUF accounting infrastructure
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Oct 28 15:04:31 UTC 2026
> From: "T.J. Mercier" <tjmercier at google.com>
>
> Introduce a MEMCG_DMABUF stat counter and helpers for
> reserve/commit/cancel and uncharging dma-buf memory against a
> memory cgroup:
>
> The charge is tracked on struct dma_buf via a new memcg pointer. The
> page count is derived internally from PAGE_ALIGN(dmabuf->size), and
> the memcg reference is stored into (or cleared from) dmabuf->memcg by
> the helpers themselves, removing the need for callers to manage those
> details. The release path in dma_buf_release() is reduced to a single
> mem_cgroup_uncharge_dmabuf() call.
>
> This decouples accounting from the backing page allocator, avoiding the
> need for every exporter to pass __GFP_ACCOUNT and enabling cross-cgroup
> charge transfer, which is impractical with page-level accounting.
>
> The next patch wires up the charging policy in the dma-heap ioctl.
>
> Signed-off-by: T.J. Mercier <tjmercier at google.com>
> Signed-off-by: Albert Esteve <aesteve at redhat.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261027-v2_20230123_tjmercier_google_com-v3-0-78d2c4cb8647@redhat.com?part=1
More information about the Linux-security-module-archive
mailing list