[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241015142917.83397-1-zhangqiao22@huawei.com>
Date: Tue, 15 Oct 2024 22:29:17 +0800
From: Zhang Qiao <zhangqiao22@...wei.com>
To: Tejun Heo <tj@...nel.org>, David Vernet <void@...ifault.com>, Ingo Molnar
<mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>, Juri Lelli
<juri.lelli@...hat.com>, Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>, Steven Rostedt
<rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>, Mel Gorman
<mgorman@...e.de>, Valentin Schneider <vschneid@...hat.com>
CC: <linux-kernel@...r.kernel.org>, <zhangqiao22@...wei.com>
Subject: [PATCH] sched_ext: Fix missing unlock in consume_dispatch_q()
When the function consume_dispatch_q() returns true, the dsq lock may
remains held and is not unlocked.
Signed-off-by: Zhang Qiao <zhangqiao22@...wei.com>
---
kernel/sched/ext.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 410a4df8a121..4d80aa3de00e 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -2377,7 +2377,8 @@ static inline bool consume_remote_task(struct rq *this_rq, struct task_struct *p
static bool consume_dispatch_q(struct rq *rq, struct scx_dispatch_q *dsq)
{
struct task_struct *p;
-retry:
+ bool ret = false;
+
/*
* The caller can't expect to successfully consume a task if the task's
* addition to @dsq isn't guaranteed to be visible somehow. Test
@@ -2394,19 +2395,20 @@ static bool consume_dispatch_q(struct rq *rq, struct scx_dispatch_q *dsq)
if (rq == task_rq) {
task_unlink_from_dsq(p, dsq);
move_local_task_to_local_dsq(p, 0, dsq, rq);
- raw_spin_unlock(&dsq->lock);
- return true;
+ ret = true;
+ break;
}
if (task_can_run_on_remote_rq(p, rq, false)) {
- if (likely(consume_remote_task(rq, p, dsq, task_rq)))
- return true;
- goto retry;
+ if (likely(consume_remote_task(rq, p, dsq, task_rq))) {
+ ret = true;
+ break;
+ }
}
}
raw_spin_unlock(&dsq->lock);
- return false;
+ return ret;
}
static bool consume_global_dsq(struct rq *rq)
--
2.33.0
Powered by blists - more mailing lists