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/fdinfo: Add "evicted" memory accounting
Date: Thu, 23 Apr 2026 09:29:11 +1000	[thread overview]
Message-ID: <review-patch1-20260420-panthor-bo-reclaim-observability-v1-1-a4d1a36ee84f@collabora.com> (raw)
In-Reply-To: <20260420-panthor-bo-reclaim-observability-v1-1-a4d1a36ee84f@collabora.com>

Patch Review

**Summary:** Adds `DRM_GEM_OBJECT_EVICTED` (BIT(3)) to `enum drm_gem_object_status`, adds `u64 evicted` to `struct drm_memory_stats`, and wires both into the fdinfo printing and accumulation paths.

**Review:**

The changes correctly follow the established pattern used by `RESIDENT`, `PURGEABLE`, and `ACTIVE`. The new enum value is properly documented with a kdoc comment.

**Issue 1 (minor): The "evicted" accumulation in `drm_show_memory_stats` uses `add_size` unconditionally.**

```c
		if (s & DRM_GEM_OBJECT_EVICTED)
			status.evicted += add_size;
```

This uses `add_size`, which is the RSS size (from `obj->funcs->rss()` if available, otherwise `obj->size`). For an evicted object, `rss()` would typically return 0 since the pages are gone. In the panthor driver (patch 2), evicted objects won't have `DRM_GEM_OBJECT_RESIDENT` set, so they won't have backing pages — meaning `rss()` would return 0 (or not be meaningful).

For evicted objects, the interesting number is the *total* size of the object (how much was evicted to swap), not the RSS. Consider using `obj->size` instead of `add_size`, or document why `add_size` is correct here.

**Issue 2 (minor/doc): The `@DRM_GEM_OBJECT_EVICTED` doc says "object is evicted to swap".**

```c
 * @DRM_GEM_OBJECT_EVICTED: object is evicted to swap
```

The commit message mentions this is about pages being swapped out, but "evicted" in the GPU driver world often means "evicted from VRAM to system memory" (e.g., in TTM-based drivers). The doc comment and the enum value name could potentially be confused with VRAM eviction. Consider whether the description should be more specific, e.g. "object's backing pages have been reclaimed by the shrinker." This is a naming/documentation concern rather than a correctness issue.

**Issue 3 (question): Interaction with existing `RESIDENT`/`PURGEABLE` filtering logic.**

In `drm_show_memory_stats`, when an object is not `RESIDENT`, the code clears `PURGEABLE`:
```c
		if (s & DRM_GEM_OBJECT_RESIDENT) {
			status.resident += add_size;
		} else {
			s &= ~DRM_GEM_OBJECT_PURGEABLE;
		}
```

The new `EVICTED` status is accumulated *after* this block (based on the patch context), which is correct since evicted objects should be non-resident by definition. But there's no explicit mutual exclusivity check — a driver could theoretically return both `RESIDENT` and `EVICTED`, which would be nonsensical. This is not a bug (drivers shouldn't do this), but a comment noting that `EVICTED` is expected to be mutually exclusive with `RESIDENT` would be helpful in the enum documentation.

**Issue 4 (nit): Missing documentation update.**

The `drm_gem_object_status` enum doc block has a long comment about the interaction between `PURGEABLE`, `RESIDENT`, and `ACTIVE`. It would be good to add a similar note about `EVICTED` — specifically that it should only be set for non-resident objects whose pages were previously allocated and then reclaimed, and that it is mutually exclusive with `RESIDENT`.

**Positive:** The `drm_memory_stats_is_zero` check is correctly updated, and the printing order (after purgeable) is reasonable.

---

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-04-22 23:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 15:46 [PATCH 0/2] Let userspace know about swapped out panthor GEM objects Nicolas Frattaroli
2026-04-20 15:46 ` [PATCH 1/2] drm/fdinfo: Add "evicted" memory accounting Nicolas Frattaroli
2026-04-22 23:29   ` Claude Code Review Bot [this message]
2026-04-20 15:47 ` [PATCH 2/2] drm/panthor: Implement evicted status for GEM objects Nicolas Frattaroli
2026-04-20 16:17   ` Boris Brezillon
2026-04-20 17:46     ` Nicolas Frattaroli
2026-04-21  7:22       ` Boris Brezillon
2026-04-22 23:29   ` Claude review: " Claude Code Review Bot
2026-04-22 23:29 ` Claude review: Let userspace know about swapped out panthor " Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-04-21 10:45 [PATCH v2 0/3] " Nicolas Frattaroli
2026-04-21 10:45 ` [PATCH v2 1/3] drm/fdinfo: Add "evicted" memory accounting Nicolas Frattaroli
2026-04-22 22:36   ` 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-patch1-20260420-panthor-bo-reclaim-observability-v1-1-a4d1a36ee84f@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