From: "Lis, Tomasz" <tomasz.lis@intel.com>
To: Matthew Auld <matthew.auld@intel.com>, <intel-xe@lists.freedesktop.org>
Cc: "Michał Winiarski" <michal.winiarski@intel.com>,
"Piotr Piórkowski" <piotr.piorkowski@intel.com>,
"Satyanarayana K V P" <satyanarayana.k.v.p@intel.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v1] drm/xe: Retry when drm_gpusvm_get_pages() gives -EBUSY
Date: Tue, 24 Nov 2026 17:15:39 +0100 [thread overview]
Message-ID: <aba1c1d4-a06e-4550-ab4f-731b9ed894e1@intel.com> (raw)
In-Reply-To: <5659b906-98d7-4004-91a0-d43a6ba47276@intel.com>
[-- Attachment #1: Type: text/plain, Size: 8844 bytes --]
On 2026-11-24 16:27, Matthew Auld wrote:
> On 24/11/2026 15:23, Tomasz Lis wrote:
>> drm_gpusvm_get_pages() returns -EBUSY when its HMM retry budget is
>> exhausted. This can happen when the range was repeatedly invalidated
>> or faulting was slow. This is transient, but the callers treat -EBUSY
>> as fatal.
>>
>> The behavior causes sporadic fails after a VF post-migration recovery,
>> if drm_gpusvm_get_pages() run in parallel with the recovery, and the
>> recovery took longer than HMM_RANGE_DEFAULT_TIMEOUT (which isn't rare,
>> as the kernel bound to VF is running on virtual CPU).
>>
>> Example signature of the issue:
>> xe 0000:00:04.0: [drm] VM worker error: -16
>> xe 0000:00:04.0: [drm] Trying to schedule after vm is closed or
>> banned
>>
>> Convert -EBUSY to -EAGAIN in both wrappers around
>> drm_gpusvm_get_pages(),
>> through a common helper. The rebind worker, exec, the pagefault loop and
>> the SVM fault path already have a retry implemented on -EAGAIN.
>>
>> xe_vma_userptr_pin_pages() can now return -EAGAIN instead of -EBUSY, so
>> update the VMA creation path in xe_vm.c, which maps this error to
>> -ENOMEM. Tis way the bind ioctl keeps returning the same error as
>> before.
>
> Do you have some more context for how you hit this?
For log context:
[ 25.058112] xe 0000:00:04.0: [drm] VF: Tile0: GT0: readyfor recovery after migration
[ 25.058330] xe 0000:00:04.0: [drm] VF: Tile0: GT0: VF migration recovery scheduled
[ 25.058334] xe 0000:00:04.0: [drm] VF: Tile0: GT1: readyfor recovery after migration
[ 25.058336] xe 0000:00:04.0: [drm] VF: Tile0: GT1: VF migration recovery scheduled
[ 25.609533] xe 0000:00:04.0: [drm:guc_ct_change_state [xe]] Tile0: GT0: GuC CT communication channel enabled
[ 25.738796] xe 0000:00:04.0: [drm] VF: Tile0: GT0: migration recovery ended
[ 31.351935] xe 0000:00:04.0: [drm:guc_ct_change_state [xe]] Tile0: GT1: GuC CT communication channel enabled
[ 31.386304] xe 0000:00:04.0: [drm:xe_guc_submit_unpause_prepare_vf [xe]] Tile0: GT1: Replay JOB - guc_id=158, seqno=0
[ 31.386392] xe 0000:00:04.0: [drm:xe_guc_submit_unpause_prepare_vf [xe]] Tile0: GT1: Replay JOB - guc_id=158, seqno=0
[ 31.390497] xe 0000:00:04.0: [drm] VM worker error: -16
[ 31.394348] xe 0000:00:04.0: [drm] Trying to schedule after vm is closed or banned
[ 31.402756] xe 0000:00:04.0: [drm] VF: Tile0: GT1: migration recovery ended
For description:
This is a rare hit when executing VM TestBench test `vmtb@test_migration.py::TestBusyMigrationIgtExecThreads5`.
The test executes `igt@xe_exec_threads@threads-bal-mixed-userptr-invalidate` within the VM, and while that is executing, performs a Cold Migration to a VM with different GGTT range.
After PF restores the VM state, post-migration recovery starts executing. In the failing instance I analyzed, the recovery happen to take 6 seconds - far more than HMM_RANGE_DEFAULT_TIMEOUT.
Since updates of GGTT are blocked during the recovery, timeout was assured. In that instance, the call stack was xe_vm_userptr_pin()->xe_vma_userptr_pin_pages()->drm_gpusvm_get_pages().
>
> This looks like:
> https://patchwork.freedesktop.org/series/179052/
It does change the same code path, and the modification is similar,
though more complex.
I believe the 179052 series will fix the issue I'm seeing, though I
think timeout should be larger that the
XE_USERPTR_REPIN_TIMEOUT_MS_DEFAULT if the current device supports VM
migration.
We actually cannot tell what is the limit for VF migration recovery time
due to VCPU used, but we've seen in testing rare cases where times
reached 10s.
-Tomasz
>
>>
>> Signed-off-by: Tomasz Lis <tomasz.lis@intel.com>
>> Cc: Matthew Auld <matthew.auld@intel.com>
>> Cc: Matthew Brost <matthew.brost@intel.com>
>> ---
>> drivers/gpu/drm/xe/xe_svm.c | 2 +-
>> drivers/gpu/drm/xe/xe_userptr.c | 16 ++++++++++------
>> drivers/gpu/drm/xe/xe_vm.c | 8 ++++----
>> drivers/gpu/drm/xe/xe_vm.h | 16 ++++++++++++++++
>> 4 files changed, 31 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
>> index bc6902b5bf57..ffc624171d50 100644
>> --- a/drivers/gpu/drm/xe/xe_svm.c
>> +++ b/drivers/gpu/drm/xe/xe_svm.c
>> @@ -1624,7 +1624,7 @@ int xe_svm_range_get_pages(struct xe_vm *vm,
>> struct xe_svm_range *range,
>> drm_gpusvm_range_evict(&vm->svm.gpusvm, &range->base);
>> }
>> - return err;
>> + return xe_gpusvm_get_pages_err(err);
>> }
>> /**
>> diff --git a/drivers/gpu/drm/xe/xe_userptr.c
>> b/drivers/gpu/drm/xe/xe_userptr.c
>> index 9c1dac0fce6f..423c190ac68d 100644
>> --- a/drivers/gpu/drm/xe/xe_userptr.c
>> +++ b/drivers/gpu/drm/xe/xe_userptr.c
>> @@ -10,6 +10,7 @@
>> #include "xe_tlb_inval.h"
>> #include "xe_trace_bo.h"
>> +#include "xe_vm.h"
>> static void xe_userptr_assert_in_notifier(struct xe_vm *vm)
>> {
>> @@ -84,6 +85,7 @@ int xe_vma_userptr_pin_pages(struct xe_userptr_vma
>> *uvma)
>> .device_private_page_owner = xe_svm_private_page_owner(vm,
>> false),
>> .allow_mixed = true,
>> };
>> + int err;
>> xe_vma_userptr_lockdep(uvma);
>> xe_assert(xe, xe_vma_is_userptr(vma));
>> @@ -91,12 +93,14 @@ int xe_vma_userptr_pin_pages(struct
>> xe_userptr_vma *uvma)
>> if (vma->gpuva.flags & XE_VMA_DESTROYED)
>> return 0;
>> - return drm_gpusvm_get_pages(&vm->svm.gpusvm,
>> &uvma->userptr.pages, 1,
>> - uvma->userptr.notifier.mm,
>> - &uvma->userptr.notifier,
>> - xe_vma_userptr(vma),
>> - xe_vma_userptr(vma) + xe_vma_size(vma),
>> - &ctx);
>> + err = drm_gpusvm_get_pages(&vm->svm.gpusvm,
>> &uvma->userptr.pages, 1,
>> + uvma->userptr.notifier.mm,
>> + &uvma->userptr.notifier,
>> + xe_vma_userptr(vma),
>> + xe_vma_userptr(vma) + xe_vma_size(vma),
>> + &ctx);
>> +
>> + return xe_gpusvm_get_pages_err(err);
>> }
>> static struct mmu_interval_notifier_finish *
>> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
>> index dd855876f571..6e6937870ac6 100644
>> --- a/drivers/gpu/drm/xe/xe_vm.c
>> +++ b/drivers/gpu/drm/xe/xe_vm.c
>> @@ -2746,11 +2746,11 @@ static struct xe_vma *new_vma(struct xe_vm
>> *vm, struct drm_gpuva_op_map *op,
>> err = xe_vma_userptr_pin_pages(to_userptr_vma(vma));
>> /*
>> * -EBUSY has dedicated meaning that a user fence
>> - * attached to the VMA is busy, in practice
>> - * xe_vma_userptr_pin_pages can only fail with -EBUSY if
>> - * we are low on memory so convert this to -ENOMEM.
>> + * attached to the VMA is busy. xe_vma_userptr_pin_pages
>> + * reports exhausted HMM retries as -EAGAIN, which makes
>> + * no sense for the bind ioctl, so convert it to -ENOMEM.
>> */
>> - if (err == -EBUSY)
>> + if (err == -EAGAIN)
>> err = -ENOMEM;
>> }
>> }
>> diff --git a/drivers/gpu/drm/xe/xe_vm.h b/drivers/gpu/drm/xe/xe_vm.h
>> index b1c5f940bcc5..ba24f2e6022e 100644
>> --- a/drivers/gpu/drm/xe/xe_vm.h
>> +++ b/drivers/gpu/drm/xe/xe_vm.h
>> @@ -38,6 +38,22 @@ struct xe_vm *xe_vm_create(struct xe_device *xe,
>> u32 flags, struct xe_file *xef)
>> struct xe_vm *xe_vm_lookup(struct xe_file *xef, u32 id);
>> int xe_vma_cmp_vma_cb(const void *key, const struct rb_node *node);
>> +/**
>> + * xe_gpusvm_get_pages_err() - Translate an error from
>> drm_gpusvm_get_pages()
>> + * @err: error code returned by drm_gpusvm_get_pages()
>> + *
>> + * drm_gpusvm_get_pages() returns -EBUSY when its HMM retry budget
>> ran out,
>> + * because the range was repeatedly invalidated or faulting was
>> slow. That is
>> + * transient, so report -EAGAIN to let the callers retry. -EBUSY
>> would be
>> + * treated as fatal, and has other meanings in the VM code.
>> + *
>> + * Return: @err, with -EBUSY replaced by -EAGAIN
>> + */
>> +static inline int xe_gpusvm_get_pages_err(int err)
>> +{
>> + return err == -EBUSY ? -EAGAIN : err;
>> +}
>> +
>> static inline struct xe_vm *xe_vm_get(struct xe_vm *vm)
>> {
>> drm_gpuvm_get(&vm->gpuvm);
>
[-- Attachment #2: Type: text/html, Size: 14772 bytes --]
next prev parent reply other threads:[~2026-11-24 16:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 15:23 [PATCH v1] drm/xe: Retry when drm_gpusvm_get_pages() gives -EBUSY Tomasz Lis
2026-11-24 15:27 ` Matthew Auld
2026-11-24 16:15 ` Lis, Tomasz [this message]
2026-11-24 15:51 ` ✓ CI.KUnit: success for " Patchwork
2026-11-24 15:54 ` [PATCH v1] " sashiko-bot
2026-11-24 16:32 ` ✓ Xe.CI.BAT: success for " 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=aba1c1d4-a06e-4550-ab4f-731b9ed894e1@intel.com \
--to=tomasz.lis@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=michal.winiarski@intel.com \
--cc=piotr.piorkowski@intel.com \
--cc=satyanarayana.k.v.p@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