]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sched: Fix proxy/current (push,pull)ability
authorValentin Schneider <valentin.schneider@arm.com>
Sat, 12 Jul 2025 03:33:48 +0000 (03:33 +0000)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 14 Jul 2025 15:16:33 +0000 (17:16 +0200)
commitbe39617e38e0b1939a6014d77ee6f14707d59b1b
tree5446c9078cd7a767db7b7869b6368157adec5f7e
parentbe41bde4c3a86de4be5cd3d1ca613e24664e68dc
sched: Fix proxy/current (push,pull)ability

Proxy execution forms atomic pairs of tasks: The waiting donor
task (scheduling context) and a proxy (execution context). The
donor task, along with the rest of the blocked chain, follows
the proxy wrt CPU placement.

They can be the same task, in which case push/pull doesn't need any
modification. When they are different, however,
FIFO1 & FIFO42:

      ,->  RT42
      |     | blocked-on
      |     v
blocked_donor |   mutex
      |     | owner
      |     v
      `--  RT1

   RT1
   RT42

  CPU0            CPU1
   ^                ^
   |                |
  overloaded    !overloaded
  rq prio = 42  rq prio = 0

RT1 is eligible to be pushed to CPU1, but should that happen it will
"carry" RT42 along. Clearly here neither RT1 nor RT42 must be seen as
push/pullable.

Unfortunately, only the donor task is usually dequeued from the rq,
and the proxy'ed execution context (rq->curr) remains on the rq.
This can cause RT1 to be selected for migration from logic like the
rt pushable_list.

Thus, adda a dequeue/enqueue cycle on the proxy task before __schedule
returns, which allows the sched class logic to avoid adding the now
current task to the pushable_list.

Furthermore, tasks becoming blocked on a mutex don't need an explicit
dequeue/enqueue cycle to be made (push/pull)able: they have to be running
to block on a mutex, thus they will eventually hit put_prev_task().

Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
Signed-off-by: Connor O'Brien <connoro@google.com>
Signed-off-by: John Stultz <jstultz@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://lkml.kernel.org/r/20250712033407.2383110-8-jstultz@google.com
kernel/sched/core.c
kernel/sched/deadline.c
kernel/sched/rt.c