sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern
authorPeter Zijlstra <peterz@infradead.org>
Wed, 30 Oct 2024 14:08:15 +0000 (15:08 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 16 Oct 2025 09:13:51 +0000 (11:13 +0200)
commit637b0682821b144d5993211cf0a768b322138a69
tree42ec9287c9ba73ca7abde1048e7a75b2adc4ad0f
parent5e42d4c123ba9b89ce19b3aa7e22b7684cbfa49c
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>
kernel/sched/core.c
kernel/sched/ext.c
kernel/sched/idle.c
kernel/sched/rt.c
kernel/sched/sched.h
kernel/sched/stop_task.c
kernel/sched/syscalls.c