From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: memcg: Track exported dma-buffers
Date: Sat, 16 May 2026 13:56:21 +1000 [thread overview]
Message-ID: <review-patch1-20260512-v2_20230123_tjmercier_google_com-v1-1-6326701c3691@redhat.com> (raw)
In-Reply-To: <20260512-v2_20230123_tjmercier_google_com-v1-1-6326701c3691@redhat.com>
Patch Review
This patch (from T.J. Mercier's earlier series) adds `MEMCG_DMABUF` as a memcg stat counter, charges at `dma_buf_export()` time, and uncharges at `dma_buf_release()` time.
**Issue 1 - Bisectability:** This patch charges in `dma_buf_export()` for ALL dma-buf exports, but patch 2 immediately removes that code and moves charging to `dma_heap_buffer_alloc()` only. Between patches 1 and 2, every DRM driver, V4L2 exporter, etc. that calls `dma_buf_export()` incurs a memcg charge. This creates a window where behavior differs from both the pre-series state and the final intended state. The infrastructure (stat counter, charge/uncharge functions) should be added in patch 1 without hooking into `dma_buf_export()`, and patch 2 should add the charging at the heap level.
```c
+ dmabuf->memcg = get_mem_cgroup_from_mm(current->mm);
+ if (!mem_cgroup_charge_dmabuf(dmabuf->memcg, PAGE_ALIGN(dmabuf->size) / PAGE_SIZE,
+ GFP_KERNEL)) {
```
This charges unconditionally in `dma_buf_export()`, then patch 2 removes it entirely.
**Issue 2 - Uncharge before ops->release():** The uncharge is placed before `dmabuf->ops->release()`:
```c
+ mem_cgroup_uncharge_dmabuf(dmabuf->memcg, PAGE_ALIGN(dmabuf->size) / PAGE_SIZE);
+ mem_cgroup_put(dmabuf->memcg);
+
dmabuf->ops->release(dmabuf);
```
This means the memcg charge is removed before the backing pages are actually freed. If `ops->release()` takes significant time or blocks, there's a window where the pages are still allocated but not charged. This is a minor accuracy concern but worth noting.
**Issue 3 - doc tag:** The documentation adds `dmabuf (npn)` — it would be helpful to confirm that `(npn)` is the correct format tag. Looking at the existing doc entries, most stats don't use this tag pattern, so this might be incorrect formatting or an undefined abbreviation.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-16 3:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 9:10 [PATCH RFC 0/5] memcg: dma-buf per-cgroup accounting via pid_fd Albert Esteve
2026-05-12 9:10 ` [PATCH RFC 1/5] memcg: Track exported dma-buffers Albert Esteve
2026-05-16 3:56 ` Claude Code Review Bot [this message]
2026-05-12 9:10 ` [PATCH RFC 2/5] dma-heap: charge dma-buf memory via explicit memcg Albert Esteve
2026-05-12 10:14 ` Christian König
2026-05-12 18:53 ` T.J. Mercier
2026-05-13 11:39 ` Albert Esteve
2026-05-13 16:35 ` T.J. Mercier
2026-05-13 12:41 ` Albert Esteve
2026-05-13 16:39 ` T.J. Mercier
2026-05-13 18:39 ` Albert Esteve
2026-05-15 13:53 ` Christian Brauner
2026-05-15 17:06 ` T.J. Mercier
2026-05-16 3:56 ` Claude review: " Claude Code Review Bot
2026-05-12 9:10 ` [PATCH RFC 3/5] security: dma-heap: Add dma_heap_alloc LSM hook Albert Esteve
2026-05-16 3:56 ` Claude review: " Claude Code Review Bot
2026-05-12 9:10 ` [PATCH RFC 4/5] selinux: Restrict cross-cgroup dma-heap charging Albert Esteve
2026-05-14 20:44 ` Paul Moore
2026-05-16 3:56 ` Claude review: " Claude Code Review Bot
2026-05-12 9:10 ` [PATCH RFC 5/5] selftests/dmabuf-heaps: Add dma-buf memcg accounting tests Albert Esteve
2026-05-16 3:56 ` Claude review: " Claude Code Review Bot
2026-05-16 3:56 ` Claude review: memcg: dma-buf per-cgroup accounting via pid_fd Claude Code Review Bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=review-patch1-20260512-v2_20230123_tjmercier_google_com-v1-1-6326701c3691@redhat.com \
--to=claude-review@example.com \
--cc=dri-devel-reviews@example.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox