linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/2] cpufreq/powernv: Set core pstate to a minimum just before hotplugging it out
@ 2014-09-05  7:39 Preeti U Murthy
  2014-09-05  7:40 ` [PATCH V2 1/2] cpufreq: Allow stop CPU callback to be used by all cpufreq drivers Preeti U Murthy
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Preeti U Murthy @ 2014-09-05  7:39 UTC (permalink / raw)
  To: viresh.kumar, rjw
  Cc: linux-pm, dirk.j.brandewie, shreyas, linux-kernel,
	patrick.marlier, linuxppc-dev, dirk.brandewie, svaidy

Today cpus go to winkle when they are offlined. Since it is the deepest
idle state that we have, it is expected to save good amount of power as compared
to online state, where cores can enter nap/fastsleep only which are
shallower idle states.
However we observed no powersavings with winkle as compared to nap/fastsleep
and traced the problem to the pstate of the core being kept at a high even
when the core is offline. This can keep the socket pstate high, thus burning
power unnecessarily. This patchset fixes this issue.

Changes in V2: Changed smp_call_function_any() to smp_call_function_single() in Patch[2/2]

---

Preeti U Murthy (2):
      cpufreq: Allow stop CPU callback to be used by all cpufreq drivers
      powernv/cpufreq: Set the pstate of the last hotplugged out cpu in policy->cpus to minimum


 drivers/cpufreq/cpufreq.c         |    2 +-
 drivers/cpufreq/powernv-cpufreq.c |    9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

--


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

* [PATCH V2 1/2] cpufreq: Allow stop CPU callback to be used by all cpufreq drivers
  2014-09-05  7:39 [PATCH V2 0/2] cpufreq/powernv: Set core pstate to a minimum just before hotplugging it out Preeti U Murthy
@ 2014-09-05  7:40 ` Preeti U Murthy
  2014-09-05  7:40 ` [PATCH V2 2/2] powernv/cpufreq: Set the pstate of the last hotplugged out cpu in policy->cpus to minimum Preeti U Murthy
  2014-09-05  7:41 ` [PATCH V2 0/2] cpufreq/powernv: Set core pstate to a minimum just before hotplugging it out Viresh Kumar
  2 siblings, 0 replies; 5+ messages in thread
From: Preeti U Murthy @ 2014-09-05  7:40 UTC (permalink / raw)
  To: viresh.kumar, rjw
  Cc: linux-pm, dirk.j.brandewie, shreyas, linux-kernel,
	patrick.marlier, linuxppc-dev, dirk.brandewie, svaidy

Commit 367dc4aa932bfb3 ("cpufreq: Add stop CPU callback to
cpufreq_driver interface") introduced the stop CPU callback for
intel_pstate drivers. During the CPU_DOWN_PREPARE stage, this
callback is invoked so that drivers can take some action on the
pstate of the cpu before it is taken offline. This callback was
assumed to be useful only for those drivers which have implemented
the set_policy CPU callback because they have no other way to take
action about the cpufreq of a CPU which is being hotplugged out
except in the exit callback which is called very late in the offline
process.

The drivers which implement the target/target_index callbacks were
expected to take care of requirements like the ones that commit
367dc4aa addresses in the GOV_STOP notification event. But there
are disadvantages to restricting the usage of stop CPU callback
to cpufreq drivers that implement the set_policy callbacks and who
want to take explicit action on the setting the cpufreq during a
hotplug operation.

1.GOV_STOP gets called for every CPU offline and drivers would usually
want to take action when the last cpu in the policy->cpus mask
is taken offline. As long as there is more than one cpu in the
policy->cpus mask, cpufreq core itself makes sure that the freq
for the other cpus in this mask is set according to the maximum load.
This is sensible and drivers which implement the target_index callback
would mostly not want to modify that. However the cpufreq core leaves a
loose end when the cpu in the policy->cpus mask is the last one to go offline;
it does nothing explicit to the frequency of the core. Drivers may need
a way to take some action here and stop CPU callback mechanism is the
best way to do it today.

2. We cannot implement driver specific actions in the GOV_STOP mechanism.
So we will need another driver callback which is invoked from here which is
unnecessary.

Therefore this patch extends the usage of stop CPU callback to be used
by all cpufreq drivers as long as they have this callback implemented
and irrespective of whether they are set_policy/target_index drivers.
The assumption is if the drivers find the GOV_STOP path to be a suitable
way of implementing what they want to do with the freq of the cpu
going offine,they will not implement the stop CPU callback at all.

Signed-off-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
---

 drivers/cpufreq/cpufreq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index d9fdedd..6463f35 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1380,7 +1380,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev,
 		if (!cpufreq_suspended)
 			pr_debug("%s: policy Kobject moved to cpu: %d from: %d\n",
 				 __func__, new_cpu, cpu);
-	} else if (cpufreq_driver->stop_cpu && cpufreq_driver->setpolicy) {
+	} else if (cpufreq_driver->stop_cpu) {
 		cpufreq_driver->stop_cpu(policy);
 	}
 


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

