summaryrefslogtreecommitdiff
path: root/kernel/sched/syscalls.c
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2024-10-30 15:08:15 +0100
committerPeter Zijlstra <peterz@infradead.org>2025-10-16 11:13:51 +0200
commit637b0682821b144d5993211cf0a768b322138a69 (patch)
tree42ec9287c9ba73ca7abde1048e7a75b2adc4ad0f /kernel/sched/syscalls.c
parent5e42d4c123ba9b89ce19b3aa7e22b7684cbfa49c (diff)
downloadlinux-637b0682821b144d5993211cf0a768b322138a69.tar.gz
linux-637b0682821b144d5993211cf0a768b322138a69.tar.bz2
linux-637b0682821b144d5993211cf0a768b322138a69.zip
sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern
Add {DE,EN}QUEUE_CLASS and fold the sched_class::switch* methods into the change pattern. This completes and makes the pattern more symmetric. This changes the order of callbacks slightly: OLD NEW | | switching_from() dequeue_task(); | dequeue_task() put_prev_task(); | put_prev_task() | switched_from() | ... change task ... | ... change task ... | switching_to(); | switching_to() enqueue_task(); | enqueue_task() set_next_task(); | set_next_task() prev_class->switched_from() | switched_to() | switched_to() | Notably, it moves the switched_from() callback right after the dequeue/put. Existing implementations don't appear to be affected by this change in location -- specifically the task isn't enqueued on the class in question in either location. Make (CLASS)^(SAVE|MOVE), because there is nothing to save-restore when changing scheduling classes. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Juri Lelli <juri.lelli@redhat.com> Acked-by: Tejun Heo <tj@kernel.org> Acked-by: Vincent Guittot <vincent.guittot@linaro.org>
Diffstat (limited to 'kernel/sched/syscalls.c')
-rw-r--r--kernel/sched/syscalls.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
index 09ffe91410b1..bcef5c72d287 100644
--- a/kernel/sched/syscalls.c
+++ b/kernel/sched/syscalls.c
@@ -684,6 +684,9 @@ change:
prev_class = p->sched_class;
next_class = __setscheduler_class(policy, newprio);
+ if (prev_class != next_class)
+ queue_flags |= DEQUEUE_CLASS;
+
if (prev_class != next_class && p->se.sched_delayed)
dequeue_task(rq, p, DEQUEUE_SLEEP | DEQUEUE_DELAYED | DEQUEUE_NOCLOCK);
@@ -695,7 +698,6 @@ change:
p->prio = newprio;
}
__setscheduler_uclamp(p, attr);
- check_class_changing(rq, p, prev_class);
if (scope->queued) {
/*
@@ -707,7 +709,8 @@ change:
}
}
- check_class_changed(rq, p, prev_class, oldprio);
+ if (!(queue_flags & DEQUEUE_CLASS))
+ check_prio_changed(rq, p, oldprio);
/* Avoid rq from going away on us: */
preempt_disable();