Re: [RESEND][PATCH v9 4/7] sched: Add do_push_task helper

From: Valentin Schneider
Date: Tue Apr 09 2024 - 12:30:23 EST


On 01/04/24 16:44, John Stultz wrote:
> From: Connor O'Brien <connoro@xxxxxxxxxx>
>
> Switch logic that deactivates, sets the task cpu,
> and reactivates a task on a different rq to use a
> helper that will be later extended to push entire
> blocked task chains.
>
> This patch was broken out from a larger chain migration
> patch originally by Connor O'Brien.
>
> Cc: Joel Fernandes <joelaf@xxxxxxxxxx>
> Cc: Qais Yousef <qyousef@xxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Juri Lelli <juri.lelli@xxxxxxxxxx>
> Cc: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> Cc: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
> Cc: Valentin Schneider <vschneid@xxxxxxxxxx>
> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
> Cc: Ben Segall <bsegall@xxxxxxxxxx>
> Cc: Zimuzo Ezeozue <zezeozue@xxxxxxxxxx>
> Cc: Youssef Esmat <youssefesmat@xxxxxxxxxx>
> Cc: Mel Gorman <mgorman@xxxxxxx>
> Cc: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
> Cc: Will Deacon <will@xxxxxxxxxx>
> Cc: Waiman Long <longman@xxxxxxxxxx>
> Cc: Boqun Feng <boqun.feng@xxxxxxxxx>
> Cc: "Paul E. McKenney" <paulmck@xxxxxxxxxx>
> Cc: Metin Kaya <Metin.Kaya@xxxxxxx>
> Cc: Xuewen Yan <xuewen.yan94@xxxxxxxxx>
> Cc: K Prateek Nayak <kprateek.nayak@xxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: kernel-team@xxxxxxxxxxx
> Tested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>

Naming nit below notwithstanding:

Reviewed-by: Valentin Schneider <vschneid@xxxxxxxxxx>

> Signed-off-by: Connor O'Brien <connoro@xxxxxxxxxx>
> [jstultz: split out from larger chain migration patch]
> Signed-off-by: John Stultz <jstultz@xxxxxxxxxx>

> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index d2242679239e..16057de24ecd 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -3472,5 +3472,14 @@ static inline void init_sched_mm_cid(struct task_struct *t) { }
>
> extern u64 avg_vruntime(struct cfs_rq *cfs_rq);
> extern int entity_eligible(struct cfs_rq *cfs_rq, struct sched_entity *se);
> +#ifdef CONFIG_SMP
> +static inline
> +void do_push_task(struct rq *rq, struct rq *dst_rq, struct task_struct *task)

The naming IMO unfortunately clashes with the hotplug push_task /
balance_push() stuff.

AFAICT this is move_queued_task() but in a double rq lock
context. How about move_queued_task_locked()?

Interestingly, all the patched call sites end up with a resched_curr(), but
move_queued_task() has wakeup_preempt() instead.

> +{
> + deactivate_task(rq, task, 0);
> + set_task_cpu(task, dst_rq->cpu);
> + activate_task(dst_rq, task, 0);
> +}
> +#endif
>
> #endif /* _KERNEL_SCHED_SCHED_H */
> --
> 2.44.0.478.gd926399ef9-goog