[tip: sched/core] sched: Fix sched_delayed vs sched_core

tip-bot2 for Peter Zijlstra posted 1 patch 2 months, 2 weeks ago
kernel/sched/core.c | 6 ++++++
1 file changed, 6 insertions(+)
[tip: sched/core] sched: Fix sched_delayed vs sched_core
Posted by tip-bot2 for Peter Zijlstra 2 months, 2 weeks ago
The following commit has been merged into the sched/core branch of tip:

Commit-ID:     c662e2b1e8cfc3b6329704dab06051f8c3ec2993
Gitweb:        https://git.kernel.org/tip/c662e2b1e8cfc3b6329704dab06051f8c3ec2993
Author:        Peter Zijlstra <peterz@infradead.org>
AuthorDate:    Thu, 05 Sep 2024 17:02:24 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 10 Sep 2024 09:51:15 +02:00

sched: Fix sched_delayed vs sched_core

Completely analogous to commit dfa0a574cbc4 ("sched/uclamg: Handle
delayed dequeue"), avoid double dequeue for the sched_core entries.

Fixes: 152e11f6df29 ("sched/fair: Implement delayed dequeue")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 kernel/sched/core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2922fac..b4c5d83 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -259,6 +259,9 @@ static inline int rb_sched_core_cmp(const void *key, const struct rb_node *node)
 
 void sched_core_enqueue(struct rq *rq, struct task_struct *p)
 {
+	if (p->se.sched_delayed)
+		return;
+
 	rq->core->core_task_seq++;
 
 	if (!p->core_cookie)
@@ -269,6 +272,9 @@ void sched_core_enqueue(struct rq *rq, struct task_struct *p)
 
 void sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags)
 {
+	if (p->se.sched_delayed)
+		return;
+
 	rq->core->core_task_seq++;
 
 	if (sched_core_enqueued(p)) {