mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dietmar Eggemann <dietmar.eggemann@arm.com>
To: Lukasz Luba <lukasz.luba@arm.com>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	rafael@kernel.org
Cc: rui.zhang@intel.com, amit.kucheria@verdurent.com,
	amit.kachhap@gmail.com, daniel.lezcano@linaro.org,
	viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz,
	Pierre.Gondois@arm.com, ionela.voinescu@arm.com,
	rostedt@goodmis.org, mhiramat@kernel.org
Subject: Re: [PATCH v2 03/17] PM: EM: Refactor em_pd_get_efficient_state() to be more flexible
Date: Tue, 30 May 2023 13:06:14 +0200	[thread overview]
Message-ID: <418bef75-883c-2442-3376-03fd7537c734@arm.com> (raw)
In-Reply-To: <20230512095743.3393563-4-lukasz.luba@arm.com>

On 12/05/2023 11:57, Lukasz Luba wrote:
> Prepare em_pd_get_efficient_state() for the upcoming changes and
> make it possible to re-use. Return an index for the best performance

Don't get the `possible to re-use`? Did you mean `possible to be
re-used`? But then `re-used` for what?

> state. The function arguments that are introduced should allow to
> work on different performance state arrays. The caller of
> em_pd_get_efficient_state() should be able to use the index either
> on the default or the modifiable EM table.

This describes the WHAT but not the WHY.

> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> ---
>  include/linux/energy_model.h | 30 +++++++++++++++++-------------
>  1 file changed, 17 insertions(+), 13 deletions(-)
> 
> diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
> index b9caa01dfac4..8069f526c9d8 100644
> --- a/include/linux/energy_model.h
> +++ b/include/linux/energy_model.h
> @@ -175,33 +175,35 @@ void em_dev_unregister_perf_domain(struct device *dev);
>  
>  /**
>   * em_pd_get_efficient_state() - Get an efficient performance state from the EM
> - * @pd   : Performance domain for which we want an efficient frequency
> - * @freq : Frequency to map with the EM
> + * @state:		List of performance states, in ascending order
> + * @nr_perf_states:	Number of performance states
> + * @freq:		Frequency to map with the EM
> + * @pd_flags:		Performance Domain flags
>   *
>   * It is called from the scheduler code quite frequently and as a consequence
>   * doesn't implement any check.
>   *
> - * Return: An efficient performance state, high enough to meet @freq
> + * Return: An efficient performance state id, high enough to meet @freq
>   * requirement.
>   */
> -static inline
> -struct em_perf_state *em_pd_get_efficient_state(struct em_perf_domain *pd,
> -						unsigned long freq)
> +static inline int
> +em_pd_get_efficient_state(struct em_perf_state *table, int nr_perf_states,
> +			  unsigned long freq, unsigned long pd_flags)
>  {
>  	struct em_perf_state *ps;
>  	int i;
>  
> -	for (i = 0; i < pd->nr_perf_states; i++) {
> -		ps = &pd->table[i];
> +	for (i = 0; i < nr_perf_states; i++) {
> +		ps = &table[i];
>  		if (ps->frequency >= freq) {
> -			if (pd->flags & EM_PERF_DOMAIN_SKIP_INEFFICIENCIES &&
> +			if (pd_flags & EM_PERF_DOMAIN_SKIP_INEFFICIENCIES &&
>  			    ps->flags & EM_PERF_STATE_INEFFICIENT)
>  				continue;
> -			break;
> +			return i;
>  		}
>  	}
>  
> -	return ps;
> +	return nr_perf_states - 1;
>  }
>  
>  /**
> @@ -226,7 +228,7 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd,
>  {
>  	unsigned long freq, scale_cpu;
>  	struct em_perf_state *ps;
> -	int cpu;
> +	int cpu, i;
>  
>  	if (!sum_util)
>  		return 0;
> @@ -251,7 +253,9 @@ static inline unsigned long em_cpu_energy(struct em_perf_domain *pd,
>  	 * Find the lowest performance state of the Energy Model above the
>  	 * requested frequency.
>  	 */
> -	ps = em_pd_get_efficient_state(pd, freq);
> +	i = em_pd_get_efficient_state(pd->table, pd->nr_perf_states, freq,
> +				      pd->flags);
> +	ps = &pd->table[i];
>  
>  	/*
>  	 * The capacity of a CPU in the domain at the performance state (ps)


  reply	other threads:[~2023-05-30 11:06 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12  9:57 [PATCH v2 00/17] Introduce runtime modifiable Energy Model Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 01/17] PM: EM: Refactor em_cpufreq_update_efficiencies() arguments Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 02/17] PM: EM: Find first CPU online while updating OPP efficiency Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 03/17] PM: EM: Refactor em_pd_get_efficient_state() to be more flexible Lukasz Luba
2023-05-30 11:06   ` Dietmar Eggemann [this message]
2023-07-03 16:22     ` Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 04/17] PM: EM: Create a new function em_compute_costs() Lukasz Luba
2023-05-30  9:51   ` Dietmar Eggemann
2023-07-03 15:09     ` Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 05/17] trace: energy_model: Add trace event for EM runtime modifications Lukasz Luba
2023-05-30 10:03   ` Dietmar Eggemann
2023-07-03 15:53     ` Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 06/17] PM: EM: Add update_power() callback for " Lukasz Luba
2023-05-30  9:31   ` Dietmar Eggemann
2023-07-03 15:06     ` Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 07/17] PM: EM: Check if the get_cost() callback is present in em_compute_costs() Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 08/17] PM: EM: Introduce runtime modifiable table Lukasz Luba
2023-05-14  4:28   ` kernel test robot
2023-05-30 10:18   ` Dietmar Eggemann
2023-07-03 15:58     ` Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 09/17] PM: EM: Add RCU mechanism which safely cleans the old data Lukasz Luba
2023-05-30 10:02   ` Dietmar Eggemann
2023-07-03 15:49     ` Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 10/17] PM: EM: Add runtime update interface to modify EM power Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 11/17] PM: EM: Use runtime modified EM for CPUs energy estimation in EAS Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 12/17] PM: EM: Add argument to get_cost() for runtime modification Lukasz Luba
2023-05-30  9:53   ` Dietmar Eggemann
2023-07-03 15:30     ` Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 13/17] PM: EM: Refactor struct em_perf_domain and add default_table Lukasz Luba
2023-05-30 10:23   ` Dietmar Eggemann
2023-07-03 16:00     ` Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 14/17] Documentation: EM: Add a new section about the design Lukasz Luba
2023-05-30 10:33   ` Dietmar Eggemann
2023-07-03 16:09     ` Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 15/17] Documentation: EM: Add a runtime modifiable EM design description Lukasz Luba
2023-05-30 10:42   ` Dietmar Eggemann
2023-07-03 16:13     ` Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 16/17] Documentation: EM: Add example with driver modifying the EM Lukasz Luba
2023-05-12  9:57 ` [PATCH v2 17/17] Documentation: EM: Describe the API of runtime modifications Lukasz Luba
2023-05-24 17:25 ` [PATCH v2 00/17] Introduce runtime modifiable Energy Model Rafael J. Wysocki
2023-07-03 11:08   ` Lukasz Luba
2023-05-30 11:07 ` Dietmar Eggemann
2023-07-03 16:35   ` Lukasz Luba

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=418bef75-883c-2442-3376-03fd7537c734@arm.com \
    --to=dietmar.eggemann@arm.com \
    --cc=Pierre.Gondois@arm.com \
    --cc=amit.kachhap@gmail.com \
    --cc=amit.kucheria@verdurent.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=ionela.voinescu@arm.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=mhiramat@kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=rui.zhang@intel.com \
    --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

all inboxes | Powered by JetHome®