Skip to content

Commit 0bc3cc0

Browse files
Mike TravisIngo Molnar
authored andcommitted
cpumask: change cpumask_of_cpu_ptr to use new cpumask_of_cpu
* Replace previous instances of the cpumask_of_cpu_ptr* macros with a the new (lvalue capable) generic cpumask_of_cpu(). Signed-off-by: Mike Travis <travis@sgi.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jack Steiner <steiner@sgi.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 6524d93 commit 0bc3cc0

17 files changed

Lines changed: 37 additions & 83 deletions

File tree

‎arch/x86/kernel/acpi/cstate.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
7373
struct cpuinfo_x86 *c = &cpu_data(cpu);
7474

7575
cpumask_t saved_mask;
76-
cpumask_of_cpu_ptr(new_mask, cpu);
7776
int retval;
7877
unsigned int eax, ebx, ecx, edx;
7978
unsigned int edx_part;
@@ -92,7 +91,7 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
9291

9392
/* Make sure we are running on right CPU */
9493
saved_mask = current->cpus_allowed;
95-
retval = set_cpus_allowed_ptr(current, new_mask);
94+
retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
9695
if (retval)
9796
return -1;
9897

‎arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,10 @@ static void drv_read(struct drv_cmd *cmd)
200200
static void drv_write(struct drv_cmd *cmd)
201201
{
202202
cpumask_t saved_mask = current->cpus_allowed;
203-
cpumask_of_cpu_ptr_declare(cpu_mask);
204203
unsigned int i;
205204

206205
for_each_cpu_mask_nr(i, cmd->mask) {
207-
cpumask_of_cpu_ptr_next(cpu_mask, i);
208-
set_cpus_allowed_ptr(current, cpu_mask);
206+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(i));
209207
do_drv_write(cmd);
210208
}
211209

@@ -269,12 +267,11 @@ static unsigned int get_measured_perf(unsigned int cpu)
269267
} aperf_cur, mperf_cur;
270268

271269
cpumask_t saved_mask;
272-
cpumask_of_cpu_ptr(cpu_mask, cpu);
273270
unsigned int perf_percent;
274271
unsigned int retval;
275272

276273
saved_mask = current->cpus_allowed;
277-
set_cpus_allowed_ptr(current, cpu_mask);
274+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
278275
if (get_cpu() != cpu) {
279276
/* We were not able to run on requested processor */
280277
put_cpu();
@@ -340,7 +337,6 @@ static unsigned int get_measured_perf(unsigned int cpu)
340337

341338
static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
342339
{
343-
cpumask_of_cpu_ptr(cpu_mask, cpu);
344340
struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu);
345341
unsigned int freq;
346342
unsigned int cached_freq;
@@ -353,7 +349,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
353349
}
354350

355351
cached_freq = data->freq_table[data->acpi_data->state].frequency;
356-
freq = extract_freq(get_cur_val(cpu_mask), data);
352+
freq = extract_freq(get_cur_val(&cpumask_of_cpu(cpu)), data);
357353
if (freq != cached_freq) {
358354
/*
359355
* The dreaded BIOS frequency change behind our back.

‎arch/x86/kernel/cpu/cpufreq/powernow-k8.c‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,11 @@ static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvi
479479
static int check_supported_cpu(unsigned int cpu)
480480
{
481481
cpumask_t oldmask;
482-
cpumask_of_cpu_ptr(cpu_mask, cpu);
483482
u32 eax, ebx, ecx, edx;
484483
unsigned int rc = 0;
485484

486485
oldmask = current->cpus_allowed;
487-
set_cpus_allowed_ptr(current, cpu_mask);
486+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
488487

489488
if (smp_processor_id() != cpu) {
490489
printk(KERN_ERR PFX "limiting to cpu %u failed\n", cpu);
@@ -1017,7 +1016,6 @@ static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned i
10171016
static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation)
10181017
{
10191018
cpumask_t oldmask;
1020-
cpumask_of_cpu_ptr(cpu_mask, pol->cpu);
10211019
struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);
10221020
u32 checkfid;
10231021
u32 checkvid;
@@ -1032,7 +1030,7 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
10321030

10331031
/* only run on specific CPU from here on */
10341032
oldmask = current->cpus_allowed;
1035-
set_cpus_allowed_ptr(current, cpu_mask);
1033+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu));
10361034

10371035
if (smp_processor_id() != pol->cpu) {
10381036
printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu);
@@ -1107,7 +1105,6 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
11071105
{
11081106
struct powernow_k8_data *data;
11091107
cpumask_t oldmask;
1110-
cpumask_of_cpu_ptr_declare(newmask);
11111108
int rc;
11121109

11131110
if (!cpu_online(pol->cpu))
@@ -1159,8 +1156,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
11591156

11601157
/* only run on specific CPU from here on */
11611158
oldmask = current->cpus_allowed;
1162-
cpumask_of_cpu_ptr_next(newmask, pol->cpu);
1163-
set_cpus_allowed_ptr(current, newmask);
1159+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu));
11641160

