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/ttm: Fix GPU MM stats during pool shrinking
Date: Tue, 05 May 2026 08:58:24 +1000	[thread overview]
Message-ID: <review-patch1-20260502065338.2720646-1-matthew.brost@intel.com> (raw)
In-Reply-To: <20260502065338.2720646-1-matthew.brost@intel.com>

Patch Review

**The helper function (lines +105..+111):**

```c
static void __free_pages_gpu_account(struct page *p, unsigned int order,
				     bool reclaim)
{
	mod_lruvec_page_state(p, reclaim ? NR_GPU_RECLAIM : NR_GPU_ACTIVE,
			      -(1 << order));
	__free_pages(p, order);
}
```

This correctly mirrors the pattern already used in `ttm_pool_free_page()`. The ordering (stat update before `__free_pages`) matches the existing code and is safe since `mod_lruvec_page_state` only needs the page struct to look up the lruvec, not the page contents.

**Refactor in `ttm_pool_free_page()` (lines -120..+123):**

Clean replacement of the inline `mod_lruvec_page_state` + `__free_pages` with the new helper. No functional change. Good.

**Fix in `ttm_pool_restore_commit()` (line +132):**

```c
__free_pages_gpu_account(p, 0, false);
```

Correct. This is the restore path where old retained pages from `tt->pages[]` are copied and freed. These pages were allocated via `ttm_pool_alloc_page()` which marks them `NR_GPU_ACTIVE` (line 175 of current tree). They were never moved to the reclaim pool, so `reclaim=false` is right. The order is 0 because `ttm_pool_split_for_swap()` was called just above.

**Fix in `ttm_pool_backup()` purge path (line +141):**

```c
__free_pages_gpu_account(page, order, false);
```

Correct. In the purge path, pages from `tt->pages[]` are freed directly at their original order (no split). These are `NR_GPU_ACTIVE` pages. `reclaim=false` is correct. The `page->private = 0` reset on the line above clears the order stored in private, and the helper reads the order from the parameter rather than from `page->private`, so ordering is fine.

**Fix in `ttm_pool_backup()` swap path (line +150):**

```c
__free_pages_gpu_account(page, 0, false);
```

Replacing `put_page(page)` — this is the v2 change per Kenneth's feedback. After `ttm_pool_split_for_swap()`, these are individual order-0 non-compound pages, so `__free_pages(p, 0)` is functionally equivalent to `put_page(page)` here (both do `put_page_testzero` + free). `reclaim=false` is correct; these pages are `NR_GPU_ACTIVE`.

**Minor observation:** The `reclaim` parameter is always `false` at all three new call sites. The only caller that passes `true` is the existing `ttm_pool_free_page()` code path. This is expected — `ttm_pool_backup()` returns `-EBUSY` for DMA alloc pools, and pages in `tt->pages[]` are never in the reclaim pool (they'd need to go through `ttm_pool_type_add()` for that). So the `reclaim` parameter is justified by the `ttm_pool_free_page()` usage, but worth noting that the *new* sites are all `NR_GPU_ACTIVE` decrements.

**No issues found.** The patch is a correct and minimal fix for a real accounting bug. The Fixes tag correctly references the commit that introduced the GPU MM stats.

Reviewed-by: Dave Airlie <airlied@gmail.com>

---
Generated by Claude Code Patch Reviewer

  parent reply	other threads:[~2026-05-04 22:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-02  6:53 [PATCH v2] drm/ttm: Fix GPU MM stats during pool shrinking Matthew Brost
     [not found] ` <7f927ef8-2d3d-4609-926d-b18535794f72@panix.com>
2026-05-04  3:56   ` Dave Airlie
2026-05-04  4:09     ` Matthew Brost
2026-05-04 22:58 ` Claude Code Review Bot [this message]
2026-05-04 22:58 ` Claude review: " Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-05-01 22:30 [PATCH] " Matthew Brost
2026-05-04 23:02 ` Claude review: " Claude Code Review Bot
2026-05-04 23:02 ` 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-20260502065338.2720646-1-matthew.brost@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