Re: [PATCH v2] sched/core: add forced idle accounting for cgroups

From: Peter Zijlstra
Date: Sat May 21 2022 - 06:01:16 EST


On Fri, May 20, 2022 at 04:51:38PM -0700, Josh Don wrote:

> diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c
> index 38a2cec21014..ddef2b8ddf68 100644
> --- a/kernel/sched/core_sched.c
> +++ b/kernel/sched/core_sched.c
> @@ -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.

> }
>
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index 78a233d43757..598d1026d629 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -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?

> +
> + task_group_account_field(p, CPUTIME_FORCEIDLE, delta);
> +}
> +#endif