public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] sched_ext: Fix lock imbalance in dispatch_to_local_dsq()
Date: Sat, 25 Jan 2025 09:35:47 +0100	[thread overview]
Message-ID: <Z5SiY0WNvEHXkrv5@gpd3> (raw)
In-Reply-To: <20250125065608.181754-1-arighi@nvidia.com>

On Sat, Jan 25, 2025 at 07:56:08AM +0100, Andrea Righi wrote:
...
> @@ -2557,6 +2567,7 @@ static void dispatch_to_local_dsq(struct rq *rq, struct scx_dispatch_q *dst_dsq,
>  {
>  	struct rq *src_rq = task_rq(p);
>  	struct rq *dst_rq = container_of(dst_dsq, struct rq, scx.local_dsq);
> +	struct rq *locked_rq = rq;

I just noticed that we have an unused variable here with !CONFIG_SMP, so
ignore this. I'll send a new version soon.

Sorry for the noise.
-Andrea

>  
>  	/*
>  	 * We're synchronized against dequeue through DISPATCHING. As @p can't
> @@ -2593,12 +2604,16 @@ static void dispatch_to_local_dsq(struct rq *rq, struct scx_dispatch_q *dst_dsq,
>  	atomic_long_set_release(&p->scx.ops_state, SCX_OPSS_NONE);
>  
>  	/* switch to @src_rq lock */
> -	if (rq != src_rq) {
> -		raw_spin_rq_unlock(rq);
> +	if (locked_rq != src_rq) {
> +		raw_spin_rq_unlock(locked_rq);
> +		locked_rq = src_rq;
>  		raw_spin_rq_lock(src_rq);
>  	}
>  
> -	/* task_rq couldn't have changed if we're still the holding cpu */
> +	/*
> +	 * If p->scx.holding_cpu still matches the current CPU, task_rq(p)
> +	 * has not changed and we can safely move the task to @dst_rq.
> +	 */
>  	if (likely(p->scx.holding_cpu == raw_smp_processor_id()) &&
>  	    !WARN_ON_ONCE(src_rq != task_rq(p))) {
>  		/*

      reply	other threads:[~2025-01-25  8:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-25  6:56 [PATCH v3] sched_ext: Fix lock imbalance in dispatch_to_local_dsq() Andrea Righi
2025-01-25  8:35 ` Andrea Righi [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=Z5SiY0WNvEHXkrv5@gpd3 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=void@manifault.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