Re: [PATCH 2/4] sched: cpufreq: Keep track of cpufreq utilization update flags

From: Rafael J. Wysocki
Date: Sat Dec 16 2017 - 11:40:07 EST


On Wed, Dec 13, 2017 at 10:53 AM, Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:
> Currently the schedutil governor overwrites the sg_cpu->flags field on
> every call to the utilization handler. It was pretty good as the initial
> implementation of utilization handlers, there are several drawbacks
> though.
>
> The biggest drawback is that the sg_cpu->flags field doesn't always
> represent the correct type of tasks that are enqueued on a CPU's rq. For
> example, if a fair task is enqueued while a RT or DL task is running, we
> will overwrite the flags with value 0 and that may take the CPU to lower
> OPPs unintentionally. There can be other corner cases as well which we
> aren't aware of currently.
>
> This patch changes the current implementation to keep track of all the
> task types that are currently enqueued to the CPUs rq. A new flag: CLEAR
> is introduced and is set by the scheduling classes when their last task
> is dequeued. When the CLEAR flag bit is set, the schedutil governor resets
> all the other flag bits that are present in the flags parameter. For
> now, the util update handlers return immediately if they were called to
> clear the flag.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> ---
> include/linux/sched/cpufreq.h | 7 ++++++-
> kernel/sched/cpufreq_schedutil.c | 21 ++++++++++++++++++---
> kernel/sched/deadline.c | 4 ++++
> kernel/sched/fair.c | 8 ++++++--
> kernel/sched/rt.c | 4 ++++
> 5 files changed, 38 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/sched/cpufreq.h b/include/linux/sched/cpufreq.h
> index d1ad3d825561..6f6641e61236 100644
> --- a/include/linux/sched/cpufreq.h
> +++ b/include/linux/sched/cpufreq.h
> @@ -8,10 +8,15 @@
> * Interface between cpufreq drivers and the scheduler:
> */
>
> +#define SCHED_CPUFREQ_CLEAR (1U << 31)

I'm not thrilled by this, because schedutil is not the only user of
the flags and it's totally unclear what the other user(s) should do
when this is set.

Thanks,
Rafael