[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z5PlN3Zj_YhPt2Da@slm.duckdns.org>
Date: Fri, 24 Jan 2025 09:08:39 -1000
From: Tejun Heo <tj@...nel.org>
To: Andrea Righi <arighi@...dia.com>
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()
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
Powered by blists - more mailing lists