Re: [PATCH] sched: core: Remove unnecessary ‘NULL’ values from core_rq

From: Steven Rostedt
Date: Tue May 28 2024 - 10:01:39 EST


On Tue, 28 May 2024 15:14:46 +0800
Li zeming <zeming@xxxxxxxxxxxx> wrote:

> core_rq is assigned first, so it does not need to initialize the
> assignment.

No, it is assigned in a loop. Yes, the loop should always execute once,
but the compiler doesn't know that (hence the WARN_ON() that checks
it). That means removing the NULL assignment will likely cause the
warning from the compiler that the variable may be used uninitialized.

The assignment is there at least to quiet the compiler. It's not a fast
path, and the initialization is not a problem.

NACK.

-- Steve


>
> Signed-off-by: Li zeming <zeming@xxxxxxxxxxxx>
> ---
> kernel/sched/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index e32fea8f5830..346159a24705 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6485,7 +6485,7 @@ static void sched_core_cpu_starting(unsigned int cpu)
> static void sched_core_cpu_deactivate(unsigned int cpu)
> {
> const struct cpumask *smt_mask = cpu_smt_mask(cpu);
> - struct rq *rq = cpu_rq(cpu), *core_rq = NULL;
> + struct rq *rq = cpu_rq(cpu), *core_rq;
> int t;
>
> guard(core_lock)(&cpu);