lkml.org 
[lkml]   [2009]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 4/6] x86/cpufreq: use cpumask_copy instead of =

so later could use nr_cpumask_bits in cpumask_size when MAXSMP is used

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 52 ++++++++++++++++++++----------
1 file changed, 35 insertions(+), 17 deletions(-)

Index: linux-2.6/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
+++ linux-2.6/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
@@ -512,12 +512,15 @@ static int core_voltage_post_transition(

static int check_supported_cpu(unsigned int cpu)
{
- cpumask_t oldmask;
+ cpumask_var_t oldmask;
u32 eax, ebx, ecx, edx;
unsigned int rc = 0;

- oldmask = current->cpus_allowed;
- set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
+ if (!alloc_cpumask_var(&oldmask, GFP_KERNEL))
+ return rc;
+
+ cpumask_copy(oldmask, &current->cpus_allowed);
+ set_cpus_allowed_ptr(current, cpumask_of(cpu));

if (smp_processor_id() != cpu) {
printk(KERN_ERR PFX "limiting to cpu %u failed\n", cpu);
@@ -565,7 +568,9 @@ static int check_supported_cpu(unsigned
rc = 1;

out:
- set_cpus_allowed_ptr(current, &oldmask);
+ set_cpus_allowed_ptr(current, oldmask);
+ free_cpumask_var(oldmask);
+
return rc;
}

@@ -1144,7 +1149,7 @@ static int transition_frequency_pstate(s
static int powernowk8_target(struct cpufreq_policy *pol,
unsigned targfreq, unsigned relation)
{
- cpumask_t oldmask;
+ cpumask_var_t oldmask;
struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);
u32 checkfid;
u32 checkvid;
@@ -1154,12 +1159,15 @@ static int powernowk8_target(struct cpuf
if (!data)
return -EINVAL;

+ if (!alloc_cpumask_var(&oldmask, GFP_KERNEL))
+ return -EINVAL;
+
checkfid = data->currfid;
checkvid = data->currvid;

/* only run on specific CPU from here on */
- oldmask = current->cpus_allowed;
- set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu));
+ cpumask_copy(oldmask, &current->cpus_allowed);
+ set_cpus_allowed_ptr(current, cpumask_of(pol->cpu));

if (smp_processor_id() != pol->cpu) {
printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu);
@@ -1219,7 +1227,8 @@ static int powernowk8_target(struct cpuf
ret = 0;

err_out:
- set_cpus_allowed_ptr(current, &oldmask);
+ set_cpus_allowed_ptr(current, oldmask);
+ free_cpumask_var(oldmask);
return ret;
}

@@ -1242,7 +1251,7 @@ static const char ACPI_PSS_BIOS_BUG_MSG[
static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
{
struct powernow_k8_data *data;
- cpumask_t oldmask;
+ cpumask_var_t oldmask;
int rc;

if (!cpu_online(pol->cpu))
@@ -1251,6 +1260,9 @@ static int __cpuinit powernowk8_cpu_init
if (!check_supported_cpu(pol->cpu))
return -ENODEV;

+ if (!alloc_cpumask_var(&oldmask, GFP_KERNEL))
+ return -ENOMEM;
+
data = kzalloc(sizeof(struct powernow_k8_data), GFP_KERNEL);
if (!data) {
printk(KERN_ERR PFX "unable to alloc powernow_k8_data");
@@ -1288,8 +1300,8 @@ static int __cpuinit powernowk8_cpu_init
pol->cpuinfo.transition_latency = get_transition_latency(data);

/* only run on specific CPU from here on */
- oldmask = current->cpus_allowed;
- set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu));
+ cpumask_copy(oldmask, &current->cpus_allowed);
+ set_cpus_allowed_ptr(current, cpumask_of(pol->cpu));

if (smp_processor_id() != pol->cpu) {
printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu);
@@ -1308,7 +1320,7 @@ static int __cpuinit powernowk8_cpu_init
fidvid_msr_init();

/* run on any CPU again */
- set_cpus_allowed_ptr(current, &oldmask);
+ set_cpus_allowed_ptr(current, oldmask);

if (cpu_family == CPU_HW_PSTATE)
cpumask_copy(pol->cpus, cpumask_of(pol->cpu));
@@ -1346,7 +1358,8 @@ static int __cpuinit powernowk8_cpu_init
return 0;

err_out_unmask:
- set_cpus_allowed_ptr(current, &oldmask);
+ set_cpus_allowed_ptr(current, oldmask);
+ free_cpumask_var(oldmask);
powernow_k8_cpu_exit_acpi(data);

err_out:
@@ -1374,7 +1387,7 @@ static int __devexit powernowk8_cpu_exit
static unsigned int powernowk8_get(unsigned int cpu)
{
struct powernow_k8_data *data;
- cpumask_t oldmask = current->cpus_allowed;
+ cpumask_var_t oldmask;
unsigned int khz = 0;
unsigned int first;

@@ -1384,11 +1397,15 @@ static unsigned int powernowk8_get(unsig
if (!data)
return -EINVAL;

- set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
+ if (!alloc_cpumask_var(&oldmask, GFP_KERNEL))
+ return -ENOMEM;
+
+ cpumask_copy(oldmask, &current->cpus_allowed);
+ set_cpus_allowed_ptr(current, cpumask_of(cpu));
if (smp_processor_id() != cpu) {
printk(KERN_ERR PFX
"limiting to CPU %d failed in powernowk8_get\n", cpu);
- set_cpus_allowed_ptr(current, &oldmask);
+ set_cpus_allowed_ptr(current, oldmask);
return 0;
}

@@ -1403,7 +1420,8 @@ static unsigned int powernowk8_get(unsig


out:
- set_cpus_allowed_ptr(current, &oldmask);
+ set_cpus_allowed_ptr(current, oldmask);
+ free_cpumask_var(oldmask);
return khz;
}


\
 
 \ /
  Last update: 2009-06-06 23:57    [W:0.093 / U:1.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site