From: sashiko-bot@kernel.org
To: "Arvind Yadav" <arvind.yadav@intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [RFC v3 5/7] drm/xe/vm: Disable madvise notifier on GPU touch
Date: Thu, 04 Jun 2026 10:03:40 +0000 [thread overview]
Message-ID: <20260604100340.96C581F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604095012.367231-6-arvind.yadav@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Unbounded accumulation of `xe_madvise_notifier` structs leading to memory leak and Denial of Service (OOM).
--
commit 01cdfed4cb38d71774f4ae69b625419325962b05
Author: Arvind Yadav <arvind.yadav@intel.com>
drm/xe/vm: Disable madvise notifier on GPU touch
This commit adds an active flag to xe_madvise_notifier to stop queueing
autoreset work once a CPU-only VMA has been GPU-faulted. It modifies the
pagefault handler to touch the VMA and deactivate exact-match notifiers
in the maple tree.
> diff --git a/drivers/gpu/drm/xe/xe_vm_madvise.c b/drivers/gpu/drm/xe/xe_vm_madvise.c
> index c2abe712598a1..6c42ce8e3f525 100644
> --- a/drivers/gpu/drm/xe/xe_vm_madvise.c
> +++ b/drivers/gpu/drm/xe/xe_vm_madvise.c
[ ... ]
> @@ -1236,3 +1238,46 @@ int xe_vm_madvise_register_notifier_range(struct xe_vm *vm, u64 start, u64 end)
>
> return err;
> }
> +
> +/**
> + * xe_vm_deactivate_madvise_notifier_for_range - Disable callbacks for a VMA
> + * @vm: VM
> + * @start: VMA start
> + * @end: VMA end
> + */
> +static void xe_vm_deactivate_madvise_notifier_for_range(struct xe_vm *vm, u64 start, u64 end)
> +{
> + struct xe_madvise_notifier *notifier;
> + unsigned long index = start;
> +
> + lockdep_assert_held_write(&vm->lock);
> +
> + if (!vm->svm.madvise_work.wq)
> + return;
> +
> + /*
> + * Only exact-match notifiers are disabled. Broader notifiers may still
> + * cover CPU-only split siblings.
> + */
> + mt_for_each(&vm->svm.madvise_notifiers, notifier, index, end - 1)
> + if (notifier->vma_start == start && notifier->vma_end == end)
> + WRITE_ONCE(notifier->active, false);
[Severity: High]
This is a pre-existing issue, but does leaving these deactivated notifiers in
memory without freeing them contribute to an unbounded accumulation?
Looking at xe_vm_madvise_register_notifier_range(), notifiers are allocated
and linked to the VM indefinitely:
xe_vm_madvise_register_notifier_range() {
notifier = xe_madvise_notifier_alloc(vm, start, end);
if (!notifier)
return -ENOMEM;
...
list_add_tail(¬ifier->link, &vm->svm.madvise_notifier_list);
}
Since older notifiers are only freed if they are fully covered by a new range
or during VM teardown, could userspace intentionally map, bind with AUTORESET,
madvise, and unbind at different addresses across the virtual address space?
This sequence seems like it would bypass the displacement logic and permanently
leak the notifier objects, potentially consuming kernel memory and causing a
denial of service.
Should xe_vm_deactivate_madvise_notifier_for_range() or the unbind path
actively clean up these deactivated objects?
> +}
> +
> +/**
> + * xe_vm_madvise_gpu_touch - Disable madvise notifier after GPU touch
> + * @vm: VM
> + * @vma: GPU-touched VMA
> + */
> +void xe_vm_madvise_gpu_touch(struct xe_vm *vm, struct xe_vma *vma)
> +{
> + lockdep_assert_held_write(&vm->lock);
> +
> + /* Only AUTORESET VMAs have madvise notifiers. */
> + if (!(vma->gpuva.flags & XE_VMA_MADV_AUTORESET))
> + return;
> +
> + xe_vm_deactivate_madvise_notifier_for_range(vm,
> + xe_vma_start(vma),
> + xe_vma_end(vma));
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260604095012.367231-1-arvind.yadav@intel.com?part=5
next prev parent reply other threads:[~2026-06-04 10:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 9:50 [RFC v3 0/7] drm/xe/svm: Add MMU notifier-based madvise autoreset on munmap Arvind Yadav
2026-06-04 9:50 ` [RFC v3 1/7] drm/xe/vm: Track CPU_AUTORESET state in xe_vma Arvind Yadav
2026-06-04 9:50 ` [RFC v3 2/7] drm/xe/vm: Preserve cpu_autoreset_active across GPUVA operations Arvind Yadav
2026-06-04 10:07 ` sashiko-bot
2026-06-04 9:50 ` [RFC v3 3/7] drm/xe/svm: Clear CPU_AUTORESET_ACTIVE on first GPU fault Arvind Yadav
2026-06-04 9:50 ` [RFC v3 4/7] drm/xe/vm: Add madvise autoreset notifier worker Arvind Yadav
2026-06-04 10:14 ` sashiko-bot
2026-06-04 9:50 ` [RFC v3 5/7] drm/xe/vm: Disable madvise notifier on GPU touch Arvind Yadav
2026-06-04 10:03 ` sashiko-bot [this message]
2026-06-04 9:50 ` [RFC v3 6/7] drm/xe/vm: Wire MADVISE_AUTORESET notifiers into VM lifecycle Arvind Yadav
2026-06-04 10:05 ` sashiko-bot
2026-06-04 9:50 ` [RFC v3 7/7] drm/xe/svm: Correct memory attribute reset for partial unmap Arvind Yadav
2026-06-04 10:12 ` sashiko-bot
2026-06-04 10:32 ` ✗ CI.checkpatch: warning for drm/xe/svm: Add MMU notifier-based madvise autoreset on munmap (rev3) Patchwork
2026-06-04 10:34 ` ✓ CI.KUnit: success " Patchwork
2026-06-04 11:35 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-05 0:02 ` ✗ Xe.CI.FULL: failure " 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=20260604100340.96C581F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=arvind.yadav@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.