intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: intel-xe@lists.freedesktop.org,
	Joonas Lahtinen	 <joonas.lahtinen@linux.intel.com>,
	Jani Nikula <jani.nikula@intel.com>,
	 Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Matthew Auld <matthew.auld@intel.com>
Subject: Re: [PATCH 01/15] drm/xe/vm: Don't use a pin the vm_resv during validation
Date: Wed, 13 Aug 2025 16:33:01 +0200	[thread overview]
Message-ID: <e6e365e23e1cd02e242c221e91b687e9ac97731b.camel@linux.intel.com> (raw)
In-Reply-To: <aJyhGXq6JEKuPs81@lstrano-desk.jf.intel.com>

On Wed, 2025-08-13 at 07:28 -0700, Matthew Brost wrote:
> On Wed, Aug 13, 2025 at 12:51:07PM +0200, Thomas Hellström wrote:
> > The pinning has the odd side-effect that unlocking *any* resv
> > during validation triggers an "unlocking pinned lock" warning.
> > 
> 
> So this is a cross process thing then - right? e.g., Process A pins a
> dma-resv lock, Process B unlock a dma-resv lock and boom lockdep
> warning? Just want to make sure I am understandinf the problem
> correctly.

No, my understanding is that this is a single process thing.
We lock the vm, pin it, lock a bo for eviction, perhaps using the same
ww_mutex_ctx, unlock the evicted bo => bang.

It might be that the locks need to be locked using the same ww_mutex
context, but not sure.

/Thomas


