From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: drm/xe/userptr: Convert invalidation to two-pass MMU notifier
Date: Tue, 03 Mar 2026 13:05:44 +1000 [thread overview]
Message-ID: <review-patch2-20260302163248.105454-3-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20260302163248.105454-3-thomas.hellstrom@linux.intel.com>
Patch Review
This patch converts the xe userptr invalidation to use the two-pass model from patch 1. The split into `xe_vma_userptr_invalidate_pass1` (enable SW signaling, check if fences are already signaled) and `xe_vma_userptr_do_inval` (wait for fences, invalidate TLB, unmap pages) is clean.
**Bug: `static` local variable in `xe_vma_userptr_force_invalidate`:**
```c
void xe_vma_userptr_force_invalidate(struct xe_userptr_vma *uvma)
{
static struct mmu_interval_notifier_finish *finish;
```
This `static` is almost certainly a bug. A local pointer to the finish struct should not be `static` - this serves no purpose and would be shared across all calls. If two threads call `xe_vma_userptr_force_invalidate` concurrently, the `static` variable creates a data race. This should be a plain local variable. (It appears this may have been introduced by the AI assistant.)
**`finish_inuse` flag race consideration:**
The `finish_inuse` flag is documented as protected by `vm::svm.gpusvm.notifier_lock`. In `xe_vma_userptr_invalidate_pass1`, it's checked and set under this lock. In `xe_vma_userptr_do_inval`, it's cleared under the lock in `xe_vma_userptr_invalidate_finish`. In the `xe_vma_userptr_invalidate_start` callback, the lock is held for the duration of the pass1 call. This looks correct.
**Locking in `xe_vma_userptr_invalidate_finish`:**
```c
down_write(&vm->svm.gpusvm.notifier_lock);
xe_vma_userptr_do_inval(vm, uvma, true);
up_write(&vm->svm.gpusvm.notifier_lock);
```
The finish callback takes the notifier_lock to protect the shared state. This is called from `mn_itree_finish_pass` which runs after the interval tree walk but before `mn_itree_inv_end`. The `mn_itree_inv_end` call releases the write side of `subscriptions->invalidate_seq`. So this should be safe - the finish pass runs in the same context as the original invalidation.
**Question: What happens when `invalidate_start` returns `true` but `*p_finish` is NULL?**
Looking at the `mn_itree_invalidate` code, when `ret` is true but `finish` is NULL, the notifier simply isn't added to the finish list. This is the correct "completed synchronously" path.
---
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-03-03 3:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 16:32 [PATCH v2 0/4] Two-pass MMU interval notifiers 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-02 19:48 ` Matthew Brost
2026-03-02 21:12 ` Thomas Hellström
2026-03-03 3:05 ` Claude review: " Claude Code Review Bot
2026-03-02 16:32 ` [PATCH v2 2/4] drm/xe/userptr: Convert invalidation to two-pass MMU notifier Thomas Hellström
2026-03-02 18:57 ` Matthew Brost
2026-03-02 21:22 ` Thomas Hellström
2026-03-02 21:30 ` Matthew Brost
2026-03-03 3:05 ` Claude Code Review Bot [this message]
2026-03-02 16:32 ` [PATCH v2 3/4] drm/xe: Split TLB invalidation into submit and wait steps Thomas Hellström
2026-03-02 19:06 ` Matthew Brost
2026-03-02 21:29 ` Thomas Hellström
2026-03-02 21:31 ` Matthew Brost
2026-03-03 3:05 ` Claude review: " Claude Code Review Bot
2026-03-02 16:32 ` [PATCH v2 4/4] drm/xe/userptr: Defer Waiting for TLB invalidation to the second pass if possible Thomas Hellström
2026-03-02 19:14 ` Matthew Brost
2026-03-02 21:33 ` Thomas Hellström
2026-03-03 3:05 ` Claude review: " Claude Code Review Bot
2026-03-03 3:05 ` Claude review: Two-pass MMU interval notifiers Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-03-03 13:34 [PATCH v3 0/4] " Thomas Hellström
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 21:09 ` 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-patch2-20260302163248.105454-3-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