From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/ttm: Hook up a cgroup-aware reclaim callback for the dmem controller
Date: Sat, 16 May 2026 14:48:43 +1000 [thread overview]
Message-ID: <review-patch3-20260511173008.36526-4-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20260511173008.36526-4-thomas.hellstrom@linux.intel.com>
Patch Review
**Verdict: Good with one concern worth discussing.**
The `ttm_bo_evict_cgroup()` function mirrors the multi-pass strategy of `ttm_bo_evict_alloc()`: trylock pass, low-watermark pass, then sleeping-lock passes. The structure is clean.
The new `sleeping_lock` field in `ttm_lru_walk_arg`:
```c
bool sleeping_lock;
```
The change in `__ttm_bo_lru_cursor_next()`:
```c
- else if (!arg->ticket || arg->ctx->no_wait_gpu || arg->trylock_only)
+ else if ((!arg->ticket && !arg->sleeping_lock) || arg->ctx->no_wait_gpu ||
+ arg->trylock_only)
```
When `sleeping_lock = true` and `ticket = NULL`, this falls through to `ttm_lru_walk_ticketlock()` which calls `dma_resv_lock(bo->base.resv, NULL)`. Without a WW ticket, there's no deadlock detection. As the commit message notes, this relies on the caller only holding one lock at a time. This is true here since the cgroup reclaim path has no pre-existing `dma_resv` locks. Using `interruptible = true` mitigates hard deadlocks since the process can be signalled, but a theoretical lock-order inversion could still cause a soft deadlock. Acceptable for this use case (admin writing to cgroup files), but should be flagged as a limitation.
The modification to `ttm_bo_evict_cb()` for cgroup drain mode:
```c
+ s64 bo_size = bo->base.size;
...
+ } else {
+ /* Cgroup drain: return bytes freed for byte-denominated progress. */
+ return bo_size;
+ }
```
This captures `bo->base.size` before eviction. `bo->base.size` is the GEM object size which doesn't change during eviction, so the early capture is defensive but harmless. Returning `bo_size` instead of `1` is correct since `ttm_lru_walk_for_evict()` accumulates these values and the caller (`ttm_bo_evict_cgroup`) compares against `target_bytes`.
The comment about `evict_walk->place` being NULL in cgroup drain mode is important:
```c
+ /*
+ * evict_walk->place is NULL in cgroup drain mode. Drivers'
+ * eviction_valuable() callbacks must handle a NULL place, treating it
+ * as "any placement": the TTM base implementation already does so via
+ * ttm_resource_intersects().
+ */
```
I verified that `ttm_resource_intersects()` returns `true` when `place == NULL` (at `ttm_resource.c:450`), so `ttm_bo_eviction_valuable()` correctly handles this. The xe driver's `xe_bo_eviction_valuable()` delegates to `ttm_bo_eviction_valuable()` as its first check and doesn't use `place` directly, so it's also safe without modification. Only amdgpu needs the explicit NULL guard (patch 5).
In `ttm_resource_manager_set_dmem_region()`:
```c
if (!IS_ERR_OR_NULL(region)) {
man->cg = region;
dmem_cgroup_region_set_reclaim(region, ...);
}
```
This correctly handles the error/NULL case (v3 fix from Sashiko-bot), leaving `man->cg` at its default (NULL/zero) if registration failed.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-16 4:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 17:30 [PATCH v3 0/5] Add reclaim to the dmem cgroup controller Thomas Hellström
2026-05-11 17:30 ` [PATCH v3 1/5] drm/amdgpu: Fix init ordering in amdgpu_vram_mgr_init() Thomas Hellström
2026-05-16 4:48 ` Claude review: " Claude Code Review Bot
2026-05-11 17:30 ` [PATCH v3 2/5] cgroup/dmem: Add reclaim callback for lowering max below current usage Thomas Hellström
2026-05-16 4:48 ` Claude review: " Claude Code Review Bot
2026-05-11 17:30 ` [PATCH v3 3/5] drm/ttm: Hook up a cgroup-aware reclaim callback for the dmem controller Thomas Hellström
2026-05-16 4:48 ` Claude Code Review Bot [this message]
2026-05-11 17:30 ` [PATCH v3 4/5] drm/xe: Wire up dmem cgroup reclaim for VRAM manager Thomas Hellström
2026-05-16 4:48 ` Claude review: " Claude Code Review Bot
2026-05-11 17:30 ` [PATCH v3 5/5] drm/amdgpu: " Thomas Hellström
2026-05-16 4:48 ` Claude review: " Claude Code Review Bot
2026-05-16 4:48 ` Claude review: Add reclaim to the dmem cgroup controller Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-05-12 8:24 [PATCH v4 0/5] " Thomas Hellström
2026-05-12 8:24 ` [PATCH v4 3/5] drm/ttm: Hook up a cgroup-aware reclaim callback for the dmem controller Thomas Hellström
2026-05-16 4:04 ` Claude review: " 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-patch3-20260511173008.36526-4-thomas.hellstrom@linux.intel.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