From: Matthew Auld <matthew.auld@intel.com>
To: "Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Himal Prasad Ghimiray" <himal.prasad.ghimiray@intel.com>,
"Stuart Summers" <stuart.summers@intel.com>
Cc: intel-xe@lists.freedesktop.org, Matthew Auld <matthew.auld@intel.com>
Subject: [PATCH v2 6/6] drm/xe: run compute rebind worker on device NUMA node
Date: Fri, 20 Nov 2026 13:02:21 +0000 [thread overview]
Message-ID: <20261120-userptr-repin-v2-6-65e1f6e582ef@intel.com> (raw)
In-Reply-To: <20261120-userptr-repin-v2-0-65e1f6e582ef@intel.com>
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.
Historically, xe->ordered_wq also serialised compute VM rebinds across
the device to avoid eviction ping-pong, which should no longer be
necessary since commit 8f25e5abcbfb ("drm/xe: Convert existing drm_exec
transactions for exhaustive eviction") serialises OOM eviction via
xe_validation_ctx.
Move vm->preempt.rebind_work onto a dedicated WQ_UNBOUND workqueue
queued via queue_work_node() with dev_to_node(), leaving user-fence
signalling on xe->ordered_wq.
v2 (Thomas):
- Drop the whole 1-at-a-time ordered wq requirement for the worker.
- Move the rebind destroy before destroy_wq; much safer.
Suggested-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
---
drivers/gpu/drm/xe/xe_device.c | 7 ++++++-
drivers/gpu/drm/xe/xe_device_types.h | 6 +++++-
drivers/gpu/drm/xe/xe_vm.c | 2 +-
drivers/gpu/drm/xe/xe_vm.h | 6 +++++-
4 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index f0c88d3297f9..8dfc8ef9dbd7 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -10,6 +10,7 @@
#include <linux/error-injection.h>
#include <linux/nodemask.h>
#include <linux/units.h>
+#include <linux/workqueue.h>
#include <drm/drm_client.h>
#include <drm/drm_gem_ttm_helper.h>
@@ -390,6 +391,9 @@ static void xe_device_destroy(struct drm_device *dev, void *dummy)
if (xe->preempt_fence_wq)
destroy_workqueue(xe->preempt_fence_wq);
+ if (xe->rebind_wq)
+ destroy_workqueue(xe->rebind_wq);
+
if (xe->ordered_wq)
destroy_workqueue(xe->ordered_wq);
@@ -523,10 +527,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, 0);
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..778cc1c9b39a 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -7,6 +7,7 @@
#define _XE_DEVICE_TYPES_H_
#include <linux/pci.h>
+#include <linux/workqueue.h>
#include <drm/drm_device.h>
#include <drm/drm_file.h>
@@ -375,7 +376,10 @@ 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;
+
+ /** @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..ab138d495f3f 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -540,7 +540,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)
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);
}
/**
--
2.56.1
next prev parent reply other threads:[~2026-11-20 13:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 13:02 [PATCH v2 0/6] Non-fatal repin retries and NUMA-local rebind worker Matthew Auld
2026-11-20 13:02 ` [PATCH v2 1/6] drm/xe/vm: restore userptr invalidations on VMA op unwind Matthew Auld
2026-11-20 13:02 ` [PATCH v2 2/6] drm/xe/vf: Free preempt fences on rebind worker retry Matthew Auld
2026-11-20 13:02 ` [PATCH v2 3/6] drm/xe: Requeue the rebind worker instead of retrying in-line on -EAGAIN Matthew Auld
2026-11-20 13:02 ` [PATCH v2 4/6] drm/xe: Add a userptr repin timeout sysfs attribute Matthew Auld
2026-11-20 13:02 ` [PATCH v2 5/6] drm/xe/userptr: Make the repin retry loop non-fatal Matthew Auld
2026-11-20 13:02 ` Matthew Auld [this message]
2026-11-20 13:12 ` ✓ CI.KUnit: success for Non-fatal repin retries and NUMA-local rebind worker (rev2) 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=20261120-userptr-repin-v2-6-65e1f6e582ef@intel.com \
--to=matthew.auld@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=stuart.summers@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