From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: mm/hmm: do the plumbing for HMM to participate in migration
Date: Tue, 26 May 2026 07:29:20 +1000 [thread overview]
Message-ID: <review-patch3-20260525084524.139868-4-mpenttil@redhat.com> (raw)
In-Reply-To: <20260525084524.139868-4-mpenttil@redhat.com>
Patch Review
This is the largest structural change — it reworks `hmm_vma_walk` to carry migration state, adds pmd/pte lock tracking, and introduces `hmm_vma_capture_migrate_range()` for capturing the VMA and MMU notifier range during the walk.
**Issue 1 — Potential duplicate definitions when CONFIG_DEVICE_MIGRATION is set:**
Patch adds a fallback `enum migrate_vma_info` and `hmm_select_migrate()` inside `#ifdef CONFIG_MIGRATION`:
```c
+enum migrate_vma_info {
+ MIGRATE_VMA_SELECT_NONE = 0,
+ MIGRATE_VMA_SELECT_COMPOUND = MIGRATE_VMA_SELECT_NONE,
+};
+
+static inline enum migrate_vma_info hmm_select_migrate(struct hmm_range *range)
+{
+ return MIGRATE_VMA_SELECT_NONE;
+}
+
#endif /* CONFIG_MIGRATION */
```
And then in the `#ifdef CONFIG_DEVICE_MIGRATION` block (which implies `CONFIG_MIGRATION`):
```c
-enum migrate_vma_direction {
+enum migrate_vma_info {
MIGRATE_VMA_SELECT_SYSTEM = 1 << 0,
...
+static inline enum migrate_vma_info hmm_select_migrate(struct hmm_range *range)
+{
+ return 0;
+}
```
When `CONFIG_DEVICE_MIGRATION=y` (which requires `CONFIG_MIGRATION=y`), both blocks are compiled, giving duplicate definitions of the enum and the inline function. This should be a compile error. The fallback definition needs a `#ifndef CONFIG_DEVICE_MIGRATION` guard. I may be misreading the base tree structure (the patches target drm-tip, not mainline), but if both blocks are unconditionally compiled, this won't build with `CONFIG_DEVICE_MIGRATION=y`.
**Issue 2 — `hmm_vma_walk` struct growth:**
```c
struct hmm_vma_walk {
- struct hmm_range *range;
- unsigned long last;
+ struct mmu_notifier_range mmu_range;
+ struct vm_area_struct *vma;
+ struct hmm_range *range;
+ unsigned long start;
+ unsigned long end;
+ unsigned long last;
+ bool ptelocked;
+ bool pmdlocked;
+ spinlock_t *ptl;
};
```
This struct is stack-allocated in `hmm_range_fault()`. The `mmu_notifier_range` alone is a significant addition. The overhead is always paid even when not migrating. This is fine functionally but worth noting for non-migration callers.
**Issue 3 — Lock state sharing via single `ptl` field:**
The `ptl` pointer is used for both PMD and PTE locks, which works because they're never held simultaneously. But it makes the code harder to reason about — a future change that accidentally holds both would corrupt state silently. The `HMM_ASSERT_*` macros help but only catch issues at runtime.
**Issue 4 — `hmm_vma_capture_migrate_range` MMU notifier range only covers the first callback:**
```c
+ if (!hmm_vma_walk->mmu_range.owner) {
+ mmu_notifier_range_init_owner(&hmm_vma_walk->mmu_range, MMU_NOTIFY_MIGRATE, 0,
+ walk->vma->vm_mm, start, end,
+ range->dev_private_owner);
+ mmu_notifier_invalidate_range_start(&hmm_vma_walk->mmu_range);
+ }
```
The MMU notifier range is initialized once with the first `start`/`end` from `hmm_vma_walk_test`. Subsequent calls update `hmm_vma_walk->end` but NOT the notifier range. Since the series enforces single-VMA via the `-ERANGE` check, this should be fine for the per-VMA test callback, but the `start`/`end` from `hmm_vma_walk_test` may be the per-VMA range which could differ from individual PMD-level sub-ranges.
**Issue 5 — `else` after `}` without braces (kernel style):**
Multiple instances of:
```c
+ } else
+ pte_unmap(ptep);
```
Kernel coding style requires braces on the `else` if the `if` block has braces.
**Issue 6 — C++ style comments for stubs:**
```c
+ // TODO: implement migration entry insertion
+ return 0;
```
These are removed in patch 4, so it's fine for bisect, but `/* */` is preferred in kernel code (though `//` is increasingly accepted).
---
Generated by Claude Code Patch Reviewer
next prev parent 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 Code Review Bot [this message]
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 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 3/5] mm/hmm: do the plumbing for HMM to participate in migration 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-patch3-20260525084524.139868-4-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