[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z5RwSI0MzoaPArh4@gpd3>
Date: Sat, 25 Jan 2025 06:02:00 +0100
From: Andrea Righi <arighi@...dia.com>
To: Tejun Heo <tj@...nel.org>
Cc: David Vernet <void@...ifault.com>, Changwoo Min <changwoo@...lia.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] sched_ext: Fix lock imbalance in
dispatch_to_local_dsq()
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
Powered by blists - more mailing lists