From: Arvind Yadav <arvind.yadav@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: matthew.brost@intel.com, himal.prasad.ghimiray@intel.com,
thomas.hellstrom@linux.intel.com
Subject: [RFC v2 0/7] drm/xe/svm: Add MMU notifier-based madvise autoreset on munmap
Date: Mon, 6 Apr 2026 14:28:23 +0530 [thread overview]
Message-ID: <20260406085830.1118431-1-arvind.yadav@intel.com> (raw)
This series implements automatic reset of GPU memory attributes when
userspace unmaps memory, ensuring non-default attributes set via the
MADVISE ioctl do not persist after CPU mappings are freed.
MMU interval notifiers detect munmap on CPU-only VMAs (not yet
GPU-faulted) and queue a worker to reset attributes. GPU-touched
VMAs continue using existing SVM notifiers.
Key aspects:
- cpu_autoreset_active (xe_vma) tracks CPU-only vs GPU-touched state.
XE_VMA_CPU_AUTORESET_ACTIVE is pipeline-only and not stored in gpuva.flags.
- MMU notifier callback does not allocate. work_struct is embedded in
xe_madvise_notifier and initialised at ioctl time. Overlapping munmap
events are coalesced via min/max.
- teardown_rwsem serialises VM teardown against callbacks.
- struct maple_tree tracks notifiers: O(log N) dedup + insert.
- Notifiers registered outside vm->lock; vm->lock taken only for dedup.
Callback only queues work.
Patch organisation:
1. Track cpu_autoreset_active in xe_vma and add pipeline-only flag.
2. Preserve state across GPUVA operations.
3. Clear state on first GPU fault.
4. Add MMU notifier and worker infrastructure.
5. Deactivate notifier on GPU touch.
6. Wire notifiers into VM lifecycle.
7. Fix partial unmap attribute reset.
Changes in v2:
- Move runtime state to xe_vma bool cpu_autoreset_active. (Matt)
- Embed work_struct in xe_madvise_notifier; no allocation in callback. (Thomas)
- Coalesce overlapping munmap events via min/max.
- Replace closing state with teardown_rwsem. (Matt)
- Use maple_tree for notifier tracking. (Matt)
- Register notifiers outside vm->lock; take it only for the maple-tree dedup check.
- Add xe_vma_effective_create_flags() and fix REMAP split handling.
- Move xe_vma_gpu_touch() to success path in pagefault handler. (Matt)
- Use plain bool active in notifier. (Matt)
- Add lockdep assertions for vm->lock.
Arvind Yadav (6):
drm/xe/vm: Track CPU_AUTORESET state in xe_vma
drm/xe/vm: Preserve cpu_autoreset_active across GPUVA operations
drm/xe/svm: Clear CPU_AUTORESET_ACTIVE on first GPU fault
drm/xe/vm: Add madvise autoreset interval notifier worker
infrastructure
drm/xe/vm: Deactivate madvise notifier on GPU touch
drm/xe/vm: Wire MADVISE_AUTORESET notifiers into VM lifecycle
Himal Prasad Ghimiray (1):
drm/xe/svm: Correct memory attribute reset for partial unmap
drivers/gpu/drm/xe/xe_svm.c | 80 ++++-
drivers/gpu/drm/xe/xe_svm.h | 10 +
drivers/gpu/drm/xe/xe_vm.c | 82 ++++-
drivers/gpu/drm/xe/xe_vm.h | 18 ++
drivers/gpu/drm/xe/xe_vm_madvise.c | 498 ++++++++++++++++++++++++++++-
drivers/gpu/drm/xe/xe_vm_madvise.h | 9 +
drivers/gpu/drm/xe/xe_vm_types.h | 87 +++++
7 files changed, 761 insertions(+), 23 deletions(-)
--
2.43.0
next reply other threads:[~2026-04-06 8:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-06 8:58 Arvind Yadav [this message]
2026-04-06 8:58 ` [RFC v2 1/7] drm/xe/vm: Track CPU_AUTORESET state in xe_vma Arvind Yadav
2026-04-30 4:07 ` Matthew Brost
2026-06-04 5:31 ` Yadav, Arvind
2026-04-06 8:58 ` [RFC v2 2/7] drm/xe/vm: Preserve cpu_autoreset_active across GPUVA operations Arvind Yadav
2026-04-30 4:29 ` Matthew Brost
2026-06-04 5:40 ` Yadav, Arvind
2026-04-06 8:58 ` [RFC v2 3/7] drm/xe/svm: Clear CPU_AUTORESET_ACTIVE on first GPU fault Arvind Yadav
2026-04-30 4:26 ` Matthew Brost
2026-06-04 5:38 ` Yadav, Arvind
2026-04-06 8:58 ` [RFC v2 4/7] drm/xe/vm: Add madvise autoreset interval notifier worker infrastructure Arvind Yadav
2026-04-06 8:58 ` [RFC v2 5/7] drm/xe/vm: Deactivate madvise notifier on GPU touch Arvind Yadav
2026-04-06 8:58 ` [RFC v2 6/7] drm/xe/vm: Wire MADVISE_AUTORESET notifiers into VM lifecycle Arvind Yadav
2026-04-06 8:58 ` [RFC v2 7/7] drm/xe/svm: Correct memory attribute reset for partial unmap Arvind Yadav
2026-04-30 5:02 ` Matthew Brost
2026-04-30 5:08 ` Matthew Brost
2026-06-04 6:05 ` Yadav, Arvind
2026-04-06 9:04 ` ✗ CI.checkpatch: warning for drm/xe/svm: Add MMU notifier-based madvise autoreset on munmap (rev2) Patchwork
2026-04-06 9:06 ` ✓ CI.KUnit: success " Patchwork
2026-04-06 9:54 ` ✓ Xe.CI.BAT: " Patchwork
2026-04-06 12:36 ` ✓ Xe.CI.FULL: " Patchwork
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=20260406085830.1118431-1-arvind.yadav@intel.com \
--to=arvind.yadav@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=thomas.hellstrom@linux.intel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).