Skip to contentSkip to conversation

rdmsr_on_cpu, wrmsr_on_cpu

PATCH New Alexey Dobriyan 1 participant 1 message Jan 31, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 rdmsr_on_cpu, wrmsr_on_cpu

There was OpenVZ specific bug rendering some cpufreq drivers unusable on SMP. In short, when cpufreq code thinks it confined itself to needed cpu by means of set_cpus_allowed() to execute rdmsr, some "virtual cpu" feature can migrate process to anywhere. This triggers bugons and does wrong things in general.

This got fixed by introducing rdmsr_on_cpu and wrmsr_on_cpu executing rdmsr and wrmsr on given physical cpu by means of smp_call_function_single().

Dave Jones mentioned cpufreq might be not only user of rdmsr_on_cpu() and wrmsr_on_cpu(), so I'm putting them into arch/{i386,x86_64}/lib/ .

---

 arch/i386/lib/Makefile       |    2 +
 arch/i386/lib/msr-on-cpu.c   |   70 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86_64/lib/Makefile     |    2 -
 arch/x86_64/lib/msr-on-cpu.c |    1 
 include/asm-i386/msr.h       |    3 +
 include/asm-x86_64/msr.h     |    2 +
 6 files changed, 79 insertions(+), 1 deletion(-)
arch/i386/lib/Makefile +2 -0
@@ -7,3 +7,5 @@ lib-y = checksum.o delay.o usercopy.o ge
 	bitops.o semaphore.o
 
 lib-$(CONFIG_X86_USE_3DNOW) += mmx.o
+
+obj-y = msr-on-cpu.o
arch/i386/lib/msr-on-cpu.c new file +70 -0

70 lines not on this page · raw message

arch/x86_64/lib/Makefile +1 -1
@@ -4,7 +4,7 @@ #
 
 CFLAGS_csum-partial.o := -funroll-loops
 
-obj-y := io.o iomap_copy.o
+obj-y := io.o iomap_copy.o msr-on-cpu.o
 
 lib-y := csum-partial.o csum-copy.o csum-wrappers.o delay.o \
 	usercopy.o getuser.o putuser.o  \
arch/x86_64/lib/msr-on-cpu.c new file +1 -0
@@ -0,0 +1 @@
+#include "../../i386/lib/msr-on-cpu.c"
include/asm-i386/msr.h +3 -0
@@ -83,6 +83,9 @@ #define rdpmc(counter,low,high) \
 			  : "c" (counter))
 #endif	/* !CONFIG_PARAVIRT */
 
+void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
+void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
+
 /* symbolic names for some interesting MSRs */
 /* Intel defined MSRs. */
 #define MSR_IA32_P5_MC_ADDR		0
include/asm-x86_64/msr.h +2 -0
@@ -160,6 +160,8 @@ static inline unsigned int cpuid_edx(uns
 #define MSR_IA32_UCODE_WRITE		0x79
 #define MSR_IA32_UCODE_REV		0x8b
 
+void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
+void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
 
 #endif