Skip to contentSkip to conversation

Add MSR Wait state to

PATCH Hollis Blanchard 2 participants 3 messages Mar 28, 2008

lore
Share & tools
lore
#0 lore raw
Quoted 17 lines · Jerone Young

# HG changeset patch
# User Jerone Young <[email protected]>
# Date 1206720510 18000
# Node ID e48cf2ad6c85c457ff64c04b83960fc305420842 # Parent 1506aa38ddabb0bf73fff3ac3f3db5f9ef6458cc Add MSR Wait state to cpu_idle loop

This patch sets the wait state MSR when in the cpu_idle loop. This is mainly to help out virtualization solutions such as KVM. This way the virtualization soultion is able to tell if the guest kernel is idle.

arch/powerpc/kernel/idle.c line 36

Quoted 5 lines
arch/powerpc/kernel/idle.c +2 -0
@@ -32,6 +32,8 @@
 #include <asm/time.h>
 #include <asm/machdep.h>
 #include <asm/smp.h>
+
+static unsigned long msr_save;

Why is this global?

arch/powerpc/kernel/idle.c void cpu_idle(void) · line 99

Quoted 13 lines
arch/powerpc/kernel/idle.c +4 -0
 #ifdef CONFIG_HOTPLUG_CPU
 /* this is used for software suspend, and that shuts down
@@ -88,6 +90,10 @@ void cpu_idle(void)
 				HMT_low();
 				HMT_very_low();
 			}
+
+			/* set wait state MSR */
+			msr_save = mfmsr();
+			mtmsr(msr_save|MSR_WE);
 		}
 
 		HMT_medium();

The code you are modifying is common to all PowerPC kernels. Why didn't you use the power_save() hook provided to you?

Signature · 13 lines
Hollis Blanchard
IBM Linux Technology Center


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
kvm-ppc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel
#1 lore raw
Quoted 14 lines · Hollis Blanchard
Quoted 13 lines · Jerone Young

# HG changeset patch
# User Jerone Young <[email protected]>
# Date 1206720510 18000
# Node ID e48cf2ad6c85c457ff64c04b83960fc305420842 # Parent 1506aa38ddabb0bf73fff3ac3f3db5f9ef6458cc Add MSR Wait state to cpu_idle loop

This patch sets the wait state MSR when in the cpu_idle loop. This is mainly to help out virtualization solutions such as KVM. This way the virtualization soultion is able to tell if the guest kernel is idle.

Quoted 11 lines

arch/powerpc/kernel/idle.c line 36

Quoted 9 lines
arch/powerpc/kernel/idle.c +2 -0
@@ -32,6 +32,8 @@
 #include <asm/time.h>
 #include <asm/machdep.h>
 #include <asm/smp.h>
+
+static unsigned long msr_save;

Why is this global?

I'll change this to declare it in cpu_idle().

Quoted 13 lines
Quoted 13 lines
arch/powerpc/kernel/idle.c +4 -0
 #ifdef CONFIG_HOTPLUG_CPU
 /* this is used for software suspend, and that shuts down
@@ -88,6 +90,10 @@ void cpu_idle(void)
 				HMT_low();
 				HMT_very_low();
 			}
+
+			/* set wait state MSR */
+			msr_save = mfmsr();
+			mtmsr(msr_save|MSR_WE);
 		}
 
Quoted 5 lines

arch/powerpc/kernel/idle.c void cpu_idle(void) · line 99

Quoted 1 line
arch/powerpc/kernel/idle.c +0 -0
 		HMT_medium();

The code you are modifying is common to all PowerPC kernels. Why didn't you use the power_save() hook provided to you?

power_save() is called with interrupts disabled. So we would never wake up.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
kvm-ppc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

#2 lore raw
In reply to Hollis Blanchard
Quoted 20 lines · Nathan Lynch
Quoted 19 lines · Jerone Young
Quoted 17 lines · Hollis Blanchard

Review void cpu_idle(void) · line 99

Quoted 13 lines

#ifdef CONFIG_HOTPLUG_CPU
/* this is used for software suspend, and that shuts down

(quoted diff) +4 -0
@@ -88,6 +90,10 @@ void cpu_idle(void)
 				HMT_low();
 				HMT_very_low();
 			}
+
+			/* set wait state MSR */
+			msr_save = mfmsr();
+			mtmsr(msr_save|MSR_WE);
 		}
 
 		HMT_medium();

The code you are modifying is common to all PowerPC kernels. Why didn't you use the power_save() hook provided to you?

Quoted 5 lines
Quoted 2 lines

power_save() is called with interrupts disabled. So we would never wake up.

MSR_WE/POW is implementation-dependent and modifying it in generic code is not okay.

I figured this would come out as an issue. Once I got to linuxppc-dev

Quoted 3 lines

You can re-enable interrupts in your power_save implementation before setting MSR_WE (in fact power4_idle does this).

OK great .. I'll do this then.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
kvm-ppc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel