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: lib/test_hmm: add a new testcase for the migrate on fault
Date: Tue, 26 May 2026 07:29:20 +1000	[thread overview]
Message-ID: <review-patch5-20260525084524.139868-6-mpenttil@redhat.com> (raw)
In-Reply-To: <20260525084524.139868-6-mpenttil@redhat.com>

Patch Review

Adds the `HMM_DMIRROR_MIGRATE_ON_FAULT_TO_DEV` ioctl and a selftest exercising it.

**Issue 1 — IOCTL number insertion breaks existing numbering:**
```c
-#define HMM_DMIRROR_MIGRATE_TO_SYS	_IOWR('H', 0x03, struct hmm_dmirror_cmd)
+#define HMM_DMIRROR_MIGRATE_ON_FAULT_TO_DEV	_IOWR('H', 0x03, struct hmm_dmirror_cmd)
+#define HMM_DMIRROR_MIGRATE_TO_SYS		_IOWR('H', 0x04, struct hmm_dmirror_cmd)
```
Inserting the new ioctl at 0x03 shifts all subsequent numbers. While this is a test-only driver (not a stable ABI), it breaks any existing out-of-tree userspace using these ioctls. Appending as 0x09 would be cleaner and avoids renumbering.

**Issue 2 — Test doesn't exercise the "fault + migrate" path:**
```c
+	/* Initialize buffer in system memory. */
+	for (i = 0, ptr = buffer->ptr; i < size / sizeof(*ptr); ++i)
+		ptr[i] = i;
+
+	/* Fault and migrate memory to device. */
+	ret = hmm_migrate_on_fault_sys_to_dev(self->fd, buffer, npages);
```
The write loop faults in all pages before the migrate-on-fault call. This means the test exercises "migrate already-present pages via the new path" but NOT "fault-in absent pages and migrate them in one walk" — which is the primary optimization this series enables. Consider adding a test that calls `hmm_migrate_on_fault_sys_to_dev` WITHOUT the initialization loop (or after an `madvise(MADV_DONTNEED)`) to exercise the true fault+migrate path.

**Issue 3 — `do_fault_and_migrate` proceeds with migration even on fault error:**
```c
+	ret = dmirror_range_fault(dmirror, range);
+
+	pr_debug("Migrating from sys mem to device mem\n");
+	migrate_hmm_range_setup(range);
+
+	dmirror_migrate_alloc_and_copy(migrate, dmirror);
+	migrate_vma_pages(migrate);
```
If `dmirror_range_fault` fails, the code still proceeds with migration setup and processing. The subsequent functions handle partial state gracefully (skipping entries without `MIGRATE_PFN_MIGRATE`), but it's still doing unnecessary work. An early-return on error with cleanup would be cleaner.

**Issue 4 — Extra blank line:**
```c
+	dmirror_bounce_fini(&bounce);
+
+
+out_mmput:
```
Double blank line.

---
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 review: " Claude Code Review Bot
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 Code Review Bot [this message]
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 5/5] lib/test_hmm: add a new testcase for the migrate on fault 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-patch5-20260525084524.139868-6-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