All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Documentation: power: Add description about new callback for EM registration
@ 2021-11-02 18:01 Lukasz Luba
  2021-11-02 18:01 ` [PATCH 2/2] Documentation: power: Describe 'advanced' and 'simple' EM models Lukasz Luba
  2021-11-09 10:38 ` [PATCH 1/2] Documentation: power: Add description about new callback for EM registration Lukasz Luba
  0 siblings, 2 replies; 5+ messages in thread
From: Lukasz Luba @ 2021-11-02 18:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: lukasz.luba, dietmar.eggemann, rafael, linux-pm

The Energy Model (EM) registration for CPUs should now be done using
a dedicated callback added recently into CPUFreq framework and drivers.

Commit c17495b01b72 ("cpufreq: Add callback to register with energy model")

The callback guaranties that the EM registration is called at the right
time during driver setup. To avoid mistakes update the documentation
to align with the existing code implementation.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 Documentation/power/energy-model.rst | 31 ++++++++++++++--------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/Documentation/power/energy-model.rst b/Documentation/power/energy-model.rst
index 8a2788afe89b..7af0e1760962 100644
--- a/Documentation/power/energy-model.rst
+++ b/Documentation/power/energy-model.rst
@@ -138,6 +138,10 @@ or in Section 2.4
 3. Example driver
 -----------------
 
+The CPUFreq framework supports dedicated callback for registering
+the EM for a given CPU(s) 'policy' object: cpufreq_driver::register_em().
+That callback has to be implemented properly for a given driver,
+because the framework would call it at the right time during setup.
 This section provides a simple example of a CPUFreq driver registering a
 performance domain in the Energy Model framework using the (fake) 'foo'
 protocol. The driver implements an est_power() function to be provided to the
@@ -167,25 +171,22 @@ EM framework::
   20		return 0;
   21	}
   22
-  23	static int foo_cpufreq_init(struct cpufreq_policy *policy)
+  23	static void foo_cpufreq_register_em(struct cpufreq_policy *policy)
   24	{
   25		struct em_data_callback em_cb = EM_DATA_CB(est_power);
   26		struct device *cpu_dev;
-  27		int nr_opp, ret;
+  27		int nr_opp;
   28
   29		cpu_dev = get_cpu_device(cpumask_first(policy->cpus));
   30
-  31     	/* Do the actual CPUFreq init work ... */
-  32     	ret = do_foo_cpufreq_init(policy);
-  33     	if (ret)
-  34     		return ret;
-  35
-  36     	/* Find the number of OPPs for this policy */
-  37     	nr_opp = foo_get_nr_opp(policy);
+  31     	/* Find the number of OPPs for this policy */
+  32     	nr_opp = foo_get_nr_opp(policy);
+  33
+  34     	/* And register the new performance domain */
+  35     	em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, policy->cpus,
+  36					    true);
+  37	}
   38
-  39     	/* And register the new performance domain */
-  40     	em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, policy->cpus,
-  41					    true);
-  42
-  43	        return 0;
-  44	}
+  39	static struct cpufreq_driver foo_cpufreq_driver = {
+  40		.register_em = foo_cpufreq_register_em,
+  41	};
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Documentation: power: Describe 'advanced' and 'simple' EM models
  2021-11-02 18:01 [PATCH 1/2] Documentation: power: Add description about new callback for EM registration Lukasz Luba
@ 2021-11-02 18:01 ` Lukasz Luba
  2021-11-09 10:38 ` [PATCH 1/2] Documentation: power: Add description about new callback for EM registration Lukasz Luba
  1 sibling, 0 replies; 5+ messages in thread
From: Lukasz Luba @ 2021-11-02 18:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: lukasz.luba, dietmar.eggemann, rafael, linux-pm

The Energy Model (EM) can be registered in two ways:
1) Using a helper function, which under the hood relies on OPP framework
   and DT entry in CPU node: 'dynamic-power-coefficient'. This is
   a 'simple' EM because it's tight to the math formula:
   Power = dynamic-power-coefficient * V^2 * f
2) Using em_dev_register_perf_domain() API function with a driver
   custom callback which provides power for each performance state.
   This is an 'advanced' EM, since it can better reflect real power
   measurements for each performance state. It's not limited to any math
   formula and can better reflect real physics of the device.