> 
> Matt 
> 
> > Cc: Matthew Brost <matthew.brost@intel.com>
> > Fixes: 9d5558649f68 ("drm/xe: Rework eviction rejection of bound
> > external bos")
> > Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_bo.c |  5 ++---
> >  drivers/gpu/drm/xe/xe_vm.h | 15 ++-------------
> >  2 files changed, 4 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_bo.c
> > b/drivers/gpu/drm/xe/xe_bo.c
> > index 6fea39842e1e..11eaf3b06766 100644
> > --- a/drivers/gpu/drm/xe/xe_bo.c
> > +++ b/drivers/gpu/drm/xe/xe_bo.c
> > @@ -2468,7 +2468,6 @@ int xe_bo_validate(struct xe_bo *bo, struct
> > xe_vm *vm, bool allow_res_evict)
> >  		.no_wait_gpu = false,
> >  		.gfp_retry_mayfail = true,
> >  	};
> > -	struct pin_cookie cookie;
> >  	int ret;
> >  
> >  	if (vm) {
> > @@ -2479,10 +2478,10 @@ int xe_bo_validate(struct xe_bo *bo, struct
> > xe_vm *vm, bool allow_res_evict)
> >  		ctx.resv = xe_vm_resv(vm);
> >  	}
> >  
> > -	cookie = xe_vm_set_validating(vm, allow_res_evict);
> > +	xe_vm_set_validating(vm, allow_res_evict);
> >  	trace_xe_bo_validate(bo);
> >  	ret = ttm_bo_validate(&bo->ttm, &bo->placement, &ctx);
> > -	xe_vm_clear_validating(vm, allow_res_evict, cookie);
> > +	xe_vm_clear_validating(vm, allow_res_evict);
> >  
> >  	return ret;
> >  }
> > diff --git a/drivers/gpu/drm/xe/xe_vm.h
> > b/drivers/gpu/drm/xe/xe_vm.h
> > index 2f213737c7e5..2ecb417c19a2 100644
> > --- a/drivers/gpu/drm/xe/xe_vm.h
> > +++ b/drivers/gpu/drm/xe/xe_vm.h
> > @@ -315,22 +315,14 @@ void xe_vm_snapshot_free(struct
> > xe_vm_snapshot *snap);
> >   * Register this task as currently making bos resident for the vm.
> > Intended
> >   * to avoid eviction by the same task of shared bos bound to the
> > vm.
> >   * Call with the vm's resv lock held.
> > - *
> > - * Return: A pin cookie that should be used for
> > xe_vm_clear_validating().
> >   */
> > -static inline struct pin_cookie xe_vm_set_validating(struct xe_vm
> > *vm,
> > -						     bool
> > allow_res_evict)
> > +static inline void xe_vm_set_validating(struct xe_vm *vm, bool
> > allow_res_evict)
> >  {
> > -	struct pin_cookie cookie = {};
> > -
> >  	if (vm && !allow_res_evict) {
> >  		xe_vm_assert_held(vm);
> > -		cookie = lockdep_pin_lock(&xe_vm_resv(vm)-
> > >lock.base);
> >  		/* Pairs with READ_ONCE in xe_vm_is_validating()
> > */
> >  		WRITE_ONCE(vm->validating, current);
> >  	}
> > -
> > -	return cookie;
> >  }
> >  
> >  /**
> > @@ -338,17 +330,14 @@ static inline struct pin_cookie
> > xe_vm_set_validating(struct xe_vm *vm,
> >   * @vm: Pointer to the vm or NULL
> >   * @allow_res_evict: Eviction from @vm was allowed. Must be set to
> > the same
> >   * value as for xe_vm_set_validation().
> > - * @cookie: Cookie obtained from xe_vm_set_validating().
> >   *
> >   * Register this task as currently making bos resident for the vm.
> > Intended
> >   * to avoid eviction by the same task of shared bos bound to the
> > vm.
> >   * Call with the vm's resv lock held.
> >   */
> > -static inline void xe_vm_clear_validating(struct xe_vm *vm, bool
> > allow_res_evict,
> > -					  struct pin_cookie
> > cookie)
> > +static inline void xe_vm_clear_validating(struct xe_vm *vm, bool
> > allow_res_evict)
> >  {
> >  	if (vm && !allow_res_evict) {
> > -		lockdep_unpin_lock(&xe_vm_resv(vm)->lock.base,
> > cookie);
> >  		/* Pairs with READ_ONCE in xe_vm_is_validating()
> > */
> >  		WRITE_ONCE(vm->validating, NULL);
> >  	}
> > -- 
> > 2.50.1
> > 


  reply	other threads:[~2025-08-13 14:33 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13 10:51 [PATCH 00/15] Driver-managed exhaustive eviction Thomas Hellström
2025-08-13 10:51 ` [PATCH 01/15] drm/xe/vm: Don't use a pin the vm_resv during validation Thomas Hellström
2025-08-13 14:28   ` Matthew Brost
2025-08-13 14:33     ` Thomas Hellström [this message]
2025-08-13 15:17       ` Matthew Brost
2025-08-13 10:51 ` [PATCH 02/15] drm/xe/tests/xe_dma_buf: Set the drm_object::dma_buf member Thomas Hellström
2025-08-14  2:52   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 03/15] drm/xe/vm: Clear the scratch_pt pointer on error Thomas Hellström
2025-08-13 14:45   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 04/15] drm/xe: Pass down drm_exec context to validation Thomas Hellström
2025-08-13 16:42   ` Matthew Brost
2025-08-14  7:49     ` Thomas Hellström
2025-08-14 19:09       ` Matthew Brost
2025-08-22  7:40     ` Thomas Hellström
2025-08-13 10:51 ` [PATCH 05/15] drm/xe: Introduce an xe_validation wrapper around drm_exec Thomas Hellström
2025-08-13 17:25   ` Matthew Brost
2025-08-15 15:04     ` Thomas Hellström
2025-08-14  2:33   ` Matthew Brost
2025-08-14  4:23     ` Matthew Brost
2025-08-15 15:23     ` Thomas Hellström
2025-08-15 19:01       ` Matthew Brost
2025-08-17 14:05   ` [05/15] " Simon Richter
2025-08-18  2:19     ` Matthew Brost
2025-08-18  5:24       ` Simon Richter
2025-08-18  9:19     ` Thomas Hellström
2025-08-13 10:51 ` [PATCH 06/15] drm/xe: Convert xe_bo_create_user() for exhaustive eviction Thomas Hellström
2025-08-14  2:23   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 07/15] drm/xe: Convert SVM validation " Thomas Hellström
2025-08-13 15:32   ` Matthew Brost
2025-08-14 12:24     ` Thomas Hellström
2025-08-13 10:51 ` [PATCH 08/15] drm/xe: Convert existing drm_exec transactions " Thomas Hellström
2025-08-14  2:48   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 09/15] drm/xe: Convert the CPU fault handler " Thomas Hellström
2025-08-13 22:06   ` Matthew Brost
2025-08-15 15:16     ` Thomas Hellström
2025-08-15 19:04       ` Matthew Brost
2025-08-18  9:11         ` Thomas Hellström
2025-08-13 10:51 ` [PATCH 10/15] drm/xe/display: Convert __xe_pin_fb_vma() Thomas Hellström
2025-08-14  2:35   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 11/15] drm/xe: Convert xe_dma_buf.c for exhaustive eviction Thomas Hellström
2025-08-13 21:37   ` Matthew Brost
2025-08-15 15:05     ` Thomas Hellström
2025-08-14 20:37   ` Matthew Brost
2025-08-15  6:57     ` Thomas Hellström
2025-08-13 10:51 ` [PATCH 12/15] drm/xe: Rename ___xe_bo_create_locked() Thomas Hellström
2025-08-13 21:33   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 13/15] drm/xe: Convert xe_bo_create_pin_map_at() for exhaustive eviction Thomas Hellström
2025-08-14  3:58   ` Matthew Brost
2025-08-15 15:25     ` Thomas Hellström
2025-08-14  4:05   ` Matthew Brost
2025-08-15 15:27     ` Thomas Hellström
2025-08-14 18:48   ` Matthew Brost
2025-08-15  9:37     ` Thomas Hellström
2025-08-13 10:51 ` [PATCH 14/15] drm/xe: Convert xe_bo_create_pin_map() " Thomas Hellström
2025-08-14  4:18   ` Matthew Brost
2025-08-14 13:14     ` Thomas Hellström
2025-08-14 18:39       ` Matthew Brost
2025-08-13 10:51 ` [PATCH 15/15] drm/xe: Convert pinned suspend eviction " Thomas Hellström
2025-08-13 12:13   ` Matthew Auld
2025-08-13 12:30     ` Thomas Hellström
2025-08-14 20:30   ` Matthew Brost
2025-08-15 15:29     ` Thomas Hellström
2025-08-13 11:54 ` ✗ CI.checkpatch: warning for Driver-managed " Patchwork
2025-08-13 11:55 ` ✓ CI.KUnit: success " Patchwork
2025-08-13 13:20 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-08-13 14:25 ` ✗ Xe.CI.Full: " 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=e6e365e23e1cd02e242c221e91b687e9ac97731b.camel@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@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;
as well as URLs for NNTP newsgroup(s).