public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
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:48:42 +1000	[thread overview]
Message-ID: <review-patch2-20260511173008.36526-3-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20260511173008.36526-3-thomas.hellstrom@linux.intel.com>

Patch Review

**Verdict: Good with minor comments.**

The core reclaim infrastructure is well designed. The key change in `set_resource_max()`:

```c
xchg(&pool->cnt.max, (unsigned long)val);
```

replaces:

```c
page_counter_set_max(&pool->cnt, val);
```

This is a significant semantic change. `page_counter_set_max()` returns `-EBUSY` when usage exceeds the new limit (and never actually sets the limit in that case). The raw `xchg()` unconditionally sets the limit. The original code was silently ignoring the `-EBUSY` return, meaning `dmem.max` writes below current usage were no-ops. The new code intentionally sets the limit regardless, then attempts reclaim. This is correct behavior, but the commit message could mention this semantic difference more explicitly.

The reclaim loop is bounded (5 retries) and interruptible:

```c
for (int retries = 5; retries > 0; retries--) {
    ...
    if (signal_pending(current))
        break;
    if (down_read_interruptible(&region->unregister_sem))
        break;
    ...
}
```

The use of `down_read_interruptible()` is good — it prevents an admin `kill` from being stuck waiting for a long eviction.

The `nonblock` parameter is threaded through `set_resource_min` and `set_resource_low` even though only `set_resource_max` uses it. This is for function pointer signature consistency since they're passed as callbacks via the `apply` parameter in `dmemcg_limit_write()`. That's fine.

Minor: The series doesn't return an error to userspace if reclaim fails to bring usage below the limit (the loop just exits). The commit message says this "matches the behavior of memory.max in the memory cgroup controller." This is acceptable but worth noting that if an admin sets `dmem.max = 0` and reclaim can't evict everything (pinned BOs), the write succeeds silently while the limit is technically set but violated.

The `unregister_sem` synchronization:
- `dmem_cgroup_region_set_reclaim()`: write-locks, sets `reclaim_priv` then `reclaim` (WRITE_ONCE), unlocks.
- `set_resource_max()`: READ_ONCE on `reclaim`, then read-locks, re-checks reclaim, calls it, unlocks.
- `dmem_cgroup_unregister_region()`: write-locks, WRITE_ONCE nulls `reclaim`, unlocks.

This correctly ensures: (1) `reclaim_priv` is visible when `reclaim` is non-NULL, (2) in-progress reclaim completes before the region is unregistered. Solid.

---
Generated by Claude Code Patch Reviewer

  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 Code Review Bot [this message]
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 review: " Claude Code Review Bot
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 2/5] cgroup/dmem: Add reclaim callback for lowering max below current usage 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-patch2-20260511173008.36526-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