aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
diff options
context:
space:
mode:
authorMike Travis <travis@sgi.com>2008-07-15 17:14:30 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-18 16:02:57 -0400
commit65c011845316d3c1381f478ca0d8265c43b3b039 (patch)
treea7e29e92a1ad0440ef5fe16dc16d73e8bf7983d2 /arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
parentbb2c018b09b681d43f5e08124b83e362647ea82b (diff)
cpumask: Replace cpumask_of_cpu with cpumask_of_cpu_ptr
* This patch replaces the dangerous lvalue version of cpumask_of_cpu with new cpumask_of_cpu_ptr macros. These are patterned after the node_to_cpumask_ptr macros. In general terms, if there is a cpumask_of_cpu_map[] then a pointer to the cpumask_of_cpu_map[cpu] entry is used. The cpumask_of_cpu_map is provided when there is a large NR_CPUS count, reducing greatly the amount of code generated and stack space used for cpumask_of_cpu(). The pointer to the cpumask_t value is needed for calling set_cpus_allowed_ptr() to reduce the amount of stack space needed to pass the cpumask_t value. If there isn't a cpumask_of_cpu_map[], then a temporary variable is declared and filled in with value from cpumask_of_cpu(cpu) as well as a pointer variable pointing to this temporary variable. Afterwards, the pointer is used to reference the cpumask value. The compiler will optimize out the extra dereference through the pointer as well as the stack space used for the pointer, resulting in identical code. A good example of the orthogonal usages is in net/sunrpc/svc.c: case SVC_POOL_PERCPU: { unsigned int cpu = m->pool_to[pidx]; cpumask_of_cpu_ptr(cpumask, cpu); *oldmask = current->cpus_allowed; set_cpus_allowed_ptr(current, cpumask); return 1; } case SVC_POOL_PERNODE: { unsigned int node = m->pool_to[pidx]; node_to_cpumask_ptr(nodecpumask, node); *oldmask = current->cpus_allowed; set_cpus_allowed_ptr(current, nodecpumask); return 1; } Signed-off-by: Mike Travis <travis@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c')
-rw-r--r--arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
index 8b0dd6f2a1ac..fd561bb26c60 100644
--- a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -313,9 +313,10 @@ static unsigned int get_cur_freq(unsigned int cpu)
313 unsigned l, h; 313 unsigned l, h;
314 unsigned clock_freq; 314 unsigned clock_freq;
315 cpumask_t saved_mask; 315 cpumask_t saved_mask;
316 cpumask_of_cpu_ptr(new_mask, cpu);
316 317
317 saved_mask = current->cpus_allowed; 318 saved_mask = current->cpus_allowed;
318 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 319 set_cpus_allowed_ptr(current, new_mask);
319 if (smp_processor_id() != cpu) 320 if (smp_processor_id() != cpu)
320 return 0; 321 return 0;
321 322
@@ -554,9 +555,11 @@ static int centrino_target (struct cpufreq_policy *policy,
554 */ 555 */
555 556
556 if (!cpus_empty(covered_cpus)) { 557 if (!cpus_empty(covered_cpus)) {
558 cpumask_of_cpu_ptr_declare(new_mask);
559
557 for_each_cpu_mask_nr(j, covered_cpus) { 560 for_each_cpu_mask_nr(j, covered_cpus) {
558 set_cpus_allowed_ptr(current, 561 cpumask_of_cpu_ptr_next(new_mask, j);
559 &cpumask_of_cpu(j)); 562 set_cpus_allowed_ptr(current, new_mask);
560 wrmsr(MSR_IA32_PERF_CTL, oldmsr, h); 563 wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
561 } 564 }
562 } 565 }