diff options
author | Mike Travis <travis@sgi.com> | 2008-07-15 17:14:30 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-18 16:02:57 -0400 |
commit | 65c011845316d3c1381f478ca0d8265c43b3b039 (patch) | |
tree | a7e29e92a1ad0440ef5fe16dc16d73e8bf7983d2 | |
parent | bb2c018b09b681d43f5e08124b83e362647ea82b (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>
-rw-r--r-- | arch/x86/kernel/acpi/cstate.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 10 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 15 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c | 9 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/cpufreq/speedstep-ich.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/intel_cacheinfo.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/microcode.c | 13 | ||||
-rw-r--r-- | arch/x86/kernel/reboot.c | 14 | ||||
-rw-r--r-- | drivers/acpi/processor_throttling.c | 11 | ||||
-rw-r--r-- | drivers/firmware/dcdbas.c | 3 | ||||
-rw-r--r-- | include/linux/cpumask.h | 32 | ||||
-rw-r--r-- | kernel/stop_machine.c | 3 | ||||
-rw-r--r-- | kernel/trace/trace_sysprof.c | 4 | ||||
-rw-r--r-- | net/sunrpc/svc.c | 3 |
14 files changed, 91 insertions, 35 deletions
diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c index c2502eb9aa83..9220cf46aa10 100644 --- a/arch/x86/kernel/acpi/cstate.c +++ b/arch/x86/kernel/acpi/cstate.c | |||
@@ -73,6 +73,7 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu, | |||
73 | struct cpuinfo_x86 *c = &cpu_data(cpu); | 73 | struct cpuinfo_x86 *c = &cpu_data(cpu); |
74 | 74 | ||
75 | cpumask_t saved_mask; | 75 | cpumask_t saved_mask; |
76 | cpumask_of_cpu_ptr(new_mask, cpu); | ||
76 | int retval; | 77 | int retval; |
77 | unsigned int eax, ebx, ecx, edx; | 78 | unsigned int eax, ebx, ecx, edx; |
78 | unsigned int edx_part; | 79 | unsigned int edx_part; |
@@ -91,7 +92,7 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu, | |||
91 | 92 | ||
92 | /* Make sure we are running on right CPU */ | 93 | /* Make sure we are running on right CPU */ |
93 | saved_mask = current->cpus_allowed; | 94 | saved_mask = current->cpus_allowed; |
94 | retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | 95 | retval = set_cpus_allowed_ptr(current, new_mask); |
95 | if (retval) | 96 | if (retval) |
96 | return -1; | 97 | return -1; |
97 | 98 | ||
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c index dd097b835839..ff2fff56f0a8 100644 --- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | |||
@@ -200,10 +200,12 @@ static void drv_read(struct drv_cmd *cmd) | |||
200 | static void drv_write(struct drv_cmd *cmd) | 200 | static void drv_write(struct drv_cmd *cmd) |
201 | { | 201 | { |
202 | cpumask_t saved_mask = current->cpus_allowed; | 202 | cpumask_t saved_mask = current->cpus_allowed; |
203 | cpumask_of_cpu_ptr_declare(cpu_mask); | ||
203 | unsigned int i; | 204 | unsigned int i; |
204 | 205 | ||
205 | for_each_cpu_mask_nr(i, cmd->mask) { | 206 | for_each_cpu_mask_nr(i, cmd->mask) { |
206 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(i)); | 207 | cpumask_of_cpu_ptr_next(cpu_mask, i); |
208 | set_cpus_allowed_ptr(current, cpu_mask); | ||
207 | do_drv_write(cmd); | 209 | do_drv_write(cmd); |
208 | } | 210 | } |
209 | 211 | ||
@@ -267,11 +269,12 @@ static unsigned int get_measured_perf(unsigned int cpu) | |||
267 | } aperf_cur, mperf_cur; | 269 | } aperf_cur, mperf_cur; |
268 | 270 | ||
269 | cpumask_t saved_mask; | 271 | cpumask_t saved_mask; |
272 | cpumask_of_cpu_ptr(cpu_mask, cpu); | ||
270 | unsigned int perf_percent; | 273 | unsigned int perf_percent; |
271 | unsigned int retval; | 274 | unsigned int retval; |
272 | 275 | ||
273 | saved_mask = current->cpus_allowed; | 276 | saved_mask = current->cpus_allowed; |
274 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | 277 | set_cpus_allowed_ptr(current, cpu_mask); |
275 | if (get_cpu() != cpu) { | 278 | if (get_cpu() != cpu) { |
276 | /* We were not able to run on requested processor */ | 279 | /* We were not able to run on requested processor */ |
277 | put_cpu(); | 280 | put_cpu(); |
@@ -337,6 +340,7 @@ static unsigned int get_measured_perf(unsigned int cpu) | |||
337 | 340 | ||
338 | static unsigned int get_cur_freq_on_cpu(unsigned int cpu) | 341 | static unsigned int get_cur_freq_on_cpu(unsigned int cpu) |
339 | { | 342 | { |
343 | cpumask_of_cpu_ptr(cpu_mask, cpu); | ||
340 | struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu); | 344 | struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu); |
341 | unsigned int freq; | 345 | unsigned int freq; |
342 | unsigned int cached_freq; | 346 | unsigned int cached_freq; |
@@ -349,7 +353,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu) | |||
349 | } | 353 | } |
350 | 354 | ||
351 | cached_freq = data->freq_table[data->acpi_data->state].frequency; | 355 | cached_freq = data->freq_table[data->acpi_data->state].frequency; |
352 | freq = extract_freq(get_cur_val(&cpumask_of_cpu(cpu)), data); | 356 | freq = extract_freq(get_cur_val(cpu_mask), data); |
353 | if (freq != cached_freq) { | 357 | if (freq != cached_freq) { |
354 | /* | 358 | /* |
355 | * The dreaded BIOS frequency change behind our back. | 359 | * The dreaded BIOS frequency change behind our back. |
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c index c45ca6d4dce1..53c7b6936973 100644 --- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c | |||
@@ -479,11 +479,12 @@ static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvi | |||
479 | static int check_supported_cpu(unsigned int cpu) | 479 | static int check_supported_cpu(unsigned int cpu) |
480 | { | 480 | { |
481 | cpumask_t oldmask; | 481 | cpumask_t oldmask; |
482 | cpumask_of_cpu_ptr(cpu_mask, cpu); | ||
482 | u32 eax, ebx, ecx, edx; | 483 | u32 eax, ebx, ecx, edx; |
483 | unsigned int rc = 0; | 484 | unsigned int rc = 0; |
484 | 485 | ||
485 | oldmask = current->cpus_allowed; | 486 | oldmask = current->cpus_allowed; |
486 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | 487 | set_cpus_allowed_ptr(current, cpu_mask); |
487 | 488 | ||
488 | if (smp_processor_id() != cpu) { | 489 | if (smp_processor_id() != cpu) { |
489 | printk(KERN_ERR PFX "limiting to cpu %u failed\n", cpu); | 490 | printk(KERN_ERR PFX "limiting to cpu %u failed\n", cpu); |
@@ -1016,6 +1017,7 @@ static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned i | |||
1016 | static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation) | 1017 | static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation) |
1017 | { | 1018 | { |
1018 | cpumask_t oldmask; | 1019 | cpumask_t oldmask; |
1020 | cpumask_of_cpu_ptr(cpu_mask, pol->cpu); | ||
1019 | struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); | 1021 | struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); |
1020 | u32 checkfid; | 1022 | u32 checkfid; |
1021 | u32 checkvid; | 1023 | u32 checkvid; |
@@ -1030,7 +1032,7 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi | |||
1030 | 1032 | ||
1031 | /* only run on specific CPU from here on */ | 1033 | /* only run on specific CPU from here on */ |
1032 | oldmask = current->cpus_allowed; | 1034 | oldmask = current->cpus_allowed; |
1033 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu)); | 1035 | set_cpus_allowed_ptr(current, cpu_mask); |
1034 | 1036 | ||
1035 | if (smp_processor_id() != pol->cpu) { | 1037 | if (smp_processor_id() != pol->cpu) { |
1036 | printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); | 1038 | printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); |
@@ -1105,6 +1107,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1105 | { | 1107 | { |
1106 | struct powernow_k8_data *data; | 1108 | struct powernow_k8_data *data; |
1107 | cpumask_t oldmask; | 1109 | cpumask_t oldmask; |
1110 | cpumask_of_cpu_ptr_declare(newmask); | ||
1108 | int rc; | 1111 | int rc; |
1109 | 1112 | ||
1110 | if (!cpu_online(pol->cpu)) | 1113 | if (!cpu_online(pol->cpu)) |
@@ -1156,7 +1159,8 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1156 | 1159 | ||
1157 | /* only run on specific CPU from here on */ | 1160 | /* only run on specific CPU from here on */ |
1158 | oldmask = current->cpus_allowed; | 1161 | oldmask = current->cpus_allowed; |
1159 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu)); | 1162 | cpumask_of_cpu_ptr_next(newmask, pol->cpu); |
1163 | set_cpus_allowed_ptr(current, newmask); | ||
1160 | 1164 | ||
1161 | if (smp_processor_id() != pol->cpu) { | 1165 | if (smp_processor_id() != pol->cpu) { |
1162 | printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); | 1166 | printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); |
@@ -1178,7 +1182,7 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1178 | set_cpus_allowed_ptr(current, &oldmask); | 1182 | set_cpus_allowed_ptr(current, &oldmask); |
1179 | 1183 | ||
1180 | if (cpu_family == CPU_HW_PSTATE) | 1184 | if (cpu_family == CPU_HW_PSTATE) |
1181 | pol->cpus = cpumask_of_cpu(pol->cpu); | 1185 | pol->cpus = *newmask; |
1182 | else | 1186 | else |
1183 | pol->cpus = per_cpu(cpu_core_map, pol->cpu); | 1187 | pol->cpus = per_cpu(cpu_core_map, pol->cpu); |
1184 | data->available_cores = &(pol->cpus); | 1188 | data->available_cores = &(pol->cpus); |
@@ -1244,6 +1248,7 @@ static unsigned int powernowk8_get (unsigned int cpu) | |||
1244 | { | 1248 | { |
1245 | struct powernow_k8_data *data; | 1249 | struct powernow_k8_data *data; |
1246 | cpumask_t oldmask = current->cpus_allowed; | 1250 | cpumask_t oldmask = current->cpus_allowed; |
1251 | cpumask_of_cpu_ptr(newmask, cpu); | ||
1247 | unsigned int khz = 0; | 1252 | unsigned int khz = 0; |
1248 | unsigned int first; | 1253 | unsigned int first; |
1249 | 1254 | ||
@@ -1253,7 +1258,7 @@ static unsigned int powernowk8_get (unsigned int cpu) | |||
1253 | if (!data) | 1258 | if (!data) |
1254 | return -EINVAL; | 1259 | return -EINVAL; |
1255 | 1260 | ||
1256 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | 1261 | set_cpus_allowed_ptr(current, newmask); |
1257 | if (smp_processor_id() != cpu) { | 1262 | if (smp_processor_id() != cpu) { |
1258 | printk(KERN_ERR PFX | 1263 | printk(KERN_ERR PFX |
1259 | "limiting to CPU %d failed in powernowk8_get\n", cpu); | 1264 | "limiting to CPU %d failed in powernowk8_get\n", cpu); |
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 | } |
diff --git a/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c b/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c index 191f7263c61d..2f3728dc24f6 100644 --- a/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c +++ b/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c | |||
@@ -244,7 +244,8 @@ static unsigned int _speedstep_get(const cpumask_t *cpus) | |||
244 | 244 | ||
245 | static unsigned int speedstep_get(unsigned int cpu) | 245 | static unsigned int speedstep_get(unsigned int cpu) |
246 | { | 246 | { |
247 | return _speedstep_get(&cpumask_of_cpu(cpu)); | 247 | cpumask_of_cpu_ptr(newmask, cpu); |
248 | return _speedstep_get(newmask); | ||
248 | } | 249 | } |
249 | 250 | ||
250 | /** | 251 | /** |
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c index a7b0f8f1736b..e4b8d189d7ed 100644 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c | |||
@@ -516,6 +516,7 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu) | |||
516 | unsigned long j; | 516 | unsigned long j; |
517 | int retval; | 517 | int retval; |
518 | cpumask_t oldmask; | 518 | cpumask_t oldmask; |
519 | cpumask_of_cpu_ptr(newmask, cpu); | ||
519 | 520 | ||
520 | if (num_cache_leaves == 0) | 521 | if (num_cache_leaves == 0) |
521 | return -ENOENT; | 522 | return -ENOENT; |
@@ -526,7 +527,7 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu) | |||
526 | return -ENOMEM; | 527 | return -ENOMEM; |
527 | 528 | ||
528 | oldmask = current->cpus_allowed; | 529 | oldmask = current->cpus_allowed; |
529 | retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | 530 | retval = set_cpus_allowed_ptr(current, newmask); |
530 | if (retval) | 531 | if (retval) |
531 | goto out; | 532 | goto out; |
532 | 533 | ||
diff --git a/arch/x86/kernel/microcode.c b/arch/x86/kernel/microcode.c index 56b933119a04..58520169e35d 100644 --- a/arch/x86/kernel/microcode.c +++ b/arch/x86/kernel/microcode.c | |||
@@ -388,6 +388,7 @@ static int do_microcode_update (void) | |||
388 | void *new_mc = NULL; | 388 | void *new_mc = NULL; |
389 | int cpu; | 389 | int cpu; |
390 | cpumask_t old; | 390 | cpumask_t old; |
391 | cpumask_of_cpu_ptr_declare(newmask); | ||
391 | 392 | ||
392 | old = current->cpus_allowed; | 393 | old = current->cpus_allowed; |
393 | 394 | ||
@@ -404,7 +405,8 @@ static int do_microcode_update (void) | |||
404 | 405 | ||
405 | if (!uci->valid) | 406 | if (!uci->valid) |
406 | continue; | 407 | continue; |
407 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | 408 | cpumask_of_cpu_ptr_next(newmask, cpu); |
409 | set_cpus_allowed_ptr(current, newmask); | ||
408 | error = get_maching_microcode(new_mc, cpu); | 410 | error = get_maching_microcode(new_mc, cpu); |
409 | if (error < 0) | 411 | if (error < 0) |
410 | goto out; | 412 | goto out; |
@@ -574,6 +576,7 @@ static int apply_microcode_check_cpu(int cpu) | |||
574 | struct cpuinfo_x86 *c = &cpu_data(cpu); | 576 | struct cpuinfo_x86 *c = &cpu_data(cpu); |
575 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu; | 577 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu; |
576 | cpumask_t old; | 578 | cpumask_t old; |
579 | cpumask_of_cpu_ptr(newmask, cpu); | ||
577 | unsigned int val[2]; | 580 | unsigned int val[2]; |
578 | int err = 0; | 581 | int err = 0; |
579 | 582 | ||
@@ -582,7 +585,7 @@ static int apply_microcode_check_cpu(int cpu) | |||
582 | return 0; | 585 | return 0; |
583 | 586 | ||
584 | old = current->cpus_allowed; | 587 | old = current->cpus_allowed; |
585 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | 588 | set_cpus_allowed_ptr(current, newmask); |
586 | 589 | ||
587 | /* Check if the microcode we have in memory matches the CPU */ | 590 | /* Check if the microcode we have in memory matches the CPU */ |
588 | if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 || | 591 | if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 || |
@@ -620,11 +623,12 @@ static int apply_microcode_check_cpu(int cpu) | |||
620 | static void microcode_init_cpu(int cpu, int resume) | 623 | static void microcode_init_cpu(int cpu, int resume) |
621 | { | 624 | { |
622 | cpumask_t old; | 625 | cpumask_t old; |
626 | cpumask_of_cpu_ptr(newmask, cpu); | ||
623 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu; | 627 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu; |
624 | 628 | ||
625 | old = current->cpus_allowed; | 629 | old = current->cpus_allowed; |
626 | 630 | ||
627 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | 631 | set_cpus_allowed_ptr(current, newmask); |
628 | mutex_lock(µcode_mutex); | 632 | mutex_lock(µcode_mutex); |
629 | collect_cpu_info(cpu); | 633 | collect_cpu_info(cpu); |
630 | if (uci->valid && system_state == SYSTEM_RUNNING && !resume) | 634 | if (uci->valid && system_state == SYSTEM_RUNNING && !resume) |
@@ -656,11 +660,12 @@ static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz) | |||
656 | return -EINVAL; | 660 | return -EINVAL; |
657 | if (val == 1) { | 661 | if (val == 1) { |
658 | cpumask_t old; | 662 | cpumask_t old; |
663 | cpumask_of_cpu_ptr(newmask, cpu); | ||
659 | 664 | ||
660 | old = current->cpus_allowed; | 665 | old = current->cpus_allowed; |
661 | 666 | ||
662 | get_online_cpus(); | 667 | get_online_cpus(); |
663 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | 668 | set_cpus_allowed_ptr(current, newmask); |
664 | 669 | ||
665 | mutex_lock(µcode_mutex); | 670 | mutex_lock(µcode_mutex); |
666 | if (uci->valid) | 671 | if (uci->valid) |
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index f8a62160e151..214bbdfc851e 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c | |||
@@ -403,24 +403,28 @@ void native_machine_shutdown(void) | |||
403 | { | 403 | { |
404 | /* Stop the cpus and apics */ | 404 | /* Stop the cpus and apics */ |
405 | #ifdef CONFIG_SMP | 405 | #ifdef CONFIG_SMP |
406 | int reboot_cpu_id; | ||
407 | 406 | ||
408 | /* The boot cpu is always logical cpu 0 */ | 407 | /* The boot cpu is always logical cpu 0 */ |
409 | reboot_cpu_id = 0; | 408 | int reboot_cpu_id = 0; |
409 | cpumask_of_cpu_ptr(newmask, reboot_cpu_id); | ||
410 | 410 | ||
411 | #ifdef CONFIG_X86_32 | 411 | #ifdef CONFIG_X86_32 |
412 | /* See if there has been given a command line override */ | 412 | /* See if there has been given a command line override */ |
413 | if ((reboot_cpu != -1) && (reboot_cpu < NR_CPUS) && | 413 | if ((reboot_cpu != -1) && (reboot_cpu < NR_CPUS) && |
414 | cpu_online(reboot_cpu)) | 414 | cpu_online(reboot_cpu)) { |
415 | reboot_cpu_id = reboot_cpu; | 415 | reboot_cpu_id = reboot_cpu; |
416 | cpumask_of_cpu_ptr_next(newmask, reboot_cpu_id); | ||
417 | } | ||
416 | #endif | 418 | #endif |
417 | 419 | ||
418 | /* Make certain the cpu I'm about to reboot on is online */ | 420 | /* Make certain the cpu I'm about to reboot on is online */ |
419 | if (!cpu_online(reboot_cpu_id)) | 421 | if (!cpu_online(reboot_cpu_id)) { |
420 | reboot_cpu_id = smp_processor_id(); | 422 | reboot_cpu_id = smp_processor_id(); |
423 | cpumask_of_cpu_ptr_next(newmask, reboot_cpu_id); | ||
424 | } | ||
421 | 425 | ||
422 | /* Make certain I only run on the appropriate processor */ | 426 | /* Make certain I only run on the appropriate processor */ |
423 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(reboot_cpu_id)); | 427 | set_cpus_allowed_ptr(current, newmask); |
424 | 428 | ||
425 | /* O.K Now that I'm on the appropriate processor, | 429 | /* O.K Now that I'm on the appropriate processor, |
426 | * stop all of the others. | 430 | * stop all of the others. |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index a56fc6c4394b..a2c3f9cfa549 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -827,6 +827,7 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) | |||
827 | static int acpi_processor_get_throttling(struct acpi_processor *pr) | 827 | static int acpi_processor_get_throttling(struct acpi_processor *pr) |
828 | { | 828 | { |
829 | cpumask_t saved_mask; | 829 | cpumask_t saved_mask; |
830 | cpumask_of_cpu_ptr_declare(new_mask); | ||
830 | int ret; | 831 | int ret; |
831 | 832 | ||
832 | if (!pr) | 833 | if (!pr) |
@@ -838,7 +839,8 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr) | |||
838 | * Migrate task to the cpu pointed by pr. | 839 | * Migrate task to the cpu pointed by pr. |
839 | */ | 840 | */ |
840 | saved_mask = current->cpus_allowed; | 841 | saved_mask = current->cpus_allowed; |
841 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); | 842 | cpumask_of_cpu_ptr_next(new_mask, pr->id); |
843 | set_cpus_allowed_ptr(current, new_mask); | ||
842 | ret = pr->throttling.acpi_processor_get_throttling(pr); | 844 | ret = pr->throttling.acpi_processor_get_throttling(pr); |
843 | /* restore the previous state */ | 845 | /* restore the previous state */ |
844 | set_cpus_allowed_ptr(current, &saved_mask); | 846 | set_cpus_allowed_ptr(current, &saved_mask); |
@@ -987,6 +989,7 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, | |||
987 | int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | 989 | int acpi_processor_set_throttling(struct acpi_processor *pr, int state) |
988 | { | 990 | { |
989 | cpumask_t saved_mask; | 991 | cpumask_t saved_mask; |
992 | cpumask_of_cpu_ptr_declare(new_mask); | ||
990 | int ret = 0; | 993 | int ret = 0; |
991 | unsigned int i; | 994 | unsigned int i; |
992 | struct acpi_processor *match_pr; | 995 | struct acpi_processor *match_pr; |
@@ -1025,7 +1028,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
1025 | * it can be called only for the cpu pointed by pr. | 1028 | * it can be called only for the cpu pointed by pr. |
1026 | */ | 1029 | */ |
1027 | if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { | 1030 | if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { |
1028 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); | 1031 | cpumask_of_cpu_ptr_next(new_mask, pr->id); |
1032 | set_cpus_allowed_ptr(current, new_mask); | ||
1029 | ret = p_throttling->acpi_processor_set_throttling(pr, | 1033 | ret = p_throttling->acpi_processor_set_throttling(pr, |
1030 | t_state.target_state); | 1034 | t_state.target_state); |
1031 | } else { | 1035 | } else { |
@@ -1056,7 +1060,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
1056 | continue; | 1060 | continue; |
1057 | } | 1061 | } |
1058 | t_state.cpu = i; | 1062 | t_state.cpu = i; |
1059 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(i)); | 1063 | cpumask_of_cpu_ptr_next(new_mask, i); |
1064 | set_cpus_allowed_ptr(current, new_mask); | ||
1060 | ret = match_pr->throttling. | 1065 | ret = match_pr->throttling. |
1061 | acpi_processor_set_throttling( | 1066 | acpi_processor_set_throttling( |
1062 | match_pr, t_state.target_state); | 1067 | match_pr, t_state.target_state); |
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c index 25918f7dfd0f..0b624e927a6f 100644 --- a/drivers/firmware/dcdbas.c +++ b/drivers/firmware/dcdbas.c | |||
@@ -254,6 +254,7 @@ static ssize_t host_control_on_shutdown_store(struct device *dev, | |||
254 | static int smi_request(struct smi_cmd *smi_cmd) | 254 | static int smi_request(struct smi_cmd *smi_cmd) |
255 | { | 255 | { |
256 | cpumask_t old_mask; | 256 | cpumask_t old_mask; |
257 | cpumask_of_cpu_ptr(new_mask, 0); | ||
257 | int ret = 0; | 258 | int ret = 0; |
258 | 259 | ||
259 | if (smi_cmd->magic != SMI_CMD_MAGIC) { | 260 | if (smi_cmd->magic != SMI_CMD_MAGIC) { |
@@ -264,7 +265,7 @@ static int smi_request(struct smi_cmd *smi_cmd) | |||
264 | 265 | ||
265 | /* SMI requires CPU 0 */ | 266 | /* SMI requires CPU 0 */ |
266 | old_mask = current->cpus_allowed; | 267 | old_mask = current->cpus_allowed; |
267 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(0)); | 268 | set_cpus_allowed_ptr(current, new_mask); |
268 | if (smp_processor_id() != 0) { | 269 | if (smp_processor_id() != 0) { |
269 | dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n", | 270 | dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n", |
270 | __func__); | 271 | __func__); |
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 80226e776143..2dbd9a287e77 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
@@ -62,6 +62,15 @@ | |||
62 | * int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids | 62 | * int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids |
63 | * | 63 | * |
64 | * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set | 64 | * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set |
65 | *ifdef CONFIG_HAS_CPUMASK_OF_CPU | ||
66 | * cpumask_of_cpu_ptr_declare(v) Declares cpumask_t *v | ||
67 | * cpumask_of_cpu_ptr_next(v, cpu) Sets v = &cpumask_of_cpu_map[cpu] | ||
68 | * cpumask_of_cpu_ptr(v, cpu) Combines above two operations | ||
69 | *else | ||
70 | * cpumask_of_cpu_ptr_declare(v) Declares cpumask_t _v and *v = &_v | ||
71 | * cpumask_of_cpu_ptr_next(v, cpu) Sets _v = cpumask_of_cpu(cpu) | ||
72 | * cpumask_of_cpu_ptr(v, cpu) Combines above two operations | ||
73 | *endif | ||
65 | * CPU_MASK_ALL Initializer - all bits set | 74 | * CPU_MASK_ALL Initializer - all bits set |
66 | * CPU_MASK_NONE Initializer - no bits set | 75 | * CPU_MASK_NONE Initializer - no bits set |
67 | * unsigned long *cpus_addr(mask) Array of unsigned long's in mask | 76 | * unsigned long *cpus_addr(mask) Array of unsigned long's in mask |
@@ -236,11 +245,16 @@ static inline void __cpus_shift_left(cpumask_t *dstp, | |||
236 | 245 | ||
237 | #ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP | 246 | #ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP |
238 | extern cpumask_t *cpumask_of_cpu_map; | 247 | extern cpumask_t *cpumask_of_cpu_map; |
239 | #define cpumask_of_cpu(cpu) (cpumask_of_cpu_map[cpu]) | 248 | #define cpumask_of_cpu(cpu) (cpumask_of_cpu_map[cpu]) |
240 | 249 | #define cpumask_of_cpu_ptr(v, cpu) \ | |
250 | const cpumask_t *v = &cpumask_of_cpu(cpu) | ||
251 | #define cpumask_of_cpu_ptr_declare(v) \ | ||
252 | const cpumask_t *v | ||
253 | #define cpumask_of_cpu_ptr_next(v, cpu) \ | ||
254 | v = &cpumask_of_cpu(cpu) | ||
241 | #else | 255 | #else |
242 | #define cpumask_of_cpu(cpu) \ | 256 | #define cpumask_of_cpu(cpu) \ |
243 | (*({ \ | 257 | ({ \ |
244 | typeof(_unused_cpumask_arg_) m; \ | 258 | typeof(_unused_cpumask_arg_) m; \ |
245 | if (sizeof(m) == sizeof(unsigned long)) { \ | 259 | if (sizeof(m) == sizeof(unsigned long)) { \ |
246 | m.bits[0] = 1UL<<(cpu); \ | 260 | m.bits[0] = 1UL<<(cpu); \ |
@@ -248,8 +262,16 @@ extern cpumask_t *cpumask_of_cpu_map; | |||
248 | cpus_clear(m); \ | 262 | cpus_clear(m); \ |
249 | cpu_set((cpu), m); \ | 263 | cpu_set((cpu), m); \ |
250 | } \ | 264 | } \ |
251 | &m; \ | 265 | m; \ |
252 | })) | 266 | }) |
267 | #define cpumask_of_cpu_ptr(v, cpu) \ | ||
268 | cpumask_t _##v = cpumask_of_cpu(cpu); \ | ||
269 | const cpumask_t *v = &_##v | ||
270 | #define cpumask_of_cpu_ptr_declare(v) \ | ||
271 | cpumask_t _##v; \ | ||
272 | const cpumask_t *v = &_##v | ||
273 | #define cpumask_of_cpu_ptr_next(v, cpu) \ | ||
274 | _##v = cpumask_of_cpu(cpu) | ||
253 | #endif | 275 | #endif |
254 | 276 | ||
255 | #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS) | 277 | #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS) |
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index ba9b2054ecbd..738b411ff2d3 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
@@ -33,8 +33,9 @@ static int stopmachine(void *cpu) | |||
33 | { | 33 | { |
34 | int irqs_disabled = 0; | 34 | int irqs_disabled = 0; |
35 | int prepared = 0; | 35 | int prepared = 0; |
36 | cpumask_of_cpu_ptr(cpumask, (int)(long)cpu); | ||
36 | 37 | ||
37 | set_cpus_allowed_ptr(current, &cpumask_of_cpu((int)(long)cpu)); | 38 | set_cpus_allowed_ptr(current, cpumask); |
38 | 39 | ||
39 | /* Ack: we are alive */ | 40 | /* Ack: we are alive */ |
40 | smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ | 41 | smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ |
diff --git a/kernel/trace/trace_sysprof.c b/kernel/trace/trace_sysprof.c index 2301e1e7c606..63528086337c 100644 --- a/kernel/trace/trace_sysprof.c +++ b/kernel/trace/trace_sysprof.c | |||
@@ -213,7 +213,9 @@ static void start_stack_timers(void) | |||
213 | int cpu; | 213 | int cpu; |
214 | 214 | ||
215 | for_each_online_cpu(cpu) { | 215 | for_each_online_cpu(cpu) { |
216 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | 216 | cpumask_of_cpu_ptr(new_mask, cpu); |
217 | |||
218 | set_cpus_allowed_ptr(current, new_mask); | ||
217 | start_stack_timer(cpu); | 219 | start_stack_timer(cpu); |
218 | } | 220 | } |
219 | set_cpus_allowed_ptr(current, &saved_mask); | 221 | set_cpus_allowed_ptr(current, &saved_mask); |
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index d43cf8ddff67..083d12688134 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c | |||
@@ -314,9 +314,10 @@ svc_pool_map_set_cpumask(unsigned int pidx, cpumask_t *oldmask) | |||
314 | case SVC_POOL_PERCPU: | 314 | case SVC_POOL_PERCPU: |
315 | { | 315 | { |
316 | unsigned int cpu = m->pool_to[pidx]; | 316 | unsigned int cpu = m->pool_to[pidx]; |
317 | cpumask_of_cpu_ptr(cpumask, cpu); | ||
317 | 318 | ||
318 | *oldmask = current->cpus_allowed; | 319 | *oldmask = current->cpus_allowed; |
319 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | 320 | set_cpus_allowed_ptr(current, cpumask); |
320 | return 1; | 321 | return 1; |
321 | } | 322 | } |
322 | case SVC_POOL_PERNODE: | 323 | case SVC_POOL_PERNODE: |