Skip to contentSkip to conversation

Correct symlink cpufreq handling when offlining dual/ht core machines

PATCH New Thomas Renninger 1 participant 1 message Nov 27, 2006 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Correct symlink cpufreq handling when offlining dual/ht core machines

The bug does not break anything currently (AFAIK), the fix is just for correctness...

Here an example:
l -d cpu*/cpufreq
cpu0/cpufreq/
cpu1/cpufreq -> ../../../../devices/system/cpu/cpu0/cpufreq/ cpu2/cpufreq/
cpu3/cpufreq -> ../../../../devices/system/cpu/cpu2/cpufreq/

echo 0 >cpu2/online
cpu0/cpufreq/
cpu1/cpufreq -> ../../../../devices/system/cpu/cpu0/cpufreq/ cpu3/cpufreq/

Without the patch the last dir (cpu3/cpufreq/, which previously was a symlink) would be missing now.

echo 1 >cpu2/online

l -d cpu*/cpufreq
cpu0/cpufreq/
cpu1/cpufreq -> ../../../../devices/system/cpu/cpu0/cpufreq/ cpu2/cpufreq -> ../../../../devices/system/cpu/cpu3/cpufreq/ cpu3/cpufreq/

Difference after offlining/onlining one "main" core with this patch:
The CPU which has a symlink cpufreq and the CPU which has the origin dir have will be exchanged if the core without the symlink got offlined/onlined.

Patch is against 2.6.18 with my previous one ("If a CPU gets onlined set the governor to the one that is run on other CPUs") also applied, therefore it might fuz a bit...

Please consider to apply to 2.6.20-rc1

Correct symlink cpufreq handling when offlining dual/ht core machines

If you offline a main CPU, the symlink of the cpufreq dir of the managed CPU just vanished. Now it get's it's own cpufreq managing directory. As soon as the sibling core is onlined again, this one gets a symlinked cpufreq dir.

---
 drivers/cpufreq/cpufreq.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +7 -1
Index: linux-2.6.18_cpufreq_symlink_problem/drivers/cpufreq/cpufreq.c
===================================================================
@@ -817,7 +817,7 @@ static int cpufreq_remove_dev (struct sy
 	unsigned long flags;
 	struct cpufreq_policy *data;
 #ifdef CONFIG_SMP
-	struct sys_device *cpu_sys_dev;
+	struct sys_device *cpu_sys_dev = NULL;
 	unsigned int j;
 #endif
 
@@ -910,6 +910,12 @@ static int cpufreq_remove_dev (struct sy
 	kfree(data);
 
 	cpufreq_debug_enable_ratelimit();
+
+	if (cpu_sys_dev){
+		dprintk("Registering managed CPU as managing CPU");
+		cpufreq_add_dev(cpu_sys_dev);
+	}
+
 	return 0;
 }
 

Correct symlink cpufreq handling when offlining dual/ht core machines

If you offline a main CPU, the symlink of the cpufreq dir of the managed CPU just vanished. Now it get's it's own cpufreq managing directory, as soon as the sibling core is onlined again, this one gets a symlinked cpufreq dir.

---
 drivers/cpufreq/cpufreq.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +7 -1
Index: linux-2.6.18_cpufreq_symlink_problem/drivers/cpufreq/cpufreq.c
===================================================================
@@ -817,7 +817,7 @@ static int cpufreq_remove_dev (struct sy
 	unsigned long flags;
 	struct cpufreq_policy *data;
 #ifdef CONFIG_SMP
-	struct sys_device *cpu_sys_dev;
+	struct sys_device *cpu_sys_dev = NULL;
 	unsigned int j;
 #endif
 
@@ -910,6 +910,12 @@ static int cpufreq_remove_dev (struct sy
 	kfree(data);
 
 	cpufreq_debug_enable_ratelimit();
+
+	if (cpu_sys_dev){
+		dprintk("Registering managed CPU as managing CPU");
+		cpufreq_add_dev(cpu_sys_dev);
+	}
+
 	return 0;
 }
 

_______________________________________________
Cpufreq mailing list
[email protected]
http://lists.linux.org.uk/mailman/listinfo/cpufreq