Re: [PATCH] sched/rt: Don't try push tasks if there are none.

From: Steven Rostedt
Date: Tue Aug 01 2023 - 12:01:04 EST


On Tue, 1 Aug 2023 17:26:48 +0200
Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> wrote:

> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 00e0e50741153..338cd150973ff 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2247,8 +2247,11 @@ static int rto_next_cpu(struct root_domain *rd)
>
> rd->rto_cpu = cpu;
>
> - if (cpu < nr_cpu_ids)
> + if (cpu < nr_cpu_ids) {
> + if (!has_pushable_tasks(cpu_rq(cpu)))
> + continue;

Hmm, I had to read this again to make sure we can't get into an infinite
loop. But it looks like we are safe, as if none of the CPUs had pushable
tasks, we would still hit the cpu == nr_cpu_ids case and fall into the loop
check, and break out there.

Reviewed-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>

-- Steve


> return cpu;
> + }
>
> rd->rto_cpu = -1;
>