public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@linux.intel.com>
To: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Andi Shyti <andi.shyti@linux.intel.com>,
	intel-gfx <intel-gfx@lists.freedesktop.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	John Harrison <John.C.Harrison@intel.com>,
	Andi Shyti <andi.shyti@kernel.org>,
	Matthew Brost <matthew.brost@intel.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] drm/i915/gt/uc: Evaluate GuC priority within locks
Date: Tue, 11 Jun 2024 15:31:57 +0200	[thread overview]
Message-ID: <ZmhRzRa9axjlaIl3@ashyti-mobl2.lan> (raw)
In-Reply-To: <185a4d70-4f1b-4b95-acc2-d2e26cb0052b@intel.com>

Hi Daniele,

thanks for checking this patch.

> > diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> > index 0eaa1064242c..1181043bc5e9 100644
> > --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> > +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> > @@ -4267,13 +4267,18 @@ static void guc_bump_inflight_request_prio(struct i915_request *rq,
> >   	u8 new_guc_prio = map_i915_prio_to_guc_prio(prio);
> >   	/* Short circuit function */
> > -	if (prio < I915_PRIORITY_NORMAL ||
> > -	    rq->guc_prio == GUC_PRIO_FINI ||
> > -	    (rq->guc_prio != GUC_PRIO_INIT &&
> > -	     !new_guc_prio_higher(rq->guc_prio, new_guc_prio)))
> > +	if (prio < I915_PRIORITY_NORMAL)
> >   		return;
> 
> My understanding was that those checks are purposely done outside of the
> lock to avoid taking it when not needed and that the early exit is not racy.
> In particular:
> 
> - GUC_PRIO_FINI is the end state for the priority, so if we're there that's
> not changing anymore and therefore the lock is not required.

yeah... then I thought that the lock should either remove it
completely or have everything inside the lock.

> - the priority only goes up with the bumping, so if new_guc_prio_higher() is
> false that's not going to be changed by a different thread running at the
> same time and increasing the priority even more.
> 
> I think there is still a possible race is if new_guc_prio_higher() is true
> when we check it outside the lock but then changes before we execute the
> protected chunk inside, so a fix would still be required for that.

This is the reason why I made the patch :-)

> All this said, I don't really have anything against moving the whole thing
> inside the lock since this isn't on a critical path, just wanted to point
> out that it's not all strictly required.
> 
> One nit on the code below.
> 
> >   	spin_lock(&ce->guc_state.lock);
> > +
> > +	if (rq->guc_prio == GUC_PRIO_FINI)
> > +		goto exit;
> > +
> > +	if (rq->guc_prio != GUC_PRIO_INIT &&
> > +	    !new_guc_prio_higher(rq->guc_prio, new_guc_prio))
> > +		goto exit;
> > +
> >   	if (rq->guc_prio != GUC_PRIO_FINI) {
> 
> You're now checking for rq->guc_prio == GUC_PRIO_FINI inside the lock, so no
> need to check it again here as it can't have changed.

True, will resend.

Thanks, Daniele!

Andi

      reply	other threads:[~2024-06-11 13:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06  0:17 [PATCH] drm/i915/gt/uc: Evaluate GuC priority within locks Andi Shyti
2024-06-06  2:57 ` Matthew Brost
2024-06-07 18:19 ` Daniele Ceraolo Spurio
2024-06-11 13:31   ` Andi Shyti [this message]

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=ZmhRzRa9axjlaIl3@ashyti-mobl2.lan \
    --to=andi.shyti@linux.intel.com \
    --cc=John.C.Harrison@intel.com \
    --cc=andi.shyti@kernel.org \
    --cc=daniele.ceraolospurio@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=stable@vger.kernel.org \
    /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