sched/core: add forced idle accounting for cgroups
PATCH v2 1/1 sched/core: add forced idle accounting for cgroups
4feee7d1260 previously added per-task forced idle accounting. This patch extends this to also include cgroups.
rstat is used for cgroup accounting, except for the root, which uses kcpustat in order to bypass the need for doing an rstat flush when reading root stats.
Only cgroup v2 is supported. Similar to the task accounting, the cgroup accounting requires that schedstats is enabled.
---
v2: Per Tejun's suggestion, move the forceidle stat to cgroup_base_stat directly.
include/linux/cgroup-defs.h | 4 ++++ include/linux/kernel_stat.h | 7 +++++++ kernel/cgroup/rstat.c | 40 +++++++++++++++++++++++++++++++------ kernel/sched/core_sched.c | 6 +++++- kernel/sched/cputime.c | 11 ++++++++++ 5 files changed, 61 insertions(+), 7 deletions(-)
include/linux/cgroup-defs.h +4 -0
@@ -287,6 +287,10 @@ struct css_set {struct cgroup_base_stat {struct task_cputime cputime; + +#ifdef CONFIG_SCHED_CORE +u64 forceidle_sum; +#endif };/*
include/linux/kernel_stat.h +7 -0
@@ -28,6 +28,9 @@ enum cpu_usage_stat {CPUTIME_STEAL ,CPUTIME_GUEST ,CPUTIME_GUEST_NICE , +#ifdef CONFIG_SCHED_CORE +CPUTIME_FORCEIDLE , +#endif NR_STATS, };
@@ -115,4 +118,8 @@ extern void account_process_tick(struct task_struct *, int user);extern void account_idle_ticks (unsigned long ticks); +#ifdef CONFIG_SCHED_CORE +extern void account_forceidle_time (struct task_struct *tsk,u64 delta); +#endif +#endif /* _LINUX_KERNEL_STAT_H */
kernel/cgroup/rstat.c +34 -6
@@ -310,6 +310,9 @@ static void cgroup_base_stat_add(struct cgroup_base_stat *dst_bstat, dst_bstat->cputime.utime += src_bstat->cputime.utime; dst_bstat->cputime.stime += src_bstat->cputime.stime; dst_bstat->cputime.sum_exec_runtime += src_bstat->cputime.sum_exec_runtime; +#ifdef CONFIG_SCHED_CORE + dst_bstat->forceidle_sum += src_bstat->forceidle_sum; +#endif } static void cgroup_base_stat_sub(struct cgroup_base_stat *dst_bstat,
@@ -318,6 +321,9 @@ static void cgroup_base_stat_sub(struct cgroup_base_stat *dst_bstat, dst_bstat->cputime.utime -= src_bstat->cputime.utime; dst_bstat->cputime.stime -= src_bstat->cputime.stime; dst_bstat->cputime.sum_exec_runtime -= src_bstat->cputime.sum_exec_runtime; +#ifdef CONFIG_SCHED_CORE + dst_bstat->forceidle_sum -= src_bstat->forceidle_sum; +#endif }static void cgroup_base_stat_flush (struct cgroup *cgrp,int cpu)
@@ -398,6 +404,11 @@ void __cgroup_account_cputime_field(struct cgroup *cgrp,case CPUTIME_SOFTIRQ : rstatc->bstat.cputime.stime += delta_exec;break ; +#ifdef CONFIG_SCHED_CORE +case CPUTIME_FORCEIDLE : + rstatc->bstat.forceidle_sum += delta_exec; +break ; +#endif default :break ; }
@@ -411,8 +422,9 @@ void __cgroup_account_cputime_field(struct cgroup *cgrp,* with how it is done by __cgroup_account_cputime_field for each bit of * cpu time attributed to a cgroup. */ -static void root_cgroup_cputime (struct task_cputime *cputime) +static void root_cgroup_cputime (struct cgroup_base_stat *bstat) { +struct task_cputime *cputime = &bstat->cputime;int i; cputime->stime =0 ;
@@ -438,6 +450,10 @@ static void root_cgroup_cputime(struct task_cputime *cputime) cputime->sum_exec_runtime += user; cputime->sum_exec_runtime += sys; cputime->sum_exec_runtime += cpustat[CPUTIME_STEAL ]; + +#ifdef CONFIG_SCHED_CORE + bstat->forceidle_sum += cpustat[CPUTIME_FORCEIDLE ]; +#endif } }
@@ -445,27 +461,39 @@ void cgroup_base_stat_cputime_show(struct seq_file *seq) {struct cgroup *cgrp =seq_css (seq)->cgroup;u64 usage, utime, stime; -struct task_cputime cputime; +struct cgroup_base_stat bstat; +u64 __maybe_unused forceidle_time;if (cgroup_parent (cgrp)) {cgroup_rstat_flush_hold (cgrp); usage = cgrp->bstat.cputime.sum_exec_runtime;cputime_adjust (&cgrp->bstat.cputime, &cgrp->prev_cputime, &utime, &stime); +#ifdef CONFIG_SCHED_CORE + forceidle_time = cgrp->bstat.forceidle_sum; +#endif cgroup_rstat_flush_release (); }else { -root_cgroup_cputime (&cputime); - usage = cputime.sum_exec_runtime; - utime = cputime.utime; - stime = cputime.stime; +root_cgroup_cputime (&bstat); + usage = bstat.cputime.sum_exec_runtime; + utime = bstat.cputime.utime; + stime = bstat.cputime.stime; +#ifdef CONFIG_SCHED_CORE + forceidle_time = bstat.forceidle_sum; +#endif }do_div (usage,NSEC_PER_USEC );do_div (utime,NSEC_PER_USEC );do_div (stime,NSEC_PER_USEC ); +do_div (forceidle_time,NSEC_PER_USEC );seq_printf (seq,"usage_usec %llu\n" "user_usec %llu\n" "system_usec %llu\n" , usage, utime, stime); + +#ifdef CONFIG_SCHED_CORE +seq_printf (seq,"forceidle_usec %llu\n" , forceidle_time); +#endif }
kernel/sched/core_sched.c +5 -1
@@ -277,7 +277,11 @@ void __sched_core_account_forceidle(struct rq *rq)if (p == rq_i->idle)continue ; -__schedstat_add (p->stats.core_forceidle_sum, delta); +/* +* Note: this will account forceidle to the current cpu, even +* if it comes from our SMT sibling. +*/ +account_forceidle_time (p, delta); } }
kernel/sched/cputime.c +11 -0
@@ -226,6 +226,17 @@ void account_idle_time(u64 cputime) cpustat[CPUTIME_IDLE ] += cputime; } + +#ifdef CONFIG_SCHED_CORE +/* Account for forceidle time due to core scheduling. */ +void account_forceidle_time (struct task_struct *p,u64 delta) +{ +schedstat_add (p->stats.core_forceidle_sum, delta); + +task_group_account_field (p,CPUTIME_FORCEIDLE , delta); +} +#endif +/* * When a guest is interrupted for a longer amount of time, missed clock * ticks are not redelivered later. Due to that, this function may on
Signature · 1 line
2.36.1.124.g0e6072fb45-goog
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Josh,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tj-cgroup/for-next]
[also build test WARNING on tip/sched/core tip/master v5.18-rc7 next-20220520] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Josh-Don/sched-core-add-forced-idle-accounting-for-cgroups/20220521-075311 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20220521/[email protected]/config) compiler: m68k-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/0575a42c9f10cda618b09b949cc42fe97abea479
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Josh-Don/sched-core-add-forced-idle-accounting-for-cgroups/20220521-075311 git checkout 0575a42c9f10cda618b09b949cc42fe97abea479
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash kernel/
If you fix the issue, kindly add following tag where applicable
All warnings (new ones prefixed by >>):
In file included from include/linux/math.h:6,
from include/linux/math64.h:6,
from include/linux/time64.h:5,
from include/linux/restart_block.h:10,
from include/linux/thread_info.h:14,
from include/asm-generic/preempt.h:5,
from ./arch/m68k/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from arch/m68k/include/asm/irqflags.h:6,
from include/linux/irqflags.h:16,
from arch/m68k/include/asm/atomic.h:6,
from include/linux/atomic.h:7,
from include/linux/rcupdate.h:25,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/cgroup.h:12,
from kernel/cgroup/cgroup-internal.h:5,
from kernel/cgroup/rstat.c:2:
kernel/cgroup/rstat.c: In function 'cgroup_base_stat_cputime_show':
>> arch/m68k/include/asm/div64.h:21:17: warning: 'forceidle_time' is used uninitialized [-Wuninitialized]
21 | __n.n64 = (n); \
| ^
kernel/cgroup/rstat.c:465:28: note: 'forceidle_time' was declared here
465 | u64 __maybe_unused forceidle_time;
| ^~~~~~~~~~~~~~vim +/forceidle_time +21 arch/m68k/include/asm/div64.h
d20f5aa338dc75 Greg Ungerer 2009-02-06 12
d20f5aa338dc75 Greg Ungerer 2009-02-06 13 #define do_div(n, base) ({ \
d20f5aa338dc75 Greg Ungerer 2009-02-06 14 union { \
d20f5aa338dc75 Greg Ungerer 2009-02-06 15 unsigned long n32[2]; \
d20f5aa338dc75 Greg Ungerer 2009-02-06 16 unsigned long long n64; \
d20f5aa338dc75 Greg Ungerer 2009-02-06 17 } __n; \
d20f5aa338dc75 Greg Ungerer 2009-02-06 18 unsigned long __rem, __upper; \
ea077b1b96e073 Andreas Schwab 2013-08-09 19 unsigned long __base = (base); \
d20f5aa338dc75 Greg Ungerer 2009-02-06 20 \
d20f5aa338dc75 Greg Ungerer 2009-02-06 @21 __n.n64 = (n); \
d20f5aa338dc75 Greg Ungerer 2009-02-06 22 if ((__upper = __n.n32[0])) { \
d20f5aa338dc75 Greg Ungerer 2009-02-06 23 asm ("divul.l %2,%1:%0" \
d20f5aa338dc75 Greg Ungerer 2009-02-06 24 : "=d" (__n.n32[0]), "=d" (__upper) \
ea077b1b96e073 Andreas Schwab 2013-08-09 25 : "d" (__base), "0" (__n.n32[0])); \
d20f5aa338dc75 Greg Ungerer 2009-02-06 26 } \
d20f5aa338dc75 Greg Ungerer 2009-02-06 27 asm ("divu.l %2,%1:%0" \
d20f5aa338dc75 Greg Ungerer 2009-02-06 28 : "=d" (__n.n32[1]), "=d" (__rem) \
ea077b1b96e073 Andreas Schwab 2013-08-09 29 : "d" (__base), "1" (__upper), "0" (__n.n32[1])); \
d20f5aa338dc75 Greg Ungerer 2009-02-06 30 (n) = __n.n64; \
d20f5aa338dc75 Greg Ungerer 2009-02-06 31 __rem; \
d20f5aa338dc75 Greg Ungerer 2009-02-06 32 })d20f5aa338dc75 Greg Ungerer 2009-02-06 33
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Josh,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tj-cgroup/for-next]
[also build test WARNING on tip/sched/core tip/master v5.18-rc7 next-20220520] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Josh-Don/sched-core-add-forced-idle-accounting-for-cgroups/20220521-075311 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next config: hexagon-randconfig-r033-20220519 (https://download.01.org/0day-ci/archive/20220521/[email protected]/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project b369762beb70dfef22c7e793aed79b94d7dc0757)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/0575a42c9f10cda618b09b949cc42fe97abea479
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Josh-Don/sched-core-add-forced-idle-accounting-for-cgroups/20220521-075311 git checkout 0575a42c9f10cda618b09b949cc42fe97abea479
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash kernel/cgroup/
If you fix the issue, kindly add following tag where applicable
All warnings (new ones prefixed by >>):
>> kernel/cgroup/rstat.c:489:9: warning: variable 'forceidle_time' is uninitialized when used here [-Wuninitialized]
do_div(forceidle_time, NSEC_PER_USEC);
^~~~~~~~~~~~~~
include/asm-generic/div64.h:225:12: note: expanded from macro 'do_div'
__rem = (n) & (__base - 1); \
^
kernel/cgroup/rstat.c:465:35: note: initialize the variable 'forceidle_time' to silence this warning
u64 __maybe_unused forceidle_time;
^
= 01 warning generated.
vim +/forceidle_time +489 kernel/cgroup/rstat.c
459
460 void cgroup_base_stat_cputime_show(struct seq_file *seq)
461 {
462 struct cgroup *cgrp = seq_css(seq)->cgroup;
463 u64 usage, utime, stime;
464 struct cgroup_base_stat bstat;
465 u64 __maybe_unused forceidle_time;
466
467 if (cgroup_parent(cgrp)) {
468 cgroup_rstat_flush_hold(cgrp);
469 usage = cgrp->bstat.cputime.sum_exec_runtime;
470 cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime,
471 &utime, &stime);
472 #ifdef CONFIG_SCHED_CORE
473 forceidle_time = cgrp->bstat.forceidle_sum;
474 #endif
475 cgroup_rstat_flush_release();
476 } else {
477 root_cgroup_cputime(&bstat);
478 usage = bstat.cputime.sum_exec_runtime;
479 utime = bstat.cputime.utime;
480 stime = bstat.cputime.stime;
481 #ifdef CONFIG_SCHED_CORE
482 forceidle_time = bstat.forceidle_sum;
483 #endif
484 }
485
486 do_div(usage, NSEC_PER_USEC);
487 do_div(utime, NSEC_PER_USEC);
488 do_div(stime, NSEC_PER_USEC);
> 489 do_div(forceidle_time, NSEC_PER_USEC); 490 491 seq_printf(seq, "usage_usec %llu\n" 492 "user_usec %llu\n" 493 "system_usec %llu\n", 494 usage, utime, stime);
495
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Josh,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tj-cgroup/for-next]
[also build test WARNING on tip/sched/core tip/master v5.18-rc7 next-20220520] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Josh-Don/sched-core-add-forced-idle-accounting-for-cgroups/20220521-075311 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next config: um-i386_defconfig (https://download.01.org/0day-ci/archive/20220521/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-1) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/0575a42c9f10cda618b09b949cc42fe97abea479 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Josh-Don/sched-core-add-forced-idle-accounting-for-cgroups/20220521-075311 git checkout 0575a42c9f10cda618b09b949cc42fe97abea479 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=um SUBARCH=i386 SHELL=/bin/bash kernel/cgroup/
If you fix the issue, kindly add following tag where applicable
All warnings (new ones prefixed by >>):
In file included from include/linux/math.h:6,
from include/linux/math64.h:6,
from include/linux/time64.h:5,
from include/linux/restart_block.h:10,
from include/linux/thread_info.h:14,
from include/asm-generic/current.h:5,
from ./arch/um/include/generated/asm/current.h:1,
from include/linux/sched.h:12,
from include/linux/cgroup.h:12,
from kernel/cgroup/cgroup-internal.h:5,
from kernel/cgroup/rstat.c:2:
kernel/cgroup/rstat.c: In function 'cgroup_base_stat_cputime_show':
>> arch/x86/include/asm/div64.h:30:17: warning: 'forceidle_time' is used uninitialized [-Wuninitialized]
30 | asm("" : "=a" (__low), "=d" (__high) : "A" (n));\
| ^~~
kernel/cgroup/rstat.c:465:28: note: 'forceidle_time' was declared here
465 | u64 __maybe_unused forceidle_time;
| ^~~~~~~~~~~~~~vim +/forceidle_time +30 arch/x86/include/asm/div64.h
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 9
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 10 /*
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 11 * do_div() is NOT a C function. It wants to return
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 12 * two values (the quotient and the remainder), but
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 13 * since that doesn't work very well in C, what it
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 14 * does is:
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 15 *
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 16 * - modifies the 64-bit dividend _in_place_
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 17 * - returns the 32-bit remainder
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 18 *
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 19 * This ends up being the most efficient "calling
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 20 * convention" on x86.
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 21 */
925a09b27fc735 include/asm-x86/div64.h Joe Perches 2008-03-23 22 #define do_div(n, base) \
925a09b27fc735 include/asm-x86/div64.h Joe Perches 2008-03-23 23 ({ \
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 24 unsigned long __upper, __low, __high, __mod, __base; \
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 25 __base = (base); \
668b4484660618 arch/x86/include/asm/div64.h Sebastian Andrzej Siewior 2011-11-30 26 if (__builtin_constant_p(__base) && is_power_of_2(__base)) { \
668b4484660618 arch/x86/include/asm/div64.h Sebastian Andrzej Siewior 2011-11-30 27 __mod = n & (__base - 1); \
668b4484660618 arch/x86/include/asm/div64.h Sebastian Andrzej Siewior 2011-11-30 28 n >>= ilog2(__base); \
668b4484660618 arch/x86/include/asm/div64.h Sebastian Andrzej Siewior 2011-11-30 29 } else { \
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 @30 asm("" : "=a" (__low), "=d" (__high) : "A" (n));\
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 31 __upper = __high; \
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 32 if (__high) { \
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 33 __upper = __high % (__base); \
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 34 __high = __high / (__base); \
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 35 } \
925a09b27fc735 include/asm-x86/div64.h Joe Perches 2008-03-23 36 asm("divl %2" : "=a" (__low), "=d" (__mod) \
925a09b27fc735 include/asm-x86/div64.h Joe Perches 2008-03-23 37 : "rm" (__base), "0" (__low), "1" (__upper)); \
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 38 asm("" : "=A" (n) : "a" (__low), "d" (__high)); \
668b4484660618 arch/x86/include/asm/div64.h Sebastian Andrzej Siewior 2011-11-30 39 } \
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 40 __mod; \
428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 41 })428c5a2339f6d5 include/asm-x86/div64.h Chris Snook 2007-10-20 42
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
Dan Carpenter
build botCC: kbuild-all(a)lists.01.org BCC: lkp(a)intel.com In-Reply-To: <[email protected]> References: <[email protected]> TO: Josh Don…
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Josh Don <[email protected]>
TO: Ingo Molnar <[email protected]>
TO: Peter Zijlstra <[email protected]>
TO: Juri Lelli <[email protected]>
TO: Vincent Guittot <[email protected]>
TO: Tejun Heo <[email protected]>
CC: Dietmar Eggemann <[email protected]>
CC: Steven Rostedt <[email protected]>
CC: Ben Segall <[email protected]>
CC: Mel Gorman <[email protected]>
CC: Daniel Bristot de Oliveira <[email protected]>
CC: Valentin Schneider <[email protected]>
CC: linux-kernel(a)vger.kernel.org
CC: Cruz Zhao <[email protected]>
CC: Josh Don <[email protected]>
Hi Josh,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tj-cgroup/for-next]
[also build test WARNING on tip/sched/core tip/master v5.18-rc7 next-20220520] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Josh-Don/sched-core-add-forced-idle-accounting-for-cgroups/20220521-075311 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next
:::::: branch date: 8 hours ago
:::::: commit date: 8 hours ago
config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive/20220521/202205211525.XlF6P8dM-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.3.0-1) 11.3.0
If you fix the issue, kindly add following tag where applicable
smatch warnings:kernel/cgroup/rstat.c:489 cgroup_base_stat_cputime_show() error: uninitialized symbol 'forceidle_time'.
vim +/forceidle_time +489 kernel/cgroup/rstat.c
936f2a70f2077f kernel/cgroup/rstat.c Boris Burkov 2020-05-27 459
d4ff749b5e0f1e kernel/cgroup/rstat.c Tejun Heo 2018-04-26 460 void cgroup_base_stat_cputime_show(struct seq_file *seq)
041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 461 {
041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 462 struct cgroup *cgrp = seq_css(seq)->cgroup;
041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 463 u64 usage, utime, stime;
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 464 struct cgroup_base_stat bstat;
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 465 u64 __maybe_unused forceidle_time;
041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 466
936f2a70f2077f kernel/cgroup/rstat.c Boris Burkov 2020-05-27 467 if (cgroup_parent(cgrp)) {
6162cef0f741c7 kernel/cgroup/rstat.c Tejun Heo 2018-04-26 468 cgroup_rstat_flush_hold(cgrp);
d4ff749b5e0f1e kernel/cgroup/rstat.c Tejun Heo 2018-04-26 469 usage = cgrp->bstat.cputime.sum_exec_runtime;
936f2a70f2077f kernel/cgroup/rstat.c Boris Burkov 2020-05-27 470 cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime,
936f2a70f2077f kernel/cgroup/rstat.c Boris Burkov 2020-05-27 471 &utime, &stime);
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 472 #ifdef CONFIG_SCHED_CORE
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 473 forceidle_time = cgrp->bstat.forceidle_sum;
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 474 #endif
6162cef0f741c7 kernel/cgroup/rstat.c Tejun Heo 2018-04-26 475 cgroup_rstat_flush_release();
936f2a70f2077f kernel/cgroup/rstat.c Boris Burkov 2020-05-27 476 } else {
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 477 root_cgroup_cputime(&bstat);
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 478 usage = bstat.cputime.sum_exec_runtime;
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 479 utime = bstat.cputime.utime;
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 480 stime = bstat.cputime.stime;
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 481 #ifdef CONFIG_SCHED_CORE
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 482 forceidle_time = bstat.forceidle_sum;
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 483 #endif
936f2a70f2077f kernel/cgroup/rstat.c Boris Burkov 2020-05-27 484 }
041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 485
041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 486 do_div(usage, NSEC_PER_USEC);
041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 487 do_div(utime, NSEC_PER_USEC);
041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 488 do_div(stime, NSEC_PER_USEC);
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 @489 do_div(forceidle_time, NSEC_PER_USEC);
041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 490
d41bf8c9deaed1 kernel/cgroup/stat.c Tejun Heo 2017-10-23 491 seq_printf(seq, "usage_usec %llu\n"
d41bf8c9deaed1 kernel/cgroup/stat.c Tejun Heo 2017-10-23 492 "user_usec %llu\n"
d41bf8c9deaed1 kernel/cgroup/stat.c Tejun Heo 2017-10-23 493 "system_usec %llu\n",
d41bf8c9deaed1 kernel/cgroup/stat.c Tejun Heo 2017-10-23 494 usage, utime, stime);
0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 495 Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
Quoted 46 lines · Dan Carpenter
Hi Josh,
url: https://github.com/intel-lab-lkp/linux/commits/Josh-Don/sched-core-add-forced-idle-accounting-for-cgroups/20220521-075311 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive/20220521/202205211525.XlF6P8dM-lkp(a)intel.com/config) compiler: gcc-11 (Debian 11.3.0-1) 11.3.0If you fix the issue, kindly add following tag where applicable
Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>smatch warnings:
kernel/cgroup/rstat.c:489cgroup_base_stat_cputime_show()error: uninitialized symbol 'forceidle_time'.vim +/forceidle_time +489
kernel/cgroup/rstat.cd4ff749b5e0f1e kernel/cgroup/rstat.c Tejun Heo 2018-04-26 460 void cgroup_base_stat_cputime_show(struct seq_file *seq) 041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 461 { 041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 462 struct cgroup *cgrp = seq_css(seq)->cgroup; 041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 463 u64 usage, utime, stime; 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 464 struct cgroup_base_stat bstat; 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 465 u64 __maybe_unused forceidle_time; 041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 466 936f2a70f2077f kernel/cgroup/rstat.c Boris Burkov 2020-05-27 467 if (cgroup_parent(cgrp)) { 6162cef0f741c7 kernel/cgroup/rstat.c Tejun Heo 2018-04-26 468 cgroup_rstat_flush_hold(cgrp); d4ff749b5e0f1e kernel/cgroup/rstat.c Tejun Heo 2018-04-26 469 usage = cgrp->bstat.cputime.sum_exec_runtime; 936f2a70f2077f kernel/cgroup/rstat.c Boris Burkov 2020-05-27 470 cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime, 936f2a70f2077f kernel/cgroup/rstat.c Boris Burkov 2020-05-27 471 &utime, &stime); 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 472 #ifdef CONFIG_SCHED_CORE 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 473 forceidle_time = cgrp->bstat.forceidle_sum; 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 474 #endif 6162cef0f741c7 kernel/cgroup/rstat.c Tejun Heo 2018-04-26 475 cgroup_rstat_flush_release(); 936f2a70f2077f kernel/cgroup/rstat.c Boris Burkov 2020-05-27 476 } else { 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 477 root_cgroup_cputime(&bstat); 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 478 usage = bstat.cputime.sum_exec_runtime; 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 479 utime = bstat.cputime.utime; 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 480 stime = bstat.cputime.stime; 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 481 #ifdef CONFIG_SCHED_CORE 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 482 forceidle_time = bstat.forceidle_sum; 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 483 #endif 936f2a70f2077f kernel/cgroup/rstat.c Boris Burkov 2020-05-27 484 } 041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 485 041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 486 do_div(usage, NSEC_PER_USEC); 041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 487 do_div(utime, NSEC_PER_USEC); 041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 488 do_div(stime, NSEC_PER_USEC);
Quoted 3 lines
0575a42c9f10cdkernel/cgroup/rstat.cJosh Don 2022-05-20 @489do_div(forceidle_time, NSEC_PER_USEC);I think this will cause MEMSan warnings at run time.
Whoops, I missed wrapping this usage with an #ifdef CONFIG_SCHED_CORE.
Quoted 11 lines
041cd640b2f3c5 kernel/cgroup/stat.c Tejun Heo 2017-09-25 490 d41bf8c9deaed1 kernel/cgroup/stat.c Tejun Heo 2017-10-23 491 seq_printf(seq, "usage_usec %llu\n" d41bf8c9deaed1 kernel/cgroup/stat.c Tejun Heo 2017-10-23 492 "user_usec %llu\n" d41bf8c9deaed1 kernel/cgroup/stat.c Tejun Heo 2017-10-23 493 "system_usec %llu\n", d41bf8c9deaed1 kernel/cgroup/stat.c Tejun Heo 2017-10-23 494 usage, utime, stime); 0575a42c9f10cd kernel/cgroup/rstat.c Josh Don 2022-05-20 495--
0-DAY CI Kernel Test Service
https://01.org/lkp
Peter Zijlstra
maintainerQuoted 5 lines · Josh Don
kernel/sched/core_sched.c +0
-0
kernel/sched/core_sched.c void __sched_core_account_forceidle(struct rq *rq) · line 285
Quoted 10 lines
kernel/sched/core_sched.c +5
-1@@ -277,7 +277,11 @@ void __sched_core_account_forceidle(struct rq *rq)if (p == rq_i->idle)continue ; -__schedstat_add (p->stats.core_forceidle_sum, delta); +/* +* Note: this will account forceidle to the current cpu, even +* if it comes from our SMT sibling. +*/ +account_forceidle_time (p, delta); }
AFAICT this is the only caller of that function.
Quoted 7 lines
kernel/sched/core_sched.c +0
-0}kernel/sched/cputime.c +0
-0
kernel/sched/cputime.c void account_idle_time(u64 cputime) · line 234
Quoted 9 lines
kernel/sched/cputime.c +6
-0@@ -226,6 +226,17 @@ void account_idle_time(u64 cputime) cpustat[CPUTIME_IDLE ] += cputime; } + +#ifdef CONFIG_SCHED_CORE +/* Account for forceidle time due to core scheduling. */ +void account_forceidle_time (struct task_struct *p,u64 delta) +{ +schedstat_add (p->stats.core_forceidle_sum, delta);
But then you loose the __, why?
Quoted 4 lines
kernel/sched/cputime.c +4
-0+ + task_group_account_field(p, CPUTIME_FORCEIDLE, delta); +} +#endif
Quoted 31 lines · Peter Zijlstra
Quoted 5 lines · Josh Don
kernel/sched/core_sched.c +0
-0kernel/sched/core_sched.c void __sched_core_account_forceidle(struct rq *rq) · line 285
Quoted 10 lines
kernel/sched/core_sched.c +5
-1@@ -277,7 +277,11 @@ void __sched_core_account_forceidle(struct rq *rq)if (p == rq_i->idle)continue ; -__schedstat_add (p->stats.core_forceidle_sum, delta); +/* +* Note: this will account forceidle to the current cpu, even +* if it comes from our SMT sibling. +*/ +account_forceidle_time (p, delta); }AFAICT this is the only caller of that function.
Quoted 10 lines
kernel/sched/core_sched.c +0
-0}kernel/sched/cputime.c +0
-0@@ -226,6 +226,17 @@ void account_idle_time(u64 cputime) cpustat[CPUTIME_IDLE ] += cputime; }
Quoted 8 lines
kernel/sched/cputime.c void account_idle_time(u64 cputime) · line 234
Quoted 6 lines
kernel/sched/cputime.c +6
-0+ +#ifdef CONFIG_SCHED_CORE +/* Account for forceidle time due to core scheduling. */ +void account_forceidle_time (struct task_struct *p,u64 delta) +{ +schedstat_add (p->stats.core_forceidle_sum, delta);But then you loose the __, why?
Yea, this is probably better off as __ and a comment on the function stating that it requires schedstat is enabled. My original thinking was that it would be nice to avoid capturing this requirement here for future potential use cases, especially given that the schedstat_enabled() check is basically free anyway.
Quoted 4 lines
Quoted 4 lines
kernel/sched/cputime.c +4
-0+ + task_group_account_field(p, CPUTIME_FORCEIDLE, delta); +} +#endif