From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>
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: Sat, 25 Jan 2025 06:02:00 +0100 [thread overview]
Message-ID: <Z5RwSI0MzoaPArh4@gpd3> (raw)
In-Reply-To: <Z5PlN3Zj_YhPt2Da@slm.duckdns.org>
On Fri, Jan 24, 2025 at 09:08:39AM -1000, Tejun Heo wrote:
> 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.
I see, that makes sense, I'll send a new patch following this approach.
Thanks!
-Andrea
prev parent reply other threads:[~2025-01-25 5:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 7:24 [PATCH v2] sched_ext: Fix lock imbalance in dispatch_to_local_dsq() Andrea Righi
2025-01-24 19:08 ` Tejun Heo
2025-01-25 5:02 ` 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=Z5RwSI0MzoaPArh4@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.