Commit a1c33bbe authored by Mike Travis's avatar Mike Travis Committed by Ingo Molnar

x86: cleanup remaining cpumask_t code in mce_amd_64.c

Impact: Reduce memory usage, use new cpumask API.

Use cpumask_var_t for 'cpus' cpumask in struct threshold_bank and update
remaining old cpumask_t functions to new cpumask API.
Signed-off-by: default avatarMike Travis <travis@sgi.com>
parent 0e21990a
...@@ -67,7 +67,7 @@ static struct threshold_block threshold_defaults = { ...@@ -67,7 +67,7 @@ static struct threshold_block threshold_defaults = {
struct threshold_bank { struct threshold_bank {
struct kobject *kobj; struct kobject *kobj;
struct threshold_block *blocks; struct threshold_block *blocks;
cpumask_t cpus; cpumask_var_t cpus;
}; };
static DEFINE_PER_CPU(struct threshold_bank *, threshold_banks[NR_BANKS]); static DEFINE_PER_CPU(struct threshold_bank *, threshold_banks[NR_BANKS]);
...@@ -481,7 +481,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) ...@@ -481,7 +481,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
if (cpu_data(cpu).cpu_core_id && shared_bank[bank]) { /* symlink */ if (cpu_data(cpu).cpu_core_id && shared_bank[bank]) { /* symlink */
i = first_cpu(per_cpu(cpu_core_map, cpu)); i = cpumask_first(&per_cpu(cpu_core_map, cpu));
/* first core not up yet */ /* first core not up yet */
if (cpu_data(i).cpu_core_id) if (cpu_data(i).cpu_core_id)
...@@ -501,7 +501,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) ...@@ -501,7 +501,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
if (err) if (err)
goto out; goto out;
b->cpus = per_cpu(cpu_core_map, cpu); cpumask_copy(b->cpus, &per_cpu(cpu_core_map, cpu));
per_cpu(threshold_banks, cpu)[bank] = b; per_cpu(threshold_banks, cpu)[bank] = b;
goto out; goto out;
} }
...@@ -512,15 +512,20 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) ...@@ -512,15 +512,20 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
if (!alloc_cpumask_var(&b->cpus, GFP_KERNEL)) {
kfree(b);
err = -ENOMEM;
goto out;
}
b->kobj = kobject_create_and_add(name, &per_cpu(device_mce, cpu).kobj); b->kobj = kobject_create_and_add(name, &per_cpu(device_mce, cpu).kobj);
if (!b->kobj) if (!b->kobj)
goto out_free; goto out_free;
#ifndef CONFIG_SMP #ifndef CONFIG_SMP
b->cpus = CPU_MASK_ALL; cpumask_setall(b->cpus);
#else #else
b->cpus = per_cpu(cpu_core_map, cpu); cpumask_copy(b->cpus, &per_cpu(cpu_core_map, cpu));
#endif #endif
per_cpu(threshold_banks, cpu)[bank] = b; per_cpu(threshold_banks, cpu)[bank] = b;
...@@ -529,7 +534,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) ...@@ -529,7 +534,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
if (err) if (err)
goto out_free; goto out_free;
for_each_cpu_mask_nr(i, b->cpus) { for_each_cpu(i, b->cpus) {
if (i == cpu) if (i == cpu)
continue; continue;
...@@ -545,6 +550,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) ...@@ -545,6 +550,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
out_free: out_free:
per_cpu(threshold_banks, cpu)[bank] = NULL; per_cpu(threshold_banks, cpu)[bank] = NULL;
free_cpumask_var(b->cpus);
kfree(b); kfree(b);
out: out:
return err; return err;
...@@ -619,7 +625,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank) ...@@ -619,7 +625,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
#endif #endif
/* remove all sibling symlinks before unregistering */ /* remove all sibling symlinks before unregistering */
for_each_cpu_mask_nr(i, b->cpus) { for_each_cpu(i, b->cpus) {
if (i == cpu) if (i == cpu)
continue; continue;
...@@ -632,6 +638,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank) ...@@ -632,6 +638,7 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
free_out: free_out:
kobject_del(b->kobj); kobject_del(b->kobj);
kobject_put(b->kobj); kobject_put(b->kobj);
free_cpumask_var(b->cpus);
kfree(b); kfree(b);
per_cpu(threshold_banks, cpu)[bank] = NULL; per_cpu(threshold_banks, cpu)[bank] = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment