All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] If a CPU gets onlined set the governor to the one that is run on other CPUs
@ 2006-11-23 15:37 Thomas Renninger
  2006-11-26 22:21 ` Dave Jones
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Renninger @ 2006-11-23 15:37 UTC (permalink / raw)
  To: cpufreq; +Cc: Dave Jones

Hi,

I wonder whether there is any real use to allow userspace to
run different governors on different CPUs?
This complicates things (in kernel and userspace) and
if not really needed I'd link up all
sys/../cpu*/cpufreq/scaling_governor files?





If a CPU gets onlined set the governor to the one that is run on other CPUs

If you offline a CPU and online it again (as done by swsusp on SMP),
the cpufreq governor jumps back to performance (or compiled in default
governor).

With this patch it's working like (if CPU is onlined):

check governor of other CPUs, if

  a) all run with the same governor, set governor of CPU that
     gets onlined to the same governor that is run on the others
  b) if different governors are running on different CPUs, set
     the CPU that got onlined to default governor

That means for userspace progs accessing/controlling cpufreq stuff, they should
*never ever* run different governors on the same machine at the same time (on
different CPUs). IMO this feature should be disabled by kernel anyway, but
there might be cases where it makes sense, don't know.

This fix is necessary as any prog is allowed to offline the CPU and cpufreq
must still work. Hal/powersaved or other userspace apps that control suspend
triggering and cpufreq control might be able to workaround the swsuspend resume
case, others that only care about cpufreq, e.g. cpufreqd cannot.
Especially ondemand governor should IMO always just work out of the box by simply
doing: echo ondemand >/sys/../scaling_governor (unfortunately this has to be done
for each cpu currently...).

Thanks,

    Thomas


Signed-off-by: Thomas Renninger <trenn@suse.de>

 drivers/cpufreq/cpufreq.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+)

Index: linux-2.6.18_cpufreq_debug_i386/drivers/cpufreq/cpufreq.c
===================================================================
--- linux-2.6.18_cpufreq_debug_i386.orig/drivers/cpufreq/cpufreq.c
+++ linux-2.6.18_cpufreq_debug_i386/drivers/cpufreq/cpufreq.c
@@ -623,6 +623,7 @@ static int cpufreq_add_dev (struct sys_d
 	unsigned int j;
 #ifdef CONFIG_SMP
 	struct cpufreq_policy *managed_policy;
+	struct cpufreq_governor *governor = NULL;
 #endif
 
 	if (cpu_is_offline(cpu))
@@ -743,6 +744,30 @@ static int cpufreq_add_dev (struct sys_d
 				  * run in cpufreq_set_policy */
 	mutex_unlock(&policy->lock);
 
+#ifdef CONFIG_SMP
+	/* Set governor of added CPU to the same governor running on other CPUs
+	   If different governors are run on differnt CPUs default gov
+	   will be taken */
+	for (j=0; j<NR_CPUS; j++){
+		if (j == cpu)
+			continue;
+		if (cpufreq_cpu_data[j]){
+			if (!governor)
+				governor = cpufreq_cpu_data[j]->governor;
+			else{
+				if (governor != cpufreq_cpu_data[j]->governor)
+					/* different governors running on
+					   different CPUs -> we will start
+					   default governor on this one... */
+					governor = NULL;
+				break;
+			}
+		}
+	}
+	if (governor)
+		new_policy.governor = governor;
+#endif
+
 	/* set default policy */
 	ret = cpufreq_set_policy(&new_policy);
 	if (ret) {

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

end of thread, other threads:[~2006-11-28 10:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-23 15:37 [PATCH] If a CPU gets onlined set the governor to the one that is run on other CPUs Thomas Renninger
2006-11-26 22:21 ` Dave Jones
2006-11-27  3:04   ` Dominik Brodowski
2006-11-27  9:47   ` Thomas Renninger
2006-11-27 17:33     ` Dave Jones
2006-11-28 10:40       ` Ashley Pittman

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.