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: drm/panthor: Implement evicted status for GEM objects
Date: Mon, 25 May 2026 21:52:46 +1000	[thread overview]
Message-ID: <review-patch2-20260520-panthor-bo-reclaim-observability-v4-2-a47ab61cb80d@collabora.com> (raw)
In-Reply-To: <20260520-panthor-bo-reclaim-observability-v4-2-a47ab61cb80d@collabora.com>

Patch Review

**Overall:** Well-designed implementation using `atomic_t` for the reclaimed counter with INT_MAX saturation.

**`atomic_add_unless` for saturation:** Correct approach.

```c
atomic_add_unless(&bo->reclaimed_count, 1, INT_MAX);
```

This atomically increments unless the value is already INT_MAX, providing clean saturation semantics. Placed correctly before the actual eviction cleanup.

**Status callback logic:**

```c
if (drm_gem_is_imported(&bo->base) || bo->backing.pages)
    res |= DRM_GEM_OBJECT_RESIDENT;
else if (atomic_read(&bo->reclaimed_count))
    res |= DRM_GEM_OBJECT_EVICTED;
```

The `else if` correctly makes RESIDENT and EVICTED mutually exclusive. An object that is swapped back in (`backing.pages` non-NULL again) will show as RESIDENT, not EVICTED — which is the correct current-state semantics. The `reclaimed_count` provides the historical record. The distinction between "never had pages" (reclaimed_count == 0, neither RESIDENT nor EVICTED) and "had pages but were evicted" (reclaimed_count > 0, EVICTED) is exactly the gap this series fills.

**Race between `backing.pages` and `reclaimed_count`:** These are read without holding locks in the status callback (called under `file->table_lock` spinlock, not dma_resv). A concurrent shrinker could evict the object between reading `backing.pages` and `reclaimed_count`. This is acceptable — fdinfo is inherently racy and will be correct on the next poll.

**Zero-initialization:** `reclaimed_count` is implicitly zero-initialized via `kzalloc_obj(*bo)` in `panthor_gem_alloc_object()`, so newly allocated objects correctly start with count 0.

**debugfs state flag:**

```c
if (drm_gem_is_imported(&bo->base))
    gem_state_flags |= PANTHOR_DEBUGFS_GEM_STATE_FLAG_IMPORTED;
else if (!resident_size && reclaimed_count)
    gem_state_flags |= PANTHOR_DEBUGFS_GEM_STATE_FLAG_EVICTED;
```

The `else if` is correct — imported BOs are always considered resident by panthor and are not managed by the shrinker, so they can never be in the evicted state.

**Format string update:** The new `%-11d` for `reclaimed_count` is correct (INT_MAX = 2147483647, 10 digits + 1 space = 11 chars). The column header "evictions" (9 chars) fits within the 11-char field.

**No issues with:** enum definitions, kerneldoc for `reclaimed_count`, debugfs flag name table update.

---

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-05-25 11:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 13:04 [PATCH v4 0/3] Let userspace know about swapped out panthor GEM objects Nicolas Frattaroli
2026-05-20 13:04 ` [PATCH v4 1/3] drm/fdinfo: Add "evicted" memory accounting Nicolas Frattaroli
2026-05-20 14:19   ` Tvrtko Ursulin
2026-05-20 19:38     ` Nicolas Frattaroli
2026-05-25 11:52   ` Claude review: " Claude Code Review Bot
2026-05-20 13:04 ` [PATCH v4 2/3] drm/panthor: Implement evicted status for GEM objects Nicolas Frattaroli
2026-05-20 13:24   ` Boris Brezillon
2026-05-20 14:33   ` Boris Brezillon
2026-05-25 11:52   ` Claude Code Review Bot [this message]
2026-05-20 13:04 ` [PATCH v4 3/3] drm/panthor: Reduce padding in gems debugfs for refcount Nicolas Frattaroli
2026-05-25 11:52   ` Claude review: " Claude Code Review Bot
2026-05-25 11:52 ` Claude review: Let userspace know about swapped out panthor GEM objects Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-05-21 13:51 [PATCH v5 0/2] " Nicolas Frattaroli
2026-05-21 13:51 ` [PATCH v5 1/2] drm/panthor: Implement evicted status for " Nicolas Frattaroli
2026-05-25 10:03   ` Claude review: " Claude Code Review Bot
2026-04-21 10:45 [PATCH v2 0/3] Let userspace know about swapped out panthor " Nicolas Frattaroli
2026-04-21 10:45 ` [PATCH v2 2/3] drm/panthor: Implement evicted status for " Nicolas Frattaroli
2026-04-22 22:36   ` Claude review: " Claude Code Review Bot
2026-04-20 15:46 [PATCH 0/2] Let userspace know about swapped out panthor " Nicolas Frattaroli
2026-04-20 15:47 ` [PATCH 2/2] drm/panthor: Implement evicted status for " Nicolas Frattaroli
2026-04-22 23:29   ` 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-20260520-panthor-bo-reclaim-observability-v4-2-a47ab61cb80d@collabora.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