Add description of these two methods to the documentation, so developers
could choose the suitable registration method (option).

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 Documentation/power/energy-model.rst | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/Documentation/power/energy-model.rst b/Documentation/power/energy-model.rst
index 7af0e1760962..5ac62a7b4b7c 100644
--- a/Documentation/power/energy-model.rst
+++ b/Documentation/power/energy-model.rst
@@ -84,6 +84,16 @@ CONFIG_ENERGY_MODEL must be enabled to use the EM framework.
 2.2 Registration of performance domains
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+Registration of 'advanced' EM
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The 'advanced' EM gets it's name due to the fact that the driver is allowed
+to provide more precised power model. It's not limited to some implemented math
+formula in the framework (like it's in 'simple' EM case). It can better reflect
+the real power measurements performed for each performance state. Thus, this
+registration method should be preferred in case considering EM static power
+(leakage) is important.
+
 Drivers are expected to register performance domains into the EM framework by
 calling the following API::
 
@@ -103,6 +113,18 @@ to: return warning/error, stop working or panic.
 See Section 3. for an example of driver implementing this
 callback, or Section 2.4 for further documentation on this API
 
+Registration of 'simple' EM
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The 'simple' EM is registered using the framework helper function
+cpufreq_register_em_with_opp(). It implements a power model which is tight to
+math formula::
+
+	Power = C * V^2 * f
+
+The EM which is registered using this method might not reflect correctly the
+physics of a real device, e.g. when static power (leakage) is important.
+
 
 2.3 Accessing performance domains
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] Documentation: power: Add description about new callback for EM registration
  2021-11-02 18:01 [PATCH 1/2] Documentation: power: Add description about new callback for EM registration Lukasz Luba
  2021-11-02 18:01 ` [PATCH 2/2] Documentation: power: Describe 'advanced' and 'simple' EM models Lukasz Luba
@ 2021-11-09 10:38 ` Lukasz Luba
  2021-11-10 20:28   ` Rafael J. Wysocki
  1 sibling, 1 reply; 5+ messages in thread
From: Lukasz Luba @ 2021-11-09 10:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: dietmar.eggemann, rafael, linux-pm

Hi Rafael,


On 11/2/21 6:01 PM, Lukasz Luba wrote:
> The Energy Model (EM) registration for CPUs should now be done using
> a dedicated callback added recently into CPUFreq framework and drivers.
> 
> Commit c17495b01b72 ("cpufreq: Add callback to register with energy model")
> 
> The callback guaranties that the EM registration is called at the right
> time during driver setup. To avoid mistakes update the documentation
> to align with the existing code implementation.
> 
> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> ---
>   Documentation/power/energy-model.rst | 31 ++++++++++++++--------------
>   1 file changed, 16 insertions(+), 15 deletions(-)
> 


Gentle ping. Could you have a look at these documentation
two patches and maybe pick them, please?
They are trying to solve some confusion discussed with our partners
recently.

Regards,
Lukasz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] Documentation: power: Add description about new callback for EM registration
  2021-11-09 10:38 ` [PATCH 1/2] Documentation: power: Add description about new callback for EM registration Lukasz Luba
@ 2021-11-10 20:28   ` Rafael J. Wysocki
  2021-11-10 20:50     ` Lukasz Luba
  0 siblings, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2021-11-10 20:28 UTC (permalink / raw)
  To: Lukasz Luba
  Cc: Linux Kernel Mailing List, Dietmar Eggemann, Rafael J. Wysocki, Linux PM

On Tue, Nov 9, 2021 at 11:38 AM Lukasz Luba <lukasz.luba@arm.com> wrote:
>
> Hi Rafael,
>
>
> On 11/2/21 6:01 PM, Lukasz Luba wrote:
> > The Energy Model (EM) registration for CPUs should now be done using
> > a dedicated callback added recently into CPUFreq framework and drivers.
> >
> > Commit c17495b01b72 ("cpufreq: Add callback to register with energy model")
> >
> > The callback guaranties that the EM registration is called at the right
> > time during driver setup. To avoid mistakes update the documentation
> > to align with the existing code implementation.
> >
> > Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> > ---
> >   Documentation/power/energy-model.rst | 31 ++++++++++++++--------------
> >   1 file changed, 16 insertions(+), 15 deletions(-)
> >
>
>
> Gentle ping. Could you have a look at these documentation
> two patches and maybe pick them, please?
> They are trying to solve some confusion discussed with our partners
> recently.

Both applied as 5.16-rc material now, thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] Documentation: power: Add description about new callback for EM registration
  2021-11-10 20:28   ` Rafael J. Wysocki
@ 2021-11-10 20:50     ` Lukasz Luba
  0 siblings, 0 replies; 5+ messages in thread
From: Lukasz Luba @ 2021-11-10 20:50 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux Kernel Mailing List, Dietmar Eggemann, Linux PM



On 11/10/21 8:28 PM, Rafael J. Wysocki wrote:
> On Tue, Nov 9, 2021 at 11:38 AM Lukasz Luba <lukasz.luba@arm.com> wrote:
>>
>> Hi Rafael,
>>
>>
>> On 11/2/21 6:01 PM, Lukasz Luba wrote:
>>> The Energy Model (EM) registration for CPUs should now be done using
>>> a dedicated callback added recently into CPUFreq framework and drivers.
>>>
>>> Commit c17495b01b72 ("cpufreq: Add callback to register with energy model")
>>>
>>> The callback guaranties that the EM registration is called at the right
>>> time during driver setup. To avoid mistakes update the documentation
>>> to align with the existing code implementation.
>>>
>>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
>>> ---
>>>    Documentation/power/energy-model.rst | 31 ++++++++++++++--------------
>>>    1 file changed, 16 insertions(+), 15 deletions(-)
>>>
>>
>>
>> Gentle ping. Could you have a look at these documentation
>> two patches and maybe pick them, please?
>> They are trying to solve some confusion discussed with our partners
>> recently.
> 
> Both applied as 5.16-rc material now, thanks!
> 

Thank you Rafael!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-10 20:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 18:01 [PATCH 1/2] Documentation: power: Add description about new callback for EM registration Lukasz Luba
2021-11-02 18:01 ` [PATCH 2/2] Documentation: power: Describe 'advanced' and 'simple' EM models Lukasz Luba
2021-11-09 10:38 ` [PATCH 1/2] Documentation: power: Add description about new callback for EM registration Lukasz Luba
2021-11-10 20:28   ` Rafael J. Wysocki
2021-11-10 20:50     ` Lukasz Luba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.