Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched/topology: Remove redundant variable and fix incorrect type in build_sched_domains

While investigating the sparse warning reported by the LKP bot [1],
observed that we have a redundant variable "top" in the function
build_sched_domains that was introduced in the recent commit
e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when
SD_NUMA spans multiple LLCs")

The existing variable "sd" suffices which allows us to remove the
redundant variable "top" while annotating the other variable "top_p"
with the "__rcu" annotation to silence the sparse warning.

[1] https://lore.kernel.org/lkml/202202170853.9vofgC3O-lkp@intel.com/

Fixes: e496132ebedd ("sched/fair: Adjust the allowed NUMA imbalance when SD_NUMA spans multiple LLCs")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
Link: https://lore.kernel.org/r/20220218162743.1134-1-kprateek.nayak@amd.com

authored by

K Prateek Nayak and committed by
Peter Zijlstra
7f434dff 821aecd0

+3 -5
+3 -5
kernel/sched/topology.c
··· 2291 2291 2292 2292 if (!(sd->flags & SD_SHARE_PKG_RESOURCES) && child && 2293 2293 (child->flags & SD_SHARE_PKG_RESOURCES)) { 2294 - struct sched_domain *top, *top_p; 2294 + struct sched_domain __rcu *top_p; 2295 2295 unsigned int nr_llcs; 2296 2296 2297 2297 /* ··· 2316 2316 sd->imb_numa_nr = imb; 2317 2317 2318 2318 /* Set span based on the first NUMA domain. */ 2319 - top = sd; 2320 - top_p = top->parent; 2319 + top_p = sd->parent; 2321 2320 while (top_p && !(top_p->flags & SD_NUMA)) { 2322 - top = top->parent; 2323 - top_p = top->parent; 2321 + top_p = top_p->parent; 2324 2322 } 2325 2323 imb_span = top_p ? top_p->span_weight : sd->span_weight; 2326 2324 } else {