mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Andrea Righi <arighi@nvidia.com>
Cc: David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] sched_ext: Fix lock imbalance in dispatch_to_local_dsq()
Date: Fri, 24 Jan 2025 09:08:39 -1000	[thread overview]
Message-ID: <Z5PlN3Zj_YhPt2Da@slm.duckdns.org> (raw)
In-Reply-To: <20250124072425.47795-1-arighi@nvidia.com>

Hello, Andrea.

Thanks for debugging this.

On Fri, Jan 24, 2025 at 08:24:25AM +0100, Andrea Righi wrote:
...
> Fix this by correctly assuming that task is still in src_rq in this
> specific scenario.

But I find this a bit misleading. It's more that we didn't do anything and
thus didn't switch the held lock and the assumption that the unlock path
makes is wrong.

...
> +	} else {
> +		/*
> +		 * Otherwise, if dequeue wins the race, we no longer have
> +		 * exclusive ownership of the task and we must keep it in
> +		 * its original @src_dsq.
> +		 */
> +		dst_rq = src_rq;

Both the code and explanation are confusing to me. This is working around
the incorrect assumption the following block is making - that we'd be
locking $dsq_rq when control reach that point. Can you instead add new
variable $locked_rq which tracks which rq is currently locked and then use
that in the unlock path? It starts with $rq and set to $src_rq when
switching to that and then set to $dst_rq in the migration block. Then, the
unlock path can test @rq against $locked_rq. scx_dsq_move() uses a similar
approach for reference.

Thanks.

-- 
tejun

  reply	other threads:[~2025-01-24 19:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-24  7:24 Andrea Righi
2025-01-24 19:08 ` Tejun Heo [this message]
2025-01-25  5:02   ` Andrea Righi

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=Z5PlN3Zj_YhPt2Da@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®