Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

* 'cpus4096-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
[IA64] fix typo in cpumask_of_pcibus()
x86: fix x86_32 builds for summit and es7000 arch's
cpumask: use work_on_cpu in acpi-cpufreq.c for read_measured_perf_ctrs
cpumask: use work_on_cpu in acpi-cpufreq.c for drv_read and drv_write
cpumask: use cpumask_var_t in acpi-cpufreq.c
cpumask: use work_on_cpu in acpi/cstate.c
cpumask: convert struct cpufreq_policy to cpumask_var_t
cpumask: replace CPUMASK_ALLOC etc with cpumask_var_t
x86: cleanup remaining cpumask_t ops in smpboot code
cpumask: update pci_bus_show_cpuaffinity to use new cpumask API
cpumask: update local_cpus_show to use new cpumask API
ia64: cpumask fix for is_affinity_mask_valid()

+363 -268
+1 -1
arch/ia64/include/asm/irq.h
··· 27 27 } 28 28 29 29 extern void set_irq_affinity_info (unsigned int irq, int dest, int redir); 30 - bool is_affinity_mask_valid(cpumask_var_t cpumask); 30 + bool is_affinity_mask_valid(const struct cpumask *cpumask); 31 31 32 32 #define is_affinity_mask_valid is_affinity_mask_valid 33 33
+1 -1
arch/ia64/include/asm/topology.h
··· 124 124 125 125 #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \ 126 126 cpu_all_mask : \ 127 - cpumask_from_node(pcibus_to_node(bus))) 127 + cpumask_of_node(pcibus_to_node(bus))) 128 128 129 129 #include <asm-generic/topology.h> 130 130
+6 -9
arch/ia64/kernel/irq.c
··· 102 102 103 103 void set_irq_affinity_info (unsigned int irq, int hwid, int redir) 104 104 { 105 - cpumask_t mask = CPU_MASK_NONE; 106 - 107 - cpu_set(cpu_logical_id(hwid), mask); 108 - 109 105 if (irq < NR_IRQS) { 110 - irq_desc[irq].affinity = mask; 106 + cpumask_copy(&irq_desc[irq].affinity, 107 + cpumask_of(cpu_logical_id(hwid))); 111 108 irq_redir[irq] = (char) (redir & 0xff); 112 109 } 113 110 } 114 111 115 - bool is_affinity_mask_valid(cpumask_var_t cpumask) 112 + bool is_affinity_mask_valid(const struct cpumask *cpumask) 116 113 { 117 114 if (ia64_platform_is("sn2")) { 118 115 /* Only allow one CPU to be specified in the smp_affinity mask */ ··· 125 128 unsigned int vectors_in_migration[NR_IRQS]; 126 129 127 130 /* 128 - * Since cpu_online_map is already updated, we just need to check for 131 + * Since cpu_online_mask is already updated, we just need to check for 129 132 * affinity that has zeros 130 133 */ 131 134 static void migrate_irqs(void) ··· 155 158 */ 156 159 vectors_in_migration[irq] = irq; 157 160 158 - new_cpu = any_online_cpu(cpu_online_map); 161 + new_cpu = cpumask_any(cpu_online_mask); 159 162 160 163 /* 161 164 * Al three are essential, currently WARN_ON.. maybe panic? ··· 188 191 * Find a new timesync master 189 192 */ 190 193 if (smp_processor_id() == time_keeper_id) { 191 - time_keeper_id = first_cpu(cpu_online_map); 194 + time_keeper_id = cpumask_first(cpu_online_mask); 192 195 printk ("CPU %d is now promoted to time-keeper master\n", time_keeper_id); 193 196 } 194 197
+2
arch/x86/include/asm/es7000/apic.h
··· 1 1 #ifndef __ASM_ES7000_APIC_H 2 2 #define __ASM_ES7000_APIC_H 3 3 4 + #include <linux/gfp.h> 5 + 4 6 #define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu) 5 7 #define esr_disable (1) 6 8
+29 -3
arch/x86/include/asm/smp.h
··· 18 18 #include <asm/pda.h> 19 19 #include <asm/thread_info.h> 20 20 21 + #ifdef CONFIG_X86_64 22 + 23 + extern cpumask_var_t cpu_callin_mask; 24 + extern cpumask_var_t cpu_callout_mask; 25 + extern cpumask_var_t cpu_initialized_mask; 26 + extern cpumask_var_t cpu_sibling_setup_mask; 27 + 28 + #else /* CONFIG_X86_32 */ 29 + 30 + extern cpumask_t cpu_callin_map; 21 31 extern cpumask_t cpu_callout_map; 22 32 extern cpumask_t cpu_initialized; 23 - extern cpumask_t cpu_callin_map; 33 + extern cpumask_t cpu_sibling_setup_map; 34 + 35 + #define cpu_callin_mask ((struct cpumask *)&cpu_callin_map) 36 + #define cpu_callout_mask ((struct cpumask *)&cpu_callout_map) 37 + #define cpu_initialized_mask ((struct cpumask *)&cpu_initialized) 38 + #define cpu_sibling_setup_mask ((struct cpumask *)&cpu_sibling_setup_map) 39 + 40 + #endif /* CONFIG_X86_32 */ 24 41 25 42 extern void (*mtrr_hook)(void); 26 43 extern void zap_low_mappings(void); ··· 46 29 47 30 extern int smp_num_siblings; 48 31 extern unsigned int num_processors; 49 - extern cpumask_t cpu_initialized; 50 32 51 33 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); 52 34 DECLARE_PER_CPU(cpumask_t, cpu_core_map); ··· 53 37 #ifdef CONFIG_X86_32 54 38 DECLARE_PER_CPU(int, cpu_number); 55 39 #endif 40 + 41 + static inline struct cpumask *cpu_sibling_mask(int cpu) 42 + { 43 + return &per_cpu(cpu_sibling_map, cpu); 44 + } 45 + 46 + static inline struct cpumask *cpu_core_mask(int cpu) 47 + { 48 + return &per_cpu(cpu_core_map, cpu); 49 + } 56 50 57 51 DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); 58 52 DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); ··· 175 149 /* We don't mark CPUs online until __cpu_up(), so we need another measure */ 176 150 static inline int num_booting_cpus(void) 177 151 { 178 - return cpus_weight(cpu_callout_map); 152 + return cpumask_weight(cpu_callout_mask); 179 153 } 180 154 #else 181 155 static inline void prefill_possible_map(void)
+1
arch/x86/include/asm/summit/apic.h
··· 2 2 #define __ASM_SUMMIT_APIC_H 3 3 4 4 #include <asm/smp.h> 5 + #include <linux/gfp.h> 5 6 6 7 #define esr_disable (1) 7 8 #define NO_BALANCE_IRQ (0)
+37 -33
arch/x86/kernel/acpi/cstate.c
··· 67 67 68 68 #define NATIVE_CSTATE_BEYOND_HALT (2) 69 69 70 - int acpi_processor_ffh_cstate_probe(unsigned int cpu, 71 - struct acpi_processor_cx *cx, struct acpi_power_register *reg) 70 + static long acpi_processor_ffh_cstate_probe_cpu(void *_cx) 72 71 { 73 - struct cstate_entry *percpu_entry; 74 - struct cpuinfo_x86 *c = &cpu_data(cpu); 75 - 76 - cpumask_t saved_mask; 77 - int retval; 72 + struct acpi_processor_cx *cx = _cx; 73 + long retval; 78 74 unsigned int eax, ebx, ecx, edx; 79 75 unsigned int edx_part; 80 76 unsigned int cstate_type; /* C-state type and not ACPI C-state type */ 81 77 unsigned int num_cstate_subtype; 82 - 83 - if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF ) 84 - return -1; 85 - 86 - if (reg->bit_offset != NATIVE_CSTATE_BEYOND_HALT) 87 - return -1; 88 - 89 - percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu); 90 - percpu_entry->states[cx->index].eax = 0; 91 - percpu_entry->states[cx->index].ecx = 0; 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 78 99 79 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); 100 80 ··· 96 116 retval = -1; 97 117 goto out; 98 118 } 99 - percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK; 100 - 101 - /* Use the hint in CST */ 102 - percpu_entry->states[cx->index].eax = cx->address; 103 119 104 120 if (!mwait_supported[cstate_type]) { 105 121 mwait_supported[cstate_type] = 1; 106 - printk(KERN_DEBUG "Monitor-Mwait will be used to enter C-%d " 107 - "state\n", cx->type); 122 + printk(KERN_DEBUG 123 + "Monitor-Mwait will be used to enter C-%d " 124 + "state\n", cx->type); 108 125 } 109 - snprintf(cx->desc, ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x", 110 - cx->address); 111 - 126 + snprintf(cx->desc, 127 + ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x", 128 + cx->address); 112 129 out: 113 - set_cpus_allowed_ptr(current, &saved_mask); 130 + return retval; 131 + } 132 + 133 + int acpi_processor_ffh_cstate_probe(unsigned int cpu, 134 + struct acpi_processor_cx *cx, struct acpi_power_register *reg) 135 + { 136 + struct cstate_entry *percpu_entry; 137 + struct cpuinfo_x86 *c = &cpu_data(cpu); 138 + long retval; 139 + 140 + if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF) 141 + return -1; 142 + 143 + if (reg->bit_offset != NATIVE_CSTATE_BEYOND_HALT) 144 + return -1; 145 + 146 + percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu); 147 + percpu_entry->states[cx->index].eax = 0; 148 + percpu_entry->states[cx->index].ecx = 0; 149 + 150 + /* Make sure we are running on right CPU */ 151 + 152 + retval = work_on_cpu(cpu, acpi_processor_ffh_cstate_probe_cpu, cx); 153 + if (retval == 0) { 154 + /* Use the hint in CST */ 155 + percpu_entry->states[cx->index].eax = cx->address; 156 + percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK; 157 + } 114 158 return retval; 115 159 } 116 160 EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe);
+22 -4
arch/x86/kernel/cpu/common.c
··· 40 40 41 41 #include "cpu.h" 42 42 43 + #ifdef CONFIG_X86_64 44 + 45 + /* all of these masks are initialized in setup_cpu_local_masks() */ 46 + cpumask_var_t cpu_callin_mask; 47 + cpumask_var_t cpu_callout_mask; 48 + cpumask_var_t cpu_initialized_mask; 49 + 50 + /* representing cpus for which sibling maps can be computed */ 51 + cpumask_var_t cpu_sibling_setup_mask; 52 + 53 + #else /* CONFIG_X86_32 */ 54 + 55 + cpumask_t cpu_callin_map; 56 + cpumask_t cpu_callout_map; 57 + cpumask_t cpu_initialized; 58 + cpumask_t cpu_sibling_setup_map; 59 + 60 + #endif /* CONFIG_X86_32 */ 61 + 62 + 43 63 static struct cpu_dev *this_cpu __cpuinitdata; 44 64 45 65 #ifdef CONFIG_X86_64 ··· 876 856 } 877 857 __setup("clearcpuid=", setup_disablecpuid); 878 858 879 - cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE; 880 - 881 859 #ifdef CONFIG_X86_64 882 860 struct x8664_pda **_cpu_pda __read_mostly; 883 861 EXPORT_SYMBOL(_cpu_pda); ··· 994 976 995 977 me = current; 996 978 997 - if (cpu_test_and_set(cpu, cpu_initialized)) 979 + if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) 998 980 panic("CPU#%d already initialized!\n", cpu); 999 981 1000 982 printk(KERN_INFO "Initializing CPU#%d\n", cpu); ··· 1103 1085 struct tss_struct *t = &per_cpu(init_tss, cpu); 1104 1086 struct thread_struct *thread = &curr->thread; 1105 1087 1106 - if (cpu_test_and_set(cpu, cpu_initialized)) { 1088 + if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) { 1107 1089 printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); 1108 1090 for (;;) local_irq_enable(); 1109 1091 }
+87 -83
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
··· 145 145 146 146 struct drv_cmd { 147 147 unsigned int type; 148 - cpumask_t mask; 148 + cpumask_var_t mask; 149 149 drv_addr_union addr; 150 150 u32 val; 151 151 }; 152 152 153 - static void do_drv_read(struct drv_cmd *cmd) 153 + static long do_drv_read(void *_cmd) 154 154 { 155 + struct drv_cmd *cmd = _cmd; 155 156 u32 h; 156 157 157 158 switch (cmd->type) { ··· 167 166 default: 168 167 break; 169 168 } 169 + return 0; 170 170 } 171 171 172 - static void do_drv_write(struct drv_cmd *cmd) 172 + static long do_drv_write(void *_cmd) 173 173 { 174 + struct drv_cmd *cmd = _cmd; 174 175 u32 lo, hi; 175 176 176 177 switch (cmd->type) { ··· 189 186 default: 190 187 break; 191 188 } 189 + return 0; 192 190 } 193 191 194 192 static void drv_read(struct drv_cmd *cmd) 195 193 { 196 - cpumask_t saved_mask = current->cpus_allowed; 197 194 cmd->val = 0; 198 195 199 - set_cpus_allowed_ptr(current, &cmd->mask); 200 - do_drv_read(cmd); 201 - set_cpus_allowed_ptr(current, &saved_mask); 196 + work_on_cpu(cpumask_any(cmd->mask), do_drv_read, cmd); 202 197 } 203 198 204 199 static void drv_write(struct drv_cmd *cmd) 205 200 { 206 - cpumask_t saved_mask = current->cpus_allowed; 207 201 unsigned int i; 208 202 209 - for_each_cpu_mask_nr(i, cmd->mask) { 210 - set_cpus_allowed_ptr(current, &cpumask_of_cpu(i)); 211 - do_drv_write(cmd); 203 + for_each_cpu(i, cmd->mask) { 204 + work_on_cpu(i, do_drv_write, cmd); 212 205 } 213 - 214 - set_cpus_allowed_ptr(current, &saved_mask); 215 - return; 216 206 } 217 207 218 - static u32 get_cur_val(const cpumask_t *mask) 208 + static u32 get_cur_val(const struct cpumask *mask) 219 209 { 220 210 struct acpi_processor_performance *perf; 221 211 struct drv_cmd cmd; 222 212 223 - if (unlikely(cpus_empty(*mask))) 213 + if (unlikely(cpumask_empty(mask))) 224 214 return 0; 225 215 226 - switch (per_cpu(drv_data, first_cpu(*mask))->cpu_feature) { 216 + switch (per_cpu(drv_data, cpumask_first(mask))->cpu_feature) { 227 217 case SYSTEM_INTEL_MSR_CAPABLE: 228 218 cmd.type = SYSTEM_INTEL_MSR_CAPABLE; 229 219 cmd.addr.msr.reg = MSR_IA32_PERF_STATUS; 230 220 break; 231 221 case SYSTEM_IO_CAPABLE: 232 222 cmd.type = SYSTEM_IO_CAPABLE; 233 - perf = per_cpu(drv_data, first_cpu(*mask))->acpi_data; 223 + perf = per_cpu(drv_data, cpumask_first(mask))->acpi_data; 234 224 cmd.addr.io.port = perf->control_register.address; 235 225 cmd.addr.io.bit_width = perf->control_register.bit_width; 236 226 break; ··· 231 235 return 0; 232 236 } 233 237 234 - cmd.mask = *mask; 238 + if (unlikely(!alloc_cpumask_var(&cmd.mask, GFP_KERNEL))) 239 + return 0; 240 + 241 + cpumask_copy(cmd.mask, mask); 235 242 236 243 drv_read(&cmd); 244 + 245 + free_cpumask_var(cmd.mask); 237 246 238 247 dprintk("get_cur_val = %u\n", cmd.val); 239 248 240 249 return cmd.val; 250 + } 251 + 252 + struct perf_cur { 253 + union { 254 + struct { 255 + u32 lo; 256 + u32 hi; 257 + } split; 258 + u64 whole; 259 + } aperf_cur, mperf_cur; 260 + }; 261 + 262 + 263 + static long read_measured_perf_ctrs(void *_cur) 264 + { 265 + struct perf_cur *cur = _cur; 266 + 267 + rdmsr(MSR_IA32_APERF, cur->aperf_cur.split.lo, cur->aperf_cur.split.hi); 268 + rdmsr(MSR_IA32_MPERF, cur->mperf_cur.split.lo, cur->mperf_cur.split.hi); 269 + 270 + wrmsr(MSR_IA32_APERF, 0, 0); 271 + wrmsr(MSR_IA32_MPERF, 0, 0); 272 + 273 + return 0; 241 274 } 242 275 243 276 /* ··· 285 260 static unsigned int get_measured_perf(struct cpufreq_policy *policy, 286 261 unsigned int cpu) 287 262 { 288 - union { 289 - struct { 290 - u32 lo; 291 - u32 hi; 292 - } split; 293 - u64 whole; 294 - } aperf_cur, mperf_cur; 295 - 296 - cpumask_t saved_mask; 263 + struct perf_cur cur; 297 264 unsigned int perf_percent; 298 265 unsigned int retval; 299 266 300 - saved_mask = current->cpus_allowed; 301 - set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 302 - if (get_cpu() != cpu) { 303 - /* We were not able to run on requested processor */ 304 - put_cpu(); 267 + if (!work_on_cpu(cpu, read_measured_perf_ctrs, &cur)) 305 268 return 0; 306 - } 307 - 308 - rdmsr(MSR_IA32_APERF, aperf_cur.split.lo, aperf_cur.split.hi); 309 - rdmsr(MSR_IA32_MPERF, mperf_cur.split.lo, mperf_cur.split.hi); 310 - 311 - wrmsr(MSR_IA32_APERF, 0,0); 312 - wrmsr(MSR_IA32_MPERF, 0,0); 313 269 314 270 #ifdef __i386__ 315 271 /* ··· 298 292 * Get an approximate value. Return failure in case we cannot get 299 293 * an approximate value. 300 294 */ 301 - if (unlikely(aperf_cur.split.hi || mperf_cur.split.hi)) { 295 + if (unlikely(cur.aperf_cur.split.hi || cur.mperf_cur.split.hi)) { 302 296 int shift_count; 303 297 u32 h; 304 298 305 - h = max_t(u32, aperf_cur.split.hi, mperf_cur.split.hi); 299 + h = max_t(u32, cur.aperf_cur.split.hi, cur.mperf_cur.split.hi); 306 300 shift_count = fls(h); 307 301 308 - aperf_cur.whole >>= shift_count; 309 - mperf_cur.whole >>= shift_count; 302 + cur.aperf_cur.whole >>= shift_count; 303 + cur.mperf_cur.whole >>= shift_count; 310 304 } 311 305 312 - if (((unsigned long)(-1) / 100) < aperf_cur.split.lo) { 306 + if (((unsigned long)(-1) / 100) < cur.aperf_cur.split.lo) { 313 307 int shift_count = 7; 314 - aperf_cur.split.lo >>= shift_count; 315 - mperf_cur.split.lo >>= shift_count; 308 + cur.aperf_cur.split.lo >>= shift_count; 309 + cur.mperf_cur.split.lo >>= shift_count; 316 310 } 317 311 318 - if (aperf_cur.split.lo && mperf_cur.split.lo) 319 - perf_percent = (aperf_cur.split.lo * 100) / mperf_cur.split.lo; 312 + if (cur.aperf_cur.split.lo && cur.mperf_cur.split.lo) 313 + perf_percent = (cur.aperf_cur.split.lo * 100) / 314 + cur.mperf_cur.split.lo; 320 315 else 321 316 perf_percent = 0; 322 317 323 318 #else 324 - if (unlikely(((unsigned long)(-1) / 100) < aperf_cur.whole)) { 319 + if (unlikely(((unsigned long)(-1) / 100) < cur.aperf_cur.whole)) { 325 320 int shift_count = 7; 326 - aperf_cur.whole >>= shift_count; 327 - mperf_cur.whole >>= shift_count; 321 + cur.aperf_cur.whole >>= shift_count; 322 + cur.mperf_cur.whole >>= shift_count; 328 323 } 329 324 330 - if (aperf_cur.whole && mperf_cur.whole) 331 - perf_percent = (aperf_cur.whole * 100) / mperf_cur.whole; 325 + if (cur.aperf_cur.whole && cur.mperf_cur.whole) 326 + perf_percent = (cur.aperf_cur.whole * 100) / 327 + cur.mperf_cur.whole; 332 328 else 333 329 perf_percent = 0; 334 330 ··· 338 330 339 331 retval = per_cpu(drv_data, policy->cpu)->max_freq * perf_percent / 100; 340 332 341 - put_cpu(); 342 - set_cpus_allowed_ptr(current, &saved_mask); 343 - 344 - dprintk("cpu %d: performance percent %d\n", cpu, perf_percent); 345 333 return retval; 346 334 } 347 335 ··· 355 351 } 356 352 357 353 cached_freq = data->freq_table[data->acpi_data->state].frequency; 358 - freq = extract_freq(get_cur_val(&cpumask_of_cpu(cpu)), data); 354 + freq = extract_freq(get_cur_val(cpumask_of(cpu)), data); 359 355 if (freq != cached_freq) { 360 356 /* 361 357 * The dreaded BIOS frequency change behind our back. ··· 390 386 struct acpi_cpufreq_data *data = per_cpu(drv_data, policy->cpu); 391 387 struct acpi_processor_performance *perf; 392 388 struct cpufreq_freqs freqs; 393 - cpumask_t online_policy_cpus; 394 389 struct drv_cmd cmd; 395 390 unsigned int next_state = 0; /* Index into freq_table */ 396 391 unsigned int next_perf_state = 0; /* Index into perf table */ ··· 404 401 return -ENODEV; 405 402 } 406 403 404 + if (unlikely(!alloc_cpumask_var(&cmd.mask, GFP_KERNEL))) 405 + return -ENOMEM; 406 + 407 407 perf = data->acpi_data; 408 408 result = cpufreq_frequency_table_target(policy, 409 409 data->freq_table, 410 410 target_freq, 411 411 relation, &next_state); 412 - if (unlikely(result)) 413 - return -ENODEV; 414 - 415 - #ifdef CONFIG_HOTPLUG_CPU 416 - /* cpufreq holds the hotplug lock, so we are safe from here on */ 417 - cpus_and(online_policy_cpus, cpu_online_map, policy->cpus); 418 - #else 419 - online_policy_cpus = policy->cpus; 420 - #endif 412 + if (unlikely(result)) { 413 + result = -ENODEV; 414 + goto out; 415 + } 421 416 422 417 next_perf_state = data->freq_table[next_state].index; 423 418 if (perf->state == next_perf_state) { ··· 426 425 } else { 427 426 dprintk("Already at target state (P%d)\n", 428 427 next_perf_state); 429 - return 0; 428 + goto out; 430 429 } 431 430 } 432 431 ··· 445 444 cmd.val = (u32) perf->states[next_perf_state].control; 446 445 break; 447 446 default: 448 - return -ENODEV; 447 + result = -ENODEV; 448 + goto out; 449 449 } 450 450 451 - cpus_clear(cmd.mask); 452 - 451 + /* cpufreq holds the hotplug lock, so we are safe from here on */ 453 452 if (policy->shared_type != CPUFREQ_SHARED_TYPE_ANY) 454 - cmd.mask = online_policy_cpus; 453 + cpumask_and(cmd.mask, cpu_online_mask, policy->cpus); 455 454 else 456 - cpu_set(policy->cpu, cmd.mask); 455 + cpumask_copy(cmd.mask, cpumask_of(policy->cpu)); 457 456 458 457 freqs.old = perf->states[perf->state].core_frequency * 1000; 459 458 freqs.new = data->freq_table[next_state].frequency; 460 - for_each_cpu_mask_nr(i, cmd.mask) { 459 + for_each_cpu(i, cmd.mask) { 461 460 freqs.cpu = i; 462 461 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 463 462 } ··· 465 464 drv_write(&cmd); 466 465 467 466 if (acpi_pstate_strict) { 468 - if (!check_freqs(&cmd.mask, freqs.new, data)) { 467 + if (!check_freqs(cmd.mask, freqs.new, data)) { 469 468 dprintk("acpi_cpufreq_target failed (%d)\n", 470 469 policy->cpu); 471 - return -EAGAIN; 470 + result = -EAGAIN; 471 + goto out; 472 472 } 473 473 } 474 474 475 - for_each_cpu_mask_nr(i, cmd.mask) { 475 + for_each_cpu(i, cmd.mask) { 476 476 freqs.cpu = i; 477 477 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 478 478 } 479 479 perf->state = next_perf_state; 480 480 481 + out: 482 + free_cpumask_var(cmd.mask); 481 483 return result; 482 484 } 483 485 ··· 630 626 */ 631 627 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL || 632 628 policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) { 633 - cpumask_copy(&policy->cpus, perf->shared_cpu_map); 629 + cpumask_copy(policy->cpus, perf->shared_cpu_map); 634 630 } 635 - cpumask_copy(&policy->related_cpus, perf->shared_cpu_map); 631 + cpumask_copy(policy->related_cpus, perf->shared_cpu_map); 636 632 637 633 #ifdef CONFIG_SMP 638 634 dmi_check_system(sw_any_bug_dmi_table); 639 - if (bios_with_sw_any_bug && cpus_weight(policy->cpus) == 1) { 635 + if (bios_with_sw_any_bug && cpumask_weight(policy->cpus) == 1) { 640 636 policy->shared_type = CPUFREQ_SHARED_TYPE_ALL; 641 - policy->cpus = per_cpu(cpu_core_map, cpu); 637 + cpumask_copy(policy->cpus, cpu_core_mask(cpu)); 642 638 } 643 639 #endif 644 640
+4 -4
arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
··· 122 122 return 0; 123 123 124 124 /* notifiers */ 125 - for_each_cpu_mask_nr(i, policy->cpus) { 125 + for_each_cpu(i, policy->cpus) { 126 126 freqs.cpu = i; 127 127 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 128 128 } ··· 130 130 /* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software 131 131 * Developer's Manual, Volume 3 132 132 */ 133 - for_each_cpu_mask_nr(i, policy->cpus) 133 + for_each_cpu(i, policy->cpus) 134 134 cpufreq_p4_setdc(i, p4clockmod_table[newstate].index); 135 135 136 136 /* notifiers */ 137 - for_each_cpu_mask_nr(i, policy->cpus) { 137 + for_each_cpu(i, policy->cpus) { 138 138 freqs.cpu = i; 139 139 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 140 140 } ··· 203 203 unsigned int i; 204 204 205 205 #ifdef CONFIG_SMP 206 - policy->cpus = per_cpu(cpu_sibling_map, policy->cpu); 206 + cpumask_copy(policy->cpus, &per_cpu(cpu_sibling_map, policy->cpu)); 207 207 #endif 208 208 209 209 /* Errata workaround */
+3 -3
arch/x86/kernel/cpu/cpufreq/powernow-k8.c
··· 1199 1199 set_cpus_allowed_ptr(current, &oldmask); 1200 1200 1201 1201 if (cpu_family == CPU_HW_PSTATE) 1202 - pol->cpus = cpumask_of_cpu(pol->cpu); 1202 + cpumask_copy(pol->cpus, cpumask_of(pol->cpu)); 1203 1203 else 1204 - pol->cpus = per_cpu(cpu_core_map, pol->cpu); 1205 - data->available_cores = &(pol->cpus); 1204 + cpumask_copy(pol->cpus, &per_cpu(cpu_core_map, pol->cpu)); 1205 + data->available_cores = pol->cpus; 1206 1206 1207 1207 /* Take a crude guess here. 1208 1208 * That guess was in microseconds, so multiply with 1000 */
+1 -1
arch/x86/kernel/cpu/cpufreq/powernow-k8.h
··· 53 53 /* we need to keep track of associated cores, but let cpufreq 54 54 * handle hotplug events - so just point at cpufreq pol->cpus 55 55 * structure */ 56 - cpumask_t *available_cores; 56 + struct cpumask *available_cores; 57 57 }; 58 58 59 59
+16 -19
arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
··· 458 458 * 459 459 * Sets a new CPUFreq policy. 460 460 */ 461 - struct allmasks { 462 - cpumask_t saved_mask; 463 - cpumask_t covered_cpus; 464 - }; 465 - 466 461 static int centrino_target (struct cpufreq_policy *policy, 467 462 unsigned int target_freq, 468 463 unsigned int relation) ··· 467 472 struct cpufreq_freqs freqs; 468 473 int retval = 0; 469 474 unsigned int j, k, first_cpu, tmp; 470 - CPUMASK_ALLOC(allmasks); 471 - CPUMASK_PTR(saved_mask, allmasks); 472 - CPUMASK_PTR(covered_cpus, allmasks); 475 + cpumask_var_t saved_mask, covered_cpus; 473 476 474 - if (unlikely(allmasks == NULL)) 477 + if (unlikely(!alloc_cpumask_var(&saved_mask, GFP_KERNEL))) 475 478 return -ENOMEM; 479 + if (unlikely(!alloc_cpumask_var(&covered_cpus, GFP_KERNEL))) { 480 + free_cpumask_var(saved_mask); 481 + return -ENOMEM; 482 + } 483 + cpumask_copy(saved_mask, &current->cpus_allowed); 476 484 477 485 if (unlikely(per_cpu(centrino_model, cpu) == NULL)) { 478 486 retval = -ENODEV; ··· 491 493 goto out; 492 494 } 493 495 494 - *saved_mask = current->cpus_allowed; 495 496 first_cpu = 1; 496 - cpus_clear(*covered_cpus); 497 - for_each_cpu_mask_nr(j, policy->cpus) { 498 - const cpumask_t *mask; 497 + for_each_cpu(j, policy->cpus) { 498 + const struct cpumask *mask; 499 499 500 500 /* cpufreq holds the hotplug lock, so we are safe here */ 501 501 if (!cpu_online(j)) ··· 504 508 * Make sure we are running on CPU that wants to change freq 505 509 */ 506 510 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) 507 - mask = &policy->cpus; 511 + mask = policy->cpus; 508 512 else 509 - mask = &cpumask_of_cpu(j); 513 + mask = cpumask_of(j); 510 514 511 515 set_cpus_allowed_ptr(current, mask); 512 516 preempt_disable(); ··· 538 542 dprintk("target=%dkHz old=%d new=%d msr=%04x\n", 539 543 target_freq, freqs.old, freqs.new, msr); 540 544 541 - for_each_cpu_mask_nr(k, policy->cpus) { 545 + for_each_cpu(k, policy->cpus) { 542 546 if (!cpu_online(k)) 543 547 continue; 544 548 freqs.cpu = k; ··· 563 567 preempt_enable(); 564 568 } 565 569 566 - for_each_cpu_mask_nr(k, policy->cpus) { 570 + for_each_cpu(k, policy->cpus) { 567 571 if (!cpu_online(k)) 568 572 continue; 569 573 freqs.cpu = k; ··· 586 590 tmp = freqs.new; 587 591 freqs.new = freqs.old; 588 592 freqs.old = tmp; 589 - for_each_cpu_mask_nr(j, policy->cpus) { 593 + for_each_cpu(j, policy->cpus) { 590 594 if (!cpu_online(j)) 591 595 continue; 592 596 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); ··· 601 605 preempt_enable(); 602 606 set_cpus_allowed_ptr(current, saved_mask); 603 607 out: 604 - CPUMASK_FREE(allmasks); 608 + free_cpumask_var(saved_mask); 609 + free_cpumask_var(covered_cpus); 605 610 return retval; 606 611 } 607 612
+9 -9
arch/x86/kernel/cpu/cpufreq/speedstep-ich.c
··· 229 229 return 0; 230 230 } 231 231 232 - static unsigned int _speedstep_get(const cpumask_t *cpus) 232 + static unsigned int _speedstep_get(const struct cpumask *cpus) 233 233 { 234 234 unsigned int speed; 235 235 cpumask_t cpus_allowed; ··· 244 244 245 245 static unsigned int speedstep_get(unsigned int cpu) 246 246 { 247 - return _speedstep_get(&cpumask_of_cpu(cpu)); 247 + return _speedstep_get(cpumask_of(cpu)); 248 248 } 249 249 250 250 /** ··· 267 267 if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], target_freq, relation, &newstate)) 268 268 return -EINVAL; 269 269 270 - freqs.old = _speedstep_get(&policy->cpus); 270 + freqs.old = _speedstep_get(policy->cpus); 271 271 freqs.new = speedstep_freqs[newstate].frequency; 272 272 freqs.cpu = policy->cpu; 273 273 ··· 279 279 280 280 cpus_allowed = current->cpus_allowed; 281 281 282 - for_each_cpu_mask_nr(i, policy->cpus) { 282 + for_each_cpu(i, policy->cpus) { 283 283 freqs.cpu = i; 284 284 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 285 285 } 286 286 287 287 /* switch to physical CPU where state is to be changed */ 288 - set_cpus_allowed_ptr(current, &policy->cpus); 288 + set_cpus_allowed_ptr(current, policy->cpus); 289 289 290 290 speedstep_set_state(newstate); 291 291 292 292 /* allow to be run on all CPUs */ 293 293 set_cpus_allowed_ptr(current, &cpus_allowed); 294 294 295 - for_each_cpu_mask_nr(i, policy->cpus) { 295 + for_each_cpu(i, policy->cpus) { 296 296 freqs.cpu = i; 297 297 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 298 298 } ··· 322 322 323 323 /* only run on CPU to be set, or on its sibling */ 324 324 #ifdef CONFIG_SMP 325 - policy->cpus = per_cpu(cpu_sibling_map, policy->cpu); 325 + cpumask_copy(policy->cpus, &per_cpu(cpu_sibling_map, policy->cpu)); 326 326 #endif 327 327 328 328 cpus_allowed = current->cpus_allowed; 329 - set_cpus_allowed_ptr(current, &policy->cpus); 329 + set_cpus_allowed_ptr(current, policy->cpus); 330 330 331 331 /* detect low and high frequency and transition latency */ 332 332 result = speedstep_get_freqs(speedstep_processor, ··· 339 339 return result; 340 340 341 341 /* get current speed setting */ 342 - speed = _speedstep_get(&policy->cpus); 342 + speed = _speedstep_get(policy->cpus); 343 343 if (!speed) 344 344 return -EIO; 345 345
+24 -1
arch/x86/kernel/setup_percpu.c
··· 131 131 /* point to new pointer table */ 132 132 _cpu_pda = new_cpu_pda; 133 133 } 134 - #endif 134 + 135 + #endif /* CONFIG_SMP && CONFIG_X86_64 */ 136 + 137 + #ifdef CONFIG_X86_64 138 + 139 + /* correctly size the local cpu masks */ 140 + static void setup_cpu_local_masks(void) 141 + { 142 + alloc_bootmem_cpumask_var(&cpu_initialized_mask); 143 + alloc_bootmem_cpumask_var(&cpu_callin_mask); 144 + alloc_bootmem_cpumask_var(&cpu_callout_mask); 145 + alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask); 146 + } 147 + 148 + #else /* CONFIG_X86_32 */ 149 + 150 + static inline void setup_cpu_local_masks(void) 151 + { 152 + } 153 + 154 + #endif /* CONFIG_X86_32 */ 135 155 136 156 /* 137 157 * Great future plan: ··· 207 187 208 188 /* Setup node to cpumask map */ 209 189 setup_node_to_cpumask_map(); 190 + 191 + /* Setup cpu initialized, callin, callout masks */ 192 + setup_cpu_local_masks(); 210 193 } 211 194 212 195 #endif
+12 -5
arch/x86/kernel/smp.c
··· 128 128 129 129 void native_send_call_func_ipi(const struct cpumask *mask) 130 130 { 131 - cpumask_t allbutself; 131 + cpumask_var_t allbutself; 132 132 133 - allbutself = cpu_online_map; 134 - cpu_clear(smp_processor_id(), allbutself); 133 + if (!alloc_cpumask_var(&allbutself, GFP_ATOMIC)) { 134 + send_IPI_mask(mask, CALL_FUNCTION_VECTOR); 135 + return; 136 + } 135 137 136 - if (cpus_equal(*mask, allbutself) && 137 - cpus_equal(cpu_online_map, cpu_callout_map)) 138 + cpumask_copy(allbutself, cpu_online_mask); 139 + cpumask_clear_cpu(smp_processor_id(), allbutself); 140 + 141 + if (cpumask_equal(mask, allbutself) && 142 + cpumask_equal(cpu_online_mask, cpu_callout_mask)) 138 143 send_IPI_allbutself(CALL_FUNCTION_VECTOR); 139 144 else 140 145 send_IPI_mask(mask, CALL_FUNCTION_VECTOR); 146 + 147 + free_cpumask_var(allbutself); 141 148 } 142 149 143 150 /*
+65 -63
arch/x86/kernel/smpboot.c
··· 102 102 /* Last level cache ID of each logical CPU */ 103 103 DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID; 104 104 105 - cpumask_t cpu_callin_map; 106 - cpumask_t cpu_callout_map; 107 - 108 105 /* representing HT siblings of each logical CPU */ 109 106 DEFINE_PER_CPU(cpumask_t, cpu_sibling_map); 110 107 EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); ··· 116 119 117 120 static atomic_t init_deasserted; 118 121 119 - 120 - /* representing cpus for which sibling maps can be computed */ 121 - static cpumask_t cpu_sibling_setup_map; 122 122 123 123 /* Set if we find a B stepping CPU */ 124 124 static int __cpuinitdata smp_b_stepping; ··· 134 140 static void map_cpu_to_node(int cpu, int node) 135 141 { 136 142 printk(KERN_INFO "Mapping cpu %d to node %d\n", cpu, node); 137 - cpu_set(cpu, node_to_cpumask_map[node]); 143 + cpumask_set_cpu(cpu, &node_to_cpumask_map[node]); 138 144 cpu_to_node_map[cpu] = node; 139 145 } 140 146 ··· 145 151 146 152 printk(KERN_INFO "Unmapping cpu %d from all nodes\n", cpu); 147 153 for (node = 0; node < MAX_NUMNODES; node++) 148 - cpu_clear(cpu, node_to_cpumask_map[node]); 154 + cpumask_clear_cpu(cpu, &node_to_cpumask_map[node]); 149 155 cpu_to_node_map[cpu] = 0; 150 156 } 151 157 #else /* !(CONFIG_NUMA && CONFIG_X86_32) */ ··· 203 209 */ 204 210 phys_id = read_apic_id(); 205 211 cpuid = smp_processor_id(); 206 - if (cpu_isset(cpuid, cpu_callin_map)) { 212 + if (cpumask_test_cpu(cpuid, cpu_callin_mask)) { 207 213 panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__, 208 214 phys_id, cpuid); 209 215 } ··· 225 231 /* 226 232 * Has the boot CPU finished it's STARTUP sequence? 227 233 */ 228 - if (cpu_isset(cpuid, cpu_callout_map)) 234 + if (cpumask_test_cpu(cpuid, cpu_callout_mask)) 229 235 break; 230 236 cpu_relax(); 231 237 } ··· 268 274 /* 269 275 * Allow the master to continue. 270 276 */ 271 - cpu_set(cpuid, cpu_callin_map); 277 + cpumask_set_cpu(cpuid, cpu_callin_mask); 272 278 } 273 279 274 280 static int __cpuinitdata unsafe_smp; ··· 326 332 ipi_call_lock(); 327 333 lock_vector_lock(); 328 334 __setup_vector_irq(smp_processor_id()); 329 - cpu_set(smp_processor_id(), cpu_online_map); 335 + set_cpu_online(smp_processor_id(), true); 330 336 unlock_vector_lock(); 331 337 ipi_call_unlock(); 332 338 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; ··· 432 438 int i; 433 439 struct cpuinfo_x86 *c = &cpu_data(cpu); 434 440 435 - cpu_set(cpu, cpu_sibling_setup_map); 441 + cpumask_set_cpu(cpu, cpu_sibling_setup_mask); 436 442 437 443 if (smp_num_siblings > 1) { 438 - for_each_cpu_mask_nr(i, cpu_sibling_setup_map) { 439 - if (c->phys_proc_id == cpu_data(i).phys_proc_id && 440 - c->cpu_core_id == cpu_data(i).cpu_core_id) { 441 - cpu_set(i, per_cpu(cpu_sibling_map, cpu)); 442 - cpu_set(cpu, per_cpu(cpu_sibling_map, i)); 443 - cpu_set(i, per_cpu(cpu_core_map, cpu)); 444 - cpu_set(cpu, per_cpu(cpu_core_map, i)); 445 - cpu_set(i, c->llc_shared_map); 446 - cpu_set(cpu, cpu_data(i).llc_shared_map); 444 + for_each_cpu(i, cpu_sibling_setup_mask) { 445 + struct cpuinfo_x86 *o = &cpu_data(i); 446 + 447 + if (c->phys_proc_id == o->phys_proc_id && 448 + c->cpu_core_id == o->cpu_core_id) { 449 + cpumask_set_cpu(i, cpu_sibling_mask(cpu)); 450 + cpumask_set_cpu(cpu, cpu_sibling_mask(i)); 451 + cpumask_set_cpu(i, cpu_core_mask(cpu)); 452 + cpumask_set_cpu(cpu, cpu_core_mask(i)); 453 + cpumask_set_cpu(i, &c->llc_shared_map); 454 + cpumask_set_cpu(cpu, &o->llc_shared_map); 447 455 } 448 456 } 449 457 } else { 450 - cpu_set(cpu, per_cpu(cpu_sibling_map, cpu)); 458 + cpumask_set_cpu(cpu, cpu_sibling_mask(cpu)); 451 459 } 452 460 453 - cpu_set(cpu, c->llc_shared_map); 461 + cpumask_set_cpu(cpu, &c->llc_shared_map); 454 462 455 463 if (current_cpu_data.x86_max_cores == 1) { 456 - per_cpu(cpu_core_map, cpu) = per_cpu(cpu_sibling_map, cpu); 464 + cpumask_copy(cpu_core_mask(cpu), cpu_sibling_mask(cpu)); 457 465 c->booted_cores = 1; 458 466 return; 459 467 } 460 468 461 - for_each_cpu_mask_nr(i, cpu_sibling_setup_map) { 469 + for_each_cpu(i, cpu_sibling_setup_mask) { 462 470 if (per_cpu(cpu_llc_id, cpu) != BAD_APICID && 463 471 per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) { 464 - cpu_set(i, c->llc_shared_map); 465 - cpu_set(cpu, cpu_data(i).llc_shared_map); 472 + cpumask_set_cpu(i, &c->llc_shared_map); 473 + cpumask_set_cpu(cpu, &cpu_data(i).llc_shared_map); 466 474 } 467 475 if (c->phys_proc_id == cpu_data(i).phys_proc_id) { 468 - cpu_set(i, per_cpu(cpu_core_map, cpu)); 469 - cpu_set(cpu, per_cpu(cpu_core_map, i)); 476 + cpumask_set_cpu(i, cpu_core_mask(cpu)); 477 + cpumask_set_cpu(cpu, cpu_core_mask(i)); 470 478 /* 471 479 * Does this new cpu bringup a new core? 472 480 */ 473 - if (cpus_weight(per_cpu(cpu_sibling_map, cpu)) == 1) { 481 + if (cpumask_weight(cpu_sibling_mask(cpu)) == 1) { 474 482 /* 475 483 * for each core in package, increment 476 484 * the booted_cores for this new cpu 477 485 */ 478 - if (first_cpu(per_cpu(cpu_sibling_map, i)) == i) 486 + if (cpumask_first(cpu_sibling_mask(i)) == i) 479 487 c->booted_cores++; 480 488 /* 481 489 * increment the core count for all ··· 500 504 * And for power savings, we return cpu_core_map 501 505 */ 502 506 if (sched_mc_power_savings || sched_smt_power_savings) 503 - return &per_cpu(cpu_core_map, cpu); 507 + return cpu_core_mask(cpu); 504 508 else 505 509 return &c->llc_shared_map; 506 510 } ··· 519 523 */ 520 524 pr_debug("Before bogomips.\n"); 521 525 for_each_possible_cpu(cpu) 522 - if (cpu_isset(cpu, cpu_callout_map)) 526 + if (cpumask_test_cpu(cpu, cpu_callout_mask)) 523 527 bogosum += cpu_data(cpu).loops_per_jiffy; 524 528 printk(KERN_INFO 525 529 "Total of %d processors activated (%lu.%02lu BogoMIPS).\n", ··· 900 904 * allow APs to start initializing. 901 905 */ 902 906 pr_debug("Before Callout %d.\n", cpu); 903 - cpu_set(cpu, cpu_callout_map); 907 + cpumask_set_cpu(cpu, cpu_callout_mask); 904 908 pr_debug("After Callout %d.\n", cpu); 905 909 906 910 /* 907 911 * Wait 5s total for a response 908 912 */ 909 913 for (timeout = 0; timeout < 50000; timeout++) { 910 - if (cpu_isset(cpu, cpu_callin_map)) 914 + if (cpumask_test_cpu(cpu, cpu_callin_mask)) 911 915 break; /* It has booted */ 912 916 udelay(100); 913 917 } 914 918 915 - if (cpu_isset(cpu, cpu_callin_map)) { 919 + if (cpumask_test_cpu(cpu, cpu_callin_mask)) { 916 920 /* number CPUs logically, starting from 1 (BSP is 0) */ 917 921 pr_debug("OK.\n"); 918 922 printk(KERN_INFO "CPU%d: ", cpu); ··· 937 941 if (boot_error) { 938 942 /* Try to put things back the way they were before ... */ 939 943 numa_remove_cpu(cpu); /* was set by numa_add_cpu */ 940 - cpu_clear(cpu, cpu_callout_map); /* was set by do_boot_cpu() */ 941 - cpu_clear(cpu, cpu_initialized); /* was set by cpu_init() */ 942 - cpu_clear(cpu, cpu_present_map); 944 + 945 + /* was set by do_boot_cpu() */ 946 + cpumask_clear_cpu(cpu, cpu_callout_mask); 947 + 948 + /* was set by cpu_init() */ 949 + cpumask_clear_cpu(cpu, cpu_initialized_mask); 950 + 951 + set_cpu_present(cpu, false); 943 952 per_cpu(x86_cpu_to_apicid, cpu) = BAD_APICID; 944 953 } 945 954 ··· 978 977 /* 979 978 * Already booted CPU? 980 979 */ 981 - if (cpu_isset(cpu, cpu_callin_map)) { 980 + if (cpumask_test_cpu(cpu, cpu_callin_mask)) { 982 981 pr_debug("do_boot_cpu %d Already started\n", cpu); 983 982 return -ENOSYS; 984 983 } ··· 1033 1032 */ 1034 1033 static __init void disable_smp(void) 1035 1034 { 1036 - cpu_present_map = cpumask_of_cpu(0); 1037 - cpu_possible_map = cpumask_of_cpu(0); 1035 + /* use the read/write pointers to the present and possible maps */ 1036 + cpumask_copy(&cpu_present_map, cpumask_of(0)); 1037 + cpumask_copy(&cpu_possible_map, cpumask_of(0)); 1038 1038 smpboot_clear_io_apic_irqs(); 1039 1039 1040 1040 if (smp_found_config) ··· 1043 1041 else 1044 1042 physid_set_mask_of_physid(0, &phys_cpu_present_map); 1045 1043 map_cpu_to_logical_apicid(); 1046 - cpu_set(0, per_cpu(cpu_sibling_map, 0)); 1047 - cpu_set(0, per_cpu(cpu_core_map, 0)); 1044 + cpumask_set_cpu(0, cpu_sibling_mask(0)); 1045 + cpumask_set_cpu(0, cpu_core_mask(0)); 1048 1046 } 1049 1047 1050 1048 /* ··· 1066 1064 nr = 0; 1067 1065 for_each_present_cpu(cpu) { 1068 1066 if (nr >= 8) 1069 - cpu_clear(cpu, cpu_present_map); 1067 + set_cpu_present(cpu, false); 1070 1068 nr++; 1071 1069 } 1072 1070 1073 1071 nr = 0; 1074 1072 for_each_possible_cpu(cpu) { 1075 1073 if (nr >= 8) 1076 - cpu_clear(cpu, cpu_possible_map); 1074 + set_cpu_possible(cpu, false); 1077 1075 nr++; 1078 1076 } 1079 1077 ··· 1169 1167 preempt_disable(); 1170 1168 smp_cpu_index_default(); 1171 1169 current_cpu_data = boot_cpu_data; 1172 - cpu_callin_map = cpumask_of_cpu(0); 1170 + cpumask_copy(cpu_callin_mask, cpumask_of(0)); 1173 1171 mb(); 1174 1172 /* 1175 1173 * Setup boot CPU information ··· 1244 1242 init_gdt(me); 1245 1243 #endif 1246 1244 switch_to_new_gdt(); 1247 - /* already set me in cpu_online_map in boot_cpu_init() */ 1248 - cpu_set(me, cpu_callout_map); 1245 + /* already set me in cpu_online_mask in boot_cpu_init() */ 1246 + cpumask_set_cpu(me, cpu_callout_mask); 1249 1247 per_cpu(cpu_state, me) = CPU_ONLINE; 1250 1248 } 1251 1249 ··· 1313 1311 possible, max_t(int, possible - num_processors, 0)); 1314 1312 1315 1313 for (i = 0; i < possible; i++) 1316 - cpu_set(i, cpu_possible_map); 1314 + set_cpu_possible(i, true); 1317 1315 1318 1316 nr_cpu_ids = possible; 1319 1317 } ··· 1325 1323 int sibling; 1326 1324 struct cpuinfo_x86 *c = &cpu_data(cpu); 1327 1325 1328 - for_each_cpu_mask_nr(sibling, per_cpu(cpu_core_map, cpu)) { 1329 - cpu_clear(cpu, per_cpu(cpu_core_map, sibling)); 1326 + for_each_cpu(sibling, cpu_core_mask(cpu)) { 1327 + cpumask_clear_cpu(cpu, cpu_core_mask(sibling)); 1330 1328 /*/ 1331 1329 * last thread sibling in this cpu core going down 1332 1330 */ 1333 - if (cpus_weight(per_cpu(cpu_sibling_map, cpu)) == 1) 1331 + if (cpumask_weight(cpu_sibling_mask(cpu)) == 1) 1334 1332 cpu_data(sibling).booted_cores--; 1335 1333 } 1336 1334 1337 - for_each_cpu_mask_nr(sibling, per_cpu(cpu_sibling_map, cpu)) 1338 - cpu_clear(cpu, per_cpu(cpu_sibling_map, sibling)); 1339 - cpus_clear(per_cpu(cpu_sibling_map, cpu)); 1340 - cpus_clear(per_cpu(cpu_core_map, cpu)); 1335 + for_each_cpu(sibling, cpu_sibling_mask(cpu)) 1336 + cpumask_clear_cpu(cpu, cpu_sibling_mask(sibling)); 1337 + cpumask_clear(cpu_sibling_mask(cpu)); 1338 + cpumask_clear(cpu_core_mask(cpu)); 1341 1339 c->phys_proc_id = 0; 1342 1340 c->cpu_core_id = 0; 1343 - cpu_clear(cpu, cpu_sibling_setup_map); 1341 + cpumask_clear_cpu(cpu, cpu_sibling_setup_mask); 1344 1342 } 1345 1343 1346 1344 static void __ref remove_cpu_from_maps(int cpu) 1347 1345 { 1348 - cpu_clear(cpu, cpu_online_map); 1349 - cpu_clear(cpu, cpu_callout_map); 1350 - cpu_clear(cpu, cpu_callin_map); 1346 + set_cpu_online(cpu, false); 1347 + cpumask_clear_cpu(cpu, cpu_callout_mask); 1348 + cpumask_clear_cpu(cpu, cpu_callin_mask); 1351 1349 /* was set by cpu_init() */ 1352 - cpu_clear(cpu, cpu_initialized); 1350 + cpumask_clear_cpu(cpu, cpu_initialized_mask); 1353 1351 numa_remove_cpu(cpu); 1354 1352 } 1355 1353
+28 -14
drivers/cpufreq/cpufreq.c
··· 584 584 return i; 585 585 } 586 586 587 - static ssize_t show_cpus(cpumask_t mask, char *buf) 587 + static ssize_t show_cpus(const struct cpumask *mask, char *buf) 588 588 { 589 589 ssize_t i = 0; 590 590 unsigned int cpu; 591 591 592 - for_each_cpu_mask_nr(cpu, mask) { 592 + for_each_cpu(cpu, mask) { 593 593 if (i) 594 594 i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), " "); 595 595 i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), "%u", cpu); ··· 606 606 */ 607 607 static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) 608 608 { 609 - if (cpus_empty(policy->related_cpus)) 609 + if (cpumask_empty(policy->related_cpus)) 610 610 return show_cpus(policy->cpus, buf); 611 611 return show_cpus(policy->related_cpus, buf); 612 612 } ··· 806 806 ret = -ENOMEM; 807 807 goto nomem_out; 808 808 } 809 + if (!alloc_cpumask_var(&policy->cpus, GFP_KERNEL)) { 810 + kfree(policy); 811 + ret = -ENOMEM; 812 + goto nomem_out; 813 + } 814 + if (!alloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) { 815 + free_cpumask_var(policy->cpus); 816 + kfree(policy); 817 + ret = -ENOMEM; 818 + goto nomem_out; 819 + } 809 820 810 821 policy->cpu = cpu; 811 - policy->cpus = cpumask_of_cpu(cpu); 822 + cpumask_copy(policy->cpus, cpumask_of(cpu)); 812 823 813 824 /* Initially set CPU itself as the policy_cpu */ 814 825 per_cpu(policy_cpu, cpu) = cpu; ··· 854 843 } 855 844 #endif 856 845 857 - for_each_cpu_mask_nr(j, policy->cpus) { 846 + for_each_cpu(j, policy->cpus) { 858 847 if (cpu == j) 859 848 continue; 860 849 ··· 872 861 goto err_out_driver_exit; 873 862 874 863 spin_lock_irqsave(&cpufreq_driver_lock, flags); 875 - managed_policy->cpus = policy->cpus; 864 + cpumask_copy(managed_policy->cpus, policy->cpus); 876 865 per_cpu(cpufreq_cpu_data, cpu) = managed_policy; 877 866 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 878 867 ··· 927 916 } 928 917 929 918 spin_lock_irqsave(&cpufreq_driver_lock, flags); 930 - for_each_cpu_mask_nr(j, policy->cpus) { 919 + for_each_cpu(j, policy->cpus) { 931 920 per_cpu(cpufreq_cpu_data, j) = policy; 932 921 per_cpu(policy_cpu, j) = policy->cpu; 933 922 } 934 923 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 935 924 936 925 /* symlink affected CPUs */ 937 - for_each_cpu_mask_nr(j, policy->cpus) { 926 + for_each_cpu(j, policy->cpus) { 938 927 if (j == cpu) 939 928 continue; 940 929 if (!cpu_online(j)) ··· 974 963 975 964 err_out_unregister: 976 965 spin_lock_irqsave(&cpufreq_driver_lock, flags); 977 - for_each_cpu_mask_nr(j, policy->cpus) 966 + for_each_cpu(j, policy->cpus) 978 967 per_cpu(cpufreq_cpu_data, j) = NULL; 979 968 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 980 969 ··· 1035 1024 */ 1036 1025 if (unlikely(cpu != data->cpu)) { 1037 1026 dprintk("removing link\n"); 1038 - cpu_clear(cpu, data->cpus); 1027 + cpumask_clear_cpu(cpu, data->cpus); 1039 1028 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1040 1029 sysfs_remove_link(&sys_dev->kobj, "cpufreq"); 1041 1030 cpufreq_cpu_put(data); ··· 1056 1045 * per_cpu(cpufreq_cpu_data) while holding the lock, and remove 1057 1046 * the sysfs links afterwards. 1058 1047 */ 1059 - if (unlikely(cpus_weight(data->cpus) > 1)) { 1060 - for_each_cpu_mask_nr(j, data->cpus) { 1048 + if (unlikely(cpumask_weight(data->cpus) > 1)) { 1049 + for_each_cpu(j, data->cpus) { 1061 1050 if (j == cpu) 1062 1051 continue; 1063 1052 per_cpu(cpufreq_cpu_data, j) = NULL; ··· 1066 1055 1067 1056 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1068 1057 1069 - if (unlikely(cpus_weight(data->cpus) > 1)) { 1070 - for_each_cpu_mask_nr(j, data->cpus) { 1058 + if (unlikely(cpumask_weight(data->cpus) > 1)) { 1059 + for_each_cpu(j, data->cpus) { 1071 1060 if (j == cpu) 1072 1061 continue; 1073 1062 dprintk("removing link for cpu %u\n", j); ··· 1101 1090 if (cpufreq_driver->exit) 1102 1091 cpufreq_driver->exit(data); 1103 1092 1093 + free_cpumask_var(data->related_cpus); 1094 + free_cpumask_var(data->cpus); 1104 1095 kfree(data); 1096 + per_cpu(cpufreq_cpu_data, cpu) = NULL; 1105 1097 1106 1098 cpufreq_debug_enable_ratelimit(); 1107 1099 return 0;
+1 -1
drivers/cpufreq/cpufreq_conservative.c
··· 498 498 return rc; 499 499 } 500 500 501 - for_each_cpu_mask_nr(j, policy->cpus) { 501 + for_each_cpu(j, policy->cpus) { 502 502 struct cpu_dbs_info_s *j_dbs_info; 503 503 j_dbs_info = &per_cpu(cpu_dbs_info, j); 504 504 j_dbs_info->cur_policy = policy;
+2 -2
drivers/cpufreq/cpufreq_ondemand.c
··· 400 400 /* Get Absolute Load - in terms of freq */ 401 401 max_load_freq = 0; 402 402 403 - for_each_cpu_mask_nr(j, policy->cpus) { 403 + for_each_cpu(j, policy->cpus) { 404 404 struct cpu_dbs_info_s *j_dbs_info; 405 405 cputime64_t cur_wall_time, cur_idle_time; 406 406 unsigned int idle_time, wall_time; ··· 568 568 return rc; 569 569 } 570 570 571 - for_each_cpu_mask_nr(j, policy->cpus) { 571 + for_each_cpu(j, policy->cpus) { 572 572 struct cpu_dbs_info_s *j_dbs_info; 573 573 j_dbs_info = &per_cpu(cpu_dbs_info, j); 574 574 j_dbs_info->cur_policy = policy;
+6 -6
drivers/pci/pci-sysfs.c
··· 71 71 static ssize_t local_cpus_show(struct device *dev, 72 72 struct device_attribute *attr, char *buf) 73 73 { 74 - cpumask_t mask; 74 + const struct cpumask *mask; 75 75 int len; 76 76 77 - mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); 78 - len = cpumask_scnprintf(buf, PAGE_SIZE-2, &mask); 77 + mask = cpumask_of_pcibus(to_pci_dev(dev)->bus); 78 + len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); 79 79 buf[len++] = '\n'; 80 80 buf[len] = '\0'; 81 81 return len; ··· 85 85 static ssize_t local_cpulist_show(struct device *dev, 86 86 struct device_attribute *attr, char *buf) 87 87 { 88 - cpumask_t mask; 88 + const struct cpumask *mask; 89 89 int len; 90 90 91 - mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); 92 - len = cpulist_scnprintf(buf, PAGE_SIZE-2, &mask); 91 + mask = cpumask_of_pcibus(to_pci_dev(dev)->bus); 92 + len = cpulist_scnprintf(buf, PAGE_SIZE-2, mask); 93 93 buf[len++] = '\n'; 94 94 buf[len] = '\0'; 95 95 return len;
+4 -4
drivers/pci/probe.c
··· 51 51 char *buf) 52 52 { 53 53 int ret; 54 - cpumask_t cpumask; 54 + const struct cpumask *cpumask; 55 55 56 - cpumask = pcibus_to_cpumask(to_pci_bus(dev)); 56 + cpumask = cpumask_of_pcibus(to_pci_bus(dev)); 57 57 ret = type? 58 - cpulist_scnprintf(buf, PAGE_SIZE-2, &cpumask) : 59 - cpumask_scnprintf(buf, PAGE_SIZE-2, &cpumask); 58 + cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask) : 59 + cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask); 60 60 buf[ret++] = '\n'; 61 61 buf[ret] = '\0'; 62 62 return ret;
+2 -2
include/linux/cpufreq.h
··· 80 80 }; 81 81 82 82 struct cpufreq_policy { 83 - cpumask_t cpus; /* CPUs requiring sw coordination */ 84 - cpumask_t related_cpus; /* CPUs with any coordination */ 83 + cpumask_var_t cpus; /* CPUs requiring sw coordination */ 84 + cpumask_var_t related_cpus; /* CPUs with any coordination */ 85 85 unsigned int shared_type; /* ANY or ALL affected CPUs 86 86 should set cpufreq */ 87 87 unsigned int cpu; /* cpu nr of registered CPU */