From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Matthew Auld <matthew.auld@intel.com>,
Matthew Brost <matthew.brost@intel.com>,
Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>,
Stuart Summers <stuart.summers@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 5/5] drm/xe: run compute rebind worker on device NUMA node
Date: Thu, 19 Nov 2026 14:11:10 +0100 [thread overview]
Message-ID: <f29cef0f95344993fc9d098f548dcde0dba8bfe8.camel@linux.intel.com> (raw)
In-Reply-To: <20261119-userptr-repin-v1-5-af2e327833a9@intel.com>
On Thu, 2026-11-19 at 11:14 +0000, Matthew Auld wrote:
> preempt_rebind_work_func() currently runs on xe->ordered_wq, whose
> unbound worker pool spans all NUMA nodes. On multi-socket systems, if
> the rebind worker runs on a remote socket when faulting userptr pages
> marked PROT_NONE by AutoNUMA, hmm_range_fault() invokes
> do_numa_page()
> using the worker's NUMA node and triggers migrate_misplaced_folio(),
> pulling pages away from the GPU's local node and causing self-
> inflicted
> MMU notifier invalidations.
>
> Move vm->preempt.rebind_work onto a dedicated WQ_UNBOUND workqueue
> (max_active = 1) queued via queue_work_node() with dev_to_node(),
> leaving user-fence signalling on xe->ordered_wq. Guard
> preempt_rebind_work_func() with a per-device mutex so compute rebinds
> remain strictly 1-at-a-time even when queue_work_node() falls back
> across nodes (such as NUMA_NO_NODE or CPU-less nodes).
I don't remember fully why we have this 1-at-a-time rebind worker. I
wonder whether it was because of concurrent validations causing VMs to
outcompete eachother for memory. If that was the case, then we might be
able to lift that restriction due to the validation guard.
>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> ---
> drivers/gpu/drm/xe/xe_device.c | 11 ++++++++++-
> drivers/gpu/drm/xe/xe_device_types.h | 10 +++++++++-
> drivers/gpu/drm/xe/xe_vm.c | 8 +++++++-
> drivers/gpu/drm/xe/xe_vm.h | 6 +++++-
> 4 files changed, 31 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_device.c
> b/drivers/gpu/drm/xe/xe_device.c
> index 4e54a1b7fc51..f75a32bb48e3 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -8,7 +8,9 @@
> #include <linux/aperture.h>
> #include <linux/delay.h>
> #include <linux/error-injection.h>
> +#include <linux/mutex.h>
> #include <linux/units.h>
> +#include <linux/workqueue.h>
>
> #include <drm/drm_client.h>
> #include <drm/drm_gem_ttm_helper.h>
> @@ -396,6 +398,11 @@ static void xe_device_destroy(struct drm_device
> *dev, void *dummy)
> if (xe->destroy_wq)
> destroy_workqueue(xe->destroy_wq);
>
> + if (xe->rebind_wq)
> + destroy_workqueue(xe->rebind_wq);
Hm. It looks safer if we destroy this wq earlier than the destroy wq?
Is there a chance that we put something on the destroy wq from the
rebind wq?
> +
> + mutex_destroy(&xe->rebind_lock);
> +
> ttm_device_fini(&xe->ttm);
>
> if (atomic_dec_and_test(&xe_device_count))
> @@ -472,6 +479,7 @@ int xe_device_init_early(struct xe_device *xe)
> return err;
>
> xe_bo_dev_init(&xe->bo_device);
> + mutex_init(&xe->rebind_lock);
> atomic_inc(&xe_device_count);
> err = drmm_add_action_or_reset(&xe->drm, xe_device_destroy,
> NULL);
> if (err)
> @@ -518,10 +526,11 @@ int xe_device_init_early(struct xe_device *xe)
>
> xe->preempt_fence_wq = alloc_ordered_workqueue("xe-preempt-
> fence-wq",
>
> WQ_MEM_RECLAIM);
> + xe->rebind_wq = alloc_workqueue("xe-rebind-wq", WQ_UNBOUND,
> 1);
> xe->ordered_wq = alloc_ordered_workqueue("xe-ordered-wq",
> 0);
> xe->unordered_wq = alloc_workqueue("xe-unordered-wq",
> WQ_PERCPU, 0);
> xe->destroy_wq = alloc_workqueue("xe-destroy-wq", WQ_PERCPU
> | WQ_MEM_RECLAIM, 0);
> - if (!xe->ordered_wq || !xe->unordered_wq ||
> + if (!xe->ordered_wq || !xe->unordered_wq || !xe->rebind_wq
> ||
> !xe->preempt_fence_wq || !xe->destroy_wq) {
> /*
> * Cleanup done in xe_device_destroy via
> diff --git a/drivers/gpu/drm/xe/xe_device_types.h
> b/drivers/gpu/drm/xe/xe_device_types.h
> index fc80cd2c766e..c30d64296869 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -6,7 +6,9 @@
> #ifndef _XE_DEVICE_TYPES_H_
> #define _XE_DEVICE_TYPES_H_
>
> +#include <linux/mutex.h>
> #include <linux/pci.h>
> +#include <linux/workqueue.h>
>
> #include <drm/drm_device.h>
> #include <drm/drm_file.h>
> @@ -375,7 +377,13 @@ struct xe_device {
> /** @preempt_fence_wq: used to serialize preempt fences */
> struct workqueue_struct *preempt_fence_wq;
>
> - /** @ordered_wq: used to serialize compute mode resume */
> + /** @rebind_wq: used to run compute mode rebind work on
> device node */
> + struct workqueue_struct *rebind_wq;
> +
> + /** @rebind_lock: serializes compute mode rebind workers per
> device */
> + struct mutex rebind_lock;
> +
> + /** @ordered_wq: used to serialize ordered work */
> struct workqueue_struct *ordered_wq;
>
> /** @unordered_wq: used to serialize unordered work */
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index 0c5121361f8e..1436d09ee560 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -18,6 +18,7 @@
> #include <linux/delay.h>
> #include <linux/kthread.h>
> #include <linux/mm.h>
> +#include <linux/mutex.h>
> #include <linux/sched/signal.h>
> #include <linux/swap.h>
>
> @@ -540,7 +541,7 @@ static bool vm_suspend_rebind_worker(struct xe_vm
> *vm)
> */
> void xe_vm_resume_rebind_worker(struct xe_vm *vm)
> {
> - queue_work(vm->xe->ordered_wq, &vm->preempt.rebind_work);
> + xe_vm_queue_rebind_worker(vm);
> }
>
> #if IS_ENABLED(CONFIG_DRM_XE_USERPTR_INVAL_INJECT)
> @@ -581,16 +582,19 @@ static void preempt_rebind_work_func(struct
> work_struct *w)
> xe_assert(vm->xe, xe_vm_in_preempt_fence_mode(vm));
> trace_xe_vm_rebind_worker_enter(vm);
>
> + mutex_lock(&vm->xe->rebind_lock);
> down_write(&vm->lock);
>
> if (xe_vm_is_closed_or_banned(vm)) {
> up_write(&vm->lock);
> + mutex_unlock(&vm->xe->rebind_lock);
> trace_xe_vm_rebind_worker_exit(vm);
> return;
> }
>
> if (!try_wait_for_completion(&vm->xe->pm_block) &&
> vm_suspend_rebind_worker(vm)) {
> up_write(&vm->lock);
> + mutex_unlock(&vm->xe->rebind_lock);
> /* We don't actually block but don't make progress.
> */
> xe_pm_might_block_on_suspend();
> return;
> @@ -666,6 +670,7 @@ static void preempt_rebind_work_func(struct
> work_struct *w)
> * lock make progress between attempts.
> */
> up_write(&vm->lock);
> + mutex_unlock(&vm->xe->rebind_lock);
> free_preempt_fences(&preempt_fences);
> xe_vm_queue_rebind_worker(vm);
> trace_xe_vm_rebind_worker_exit(vm);
> @@ -679,6 +684,7 @@ static void preempt_rebind_work_func(struct
> work_struct *w)
> xe_vm_kill(vm, true);
> }
> up_write(&vm->lock);
> + mutex_unlock(&vm->xe->rebind_lock);
>
> free_preempt_fences(&preempt_fences);
>
> diff --git a/drivers/gpu/drm/xe/xe_vm.h b/drivers/gpu/drm/xe/xe_vm.h
> index b1c5f940bcc5..ed590bad892c 100644
> --- a/drivers/gpu/drm/xe/xe_vm.h
> +++ b/drivers/gpu/drm/xe/xe_vm.h
> @@ -6,6 +6,9 @@
> #ifndef _XE_VM_H_
> #define _XE_VM_H_
>
> +#include <linux/device.h>
> +#include <linux/workqueue.h>
> +
> #include "xe_assert.h"
> #include "xe_bo_types.h"
> #include "xe_macros.h"
> @@ -259,7 +262,8 @@ int xe_vm_validate_protected(struct xe_vm *vm);
> static inline void xe_vm_queue_rebind_worker(struct xe_vm *vm)
> {
> xe_assert(vm->xe, xe_vm_in_preempt_fence_mode(vm));
> - queue_work(vm->xe->ordered_wq, &vm->preempt.rebind_work);
> + queue_work_node(dev_to_node(vm->xe->drm.dev), vm->xe-
> >rebind_wq,
> + &vm->preempt.rebind_work);
Is a NUMA_NO_NODE dev_to_node() return OK here?
Thanks,
Thomas
> }
>
> /**
next prev parent reply other threads:[~2026-11-19 13:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 11:14 [PATCH 0/5] Non-fatal repin retries and NUMA-local rebind worker Matthew Auld
2026-11-19 11:14 ` [PATCH 1/5] drm/xe/vm: restore userptr invalidations on VMA op unwind Matthew Auld
2026-11-19 12:48 ` Thomas Hellström
2026-11-19 16:35 ` Himal prasad Ghimiray
2026-11-19 11:14 ` [PATCH 2/5] drm/xe: Requeue the rebind worker instead of retrying in-line on -EAGAIN Matthew Auld
2026-11-19 12:51 ` Thomas Hellström
2026-11-19 16:29 ` Matthew Auld
2026-11-19 17:26 ` Thomas Hellström
2026-11-19 17:38 ` Matthew Auld
2026-11-19 16:36 ` Himal prasad Ghimiray
2026-11-19 11:14 ` [PATCH 3/5] drm/xe: Add a userptr repin timeout sysfs attribute Matthew Auld
2026-11-19 16:38 ` Himal prasad Ghimiray
2026-11-20 10:43 ` Matthew Auld
2026-11-20 10:49 ` Himal prasad Ghimiray
2026-11-19 11:14 ` [PATCH 4/5] drm/xe/userptr: Make the repin retry loop non-fatal Matthew Auld
2026-11-19 13:03 ` Thomas Hellström
2026-11-19 17:10 ` Himal prasad Ghimiray
2026-11-19 11:14 ` [PATCH 5/5] drm/xe: run compute rebind worker on device NUMA node Matthew Auld
2026-11-19 13:11 ` Thomas Hellström [this message]
2026-11-19 13:38 ` Matthew Auld
2026-11-19 13:16 ` ✓ CI.KUnit: success for Non-fatal repin retries and NUMA-local rebind worker Patchwork
2026-11-19 13:54 ` ✓ Xe.CI.BAT: " 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=f29cef0f95344993fc9d098f548dcde0dba8bfe8.camel@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=stuart.summers@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 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.