* [PATCH V2 2/2] powernv/cpufreq: Set the pstate of the last hotplugged out cpu in policy->cpus to minimum
  2014-09-05  7:39 [PATCH V2 0/2] cpufreq/powernv: Set core pstate to a minimum just before hotplugging it out Preeti U Murthy
  2014-09-05  7:40 ` [PATCH V2 1/2] cpufreq: Allow stop CPU callback to be used by all cpufreq drivers Preeti U Murthy
@ 2014-09-05  7:40 ` Preeti U Murthy
  2014-09-05  7:41 ` [PATCH V2 0/2] cpufreq/powernv: Set core pstate to a minimum just before hotplugging it out Viresh Kumar
  2 siblings, 0 replies; 5+ messages in thread
From: Preeti U Murthy @ 2014-09-05  7:40 UTC (permalink / raw)
  To: viresh.kumar, rjw
  Cc: linux-pm, dirk.j.brandewie, shreyas, linux-kernel,
	patrick.marlier, linuxppc-dev, dirk.brandewie, svaidy

Its possible today that the pstate of a core is held at a high even after the
entire core is hotplugged out if a load had just run on  the hotplugged cpu. This is
fair, since it is assumed that the pstate does not matter to a cpu in a deep idle
state, which is the expected state of a hotplugged core on powerpc. However on powerpc,
the pstate at a socket level is held at the maximum of the pstates of each core. Even
if the pstates of the active cores on that socket is low, the socket pstate is held
high due to the pstate of the hotplugged core in the above mentioned scenario. This
can cost significant amount of power loss for no good.

Besides, since it is a non active core, nothing can be done from the kernel's end
to set the frequency of the core right. Hence make use of the stop_cpu callback
to explicitly set the pstate of the core to a minimum when the last cpu of the
core gets hotplugged out.

Signed-off-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
---

 drivers/cpufreq/powernv-cpufreq.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 379c083..5a628f1 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -317,6 +317,14 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	return cpufreq_table_validate_and_show(policy, powernv_freqs);
 }
 
+static void powernv_cpufreq_stop_cpu(struct cpufreq_policy *policy)
+{
+	struct powernv_smp_call_data freq_data;
+
+	freq_data.pstate_id = powernv_pstate_info.min;
+	smp_call_function_single(policy->cpu, set_pstate, &freq_data, 1);
+}
+
 static struct cpufreq_driver powernv_cpufreq_driver = {
 	.name		= "powernv-cpufreq",
 	.flags		= CPUFREQ_CONST_LOOPS,
@@ -324,6 +332,7 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
 	.verify		= cpufreq_generic_frequency_table_verify,
 	.target_index	= powernv_cpufreq_target_index,
 	.get		= powernv_cpufreq_get,
+	.stop_cpu	= powernv_cpufreq_stop_cpu,
 	.attr		= powernv_cpu_freq_attr,
 };
 


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

* Re: [PATCH V2 0/2] cpufreq/powernv: Set core pstate to a minimum just before hotplugging it out
  2014-09-05  7:39 [PATCH V2 0/2] cpufreq/powernv: Set core pstate to a minimum just before hotplugging it out Preeti U Murthy
  2014-09-05  7:40 ` [PATCH V2 1/2] cpufreq: Allow stop CPU callback to be used by all cpufreq drivers Preeti U Murthy
  2014-09-05  7:40 ` [PATCH V2 2/2] powernv/cpufreq: Set the pstate of the last hotplugged out cpu in policy->cpus to minimum Preeti U Murthy
@ 2014-09-05  7:41 ` Viresh Kumar
  2014-09-09  0:16   ` Rafael J. Wysocki
  2 siblings, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2014-09-05  7:41 UTC (permalink / raw)
  To: Preeti U Murthy
  Cc: Rafael J. Wysocki, linux-pm, Dirk Brandewie, Shreyas Prabhu,
	Linux Kernel Mailing List, Patrick Marlier, linuxppc-dev,
	Dirk Brandewie, Vaidyanathan Srinivasan

On 5 September 2014 13:09, Preeti U Murthy <preeti@linux.vnet.ibm.com> wrote:
> Today cpus go to winkle when they are offlined. Since it is the deepest
> idle state that we have, it is expected to save good amount of power as compared
> to online state, where cores can enter nap/fastsleep only which are
> shallower idle states.
> However we observed no powersavings with winkle as compared to nap/fastsleep
> and traced the problem to the pstate of the core being kept at a high even
> when the core is offline. This can keep the socket pstate high, thus burning
> power unnecessarily. This patchset fixes this issue.
>
> Changes in V2: Changed smp_call_function_any() to smp_call_function_single() in Patch[2/2]

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

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

* Re: [PATCH V2 0/2] cpufreq/powernv: Set core pstate to a minimum just before hotplugging it out
  2014-09-05  7:41 ` [PATCH V2 0/2] cpufreq/powernv: Set core pstate to a minimum just before hotplugging it out Viresh Kumar
