Re: [PATCH 00/14] sched: Support shared runqueue locking

Peter Zijlstra
2025-09-11T09:58:59Z

On Wed, Sep 10, 2025 at 08:35:55PM +0200, Peter Zijlstra wrote:

> I'll go untangle it, but probably something for tomorrow, I'm bound to
> make a mess of it now :-)

Best I could come up with is something like this. I tried a few other
approaches, but they all turned into a bigger mess.

Let me go try and run this.

---
kernel/sched/core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2481,11 +2481,11 @@ static inline bool is_cpu_allowed(struct
* Returns (locked) new rq. Old rq's lock is released.
*/
static struct rq *move_queued_task(struct rq *rq, struct rq_flags *rf,
- struct task_struct *p, int new_cpu)
+ struct task_struct *p, int new_cpu, int flags)
{
lockdep_assert_rq_held(rq);

- deactivate_task(rq, p, DEQUEUE_NOCLOCK);
+ deactivate_task(rq, p, flags | DEQUEUE_NOCLOCK);
set_task_cpu(p, new_cpu);
rq_unlock(rq, rf);

@@ -2493,7 +2493,7 @@ static struct rq *move_queued_task(struc

rq_lock(rq, rf);
WARN_ON_ONCE(task_cpu(p) != new_cpu);
- activate_task(rq, p, 0);
+ activate_task(rq, p, flags);
wakeup_preempt(rq, p, 0);

return rq;
@@ -2533,7 +2533,7 @@ static struct rq *__migrate_task(struct
if (!is_cpu_allowed(p, dest_cpu))
return rq;

- rq = move_queued_task(rq, rf, p, dest_cpu);
+ rq = move_queued_task(rq, rf, p, dest_cpu, 0);

return rq;
}
@@ -3007,7 +3007,7 @@ static int affine_move_task(struct rq *r

if (!is_migration_disabled(p)) {
if (task_on_rq_queued(p))
- rq = move_queued_task(rq, rf, p, dest_cpu);
+ rq = move_queued_task(rq, rf, p, dest_cpu, DEQUEUE_LOCKED);

if (!pending->stop_pending) {
p->migration_pending = NULL;