Re: [tip:sched/core 13/47] kernel/sched/core.c:10400:42: error: variable 'stats' set but not used

From: Yafang Shao
Date: Sun Oct 10 2021 - 06:00:34 EST


On Sun, Oct 10, 2021 at 9:38 AM kernel test robot <lkp@xxxxxxxxx> wrote:
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/core
> head: b2d5b9cec60fecc72a13191c2c6c05acf60975a5
> commit: ceeadb83aea28372e54857bf88ab7e17af48ab7b [13/47] sched: Make struct sched_statistics independent of fair sched class
> config: microblaze-buildonly-randconfig-r002-20211010 (attached as .config)
> compiler: microblaze-linux-gcc (GCC) 11.2.0
> reproduce (this is a W=1 build):

It is a W=1 warning.
It seems that we don't need to fix the warning.

> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=ceeadb83aea28372e54857bf88ab7e17af48ab7b
> git remote add tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
> git fetch --no-tags tip sched/core
> git checkout ceeadb83aea28372e54857bf88ab7e17af48ab7b
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=microblaze
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> All errors (new ones prefixed by >>):
>
> kernel/sched/core.c: In function 'ttwu_stat':
> kernel/sched/core.c:3482:20: error: variable 'rq' set but not used [-Werror=unused-but-set-variable]
> 3482 | struct rq *rq;
> | ^~
> kernel/sched/core.c: In function 'cpu_cfs_stat_show':
> >> kernel/sched/core.c:10400:42: error: variable 'stats' set but not used [-Werror=unused-but-set-variable]
> 10400 | struct sched_statistics *stats;
> | ^~~~~
> cc1: all warnings being treated as errors
>
>
> vim +/stats +10400 kernel/sched/core.c
>
> 10389
> 10390 static int cpu_cfs_stat_show(struct seq_file *sf, void *v)
> 10391 {
> 10392 struct task_group *tg = css_tg(seq_css(sf));
> 10393 struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
> 10394
> 10395 seq_printf(sf, "nr_periods %d\n", cfs_b->nr_periods);
> 10396 seq_printf(sf, "nr_throttled %d\n", cfs_b->nr_throttled);
> 10397 seq_printf(sf, "throttled_time %llu\n", cfs_b->throttled_time);
> 10398
> 10399 if (schedstat_enabled() && tg != &root_task_group) {
> 10400 struct sched_statistics *stats;
> 10401 u64 ws = 0;
> 10402 int i;
> 10403
> 10404 for_each_possible_cpu(i) {
> 10405 stats = __schedstats_from_se(tg->se[i]);
> 10406 ws += schedstat_val(stats->wait_sum);
> 10407 }
> 10408
> 10409 seq_printf(sf, "wait_sum %llu\n", ws);
> 10410 }
> 10411
> 10412 seq_printf(sf, "nr_bursts %d\n", cfs_b->nr_burst);
> 10413 seq_printf(sf, "burst_time %llu\n", cfs_b->burst_time);
> 10414
> 10415 return 0;
> 10416 }
> 10417 #endif /* CONFIG_CFS_BANDWIDTH */
> 10418 #endif /* CONFIG_FAIR_GROUP_SCHED */
> 10419
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx



--
Thanks
Yafang