Merge branch 'cpus4096-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'cpus4096-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
cpu masks: optimize and clean up cpumask_of_cpu()
cpumask: export cpumask_of_cpu_map
cpumask: change cpumask_of_cpu_ptr to use new cpumask_of_cpu
cpumask: put cpumask_of_cpu_map in the initdata section
cpumask: make cpumask_of_cpu_map generic

+85 -141
+1 -2
arch/x86/kernel/acpi/cstate.c
··· 73 struct cpuinfo_x86 *c = &cpu_data(cpu); 74 75 cpumask_t saved_mask; 76 - cpumask_of_cpu_ptr(new_mask, cpu); 77 int retval; 78 unsigned int eax, ebx, ecx, edx; 79 unsigned int edx_part; ··· 91 92 /* Make sure we are running on right CPU */ 93 saved_mask = current->cpus_allowed; 94 - retval = set_cpus_allowed_ptr(current, new_mask); 95 if (retval) 96 return -1; 97
··· 73 struct cpuinfo_x86 *c = &cpu_data(cpu); 74 75 cpumask_t saved_mask; 76 int retval; 77 unsigned int eax, ebx, ecx, edx; 78 unsigned int edx_part; ··· 92 93 /* Make sure we are running on right CPU */ 94 saved_mask = current->cpus_allowed; 95 + retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 96 if (retval) 97 return -1; 98
+3 -7
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
··· 200 static void drv_write(struct drv_cmd *cmd) 201 { 202 cpumask_t saved_mask = current->cpus_allowed; 203 - cpumask_of_cpu_ptr_declare(cpu_mask); 204 unsigned int i; 205 206 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); 209 do_drv_write(cmd); 210 } 211 ··· 267 } aperf_cur, mperf_cur; 268 269 cpumask_t saved_mask; 270 - cpumask_of_cpu_ptr(cpu_mask, cpu); 271 unsigned int perf_percent; 272 unsigned int retval; 273 274 saved_mask = current->cpus_allowed; 275 - set_cpus_allowed_ptr(current, cpu_mask); 276 if (get_cpu() != cpu) { 277 /* We were not able to run on requested processor */ 278 put_cpu(); ··· 337 338 static unsigned int get_cur_freq_on_cpu(unsigned int cpu) 339 { 340 - cpumask_of_cpu_ptr(cpu_mask, cpu); 341 struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu); 342 unsigned int freq; 343 unsigned int cached_freq; ··· 349 } 350 351 cached_freq = data->freq_table[data->acpi_data->state].frequency; 352 - freq = extract_freq(get_cur_val(cpu_mask), data); 353 if (freq != cached_freq) { 354 /* 355 * The dreaded BIOS frequency change behind our back.
··· 200 static void drv_write(struct drv_cmd *cmd) 201 { 202 cpumask_t saved_mask = current->cpus_allowed; 203 unsigned int i; 204 205 for_each_cpu_mask_nr(i, cmd->mask) { 206 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(i)); 207 do_drv_write(cmd); 208 } 209 ··· 269 } aperf_cur, mperf_cur; 270 271 cpumask_t saved_mask; 272 unsigned int perf_percent; 273 unsigned int retval; 274 275 saved_mask = current->cpus_allowed; 276 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 277 if (get_cpu() != cpu) { 278 /* We were not able to run on requested processor */ 279 put_cpu(); ··· 340 341 static unsigned int get_cur_freq_on_cpu(unsigned int cpu) 342 { 343 struct acpi_cpufreq_data *data = per_cpu(drv_data, cpu); 344 unsigned int freq; 345 unsigned int cached_freq; ··· 353 } 354 355 cached_freq = data->freq_table[data->acpi_data->state].frequency; 356 + freq = extract_freq(get_cur_val(&cpumask_of_cpu(cpu)), data); 357 if (freq != cached_freq) { 358 /* 359 * The dreaded BIOS frequency change behind our back.
+5 -10
arch/x86/kernel/cpu/cpufreq/powernow-k8.c
··· 479 static int check_supported_cpu(unsigned int cpu) 480 { 481 cpumask_t oldmask; 482 - cpumask_of_cpu_ptr(cpu_mask, cpu); 483 u32 eax, ebx, ecx, edx; 484 unsigned int rc = 0; 485 486 oldmask = current->cpus_allowed; 487 - set_cpus_allowed_ptr(current, cpu_mask); 488 489 if (smp_processor_id() != cpu) { 490 printk(KERN_ERR PFX "limiting to cpu %u failed\n", cpu); ··· 1016 static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation) 1017 { 1018 cpumask_t oldmask; 1019 - cpumask_of_cpu_ptr(cpu_mask, pol->cpu); 1020 struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); 1021 u32 checkfid; 1022 u32 checkvid; ··· 1030 1031 /* only run on specific CPU from here on */ 1032 oldmask = current->cpus_allowed; 1033 - set_cpus_allowed_ptr(current, cpu_mask); 1034 1035 if (smp_processor_id() != pol->cpu) { 1036 printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); ··· 1105 { 1106 struct powernow_k8_data *data; 1107 cpumask_t oldmask; 1108 - cpumask_of_cpu_ptr_declare(newmask); 1109 int rc; 1110 1111 if (!cpu_online(pol->cpu)) ··· 1156 1157 /* only run on specific CPU from here on */ 1158 oldmask = current->cpus_allowed; 1159 - cpumask_of_cpu_ptr_next(newmask, pol->cpu); 1160 - set_cpus_allowed_ptr(current, newmask); 1161 1162 if (smp_processor_id() != pol->cpu) { 1163 printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); ··· 1178 set_cpus_allowed_ptr(current, &oldmask); 1179 1180 if (cpu_family == CPU_HW_PSTATE) 1181 - pol->cpus = *newmask; 1182 else 1183 pol->cpus = per_cpu(cpu_core_map, pol->cpu); 1184 data->available_cores = &(pol->cpus); ··· 1244 { 1245 struct powernow_k8_data *data; 1246 cpumask_t oldmask = current->cpus_allowed; 1247 - cpumask_of_cpu_ptr(newmask, cpu); 1248 unsigned int khz = 0; 1249 unsigned int first; 1250 ··· 1253 if (!data) 1254 return -EINVAL; 1255 1256 - set_cpus_allowed_ptr(current, newmask); 1257 if (smp_processor_id() != cpu) { 1258 printk(KERN_ERR PFX 1259 "limiting to CPU %d failed in powernowk8_get\n", cpu);
··· 479 static int check_supported_cpu(unsigned int cpu) 480 { 481 cpumask_t oldmask; 482 u32 eax, ebx, ecx, edx; 483 unsigned int rc = 0; 484 485 oldmask = current->cpus_allowed; 486 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 487 488 if (smp_processor_id() != cpu) { 489 printk(KERN_ERR PFX "limiting to cpu %u failed\n", cpu); ··· 1017 static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsigned relation) 1018 { 1019 cpumask_t oldmask; 1020 struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); 1021 u32 checkfid; 1022 u32 checkvid; ··· 1032 1033 /* only run on specific CPU from here on */ 1034 oldmask = current->cpus_allowed; 1035 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu)); 1036 1037 if (smp_processor_id() != pol->cpu) { 1038 printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); ··· 1107 { 1108 struct powernow_k8_data *data; 1109 cpumask_t oldmask; 1110 int rc; 1111 1112 if (!cpu_online(pol->cpu)) ··· 1159 1160 /* only run on specific CPU from here on */ 1161 oldmask = current->cpus_allowed; 1162 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu)); 1163 1164 if (smp_processor_id() != pol->cpu) { 1165 printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); ··· 1182 set_cpus_allowed_ptr(current, &oldmask); 1183 1184 if (cpu_family == CPU_HW_PSTATE) 1185 + pol->cpus = cpumask_of_cpu(pol->cpu); 1186 else 1187 pol->cpus = per_cpu(cpu_core_map, pol->cpu); 1188 data->available_cores = &(pol->cpus); ··· 1248 { 1249 struct powernow_k8_data *data; 1250 cpumask_t oldmask = current->cpus_allowed; 1251 unsigned int khz = 0; 1252 unsigned int first; 1253 ··· 1258 if (!data) 1259 return -EINVAL; 1260 1261 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 1262 if (smp_processor_id() != cpu) { 1263 printk(KERN_ERR PFX 1264 "limiting to CPU %d failed in powernowk8_get\n", cpu);
+4 -8
arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
··· 324 unsigned l, h; 325 unsigned clock_freq; 326 cpumask_t saved_mask; 327 - cpumask_of_cpu_ptr(new_mask, cpu); 328 329 saved_mask = current->cpus_allowed; 330 - set_cpus_allowed_ptr(current, new_mask); 331 if (smp_processor_id() != cpu) 332 return 0; 333 ··· 584 * Best effort undo.. 585 */ 586 587 - if (!cpus_empty(*covered_cpus)) { 588 - cpumask_of_cpu_ptr_declare(new_mask); 589 - 590 for_each_cpu_mask_nr(j, *covered_cpus) { 591 - cpumask_of_cpu_ptr_next(new_mask, j); 592 - set_cpus_allowed_ptr(current, new_mask); 593 wrmsr(MSR_IA32_PERF_CTL, oldmsr, h); 594 } 595 - } 596 597 tmp = freqs.new; 598 freqs.new = freqs.old;
··· 324 unsigned l, h; 325 unsigned clock_freq; 326 cpumask_t saved_mask; 327 328 saved_mask = current->cpus_allowed; 329 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 330 if (smp_processor_id() != cpu) 331 return 0; 332 ··· 585 * Best effort undo.. 586 */ 587 588 + if (!cpus_empty(*covered_cpus)) 589 for_each_cpu_mask_nr(j, *covered_cpus) { 590 + set_cpus_allowed_ptr(current, 591 + &cpumask_of_cpu(j)); 592 wrmsr(MSR_IA32_PERF_CTL, oldmsr, h); 593 } 594 595 tmp = freqs.new; 596 freqs.new = freqs.old;
+1 -2
arch/x86/kernel/cpu/cpufreq/speedstep-ich.c
··· 244 245 static unsigned int speedstep_get(unsigned int cpu) 246 { 247 - cpumask_of_cpu_ptr(newmask, cpu); 248 - return _speedstep_get(newmask); 249 } 250 251 /**
··· 244 245 static unsigned int speedstep_get(unsigned int cpu) 246 { 247 + return _speedstep_get(&cpumask_of_cpu(cpu)); 248 } 249 250 /**
+1 -2
arch/x86/kernel/cpu/intel_cacheinfo.c
··· 516 unsigned long j; 517 int retval; 518 cpumask_t oldmask; 519 - cpumask_of_cpu_ptr(newmask, cpu); 520 521 if (num_cache_leaves == 0) 522 return -ENOENT; ··· 526 return -ENOMEM; 527 528 oldmask = current->cpus_allowed; 529 - retval = set_cpus_allowed_ptr(current, newmask); 530 if (retval) 531 goto out; 532
··· 516 unsigned long j; 517 int retval; 518 cpumask_t oldmask; 519 520 if (num_cache_leaves == 0) 521 return -ENOENT; ··· 527 return -ENOMEM; 528 529 oldmask = current->cpus_allowed; 530 + retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 531 if (retval) 532 goto out; 533
+2 -4
arch/x86/kernel/ldt.c
··· 62 63 if (reload) { 64 #ifdef CONFIG_SMP 65 - cpumask_of_cpu_ptr_declare(mask); 66 - 67 preempt_disable(); 68 load_LDT(pc); 69 - cpumask_of_cpu_ptr_next(mask, smp_processor_id()); 70 - if (!cpus_equal(current->mm->cpu_vm_mask, *mask)) 71 smp_call_function(flush_ldt, current->mm, 1); 72 preempt_enable(); 73 #else
··· 62 63 if (reload) { 64 #ifdef CONFIG_SMP 65 preempt_disable(); 66 load_LDT(pc); 67 + if (!cpus_equal(current->mm->cpu_vm_mask, 68 + cpumask_of_cpu(smp_processor_id()))) 69 smp_call_function(flush_ldt, current->mm, 1); 70 preempt_enable(); 71 #else
+5 -12
arch/x86/kernel/microcode.c
··· 388 void *new_mc = NULL; 389 int cpu; 390 cpumask_t old; 391 - cpumask_of_cpu_ptr_declare(newmask); 392 393 old = current->cpus_allowed; 394 ··· 404 405 if (!uci->valid) 406 continue; 407 - cpumask_of_cpu_ptr_next(newmask, cpu); 408 - set_cpus_allowed_ptr(current, newmask); 409 error = get_maching_microcode(new_mc, cpu); 410 if (error < 0) 411 goto out; ··· 574 struct cpuinfo_x86 *c = &cpu_data(cpu); 575 struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 576 cpumask_t old; 577 - cpumask_of_cpu_ptr(newmask, cpu); 578 unsigned int val[2]; 579 int err = 0; 580 ··· 582 return 0; 583 584 old = current->cpus_allowed; 585 - set_cpus_allowed_ptr(current, newmask); 586 587 /* Check if the microcode we have in memory matches the CPU */ 588 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 || ··· 620 static void microcode_init_cpu(int cpu, int resume) 621 { 622 cpumask_t old; 623 - cpumask_of_cpu_ptr(newmask, cpu); 624 struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 625 626 old = current->cpus_allowed; 627 628 - set_cpus_allowed_ptr(current, newmask); 629 mutex_lock(&microcode_mutex); 630 collect_cpu_info(cpu); 631 if (uci->valid && system_state == SYSTEM_RUNNING && !resume) ··· 657 if (end == buf) 658 return -EINVAL; 659 if (val == 1) { 660 - cpumask_t old; 661 - cpumask_of_cpu_ptr(newmask, cpu); 662 - 663 - old = current->cpus_allowed; 664 665 get_online_cpus(); 666 - set_cpus_allowed_ptr(current, newmask); 667 668 mutex_lock(&microcode_mutex); 669 if (uci->valid)
··· 388 void *new_mc = NULL; 389 int cpu; 390 cpumask_t old; 391 392 old = current->cpus_allowed; 393 ··· 405 406 if (!uci->valid) 407 continue; 408 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 409 error = get_maching_microcode(new_mc, cpu); 410 if (error < 0) 411 goto out; ··· 576 struct cpuinfo_x86 *c = &cpu_data(cpu); 577 struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 578 cpumask_t old; 579 unsigned int val[2]; 580 int err = 0; 581 ··· 585 return 0; 586 587 old = current->cpus_allowed; 588 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 589 590 /* Check if the microcode we have in memory matches the CPU */ 591 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 || ··· 623 static void microcode_init_cpu(int cpu, int resume) 624 { 625 cpumask_t old; 626 struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 627 628 old = current->cpus_allowed; 629 630 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 631 mutex_lock(&microcode_mutex); 632 collect_cpu_info(cpu); 633 if (uci->valid && system_state == SYSTEM_RUNNING && !resume) ··· 661 if (end == buf) 662 return -EINVAL; 663 if (val == 1) { 664 + cpumask_t old = current->cpus_allowed; 665 666 get_online_cpus(); 667 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 668 669 mutex_lock(&microcode_mutex); 670 if (uci->valid)
+3 -8
arch/x86/kernel/reboot.c
··· 414 415 /* The boot cpu is always logical cpu 0 */ 416 int reboot_cpu_id = 0; 417 - cpumask_of_cpu_ptr(newmask, reboot_cpu_id); 418 419 #ifdef CONFIG_X86_32 420 /* See if there has been given a command line override */ 421 if ((reboot_cpu != -1) && (reboot_cpu < NR_CPUS) && 422 - cpu_online(reboot_cpu)) { 423 reboot_cpu_id = reboot_cpu; 424 - cpumask_of_cpu_ptr_next(newmask, reboot_cpu_id); 425 - } 426 #endif 427 428 /* Make certain the cpu I'm about to reboot on is online */ 429 - if (!cpu_online(reboot_cpu_id)) { 430 reboot_cpu_id = smp_processor_id(); 431 - cpumask_of_cpu_ptr_next(newmask, reboot_cpu_id); 432 - } 433 434 /* Make certain I only run on the appropriate processor */ 435 - set_cpus_allowed_ptr(current, newmask); 436 437 /* O.K Now that I'm on the appropriate processor, 438 * stop all of the others.
··· 414 415 /* The boot cpu is always logical cpu 0 */ 416 int reboot_cpu_id = 0; 417 418 #ifdef CONFIG_X86_32 419 /* See if there has been given a command line override */ 420 if ((reboot_cpu != -1) && (reboot_cpu < NR_CPUS) && 421 + cpu_online(reboot_cpu)) 422 reboot_cpu_id = reboot_cpu; 423 #endif 424 425 /* Make certain the cpu I'm about to reboot on is online */ 426 + if (!cpu_online(reboot_cpu_id)) 427 reboot_cpu_id = smp_processor_id(); 428 429 /* Make certain I only run on the appropriate processor */ 430 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(reboot_cpu_id)); 431 432 /* O.K Now that I'm on the appropriate processor, 433 * stop all of the others.
-21
arch/x86/kernel/setup_percpu.c
··· 80 #endif 81 } 82 83 - #ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP 84 - cpumask_t *cpumask_of_cpu_map __read_mostly; 85 - EXPORT_SYMBOL(cpumask_of_cpu_map); 86 - 87 - /* requires nr_cpu_ids to be initialized */ 88 - static void __init setup_cpumask_of_cpu(void) 89 - { 90 - int i; 91 - 92 - /* alloc_bootmem zeroes memory */ 93 - cpumask_of_cpu_map = alloc_bootmem_low(sizeof(cpumask_t) * nr_cpu_ids); 94 - for (i = 0; i < nr_cpu_ids; i++) 95 - cpu_set(i, cpumask_of_cpu_map[i]); 96 - } 97 - #else 98 - static inline void setup_cpumask_of_cpu(void) { } 99 - #endif 100 - 101 #ifdef CONFIG_X86_32 102 /* 103 * Great future not-so-futuristic plan: make i386 and x86_64 do it ··· 179 180 /* Setup node to cpumask map */ 181 setup_node_to_cpumask_map(); 182 - 183 - /* Setup cpumask_of_cpu map */ 184 - setup_cpumask_of_cpu(); 185 } 186 187 #endif
··· 80 #endif 81 } 82 83 #ifdef CONFIG_X86_32 84 /* 85 * Great future not-so-futuristic plan: make i386 and x86_64 do it ··· 197 198 /* Setup node to cpumask map */ 199 setup_node_to_cpumask_map(); 200 } 201 202 #endif
+3 -8
drivers/acpi/processor_throttling.c
··· 827 static int acpi_processor_get_throttling(struct acpi_processor *pr) 828 { 829 cpumask_t saved_mask; 830 - cpumask_of_cpu_ptr_declare(new_mask); 831 int ret; 832 833 if (!pr) ··· 838 * Migrate task to the cpu pointed by pr. 839 */ 840 saved_mask = current->cpus_allowed; 841 - cpumask_of_cpu_ptr_next(new_mask, pr->id); 842 - set_cpus_allowed_ptr(current, new_mask); 843 ret = pr->throttling.acpi_processor_get_throttling(pr); 844 /* restore the previous state */ 845 set_cpus_allowed_ptr(current, &saved_mask); ··· 987 int acpi_processor_set_throttling(struct acpi_processor *pr, int state) 988 { 989 cpumask_t saved_mask; 990 - cpumask_of_cpu_ptr_declare(new_mask); 991 int ret = 0; 992 unsigned int i; 993 struct acpi_processor *match_pr; ··· 1025 * it can be called only for the cpu pointed by pr. 1026 */ 1027 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { 1028 - cpumask_of_cpu_ptr_next(new_mask, pr->id); 1029 - set_cpus_allowed_ptr(current, new_mask); 1030 ret = p_throttling->acpi_processor_set_throttling(pr, 1031 t_state.target_state); 1032 } else { ··· 1056 continue; 1057 } 1058 t_state.cpu = i; 1059 - cpumask_of_cpu_ptr_next(new_mask, i); 1060 - set_cpus_allowed_ptr(current, new_mask); 1061 ret = match_pr->throttling. 1062 acpi_processor_set_throttling( 1063 match_pr, t_state.target_state);
··· 827 static int acpi_processor_get_throttling(struct acpi_processor *pr) 828 { 829 cpumask_t saved_mask; 830 int ret; 831 832 if (!pr) ··· 839 * Migrate task to the cpu pointed by pr. 840 */ 841 saved_mask = current->cpus_allowed; 842 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); 843 ret = pr->throttling.acpi_processor_get_throttling(pr); 844 /* restore the previous state */ 845 set_cpus_allowed_ptr(current, &saved_mask); ··· 989 int acpi_processor_set_throttling(struct acpi_processor *pr, int state) 990 { 991 cpumask_t saved_mask; 992 int ret = 0; 993 unsigned int i; 994 struct acpi_processor *match_pr; ··· 1028 * it can be called only for the cpu pointed by pr. 1029 */ 1030 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { 1031 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); 1032 ret = p_throttling->acpi_processor_set_throttling(pr, 1033 t_state.target_state); 1034 } else { ··· 1060 continue; 1061 } 1062 t_state.cpu = i; 1063 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(i)); 1064 ret = match_pr->throttling. 1065 acpi_processor_set_throttling( 1066 match_pr, t_state.target_state);
+1 -2
drivers/firmware/dcdbas.c
··· 245 static int smi_request(struct smi_cmd *smi_cmd) 246 { 247 cpumask_t old_mask; 248 - cpumask_of_cpu_ptr(new_mask, 0); 249 int ret = 0; 250 251 if (smi_cmd->magic != SMI_CMD_MAGIC) { ··· 255 256 /* SMI requires CPU 0 */ 257 old_mask = current->cpus_allowed; 258 - set_cpus_allowed_ptr(current, new_mask); 259 if (smp_processor_id() != 0) { 260 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n", 261 __func__);
··· 245 static int smi_request(struct smi_cmd *smi_cmd) 246 { 247 cpumask_t old_mask; 248 int ret = 0; 249 250 if (smi_cmd->magic != SMI_CMD_MAGIC) { ··· 256 257 /* SMI requires CPU 0 */ 258 old_mask = current->cpus_allowed; 259 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(0)); 260 if (smp_processor_id() != 0) { 261 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n", 262 __func__);
+1 -2
drivers/misc/sgi-xp/xpc_main.c
··· 229 int last_IRQ_count = 0; 230 int new_IRQ_count; 231 int force_IRQ = 0; 232 - cpumask_of_cpu_ptr(cpumask, XPC_HB_CHECK_CPU); 233 234 /* this thread was marked active by xpc_hb_init() */ 235 236 - set_cpus_allowed_ptr(current, cpumask); 237 238 /* set our heartbeating to other partitions into motion */ 239 xpc_hb_check_timeout = jiffies + (xpc_hb_check_interval * HZ);
··· 229 int last_IRQ_count = 0; 230 int new_IRQ_count; 231 int force_IRQ = 0; 232 233 /* this thread was marked active by xpc_hb_init() */ 234 235 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(XPC_HB_CHECK_CPU)); 236 237 /* set our heartbeating to other partitions into motion */ 238 xpc_hb_check_timeout = jiffies + (xpc_hb_check_interval * HZ);
+24 -39
include/linux/cpumask.h
··· 62 * int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids 63 * 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 74 * CPU_MASK_ALL Initializer - all bits set 75 * CPU_MASK_NONE Initializer - no bits set 76 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask ··· 265 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits); 266 } 267 268 269 - #ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP 270 - extern cpumask_t *cpumask_of_cpu_map; 271 - #define cpumask_of_cpu(cpu) (cpumask_of_cpu_map[cpu]) 272 - #define cpumask_of_cpu_ptr(v, cpu) \ 273 - const cpumask_t *v = &cpumask_of_cpu(cpu) 274 - #define cpumask_of_cpu_ptr_declare(v) \ 275 - const cpumask_t *v 276 - #define cpumask_of_cpu_ptr_next(v, cpu) \ 277 - v = &cpumask_of_cpu(cpu) 278 - #else 279 - #define cpumask_of_cpu(cpu) \ 280 - ({ \ 281 - typeof(_unused_cpumask_arg_) m; \ 282 - if (sizeof(m) == sizeof(unsigned long)) { \ 283 - m.bits[0] = 1UL<<(cpu); \ 284 - } else { \ 285 - cpus_clear(m); \ 286 - cpu_set((cpu), m); \ 287 - } \ 288 - m; \ 289 - }) 290 - #define cpumask_of_cpu_ptr(v, cpu) \ 291 - cpumask_t _##v = cpumask_of_cpu(cpu); \ 292 - const cpumask_t *v = &_##v 293 - #define cpumask_of_cpu_ptr_declare(v) \ 294 - cpumask_t _##v; \ 295 - const cpumask_t *v = &_##v 296 - #define cpumask_of_cpu_ptr_next(v, cpu) \ 297 - _##v = cpumask_of_cpu(cpu) 298 - #endif 299 300 #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS) 301
··· 62 * int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids 63 * 64 * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set 65 + * (can be used as an lvalue) 66 * CPU_MASK_ALL Initializer - all bits set 67 * CPU_MASK_NONE Initializer - no bits set 68 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask ··· 273 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits); 274 } 275 276 + /* 277 + * Special-case data structure for "single bit set only" constant CPU masks. 278 + * 279 + * We pre-generate all the 64 (or 32) possible bit positions, with enough 280 + * padding to the left and the right, and return the constant pointer 281 + * appropriately offset. 282 + */ 283 + extern const unsigned long 284 + cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)]; 285 286 + static inline const cpumask_t *get_cpu_mask(unsigned int cpu) 287 + { 288 + const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG]; 289 + p -= cpu / BITS_PER_LONG; 290 + return (const cpumask_t *)p; 291 + } 292 + 293 + /* 294 + * In cases where we take the address of the cpumask immediately, 295 + * gcc optimizes it out (it's a constant) and there's no huge stack 296 + * variable created: 297 + */ 298 + #define cpumask_of_cpu(cpu) ({ *get_cpu_mask(cpu); }) 299 + 300 301 #define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS) 302
+25
kernel/cpu.c
··· 455 #endif /* CONFIG_PM_SLEEP_SMP */ 456 457 #endif /* CONFIG_SMP */
··· 455 #endif /* CONFIG_PM_SLEEP_SMP */ 456 457 #endif /* CONFIG_SMP */ 458 + 459 + /* 460 + * cpu_bit_bitmap[] is a special, "compressed" data structure that 461 + * represents all NR_CPUS bits binary values of 1<<nr. 462 + * 463 + * It is used by cpumask_of_cpu() to get a constant address to a CPU 464 + * mask value that has a single bit set only. 465 + */ 466 + 467 + /* cpu_bit_bitmap[0] is empty - so we can back into it */ 468 + #define MASK_DECLARE_1(x) [x+1][0] = 1UL << (x) 469 + #define MASK_DECLARE_2(x) MASK_DECLARE_1(x), MASK_DECLARE_1(x+1) 470 + #define MASK_DECLARE_4(x) MASK_DECLARE_2(x), MASK_DECLARE_2(x+2) 471 + #define MASK_DECLARE_8(x) MASK_DECLARE_4(x), MASK_DECLARE_4(x+4) 472 + 473 + const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)] = { 474 + 475 + MASK_DECLARE_8(0), MASK_DECLARE_8(8), 476 + MASK_DECLARE_8(16), MASK_DECLARE_8(24), 477 + #if BITS_PER_LONG > 32 478 + MASK_DECLARE_8(32), MASK_DECLARE_8(40), 479 + MASK_DECLARE_8(48), MASK_DECLARE_8(56), 480 + #endif 481 + }; 482 + EXPORT_SYMBOL_GPL(cpu_bit_bitmap);
+3 -5
kernel/time/tick-common.c
··· 196 struct tick_device *td; 197 int cpu, ret = NOTIFY_OK; 198 unsigned long flags; 199 - cpumask_of_cpu_ptr_declare(cpumask); 200 201 spin_lock_irqsave(&tick_device_lock, flags); 202 203 cpu = smp_processor_id(); 204 - cpumask_of_cpu_ptr_next(cpumask, cpu); 205 if (!cpu_isset(cpu, newdev->cpumask)) 206 goto out_bc; 207 ··· 207 curdev = td->evtdev; 208 209 /* cpu local device ? */ 210 - if (!cpus_equal(newdev->cpumask, *cpumask)) { 211 212 /* 213 * If the cpu affinity of the device interrupt can not ··· 220 * If we have a cpu local device already, do not replace it 221 * by a non cpu local device 222 */ 223 - if (curdev && cpus_equal(curdev->cpumask, *cpumask)) 224 goto out_bc; 225 } 226 ··· 252 curdev = NULL; 253 } 254 clockevents_exchange_device(curdev, newdev); 255 - tick_setup_device(td, newdev, cpu, cpumask); 256 if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) 257 tick_oneshot_notify(); 258
··· 196 struct tick_device *td; 197 int cpu, ret = NOTIFY_OK; 198 unsigned long flags; 199 200 spin_lock_irqsave(&tick_device_lock, flags); 201 202 cpu = smp_processor_id(); 203 if (!cpu_isset(cpu, newdev->cpumask)) 204 goto out_bc; 205 ··· 209 curdev = td->evtdev; 210 211 /* cpu local device ? */ 212 + if (!cpus_equal(newdev->cpumask, cpumask_of_cpu(cpu))) { 213 214 /* 215 * If the cpu affinity of the device interrupt can not ··· 222 * If we have a cpu local device already, do not replace it 223 * by a non cpu local device 224 */ 225 + if (curdev && cpus_equal(curdev->cpumask, cpumask_of_cpu(cpu))) 226 goto out_bc; 227 } 228 ··· 254 curdev = NULL; 255 } 256 clockevents_exchange_device(curdev, newdev); 257 + tick_setup_device(td, newdev, cpu, &cpumask_of_cpu(cpu)); 258 if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) 259 tick_oneshot_notify(); 260
+1 -3
kernel/trace/trace_sysprof.c
··· 213 int cpu; 214 215 for_each_online_cpu(cpu) { 216 - cpumask_of_cpu_ptr(new_mask, cpu); 217 - 218 - set_cpus_allowed_ptr(current, new_mask); 219 start_stack_timer(cpu); 220 } 221 set_cpus_allowed_ptr(current, &saved_mask);
··· 213 int cpu; 214 215 for_each_online_cpu(cpu) { 216 + set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 217 start_stack_timer(cpu); 218 } 219 set_cpus_allowed_ptr(current, &saved_mask);
+1 -4
lib/smp_processor_id.c
··· 11 { 12 unsigned long preempt_count = preempt_count(); 13 int this_cpu = raw_smp_processor_id(); 14 - cpumask_of_cpu_ptr_declare(this_mask); 15 16 if (likely(preempt_count)) 17 goto out; ··· 22 * Kernel threads bound to a single CPU can safely use 23 * smp_processor_id(): 24 */ 25 - cpumask_of_cpu_ptr_next(this_mask, this_cpu); 26 - 27 - if (cpus_equal(current->cpus_allowed, *this_mask)) 28 goto out; 29 30 /*
··· 11 { 12 unsigned long preempt_count = preempt_count(); 13 int this_cpu = raw_smp_processor_id(); 14 15 if (likely(preempt_count)) 16 goto out; ··· 23 * Kernel threads bound to a single CPU can safely use 24 * smp_processor_id(): 25 */ 26 + if (cpus_equal(current->cpus_allowed, cpumask_of_cpu(this_cpu))) 27 goto out; 28 29 /*
+1 -2
net/sunrpc/svc.c
··· 310 switch (m->mode) { 311 case SVC_POOL_PERCPU: 312 { 313 - cpumask_of_cpu_ptr(cpumask, node); 314 - set_cpus_allowed_ptr(task, cpumask); 315 break; 316 } 317 case SVC_POOL_PERNODE:
··· 310 switch (m->mode) { 311 case SVC_POOL_PERCPU: 312 { 313 + set_cpus_allowed_ptr(task, &cpumask_of_cpu(node)); 314 break; 315 } 316 case SVC_POOL_PERNODE: