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: mm: setup device page migration in HMM pagewalk
Date: Tue, 26 May 2026 07:29:20 +1000	[thread overview]
Message-ID: <review-patch4-20260525084524.139868-5-mpenttil@redhat.com> (raw)
In-Reply-To: <20260525084524.139868-5-mpenttil@redhat.com>

Patch Review

The core implementation — fills in the stub functions from patch 3 with real migration entry installation, implements the split callback, and rewires `migrate_vma_setup()` to use `hmm_range_fault()` internally.

**Issue 1 — `migrate_vma_setup()` return value semantics changed:**

Old behavior:
```c
-	migrate_vma_collect(args);
-	if (args->cpages)
-		migrate_vma_unmap(args);
-	return 0;
```

New behavior:
```c
+	ret = hmm_range_fault(&range);
+	migrate_hmm_range_setup(&range);
+	if (ret) {
+		migrate_vma_pages(args);
+		migrate_vma_finalize(args);
+	}
+	return ret;
```

The old code always returned 0 after the collect/unmap phase. The new code can return errors from `hmm_range_fault()`. This changes the API contract for callers (test_hmm, nouveau, amdgpu, xe). While callers should already handle errors from `migrate_vma_setup()` (due to earlier validation failures), any caller that assumed the walk phase never fails will now see new error paths exercised. The cleanup path (calling `migrate_vma_pages` + `migrate_vma_finalize` to undo migration entries) seems correct but is a new error-handling pattern.

**Issue 2 — `migrate_hmm_range_setup` called unconditionally on error:**
```c
+	ret = hmm_range_fault(&range);
+	migrate_hmm_range_setup(&range);
```
If `hmm_range_fault` fails partway, some `hmm_pfns` entries may be in an inconsistent state. `migrate_hmm_range_setup` iterates all entries and only processes those with `HMM_PFN_MIGRATE` set, so unprocessed entries (value 0) are safely skipped. This should be correct.

**Issue 3 — `flush_cache_page` called for device private pages:**
```c
+		flush_cache_page(walk->vma, addr, pfn);
```
This is called in the common path after both the device-private and present-pte branches converge. For device private pages, the page isn't in CPU cache, making this unnecessary. The old code only called `flush_cache_page` for present PTEs. Not a correctness bug, but unnecessary work for device-private-to-device-private migrations.

**Issue 4 — `hmm_vma_handle_pmd` called with `start` instead of `addr`:**
```c
-			r = hmm_vma_handle_pmd(walk, addr, end, hmm_pfns, pmd);
+			r = hmm_vma_handle_pmd(walk, start, end, hmm_pfns, pmd);
```
Using `start` is correct for the PMD-level handler since the PMD covers `[start, end)`. But note that `hmm_pfns` is recalculated at `again:` based on `addr`, not `start`. If an `-EAGAIN` retry causes `addr != start` AND the PMD happens to be (re-)promoted to a huge page in between, `hmm_pfns` would point to the wrong offset. This is a pre-existing race condition (extremely unlikely in practice) that isn't introduced by this patch, but the `start` change makes the mismatch slightly more visible.

**Issue 5 — Style: `} else` without braces:**
```c
+	} else
+		folio_put(folio);
```
Same coding style issue as patch 3.

**Issue 6 — `hmm_vma_walk_split` folio handling for fault_folio:**
```c
+		if (folio != fault_folio) {
+			if (unlikely(!folio_trylock(folio))) {
+				folio_put(folio);
+				ret = -EBUSY;
+				goto out;
+			}
+		}  else
+			folio_put(folio);
```
When `folio == fault_folio`: `folio_get` is followed by `folio_put` (net zero), then `split_folio(folio)` is called. This relies on `fault_folio` already being locked by the caller with sufficient refcount. Correct but non-obvious — a comment would help here.

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-05-25 21:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-25  8:45 [PATCH v12 0/5] Migrate on fault for device pages mpenttil
2026-05-25  8:45 ` [PATCH v12 1/5] mm/Kconfig: changes for migrate " mpenttil
2026-05-25 21:29   ` Claude review: " Claude Code Review Bot
2026-05-25  8:45 ` [PATCH v12 2/5] mm: Add helper to convert HMM pfn to migrate pfn mpenttil
2026-05-25 21:29   ` Claude review: " Claude Code Review Bot
2026-05-25  8:45 ` [PATCH v12 3/5] mm/hmm: do the plumbing for HMM to participate in migration mpenttil
2026-05-25 21:29   ` Claude review: " Claude Code Review Bot
2026-05-25  8:45 ` [PATCH v12 4/5] mm: setup device page migration in HMM pagewalk mpenttil
2026-05-25 21:29   ` Claude Code Review Bot [this message]
2026-05-25  8:45 ` [PATCH v12 5/5] lib/test_hmm: add a new testcase for the migrate on fault mpenttil
2026-05-25 21:29   ` Claude review: " Claude Code Review Bot
2026-05-25 21:29 ` Claude review: Migrate on fault for device pages Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-05-25  5:08 [PATCH v11 0/5] " mpenttil
2026-05-25  5:08 ` [PATCH v11 4/5] mm: setup device page migration in HMM pagewalk mpenttil
2026-05-25  6:46   ` 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-patch4-20260525084524.139868-5-mpenttil@redhat.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