[Debian] [Fwd: [PATCH] Fix speedstep-centino driver in VCPU presence]

Kirill Korotaev dev at sw.ru
Thu Apr 26 12:45:25 EDT 2007


Ola Lundqvist wrote:
> Hi Kiril
> 
> Thanks. Do this apply to the Debian kernel or is it against the
> vanilla kernel?

against vanilla, but should apply well against debian as well (haven't checked).
I've added this patch to coming 028stab031 kernel already.

Thanks,
Kirill


> 
> Regards,
> 
> // Ola
> 
> On Thu, Apr 26, 2007 at 04:15:06PM +0400, Kirill Korotaev wrote:
> 
>>Ola,
>>
>>FYI, debian bug 420708 will be fixed in 2.6.18-028stab031
>>patch attached.
>>
>>Thanks,
>>Kirill
>>
>>
>>-------- Original Message --------
>>Subject: [PATCH] Fix speedstep-centino driver in VCPU presence
>>Date: Thu, 26 Apr 2007 14:35:45 +0400
>>From: Alexey Dobriyan <adobriyan at sw.ru>
>>To: dev at sw.ru
>>CC: vz at sw.ru
>>
>>Patch from Alexey Dobriyan (adobriyan@)
>>
>>speedstep-centrino cpufreq driver was using set_cpus_allowed() and
>>checks for smp_processor_id() to confine itself to given CPU. In
>>presence of VCPU freature this doesn't work.
>>
>>Switch to rdmsr_on_cpu/wrmsr_on_cpu() infrastructure.
>>
>>Closes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=420708
>>
> 
> 
>>--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
>>+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
>>@@ -17,7 +17,6 @@ #include <linux/kernel.h>
>> #include <linux/module.h>
>> #include <linux/init.h>
>> #include <linux/cpufreq.h>
>>-#include <linux/sched.h>	/* current */
>> #include <linux/delay.h>
>> #include <linux/compiler.h>
>> 
>>@@ -319,14 +318,8 @@ static unsigned int get_cur_freq(unsigne
>> {
>> 	unsigned l, h;
>> 	unsigned clock_freq;
>>-	cpumask_t saved_mask;
>> 
>>-	saved_mask = current->cpus_allowed;
>>-	set_cpus_allowed(current, cpumask_of_cpu(cpu));
>>-	if (smp_processor_id() != cpu)
>>-		return 0;
>>-
>>-	rdmsr(MSR_IA32_PERF_STATUS, l, h);
>>+	rdmsr_on_cpu(cpu, MSR_IA32_PERF_STATUS, &l, &h);
>> 	clock_freq = extract_clock(l, cpu, 0);
>> 
>> 	if (unlikely(clock_freq == 0)) {
>>@@ -336,11 +329,10 @@ static unsigned int get_cur_freq(unsigne
>> 		 * P-state transition (like TM2). Get the last freq set 
>> 		 * in PERF_CTL.
>> 		 */
>>-		rdmsr(MSR_IA32_PERF_CTL, l, h);
>>+		rdmsr_on_cpu(cpu, MSR_IA32_PERF_CTL, &l, &h);
>> 		clock_freq = extract_clock(l, cpu, 1);
>> 	}
>> 
>>-	set_cpus_allowed(current, saved_mask);
>> 	return clock_freq;
>> }
>> 
>>@@ -550,15 +542,15 @@ static int centrino_cpu_init(struct cpuf
>> 
>> 	/* Check to see if Enhanced SpeedStep is enabled, and try to
>> 	   enable it if not. */
>>-	rdmsr(MSR_IA32_MISC_ENABLE, l, h);
>>+	rdmsr_on_cpu(policy->cpu, MSR_IA32_MISC_ENABLE, &l, &h);
>> 
>> 	if (!(l & (1<<16))) {
>> 		l |= (1<<16);
>> 		dprintk("trying to enable Enhanced SpeedStep (%x)\n", l);
>>-		wrmsr(MSR_IA32_MISC_ENABLE, l, h);
>>+		wrmsr_on_cpu(policy->cpu, MSR_IA32_MISC_ENABLE, l, h);
>> 
>> 		/* check to see if it stuck */
>>-		rdmsr(MSR_IA32_MISC_ENABLE, l, h);
>>+		rdmsr_on_cpu(policy->cpu, MSR_IA32_MISC_ENABLE, &l, &h);
>> 		if (!(l & (1<<16))) {
>> 			printk(KERN_INFO PFX "couldn't enable Enhanced SpeedStep\n");
>> 			return -ENODEV;
>>@@ -638,7 +630,6 @@ static int centrino_target (struct cpufr
>> 	unsigned int	msr, oldmsr = 0, h = 0, cpu = policy->cpu;
>> 	struct cpufreq_freqs	freqs;
>> 	cpumask_t		online_policy_cpus;
>>-	cpumask_t		saved_mask;
>> 	cpumask_t		set_mask;
>> 	cpumask_t		covered_cpus;
>> 	int			retval = 0;
>>@@ -662,7 +653,6 @@ #else
>> 	online_policy_cpus = policy->cpus;
>> #endif
>> 
>>-	saved_mask = current->cpus_allowed;
>> 	first_cpu = 1;
>> 	cpus_clear(covered_cpus);
>> 	for_each_cpu_mask(j, online_policy_cpus) {
>>@@ -676,8 +666,7 @@ #endif
>> 		else
>> 			cpu_set(j, set_mask);
>> 
>>-		set_cpus_allowed(current, set_mask);
>>-		if (unlikely(!cpu_isset(smp_processor_id(), set_mask))) {
>>+		if (unlikely(!cpu_isset(j, set_mask))) {
>> 			dprintk("couldn't limit to CPUs in this domain\n");
>> 			retval = -EAGAIN;
>> 			if (first_cpu) {
>>@@ -690,7 +679,7 @@ #endif
>> 		msr = centrino_model[cpu]->op_points[newstate].index;
>> 
>> 		if (first_cpu) {
>>-			rdmsr(MSR_IA32_PERF_CTL, oldmsr, h);
>>+			rdmsr_on_cpu(j, MSR_IA32_PERF_CTL, &oldmsr, &h);
>> 			if (msr == (oldmsr & 0xffff)) {
>> 				dprintk("no change needed - msr was and needs "
>> 					"to be %x\n", oldmsr);
>>@@ -717,7 +706,7 @@ #endif
>> 			oldmsr |= msr;
>> 		}
>> 
>>-		wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
>>+		wrmsr_on_cpu(j, MSR_IA32_PERF_CTL, oldmsr, h);
>> 		if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
>> 			break;
>> 
>>@@ -739,8 +728,7 @@ #endif
>> 
>> 		if (!cpus_empty(covered_cpus)) {
>> 			for_each_cpu_mask(j, covered_cpus) {
>>-				set_cpus_allowed(current, cpumask_of_cpu(j));
>>-				wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
>>+				wrmsr_on_cpu(j, MSR_IA32_PERF_CTL, oldmsr, h);
>> 			}
>> 		}
>> 
>>@@ -755,7 +743,6 @@ #endif
>> 	}
>> 
>> migrate_end:
>>-	set_cpus_allowed(current, saved_mask);
>> 	return 0;
>> }
>> 
>>
> 
> 
>>_______________________________________________
>>Debian mailing list
>>Debian at openvz.org
>>https://openvz.org/mailman/listinfo/debian
> 
> 
> 



More information about the Debian mailing list