All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Arvind Yadav <arvind.yadav@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>, <rodrigo.vivi@intel.com>,
	<himal.prasad.ghimiray@intel.com>,
	<thomas.hellstrom@linux.intel.com>, <tejas.upadhyay@intel.com>
Subject: Re: [PATCH] drm/xe/vm: Cancel pending rebind work before freeing the VM
Date: Wed, 25 Nov 2026 09:30:37 -0800	[thread overview]
Message-ID: <awcbPRYPCeNHsRGL@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <awcK/Q6SifMWJNR1@gsse-cloud1.jf.intel.com>

On Wed, Nov 25, 2026 at 08:21:17AM -0800, Matthew Brost wrote:
> On Wed, Nov 25, 2026 at 03:37:44PM +0530, Arvind Yadav wrote:
> > vm_destroy_work_func() runs on xe->destroy_wq and flushes rebind work
> > on xe->ordered_wq. The destroy queue has WQ_MEM_RECLAIM, but the
> > ordered queue has no rescuer. The kernel warns because this wait can
> > stall memory reclaim.
> > 
> > The VM is already closed, so a pending rebind would return immediately.
> > Use cancel_work_sync() to cancel pending work and wait for a running
> > rebind to finish before freeing the VM.
> > 
> > [  727.067318] ------------[ cut here ]------------
> > [  727.067552] workqueue: WQ_MEM_RECLAIM xe-destroy-wq:vm_destroy_work_func [xe] is flushing !WQ_MEM_RECLAIM xe-ordered-wq:preempt_rebind_work_func [xe]

I didn't read the stack trace, but this patch, or switching to
disable_work_sync(), probably won't help.
cancel_work_sync()/disable_work_sync() can still block if the rebind
workqueue is running, and I think the same warning would still appear
(though I'm not 100% sure)/

Maybe the better question is why xe-destroy-wq is marked with
WQ_MEM_RECLAIM. Sure, it frees memory, but it isn't in the DMA-fencing
path, which I think is the actual hard requirement for marking a
workqueue with WQ_MEM_RECLAIM. So perhaps we should just drop
WQ_MEM_RECLAIM from xe-destroy-wq?

Also, I think s/flush_work()/disable_work_sync()/ is technically still
the right code change, but I wouldn't consider it a fix.

Matt

> > [  727.067726] WARNING: kernel/workqueue.c:4043 at check_flush_dependency.part.0+0xd9/0x110, CPU#1: kworker/1:0/33641
> > [  727.067876] Workqueue: xe-destroy-wq vm_destroy_work_func [xe]
> > [  727.067963] Call Trace:
> > [  727.067964]  <TASK>
> > [  727.067967]  __flush_work+0x44b/0x660
> > [  727.067970]  ? __lock_acquire+0x584/0x29c0
> > [  727.067974]  ? lock_is_held_type+0xa3/0x130
> > [  727.067980]  flush_work+0x28/0x40
> > [  727.067982]  vm_destroy_work_func+0x1a9/0x350 [xe]
> > [  727.068061]  ? lock_release+0xd0/0x2c0
> > [  727.068065]  process_one_work+0x2ad/0x890
> > [  727.068071]  worker_thread+0x200/0x3f0
> > [  727.068074]  ? __pfx_worker_thread+0x10/0x10
> > [  727.068077]  kthread+0x113/0x150
> > [  727.068079]  ? __pfx_kthread+0x10/0x10
> > [  727.068081]  ret_from_fork+0x3bf/0x470
> > [  727.068085]  ? __pfx_kthread+0x10/0x10
> > [  727.068087]  ret_from_fork_asm+0x1a/0x30
> > [  727.068096]  </TASK>
> > [  727.068108] ---[ end trace 0000000000000000 ]---
> > 
> > Fixes: 61e18525023a ("drm/xe: Route deferred xe_vma/xe_vm teardown off system_dfl_wq")
> > Cc: Matthew Brost <matthew.brost@intel.com>
> > Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> > Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
> > Signed-off-by: Arvind Yadav <arvind.yadav@intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_vm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> > index dd855876f571..2ba99c083db8 100644
> > --- a/drivers/gpu/drm/xe/xe_vm.c
> > +++ b/drivers/gpu/drm/xe/xe_vm.c
> > @@ -2091,7 +2091,7 @@ static void vm_destroy_work_func(struct work_struct *w)
> >  	xe_assert(xe, !vm->size);
> >  
> >  	if (xe_vm_in_preempt_fence_mode(vm))
> > -		flush_work(&vm->preempt.rebind_work);
> > +		cancel_work_sync(&vm->preempt.rebind_work);
> 
> disable_work_sync ?
> 
> Matt
> 
> >  
> >  	mutex_destroy(&vm->snap_mutex);
> >  
> > -- 
> > 2.43.0
> > 

  reply	other threads:[~2026-11-25 18:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 10:07 [PATCH] drm/xe/vm: Cancel pending rebind work before freeing the VM Arvind Yadav
2026-11-25 11:25 ` ✓ CI.KUnit: success for " Patchwork
2026-11-25 12:02 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-25 15:59 ` ✓ Xe.CI.FULL: " Patchwork
2026-11-25 16:21 ` [PATCH] " Matthew Brost
2026-11-25 17:30   ` Matthew Brost [this message]
2026-11-26  4:43     ` Yadav, Arvind

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=awcbPRYPCeNHsRGL@gsse-cloud1.jf.intel.com \
    --to=matthew.brost@intel.com \
    --cc=arvind.yadav@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=tejas.upadhyay@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.