Commit b8247665 authored by Chen Ridong's avatar Chen Ridong Committed by Tejun Heo

cgroup/rstat: add force idle show helper

In the function cgroup_base_stat_cputime_show, there are five
instances of #ifdef, which makes the code not concise.
To address this, add the function cgroup_force_idle_show
to make the code more succinct.
Signed-off-by: default avatarChen Ridong <chenridong@huawei.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 1028f391
...@@ -594,49 +594,46 @@ static void root_cgroup_cputime(struct cgroup_base_stat *bstat) ...@@ -594,49 +594,46 @@ static void root_cgroup_cputime(struct cgroup_base_stat *bstat)
} }
} }
static void cgroup_force_idle_show(struct seq_file *seq, struct cgroup_base_stat *bstat)
{
#ifdef CONFIG_SCHED_CORE
u64 forceidle_time = bstat->forceidle_sum;
do_div(forceidle_time, NSEC_PER_USEC);
seq_printf(seq, "core_sched.force_idle_usec %llu\n", forceidle_time);
#endif
}
void cgroup_base_stat_cputime_show(struct seq_file *seq) void cgroup_base_stat_cputime_show(struct seq_file *seq)
{ {
struct cgroup *cgrp = seq_css(seq)->cgroup; struct cgroup *cgrp = seq_css(seq)->cgroup;
u64 usage, utime, stime; u64 usage, utime, stime;
struct cgroup_base_stat bstat;
#ifdef CONFIG_SCHED_CORE
u64 forceidle_time;
#endif
if (cgroup_parent(cgrp)) { if (cgroup_parent(cgrp)) {
cgroup_rstat_flush_hold(cgrp); cgroup_rstat_flush_hold(cgrp);
usage = cgrp->bstat.cputime.sum_exec_runtime; usage = cgrp->bstat.cputime.sum_exec_runtime;
cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime, cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime,
&utime, &stime); &utime, &stime);
#ifdef CONFIG_SCHED_CORE
forceidle_time = cgrp->bstat.forceidle_sum;
#endif
cgroup_rstat_flush_release(cgrp); cgroup_rstat_flush_release(cgrp);
} else { } else {
root_cgroup_cputime(&bstat); /* cgrp->bstat of root is not actually used, reuse it */
usage = bstat.cputime.sum_exec_runtime; root_cgroup_cputime(&cgrp->bstat);
utime = bstat.cputime.utime; usage = cgrp->bstat.cputime.sum_exec_runtime;
stime = bstat.cputime.stime; utime = cgrp->bstat.cputime.utime;
#ifdef CONFIG_SCHED_CORE stime = cgrp->bstat.cputime.stime;
forceidle_time = bstat.forceidle_sum;
#endif
} }
do_div(usage, NSEC_PER_USEC); do_div(usage, NSEC_PER_USEC);
do_div(utime, NSEC_PER_USEC); do_div(utime, NSEC_PER_USEC);
do_div(stime, NSEC_PER_USEC); do_div(stime, NSEC_PER_USEC);
#ifdef CONFIG_SCHED_CORE
do_div(forceidle_time, NSEC_PER_USEC);
#endif
seq_printf(seq, "usage_usec %llu\n" seq_printf(seq, "usage_usec %llu\n"
"user_usec %llu\n" "user_usec %llu\n"
"system_usec %llu\n", "system_usec %llu\n",
usage, utime, stime); usage, utime, stime);
#ifdef CONFIG_SCHED_CORE cgroup_force_idle_show(seq, &cgrp->bstat);
seq_printf(seq, "core_sched.force_idle_usec %llu\n", forceidle_time);
#endif
} }
/* Add bpf kfuncs for cgroup_rstat_updated() and cgroup_rstat_flush() */ /* Add bpf kfuncs for cgroup_rstat_updated() and cgroup_rstat_flush() */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment