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/mmu_notifier: Allow two-pass struct mmu_interval_notifiers
Date: Wed, 04 Mar 2026 07:09:16 +1000	[thread overview]
Message-ID: <review-patch1-20260303133409.11609-2-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20260303133409.11609-2-thomas.hellstrom@linux.intel.com>

Patch Review

This is the core mm infrastructure change. The design uses `invalidate_start` + `invalidate_finish` callbacks in the ops struct, with a lockless list to collect finish entries during the interval tree walk.

**Positive aspects:**
- Clean separation: drivers that don't need two-pass are unaffected (the `invalidate` callback remains)
- Using a lockless list (`llist`) to avoid a second interval tree walk is a good optimization
- The `WARN_ON_ONCE` for `invalidate_start` without `invalidate_finish` is a useful safety check (added per Matt Brost's v3 review)
- Good documentation in the `struct mmu_interval_notifier_finish` kerneldoc about GFP_NOWAIT allocation considerations

**Concern — duplicated dispatching logic:**

The same if/else dispatching logic between `invalidate_start` and `invalidate` is duplicated in both `mn_itree_release` and `mn_itree_invalidate`:

```c
if (interval_sub->ops->invalidate_start) {
    struct mmu_interval_notifier_finish *finish = NULL;
    ret = interval_sub->ops->invalidate_start(..., &finish);
    if (ret && finish) {
        finish->notifier = interval_sub;
        __llist_add(&finish->link, &finish_passes);
    }
} else {
    ret = interval_sub->ops->invalidate(interval_sub, ...);
}
```

This is an exact copy-paste across both functions. Consider extracting a helper like `mn_itree_inv_call()` to reduce the duplication. This is a minor style nit, not a blocker.

**Concern — mn_itree_invalidate -EAGAIN path calls finish on partial set:**

In `mn_itree_invalidate`, when a non-blockable callback returns false, the code breaks out of the loop but still calls `mn_itree_finish_pass(&finish_passes)`. This means `invalidate_finish` callbacks will be invoked for notifiers that were already processed, while the iteration was aborted mid-way:

```c
if (!ret) {
    if (WARN_ON(mmu_notifier_range_blockable(range)))
        continue;
    err = -EAGAIN;
    break;
}
```
followed by:
```c
mn_itree_finish_pass(&finish_passes);
if (err)
    mn_itree_inv_end(subscriptions);
```

This is actually correct behavior — the finish pass must still run for all notifiers that *did* successfully start, to complete their work. The comment should perhaps clarify this is intentional.

**Minor:** The `llist_reverse_order()` call in `mn_itree_finish_pass` ensures FIFO ordering for the finish callbacks (matching the iteration order of the tree walk). This is a nice touch for deterministic behavior.

Overall: **Looks correct.** The WARN_ON_ONCE validation and the v2/v3 refinements are welcome.

---

---
Generated by Claude Code Patch Reviewer

  reply	other threads:[~2026-03-03 21:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 13:34 [PATCH v3 0/4] Two-pass MMU interval notifiers Thomas Hellström
2026-03-03 13:34 ` [PATCH v3 1/4] mm/mmu_notifier: Allow two-pass struct mmu_interval_notifiers Thomas Hellström
2026-03-03 21:09   ` Claude Code Review Bot [this message]
2026-03-03 13:34 ` [PATCH v3 2/4] drm/xe/userptr: Convert invalidation to two-pass MMU notifier Thomas Hellström
2026-03-03 18:10   ` Matthew Brost
2026-03-03 21:09   ` Claude review: " Claude Code Review Bot
2026-03-03 13:34 ` [PATCH v3 3/4] drm/xe: Split TLB invalidation into submit and wait steps Thomas Hellström
2026-03-03 18:13   ` Matthew Brost
2026-03-03 21:09   ` Claude review: " Claude Code Review Bot
2026-03-03 13:34 ` [PATCH v3 4/4] drm/xe/userptr: Defer Waiting for TLB invalidation to the second pass if possible Thomas Hellström
2026-03-03 21:09   ` Claude review: " Claude Code Review Bot
2026-03-03 21:09 ` Claude review: Two-pass MMU interval notifiers Claude Code Review Bot
  -- strict thread matches above, loose matches on Subject: below --
2026-03-02 16:32 [PATCH v2 0/4] " Thomas Hellström
2026-03-02 16:32 ` [PATCH v2 1/4] mm/mmu_notifier: Allow two-pass struct mmu_interval_notifiers Thomas Hellström
2026-03-03  3:05   ` 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-20260303133409.11609-2-thomas.hellstrom@linux.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