From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: cgroup/dmem: Add reclaim callback for lowering max below current usage
Date: Sat, 16 May 2026 14:04:00 +1000 [thread overview]
Message-ID: <review-patch2-20260512082406.44470-3-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20260512082406.44470-3-thomas.hellstrom@linux.intel.com>
Patch Review
**Verdict: Good with minor observations.**
**Core design change — `xchg` replacing `page_counter_set_max`:**
```c
+ xchg(&pool->cnt.max, (unsigned long)val);
```
The original `page_counter_set_max()` refuses to set max below current usage (returns `-EBUSY`). The new code unconditionally sets max via `xchg`, which preserves the full memory barrier semantics while allowing max < usage. This is the right approach: it throttles concurrent allocations immediately while reclaim runs. Well motivated.
**Retry loop termination on partial progress:**
```c
+ for (int retries = 5; retries > 0; retries--) {
+ ...
+ ret = region->reclaim(pool, usage - val, region->reclaim_priv);
+ ...
+ if (ret)
+ break;
```
The reclaim callback (in patch 3) returns `-ENOSPC` when partial progress is made. This causes the retry loop to break even if some memory was freed. A more aggressive approach would be to retry on partial progress (similar to how the memory cgroup controller distinguishes `-EAGAIN` for "retry" from hard errors). However, since `page_counter_read()` reflects the actual usage and the max is already set to throttle new allocations, this best-effort approach is defensible and matches the stated design intent.
**rwsem protection looks correct:**
- `down_write` in `dmem_cgroup_unregister_region()` ensures all in-flight reclaim callbacks complete before clearing the callback pointer.
- `down_read_interruptible` in `set_resource_max()` allows concurrent reclaim and handles signals gracefully.
- `WRITE_ONCE`/`READ_ONCE` pairs on `region->reclaim` are properly placed.
**Unused `nonblock` parameter in `set_resource_min`/`set_resource_low`:**
```c
static void
-set_resource_min(struct dmem_cgroup_pool_state *pool, u64 val)
+set_resource_min(struct dmem_cgroup_pool_state *pool, u64 val, bool nonblock)
```
These functions accept `nonblock` but ignore it, keeping the function pointer signature uniform for `dmemcg_limit_write()`. This is clean.
---
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-05-16 4:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 8:24 [PATCH v4 0/5] Add reclaim to the dmem cgroup controller Thomas Hellström
2026-05-12 8:24 ` [PATCH v4 1/5] drm/amdgpu: Fix init ordering in amdgpu_vram_mgr_init() Thomas Hellström
2026-05-16 4:03 ` Claude review: " Claude Code Review Bot
2026-05-12 8:24 ` [PATCH v4 2/5] cgroup/dmem: Add reclaim callback for lowering max below current usage Thomas Hellström
2026-05-16 4:04 ` Claude Code Review Bot [this message]
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
2026-05-12 8:24 ` [PATCH v4 4/5] drm/xe: Wire up dmem cgroup reclaim for VRAM manager Thomas Hellström
2026-05-16 4:04 ` Claude review: " Claude Code Review Bot
2026-05-12 8:24 ` [PATCH v4 5/5] drm/amdgpu: " Thomas Hellström
2026-05-16 4:04 ` Claude review: " Claude Code Review Bot
2026-05-16 4:03 ` Claude review: Add reclaim to the dmem cgroup controller Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-05-11 17:30 [PATCH v3 0/5] " Thomas Hellström
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
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-patch2-20260512082406.44470-3-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