All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Jia Yao <jia.yao@intel.com>
Cc: intel-xe@lists.freedesktop.org,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH] drm/xe: Use a dedicated workqueue for VM rebinds
Date: Tue, 20 Oct 2026 09:34:40 -0700	[thread overview]
Message-ID: <ateYILtvzWfEkwoi@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <20261019230142.1112281-1-jia.yao@intel.com>

On Mon, Oct 19, 2026 at 11:01:42PM +0000, Jia Yao wrote:
> VM rebind workers may block while handling HMM faults or waiting for VM
> fences. Running them on ordered_wq can stall user-fence notifications
> and VM TLB timeout work queued behind them, preventing forward progress.

I don't see how ' VM TLB timeout work' is related. Those are scheduled
on the GT ordered work queue. 

> 
> Move rebind workers to a dedicated ordered workqueue. This keeps rebinds
> serialized across VMs while allowing fence-related work to run
> independently.
> 

So this isn't a deadlock rather just a delay in user fences signaling?

> Signed-off-by: Jia Yao <jia.yao@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_device.c       | 12 +++++++++++-
>  drivers/gpu/drm/xe/xe_device_types.h |  5 ++++-
>  drivers/gpu/drm/xe/xe_vm.c           |  2 +-
>  drivers/gpu/drm/xe/xe_vm.h           |  2 +-
>  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 db0b883322ef..f1dd4b7842a9 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -385,6 +385,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);

How about s/ordered_wq/userfence_wq to make this clear what is used for
and nothing else should be scheduled on this.

Matt

>  
> @@ -515,9 +518,16 @@ int xe_device_init_early(struct xe_device *xe)
>  	xe->preempt_fence_wq = alloc_ordered_workqueue("xe-preempt-fence-wq",
>  						       WQ_MEM_RECLAIM);
>  	xe->ordered_wq = alloc_ordered_workqueue("xe-ordered-wq", 0);
> +	/*
> +	 * Rebinding can block in HMM or wait for VM fences. Keep it off the
> +	 * queue serving user-fence notifications and VM TLB fence timeouts,
> +	 * which must be able to make progress while a rebind is waiting.
> +	 * Preserve serialization between rebind workers on different VMs.
> +	 */
> +	xe->rebind_wq = alloc_ordered_workqueue("xe-rebind-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->rebind_wq || !xe->unordered_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 5553415afeaf..705c487e3c6f 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -387,9 +387,12 @@ 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 */
> +	/** @ordered_wq: ordered user-fence and VM TLB timeout work */
>  	struct workqueue_struct *ordered_wq;
>  
> +	/** @rebind_wq: serializes compute mode rebinds and resume */
> +	struct workqueue_struct *rebind_wq;
> +
>  	/** @unordered_wq: used to serialize unordered work */
>  	struct workqueue_struct *unordered_wq;
>  
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index e7f421a43516..88b4f6b19fdd 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -501,7 +501,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);
>  }
>  
>  static void preempt_rebind_work_func(struct work_struct *w)
> diff --git a/drivers/gpu/drm/xe/xe_vm.h b/drivers/gpu/drm/xe/xe_vm.h
> index 06138c3c4315..25c8760e2392 100644
> --- a/drivers/gpu/drm/xe/xe_vm.h
> +++ b/drivers/gpu/drm/xe/xe_vm.h
> @@ -259,7 +259,7 @@ 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(vm->xe->rebind_wq, &vm->preempt.rebind_work);
>  }
>  
>  /**
> -- 
> 2.43.0
> 

  parent reply	other threads:[~2026-10-20 16:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 23:01 [PATCH] drm/xe: Use a dedicated workqueue for VM rebinds Jia Yao
2026-10-19 23:10 ` ✓ CI.KUnit: success for " Patchwork
2026-10-20  0:01 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-20  3:05 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-10-20 16:34 ` Matthew Brost [this message]
2026-10-21  5:04   ` [PATCH] " Yao, Jia

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=ateYILtvzWfEkwoi@gsse-cloud1.jf.intel.com \
    --to=matthew.brost@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jia.yao@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 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.