[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240520071155.lbphk4dqbhibogtj@vireshk-i7>
Date: Mon, 20 May 2024 12:41:55 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Fares Mehanna <faresx@...zon.de>
Cc: rkagan@...zon.de, "Rafael J. Wysocki" <rafael@...nel.org>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Valentin Schneider <vschneid@...hat.com>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cpufreq: fail to start a governor if limits weren't
updated correctly
On 30-04-24, 14:39, Fares Mehanna wrote:
> Current cpufreq governors are using `__cpufreq_driver_target()` in their
> `.limits()` functions to update the frequency. `__cpufreq_driver_target()`
> will eventually call `.target()` or `.target_index()` in the cpufreq driver
> to update the frequency.
>
> `.target()`, `.target_index()` and `__cpufreq_driver_target()` may fail and
> all do return an error code, this error code is dropped by the governor and
> not propagated to the core.
>
> This have the downside of accepting a new CPU governor even if it fails to
> set the wanted limits. This is misleading to the sysfs user, as setting the
> governor will be accepted but the governor itself is not functioning as
> expected. Especially with `performance` and `powersave` where they only
> target specific frequency during starting of the governor and stays the
> same during their lifetime.
>
> This change will cause a failure to start the new governor if `.limits()`
> failed, propagating back to userspace if the change is driven by sysfs.
>
> Signed-off-by: Fares Mehanna <faresx@...zon.de>
> ---
> drivers/cpufreq/cpufreq.c | 7 +++++--
> drivers/cpufreq/cpufreq_governor.c | 6 ++++--
> drivers/cpufreq/cpufreq_governor.h | 2 +-
> drivers/cpufreq/cpufreq_performance.c | 4 ++--
> drivers/cpufreq/cpufreq_powersave.c | 4 ++--
> drivers/cpufreq/cpufreq_userspace.c | 16 +++++++++-------
> include/linux/cpufreq.h | 13 +++++++------
> kernel/sched/cpufreq_schedutil.c | 6 ++++--
> 8 files changed, 34 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 66e10a19d76a..5ac44a44d319 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2474,8 +2474,11 @@ int cpufreq_start_governor(struct cpufreq_policy *policy)
> return ret;
> }
>
> - if (policy->governor->limits)
> - policy->governor->limits(policy);
> + if (policy->governor->limits) {
> + ret = policy->governor->limits(policy);
> + if (ret)
> + return ret;
You need to stop the governor here on failure as this function started it
successfully.
--
viresh
Powered by blists - more mailing lists