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

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

Conflicts:

arch/x86/include/asm/topology.h
drivers/oprofile/buffer_sync.c
(Both cases: changed in Linus' tree, removed in Ingo's).

+641 -661
+1
arch/powerpc/include/asm/mmzone.h
··· 8 8 #define _ASM_MMZONE_H_ 9 9 #ifdef __KERNEL__ 10 10 11 + #include <linux/cpumask.h> 11 12 12 13 /* 13 14 * generic non-linear memory support:
+2
arch/sparc/include/asm/mmzone.h
··· 3 3 4 4 #ifdef CONFIG_NEED_MULTIPLE_NODES 5 5 6 + #include <linux/cpumask.h> 7 + 6 8 extern struct pglist_data *node_data[]; 7 9 8 10 #define NODE_DATA(nid) (node_data[nid])
-18
arch/x86/include/asm/cpumask.h
··· 3 3 #ifndef __ASSEMBLY__ 4 4 #include <linux/cpumask.h> 5 5 6 - #ifdef CONFIG_X86_64 7 - 8 6 extern cpumask_var_t cpu_callin_mask; 9 7 extern cpumask_var_t cpu_callout_mask; 10 8 extern cpumask_var_t cpu_initialized_mask; 11 9 extern cpumask_var_t cpu_sibling_setup_mask; 12 10 13 11 extern void setup_cpu_local_masks(void); 14 - 15 - #else /* CONFIG_X86_32 */ 16 - 17 - extern cpumask_t cpu_callin_map; 18 - extern cpumask_t cpu_callout_map; 19 - extern cpumask_t cpu_initialized; 20 - extern cpumask_t cpu_sibling_setup_map; 21 - 22 - #define cpu_callin_mask ((struct cpumask *)&cpu_callin_map) 23 - #define cpu_callout_mask ((struct cpumask *)&cpu_callout_map) 24 - #define cpu_initialized_mask ((struct cpumask *)&cpu_initialized) 25 - #define cpu_sibling_setup_mask ((struct cpumask *)&cpu_sibling_setup_map) 26 - 27 - static inline void setup_cpu_local_masks(void) { } 28 - 29 - #endif /* CONFIG_X86_32 */ 30 12 31 13 #endif /* __ASSEMBLY__ */ 32 14 #endif /* _ASM_X86_CPUMASK_H */
-5
arch/x86/include/asm/pci.h
··· 109 109 return sd->node; 110 110 } 111 111 112 - static inline cpumask_t __pcibus_to_cpumask(struct pci_bus *bus) 113 - { 114 - return node_to_cpumask(__pcibus_to_node(bus)); 115 - } 116 - 117 112 static inline const struct cpumask * 118 113 cpumask_of_pcibus(const struct pci_bus *bus) 119 114 {
+2 -1
arch/x86/include/asm/processor.h
··· 94 94 unsigned long loops_per_jiffy; 95 95 #ifdef CONFIG_SMP 96 96 /* cpus sharing the last level cache: */ 97 - cpumask_t llc_shared_map; 97 + cpumask_var_t llc_shared_map; 98 98 #endif 99 99 /* cpuid returned max cores value: */ 100 100 u16 x86_max_cores; ··· 736 736 extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx); 737 737 738 738 extern void select_idle_routine(const struct cpuinfo_x86 *c); 739 + extern void init_c1e_mask(void); 739 740 740 741 extern unsigned long boot_option_idle_override; 741 742 extern unsigned long idle_halt;
+7 -6
arch/x86/include/asm/smp.h
··· 21 21 extern int smp_num_siblings; 22 22 extern unsigned int num_processors; 23 23 24 - DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); 25 - DECLARE_PER_CPU(cpumask_t, cpu_core_map); 24 + DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map); 25 + DECLARE_PER_CPU(cpumask_var_t, cpu_core_map); 26 26 DECLARE_PER_CPU(u16, cpu_llc_id); 27 27 DECLARE_PER_CPU(int, cpu_number); 28 28 29 29 static inline struct cpumask *cpu_sibling_mask(int cpu) 30 30 { 31 - return &per_cpu(cpu_sibling_map, cpu); 31 + return per_cpu(cpu_sibling_map, cpu); 32 32 } 33 33 34 34 static inline struct cpumask *cpu_core_mask(int cpu) 35 35 { 36 - return &per_cpu(cpu_core_map, cpu); 36 + return per_cpu(cpu_core_map, cpu); 37 37 } 38 38 39 39 DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); ··· 121 121 smp_ops.send_call_func_single_ipi(cpu); 122 122 } 123 123 124 - static inline void arch_send_call_function_ipi(cpumask_t mask) 124 + #define arch_send_call_function_ipi_mask arch_send_call_function_ipi_mask 125 + static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask) 125 126 { 126 - smp_ops.send_call_func_ipi(&mask); 127 + smp_ops.send_call_func_ipi(mask); 127 128 } 128 129 129 130 void cpu_disable_common(void);
+17 -70
arch/x86/include/asm/topology.h
··· 44 44 45 45 #ifdef CONFIG_X86_32 46 46 47 - /* Mappings between node number and cpus on that node. */ 48 - extern cpumask_t node_to_cpumask_map[]; 49 - 50 47 /* Mappings between logical cpu number and node number */ 51 48 extern int cpu_to_node_map[]; 52 49 ··· 54 57 } 55 58 #define early_cpu_to_node(cpu) cpu_to_node(cpu) 56 59 57 - /* Returns a bitmask of CPUs on Node 'node'. 58 - * 59 - * Side note: this function creates the returned cpumask on the stack 60 - * so with a high NR_CPUS count, excessive stack space is used. The 61 - * cpumask_of_node function should be used whenever possible. 62 - */ 63 - static inline cpumask_t node_to_cpumask(int node) 64 - { 65 - return node_to_cpumask_map[node]; 66 - } 67 - 68 - /* Returns a bitmask of CPUs on Node 'node'. */ 69 - static inline const struct cpumask *cpumask_of_node(int node) 70 - { 71 - return &node_to_cpumask_map[node]; 72 - } 73 - 74 - static inline void setup_node_to_cpumask_map(void) { } 75 - 76 60 #else /* CONFIG_X86_64 */ 77 - 78 - /* Mappings between node number and cpus on that node. */ 79 - extern cpumask_t *node_to_cpumask_map; 80 61 81 62 /* Mappings between logical cpu number and node number */ 82 63 DECLARE_EARLY_PER_CPU(int, x86_cpu_to_node_map); ··· 66 91 #ifdef CONFIG_DEBUG_PER_CPU_MAPS 67 92 extern int cpu_to_node(int cpu); 68 93 extern int early_cpu_to_node(int cpu); 69 - extern const cpumask_t *cpumask_of_node(int node); 70 - extern cpumask_t node_to_cpumask(int node); 71 94 72 95 #else /* !CONFIG_DEBUG_PER_CPU_MAPS */ 73 96 ··· 81 108 return early_per_cpu(x86_cpu_to_node_map, cpu); 82 109 } 83 110 84 - /* Returns a pointer to the cpumask of CPUs on Node 'node'. */ 85 - static inline const cpumask_t *cpumask_of_node(int node) 86 - { 87 - return &node_to_cpumask_map[node]; 88 - } 111 + #endif /* !CONFIG_DEBUG_PER_CPU_MAPS */ 89 112 90 - /* Returns a bitmask of CPUs on Node 'node'. */ 91 - static inline cpumask_t node_to_cpumask(int node) 113 + #endif /* CONFIG_X86_64 */ 114 + 115 + /* Mappings between node number and cpus on that node. */ 116 + extern cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; 117 + 118 + #ifdef CONFIG_DEBUG_PER_CPU_MAPS 119 + extern const struct cpumask *cpumask_of_node(int node); 120 + #else 121 + /* Returns a pointer to the cpumask of CPUs on Node 'node'. */ 122 + static inline const struct cpumask *cpumask_of_node(int node) 92 123 { 93 124 return node_to_cpumask_map[node]; 94 125 } 95 - 96 - #endif /* !CONFIG_DEBUG_PER_CPU_MAPS */ 126 + #endif 97 127 98 128 extern void setup_node_to_cpumask_map(void); 99 - 100 - /* 101 - * Replace default node_to_cpumask_ptr with optimized version 102 - * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)" 103 - */ 104 - #define node_to_cpumask_ptr(v, node) \ 105 - const cpumask_t *v = cpumask_of_node(node) 106 - 107 - #define node_to_cpumask_ptr_next(v, node) \ 108 - v = cpumask_of_node(node) 109 - 110 - #endif /* CONFIG_X86_64 */ 111 129 112 130 /* 113 131 * Returns the number of the node containing Node 'node'. This ··· 107 143 #define parent_node(node) (node) 108 144 109 145 #define pcibus_to_node(bus) __pcibus_to_node(bus) 110 - #define pcibus_to_cpumask(bus) __pcibus_to_cpumask(bus) 111 146 112 147 #ifdef CONFIG_X86_32 113 148 extern unsigned long node_start_pfn[]; ··· 172 209 return 0; 173 210 } 174 211 175 - static inline const cpumask_t *cpumask_of_node(int node) 212 + static inline const struct cpumask *cpumask_of_node(int node) 176 213 { 177 - return &cpu_online_map; 178 - } 179 - static inline cpumask_t node_to_cpumask(int node) 180 - { 181 - return cpu_online_map; 214 + return cpu_online_mask; 182 215 } 183 216 184 217 static inline void setup_node_to_cpumask_map(void) { } 185 218 186 - /* 187 - * Replace default node_to_cpumask_ptr with optimized version 188 - * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)" 189 - */ 190 - #define node_to_cpumask_ptr(v, node) \ 191 - const cpumask_t *v = cpumask_of_node(node) 192 - 193 - #define node_to_cpumask_ptr_next(v, node) \ 194 - v = cpumask_of_node(node) 195 219 #endif 196 220 197 221 #include <asm-generic/topology.h> 198 222 199 - extern cpumask_t cpu_coregroup_map(int cpu); 200 223 extern const struct cpumask *cpu_coregroup_mask(int cpu); 201 224 202 225 #ifdef ENABLE_TOPO_DEFINES 203 226 #define topology_physical_package_id(cpu) (cpu_data(cpu).phys_proc_id) 204 227 #define topology_core_id(cpu) (cpu_data(cpu).cpu_core_id) 205 - #define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu)) 206 - #define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu)) 207 - #define topology_core_cpumask(cpu) (&per_cpu(cpu_core_map, cpu)) 208 - #define topology_thread_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu)) 228 + #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu)) 229 + #define topology_thread_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu)) 209 230 210 231 /* indicates that pointers to the topology cpumask_t maps are valid */ 211 232 #define arch_provides_topology_pointers yes ··· 203 256 void set_pci_bus_resources_arch_default(struct pci_bus *b); 204 257 205 258 #ifdef CONFIG_SMP 206 - #define mc_capable() (cpus_weight(per_cpu(cpu_core_map, 0)) != nr_cpu_ids) 259 + #define mc_capable() (cpumask_weight(cpu_core_mask(0)) != nr_cpu_ids) 207 260 #define smt_capable() (smp_num_siblings > 1) 208 261 #endif 209 262
+8 -8
arch/x86/kernel/apic/bigsmp_32.c
··· 26 26 return 1; 27 27 } 28 28 29 - static const cpumask_t *bigsmp_target_cpus(void) 29 + static const struct cpumask *bigsmp_target_cpus(void) 30 30 { 31 31 #ifdef CONFIG_SMP 32 - return &cpu_online_map; 32 + return cpu_online_mask; 33 33 #else 34 - return &cpumask_of_cpu(0); 34 + return cpumask_of(0); 35 35 #endif 36 36 } 37 37 ··· 118 118 } 119 119 120 120 /* As we are using single CPU as destination, pick only one CPU here */ 121 - static unsigned int bigsmp_cpu_mask_to_apicid(const cpumask_t *cpumask) 121 + static unsigned int bigsmp_cpu_mask_to_apicid(const struct cpumask *cpumask) 122 122 { 123 - return bigsmp_cpu_to_logical_apicid(first_cpu(*cpumask)); 123 + return bigsmp_cpu_to_logical_apicid(cpumask_first(cpumask)); 124 124 } 125 125 126 126 static unsigned int bigsmp_cpu_mask_to_apicid_and(const struct cpumask *cpumask, ··· 188 188 { } /* NULL entry stops DMI scanning */ 189 189 }; 190 190 191 - static void bigsmp_vector_allocation_domain(int cpu, cpumask_t *retmask) 191 + static void bigsmp_vector_allocation_domain(int cpu, struct cpumask *retmask) 192 192 { 193 - cpus_clear(*retmask); 194 - cpu_set(cpu, *retmask); 193 + cpumask_clear(retmask); 194 + cpumask_set_cpu(cpu, retmask); 195 195 } 196 196 197 197 static int probe_bigsmp(void)
+9 -8
arch/x86/kernel/apic/es7000_32.c
··· 410 410 WARN(1, "Command failed, status = %x\n", mip_status); 411 411 } 412 412 413 - static void es7000_vector_allocation_domain(int cpu, cpumask_t *retmask) 413 + static void es7000_vector_allocation_domain(int cpu, struct cpumask *retmask) 414 414 { 415 415 /* Careful. Some cpus do not strictly honor the set of cpus 416 416 * specified in the interrupt destination when using lowest ··· 420 420 * deliver interrupts to the wrong hyperthread when only one 421 421 * hyperthread was specified in the interrupt desitination. 422 422 */ 423 - *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } }; 423 + cpumask_clear(retmask); 424 + cpumask_bits(retmask)[0] = APIC_ALL_CPUS; 424 425 } 425 426 426 427 ··· 456 455 return 1; 457 456 } 458 457 459 - static const cpumask_t *target_cpus_cluster(void) 458 + static const struct cpumask *target_cpus_cluster(void) 460 459 { 461 - return &CPU_MASK_ALL; 460 + return cpu_all_mask; 462 461 } 463 462 464 - static const cpumask_t *es7000_target_cpus(void) 463 + static const struct cpumask *es7000_target_cpus(void) 465 464 { 466 - return &cpumask_of_cpu(smp_processor_id()); 465 + return cpumask_of(smp_processor_id()); 467 466 } 468 467 469 468 static unsigned long ··· 518 517 "Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n", 519 518 (apic_version[apic] == 0x14) ? 520 519 "Physical Cluster" : "Logical Cluster", 521 - nr_ioapics, cpus_addr(*es7000_target_cpus())[0]); 520 + nr_ioapics, cpumask_bits(es7000_target_cpus())[0]); 522 521 } 523 522 524 523 static int es7000_apicid_to_node(int logical_apicid) ··· 573 572 return 1; 574 573 } 575 574 576 - static unsigned int es7000_cpu_mask_to_apicid(const cpumask_t *cpumask) 575 + static unsigned int es7000_cpu_mask_to_apicid(const struct cpumask *cpumask) 577 576 { 578 577 unsigned int round = 0; 579 578 int cpu, uninitialized_var(apicid);
+6 -5
arch/x86/kernel/apic/nmi.c
··· 39 39 int unknown_nmi_panic; 40 40 int nmi_watchdog_enabled; 41 41 42 - static cpumask_t backtrace_mask = CPU_MASK_NONE; 42 + static cpumask_var_t backtrace_mask; 43 43 44 44 /* nmi_active: 45 45 * >0: the lapic NMI watchdog is active, but can be disabled ··· 138 138 if (!prev_nmi_count) 139 139 goto error; 140 140 141 + alloc_cpumask_var(&backtrace_mask, GFP_KERNEL); 141 142 printk(KERN_INFO "Testing NMI watchdog ... "); 142 143 143 144 #ifdef CONFIG_SMP ··· 414 413 touched = 1; 415 414 } 416 415 417 - if (cpu_isset(cpu, backtrace_mask)) { 416 + if (cpumask_test_cpu(cpu, backtrace_mask)) { 418 417 static DEFINE_SPINLOCK(lock); /* Serialise the printks */ 419 418 420 419 spin_lock(&lock); 421 420 printk(KERN_WARNING "NMI backtrace for cpu %d\n", cpu); 422 421 dump_stack(); 423 422 spin_unlock(&lock); 424 - cpu_clear(cpu, backtrace_mask); 423 + cpumask_clear_cpu(cpu, backtrace_mask); 425 424 } 426 425 427 426 /* Could check oops_in_progress here too, but it's safer not to */ ··· 555 554 { 556 555 int i; 557 556 558 - backtrace_mask = cpu_online_map; 557 + cpumask_copy(backtrace_mask, cpu_online_mask); 559 558 /* Wait for up to 10 seconds for all CPUs to do the backtrace */ 560 559 for (i = 0; i < 10 * 1000; i++) { 561 - if (cpus_empty(backtrace_mask)) 560 + if (cpumask_empty(backtrace_mask)) 562 561 break; 563 562 mdelay(1); 564 563 }
+6 -5
arch/x86/kernel/apic/numaq_32.c
··· 334 334 clear_local_APIC(); 335 335 } 336 336 337 - static inline const cpumask_t *numaq_target_cpus(void) 337 + static inline const struct cpumask *numaq_target_cpus(void) 338 338 { 339 - return &CPU_MASK_ALL; 339 + return cpu_all_mask; 340 340 } 341 341 342 342 static inline unsigned long ··· 427 427 * We use physical apicids here, not logical, so just return the default 428 428 * physical broadcast to stop people from breaking us 429 429 */ 430 - static inline unsigned int numaq_cpu_mask_to_apicid(const cpumask_t *cpumask) 430 + static unsigned int numaq_cpu_mask_to_apicid(const struct cpumask *cpumask) 431 431 { 432 432 return 0x0F; 433 433 } ··· 462 462 return found_numaq; 463 463 } 464 464 465 - static void numaq_vector_allocation_domain(int cpu, cpumask_t *retmask) 465 + static void numaq_vector_allocation_domain(int cpu, struct cpumask *retmask) 466 466 { 467 467 /* Careful. Some cpus do not strictly honor the set of cpus 468 468 * specified in the interrupt destination when using lowest ··· 472 472 * deliver interrupts to the wrong hyperthread when only one 473 473 * hyperthread was specified in the interrupt desitination. 474 474 */ 475 - *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } }; 475 + cpumask_clear(retmask); 476 + cpumask_bits(retmask)[0] = APIC_ALL_CPUS; 476 477 } 477 478 478 479 static void numaq_setup_portio_remap(void)
+2 -1
arch/x86/kernel/apic/probe_32.c
··· 83 83 * deliver interrupts to the wrong hyperthread when only one 84 84 * hyperthread was specified in the interrupt desitination. 85 85 */ 86 - *retmask = (cpumask_t) { { [0] = APIC_ALL_CPUS } }; 86 + cpumask_clear(retmask); 87 + cpumask_bits(retmask)[0] = APIC_ALL_CPUS; 87 88 } 88 89 89 90 /* should be called last. */
+9 -12
arch/x86/kernel/apic/summit_32.c
··· 53 53 return (x >> 24) & 0xFF; 54 54 } 55 55 56 - static inline void summit_send_IPI_mask(const cpumask_t *mask, int vector) 56 + static inline void summit_send_IPI_mask(const struct cpumask *mask, int vector) 57 57 { 58 58 default_send_IPI_mask_sequence_logical(mask, vector); 59 59 } 60 60 61 61 static void summit_send_IPI_allbutself(int vector) 62 62 { 63 - cpumask_t mask = cpu_online_map; 64 - cpu_clear(smp_processor_id(), mask); 65 - 66 - if (!cpus_empty(mask)) 67 - summit_send_IPI_mask(&mask, vector); 63 + default_send_IPI_mask_allbutself_logical(cpu_online_mask, vector); 68 64 } 69 65 70 66 static void summit_send_IPI_all(int vector) 71 67 { 72 - summit_send_IPI_mask(&cpu_online_map, vector); 68 + summit_send_IPI_mask(cpu_online_mask, vector); 73 69 } 74 70 75 71 #include <asm/tsc.h> ··· 182 186 183 187 #define SUMMIT_APIC_DFR_VALUE (APIC_DFR_CLUSTER) 184 188 185 - static const cpumask_t *summit_target_cpus(void) 189 + static const struct cpumask *summit_target_cpus(void) 186 190 { 187 191 /* CPU_MASK_ALL (0xff) has undefined behaviour with 188 192 * dest_LowestPrio mode logical clustered apic interrupt routing 189 193 * Just start on cpu 0. IRQ balancing will spread load 190 194 */ 191 - return &cpumask_of_cpu(0); 195 + return cpumask_of(0); 192 196 } 193 197 194 198 static unsigned long summit_check_apicid_used(physid_mask_t bitmap, int apicid) ··· 285 289 return 1; 286 290 } 287 291 288 - static unsigned int summit_cpu_mask_to_apicid(const cpumask_t *cpumask) 292 + static unsigned int summit_cpu_mask_to_apicid(const struct cpumask *cpumask) 289 293 { 290 294 unsigned int round = 0; 291 295 int cpu, apicid = 0; ··· 342 346 return 0; 343 347 } 344 348 345 - static void summit_vector_allocation_domain(int cpu, cpumask_t *retmask) 349 + static void summit_vector_allocation_domain(int cpu, struct cpumask *retmask) 346 350 { 347 351 /* Careful. Some cpus do not strictly honor the set of cpus 348 352 * specified in the interrupt destination when using lowest ··· 352 356 * deliver interrupts to the wrong hyperthread when only one 353 357 * hyperthread was specified in the interrupt desitination. 354 358 */ 355 - *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } }; 359 + cpumask_clear(retmask); 360 + cpumask_bits(retmask)[0] = APIC_ALL_CPUS; 356 361 } 357 362 358 363 #ifdef CONFIG_X86_SUMMIT_NUMA
+158 -116
arch/x86/kernel/apm_32.c
··· 466 466 * @err: APM BIOS return code 467 467 * 468 468 * Write a meaningful log entry to the kernel log in the event of 469 - * an APM error. 469 + * an APM error. Note that this also handles (negative) kernel errors. 470 470 */ 471 471 472 472 static void apm_error(char *str, int err) ··· 478 478 break; 479 479 if (i < ERROR_COUNT) 480 480 printk(KERN_NOTICE "apm: %s: %s\n", str, error_table[i].msg); 481 + else if (err < 0) 482 + printk(KERN_NOTICE "apm: %s: linux error code %i\n", str, err); 481 483 else 482 484 printk(KERN_NOTICE "apm: %s: unknown error code %#2.2x\n", 483 485 str, err); 484 486 } 485 - 486 - /* 487 - * Lock APM functionality to physical CPU 0 488 - */ 489 - 490 - #ifdef CONFIG_SMP 491 - 492 - static cpumask_t apm_save_cpus(void) 493 - { 494 - cpumask_t x = current->cpus_allowed; 495 - /* Some bioses don't like being called from CPU != 0 */ 496 - set_cpus_allowed(current, cpumask_of_cpu(0)); 497 - BUG_ON(smp_processor_id() != 0); 498 - return x; 499 - } 500 - 501 - static inline void apm_restore_cpus(cpumask_t mask) 502 - { 503 - set_cpus_allowed(current, mask); 504 - } 505 - 506 - #else 507 - 508 - /* 509 - * No CPU lockdown needed on a uniprocessor 510 - */ 511 - 512 - #define apm_save_cpus() (current->cpus_allowed) 513 - #define apm_restore_cpus(x) (void)(x) 514 - 515 - #endif 516 487 517 488 /* 518 489 * These are the actual BIOS calls. Depending on APM_ZERO_SEGS and ··· 539 568 # define APM_DO_RESTORE_SEGS 540 569 #endif 541 570 571 + struct apm_bios_call { 572 + u32 func; 573 + /* In and out */ 574 + u32 ebx; 575 + u32 ecx; 576 + /* Out only */ 577 + u32 eax; 578 + u32 edx; 579 + u32 esi; 580 + 581 + /* Error: -ENOMEM, or bits 8-15 of eax */ 582 + int err; 583 + }; 584 + 542 585 /** 543 - * apm_bios_call - Make an APM BIOS 32bit call 544 - * @func: APM function to execute 545 - * @ebx_in: EBX register for call entry 546 - * @ecx_in: ECX register for call entry 547 - * @eax: EAX register return 548 - * @ebx: EBX register return 549 - * @ecx: ECX register return 550 - * @edx: EDX register return 551 - * @esi: ESI register return 586 + * __apm_bios_call - Make an APM BIOS 32bit call 587 + * @_call: pointer to struct apm_bios_call. 552 588 * 553 589 * Make an APM call using the 32bit protected mode interface. The 554 590 * caller is responsible for knowing if APM BIOS is configured and ··· 564 586 * flag is loaded into AL. If there is an error, then the error 565 587 * code is returned in AH (bits 8-15 of eax) and this function 566 588 * returns non-zero. 589 + * 590 + * Note: this makes the call on the current CPU. 567 591 */ 568 - 569 - static u8 apm_bios_call(u32 func, u32 ebx_in, u32 ecx_in, 570 - u32 *eax, u32 *ebx, u32 *ecx, u32 *edx, u32 *esi) 592 + static long __apm_bios_call(void *_call) 571 593 { 572 594 APM_DECL_SEGS 573 595 unsigned long flags; 574 - cpumask_t cpus; 575 596 int cpu; 576 597 struct desc_struct save_desc_40; 577 598 struct desc_struct *gdt; 578 - 579 - cpus = apm_save_cpus(); 599 + struct apm_bios_call *call = _call; 580 600 581 601 cpu = get_cpu(); 602 + BUG_ON(cpu != 0); 582 603 gdt = get_cpu_gdt_table(cpu); 583 604 save_desc_40 = gdt[0x40 / 8]; 584 605 gdt[0x40 / 8] = bad_bios_desc; 585 606 586 607 apm_irq_save(flags); 587 608 APM_DO_SAVE_SEGS; 588 - apm_bios_call_asm(func, ebx_in, ecx_in, eax, ebx, ecx, edx, esi); 609 + apm_bios_call_asm(call->func, call->ebx, call->ecx, 610 + &call->eax, &call->ebx, &call->ecx, &call->edx, 611 + &call->esi); 589 612 APM_DO_RESTORE_SEGS; 590 613 apm_irq_restore(flags); 591 614 gdt[0x40 / 8] = save_desc_40; 592 615 put_cpu(); 593 - apm_restore_cpus(cpus); 594 616 595 - return *eax & 0xff; 617 + return call->eax & 0xff; 618 + } 619 + 620 + /* Run __apm_bios_call or __apm_bios_call_simple on CPU 0 */ 621 + static int on_cpu0(long (*fn)(void *), struct apm_bios_call *call) 622 + { 623 + int ret; 624 + 625 + /* Don't bother with work_on_cpu in the common case, so we don't 626 + * have to worry about OOM or overhead. */ 627 + if (get_cpu() == 0) { 628 + ret = fn(call); 629 + put_cpu(); 630 + } else { 631 + put_cpu(); 632 + ret = work_on_cpu(0, fn, call); 633 + } 634 + 635 + /* work_on_cpu can fail with -ENOMEM */ 636 + if (ret < 0) 637 + call->err = ret; 638 + else 639 + call->err = (call->eax >> 8) & 0xff; 640 + 641 + return ret; 642 + } 643 + 644 + /** 645 + * apm_bios_call - Make an APM BIOS 32bit call (on CPU 0) 646 + * @call: the apm_bios_call registers. 647 + * 648 + * If there is an error, it is returned in @call.err. 649 + */ 650 + static int apm_bios_call(struct apm_bios_call *call) 651 + { 652 + return on_cpu0(__apm_bios_call, call); 653 + } 654 + 655 + /** 656 + * __apm_bios_call_simple - Make an APM BIOS 32bit call (on CPU 0) 657 + * @_call: pointer to struct apm_bios_call. 658 + * 659 + * Make a BIOS call that returns one value only, or just status. 660 + * If there is an error, then the error code is returned in AH 661 + * (bits 8-15 of eax) and this function returns non-zero (it can 662 + * also return -ENOMEM). This is used for simpler BIOS operations. 663 + * This call may hold interrupts off for a long time on some laptops. 664 + * 665 + * Note: this makes the call on the current CPU. 666 + */ 667 + static long __apm_bios_call_simple(void *_call) 668 + { 669 + u8 error; 670 + APM_DECL_SEGS 671 + unsigned long flags; 672 + int cpu; 673 + struct desc_struct save_desc_40; 674 + struct desc_struct *gdt; 675 + struct apm_bios_call *call = _call; 676 + 677 + cpu = get_cpu(); 678 + BUG_ON(cpu != 0); 679 + gdt = get_cpu_gdt_table(cpu); 680 + save_desc_40 = gdt[0x40 / 8]; 681 + gdt[0x40 / 8] = bad_bios_desc; 682 + 683 + apm_irq_save(flags); 684 + APM_DO_SAVE_SEGS; 685 + error = apm_bios_call_simple_asm(call->func, call->ebx, call->ecx, 686 + &call->eax); 687 + APM_DO_RESTORE_SEGS; 688 + apm_irq_restore(flags); 689 + gdt[0x40 / 8] = save_desc_40; 690 + put_cpu(); 691 + return error; 596 692 } 597 693 598 694 /** ··· 675 623 * @ebx_in: EBX register value for BIOS call 676 624 * @ecx_in: ECX register value for BIOS call 677 625 * @eax: EAX register on return from the BIOS call 626 + * @err: bits 678 627 * 679 628 * Make a BIOS call that returns one value only, or just status. 680 - * If there is an error, then the error code is returned in AH 681 - * (bits 8-15 of eax) and this function returns non-zero. This is 682 - * used for simpler BIOS operations. This call may hold interrupts 683 - * off for a long time on some laptops. 629 + * If there is an error, then the error code is returned in @err 630 + * and this function returns non-zero. This is used for simpler 631 + * BIOS operations. This call may hold interrupts off for a long 632 + * time on some laptops. 684 633 */ 685 - 686 - static u8 apm_bios_call_simple(u32 func, u32 ebx_in, u32 ecx_in, u32 *eax) 634 + static int apm_bios_call_simple(u32 func, u32 ebx_in, u32 ecx_in, u32 *eax, 635 + int *err) 687 636 { 688 - u8 error; 689 - APM_DECL_SEGS 690 - unsigned long flags; 691 - cpumask_t cpus; 692 - int cpu; 693 - struct desc_struct save_desc_40; 694 - struct desc_struct *gdt; 637 + struct apm_bios_call call; 638 + int ret; 695 639 696 - cpus = apm_save_cpus(); 640 + call.func = func; 641 + call.ebx = ebx_in; 642 + call.ecx = ecx_in; 697 643 698 - cpu = get_cpu(); 699 - gdt = get_cpu_gdt_table(cpu); 700 - save_desc_40 = gdt[0x40 / 8]; 701 - gdt[0x40 / 8] = bad_bios_desc; 702 - 703 - apm_irq_save(flags); 704 - APM_DO_SAVE_SEGS; 705 - error = apm_bios_call_simple_asm(func, ebx_in, ecx_in, eax); 706 - APM_DO_RESTORE_SEGS; 707 - apm_irq_restore(flags); 708 - gdt[0x40 / 8] = save_desc_40; 709 - put_cpu(); 710 - apm_restore_cpus(cpus); 711 - return error; 644 + ret = on_cpu0(__apm_bios_call_simple, &call); 645 + *eax = call.eax; 646 + *err = call.err; 647 + return ret; 712 648 } 713 649 714 650 /** ··· 718 678 static int apm_driver_version(u_short *val) 719 679 { 720 680 u32 eax; 681 + int err; 721 682 722 - if (apm_bios_call_simple(APM_FUNC_VERSION, 0, *val, &eax)) 723 - return (eax >> 8) & 0xff; 683 + if (apm_bios_call_simple(APM_FUNC_VERSION, 0, *val, &eax, &err)) 684 + return err; 724 685 *val = eax; 725 686 return APM_SUCCESS; 726 687 } ··· 742 701 * that APM 1.2 is in use. If no messges are pending the value 0x80 743 702 * is returned (No power management events pending). 744 703 */ 745 - 746 704 static int apm_get_event(apm_event_t *event, apm_eventinfo_t *info) 747 705 { 748 - u32 eax; 749 - u32 ebx; 750 - u32 ecx; 751 - u32 dummy; 706 + struct apm_bios_call call; 752 707 753 - if (apm_bios_call(APM_FUNC_GET_EVENT, 0, 0, &eax, &ebx, &ecx, 754 - &dummy, &dummy)) 755 - return (eax >> 8) & 0xff; 756 - *event = ebx; 708 + call.func = APM_FUNC_GET_EVENT; 709 + call.ebx = call.ecx = 0; 710 + 711 + if (apm_bios_call(&call)) 712 + return call.err; 713 + 714 + *event = call.ebx; 757 715 if (apm_info.connection_version < 0x0102) 758 716 *info = ~0; /* indicate info not valid */ 759 717 else 760 - *info = ecx; 718 + *info = call.ecx; 761 719 return APM_SUCCESS; 762 720 } 763 721 ··· 777 737 static int set_power_state(u_short what, u_short state) 778 738 { 779 739 u32 eax; 740 + int err; 780 741 781 - if (apm_bios_call_simple(APM_FUNC_SET_STATE, what, state, &eax)) 782 - return (eax >> 8) & 0xff; 742 + if (apm_bios_call_simple(APM_FUNC_SET_STATE, what, state, &eax, &err)) 743 + return err; 783 744 return APM_SUCCESS; 784 745 } 785 746 ··· 811 770 u8 ret = 0; 812 771 int idled = 0; 813 772 int polling; 773 + int err; 814 774 815 775 polling = !!(current_thread_info()->status & TS_POLLING); 816 776 if (polling) { ··· 824 782 } 825 783 if (!need_resched()) { 826 784 idled = 1; 827 - ret = apm_bios_call_simple(APM_FUNC_IDLE, 0, 0, &eax); 785 + ret = apm_bios_call_simple(APM_FUNC_IDLE, 0, 0, &eax, &err); 828 786 } 829 787 if (polling) 830 788 current_thread_info()->status |= TS_POLLING; ··· 839 797 * Only report the failure the first 5 times. 840 798 */ 841 799 if (++t < 5) { 842 - printk(KERN_DEBUG "apm_do_idle failed (%d)\n", 843 - (eax >> 8) & 0xff); 800 + printk(KERN_DEBUG "apm_do_idle failed (%d)\n", err); 844 801 t = jiffies; 845 802 } 846 803 return -1; ··· 857 816 static void apm_do_busy(void) 858 817 { 859 818 u32 dummy; 819 + int err; 860 820 861 821 if (clock_slowed || ALWAYS_CALL_BUSY) { 862 - (void)apm_bios_call_simple(APM_FUNC_BUSY, 0, 0, &dummy); 822 + (void)apm_bios_call_simple(APM_FUNC_BUSY, 0, 0, &dummy, &err); 863 823 clock_slowed = 0; 864 824 } 865 825 } ··· 979 937 980 938 /* Some bioses don't like being called from CPU != 0 */ 981 939 if (apm_info.realmode_power_off) { 982 - (void)apm_save_cpus(); 940 + set_cpus_allowed_ptr(current, cpumask_of(0)); 983 941 machine_real_restart(po_bios_call, sizeof(po_bios_call)); 984 942 } else { 985 943 (void)set_system_power_state(APM_STATE_OFF); ··· 998 956 static int apm_enable_power_management(int enable) 999 957 { 1000 958 u32 eax; 959 + int err; 1001 960 1002 961 if ((enable == 0) && (apm_info.bios.flags & APM_BIOS_DISENGAGED)) 1003 962 return APM_NOT_ENGAGED; 1004 963 if (apm_bios_call_simple(APM_FUNC_ENABLE_PM, APM_DEVICE_BALL, 1005 - enable, &eax)) 1006 - return (eax >> 8) & 0xff; 964 + enable, &eax, &err)) 965 + return err; 1007 966 if (enable) 1008 967 apm_info.bios.flags &= ~APM_BIOS_DISABLED; 1009 968 else ··· 1029 986 1030 987 static int apm_get_power_status(u_short *status, u_short *bat, u_short *life) 1031 988 { 1032 - u32 eax; 1033 - u32 ebx; 1034 - u32 ecx; 1035 - u32 edx; 1036 - u32 dummy; 989 + struct apm_bios_call call; 990 + 991 + call.func = APM_FUNC_GET_STATUS; 992 + call.ebx = APM_DEVICE_ALL; 993 + call.ecx = 0; 1037 994 1038 995 if (apm_info.get_power_status_broken) 1039 996 return APM_32_UNSUPPORTED; 1040 - if (apm_bios_call(APM_FUNC_GET_STATUS, APM_DEVICE_ALL, 0, 1041 - &eax, &ebx, &ecx, &edx, &dummy)) 1042 - return (eax >> 8) & 0xff; 1043 - *status = ebx; 1044 - *bat = ecx; 997 + if (apm_bios_call(&call)) 998 + return call.err; 999 + *status = call.ebx; 1000 + *bat = call.ecx; 1045 1001 if (apm_info.get_power_status_swabinminutes) { 1046 - *life = swab16((u16)edx); 1002 + *life = swab16((u16)call.edx); 1047 1003 *life |= 0x8000; 1048 1004 } else 1049 - *life = edx; 1005 + *life = call.edx; 1050 1006 return APM_SUCCESS; 1051 1007 } 1052 1008 ··· 1090 1048 static int apm_engage_power_management(u_short device, int enable) 1091 1049 { 1092 1050 u32 eax; 1051 + int err; 1093 1052 1094 1053 if ((enable == 0) && (device == APM_DEVICE_ALL) 1095 1054 && (apm_info.bios.flags & APM_BIOS_DISABLED)) 1096 1055 return APM_DISABLED; 1097 - if (apm_bios_call_simple(APM_FUNC_ENGAGE_PM, device, enable, &eax)) 1098 - return (eax >> 8) & 0xff; 1056 + if (apm_bios_call_simple(APM_FUNC_ENGAGE_PM, device, enable, 1057 + &eax, &err)) 1058 + return err; 1099 1059 if (device == APM_DEVICE_ALL) { 1100 1060 if (enable) 1101 1061 apm_info.bios.flags &= ~APM_BIOS_DISENGAGED; ··· 1733 1689 char *power_stat; 1734 1690 char *bat_stat; 1735 1691 1736 - #ifdef CONFIG_SMP 1737 1692 /* 2002/08/01 - WT 1738 1693 * This is to avoid random crashes at boot time during initialization 1739 1694 * on SMP systems in case of "apm=power-off" mode. Seen on ASUS A7M266D. 1740 1695 * Some bioses don't like being called from CPU != 0. 1741 1696 * Method suggested by Ingo Molnar. 1742 1697 */ 1743 - set_cpus_allowed(current, cpumask_of_cpu(0)); 1698 + set_cpus_allowed_ptr(current, cpumask_of(0)); 1744 1699 BUG_ON(smp_processor_id() != 0); 1745 - #endif 1746 1700 1747 1701 if (apm_info.connection_version == 0) { 1748 1702 apm_info.connection_version = apm_info.bios.version;
+1 -12
arch/x86/kernel/cpu/common.c
··· 41 41 42 42 #include "cpu.h" 43 43 44 - #ifdef CONFIG_X86_64 45 - 46 44 /* all of these masks are initialized in setup_cpu_local_masks() */ 47 45 cpumask_var_t cpu_initialized_mask; 48 46 cpumask_var_t cpu_callout_mask; ··· 57 59 alloc_bootmem_cpumask_var(&cpu_callout_mask); 58 60 alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask); 59 61 } 60 - 61 - #else /* CONFIG_X86_32 */ 62 - 63 - cpumask_t cpu_sibling_setup_map; 64 - cpumask_t cpu_callout_map; 65 - cpumask_t cpu_initialized; 66 - cpumask_t cpu_callin_map; 67 - 68 - #endif /* CONFIG_X86_32 */ 69 - 70 62 71 63 static const struct cpu_dev *this_cpu __cpuinitdata; 72 64 ··· 847 859 void __init identify_boot_cpu(void) 848 860 { 849 861 identify_cpu(&boot_cpu_data); 862 + init_c1e_mask(); 850 863 #ifdef CONFIG_X86_32 851 864 sysenter_setup(); 852 865 enable_sep_cpu();
+1 -1
arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
··· 211 211 unsigned int i; 212 212 213 213 #ifdef CONFIG_SMP 214 - cpumask_copy(policy->cpus, &per_cpu(cpu_sibling_map, policy->cpu)); 214 + cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu)); 215 215 #endif 216 216 217 217 /* Errata workaround */
+8 -5
arch/x86/kernel/cpu/cpufreq/powernow-k8.c
··· 54 54 static int cpu_family = CPU_OPTERON; 55 55 56 56 #ifndef CONFIG_SMP 57 - DEFINE_PER_CPU(cpumask_t, cpu_core_map); 57 + static inline const struct cpumask *cpu_core_mask(int cpu) 58 + { 59 + return cpumask_of(0); 60 + } 58 61 #endif 59 62 60 63 /* Return a frequency in MHz, given an input fid */ ··· 702 699 703 700 dprintk("cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid); 704 701 data->powernow_table = powernow_table; 705 - if (first_cpu(per_cpu(cpu_core_map, data->cpu)) == data->cpu) 702 + if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu) 706 703 print_basics(data); 707 704 708 705 for (j = 0; j < data->numps; j++) ··· 865 862 866 863 /* fill in data */ 867 864 data->numps = data->acpi_data.state_count; 868 - if (first_cpu(per_cpu(cpu_core_map, data->cpu)) == data->cpu) 865 + if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu) 869 866 print_basics(data); 870 867 powernow_k8_acpi_pst_values(data, 0); 871 868 ··· 1303 1300 if (cpu_family == CPU_HW_PSTATE) 1304 1301 cpumask_copy(pol->cpus, cpumask_of(pol->cpu)); 1305 1302 else 1306 - cpumask_copy(pol->cpus, &per_cpu(cpu_core_map, pol->cpu)); 1303 + cpumask_copy(pol->cpus, cpu_core_mask(pol->cpu)); 1307 1304 data->available_cores = pol->cpus; 1308 1305 1309 1306 if (cpu_family == CPU_HW_PSTATE) ··· 1368 1365 unsigned int khz = 0; 1369 1366 unsigned int first; 1370 1367 1371 - first = first_cpu(per_cpu(cpu_core_map, cpu)); 1368 + first = cpumask_first(cpu_core_mask(cpu)); 1372 1369 data = per_cpu(powernow_data, first); 1373 1370 1374 1371 if (!data)
+1 -1
arch/x86/kernel/cpu/cpufreq/speedstep-ich.c
··· 321 321 322 322 /* only run on CPU to be set, or on its sibling */ 323 323 #ifdef CONFIG_SMP 324 - cpumask_copy(policy->cpus, &per_cpu(cpu_sibling_map, policy->cpu)); 324 + cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu)); 325 325 #endif 326 326 327 327 cpus_allowed = current->cpus_allowed;
+12 -12
arch/x86/kernel/cpu/intel_cacheinfo.c
··· 159 159 unsigned long can_disable; 160 160 }; 161 161 162 - #ifdef CONFIG_PCI 162 + #if defined(CONFIG_PCI) && defined(CONFIG_SYSFS) 163 163 static struct pci_device_id k8_nb_id[] = { 164 164 { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1103) }, 165 165 { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1203) }, ··· 322 322 (ebx.split.physical_line_partition + 1) * 323 323 (ebx.split.ways_of_associativity + 1); 324 324 return 0; 325 - } 326 - 327 - static int 328 - __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf) 329 - { 330 - struct _cpuid4_info_regs *leaf_regs = 331 - (struct _cpuid4_info_regs *)this_leaf; 332 - 333 - return cpuid4_cache_lookup_regs(index, leaf_regs); 334 325 } 335 326 336 327 static int __cpuinit find_num_cache_leaves(void) ··· 499 508 return l2; 500 509 } 501 510 511 + #ifdef CONFIG_SYSFS 512 + 502 513 /* pointer to _cpuid4_info array (for each cache leaf) */ 503 514 static DEFINE_PER_CPU(struct _cpuid4_info *, cpuid4_info); 504 515 #define CPUID4_INFO_IDX(x, y) (&((per_cpu(cpuid4_info, x))[y])) ··· 564 571 per_cpu(cpuid4_info, cpu) = NULL; 565 572 } 566 573 574 + static int 575 + __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf) 576 + { 577 + struct _cpuid4_info_regs *leaf_regs = 578 + (struct _cpuid4_info_regs *)this_leaf; 579 + 580 + return cpuid4_cache_lookup_regs(index, leaf_regs); 581 + } 582 + 567 583 static void __cpuinit get_cpu_leaves(void *_retval) 568 584 { 569 585 int j, *retval = _retval, cpu = smp_processor_id(); ··· 613 611 614 612 return retval; 615 613 } 616 - 617 - #ifdef CONFIG_SYSFS 618 614 619 615 #include <linux/kobject.h> 620 616 #include <linux/sysfs.h>
+6 -4
arch/x86/kernel/cpu/mcheck/mce_64.c
··· 990 990 NULL 991 991 }; 992 992 993 - static cpumask_t mce_device_initialized = CPU_MASK_NONE; 993 + static cpumask_var_t mce_device_initialized; 994 994 995 995 /* Per cpu sysdev init. All of the cpus still share the same ctl bank */ 996 996 static __cpuinit int mce_create_device(unsigned int cpu) ··· 1021 1021 if (err) 1022 1022 goto error2; 1023 1023 } 1024 - cpu_set(cpu, mce_device_initialized); 1024 + cpumask_set_cpu(cpu, mce_device_initialized); 1025 1025 1026 1026 return 0; 1027 1027 error2: ··· 1043 1043 { 1044 1044 int i; 1045 1045 1046 - if (!cpu_isset(cpu, mce_device_initialized)) 1046 + if (!cpumask_test_cpu(cpu, mce_device_initialized)) 1047 1047 return; 1048 1048 1049 1049 for (i = 0; mce_attributes[i]; i++) ··· 1053 1053 sysdev_remove_file(&per_cpu(device_mce, cpu), 1054 1054 &bank_attrs[i]); 1055 1055 sysdev_unregister(&per_cpu(device_mce,cpu)); 1056 - cpu_clear(cpu, mce_device_initialized); 1056 + cpumask_clear_cpu(cpu, mce_device_initialized); 1057 1057 } 1058 1058 1059 1059 /* Make sure there are no machine checks on offlined CPUs. */ ··· 1161 1161 1162 1162 if (!mce_available(&boot_cpu_data)) 1163 1163 return -EIO; 1164 + 1165 + alloc_cpumask_var(&mce_device_initialized, GFP_KERNEL); 1164 1166 1165 1167 err = mce_init_banks(); 1166 1168 if (err)
+3 -3
arch/x86/kernel/cpu/mcheck/mce_amd_64.c
··· 485 485 486 486 #ifdef CONFIG_SMP 487 487 if (cpu_data(cpu).cpu_core_id && shared_bank[bank]) { /* symlink */ 488 - i = cpumask_first(&per_cpu(cpu_core_map, cpu)); 488 + i = cpumask_first(cpu_core_mask(cpu)); 489 489 490 490 /* first core not up yet */ 491 491 if (cpu_data(i).cpu_core_id) ··· 505 505 if (err) 506 506 goto out; 507 507 508 - cpumask_copy(b->cpus, &per_cpu(cpu_core_map, cpu)); 508 + cpumask_copy(b->cpus, cpu_core_mask(cpu)); 509 509 per_cpu(threshold_banks, cpu)[bank] = b; 510 510 goto out; 511 511 } ··· 529 529 #ifndef CONFIG_SMP 530 530 cpumask_setall(b->cpus); 531 531 #else 532 - cpumask_copy(b->cpus, &per_cpu(cpu_core_map, cpu)); 532 + cpumask_copy(b->cpus, cpu_core_mask(cpu)); 533 533 #endif 534 534 535 535 per_cpu(threshold_banks, cpu)[bank] = b;
+1 -1
arch/x86/kernel/cpu/mcheck/mce_intel_64.c
··· 249 249 for_each_online_cpu (cpu) { 250 250 if (cpu == dying) 251 251 continue; 252 - if (set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu))) 252 + if (set_cpus_allowed_ptr(current, cpumask_of(cpu))) 253 253 continue; 254 254 /* Recheck banks in case CPUs don't all have the same */ 255 255 if (cmci_supported(&banks))
+3 -3
arch/x86/kernel/cpu/proc.c
··· 14 14 if (c->x86_max_cores * smp_num_siblings > 1) { 15 15 seq_printf(m, "physical id\t: %d\n", c->phys_proc_id); 16 16 seq_printf(m, "siblings\t: %d\n", 17 - cpus_weight(per_cpu(cpu_core_map, cpu))); 17 + cpumask_weight(cpu_sibling_mask(cpu))); 18 18 seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id); 19 19 seq_printf(m, "cpu cores\t: %d\n", c->booted_cores); 20 20 seq_printf(m, "apicid\t\t: %d\n", c->apicid); ··· 143 143 static void *c_start(struct seq_file *m, loff_t *pos) 144 144 { 145 145 if (*pos == 0) /* just in case, cpu 0 is not the first */ 146 - *pos = first_cpu(cpu_online_map); 146 + *pos = cpumask_first(cpu_online_mask); 147 147 else 148 - *pos = next_cpu_nr(*pos - 1, cpu_online_map); 148 + *pos = cpumask_next(*pos - 1, cpu_online_mask); 149 149 if ((*pos) < nr_cpu_ids) 150 150 return &cpu_data(*pos); 151 151 return NULL;
+23 -26
arch/x86/kernel/microcode_amd.c
··· 12 12 * 13 13 * Licensed under the terms of the GNU General Public 14 14 * License version 2. See file COPYING for details. 15 - */ 16 - 17 - #include <linux/capability.h> 18 - #include <linux/kernel.h> 19 - #include <linux/init.h> 20 - #include <linux/sched.h> 21 - #include <linux/cpumask.h> 22 - #include <linux/module.h> 23 - #include <linux/slab.h> 24 - #include <linux/vmalloc.h> 25 - #include <linux/miscdevice.h> 26 - #include <linux/spinlock.h> 27 - #include <linux/mm.h> 28 - #include <linux/fs.h> 29 - #include <linux/mutex.h> 30 - #include <linux/cpu.h> 31 - #include <linux/firmware.h> 15 + */ 32 16 #include <linux/platform_device.h> 33 - #include <linux/pci.h> 17 + #include <linux/capability.h> 18 + #include <linux/miscdevice.h> 19 + #include <linux/firmware.h> 20 + #include <linux/spinlock.h> 21 + #include <linux/cpumask.h> 34 22 #include <linux/pci_ids.h> 35 23 #include <linux/uaccess.h> 24 + #include <linux/vmalloc.h> 25 + #include <linux/kernel.h> 26 + #include <linux/module.h> 27 + #include <linux/mutex.h> 28 + #include <linux/sched.h> 29 + #include <linux/init.h> 30 + #include <linux/slab.h> 31 + #include <linux/cpu.h> 32 + #include <linux/pci.h> 33 + #include <linux/fs.h> 34 + #include <linux/mm.h> 36 35 37 - #include <asm/msr.h> 38 - #include <asm/processor.h> 39 36 #include <asm/microcode.h> 37 + #include <asm/processor.h> 38 + #include <asm/msr.h> 40 39 41 40 MODULE_DESCRIPTION("AMD Microcode Update Driver"); 42 41 MODULE_AUTHOR("Peter Oruba"); ··· 71 72 } __attribute__((packed)); 72 73 73 74 struct microcode_amd { 74 - struct microcode_header_amd hdr; 75 - unsigned int mpb[0]; 75 + struct microcode_header_amd hdr; 76 + unsigned int mpb[0]; 76 77 }; 77 78 78 79 #define UCODE_MAX_SIZE 2048 ··· 183 184 return 0; 184 185 } 185 186 186 - static void *get_next_ucode(const u8 *buf, unsigned int size, 187 - unsigned int *mc_size) 187 + static void * 188 + get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size) 188 189 { 189 190 unsigned int total_size; 190 191 u8 section_hdr[UCODE_CONTAINER_SECTION_HDR]; ··· 221 222 } 222 223 return mc; 223 224 } 224 - 225 225 226 226 static int install_equiv_cpu_table(const u8 *buf) 227 227 { ··· 370 372 { 371 373 return &microcode_amd_ops; 372 374 } 373 -
+93 -77
arch/x86/kernel/microcode_core.c
··· 70 70 * Fix sigmatch() macro to handle old CPUs with pf == 0. 71 71 * Thanks to Stuart Swales for pointing out this bug. 72 72 */ 73 - #include <linux/capability.h> 74 - #include <linux/kernel.h> 75 - #include <linux/init.h> 76 - #include <linux/sched.h> 77 - #include <linux/smp_lock.h> 78 - #include <linux/cpumask.h> 79 - #include <linux/module.h> 80 - #include <linux/slab.h> 81 - #include <linux/vmalloc.h> 82 - #include <linux/miscdevice.h> 83 - #include <linux/spinlock.h> 84 - #include <linux/mm.h> 85 - #include <linux/fs.h> 86 - #include <linux/mutex.h> 87 - #include <linux/cpu.h> 88 - #include <linux/firmware.h> 89 73 #include <linux/platform_device.h> 74 + #include <linux/capability.h> 75 + #include <linux/miscdevice.h> 76 + #include <linux/firmware.h> 77 + #include <linux/smp_lock.h> 78 + #include <linux/spinlock.h> 79 + #include <linux/cpumask.h> 80 + #include <linux/uaccess.h> 81 + #include <linux/vmalloc.h> 82 + #include <linux/kernel.h> 83 + #include <linux/module.h> 84 + #include <linux/mutex.h> 85 + #include <linux/sched.h> 86 + #include <linux/init.h> 87 + #include <linux/slab.h> 88 + #include <linux/cpu.h> 89 + #include <linux/fs.h> 90 + #include <linux/mm.h> 90 91 91 - #include <asm/msr.h> 92 - #include <asm/uaccess.h> 93 - #include <asm/processor.h> 94 92 #include <asm/microcode.h> 93 + #include <asm/processor.h> 94 + #include <asm/msr.h> 95 95 96 96 MODULE_DESCRIPTION("Microcode Update Driver"); 97 97 MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>"); 98 98 MODULE_LICENSE("GPL"); 99 99 100 - #define MICROCODE_VERSION "2.00" 100 + #define MICROCODE_VERSION "2.00" 101 101 102 - static struct microcode_ops *microcode_ops; 102 + static struct microcode_ops *microcode_ops; 103 103 104 104 /* no concurrent ->write()s are allowed on /dev/cpu/microcode */ 105 105 static DEFINE_MUTEX(microcode_mutex); 106 106 107 - struct ucode_cpu_info ucode_cpu_info[NR_CPUS]; 107 + struct ucode_cpu_info ucode_cpu_info[NR_CPUS]; 108 108 EXPORT_SYMBOL_GPL(ucode_cpu_info); 109 109 110 110 #ifdef CONFIG_MICROCODE_OLD_INTERFACE 111 + struct update_for_cpu { 112 + const void __user *buf; 113 + size_t size; 114 + }; 115 + 116 + static long update_for_cpu(void *_ufc) 117 + { 118 + struct update_for_cpu *ufc = _ufc; 119 + int error; 120 + 121 + error = microcode_ops->request_microcode_user(smp_processor_id(), 122 + ufc->buf, ufc->size); 123 + if (error < 0) 124 + return error; 125 + if (!error) 126 + microcode_ops->apply_microcode(smp_processor_id()); 127 + return error; 128 + } 129 + 111 130 static int do_microcode_update(const void __user *buf, size_t size) 112 131 { 113 - cpumask_t old; 114 132 int error = 0; 115 133 int cpu; 116 - 117 - old = current->cpus_allowed; 134 + struct update_for_cpu ufc = { .buf = buf, .size = size }; 118 135 119 136 for_each_online_cpu(cpu) { 120 137 struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 121 138 122 139 if (!uci->valid) 123 140 continue; 124 - 125 - set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 126 - error = microcode_ops->request_microcode_user(cpu, buf, size); 141 + error = work_on_cpu(cpu, update_for_cpu, &ufc); 127 142 if (error < 0) 128 - goto out; 129 - if (!error) 130 - microcode_ops->apply_microcode(cpu); 143 + break; 131 144 } 132 - out: 133 - set_cpus_allowed_ptr(current, &old); 134 145 return error; 135 146 } 136 147 ··· 209 198 210 199 MODULE_ALIAS_MISCDEV(MICROCODE_MINOR); 211 200 #else 212 - #define microcode_dev_init() 0 213 - #define microcode_dev_exit() do { } while (0) 201 + #define microcode_dev_init() 0 202 + #define microcode_dev_exit() do { } while (0) 214 203 #endif 215 204 216 205 /* fake device for request_firmware */ 217 - static struct platform_device *microcode_pdev; 206 + static struct platform_device *microcode_pdev; 207 + 208 + static long reload_for_cpu(void *unused) 209 + { 210 + struct ucode_cpu_info *uci = ucode_cpu_info + smp_processor_id(); 211 + int err = 0; 212 + 213 + mutex_lock(&microcode_mutex); 214 + if (uci->valid) { 215 + err = microcode_ops->request_microcode_fw(smp_processor_id(), 216 + &microcode_pdev->dev); 217 + if (!err) 218 + microcode_ops->apply_microcode(smp_processor_id()); 219 + } 220 + mutex_unlock(&microcode_mutex); 221 + return err; 222 + } 218 223 219 224 static ssize_t reload_store(struct sys_device *dev, 220 225 struct sysdev_attribute *attr, 221 226 const char *buf, size_t sz) 222 227 { 223 - struct ucode_cpu_info *uci = ucode_cpu_info + dev->id; 224 228 char *end; 225 229 unsigned long val = simple_strtoul(buf, &end, 0); 226 230 int err = 0; ··· 244 218 if (end == buf) 245 219 return -EINVAL; 246 220 if (val == 1) { 247 - cpumask_t old = current->cpus_allowed; 248 - 249 221 get_online_cpus(); 250 - if (cpu_online(cpu)) { 251 - set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 252 - mutex_lock(&microcode_mutex); 253 - if (uci->valid) { 254 - err = microcode_ops->request_microcode_fw(cpu, 255 - &microcode_pdev->dev); 256 - if (!err) 257 - microcode_ops->apply_microcode(cpu); 258 - } 259 - mutex_unlock(&microcode_mutex); 260 - set_cpus_allowed_ptr(current, &old); 261 - } 222 + if (cpu_online(cpu)) 223 + err = work_on_cpu(cpu, reload_for_cpu, NULL); 262 224 put_online_cpus(); 263 225 } 264 226 if (err) ··· 282 268 }; 283 269 284 270 static struct attribute_group mc_attr_group = { 285 - .attrs = mc_default_attrs, 286 - .name = "microcode", 271 + .attrs = mc_default_attrs, 272 + .name = "microcode", 287 273 }; 288 274 289 275 static void __microcode_fini_cpu(int cpu) ··· 342 328 return 0; 343 329 } 344 330 345 - static void microcode_update_cpu(int cpu) 331 + static long microcode_update_cpu(void *unused) 346 332 { 347 - struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 333 + struct ucode_cpu_info *uci = ucode_cpu_info + smp_processor_id(); 348 334 int err = 0; 349 335 350 336 /* ··· 352 338 * otherwise just request a firmware: 353 339 */ 354 340 if (uci->valid) { 355 - err = microcode_resume_cpu(cpu); 356 - } else { 357 - collect_cpu_info(cpu); 341 + err = microcode_resume_cpu(smp_processor_id()); 342 + } else { 343 + collect_cpu_info(smp_processor_id()); 358 344 if (uci->valid && system_state == SYSTEM_RUNNING) 359 - err = microcode_ops->request_microcode_fw(cpu, 345 + err = microcode_ops->request_microcode_fw( 346 + smp_processor_id(), 360 347 &microcode_pdev->dev); 361 348 } 362 349 if (!err) 363 - microcode_ops->apply_microcode(cpu); 350 + microcode_ops->apply_microcode(smp_processor_id()); 351 + return err; 364 352 } 365 353 366 - static void microcode_init_cpu(int cpu) 354 + static int microcode_init_cpu(int cpu) 367 355 { 368 - cpumask_t old = current->cpus_allowed; 369 - 370 - set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 371 - /* We should bind the task to the CPU */ 372 - BUG_ON(raw_smp_processor_id() != cpu); 373 - 356 + int err; 374 357 mutex_lock(&microcode_mutex); 375 - microcode_update_cpu(cpu); 358 + err = work_on_cpu(cpu, microcode_update_cpu, NULL); 376 359 mutex_unlock(&microcode_mutex); 377 360 378 - set_cpus_allowed_ptr(current, &old); 361 + return err; 379 362 } 380 363 381 364 static int mc_sysdev_add(struct sys_device *sys_dev) ··· 390 379 if (err) 391 380 return err; 392 381 393 - microcode_init_cpu(cpu); 394 - return 0; 382 + err = microcode_init_cpu(cpu); 383 + if (err) 384 + sysfs_remove_group(&sys_dev->kobj, &mc_attr_group); 385 + 386 + return err; 395 387 } 396 388 397 389 static int mc_sysdev_remove(struct sys_device *sys_dev) ··· 418 404 return 0; 419 405 420 406 /* only CPU 0 will apply ucode here */ 421 - microcode_update_cpu(0); 407 + microcode_update_cpu(NULL); 422 408 return 0; 423 409 } 424 410 425 411 static struct sysdev_driver mc_sysdev_driver = { 426 - .add = mc_sysdev_add, 427 - .remove = mc_sysdev_remove, 428 - .resume = mc_sysdev_resume, 412 + .add = mc_sysdev_add, 413 + .remove = mc_sysdev_remove, 414 + .resume = mc_sysdev_resume, 429 415 }; 430 416 431 417 static __cpuinit int ··· 438 424 switch (action) { 439 425 case CPU_ONLINE: 440 426 case CPU_ONLINE_FROZEN: 441 - microcode_init_cpu(cpu); 427 + if (microcode_init_cpu(cpu)) 428 + printk(KERN_ERR "microcode: failed to init CPU%d\n", 429 + cpu); 442 430 case CPU_DOWN_FAILED: 443 431 case CPU_DOWN_FAILED_FROZEN: 444 432 pr_debug("microcode: CPU%d added\n", cpu); ··· 464 448 } 465 449 466 450 static struct notifier_block __refdata mc_cpu_notifier = { 467 - .notifier_call = mc_cpu_callback, 451 + .notifier_call = mc_cpu_callback, 468 452 }; 469 453 470 454 static int __init microcode_init(void)
+52 -39
arch/x86/kernel/microcode_intel.c
··· 70 70 * Fix sigmatch() macro to handle old CPUs with pf == 0. 71 71 * Thanks to Stuart Swales for pointing out this bug. 72 72 */ 73 - #include <linux/capability.h> 74 - #include <linux/kernel.h> 75 - #include <linux/init.h> 76 - #include <linux/sched.h> 77 - #include <linux/smp_lock.h> 78 - #include <linux/cpumask.h> 79 - #include <linux/module.h> 80 - #include <linux/slab.h> 81 - #include <linux/vmalloc.h> 82 - #include <linux/miscdevice.h> 83 - #include <linux/spinlock.h> 84 - #include <linux/mm.h> 85 - #include <linux/fs.h> 86 - #include <linux/mutex.h> 87 - #include <linux/cpu.h> 88 - #include <linux/firmware.h> 89 73 #include <linux/platform_device.h> 74 + #include <linux/capability.h> 75 + #include <linux/miscdevice.h> 76 + #include <linux/firmware.h> 77 + #include <linux/smp_lock.h> 78 + #include <linux/spinlock.h> 79 + #include <linux/cpumask.h> 90 80 #include <linux/uaccess.h> 81 + #include <linux/vmalloc.h> 82 + #include <linux/kernel.h> 83 + #include <linux/module.h> 84 + #include <linux/mutex.h> 85 + #include <linux/sched.h> 86 + #include <linux/init.h> 87 + #include <linux/slab.h> 88 + #include <linux/cpu.h> 89 + #include <linux/fs.h> 90 + #include <linux/mm.h> 91 91 92 - #include <asm/msr.h> 93 - #include <asm/processor.h> 94 92 #include <asm/microcode.h> 93 + #include <asm/processor.h> 94 + #include <asm/msr.h> 95 95 96 96 MODULE_DESCRIPTION("Microcode Update Driver"); 97 97 MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>"); ··· 129 129 struct extended_signature sigs[0]; 130 130 }; 131 131 132 - #define DEFAULT_UCODE_DATASIZE (2000) 132 + #define DEFAULT_UCODE_DATASIZE (2000) 133 133 #define MC_HEADER_SIZE (sizeof(struct microcode_header_intel)) 134 134 #define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE) 135 135 #define EXT_HEADER_SIZE (sizeof(struct extended_sigtable)) 136 136 #define EXT_SIGNATURE_SIZE (sizeof(struct extended_signature)) 137 137 #define DWSIZE (sizeof(u32)) 138 + 138 139 #define get_totalsize(mc) \ 139 140 (((struct microcode_intel *)mc)->hdr.totalsize ? \ 140 141 ((struct microcode_intel *)mc)->hdr.totalsize : \ ··· 198 197 } 199 198 200 199 static inline int 201 - update_match_revision(struct microcode_header_intel *mc_header, int rev) 200 + update_match_revision(struct microcode_header_intel *mc_header, int rev) 202 201 { 203 202 return (mc_header->rev <= rev) ? 0 : 1; 204 203 } 205 204 206 205 static int microcode_sanity_check(void *mc) 207 206 { 207 + unsigned long total_size, data_size, ext_table_size; 208 208 struct microcode_header_intel *mc_header = mc; 209 209 struct extended_sigtable *ext_header = NULL; 210 - struct extended_signature *ext_sig; 211 - unsigned long total_size, data_size, ext_table_size; 212 210 int sum, orig_sum, ext_sigcount = 0, i; 211 + struct extended_signature *ext_sig; 213 212 214 213 total_size = get_totalsize(mc_header); 215 214 data_size = get_datasize(mc_header); 215 + 216 216 if (data_size + MC_HEADER_SIZE > total_size) { 217 217 printk(KERN_ERR "microcode: error! " 218 - "Bad data size in microcode data file\n"); 218 + "Bad data size in microcode data file\n"); 219 219 return -EINVAL; 220 220 } 221 221 222 222 if (mc_header->ldrver != 1 || mc_header->hdrver != 1) { 223 223 printk(KERN_ERR "microcode: error! " 224 - "Unknown microcode update format\n"); 224 + "Unknown microcode update format\n"); 225 225 return -EINVAL; 226 226 } 227 227 ext_table_size = total_size - (MC_HEADER_SIZE + data_size); ··· 320 318 321 319 static void apply_microcode(int cpu) 322 320 { 321 + struct microcode_intel *mc_intel; 322 + struct ucode_cpu_info *uci; 323 323 unsigned long flags; 324 324 unsigned int val[2]; 325 - int cpu_num = raw_smp_processor_id(); 326 - struct ucode_cpu_info *uci = ucode_cpu_info + cpu; 327 - struct microcode_intel *mc_intel = uci->mc; 325 + int cpu_num; 326 + 327 + cpu_num = raw_smp_processor_id(); 328 + uci = ucode_cpu_info + cpu; 329 + mc_intel = uci->mc; 328 330 329 331 /* We should bind the task to the CPU */ 330 332 BUG_ON(cpu_num != cpu); ··· 354 348 spin_unlock_irqrestore(&microcode_update_lock, flags); 355 349 if (val[1] != mc_intel->hdr.rev) { 356 350 printk(KERN_ERR "microcode: CPU%d update from revision " 357 - "0x%x to 0x%x failed\n", cpu_num, uci->cpu_sig.rev, val[1]); 351 + "0x%x to 0x%x failed\n", 352 + cpu_num, uci->cpu_sig.rev, val[1]); 358 353 return; 359 354 } 360 355 printk(KERN_INFO "microcode: CPU%d updated from revision " 361 - "0x%x to 0x%x, date = %04x-%02x-%02x \n", 356 + "0x%x to 0x%x, date = %04x-%02x-%02x \n", 362 357 cpu_num, uci->cpu_sig.rev, val[1], 363 358 mc_intel->hdr.date & 0xffff, 364 359 mc_intel->hdr.date >> 24, 365 360 (mc_intel->hdr.date >> 16) & 0xff); 361 + 366 362 uci->cpu_sig.rev = val[1]; 367 363 } 368 364 ··· 412 404 leftover -= mc_size; 413 405 } 414 406 415 - if (new_mc) { 416 - if (!leftover) { 417 - if (uci->mc) 418 - vfree(uci->mc); 419 - uci->mc = (struct microcode_intel *)new_mc; 420 - pr_debug("microcode: CPU%d found a matching microcode update with" 421 - " version 0x%x (current=0x%x)\n", 422 - cpu, new_rev, uci->cpu_sig.rev); 423 - } else 424 - vfree(new_mc); 407 + if (!new_mc) 408 + goto out; 409 + 410 + if (leftover) { 411 + vfree(new_mc); 412 + goto out; 425 413 } 426 414 415 + if (uci->mc) 416 + vfree(uci->mc); 417 + uci->mc = (struct microcode_intel *)new_mc; 418 + 419 + pr_debug("microcode: CPU%d found a matching microcode update with" 420 + " version 0x%x (current=0x%x)\n", 421 + cpu, new_rev, uci->cpu_sig.rev); 422 + 423 + out: 427 424 return (int)leftover; 428 425 } 429 426
+15 -5
arch/x86/kernel/process.c
··· 325 325 /* 326 326 * Remove this CPU: 327 327 */ 328 - cpu_clear(smp_processor_id(), cpu_online_map); 328 + set_cpu_online(smp_processor_id(), false); 329 329 disable_local_APIC(); 330 330 331 331 for (;;) { ··· 475 475 return 1; 476 476 } 477 477 478 - static cpumask_t c1e_mask = CPU_MASK_NONE; 478 + static cpumask_var_t c1e_mask; 479 479 static int c1e_detected; 480 480 481 481 void c1e_remove_cpu(int cpu) 482 482 { 483 - cpu_clear(cpu, c1e_mask); 483 + if (c1e_mask != NULL) 484 + cpumask_clear_cpu(cpu, c1e_mask); 484 485 } 485 486 486 487 /* ··· 510 509 if (c1e_detected) { 511 510 int cpu = smp_processor_id(); 512 511 513 - if (!cpu_isset(cpu, c1e_mask)) { 514 - cpu_set(cpu, c1e_mask); 512 + if (!cpumask_test_cpu(cpu, c1e_mask)) { 513 + cpumask_set_cpu(cpu, c1e_mask); 515 514 /* 516 515 * Force broadcast so ACPI can not interfere. Needs 517 516 * to run with interrupts enabled as it uses ··· 561 560 pm_idle = c1e_idle; 562 561 } else 563 562 pm_idle = default_idle; 563 + } 564 + 565 + void __init init_c1e_mask(void) 566 + { 567 + /* If we're using c1e_idle, we need to allocate c1e_mask. */ 568 + if (pm_idle == c1e_idle) { 569 + alloc_cpumask_var(&c1e_mask, GFP_KERNEL); 570 + cpumask_clear(c1e_mask); 571 + } 564 572 } 565 573 566 574 static int __init idle_setup(char *str)
+43 -27
arch/x86/kernel/smpboot.c
··· 101 101 DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID; 102 102 103 103 /* representing HT siblings of each logical CPU */ 104 - DEFINE_PER_CPU(cpumask_t, cpu_sibling_map); 104 + DEFINE_PER_CPU(cpumask_var_t, cpu_sibling_map); 105 105 EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); 106 106 107 107 /* representing HT and core siblings of each logical CPU */ 108 - DEFINE_PER_CPU(cpumask_t, cpu_core_map); 108 + DEFINE_PER_CPU(cpumask_var_t, cpu_core_map); 109 109 EXPORT_PER_CPU_SYMBOL(cpu_core_map); 110 110 111 111 /* Per CPU bogomips and other parameters */ ··· 115 115 atomic_t init_deasserted; 116 116 117 117 #if defined(CONFIG_NUMA) && defined(CONFIG_X86_32) 118 - 119 - /* which logical CPUs are on which nodes */ 120 - cpumask_t node_to_cpumask_map[MAX_NUMNODES] __read_mostly = 121 - { [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE }; 122 - EXPORT_SYMBOL(node_to_cpumask_map); 123 118 /* which node each logical CPU is on */ 124 119 int cpu_to_node_map[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0 }; 125 120 EXPORT_SYMBOL(cpu_to_node_map); ··· 123 128 static void map_cpu_to_node(int cpu, int node) 124 129 { 125 130 printk(KERN_INFO "Mapping cpu %d to node %d\n", cpu, node); 126 - cpumask_set_cpu(cpu, &node_to_cpumask_map[node]); 131 + cpumask_set_cpu(cpu, node_to_cpumask_map[node]); 127 132 cpu_to_node_map[cpu] = node; 128 133 } 129 134 ··· 134 139 135 140 printk(KERN_INFO "Unmapping cpu %d from all nodes\n", cpu); 136 141 for (node = 0; node < MAX_NUMNODES; node++) 137 - cpumask_clear_cpu(cpu, &node_to_cpumask_map[node]); 142 + cpumask_clear_cpu(cpu, node_to_cpumask_map[node]); 138 143 cpu_to_node_map[cpu] = 0; 139 144 } 140 145 #else /* !(CONFIG_NUMA && CONFIG_X86_32) */ ··· 296 301 __flush_tlb_all(); 297 302 #endif 298 303 299 - /* This must be done before setting cpu_online_map */ 304 + /* This must be done before setting cpu_online_mask */ 300 305 set_cpu_sibling_map(raw_smp_processor_id()); 301 306 wmb(); 302 307 ··· 329 334 cpu_idle(); 330 335 } 331 336 337 + #ifdef CONFIG_CPUMASK_OFFSTACK 338 + /* In this case, llc_shared_map is a pointer to a cpumask. */ 339 + static inline void copy_cpuinfo_x86(struct cpuinfo_x86 *dst, 340 + const struct cpuinfo_x86 *src) 341 + { 342 + struct cpumask *llc = dst->llc_shared_map; 343 + *dst = *src; 344 + dst->llc_shared_map = llc; 345 + } 346 + #else 347 + static inline void copy_cpuinfo_x86(struct cpuinfo_x86 *dst, 348 + const struct cpuinfo_x86 *src) 349 + { 350 + *dst = *src; 351 + } 352 + #endif /* CONFIG_CPUMASK_OFFSTACK */ 353 + 332 354 /* 333 355 * The bootstrap kernel entry code has set these up. Save them for 334 356 * a given CPU ··· 355 343 { 356 344 struct cpuinfo_x86 *c = &cpu_data(id); 357 345 358 - *c = boot_cpu_data; 346 + copy_cpuinfo_x86(c, &boot_cpu_data); 359 347 c->cpu_index = id; 360 348 if (id != 0) 361 349 identify_secondary_cpu(c); ··· 379 367 cpumask_set_cpu(cpu, cpu_sibling_mask(i)); 380 368 cpumask_set_cpu(i, cpu_core_mask(cpu)); 381 369 cpumask_set_cpu(cpu, cpu_core_mask(i)); 382 - cpumask_set_cpu(i, &c->llc_shared_map); 383 - cpumask_set_cpu(cpu, &o->llc_shared_map); 370 + cpumask_set_cpu(i, c->llc_shared_map); 371 + cpumask_set_cpu(cpu, o->llc_shared_map); 384 372 } 385 373 } 386 374 } else { 387 375 cpumask_set_cpu(cpu, cpu_sibling_mask(cpu)); 388 376 } 389 377 390 - cpumask_set_cpu(cpu, &c->llc_shared_map); 378 + cpumask_set_cpu(cpu, c->llc_shared_map); 391 379 392 380 if (current_cpu_data.x86_max_cores == 1) { 393 381 cpumask_copy(cpu_core_mask(cpu), cpu_sibling_mask(cpu)); ··· 398 386 for_each_cpu(i, cpu_sibling_setup_mask) { 399 387 if (per_cpu(cpu_llc_id, cpu) != BAD_APICID && 400 388 per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) { 401 - cpumask_set_cpu(i, &c->llc_shared_map); 402 - cpumask_set_cpu(cpu, &cpu_data(i).llc_shared_map); 389 + cpumask_set_cpu(i, c->llc_shared_map); 390 + cpumask_set_cpu(cpu, cpu_data(i).llc_shared_map); 403 391 } 404 392 if (c->phys_proc_id == cpu_data(i).phys_proc_id) { 405 393 cpumask_set_cpu(i, cpu_core_mask(cpu)); ··· 437 425 if (sched_mc_power_savings || sched_smt_power_savings) 438 426 return cpu_core_mask(cpu); 439 427 else 440 - return &c->llc_shared_map; 441 - } 442 - 443 - cpumask_t cpu_coregroup_map(int cpu) 444 - { 445 - return *cpu_coregroup_mask(cpu); 428 + return c->llc_shared_map; 446 429 } 447 430 448 431 static void impress_friends(void) ··· 904 897 */ 905 898 static __init void disable_smp(void) 906 899 { 907 - /* use the read/write pointers to the present and possible maps */ 908 - cpumask_copy(&cpu_present_map, cpumask_of(0)); 909 - cpumask_copy(&cpu_possible_map, cpumask_of(0)); 900 + init_cpu_present(cpumask_of(0)); 901 + init_cpu_possible(cpumask_of(0)); 910 902 smpboot_clear_io_apic_irqs(); 911 903 912 904 if (smp_found_config) ··· 1037 1031 */ 1038 1032 void __init native_smp_prepare_cpus(unsigned int max_cpus) 1039 1033 { 1034 + unsigned int i; 1035 + 1040 1036 preempt_disable(); 1041 1037 smp_cpu_index_default(); 1042 1038 current_cpu_data = boot_cpu_data; ··· 1052 1044 boot_cpu_logical_apicid = logical_smp_processor_id(); 1053 1045 #endif 1054 1046 current_thread_info()->cpu = 0; /* needed? */ 1047 + for_each_possible_cpu(i) { 1048 + alloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL); 1049 + alloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL); 1050 + alloc_cpumask_var(&cpu_data(i).llc_shared_map, GFP_KERNEL); 1051 + cpumask_clear(per_cpu(cpu_core_map, i)); 1052 + cpumask_clear(per_cpu(cpu_sibling_map, i)); 1053 + cpumask_clear(cpu_data(i).llc_shared_map); 1054 + } 1055 1055 set_cpu_sibling_map(0); 1056 1056 1057 1057 enable_IR_x2apic(); ··· 1148 1132 1149 1133 1150 1134 /* 1151 - * cpu_possible_map should be static, it cannot change as cpu's 1135 + * cpu_possible_mask should be static, it cannot change as cpu's 1152 1136 * are onlined, or offlined. The reason is per-cpu data-structures 1153 1137 * are allocated by some modules at init time, and dont expect to 1154 1138 * do this dynamically on cpu arrival/departure. 1155 - * cpu_present_map on the other hand can change dynamically. 1139 + * cpu_present_mask on the other hand can change dynamically. 1156 1140 * In case when cpu_hotplug is not compiled, then we resort to current 1157 1141 * behaviour, which is cpu_possible == cpu_present. 1158 1142 * - Ashok Raj
+7 -2
arch/x86/kernel/tlb_uv.c
··· 275 275 return NULL; 276 276 } 277 277 278 + static DEFINE_PER_CPU(cpumask_var_t, uv_flush_tlb_mask); 279 + 278 280 /** 279 281 * uv_flush_tlb_others - globally purge translation cache of a virtual 280 282 * address or all TLB's ··· 306 304 struct mm_struct *mm, 307 305 unsigned long va, unsigned int cpu) 308 306 { 309 - static DEFINE_PER_CPU(cpumask_t, flush_tlb_mask); 310 - struct cpumask *flush_mask = &__get_cpu_var(flush_tlb_mask); 307 + struct cpumask *flush_mask = __get_cpu_var(uv_flush_tlb_mask); 311 308 int i; 312 309 int bit; 313 310 int blade; ··· 755 754 756 755 if (!is_uv_system()) 757 756 return 0; 757 + 758 + for_each_possible_cpu(cur_cpu) 759 + alloc_cpumask_var_node(&per_cpu(uv_flush_tlb_mask, cur_cpu), 760 + GFP_KERNEL, cpu_to_node(cur_cpu)); 758 761 759 762 uv_bau_retry_limit = 1; 760 763 uv_nshift = uv_hub_info->n_val;
+1 -1
arch/x86/mm/Makefile
··· 14 14 mmiotrace-y := kmmio.o pf_in.o mmio-mod.o 15 15 obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o 16 16 17 - obj-$(CONFIG_NUMA) += numa_$(BITS).o 17 + obj-$(CONFIG_NUMA) += numa.o numa_$(BITS).o 18 18 obj-$(CONFIG_K8_NUMA) += k8topology_64.o 19 19 obj-$(CONFIG_ACPI_NUMA) += srat_$(BITS).o 20 20
+13 -6
arch/x86/mm/mmio-mod.c
··· 378 378 } 379 379 380 380 #ifdef CONFIG_HOTPLUG_CPU 381 - static cpumask_t downed_cpus; 381 + static cpumask_var_t downed_cpus; 382 382 383 383 static void enter_uniprocessor(void) 384 384 { 385 385 int cpu; 386 386 int err; 387 387 388 + if (downed_cpus == NULL && 389 + !alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) { 390 + pr_notice(NAME "Failed to allocate mask\n"); 391 + goto out; 392 + } 393 + 388 394 get_online_cpus(); 389 - downed_cpus = cpu_online_map; 390 - cpu_clear(first_cpu(cpu_online_map), downed_cpus); 395 + cpumask_copy(downed_cpus, cpu_online_mask); 396 + cpumask_clear_cpu(cpumask_first(cpu_online_mask), downed_cpus); 391 397 if (num_online_cpus() > 1) 392 398 pr_notice(NAME "Disabling non-boot CPUs...\n"); 393 399 put_online_cpus(); 394 400 395 - for_each_cpu_mask(cpu, downed_cpus) { 401 + for_each_cpu(cpu, downed_cpus) { 396 402 err = cpu_down(cpu); 397 403 if (!err) 398 404 pr_info(NAME "CPU%d is down.\n", cpu); 399 405 else 400 406 pr_err(NAME "Error taking CPU%d down: %d\n", cpu, err); 401 407 } 408 + out: 402 409 if (num_online_cpus() > 1) 403 410 pr_warning(NAME "multiple CPUs still online, " 404 411 "may miss events.\n"); ··· 418 411 int cpu; 419 412 int err; 420 413 421 - if (cpus_weight(downed_cpus) == 0) 414 + if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0) 422 415 return; 423 416 pr_notice(NAME "Re-enabling CPUs...\n"); 424 - for_each_cpu_mask(cpu, downed_cpus) { 417 + for_each_cpu(cpu, downed_cpus) { 425 418 err = cpu_up(cpu); 426 419 if (!err) 427 420 pr_info(NAME "enabled CPU%d.\n", cpu);
+67
arch/x86/mm/numa.c
··· 1 + /* Common code for 32 and 64-bit NUMA */ 2 + #include <linux/topology.h> 3 + #include <linux/module.h> 4 + #include <linux/bootmem.h> 5 + 6 + #ifdef CONFIG_DEBUG_PER_CPU_MAPS 7 + # define DBG(x...) printk(KERN_DEBUG x) 8 + #else 9 + # define DBG(x...) 10 + #endif 11 + 12 + /* 13 + * Which logical CPUs are on which nodes 14 + */ 15 + cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; 16 + EXPORT_SYMBOL(node_to_cpumask_map); 17 + 18 + /* 19 + * Allocate node_to_cpumask_map based on number of available nodes 20 + * Requires node_possible_map to be valid. 21 + * 22 + * Note: node_to_cpumask() is not valid until after this is done. 23 + * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.) 24 + */ 25 + void __init setup_node_to_cpumask_map(void) 26 + { 27 + unsigned int node, num = 0; 28 + 29 + /* setup nr_node_ids if not done yet */ 30 + if (nr_node_ids == MAX_NUMNODES) { 31 + for_each_node_mask(node, node_possible_map) 32 + num = node; 33 + nr_node_ids = num + 1; 34 + } 35 + 36 + /* allocate the map */ 37 + for (node = 0; node < nr_node_ids; node++) 38 + alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]); 39 + 40 + /* cpumask_of_node() will now work */ 41 + pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids); 42 + } 43 + 44 + #ifdef CONFIG_DEBUG_PER_CPU_MAPS 45 + /* 46 + * Returns a pointer to the bitmask of CPUs on Node 'node'. 47 + */ 48 + const struct cpumask *cpumask_of_node(int node) 49 + { 50 + if (node >= nr_node_ids) { 51 + printk(KERN_WARNING 52 + "cpumask_of_node(%d): node > nr_node_ids(%d)\n", 53 + node, nr_node_ids); 54 + dump_stack(); 55 + return cpu_none_mask; 56 + } 57 + if (node_to_cpumask_map[node] == NULL) { 58 + printk(KERN_WARNING 59 + "cpumask_of_node(%d): no node_to_cpumask_map!\n", 60 + node); 61 + dump_stack(); 62 + return cpu_online_mask; 63 + } 64 + return node_to_cpumask_map[node]; 65 + } 66 + EXPORT_SYMBOL(cpumask_of_node); 67 + #endif
+8 -103
arch/x86/mm/numa_64.c
··· 20 20 #include <asm/acpi.h> 21 21 #include <asm/k8.h> 22 22 23 - #ifdef CONFIG_DEBUG_PER_CPU_MAPS 24 - # define DBG(x...) printk(KERN_DEBUG x) 25 - #else 26 - # define DBG(x...) 27 - #endif 28 - 29 23 struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; 30 24 EXPORT_SYMBOL(node_data); 31 25 ··· 41 47 */ 42 48 DEFINE_EARLY_PER_CPU(int, x86_cpu_to_node_map, NUMA_NO_NODE); 43 49 EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_node_map); 44 - 45 - /* 46 - * Which logical CPUs are on which nodes 47 - */ 48 - cpumask_t *node_to_cpumask_map; 49 - EXPORT_SYMBOL(node_to_cpumask_map); 50 50 51 51 /* 52 52 * Given a shift value, try to populate memnodemap[] ··· 649 661 #endif 650 662 651 663 652 - /* 653 - * Allocate node_to_cpumask_map based on number of available nodes 654 - * Requires node_possible_map to be valid. 655 - * 656 - * Note: node_to_cpumask() is not valid until after this is done. 657 - * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.) 658 - */ 659 - void __init setup_node_to_cpumask_map(void) 660 - { 661 - unsigned int node, num = 0; 662 - cpumask_t *map; 663 - 664 - /* setup nr_node_ids if not done yet */ 665 - if (nr_node_ids == MAX_NUMNODES) { 666 - for_each_node_mask(node, node_possible_map) 667 - num = node; 668 - nr_node_ids = num + 1; 669 - } 670 - 671 - /* allocate the map */ 672 - map = alloc_bootmem_low(nr_node_ids * sizeof(cpumask_t)); 673 - DBG("node_to_cpumask_map at %p for %d nodes\n", map, nr_node_ids); 674 - 675 - pr_debug("Node to cpumask map at %p for %d nodes\n", 676 - map, nr_node_ids); 677 - 678 - /* node_to_cpumask() will now work */ 679 - node_to_cpumask_map = map; 680 - } 681 - 682 664 void __cpuinit numa_set_node(int cpu, int node) 683 665 { 684 666 int *cpu_to_node_map = early_per_cpu_ptr(x86_cpu_to_node_map); ··· 681 723 682 724 void __cpuinit numa_add_cpu(int cpu) 683 725 { 684 - cpu_set(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); 726 + cpumask_set_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); 685 727 } 686 728 687 729 void __cpuinit numa_remove_cpu(int cpu) 688 730 { 689 - cpu_clear(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); 731 + cpumask_clear_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); 690 732 } 691 733 692 734 #else /* CONFIG_DEBUG_PER_CPU_MAPS */ ··· 697 739 static void __cpuinit numa_set_cpumask(int cpu, int enable) 698 740 { 699 741 int node = early_cpu_to_node(cpu); 700 - cpumask_t *mask; 742 + struct cpumask *mask; 701 743 char buf[64]; 702 744 703 - if (node_to_cpumask_map == NULL) { 704 - printk(KERN_ERR "node_to_cpumask_map NULL\n"); 745 + mask = node_to_cpumask_map[node]; 746 + if (mask == NULL) { 747 + printk(KERN_ERR "node_to_cpumask_map[%i] NULL\n", node); 705 748 dump_stack(); 706 749 return; 707 750 } 708 751 709 - mask = &node_to_cpumask_map[node]; 710 752 if (enable) 711 - cpu_set(cpu, *mask); 753 + cpumask_set_cpu(cpu, mask); 712 754 else 713 - cpu_clear(cpu, *mask); 755 + cpumask_clear_cpu(cpu, mask); 714 756 715 757 cpulist_scnprintf(buf, sizeof(buf), mask); 716 758 printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n", ··· 756 798 } 757 799 return per_cpu(x86_cpu_to_node_map, cpu); 758 800 } 759 - 760 - 761 - /* empty cpumask */ 762 - static const cpumask_t cpu_mask_none; 763 - 764 - /* 765 - * Returns a pointer to the bitmask of CPUs on Node 'node'. 766 - */ 767 - const cpumask_t *cpumask_of_node(int node) 768 - { 769 - if (node_to_cpumask_map == NULL) { 770 - printk(KERN_WARNING 771 - "cpumask_of_node(%d): no node_to_cpumask_map!\n", 772 - node); 773 - dump_stack(); 774 - return (const cpumask_t *)&cpu_online_map; 775 - } 776 - if (node >= nr_node_ids) { 777 - printk(KERN_WARNING 778 - "cpumask_of_node(%d): node > nr_node_ids(%d)\n", 779 - node, nr_node_ids); 780 - dump_stack(); 781 - return &cpu_mask_none; 782 - } 783 - return &node_to_cpumask_map[node]; 784 - } 785 - EXPORT_SYMBOL(cpumask_of_node); 786 - 787 - /* 788 - * Returns a bitmask of CPUs on Node 'node'. 789 - * 790 - * Side note: this function creates the returned cpumask on the stack 791 - * so with a high NR_CPUS count, excessive stack space is used. The 792 - * node_to_cpumask_ptr function should be used whenever possible. 793 - */ 794 - cpumask_t node_to_cpumask(int node) 795 - { 796 - if (node_to_cpumask_map == NULL) { 797 - printk(KERN_WARNING 798 - "node_to_cpumask(%d): no node_to_cpumask_map!\n", node); 799 - dump_stack(); 800 - return cpu_online_map; 801 - } 802 - if (node >= nr_node_ids) { 803 - printk(KERN_WARNING 804 - "node_to_cpumask(%d): node > nr_node_ids(%d)\n", 805 - node, nr_node_ids); 806 - dump_stack(); 807 - return cpu_mask_none; 808 - } 809 - return node_to_cpumask_map[node]; 810 - } 811 - EXPORT_SYMBOL(node_to_cpumask); 812 801 813 802 /* 814 803 * --------- end of debug versions of the numa functions ---------
+1 -1
arch/x86/oprofile/op_model_p4.c
··· 380 380 { 381 381 #ifdef CONFIG_SMP 382 382 int cpu = smp_processor_id(); 383 - return (cpu != first_cpu(per_cpu(cpu_sibling_map, cpu))); 383 + return cpu != cpumask_first(__get_cpu_var(cpu_sibling_map)); 384 384 #endif 385 385 return 0; 386 386 }
+3 -3
arch/x86/xen/smp.c
··· 158 158 rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL); 159 159 if (rc >= 0) { 160 160 num_processors++; 161 - cpu_set(i, cpu_possible_map); 161 + set_cpu_possible(i, true); 162 162 } 163 163 } 164 164 } ··· 197 197 while ((num_possible_cpus() > 1) && (num_possible_cpus() > max_cpus)) { 198 198 for (cpu = nr_cpu_ids - 1; !cpu_possible(cpu); cpu--) 199 199 continue; 200 - cpu_clear(cpu, cpu_possible_map); 200 + set_cpu_possible(cpu, false); 201 201 } 202 202 203 203 for_each_possible_cpu (cpu) { ··· 210 210 if (IS_ERR(idle)) 211 211 panic("failed fork for CPU %d", cpu); 212 212 213 - cpu_set(cpu, cpu_present_map); 213 + set_cpu_present(cpu, true); 214 214 } 215 215 } 216 216
+1 -1
block/blk.h
··· 102 102 const struct cpumask *mask = cpu_coregroup_mask(cpu); 103 103 return cpumask_first(mask); 104 104 #elif defined(CONFIG_SCHED_SMT) 105 - return first_cpu(per_cpu(cpu_sibling_map, cpu)); 105 + return cpumask_first(topology_thread_cpumask(cpu)); 106 106 #else 107 107 return cpu; 108 108 #endif
+1 -1
drivers/base/node.c
··· 24 24 static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf) 25 25 { 26 26 struct node *node_dev = to_node(dev); 27 - node_to_cpumask_ptr(mask, node_dev->sysdev.id); 27 + const struct cpumask *mask = cpumask_of_node(node_dev->sysdev.id); 28 28 int len; 29 29 30 30 /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */
+1 -1
drivers/char/sysrq.c
··· 35 35 #include <linux/vt_kern.h> 36 36 #include <linux/workqueue.h> 37 37 #include <linux/kexec.h> 38 - #include <linux/irq.h> 38 + #include <linux/interrupt.h> 39 39 #include <linux/hrtimer.h> 40 40 #include <linux/oom.h> 41 41
+6 -14
drivers/oprofile/buffer_sync.c
··· 154 154 { 155 155 int err; 156 156 157 + if (!alloc_cpumask_var(&marked_cpus, GFP_KERNEL)) 158 + return -ENOMEM; 159 + cpumask_clear(marked_cpus); 160 + 157 161 start_cpu_work(); 158 162 159 163 err = task_handoff_register(&task_free_nb); ··· 183 179 task_handoff_unregister(&task_free_nb); 184 180 out1: 185 181 end_sync(); 182 + free_cpumask_var(marked_cpus); 186 183 goto out; 187 184 } 188 185 ··· 195 190 profile_event_unregister(PROFILE_TASK_EXIT, &task_exit_nb); 196 191 task_handoff_unregister(&task_free_nb); 197 192 end_sync(); 193 + free_cpumask_var(marked_cpus); 198 194 } 199 195 200 196 ··· 569 563 mark_done(cpu); 570 564 571 565 mutex_unlock(&buffer_mutex); 572 - } 573 - 574 - int __init buffer_sync_init(void) 575 - { 576 - if (!alloc_cpumask_var(&marked_cpus, GFP_KERNEL)) 577 - return -ENOMEM; 578 - 579 - cpumask_clear(marked_cpus); 580 - return 0; 581 - } 582 - 583 - void buffer_sync_cleanup(void) 584 - { 585 - free_cpumask_var(marked_cpus); 586 566 } 587 567 588 568 /* The function can be used to add a buffer worth of data directly to
-4
drivers/oprofile/buffer_sync.h
··· 19 19 /* sync the given CPU's buffer */ 20 20 void sync_buffer(int cpu); 21 21 22 - /* initialize/destroy the buffer system. */ 23 - int buffer_sync_init(void); 24 - void buffer_sync_cleanup(void); 25 - 26 22 #endif /* OPROFILE_BUFFER_SYNC_H */
+1 -8
drivers/oprofile/oprof.c
··· 183 183 { 184 184 int err; 185 185 186 - err = buffer_sync_init(); 187 - if (err) 188 - return err; 189 - 190 186 err = oprofile_arch_init(&oprofile_ops); 191 187 192 188 if (err < 0 || timer) { ··· 191 195 } 192 196 193 197 err = oprofilefs_register(); 194 - if (err) { 198 + if (err) 195 199 oprofile_arch_exit(); 196 - buffer_sync_cleanup(); 197 - } 198 200 199 201 return err; 200 202 } ··· 202 208 { 203 209 oprofilefs_unregister(); 204 210 oprofile_arch_exit(); 205 - buffer_sync_cleanup(); 206 211 } 207 212 208 213
+1 -2
drivers/pci/pci-driver.c
··· 212 212 node = dev_to_node(&dev->dev); 213 213 if (node >= 0) { 214 214 int cpu; 215 - node_to_cpumask_ptr(nodecpumask, node); 216 215 217 216 get_online_cpus(); 218 - cpu = cpumask_any_and(nodecpumask, cpu_online_mask); 217 + cpu = cpumask_any_and(cpumask_of_node(node), cpu_online_mask); 219 218 if (cpu < nr_cpu_ids) 220 219 error = work_on_cpu(cpu, local_pci_probe, &ddi); 221 220 else
+2 -2
drivers/xen/cpu_hotplug.c
··· 10 10 if (!cpu_present(cpu)) 11 11 arch_register_cpu(cpu); 12 12 13 - cpu_set(cpu, cpu_present_map); 13 + set_cpu_present(cpu, true); 14 14 } 15 15 16 16 static void disable_hotplug_cpu(int cpu) ··· 18 18 if (cpu_present(cpu)) 19 19 arch_unregister_cpu(cpu); 20 20 21 - cpu_clear(cpu, cpu_present_map); 21 + set_cpu_present(cpu, false); 22 22 } 23 23 24 24 static void vcpu_hotplug(unsigned int cpu)
+1
include/linux/gfp.h
··· 4 4 #include <linux/mmzone.h> 5 5 #include <linux/stddef.h> 6 6 #include <linux/linkage.h> 7 + #include <linux/topology.h> 7 8 8 9 struct vm_area_struct; 9 10
-6
include/linux/mmzone.h
··· 764 764 extern char numa_zonelist_order[]; 765 765 #define NUMA_ZONELIST_ORDER_LEN 16 /* string buffer size */ 766 766 767 - #include <linux/topology.h> 768 - /* Returns the number of the current Node. */ 769 - #ifndef numa_node_id 770 - #define numa_node_id() (cpu_to_node(raw_smp_processor_id())) 771 - #endif 772 - 773 767 #ifndef CONFIG_NEED_MULTIPLE_NODES 774 768 775 769 extern struct pglist_data contig_page_data;
+6 -5
include/linux/topology.h
··· 38 38 #endif 39 39 40 40 #ifndef nr_cpus_node 41 - #define nr_cpus_node(node) \ 42 - ({ \ 43 - node_to_cpumask_ptr(__tmp__, node); \ 44 - cpus_weight(*__tmp__); \ 45 - }) 41 + #define nr_cpus_node(node) cpumask_weight(cpumask_of_node(node)) 46 42 #endif 47 43 48 44 #define for_each_node_with_cpus(node) \ ··· 194 198 #endif 195 199 #ifndef topology_core_cpumask 196 200 #define topology_core_cpumask(cpu) cpumask_of(cpu) 201 + #endif 202 + 203 + /* Returns the number of the current Node. */ 204 + #ifndef numa_node_id 205 + #define numa_node_id() (cpu_to_node(raw_smp_processor_id())) 197 206 #endif 198 207 199 208 #endif /* _LINUX_TOPOLOGY_H */
+22 -21
kernel/sched.c
··· 3818 3818 */ 3819 3819 #define MAX_PINNED_INTERVAL 512 3820 3820 3821 + /* Working cpumask for load_balance and load_balance_newidle. */ 3822 + static DEFINE_PER_CPU(cpumask_var_t, load_balance_tmpmask); 3823 + 3821 3824 /* 3822 3825 * Check this_cpu to ensure it is balanced within domain. Attempt to move 3823 3826 * tasks if there is an imbalance. 3824 3827 */ 3825 3828 static int load_balance(int this_cpu, struct rq *this_rq, 3826 3829 struct sched_domain *sd, enum cpu_idle_type idle, 3827 - int *balance, struct cpumask *cpus) 3830 + int *balance) 3828 3831 { 3829 3832 int ld_moved, all_pinned = 0, active_balance = 0, sd_idle = 0; 3830 3833 struct sched_group *group; 3831 3834 unsigned long imbalance; 3832 3835 struct rq *busiest; 3833 3836 unsigned long flags; 3837 + struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask); 3834 3838 3835 3839 cpumask_setall(cpus); 3836 3840 ··· 3989 3985 * this_rq is locked. 3990 3986 */ 3991 3987 static int 3992 - load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd, 3993 - struct cpumask *cpus) 3988 + load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd) 3994 3989 { 3995 3990 struct sched_group *group; 3996 3991 struct rq *busiest = NULL; ··· 3997 3994 int ld_moved = 0; 3998 3995 int sd_idle = 0; 3999 3996 int all_pinned = 0; 3997 + struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask); 4000 3998 4001 3999 cpumask_setall(cpus); 4002 4000 ··· 4138 4134 struct sched_domain *sd; 4139 4135 int pulled_task = 0; 4140 4136 unsigned long next_balance = jiffies + HZ; 4141 - cpumask_var_t tmpmask; 4142 - 4143 - if (!alloc_cpumask_var(&tmpmask, GFP_ATOMIC)) 4144 - return; 4145 4137 4146 4138 for_each_domain(this_cpu, sd) { 4147 4139 unsigned long interval; ··· 4148 4148 if (sd->flags & SD_BALANCE_NEWIDLE) 4149 4149 /* If we've pulled tasks over stop searching: */ 4150 4150 pulled_task = load_balance_newidle(this_cpu, this_rq, 4151 - sd, tmpmask); 4151 + sd); 4152 4152 4153 4153 interval = msecs_to_jiffies(sd->balance_interval); 4154 4154 if (time_after(next_balance, sd->last_balance + interval)) ··· 4163 4163 */ 4164 4164 this_rq->next_balance = next_balance; 4165 4165 } 4166 - free_cpumask_var(tmpmask); 4167 4166 } 4168 4167 4169 4168 /* ··· 4312 4313 unsigned long next_balance = jiffies + 60*HZ; 4313 4314 int update_next_balance = 0; 4314 4315 int need_serialize; 4315 - cpumask_var_t tmp; 4316 - 4317 - /* Fails alloc? Rebalancing probably not a priority right now. */ 4318 - if (!alloc_cpumask_var(&tmp, GFP_ATOMIC)) 4319 - return; 4320 4316 4321 4317 for_each_domain(cpu, sd) { 4322 4318 if (!(sd->flags & SD_LOAD_BALANCE)) ··· 4336 4342 } 4337 4343 4338 4344 if (time_after_eq(jiffies, sd->last_balance + interval)) { 4339 - if (load_balance(cpu, rq, sd, idle, &balance, tmp)) { 4345 + if (load_balance(cpu, rq, sd, idle, &balance)) { 4340 4346 /* 4341 4347 * We've pulled tasks over so either we're no 4342 4348 * longer idle, or one of our SMT siblings is ··· 4370 4376 */ 4371 4377 if (likely(update_next_balance)) 4372 4378 rq->next_balance = next_balance; 4373 - 4374 - free_cpumask_var(tmp); 4375 4379 } 4376 4380 4377 4381 /* ··· 7705 7713 { 7706 7714 int group; 7707 7715 7708 - cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map); 7716 + cpumask_and(mask, topology_thread_cpumask(cpu), cpu_map); 7709 7717 group = cpumask_first(mask); 7710 7718 if (sg) 7711 7719 *sg = &per_cpu(sched_group_core, group).sg; ··· 7734 7742 cpumask_and(mask, cpu_coregroup_mask(cpu), cpu_map); 7735 7743 group = cpumask_first(mask); 7736 7744 #elif defined(CONFIG_SCHED_SMT) 7737 - cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map); 7745 + cpumask_and(mask, topology_thread_cpumask(cpu), cpu_map); 7738 7746 group = cpumask_first(mask); 7739 7747 #else 7740 7748 group = cpu; ··· 8077 8085 SD_INIT(sd, SIBLING); 8078 8086 set_domain_attribute(sd, attr); 8079 8087 cpumask_and(sched_domain_span(sd), 8080 - &per_cpu(cpu_sibling_map, i), cpu_map); 8088 + topology_thread_cpumask(i), cpu_map); 8081 8089 sd->parent = p; 8082 8090 p->child = sd; 8083 8091 cpu_to_cpu_group(i, cpu_map, &sd->groups, tmpmask); ··· 8088 8096 /* Set up CPU (sibling) groups */ 8089 8097 for_each_cpu(i, cpu_map) { 8090 8098 cpumask_and(this_sibling_map, 8091 - &per_cpu(cpu_sibling_map, i), cpu_map); 8099 + topology_thread_cpumask(i), cpu_map); 8092 8100 if (i != cpumask_first(this_sibling_map)) 8093 8101 continue; 8094 8102 ··· 8764 8772 #ifdef CONFIG_USER_SCHED 8765 8773 alloc_size *= 2; 8766 8774 #endif 8775 + #ifdef CONFIG_CPUMASK_OFFSTACK 8776 + alloc_size += num_possible_cpus() * cpumask_size(); 8777 + #endif 8767 8778 /* 8768 8779 * As sched_init() is called before page_alloc is setup, 8769 8780 * we use alloc_bootmem(). ··· 8804 8809 ptr += nr_cpu_ids * sizeof(void **); 8805 8810 #endif /* CONFIG_USER_SCHED */ 8806 8811 #endif /* CONFIG_RT_GROUP_SCHED */ 8812 + #ifdef CONFIG_CPUMASK_OFFSTACK 8813 + for_each_possible_cpu(i) { 8814 + per_cpu(load_balance_tmpmask, i) = (void *)ptr; 8815 + ptr += cpumask_size(); 8816 + } 8817 + #endif /* CONFIG_CPUMASK_OFFSTACK */ 8807 8818 } 8808 8819 8809 8820 #ifdef CONFIG_SMP
+3 -3
mm/page_alloc.c
··· 2139 2139 int n, val; 2140 2140 int min_val = INT_MAX; 2141 2141 int best_node = -1; 2142 - node_to_cpumask_ptr(tmp, 0); 2142 + const struct cpumask *tmp = cpumask_of_node(0); 2143 2143 2144 2144 /* Use the local node if we haven't already */ 2145 2145 if (!node_isset(node, *used_node_mask)) { ··· 2160 2160 val += (n < node); 2161 2161 2162 2162 /* Give preference to headless and unused nodes */ 2163 - node_to_cpumask_ptr_next(tmp, n); 2164 - if (!cpus_empty(*tmp)) 2163 + tmp = cpumask_of_node(n); 2164 + if (!cpumask_empty(tmp)) 2165 2165 val += PENALTY_FOR_NODE_WITH_CPUS; 2166 2166 2167 2167 /* Slight preference for less loaded node */
+1 -1
mm/quicklist.c
··· 29 29 int node = numa_node_id(); 30 30 struct zone *zones = NODE_DATA(node)->node_zones; 31 31 int num_cpus_on_node; 32 - node_to_cpumask_ptr(cpumask_on_node, node); 32 + const struct cpumask *cpumask_on_node = cpumask_of_node(node); 33 33 34 34 node_free_pages = 35 35 #ifdef CONFIG_ZONE_DMA
+1 -1
mm/slab.c
··· 1160 1160 struct kmem_cache *cachep; 1161 1161 struct kmem_list3 *l3 = NULL; 1162 1162 int node = cpu_to_node(cpu); 1163 - node_to_cpumask_ptr(mask, node); 1163 + const struct cpumask *mask = cpumask_of_node(node); 1164 1164 1165 1165 list_for_each_entry(cachep, &cache_chain, next) { 1166 1166 struct array_cache *nc;
+4 -2
mm/vmscan.c
··· 1963 1963 struct reclaim_state reclaim_state = { 1964 1964 .reclaimed_slab = 0, 1965 1965 }; 1966 - node_to_cpumask_ptr(cpumask, pgdat->node_id); 1966 + const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id); 1967 1967 1968 1968 lockdep_set_current_reclaim_state(GFP_KERNEL); 1969 1969 ··· 2200 2200 if (action == CPU_ONLINE || action == CPU_ONLINE_FROZEN) { 2201 2201 for_each_node_state(nid, N_HIGH_MEMORY) { 2202 2202 pg_data_t *pgdat = NODE_DATA(nid); 2203 - node_to_cpumask_ptr(mask, pgdat->node_id); 2203 + const struct cpumask *mask; 2204 + 2205 + mask = cpumask_of_node(pgdat->node_id); 2204 2206 2205 2207 if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids) 2206 2208 /* One of our CPUs online: restore mask */
+1 -2
net/sunrpc/svc.c
··· 317 317 } 318 318 case SVC_POOL_PERNODE: 319 319 { 320 - node_to_cpumask_ptr(nodecpumask, node); 321 - set_cpus_allowed_ptr(task, nodecpumask); 320 + set_cpus_allowed_ptr(task, cpumask_of_node(node)); 322 321 break; 323 322 } 324 323 }