11651161
if (smp_processor_id() != pol->cpu) {
11661162
printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu);
@@ -1182,7 +1178,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
11821178
set_cpus_allowed_ptr(current, &oldmask);
11831179

11841180
if (cpu_family == CPU_HW_PSTATE)
1185-
pol->cpus = *newmask;
1181+
pol->cpus = cpumask_of_cpu(pol->cpu);
11861182
else
11871183
pol->cpus = per_cpu(cpu_core_map, pol->cpu);
11881184
data->available_cores = &(pol->cpus);
@@ -1248,7 +1244,6 @@ static unsigned int powernowk8_get (unsigned int cpu)
12481244
{
12491245
struct powernow_k8_data *data;
12501246
cpumask_t oldmask = current->cpus_allowed;
1251-
cpumask_of_cpu_ptr(newmask, cpu);
12521247
unsigned int khz = 0;
12531248
unsigned int first;
12541249

@@ -1258,7 +1253,7 @@ static unsigned int powernowk8_get (unsigned int cpu)
12581253
if (!data)
12591254
return -EINVAL;
12601255

1261-
set_cpus_allowed_ptr(current, newmask);
1256+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
12621257
if (smp_processor_id() != cpu) {
12631258
printk(KERN_ERR PFX
12641259
"limiting to CPU %d failed in powernowk8_get\n", cpu);

‎arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,9 @@ static unsigned int get_cur_freq(unsigned int cpu)
324324
unsigned l, h;
325325
unsigned clock_freq;
326326
cpumask_t saved_mask;
327-
cpumask_of_cpu_ptr(new_mask, cpu);
328327

329328
saved_mask = current->cpus_allowed;
330-
set_cpus_allowed_ptr(current, new_mask);
329+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
331330
if (smp_processor_id() != cpu)
332331
return 0;
333332

@@ -585,15 +584,12 @@ static int centrino_target (struct cpufreq_policy *policy,
585584
* Best effort undo..
586585
*/
587586

588-
if (!cpus_empty(*covered_cpus)) {
589-
cpumask_of_cpu_ptr_declare(new_mask);
590-
587+
if (!cpus_empty(*covered_cpus))
591588
for_each_cpu_mask_nr(j, *covered_cpus) {
592-
cpumask_of_cpu_ptr_next(new_mask, j);
593-
set_cpus_allowed_ptr(current, new_mask);
589+
set_cpus_allowed_ptr(current,
590+
&cpumask_of_cpu(j));
594591
wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
595592
}
596-
}
597593

598594
tmp = freqs.new;
599595
freqs.new = freqs.old;

‎arch/x86/kernel/cpu/cpufreq/speedstep-ich.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,7 @@ static unsigned int _speedstep_get(const cpumask_t *cpus)
244244

245245
static unsigned int speedstep_get(unsigned int cpu)
246246
{
247-
cpumask_of_cpu_ptr(newmask, cpu);
248-
return _speedstep_get(newmask);
247+
return _speedstep_get(&cpumask_of_cpu(cpu));
249248
}
250249

251250
/**

‎arch/x86/kernel/cpu/intel_cacheinfo.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,6 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu)
516516
unsigned long j;
517517
int retval;
518518
cpumask_t oldmask;
519-
cpumask_of_cpu_ptr(newmask, cpu);
520519

521520
if (num_cache_leaves == 0)
522521
return -ENOENT;
@@ -527,7 +526,7 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu)
527526
return -ENOMEM;
528527

529528
oldmask = current->cpus_allowed;
530-
retval = set_cpus_allowed_ptr(current, newmask);
529+
retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
531530
if (retval)
532531
goto out;
533532

‎arch/x86/kernel/ldt.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,10 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
6262

6363
if (reload) {
6464
#ifdef CONFIG_SMP
65-
cpumask_of_cpu_ptr_declare(mask);
66-
6765
preempt_disable();
6866
load_LDT(pc);
69-
cpumask_of_cpu_ptr_next(mask, smp_processor_id());
70-
if (!cpus_equal(current->mm->cpu_vm_mask, *mask))
67+
if (!cpus_equal(current->mm->cpu_vm_mask,
68+
cpumask_of_cpu(smp_processor_id())))
7169
smp_call_function(flush_ldt, current->mm, 1);
7270
preempt_enable();
7371
#else

‎arch/x86/kernel/microcode.c‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ static int do_microcode_update (void)
388388
void *new_mc = NULL;
389389
int cpu;
390390
cpumask_t old;
391-
cpumask_of_cpu_ptr_declare(newmask);
392391

393392
old = current->cpus_allowed;
394393

@@ -405,8 +404,7 @@ static int do_microcode_update (void)
405404

406405
if (!uci->valid)
407406
continue;
408-
cpumask_of_cpu_ptr_next(newmask, cpu);
409-
set_cpus_allowed_ptr(current, newmask);
407+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
410408
error = get_maching_microcode(new_mc, cpu);
411409
if (error < 0)
412410
goto out;
@@ -576,7 +574,6 @@ static int apply_microcode_check_cpu(int cpu)
576574
struct cpuinfo_x86 *c = &cpu_data(cpu);
577575
struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
578576
cpumask_t old;
579-
cpumask_of_cpu_ptr(newmask, cpu);
580577
unsigned int val[2];
581578
int err = 0;
582579

@@ -585,7 +582,7 @@ static int apply_microcode_check_cpu(int cpu)
585582
return 0;
586583

587584
old = current->cpus_allowed;
588-
set_cpus_allowed_ptr(current, newmask);
585+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
589586

590587
/* Check if the microcode we have in memory matches the CPU */
591588
if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
@@ -623,12 +620,11 @@ static int apply_microcode_check_cpu(int cpu)
623620
static void microcode_init_cpu(int cpu, int resume)
624621
{
625622
cpumask_t old;
626-
cpumask_of_cpu_ptr(newmask, cpu);
627623
struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
628624

629625
old = current->cpus_allowed;
630626

631-
set_cpus_allowed_ptr(current, newmask);
627+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
632628
mutex_lock(&microcode_mutex);
633629
collect_cpu_info(cpu);
634630
if (uci->valid && system_state == SYSTEM_RUNNING && !resume)
@@ -661,13 +657,10 @@ static ssize_t reload_store(struct sys_device *dev,
661657
if (end == buf)
662658
return -EINVAL;
663659
if (val == 1) {
664-
cpumask_t old;
665-
cpumask_of_cpu_ptr(newmask, cpu);
666-
667-
old = current->cpus_allowed;
660+
cpumask_t old = current->cpus_allowed;
668661

669662
get_online_cpus();
670-
set_cpus_allowed_ptr(current, newmask);
663+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
671664

672665
mutex_lock(&microcode_mutex);
673666
if (uci->valid)

‎arch/x86/kernel/reboot.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,25 +414,20 @@ void native_machine_shutdown(void)
414414

415415
/* The boot cpu is always logical cpu 0 */
416416
int reboot_cpu_id = 0;
417-
cpumask_of_cpu_ptr(newmask, reboot_cpu_id);
418417

419418
#ifdef CONFIG_X86_32
420419
/* See if there has been given a command line override */
421420
if ((reboot_cpu != -1) && (reboot_cpu < NR_CPUS) &&
422-
cpu_online(reboot_cpu)) {
421+
cpu_online(reboot_cpu))
423422
reboot_cpu_id = reboot_cpu;
424-
cpumask_of_cpu_ptr_next(newmask, reboot_cpu_id);
425-
}
426423
#endif
427424

428425
/* Make certain the cpu I'm about to reboot on is online */
429-
if (!cpu_online(reboot_cpu_id)) {
426+
if (!cpu_online(reboot_cpu_id))
430427
reboot_cpu_id = smp_processor_id();
431-
cpumask_of_cpu_ptr_next(newmask, reboot_cpu_id);
432-
}
433428

434429
/* Make certain I only run on the appropriate processor */
435-
set_cpus_allowed_ptr(current, newmask);
430+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(reboot_cpu_id));
436431

437432
/* O.K Now that I'm on the appropriate processor,
438433
* stop all of the others.

‎drivers/acpi/processor_throttling.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,6 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
827827
static int acpi_processor_get_throttling(struct acpi_processor *pr)
828828
{
829829
cpumask_t saved_mask;
830-
cpumask_of_cpu_ptr_declare(new_mask);
831830
int ret;
832831

833832
if (!pr)
@@ -839,8 +838,7 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
839838
* Migrate task to the cpu pointed by pr.
840839
*/
841840
saved_mask = current->cpus_allowed;
842-
cpumask_of_cpu_ptr_next(new_mask, pr->id);
843-
set_cpus_allowed_ptr(current, new_mask);
841+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id));
844842
ret = pr->throttling.acpi_processor_get_throttling(pr);
845843
/* restore the previous state */
846844
set_cpus_allowed_ptr(current, &saved_mask);
@@ -989,7 +987,6 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
989987
int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
990988
{
991989
cpumask_t saved_mask;
992-
cpumask_of_cpu_ptr_declare(new_mask);
993990
int ret = 0;
994991
unsigned int i;
995992
struct acpi_processor *match_pr;
@@ -1028,8 +1025,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
10281025
* it can be called only for the cpu pointed by pr.
10291026
*/
10301027
if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) {
1031-
cpumask_of_cpu_ptr_next(new_mask, pr->id);
1032-
set_cpus_allowed_ptr(current, new_mask);
1028+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id));
10331029
ret = p_throttling->acpi_processor_set_throttling(pr,
10341030
t_state.target_state);
10351031
} else {
@@ -1060,8 +1056,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
10601056
continue;
10611057
}
10621058
t_state.cpu = i;
1063-
cpumask_of_cpu_ptr_next(new_mask, i);
1064-
set_cpus_allowed_ptr(current, new_mask);
1059+
set_cpus_allowed_ptr(current, &cpumask_of_cpu(i));
10651060
ret = match_pr->throttling.
10661061
acpi_processor_set_throttling(
10671062
match_pr, t_state.target_state);

0 commit comments

Comments
 (0)