From: Lukasz Luba <lukasz.luba@arm.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Morten Rasmussen <morten.rasmussen@arm.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Ricardo Neri <ricardo.neri-calderon@linux.intel.com>,
Pierre Gondois <pierre.gondois@arm.com>,
Christian Loehle <christian.loehle@arm.com>,
Viresh Kumar <viresh.kumar@linaro.org>
Subject: Re: [RFC][PATCH v0.3 5/6] PM: EM: Introduce em_adjust_cpu_capacity()
Date: Mon, 24 Mar 2025 16:25:49 +0000 [thread overview]
Message-ID: <9bb64bd4-8715-481b-9e08-73b715a78927@arm.com> (raw)
In-Reply-To: <2446858.NG923GbCHz@rjwysocki.net>
On 3/7/25 19:39, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Add a function for updating the Energy Model for a CPU after its
> capacity has changed, which subsequently will be used by the
> intel_pstate driver.
>
> An EM_PERF_DOMAIN_ARTIFICIAL check is added to em_adjust_new_capacity()
> to prevent it from calling em_compute_costs() for an "artificial" perf
> domain with a NULL cb parameter which would cause it to crash.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>
> Note that this function is needed because the performance level values
> in the EM "state" table need to be adjusted on CPU capacity changes. In
> the intel_pstate case the cost values associated with them don't change
> because they are artificial anyway, so replacing the entire table just
> in order to update the performance level values is a bit wasteful, but
> it seems to be an exception (in the other cases when the CPU capacity
> changes, the cost values change too AFAICS).
>
> ---
> include/linux/energy_model.h | 2 ++
> kernel/power/energy_model.c | 28 ++++++++++++++++++++++++----
> 2 files changed, 26 insertions(+), 4 deletions(-)
>
> --- a/include/linux/energy_model.h
> +++ b/include/linux/energy_model.h
> @@ -179,6 +179,7 @@
> int em_dev_update_chip_binning(struct device *dev);
> int em_update_performance_limits(struct em_perf_domain *pd,
> unsigned long freq_min_khz, unsigned long freq_max_khz);
> +void em_adjust_cpu_capacity(unsigned int cpu);
> void em_rebuild_sched_domains(void);
>
> /**
> @@ -405,6 +406,7 @@
> {
> return -EINVAL;
> }
> +void em_adjust_cpu_capacity(unsigned int cpu) {}
> static inline void em_rebuild_sched_domains(void) {}
> #endif
>
> --- a/kernel/power/energy_model.c
> +++ b/kernel/power/energy_model.c
> @@ -698,10 +698,12 @@
> {
> int ret;
>
> - ret = em_compute_costs(dev, em_table->state, NULL, pd->nr_perf_states,
> - pd->flags);
> - if (ret)
> - goto free_em_table;
> + if (!(pd->flags & EM_PERF_DOMAIN_ARTIFICIAL)) {
> + ret = em_compute_costs(dev, em_table->state, NULL,
> + pd->nr_perf_states, pd->flags);
> + if (ret)
> + goto free_em_table;
> + }
>
> ret = em_dev_update_perf_domain(dev, em_table);
> if (ret)
> @@ -751,6 +753,24 @@
> em_recalc_and_update(dev, pd, em_table);
> }
>
> +/**
> + * em_adjust_cpu_capacity() - Adjust the EM for a CPU after a capacity update.
> + * @cpu: Target CPU.
> + *
> + * Adjust the existing EM for @cpu after a capacity update under the assumption
> + * that the capacity has been updated in the same way for all of the CPUs in
> + * the same perf domain.
> + */
> +void em_adjust_cpu_capacity(unsigned int cpu)
> +{
> + struct device *dev = get_cpu_device(cpu);
> + struct em_perf_domain *pd;
> +
> + pd = em_pd_get(dev);
> + if (pd)
> + em_adjust_new_capacity(cpu, dev, pd);
> +}
> +
> static void em_check_capacity_update(void)
> {
> cpumask_var_t cpu_done_mask;
>
>
>
LGTM,
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
next prev parent reply other threads:[~2025-03-24 16:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 19:12 [RFC][PATCH v0.3 0/6] cpufreq: intel_pstate: Enable EAS on hybrid platforms without SMT - alternative Rafael J. Wysocki
2025-03-07 19:15 ` [RFC][PATCH v0.3 1/6] cpufreq/sched: schedutil: Add helper for governor checks Rafael J. Wysocki
2025-03-07 19:16 ` [RFC][PATCH v0.3 2/6] cpufreq/sched: Move cpufreq-specific EAS checks to cpufreq Rafael J. Wysocki
2025-03-07 19:16 ` [RFC][PATCH v0.3 3/6] cpufreq/sched: Allow .setpolicy() cpufreq drivers to enable EAS Rafael J. Wysocki
2025-03-07 19:17 ` [RFC][PATCH v0.3 4/6] PM: EM: Move CPU capacity check to em_adjust_new_capacity() Rafael J. Wysocki
2025-03-24 16:25 ` Lukasz Luba
2025-03-07 19:39 ` [RFC][PATCH v0.3 5/6] PM: EM: Introduce em_adjust_cpu_capacity() Rafael J. Wysocki
2025-03-24 16:25 ` Lukasz Luba [this message]
2025-03-07 19:42 ` [RFC][PATCH v0.3 6/6] cpufreq: intel_pstate: EAS support for hybrid platforms Rafael J. Wysocki
2025-03-13 18:46 ` Tim Chen
2025-03-13 18:50 ` Rafael J. Wysocki
2025-04-03 10:47 ` [RFC][PATCH v0.3 0/6] cpufreq: intel_pstate: Enable EAS on hybrid platforms without SMT - alternative Christian Loehle
2025-04-03 11:02 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9bb64bd4-8715-481b-9e08-73b715a78927@arm.com \
--to=lukasz.luba@arm.com \
--cc=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=morten.rasmussen@arm.com \
--cc=peterz@infradead.org \
--cc=pierre.gondois@arm.com \
--cc=ricardo.neri-calderon@linux.intel.com \
--cc=rjw@rjwysocki.net \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox