Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Nirmoy Das <nirmoy.das@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, Matthew Auld <matthew.auld@intel.com>
Subject: Re: [PATCH v2] drm/xe/ufence: Kick ufence immediately when possible
Date: Thu, 17 Oct 2024 23:58:57 +0000	[thread overview]
Message-ID: <ZxGkwS80jgq16rYL@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <ZxGjg+DwLbDhiNOX@DUT025-TGLU.fm.intel.com>

On Thu, Oct 17, 2024 at 11:53:39PM +0000, Matthew Brost wrote:
> On Thu, Oct 17, 2024 at 11:42:37AM +0200, Nirmoy Das wrote:
> > If the backing fence is signaled then signal ufence soon with
> > system_wq. This should reduce load from the xe ordered_wq and also
> > won't block signaling a ufence which doesn't require any serialization.
> > 
> > v2: fix system_wq typo
> > 
> > Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/1630
> > Cc: Matthew Auld <matthew.auld@intel.com>
> > gc: Matthew Brost <matthew.brost@intel.com>
> > Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_sync.c | 12 ++++++++----
> >  1 file changed, 8 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c
> > index c6cf227ead40..1a7907293088 100644
> > --- a/drivers/gpu/drm/xe/xe_sync.c
> > +++ b/drivers/gpu/drm/xe/xe_sync.c
> > @@ -89,10 +89,14 @@ static void user_fence_worker(struct work_struct *w)
> >  	user_fence_put(ufence);
> >  }
> >  
> > -static void kick_ufence(struct xe_user_fence *ufence, struct dma_fence *fence)
> > +static void kick_ufence(struct xe_user_fence *ufence, struct dma_fence *fence,
> > +			bool signaled)
> 
> Predantic but maybe replace 'bool signaled' which a flag. We really want
> to avoid bools if possible.
> 
> e.g.
> 
> #define UFENCE_FLAG_SIGNALED	BIT(0)
> 

Sorry double reply, 'signaled' not actually relavent here as in both
calling cases the fence is signaled. Rather we want to pick between a
worker (needed if in a IRQ context) and doing it directly. Maybe
rename this to something more relavent indicating that.

Matt

> static void kick_ufence(struct xe_user_fence *ufence, struct dma_fence *fence,
> 			unsigned int flags)
> {
> 	...
> 	if (flags & UFENCE_FLAG_SIGNALED)
> 		...
> 	else
> 		...
> 	...	
> }
> 
> >  {
> >  	INIT_WORK(&ufence->worker, user_fence_worker);
> > -	queue_work(ufence->xe->ordered_wq, &ufence->worker);
> > +	if (signaled)
> > +		queue_work(system_wq, &ufence->worker);
> 
> I don't think you need the work queue here, just call the work func directly.
> 
> s/queue_work(system_wq, &ufence->worker)/user_fence_worker(&ufence->worker)
> 
> Matt
> 
> > +	else
> > +		queue_work(ufence->xe->ordered_wq, &ufence->worker);
> >  	dma_fence_put(fence);
> >  }
> >  
> > @@ -100,7 +104,7 @@ static void user_fence_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
> >  {
> >  	struct xe_user_fence *ufence = container_of(cb, struct xe_user_fence, cb);
> >  
> > -	kick_ufence(ufence, fence);
> > +	kick_ufence(ufence, fence, false);
> >  }
> >  
> >  int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
> > @@ -236,7 +240,7 @@ void xe_sync_entry_signal(struct xe_sync_entry *sync, struct dma_fence *fence)
> >  		err = dma_fence_add_callback(fence, &sync->ufence->cb,
> >  					     user_fence_cb);
> >  		if (err == -ENOENT) {
> > -			kick_ufence(sync->ufence, fence);
> > +			kick_ufence(sync->ufence, fence, true);
> >  		} else if (err) {
> >  			XE_WARN_ON("failed to add user fence");
> >  			user_fence_put(sync->ufence);
> > -- 
> > 2.46.0
> > 

  reply	other threads:[~2024-10-17 23:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-17  9:42 [PATCH v2] drm/xe/ufence: Kick ufence immediately when possible Nirmoy Das
2024-10-17 10:29 ` ✓ CI.Patch_applied: success for drm/xe/ufence: Kick ufence immediately when possible (rev2) Patchwork
2024-10-17 10:29 ` ✓ CI.checkpatch: " Patchwork
2024-10-17 10:30 ` ✓ CI.KUnit: " Patchwork
2024-10-17 10:42 ` ✓ CI.Build: " Patchwork
2024-10-17 10:44 ` ✓ CI.Hooks: " Patchwork
2024-10-17 10:45 ` ✓ CI.checksparse: " Patchwork
2024-10-17 11:09 ` ✓ CI.BAT: " Patchwork
2024-10-17 20:55 ` ✗ CI.FULL: failure " Patchwork
2024-10-17 23:53 ` [PATCH v2] drm/xe/ufence: Kick ufence immediately when possible Matthew Brost
2024-10-17 23:58   ` Matthew Brost [this message]
2024-10-18 13:32   ` Nirmoy Das
2024-10-21 12:32 ` Jani Nikula
2024-10-21 14:08   ` Nirmoy Das

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=ZxGkwS80jgq16rYL@DUT025-TGLU.fm.intel.com \
    --to=matthew.brost@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=nirmoy.das@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