@ 2014-09-09  0:16   ` Rafael J. Wysocki
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2014-09-09  0:16 UTC (permalink / raw)
  To: Viresh Kumar, Preeti U Murthy
  Cc: linux-pm, Dirk Brandewie, Shreyas Prabhu,
	Linux Kernel Mailing List, Patrick Marlier, linuxppc-dev,
	Dirk Brandewie, Vaidyanathan Srinivasan

On Friday, September 05, 2014 01:11:22 PM Viresh Kumar wrote:
> On 5 September 2014 13:09, Preeti U Murthy <preeti@linux.vnet.ibm.com> wrote:
> > Today cpus go to winkle when they are offlined. Since it is the deepest
> > idle state that we have, it is expected to save good amount of power as compared
> > to online state, where cores can enter nap/fastsleep only which are
> > shallower idle states.
> > However we observed no powersavings with winkle as compared to nap/fastsleep
> > and traced the problem to the pstate of the core being kept at a high even
> > when the core is offline. This can keep the socket pstate high, thus burning
> > power unnecessarily. This patchset fixes this issue.
> >
> > Changes in V2: Changed smp_call_function_any() to smp_call_function_single() in Patch[2/2]
> 
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

I've queued up the two patches for 3.18, thanks!

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

end of thread, other threads:[~2014-09-08 23:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-05  7:39 [PATCH V2 0/2] cpufreq/powernv: Set core pstate to a minimum just before hotplugging it out Preeti U Murthy
2014-09-05  7:40 ` [PATCH V2 1/2] cpufreq: Allow stop CPU callback to be used by all cpufreq drivers Preeti U Murthy
2014-09-05  7:40 ` [PATCH V2 2/2] powernv/cpufreq: Set the pstate of the last hotplugged out cpu in policy->cpus to minimum Preeti U Murthy
2014-09-05  7:41 ` [PATCH V2 0/2] cpufreq/powernv: Set core pstate to a minimum just before hotplugging it out Viresh Kumar
2014-09-09  0:16   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).