Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C44CA606A32A for ; Thu, 19 Nov 2026 11:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=cWaZMBaN Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 76D1A1122BB; Thu, 19 Nov 2026 11:19:39 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 883A71122D2 for ; Thu, 19 Nov 2026 11:19:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1795087174; x=1826623174; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=qPvIOpQB2SUlh3I082bksSuWwCDrBXl7YVX6T2Yi4PI=; b=cWaZMBaNqD9oOGMPYQ3VHDUPQEABMJu7dB84yA4l2AoycO7AlUuKy1n1 5v7YmZoWlxXxkX6Z5ZkckdIXyQDfTOWxFnAbOG2Y1Z6LX4mmdGm2lDbiu aAeE6CzLFBQq+W6MZVjjW6eV06huyVr4zi7JLJ6oui000QuLKX6ATRmWO lGn32ksX+WVF1SqRrcXBqfYuTIk1OQNfcucVno9mEB7MzscRUs9XnE0BU OVm7JCA+GxYRJp5DoX/NEQPCG02MbkifD0S/SZKxf/+P50PZg4kh+0sXU 2IwuwFuqDXcxmNQNZjPKdd29Rgd1/+IHNb2sWH8IsEIwjSButK8SaHC9x A==; X-CSE-ConnectionGUID: GK0OseyJT6KoS1wcdvKGhA== X-CSE-MsgGUID: XkTJHvlTQlm5/bAss7paLw== X-IronPort-AV: E=McAfee;i="6800,10657,11970"; a="3828784" X-IronPort-AV: E=Sophos;i="6.27,220,1787036400"; d="scan'208";a="3828784" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2026 03:19:33 -0800 X-CSE-ConnectionGUID: QOxZAK5uS3CN8g6qAiqoYA== X-CSE-MsgGUID: osdn9xaySjy1kC/o4vktiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,220,1787036400"; d="scan'208";a="10402320" Received: from ettammin-mobl3.ger.corp.intel.com (HELO [192.168.0.182]) ([10.245.245.108]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2026 03:19:32 -0800 From: Matthew Auld Date: Thu, 19 Nov 2026 11:14:36 +0000 Subject: [PATCH 5/5] drm/xe: run compute rebind worker on device NUMA node X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261119-userptr-repin-v1-5-af2e327833a9@intel.com> References: <20261119-userptr-repin-v1-0-af2e327833a9@intel.com> In-Reply-To: <20261119-userptr-repin-v1-0-af2e327833a9@intel.com> To: Matthew Brost , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Himal Prasad Ghimiray , Stuart Summers Cc: intel-xe@lists.freedesktop.org, Matthew Auld X-Mailer: b4 0.14.3 X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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). Signed-off-by: Matthew Auld --- 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 #include #include +#include #include +#include #include #include @@ -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); + + 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 #include +#include #include #include @@ -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 #include #include +#include #include #include @@ -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 +#include + #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