···44444545#ifdef CONFIG_X86_3246464747-/* Mappings between node number and cpus on that node. */4848-extern cpumask_t node_to_cpumask_map[];4949-5047/* Mappings between logical cpu number and node number */5148extern int cpu_to_node_map[];5249···5457}5558#define early_cpu_to_node(cpu) cpu_to_node(cpu)56595757-/* Returns a bitmask of CPUs on Node 'node'.5858- *5959- * Side note: this function creates the returned cpumask on the stack6060- * so with a high NR_CPUS count, excessive stack space is used. The6161- * cpumask_of_node function should be used whenever possible.6262- */6363-static inline cpumask_t node_to_cpumask(int node)6464-{6565- return node_to_cpumask_map[node];6666-}6767-6868-/* Returns a bitmask of CPUs on Node 'node'. */6969-static inline const struct cpumask *cpumask_of_node(int node)7070-{7171- return &node_to_cpumask_map[node];7272-}7373-7474-static inline void setup_node_to_cpumask_map(void) { }7575-7660#else /* CONFIG_X86_64 */7777-7878-/* Mappings between node number and cpus on that node. */7979-extern cpumask_t *node_to_cpumask_map;80618162/* Mappings between logical cpu number and node number */8263DECLARE_EARLY_PER_CPU(int, x86_cpu_to_node_map);···6691#ifdef CONFIG_DEBUG_PER_CPU_MAPS6792extern int cpu_to_node(int cpu);6893extern int early_cpu_to_node(int cpu);6969-extern const cpumask_t *cpumask_of_node(int node);7070-extern cpumask_t node_to_cpumask(int node);71947295#else /* !CONFIG_DEBUG_PER_CPU_MAPS */7396···81108 return early_per_cpu(x86_cpu_to_node_map, cpu);82109}831108484-/* Returns a pointer to the cpumask of CPUs on Node 'node'. */8585-static inline const cpumask_t *cpumask_of_node(int node)8686-{8787- return &node_to_cpumask_map[node];8888-}111111+#endif /* !CONFIG_DEBUG_PER_CPU_MAPS */891129090-/* Returns a bitmask of CPUs on Node 'node'. */9191-static inline cpumask_t node_to_cpumask(int node)113113+#endif /* CONFIG_X86_64 */114114+115115+/* Mappings between node number and cpus on that node. */116116+extern cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];117117+118118+#ifdef CONFIG_DEBUG_PER_CPU_MAPS119119+extern const struct cpumask *cpumask_of_node(int node);120120+#else121121+/* Returns a pointer to the cpumask of CPUs on Node 'node'. */122122+static inline const struct cpumask *cpumask_of_node(int node)92123{93124 return node_to_cpumask_map[node];94125}9595-9696-#endif /* !CONFIG_DEBUG_PER_CPU_MAPS */126126+#endif9712798128extern void setup_node_to_cpumask_map(void);9999-100100-/*101101- * Replace default node_to_cpumask_ptr with optimized version102102- * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)"103103- */104104-#define node_to_cpumask_ptr(v, node) \105105- const cpumask_t *v = cpumask_of_node(node)106106-107107-#define node_to_cpumask_ptr_next(v, node) \108108- v = cpumask_of_node(node)109109-110110-#endif /* CONFIG_X86_64 */111129112130/*113131 * Returns the number of the node containing Node 'node'. This···107143#define parent_node(node) (node)108144109145#define pcibus_to_node(bus) __pcibus_to_node(bus)110110-#define pcibus_to_cpumask(bus) __pcibus_to_cpumask(bus)111146112147#ifdef CONFIG_X86_32113148extern unsigned long node_start_pfn[];···172209 return 0;173210}174211175175-static inline const cpumask_t *cpumask_of_node(int node)212212+static inline const struct cpumask *cpumask_of_node(int node)176213{177177- return &cpu_online_map;178178-}179179-static inline cpumask_t node_to_cpumask(int node)180180-{181181- return cpu_online_map;214214+ return cpu_online_mask;182215}183216184217static inline void setup_node_to_cpumask_map(void) { }185218186186-/*187187- * Replace default node_to_cpumask_ptr with optimized version188188- * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)"189189- */190190-#define node_to_cpumask_ptr(v, node) \191191- const cpumask_t *v = cpumask_of_node(node)192192-193193-#define node_to_cpumask_ptr_next(v, node) \194194- v = cpumask_of_node(node)195219#endif196220197221#include <asm-generic/topology.h>198222199199-extern cpumask_t cpu_coregroup_map(int cpu);200223extern const struct cpumask *cpu_coregroup_mask(int cpu);201224202225#ifdef ENABLE_TOPO_DEFINES203226#define topology_physical_package_id(cpu) (cpu_data(cpu).phys_proc_id)204227#define topology_core_id(cpu) (cpu_data(cpu).cpu_core_id)205205-#define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu))206206-#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))207207-#define topology_core_cpumask(cpu) (&per_cpu(cpu_core_map, cpu))208208-#define topology_thread_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))228228+#define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))229229+#define topology_thread_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))209230210231/* indicates that pointers to the topology cpumask_t maps are valid */211232#define arch_provides_topology_pointers yes···203256void set_pci_bus_resources_arch_default(struct pci_bus *b);204257205258#ifdef CONFIG_SMP206206-#define mc_capable() (cpus_weight(per_cpu(cpu_core_map, 0)) != nr_cpu_ids)259259+#define mc_capable() (cpumask_weight(cpu_core_mask(0)) != nr_cpu_ids)207260#define smt_capable() (smp_num_siblings > 1)208261#endif209262
+8-8
arch/x86/kernel/apic/bigsmp_32.c
···2626 return 1;2727}28282929-static const cpumask_t *bigsmp_target_cpus(void)2929+static const struct cpumask *bigsmp_target_cpus(void)3030{3131#ifdef CONFIG_SMP3232- return &cpu_online_map;3232+ return cpu_online_mask;3333#else3434- return &cpumask_of_cpu(0);3434+ return cpumask_of(0);3535#endif3636}3737···118118}119119120120/* As we are using single CPU as destination, pick only one CPU here */121121-static unsigned int bigsmp_cpu_mask_to_apicid(const cpumask_t *cpumask)121121+static unsigned int bigsmp_cpu_mask_to_apicid(const struct cpumask *cpumask)122122{123123- return bigsmp_cpu_to_logical_apicid(first_cpu(*cpumask));123123+ return bigsmp_cpu_to_logical_apicid(cpumask_first(cpumask));124124}125125126126static unsigned int bigsmp_cpu_mask_to_apicid_and(const struct cpumask *cpumask,···188188 { } /* NULL entry stops DMI scanning */189189};190190191191-static void bigsmp_vector_allocation_domain(int cpu, cpumask_t *retmask)191191+static void bigsmp_vector_allocation_domain(int cpu, struct cpumask *retmask)192192{193193- cpus_clear(*retmask);194194- cpu_set(cpu, *retmask);193193+ cpumask_clear(retmask);194194+ cpumask_set_cpu(cpu, retmask);195195}196196197197static int probe_bigsmp(void)
+9-8
arch/x86/kernel/apic/es7000_32.c
···410410 WARN(1, "Command failed, status = %x\n", mip_status);411411}412412413413-static void es7000_vector_allocation_domain(int cpu, cpumask_t *retmask)413413+static void es7000_vector_allocation_domain(int cpu, struct cpumask *retmask)414414{415415 /* Careful. Some cpus do not strictly honor the set of cpus416416 * specified in the interrupt destination when using lowest···420420 * deliver interrupts to the wrong hyperthread when only one421421 * hyperthread was specified in the interrupt desitination.422422 */423423- *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };423423+ cpumask_clear(retmask);424424+ cpumask_bits(retmask)[0] = APIC_ALL_CPUS;424425}425426426427···456455 return 1;457456}458457459459-static const cpumask_t *target_cpus_cluster(void)458458+static const struct cpumask *target_cpus_cluster(void)460459{461461- return &CPU_MASK_ALL;460460+ return cpu_all_mask;462461}463462464464-static const cpumask_t *es7000_target_cpus(void)463463+static const struct cpumask *es7000_target_cpus(void)465464{466466- return &cpumask_of_cpu(smp_processor_id());465465+ return cpumask_of(smp_processor_id());467466}468467469468static unsigned long···518517 "Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n",519518 (apic_version[apic] == 0x14) ?520519 "Physical Cluster" : "Logical Cluster",521521- nr_ioapics, cpus_addr(*es7000_target_cpus())[0]);520520+ nr_ioapics, cpumask_bits(es7000_target_cpus())[0]);522521}523522524523static int es7000_apicid_to_node(int logical_apicid)···573572 return 1;574573}575574576576-static unsigned int es7000_cpu_mask_to_apicid(const cpumask_t *cpumask)575575+static unsigned int es7000_cpu_mask_to_apicid(const struct cpumask *cpumask)577576{578577 unsigned int round = 0;579578 int cpu, uninitialized_var(apicid);
+6-5
arch/x86/kernel/apic/nmi.c
···3939int unknown_nmi_panic;4040int nmi_watchdog_enabled;41414242-static cpumask_t backtrace_mask = CPU_MASK_NONE;4242+static cpumask_var_t backtrace_mask;43434444/* nmi_active:4545 * >0: the lapic NMI watchdog is active, but can be disabled···138138 if (!prev_nmi_count)139139 goto error;140140141141+ alloc_cpumask_var(&backtrace_mask, GFP_KERNEL);141142 printk(KERN_INFO "Testing NMI watchdog ... ");142143143144#ifdef CONFIG_SMP···414413 touched = 1;415414 }416415417417- if (cpu_isset(cpu, backtrace_mask)) {416416+ if (cpumask_test_cpu(cpu, backtrace_mask)) {418417 static DEFINE_SPINLOCK(lock); /* Serialise the printks */419418420419 spin_lock(&lock);421420 printk(KERN_WARNING "NMI backtrace for cpu %d\n", cpu);422421 dump_stack();423422 spin_unlock(&lock);424424- cpu_clear(cpu, backtrace_mask);423423+ cpumask_clear_cpu(cpu, backtrace_mask);425424 }426425427426 /* Could check oops_in_progress here too, but it's safer not to */···555554{556555 int i;557556558558- backtrace_mask = cpu_online_map;557557+ cpumask_copy(backtrace_mask, cpu_online_mask);559558 /* Wait for up to 10 seconds for all CPUs to do the backtrace */560559 for (i = 0; i < 10 * 1000; i++) {561561- if (cpus_empty(backtrace_mask))560560+ if (cpumask_empty(backtrace_mask))562561 break;563562 mdelay(1);564563 }
+6-5
arch/x86/kernel/apic/numaq_32.c
···334334 clear_local_APIC();335335}336336337337-static inline const cpumask_t *numaq_target_cpus(void)337337+static inline const struct cpumask *numaq_target_cpus(void)338338{339339- return &CPU_MASK_ALL;339339+ return cpu_all_mask;340340}341341342342static inline unsigned long···427427 * We use physical apicids here, not logical, so just return the default428428 * physical broadcast to stop people from breaking us429429 */430430-static inline unsigned int numaq_cpu_mask_to_apicid(const cpumask_t *cpumask)430430+static unsigned int numaq_cpu_mask_to_apicid(const struct cpumask *cpumask)431431{432432 return 0x0F;433433}···462462 return found_numaq;463463}464464465465-static void numaq_vector_allocation_domain(int cpu, cpumask_t *retmask)465465+static void numaq_vector_allocation_domain(int cpu, struct cpumask *retmask)466466{467467 /* Careful. Some cpus do not strictly honor the set of cpus468468 * specified in the interrupt destination when using lowest···472472 * deliver interrupts to the wrong hyperthread when only one473473 * hyperthread was specified in the interrupt desitination.474474 */475475- *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };475475+ cpumask_clear(retmask);476476+ cpumask_bits(retmask)[0] = APIC_ALL_CPUS;476477}477478478479static void numaq_setup_portio_remap(void)
+2-1
arch/x86/kernel/apic/probe_32.c
···8383 * deliver interrupts to the wrong hyperthread when only one8484 * hyperthread was specified in the interrupt desitination.8585 */8686- *retmask = (cpumask_t) { { [0] = APIC_ALL_CPUS } };8686+ cpumask_clear(retmask);8787+ cpumask_bits(retmask)[0] = APIC_ALL_CPUS;8788}88898990/* should be called last. */
+9-12
arch/x86/kernel/apic/summit_32.c
···5353 return (x >> 24) & 0xFF;5454}55555656-static inline void summit_send_IPI_mask(const cpumask_t *mask, int vector)5656+static inline void summit_send_IPI_mask(const struct cpumask *mask, int vector)5757{5858 default_send_IPI_mask_sequence_logical(mask, vector);5959}60606161static void summit_send_IPI_allbutself(int vector)6262{6363- cpumask_t mask = cpu_online_map;6464- cpu_clear(smp_processor_id(), mask);6565-6666- if (!cpus_empty(mask))6767- summit_send_IPI_mask(&mask, vector);6363+ default_send_IPI_mask_allbutself_logical(cpu_online_mask, vector);6864}69657066static void summit_send_IPI_all(int vector)7167{7272- summit_send_IPI_mask(&cpu_online_map, vector);6868+ summit_send_IPI_mask(cpu_online_mask, vector);7369}74707571#include <asm/tsc.h>···182186183187#define SUMMIT_APIC_DFR_VALUE (APIC_DFR_CLUSTER)184188185185-static const cpumask_t *summit_target_cpus(void)189189+static const struct cpumask *summit_target_cpus(void)186190{187191 /* CPU_MASK_ALL (0xff) has undefined behaviour with188192 * dest_LowestPrio mode logical clustered apic interrupt routing189193 * Just start on cpu 0. IRQ balancing will spread load190194 */191191- return &cpumask_of_cpu(0);195195+ return cpumask_of(0);192196}193197194198static unsigned long summit_check_apicid_used(physid_mask_t bitmap, int apicid)···285289 return 1;286290}287291288288-static unsigned int summit_cpu_mask_to_apicid(const cpumask_t *cpumask)292292+static unsigned int summit_cpu_mask_to_apicid(const struct cpumask *cpumask)289293{290294 unsigned int round = 0;291295 int cpu, apicid = 0;···342346 return 0;343347}344348345345-static void summit_vector_allocation_domain(int cpu, cpumask_t *retmask)349349+static void summit_vector_allocation_domain(int cpu, struct cpumask *retmask)346350{347351 /* Careful. Some cpus do not strictly honor the set of cpus348352 * specified in the interrupt destination when using lowest···352356 * deliver interrupts to the wrong hyperthread when only one353357 * hyperthread was specified in the interrupt desitination.354358 */355355- *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };359359+ cpumask_clear(retmask);360360+ cpumask_bits(retmask)[0] = APIC_ALL_CPUS;356361}357362358363#ifdef CONFIG_X86_SUMMIT_NUMA
+158-116
arch/x86/kernel/apm_32.c
···466466 * @err: APM BIOS return code467467 *468468 * Write a meaningful log entry to the kernel log in the event of469469- * an APM error.469469+ * an APM error. Note that this also handles (negative) kernel errors.470470 */471471472472static void apm_error(char *str, int err)···478478 break;479479 if (i < ERROR_COUNT)480480 printk(KERN_NOTICE "apm: %s: %s\n", str, error_table[i].msg);481481+ else if (err < 0)482482+ printk(KERN_NOTICE "apm: %s: linux error code %i\n", str, err);481483 else482484 printk(KERN_NOTICE "apm: %s: unknown error code %#2.2x\n",483485 str, err);484486}485485-486486-/*487487- * Lock APM functionality to physical CPU 0488488- */489489-490490-#ifdef CONFIG_SMP491491-492492-static cpumask_t apm_save_cpus(void)493493-{494494- cpumask_t x = current->cpus_allowed;495495- /* Some bioses don't like being called from CPU != 0 */496496- set_cpus_allowed(current, cpumask_of_cpu(0));497497- BUG_ON(smp_processor_id() != 0);498498- return x;499499-}500500-501501-static inline void apm_restore_cpus(cpumask_t mask)502502-{503503- set_cpus_allowed(current, mask);504504-}505505-506506-#else507507-508508-/*509509- * No CPU lockdown needed on a uniprocessor510510- */511511-512512-#define apm_save_cpus() (current->cpus_allowed)513513-#define apm_restore_cpus(x) (void)(x)514514-515515-#endif516487517488/*518489 * These are the actual BIOS calls. Depending on APM_ZERO_SEGS and···539568# define APM_DO_RESTORE_SEGS540569#endif541570571571+struct apm_bios_call {572572+ u32 func;573573+ /* In and out */574574+ u32 ebx;575575+ u32 ecx;576576+ /* Out only */577577+ u32 eax;578578+ u32 edx;579579+ u32 esi;580580+581581+ /* Error: -ENOMEM, or bits 8-15 of eax */582582+ int err;583583+};584584+542585/**543543- * apm_bios_call - Make an APM BIOS 32bit call544544- * @func: APM function to execute545545- * @ebx_in: EBX register for call entry546546- * @ecx_in: ECX register for call entry547547- * @eax: EAX register return548548- * @ebx: EBX register return549549- * @ecx: ECX register return550550- * @edx: EDX register return551551- * @esi: ESI register return586586+ * __apm_bios_call - Make an APM BIOS 32bit call587587+ * @_call: pointer to struct apm_bios_call.552588 *553589 * Make an APM call using the 32bit protected mode interface. The554590 * caller is responsible for knowing if APM BIOS is configured and···564586 * flag is loaded into AL. If there is an error, then the error565587 * code is returned in AH (bits 8-15 of eax) and this function566588 * returns non-zero.589589+ *590590+ * Note: this makes the call on the current CPU.567591 */568568-569569-static u8 apm_bios_call(u32 func, u32 ebx_in, u32 ecx_in,570570- u32 *eax, u32 *ebx, u32 *ecx, u32 *edx, u32 *esi)592592+static long __apm_bios_call(void *_call)571593{572594 APM_DECL_SEGS573595 unsigned long flags;574574- cpumask_t cpus;575596 int cpu;576597 struct desc_struct save_desc_40;577598 struct desc_struct *gdt;578578-579579- cpus = apm_save_cpus();599599+ struct apm_bios_call *call = _call;580600581601 cpu = get_cpu();602602+ BUG_ON(cpu != 0);582603 gdt = get_cpu_gdt_table(cpu);583604 save_desc_40 = gdt[0x40 / 8];584605 gdt[0x40 / 8] = bad_bios_desc;585606586607 apm_irq_save(flags);587608 APM_DO_SAVE_SEGS;588588- apm_bios_call_asm(func, ebx_in, ecx_in, eax, ebx, ecx, edx, esi);609609+ apm_bios_call_asm(call->func, call->ebx, call->ecx,610610+ &call->eax, &call->ebx, &call->ecx, &call->edx,611611+ &call->esi);589612 APM_DO_RESTORE_SEGS;590613 apm_irq_restore(flags);591614 gdt[0x40 / 8] = save_desc_40;592615 put_cpu();593593- apm_restore_cpus(cpus);594616595595- return *eax & 0xff;617617+ return call->eax & 0xff;618618+}619619+620620+/* Run __apm_bios_call or __apm_bios_call_simple on CPU 0 */621621+static int on_cpu0(long (*fn)(void *), struct apm_bios_call *call)622622+{623623+ int ret;624624+625625+ /* Don't bother with work_on_cpu in the common case, so we don't626626+ * have to worry about OOM or overhead. */627627+ if (get_cpu() == 0) {628628+ ret = fn(call);629629+ put_cpu();630630+ } else {631631+ put_cpu();632632+ ret = work_on_cpu(0, fn, call);633633+ }634634+635635+ /* work_on_cpu can fail with -ENOMEM */636636+ if (ret < 0)637637+ call->err = ret;638638+ else639639+ call->err = (call->eax >> 8) & 0xff;640640+641641+ return ret;642642+}643643+644644+/**645645+ * apm_bios_call - Make an APM BIOS 32bit call (on CPU 0)646646+ * @call: the apm_bios_call registers.647647+ *648648+ * If there is an error, it is returned in @call.err.649649+ */650650+static int apm_bios_call(struct apm_bios_call *call)651651+{652652+ return on_cpu0(__apm_bios_call, call);653653+}654654+655655+/**656656+ * __apm_bios_call_simple - Make an APM BIOS 32bit call (on CPU 0)657657+ * @_call: pointer to struct apm_bios_call.658658+ *659659+ * Make a BIOS call that returns one value only, or just status.660660+ * If there is an error, then the error code is returned in AH661661+ * (bits 8-15 of eax) and this function returns non-zero (it can662662+ * also return -ENOMEM). This is used for simpler BIOS operations.663663+ * This call may hold interrupts off for a long time on some laptops.664664+ *665665+ * Note: this makes the call on the current CPU.666666+ */667667+static long __apm_bios_call_simple(void *_call)668668+{669669+ u8 error;670670+ APM_DECL_SEGS671671+ unsigned long flags;672672+ int cpu;673673+ struct desc_struct save_desc_40;674674+ struct desc_struct *gdt;675675+ struct apm_bios_call *call = _call;676676+677677+ cpu = get_cpu();678678+ BUG_ON(cpu != 0);679679+ gdt = get_cpu_gdt_table(cpu);680680+ save_desc_40 = gdt[0x40 / 8];681681+ gdt[0x40 / 8] = bad_bios_desc;682682+683683+ apm_irq_save(flags);684684+ APM_DO_SAVE_SEGS;685685+ error = apm_bios_call_simple_asm(call->func, call->ebx, call->ecx,686686+ &call->eax);687687+ APM_DO_RESTORE_SEGS;688688+ apm_irq_restore(flags);689689+ gdt[0x40 / 8] = save_desc_40;690690+ put_cpu();691691+ return error;596692}597693598694/**···675623 * @ebx_in: EBX register value for BIOS call676624 * @ecx_in: ECX register value for BIOS call677625 * @eax: EAX register on return from the BIOS call626626+ * @err: bits678627 *679628 * Make a BIOS call that returns one value only, or just status.680680- * If there is an error, then the error code is returned in AH681681- * (bits 8-15 of eax) and this function returns non-zero. This is682682- * used for simpler BIOS operations. This call may hold interrupts683683- * off for a long time on some laptops.629629+ * If there is an error, then the error code is returned in @err630630+ * and this function returns non-zero. This is used for simpler631631+ * BIOS operations. This call may hold interrupts off for a long632632+ * time on some laptops.684633 */685685-686686-static u8 apm_bios_call_simple(u32 func, u32 ebx_in, u32 ecx_in, u32 *eax)634634+static int apm_bios_call_simple(u32 func, u32 ebx_in, u32 ecx_in, u32 *eax,635635+ int *err)687636{688688- u8 error;689689- APM_DECL_SEGS690690- unsigned long flags;691691- cpumask_t cpus;692692- int cpu;693693- struct desc_struct save_desc_40;694694- struct desc_struct *gdt;637637+ struct apm_bios_call call;638638+ int ret;695639696696- cpus = apm_save_cpus();640640+ call.func = func;641641+ call.ebx = ebx_in;642642+ call.ecx = ecx_in;697643698698- cpu = get_cpu();699699- gdt = get_cpu_gdt_table(cpu);700700- save_desc_40 = gdt[0x40 / 8];701701- gdt[0x40 / 8] = bad_bios_desc;702702-703703- apm_irq_save(flags);704704- APM_DO_SAVE_SEGS;705705- error = apm_bios_call_simple_asm(func, ebx_in, ecx_in, eax);706706- APM_DO_RESTORE_SEGS;707707- apm_irq_restore(flags);708708- gdt[0x40 / 8] = save_desc_40;709709- put_cpu();710710- apm_restore_cpus(cpus);711711- return error;644644+ ret = on_cpu0(__apm_bios_call_simple, &call);645645+ *eax = call.eax;646646+ *err = call.err;647647+ return ret;712648}713649714650/**···718678static int apm_driver_version(u_short *val)719679{720680 u32 eax;681681+ int err;721682722722- if (apm_bios_call_simple(APM_FUNC_VERSION, 0, *val, &eax))723723- return (eax >> 8) & 0xff;683683+ if (apm_bios_call_simple(APM_FUNC_VERSION, 0, *val, &eax, &err))684684+ return err;724685 *val = eax;725686 return APM_SUCCESS;726687}···742701 * that APM 1.2 is in use. If no messges are pending the value 0x80743702 * is returned (No power management events pending).744703 */745745-746704static int apm_get_event(apm_event_t *event, apm_eventinfo_t *info)747705{748748- u32 eax;749749- u32 ebx;750750- u32 ecx;751751- u32 dummy;706706+ struct apm_bios_call call;752707753753- if (apm_bios_call(APM_FUNC_GET_EVENT, 0, 0, &eax, &ebx, &ecx,754754- &dummy, &dummy))755755- return (eax >> 8) & 0xff;756756- *event = ebx;708708+ call.func = APM_FUNC_GET_EVENT;709709+ call.ebx = call.ecx = 0;710710+711711+ if (apm_bios_call(&call))712712+ return call.err;713713+714714+ *event = call.ebx;757715 if (apm_info.connection_version < 0x0102)758716 *info = ~0; /* indicate info not valid */759717 else760760- *info = ecx;718718+ *info = call.ecx;761719 return APM_SUCCESS;762720}763721···777737static int set_power_state(u_short what, u_short state)778738{779739 u32 eax;740740+ int err;780741781781- if (apm_bios_call_simple(APM_FUNC_SET_STATE, what, state, &eax))782782- return (eax >> 8) & 0xff;742742+ if (apm_bios_call_simple(APM_FUNC_SET_STATE, what, state, &eax, &err))743743+ return err;783744 return APM_SUCCESS;784745}785746···811770 u8 ret = 0;812771 int idled = 0;813772 int polling;773773+ int err;814774815775 polling = !!(current_thread_info()->status & TS_POLLING);816776 if (polling) {···824782 }825783 if (!need_resched()) {826784 idled = 1;827827- ret = apm_bios_call_simple(APM_FUNC_IDLE, 0, 0, &eax);785785+ ret = apm_bios_call_simple(APM_FUNC_IDLE, 0, 0, &eax, &err);828786 }829787 if (polling)830788 current_thread_info()->status |= TS_POLLING;···839797 * Only report the failure the first 5 times.840798 */841799 if (++t < 5) {842842- printk(KERN_DEBUG "apm_do_idle failed (%d)\n",843843- (eax >> 8) & 0xff);800800+ printk(KERN_DEBUG "apm_do_idle failed (%d)\n", err);844801 t = jiffies;845802 }846803 return -1;···857816static void apm_do_busy(void)858817{859818 u32 dummy;819819+ int err;860820861821 if (clock_slowed || ALWAYS_CALL_BUSY) {862862- (void)apm_bios_call_simple(APM_FUNC_BUSY, 0, 0, &dummy);822822+ (void)apm_bios_call_simple(APM_FUNC_BUSY, 0, 0, &dummy, &err);863823 clock_slowed = 0;864824 }865825}···979937980938 /* Some bioses don't like being called from CPU != 0 */981939 if (apm_info.realmode_power_off) {982982- (void)apm_save_cpus();940940+ set_cpus_allowed_ptr(current, cpumask_of(0));983941 machine_real_restart(po_bios_call, sizeof(po_bios_call));984942 } else {985943 (void)set_system_power_state(APM_STATE_OFF);···998956static int apm_enable_power_management(int enable)999957{1000958 u32 eax;959959+ int err;10019601002961 if ((enable == 0) && (apm_info.bios.flags & APM_BIOS_DISENGAGED))1003962 return APM_NOT_ENGAGED;1004963 if (apm_bios_call_simple(APM_FUNC_ENABLE_PM, APM_DEVICE_BALL,10051005- enable, &eax))10061006- return (eax >> 8) & 0xff;964964+ enable, &eax, &err))965965+ return err;1007966 if (enable)1008967 apm_info.bios.flags &= ~APM_BIOS_DISABLED;1009968 else···10299861030987static int apm_get_power_status(u_short *status, u_short *bat, u_short *life)1031988{10321032- u32 eax;10331033- u32 ebx;10341034- u32 ecx;10351035- u32 edx;10361036- u32 dummy;989989+ struct apm_bios_call call;990990+991991+ call.func = APM_FUNC_GET_STATUS;992992+ call.ebx = APM_DEVICE_ALL;993993+ call.ecx = 0;10379941038995 if (apm_info.get_power_status_broken)1039996 return APM_32_UNSUPPORTED;10401040- if (apm_bios_call(APM_FUNC_GET_STATUS, APM_DEVICE_ALL, 0,10411041- &eax, &ebx, &ecx, &edx, &dummy))10421042- return (eax >> 8) & 0xff;10431043- *status = ebx;10441044- *bat = ecx;997997+ if (apm_bios_call(&call))998998+ return call.err;999999+ *status = call.ebx;10001000+ *bat = call.ecx;10451001 if (apm_info.get_power_status_swabinminutes) {10461046- *life = swab16((u16)edx);10021002+ *life = swab16((u16)call.edx);10471003 *life |= 0x8000;10481004 } else10491049- *life = edx;10051005+ *life = call.edx;10501006 return APM_SUCCESS;10511007}10521008···10901048static int apm_engage_power_management(u_short device, int enable)10911049{10921050 u32 eax;10511051+ int err;1093105210941053 if ((enable == 0) && (device == APM_DEVICE_ALL)10951054 && (apm_info.bios.flags & APM_BIOS_DISABLED))10961055 return APM_DISABLED;10971097- if (apm_bios_call_simple(APM_FUNC_ENGAGE_PM, device, enable, &eax))10981098- return (eax >> 8) & 0xff;10561056+ if (apm_bios_call_simple(APM_FUNC_ENGAGE_PM, device, enable,10571057+ &eax, &err))10581058+ return err;10991059 if (device == APM_DEVICE_ALL) {11001060 if (enable)11011061 apm_info.bios.flags &= ~APM_BIOS_DISENGAGED;···17331689 char *power_stat;17341690 char *bat_stat;1735169117361736-#ifdef CONFIG_SMP17371692 /* 2002/08/01 - WT17381693 * This is to avoid random crashes at boot time during initialization17391694 * on SMP systems in case of "apm=power-off" mode. Seen on ASUS A7M266D.17401695 * Some bioses don't like being called from CPU != 0.17411696 * Method suggested by Ingo Molnar.17421697 */17431743- set_cpus_allowed(current, cpumask_of_cpu(0));16981698+ set_cpus_allowed_ptr(current, cpumask_of(0));17441699 BUG_ON(smp_processor_id() != 0);17451745-#endif1746170017471701 if (apm_info.connection_version == 0) {17481702 apm_info.connection_version = apm_info.bios.version;
+1-12
arch/x86/kernel/cpu/common.c
···41414242#include "cpu.h"43434444-#ifdef CONFIG_X86_644545-4644/* all of these masks are initialized in setup_cpu_local_masks() */4745cpumask_var_t cpu_initialized_mask;4846cpumask_var_t cpu_callout_mask;···5759 alloc_bootmem_cpumask_var(&cpu_callout_mask);5860 alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask);5961}6060-6161-#else /* CONFIG_X86_32 */6262-6363-cpumask_t cpu_sibling_setup_map;6464-cpumask_t cpu_callout_map;6565-cpumask_t cpu_initialized;6666-cpumask_t cpu_callin_map;6767-6868-#endif /* CONFIG_X86_32 */6969-70627163static const struct cpu_dev *this_cpu __cpuinitdata;7264···847859void __init identify_boot_cpu(void)848860{849861 identify_cpu(&boot_cpu_data);862862+ init_c1e_mask();850863#ifdef CONFIG_X86_32851864 sysenter_setup();852865 enable_sep_cpu();
···5454static int cpu_family = CPU_OPTERON;55555656#ifndef CONFIG_SMP5757-DEFINE_PER_CPU(cpumask_t, cpu_core_map);5757+static inline const struct cpumask *cpu_core_mask(int cpu)5858+{5959+ return cpumask_of(0);6060+}5861#endif59626063/* Return a frequency in MHz, given an input fid */···702699703700 dprintk("cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid);704701 data->powernow_table = powernow_table;705705- if (first_cpu(per_cpu(cpu_core_map, data->cpu)) == data->cpu)702702+ if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu)706703 print_basics(data);707704708705 for (j = 0; j < data->numps; j++)···865862866863 /* fill in data */867864 data->numps = data->acpi_data.state_count;868868- if (first_cpu(per_cpu(cpu_core_map, data->cpu)) == data->cpu)865865+ if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu)869866 print_basics(data);870867 powernow_k8_acpi_pst_values(data, 0);871868···13031300 if (cpu_family == CPU_HW_PSTATE)13041301 cpumask_copy(pol->cpus, cpumask_of(pol->cpu));13051302 else13061306- cpumask_copy(pol->cpus, &per_cpu(cpu_core_map, pol->cpu));13031303+ cpumask_copy(pol->cpus, cpu_core_mask(pol->cpu));13071304 data->available_cores = pol->cpus;1308130513091306 if (cpu_family == CPU_HW_PSTATE)···13681365 unsigned int khz = 0;13691366 unsigned int first;1370136713711371- first = first_cpu(per_cpu(cpu_core_map, cpu));13681368+ first = cpumask_first(cpu_core_mask(cpu));13721369 data = per_cpu(powernow_data, first);1373137013741371 if (!data)
+1-1
arch/x86/kernel/cpu/cpufreq/speedstep-ich.c
···321321322322 /* only run on CPU to be set, or on its sibling */323323#ifdef CONFIG_SMP324324- cpumask_copy(policy->cpus, &per_cpu(cpu_sibling_map, policy->cpu));324324+ cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu));325325#endif326326327327 cpus_allowed = current->cpus_allowed;
···990990 NULL991991};992992993993-static cpumask_t mce_device_initialized = CPU_MASK_NONE;993993+static cpumask_var_t mce_device_initialized;994994995995/* Per cpu sysdev init. All of the cpus still share the same ctl bank */996996static __cpuinit int mce_create_device(unsigned int cpu)···10211021 if (err)10221022 goto error2;10231023 }10241024- cpu_set(cpu, mce_device_initialized);10241024+ cpumask_set_cpu(cpu, mce_device_initialized);1025102510261026 return 0;10271027error2:···10431043{10441044 int i;1045104510461046- if (!cpu_isset(cpu, mce_device_initialized))10461046+ if (!cpumask_test_cpu(cpu, mce_device_initialized))10471047 return;1048104810491049 for (i = 0; mce_attributes[i]; i++)···10531053 sysdev_remove_file(&per_cpu(device_mce, cpu),10541054 &bank_attrs[i]);10551055 sysdev_unregister(&per_cpu(device_mce,cpu));10561056- cpu_clear(cpu, mce_device_initialized);10561056+ cpumask_clear_cpu(cpu, mce_device_initialized);10571057}1058105810591059/* Make sure there are no machine checks on offlined CPUs. */···1161116111621162 if (!mce_available(&boot_cpu_data))11631163 return -EIO;11641164+11651165+ alloc_cpumask_var(&mce_device_initialized, GFP_KERNEL);1164116611651167 err = mce_init_banks();11661168 if (err)
+3-3
arch/x86/kernel/cpu/mcheck/mce_amd_64.c
···485485486486#ifdef CONFIG_SMP487487 if (cpu_data(cpu).cpu_core_id && shared_bank[bank]) { /* symlink */488488- i = cpumask_first(&per_cpu(cpu_core_map, cpu));488488+ i = cpumask_first(cpu_core_mask(cpu));489489490490 /* first core not up yet */491491 if (cpu_data(i).cpu_core_id)···505505 if (err)506506 goto out;507507508508- cpumask_copy(b->cpus, &per_cpu(cpu_core_map, cpu));508508+ cpumask_copy(b->cpus, cpu_core_mask(cpu));509509 per_cpu(threshold_banks, cpu)[bank] = b;510510 goto out;511511 }···529529#ifndef CONFIG_SMP530530 cpumask_setall(b->cpus);531531#else532532- cpumask_copy(b->cpus, &per_cpu(cpu_core_map, cpu));532532+ cpumask_copy(b->cpus, cpu_core_mask(cpu));533533#endif534534535535 per_cpu(threshold_banks, cpu)[bank] = b;
+1-1
arch/x86/kernel/cpu/mcheck/mce_intel_64.c
···249249 for_each_online_cpu (cpu) {250250 if (cpu == dying)251251 continue;252252- if (set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)))252252+ if (set_cpus_allowed_ptr(current, cpumask_of(cpu)))253253 continue;254254 /* Recheck banks in case CPUs don't all have the same */255255 if (cmci_supported(&banks))
+3-3
arch/x86/kernel/cpu/proc.c
···1414 if (c->x86_max_cores * smp_num_siblings > 1) {1515 seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);1616 seq_printf(m, "siblings\t: %d\n",1717- cpus_weight(per_cpu(cpu_core_map, cpu)));1717+ cpumask_weight(cpu_sibling_mask(cpu)));1818 seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);1919 seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);2020 seq_printf(m, "apicid\t\t: %d\n", c->apicid);···143143static void *c_start(struct seq_file *m, loff_t *pos)144144{145145 if (*pos == 0) /* just in case, cpu 0 is not the first */146146- *pos = first_cpu(cpu_online_map);146146+ *pos = cpumask_first(cpu_online_mask);147147 else148148- *pos = next_cpu_nr(*pos - 1, cpu_online_map);148148+ *pos = cpumask_next(*pos - 1, cpu_online_mask);149149 if ((*pos) < nr_cpu_ids)150150 return &cpu_data(*pos);151151 return NULL;
+23-26
arch/x86/kernel/microcode_amd.c
···1212 *1313 * Licensed under the terms of the GNU General Public1414 * License version 2. See file COPYING for details.1515-*/1616-1717-#include <linux/capability.h>1818-#include <linux/kernel.h>1919-#include <linux/init.h>2020-#include <linux/sched.h>2121-#include <linux/cpumask.h>2222-#include <linux/module.h>2323-#include <linux/slab.h>2424-#include <linux/vmalloc.h>2525-#include <linux/miscdevice.h>2626-#include <linux/spinlock.h>2727-#include <linux/mm.h>2828-#include <linux/fs.h>2929-#include <linux/mutex.h>3030-#include <linux/cpu.h>3131-#include <linux/firmware.h>1515+ */3216#include <linux/platform_device.h>3333-#include <linux/pci.h>1717+#include <linux/capability.h>1818+#include <linux/miscdevice.h>1919+#include <linux/firmware.h>2020+#include <linux/spinlock.h>2121+#include <linux/cpumask.h>3422#include <linux/pci_ids.h>3523#include <linux/uaccess.h>2424+#include <linux/vmalloc.h>2525+#include <linux/kernel.h>2626+#include <linux/module.h>2727+#include <linux/mutex.h>2828+#include <linux/sched.h>2929+#include <linux/init.h>3030+#include <linux/slab.h>3131+#include <linux/cpu.h>3232+#include <linux/pci.h>3333+#include <linux/fs.h>3434+#include <linux/mm.h>36353737-#include <asm/msr.h>3838-#include <asm/processor.h>3936#include <asm/microcode.h>3737+#include <asm/processor.h>3838+#include <asm/msr.h>40394140MODULE_DESCRIPTION("AMD Microcode Update Driver");4241MODULE_AUTHOR("Peter Oruba");···7172} __attribute__((packed));72737374struct microcode_amd {7474- struct microcode_header_amd hdr;7575- unsigned int mpb[0];7575+ struct microcode_header_amd hdr;7676+ unsigned int mpb[0];7677};77787879#define UCODE_MAX_SIZE 2048···183184 return 0;184185}185186186186-static void *get_next_ucode(const u8 *buf, unsigned int size,187187- unsigned int *mc_size)187187+static void *188188+get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size)188189{189190 unsigned int total_size;190191 u8 section_hdr[UCODE_CONTAINER_SECTION_HDR];···221222 }222223 return mc;223224}224224-225225226226static int install_equiv_cpu_table(const u8 *buf)227227{···370372{371373 return µcode_amd_ops;372374}373373-
+93-77
arch/x86/kernel/microcode_core.c
···7070 * Fix sigmatch() macro to handle old CPUs with pf == 0.7171 * Thanks to Stuart Swales for pointing out this bug.7272 */7373-#include <linux/capability.h>7474-#include <linux/kernel.h>7575-#include <linux/init.h>7676-#include <linux/sched.h>7777-#include <linux/smp_lock.h>7878-#include <linux/cpumask.h>7979-#include <linux/module.h>8080-#include <linux/slab.h>8181-#include <linux/vmalloc.h>8282-#include <linux/miscdevice.h>8383-#include <linux/spinlock.h>8484-#include <linux/mm.h>8585-#include <linux/fs.h>8686-#include <linux/mutex.h>8787-#include <linux/cpu.h>8888-#include <linux/firmware.h>8973#include <linux/platform_device.h>7474+#include <linux/capability.h>7575+#include <linux/miscdevice.h>7676+#include <linux/firmware.h>7777+#include <linux/smp_lock.h>7878+#include <linux/spinlock.h>7979+#include <linux/cpumask.h>8080+#include <linux/uaccess.h>8181+#include <linux/vmalloc.h>8282+#include <linux/kernel.h>8383+#include <linux/module.h>8484+#include <linux/mutex.h>8585+#include <linux/sched.h>8686+#include <linux/init.h>8787+#include <linux/slab.h>8888+#include <linux/cpu.h>8989+#include <linux/fs.h>9090+#include <linux/mm.h>90919191-#include <asm/msr.h>9292-#include <asm/uaccess.h>9393-#include <asm/processor.h>9492#include <asm/microcode.h>9393+#include <asm/processor.h>9494+#include <asm/msr.h>95959696MODULE_DESCRIPTION("Microcode Update Driver");9797MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>");9898MODULE_LICENSE("GPL");9999100100-#define MICROCODE_VERSION "2.00"100100+#define MICROCODE_VERSION "2.00"101101102102-static struct microcode_ops *microcode_ops;102102+static struct microcode_ops *microcode_ops;103103104104/* no concurrent ->write()s are allowed on /dev/cpu/microcode */105105static DEFINE_MUTEX(microcode_mutex);106106107107-struct ucode_cpu_info ucode_cpu_info[NR_CPUS];107107+struct ucode_cpu_info ucode_cpu_info[NR_CPUS];108108EXPORT_SYMBOL_GPL(ucode_cpu_info);109109110110#ifdef CONFIG_MICROCODE_OLD_INTERFACE111111+struct update_for_cpu {112112+ const void __user *buf;113113+ size_t size;114114+};115115+116116+static long update_for_cpu(void *_ufc)117117+{118118+ struct update_for_cpu *ufc = _ufc;119119+ int error;120120+121121+ error = microcode_ops->request_microcode_user(smp_processor_id(),122122+ ufc->buf, ufc->size);123123+ if (error < 0)124124+ return error;125125+ if (!error)126126+ microcode_ops->apply_microcode(smp_processor_id());127127+ return error;128128+}129129+111130static int do_microcode_update(const void __user *buf, size_t size)112131{113113- cpumask_t old;114132 int error = 0;115133 int cpu;116116-117117- old = current->cpus_allowed;134134+ struct update_for_cpu ufc = { .buf = buf, .size = size };118135119136 for_each_online_cpu(cpu) {120137 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;121138122139 if (!uci->valid)123140 continue;124124-125125- set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));126126- error = microcode_ops->request_microcode_user(cpu, buf, size);141141+ error = work_on_cpu(cpu, update_for_cpu, &ufc);127142 if (error < 0)128128- goto out;129129- if (!error)130130- microcode_ops->apply_microcode(cpu);143143+ break;131144 }132132-out:133133- set_cpus_allowed_ptr(current, &old);134145 return error;135146}136147···209198210199MODULE_ALIAS_MISCDEV(MICROCODE_MINOR);211200#else212212-#define microcode_dev_init() 0213213-#define microcode_dev_exit() do { } while (0)201201+#define microcode_dev_init() 0202202+#define microcode_dev_exit() do { } while (0)214203#endif215204216205/* fake device for request_firmware */217217-static struct platform_device *microcode_pdev;206206+static struct platform_device *microcode_pdev;207207+208208+static long reload_for_cpu(void *unused)209209+{210210+ struct ucode_cpu_info *uci = ucode_cpu_info + smp_processor_id();211211+ int err = 0;212212+213213+ mutex_lock(µcode_mutex);214214+ if (uci->valid) {215215+ err = microcode_ops->request_microcode_fw(smp_processor_id(),216216+ µcode_pdev->dev);217217+ if (!err)218218+ microcode_ops->apply_microcode(smp_processor_id());219219+ }220220+ mutex_unlock(µcode_mutex);221221+ return err;222222+}218223219224static ssize_t reload_store(struct sys_device *dev,220225 struct sysdev_attribute *attr,221226 const char *buf, size_t sz)222227{223223- struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;224228 char *end;225229 unsigned long val = simple_strtoul(buf, &end, 0);226230 int err = 0;···244218 if (end == buf)245219 return -EINVAL;246220 if (val == 1) {247247- cpumask_t old = current->cpus_allowed;248248-249221 get_online_cpus();250250- if (cpu_online(cpu)) {251251- set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));252252- mutex_lock(µcode_mutex);253253- if (uci->valid) {254254- err = microcode_ops->request_microcode_fw(cpu,255255- µcode_pdev->dev);256256- if (!err)257257- microcode_ops->apply_microcode(cpu);258258- }259259- mutex_unlock(µcode_mutex);260260- set_cpus_allowed_ptr(current, &old);261261- }222222+ if (cpu_online(cpu))223223+ err = work_on_cpu(cpu, reload_for_cpu, NULL);262224 put_online_cpus();263225 }264226 if (err)···282268};283269284270static struct attribute_group mc_attr_group = {285285- .attrs = mc_default_attrs,286286- .name = "microcode",271271+ .attrs = mc_default_attrs,272272+ .name = "microcode",287273};288274289275static void __microcode_fini_cpu(int cpu)···342328 return 0;343329}344330345345-static void microcode_update_cpu(int cpu)331331+static long microcode_update_cpu(void *unused)346332{347347- struct ucode_cpu_info *uci = ucode_cpu_info + cpu;333333+ struct ucode_cpu_info *uci = ucode_cpu_info + smp_processor_id();348334 int err = 0;349335350336 /*···352338 * otherwise just request a firmware:353339 */354340 if (uci->valid) {355355- err = microcode_resume_cpu(cpu);356356- } else { 357357- collect_cpu_info(cpu);341341+ err = microcode_resume_cpu(smp_processor_id());342342+ } else {343343+ collect_cpu_info(smp_processor_id());358344 if (uci->valid && system_state == SYSTEM_RUNNING)359359- err = microcode_ops->request_microcode_fw(cpu,345345+ err = microcode_ops->request_microcode_fw(346346+ smp_processor_id(),360347 µcode_pdev->dev);361348 }362349 if (!err)363363- microcode_ops->apply_microcode(cpu);350350+ microcode_ops->apply_microcode(smp_processor_id());351351+ return err;364352}365353366366-static void microcode_init_cpu(int cpu)354354+static int microcode_init_cpu(int cpu)367355{368368- cpumask_t old = current->cpus_allowed;369369-370370- set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));371371- /* We should bind the task to the CPU */372372- BUG_ON(raw_smp_processor_id() != cpu);373373-356356+ int err;374357 mutex_lock(µcode_mutex);375375- microcode_update_cpu(cpu);358358+ err = work_on_cpu(cpu, microcode_update_cpu, NULL);376359 mutex_unlock(µcode_mutex);377360378378- set_cpus_allowed_ptr(current, &old);361361+ return err;379362}380363381364static int mc_sysdev_add(struct sys_device *sys_dev)···390379 if (err)391380 return err;392381393393- microcode_init_cpu(cpu);394394- return 0;382382+ err = microcode_init_cpu(cpu);383383+ if (err)384384+ sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);385385+386386+ return err;395387}396388397389static int mc_sysdev_remove(struct sys_device *sys_dev)···418404 return 0;419405420406 /* only CPU 0 will apply ucode here */421421- microcode_update_cpu(0);407407+ microcode_update_cpu(NULL);422408 return 0;423409}424410425411static struct sysdev_driver mc_sysdev_driver = {426426- .add = mc_sysdev_add,427427- .remove = mc_sysdev_remove,428428- .resume = mc_sysdev_resume,412412+ .add = mc_sysdev_add,413413+ .remove = mc_sysdev_remove,414414+ .resume = mc_sysdev_resume,429415};430416431417static __cpuinit int···438424 switch (action) {439425 case CPU_ONLINE:440426 case CPU_ONLINE_FROZEN:441441- microcode_init_cpu(cpu);427427+ if (microcode_init_cpu(cpu))428428+ printk(KERN_ERR "microcode: failed to init CPU%d\n",429429+ cpu);442430 case CPU_DOWN_FAILED:443431 case CPU_DOWN_FAILED_FROZEN:444432 pr_debug("microcode: CPU%d added\n", cpu);···464448}465449466450static struct notifier_block __refdata mc_cpu_notifier = {467467- .notifier_call = mc_cpu_callback,451451+ .notifier_call = mc_cpu_callback,468452};469453470454static int __init microcode_init(void)
+52-39
arch/x86/kernel/microcode_intel.c
···7070 * Fix sigmatch() macro to handle old CPUs with pf == 0.7171 * Thanks to Stuart Swales for pointing out this bug.7272 */7373-#include <linux/capability.h>7474-#include <linux/kernel.h>7575-#include <linux/init.h>7676-#include <linux/sched.h>7777-#include <linux/smp_lock.h>7878-#include <linux/cpumask.h>7979-#include <linux/module.h>8080-#include <linux/slab.h>8181-#include <linux/vmalloc.h>8282-#include <linux/miscdevice.h>8383-#include <linux/spinlock.h>8484-#include <linux/mm.h>8585-#include <linux/fs.h>8686-#include <linux/mutex.h>8787-#include <linux/cpu.h>8888-#include <linux/firmware.h>8973#include <linux/platform_device.h>7474+#include <linux/capability.h>7575+#include <linux/miscdevice.h>7676+#include <linux/firmware.h>7777+#include <linux/smp_lock.h>7878+#include <linux/spinlock.h>7979+#include <linux/cpumask.h>9080#include <linux/uaccess.h>8181+#include <linux/vmalloc.h>8282+#include <linux/kernel.h>8383+#include <linux/module.h>8484+#include <linux/mutex.h>8585+#include <linux/sched.h>8686+#include <linux/init.h>8787+#include <linux/slab.h>8888+#include <linux/cpu.h>8989+#include <linux/fs.h>9090+#include <linux/mm.h>91919292-#include <asm/msr.h>9393-#include <asm/processor.h>9492#include <asm/microcode.h>9393+#include <asm/processor.h>9494+#include <asm/msr.h>95959696MODULE_DESCRIPTION("Microcode Update Driver");9797MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>");···129129 struct extended_signature sigs[0];130130};131131132132-#define DEFAULT_UCODE_DATASIZE (2000)132132+#define DEFAULT_UCODE_DATASIZE (2000)133133#define MC_HEADER_SIZE (sizeof(struct microcode_header_intel))134134#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE)135135#define EXT_HEADER_SIZE (sizeof(struct extended_sigtable))136136#define EXT_SIGNATURE_SIZE (sizeof(struct extended_signature))137137#define DWSIZE (sizeof(u32))138138+138139#define get_totalsize(mc) \139140 (((struct microcode_intel *)mc)->hdr.totalsize ? \140141 ((struct microcode_intel *)mc)->hdr.totalsize : \···198197}199198200199static inline int201201-update_match_revision(struct microcode_header_intel *mc_header, int rev)200200+update_match_revision(struct microcode_header_intel *mc_header, int rev)202201{203202 return (mc_header->rev <= rev) ? 0 : 1;204203}205204206205static int microcode_sanity_check(void *mc)207206{207207+ unsigned long total_size, data_size, ext_table_size;208208 struct microcode_header_intel *mc_header = mc;209209 struct extended_sigtable *ext_header = NULL;210210- struct extended_signature *ext_sig;211211- unsigned long total_size, data_size, ext_table_size;212210 int sum, orig_sum, ext_sigcount = 0, i;211211+ struct extended_signature *ext_sig;213212214213 total_size = get_totalsize(mc_header);215214 data_size = get_datasize(mc_header);215215+216216 if (data_size + MC_HEADER_SIZE > total_size) {217217 printk(KERN_ERR "microcode: error! "218218- "Bad data size in microcode data file\n");218218+ "Bad data size in microcode data file\n");219219 return -EINVAL;220220 }221221222222 if (mc_header->ldrver != 1 || mc_header->hdrver != 1) {223223 printk(KERN_ERR "microcode: error! "224224- "Unknown microcode update format\n");224224+ "Unknown microcode update format\n");225225 return -EINVAL;226226 }227227 ext_table_size = total_size - (MC_HEADER_SIZE + data_size);···320318321319static void apply_microcode(int cpu)322320{321321+ struct microcode_intel *mc_intel;322322+ struct ucode_cpu_info *uci;323323 unsigned long flags;324324 unsigned int val[2];325325- int cpu_num = raw_smp_processor_id();326326- struct ucode_cpu_info *uci = ucode_cpu_info + cpu;327327- struct microcode_intel *mc_intel = uci->mc;325325+ int cpu_num;326326+327327+ cpu_num = raw_smp_processor_id();328328+ uci = ucode_cpu_info + cpu;329329+ mc_intel = uci->mc;328330329331 /* We should bind the task to the CPU */330332 BUG_ON(cpu_num != cpu);···354348 spin_unlock_irqrestore(µcode_update_lock, flags);355349 if (val[1] != mc_intel->hdr.rev) {356350 printk(KERN_ERR "microcode: CPU%d update from revision "357357- "0x%x to 0x%x failed\n", cpu_num, uci->cpu_sig.rev, val[1]);351351+ "0x%x to 0x%x failed\n",352352+ cpu_num, uci->cpu_sig.rev, val[1]);358353 return;359354 }360355 printk(KERN_INFO "microcode: CPU%d updated from revision "361361- "0x%x to 0x%x, date = %04x-%02x-%02x \n",356356+ "0x%x to 0x%x, date = %04x-%02x-%02x \n",362357 cpu_num, uci->cpu_sig.rev, val[1],363358 mc_intel->hdr.date & 0xffff,364359 mc_intel->hdr.date >> 24,365360 (mc_intel->hdr.date >> 16) & 0xff);361361+366362 uci->cpu_sig.rev = val[1];367363}368364···412404 leftover -= mc_size;413405 }414406415415- if (new_mc) {416416- if (!leftover) {417417- if (uci->mc)418418- vfree(uci->mc);419419- uci->mc = (struct microcode_intel *)new_mc;420420- pr_debug("microcode: CPU%d found a matching microcode update with"421421- " version 0x%x (current=0x%x)\n",422422- cpu, new_rev, uci->cpu_sig.rev);423423- } else424424- vfree(new_mc);407407+ if (!new_mc)408408+ goto out;409409+410410+ if (leftover) {411411+ vfree(new_mc);412412+ goto out;425413 }426414415415+ if (uci->mc)416416+ vfree(uci->mc);417417+ uci->mc = (struct microcode_intel *)new_mc;418418+419419+ pr_debug("microcode: CPU%d found a matching microcode update with"420420+ " version 0x%x (current=0x%x)\n",421421+ cpu, new_rev, uci->cpu_sig.rev);422422+423423+ out:427424 return (int)leftover;428425}429426
+15-5
arch/x86/kernel/process.c
···325325 /*326326 * Remove this CPU:327327 */328328- cpu_clear(smp_processor_id(), cpu_online_map);328328+ set_cpu_online(smp_processor_id(), false);329329 disable_local_APIC();330330331331 for (;;) {···475475 return 1;476476}477477478478-static cpumask_t c1e_mask = CPU_MASK_NONE;478478+static cpumask_var_t c1e_mask;479479static int c1e_detected;480480481481void c1e_remove_cpu(int cpu)482482{483483- cpu_clear(cpu, c1e_mask);483483+ if (c1e_mask != NULL)484484+ cpumask_clear_cpu(cpu, c1e_mask);484485}485486486487/*···510509 if (c1e_detected) {511510 int cpu = smp_processor_id();512511513513- if (!cpu_isset(cpu, c1e_mask)) {514514- cpu_set(cpu, c1e_mask);512512+ if (!cpumask_test_cpu(cpu, c1e_mask)) {513513+ cpumask_set_cpu(cpu, c1e_mask);515514 /*516515 * Force broadcast so ACPI can not interfere. Needs517516 * to run with interrupts enabled as it uses···561560 pm_idle = c1e_idle;562561 } else563562 pm_idle = default_idle;563563+}564564+565565+void __init init_c1e_mask(void)566566+{567567+ /* If we're using c1e_idle, we need to allocate c1e_mask. */568568+ if (pm_idle == c1e_idle) {569569+ alloc_cpumask_var(&c1e_mask, GFP_KERNEL);570570+ cpumask_clear(c1e_mask);571571+ }564572}565573566574static int __init idle_setup(char *str)
+43-27
arch/x86/kernel/smpboot.c
···101101DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID;102102103103/* representing HT siblings of each logical CPU */104104-DEFINE_PER_CPU(cpumask_t, cpu_sibling_map);104104+DEFINE_PER_CPU(cpumask_var_t, cpu_sibling_map);105105EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);106106107107/* representing HT and core siblings of each logical CPU */108108-DEFINE_PER_CPU(cpumask_t, cpu_core_map);108108+DEFINE_PER_CPU(cpumask_var_t, cpu_core_map);109109EXPORT_PER_CPU_SYMBOL(cpu_core_map);110110111111/* Per CPU bogomips and other parameters */···115115atomic_t init_deasserted;116116117117#if defined(CONFIG_NUMA) && defined(CONFIG_X86_32)118118-119119-/* which logical CPUs are on which nodes */120120-cpumask_t node_to_cpumask_map[MAX_NUMNODES] __read_mostly =121121- { [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE };122122-EXPORT_SYMBOL(node_to_cpumask_map);123118/* which node each logical CPU is on */124119int cpu_to_node_map[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0 };125120EXPORT_SYMBOL(cpu_to_node_map);···123128static void map_cpu_to_node(int cpu, int node)124129{125130 printk(KERN_INFO "Mapping cpu %d to node %d\n", cpu, node);126126- cpumask_set_cpu(cpu, &node_to_cpumask_map[node]);131131+ cpumask_set_cpu(cpu, node_to_cpumask_map[node]);127132 cpu_to_node_map[cpu] = node;128133}129134···134139135140 printk(KERN_INFO "Unmapping cpu %d from all nodes\n", cpu);136141 for (node = 0; node < MAX_NUMNODES; node++)137137- cpumask_clear_cpu(cpu, &node_to_cpumask_map[node]);142142+ cpumask_clear_cpu(cpu, node_to_cpumask_map[node]);138143 cpu_to_node_map[cpu] = 0;139144}140145#else /* !(CONFIG_NUMA && CONFIG_X86_32) */···296301 __flush_tlb_all();297302#endif298303299299- /* This must be done before setting cpu_online_map */304304+ /* This must be done before setting cpu_online_mask */300305 set_cpu_sibling_map(raw_smp_processor_id());301306 wmb();302307···329334 cpu_idle();330335}331336337337+#ifdef CONFIG_CPUMASK_OFFSTACK338338+/* In this case, llc_shared_map is a pointer to a cpumask. */339339+static inline void copy_cpuinfo_x86(struct cpuinfo_x86 *dst,340340+ const struct cpuinfo_x86 *src)341341+{342342+ struct cpumask *llc = dst->llc_shared_map;343343+ *dst = *src;344344+ dst->llc_shared_map = llc;345345+}346346+#else347347+static inline void copy_cpuinfo_x86(struct cpuinfo_x86 *dst,348348+ const struct cpuinfo_x86 *src)349349+{350350+ *dst = *src;351351+}352352+#endif /* CONFIG_CPUMASK_OFFSTACK */353353+332354/*333355 * The bootstrap kernel entry code has set these up. Save them for334356 * a given CPU···355343{356344 struct cpuinfo_x86 *c = &cpu_data(id);357345358358- *c = boot_cpu_data;346346+ copy_cpuinfo_x86(c, &boot_cpu_data);359347 c->cpu_index = id;360348 if (id != 0)361349 identify_secondary_cpu(c);···379367 cpumask_set_cpu(cpu, cpu_sibling_mask(i));380368 cpumask_set_cpu(i, cpu_core_mask(cpu));381369 cpumask_set_cpu(cpu, cpu_core_mask(i));382382- cpumask_set_cpu(i, &c->llc_shared_map);383383- cpumask_set_cpu(cpu, &o->llc_shared_map);370370+ cpumask_set_cpu(i, c->llc_shared_map);371371+ cpumask_set_cpu(cpu, o->llc_shared_map);384372 }385373 }386374 } else {387375 cpumask_set_cpu(cpu, cpu_sibling_mask(cpu));388376 }389377390390- cpumask_set_cpu(cpu, &c->llc_shared_map);378378+ cpumask_set_cpu(cpu, c->llc_shared_map);391379392380 if (current_cpu_data.x86_max_cores == 1) {393381 cpumask_copy(cpu_core_mask(cpu), cpu_sibling_mask(cpu));···398386 for_each_cpu(i, cpu_sibling_setup_mask) {399387 if (per_cpu(cpu_llc_id, cpu) != BAD_APICID &&400388 per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) {401401- cpumask_set_cpu(i, &c->llc_shared_map);402402- cpumask_set_cpu(cpu, &cpu_data(i).llc_shared_map);389389+ cpumask_set_cpu(i, c->llc_shared_map);390390+ cpumask_set_cpu(cpu, cpu_data(i).llc_shared_map);403391 }404392 if (c->phys_proc_id == cpu_data(i).phys_proc_id) {405393 cpumask_set_cpu(i, cpu_core_mask(cpu));···437425 if (sched_mc_power_savings || sched_smt_power_savings)438426 return cpu_core_mask(cpu);439427 else440440- return &c->llc_shared_map;441441-}442442-443443-cpumask_t cpu_coregroup_map(int cpu)444444-{445445- return *cpu_coregroup_mask(cpu);428428+ return c->llc_shared_map;446429}447430448431static void impress_friends(void)···904897 */905898static __init void disable_smp(void)906899{907907- /* use the read/write pointers to the present and possible maps */908908- cpumask_copy(&cpu_present_map, cpumask_of(0));909909- cpumask_copy(&cpu_possible_map, cpumask_of(0));900900+ init_cpu_present(cpumask_of(0));901901+ init_cpu_possible(cpumask_of(0));910902 smpboot_clear_io_apic_irqs();911903912904 if (smp_found_config)···10371031 */10381032void __init native_smp_prepare_cpus(unsigned int max_cpus)10391033{10341034+ unsigned int i;10351035+10401036 preempt_disable();10411037 smp_cpu_index_default();10421038 current_cpu_data = boot_cpu_data;···10521044 boot_cpu_logical_apicid = logical_smp_processor_id();10531045#endif10541046 current_thread_info()->cpu = 0; /* needed? */10471047+ for_each_possible_cpu(i) {10481048+ alloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL);10491049+ alloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL);10501050+ alloc_cpumask_var(&cpu_data(i).llc_shared_map, GFP_KERNEL);10511051+ cpumask_clear(per_cpu(cpu_core_map, i));10521052+ cpumask_clear(per_cpu(cpu_sibling_map, i));10531053+ cpumask_clear(cpu_data(i).llc_shared_map);10541054+ }10551055 set_cpu_sibling_map(0);1056105610571057 enable_IR_x2apic();···114811321149113311501134/*11511151- * cpu_possible_map should be static, it cannot change as cpu's11351135+ * cpu_possible_mask should be static, it cannot change as cpu's11521136 * are onlined, or offlined. The reason is per-cpu data-structures11531137 * are allocated by some modules at init time, and dont expect to11541138 * do this dynamically on cpu arrival/departure.11551155- * cpu_present_map on the other hand can change dynamically.11391139+ * cpu_present_mask on the other hand can change dynamically.11561140 * In case when cpu_hotplug is not compiled, then we resort to current11571141 * behaviour, which is cpu_possible == cpu_present.11581142 * - Ashok Raj
+7-2
arch/x86/kernel/tlb_uv.c
···275275 return NULL;276276}277277278278+static DEFINE_PER_CPU(cpumask_var_t, uv_flush_tlb_mask);279279+278280/**279281 * uv_flush_tlb_others - globally purge translation cache of a virtual280282 * address or all TLB's···306304 struct mm_struct *mm,307305 unsigned long va, unsigned int cpu)308306{309309- static DEFINE_PER_CPU(cpumask_t, flush_tlb_mask);310310- struct cpumask *flush_mask = &__get_cpu_var(flush_tlb_mask);307307+ struct cpumask *flush_mask = __get_cpu_var(uv_flush_tlb_mask);311308 int i;312309 int bit;313310 int blade;···755754756755 if (!is_uv_system())757756 return 0;757757+758758+ for_each_possible_cpu(cur_cpu)759759+ alloc_cpumask_var_node(&per_cpu(uv_flush_tlb_mask, cur_cpu),760760+ GFP_KERNEL, cpu_to_node(cur_cpu));758761759762 uv_bau_retry_limit = 1;760763 uv_nshift = uv_hub_info->n_val;
···378378}379379380380#ifdef CONFIG_HOTPLUG_CPU381381-static cpumask_t downed_cpus;381381+static cpumask_var_t downed_cpus;382382383383static void enter_uniprocessor(void)384384{385385 int cpu;386386 int err;387387388388+ if (downed_cpus == NULL &&389389+ !alloc_cpumask_var(&downed_cpus, GFP_KERNEL)) {390390+ pr_notice(NAME "Failed to allocate mask\n");391391+ goto out;392392+ }393393+388394 get_online_cpus();389389- downed_cpus = cpu_online_map;390390- cpu_clear(first_cpu(cpu_online_map), downed_cpus);395395+ cpumask_copy(downed_cpus, cpu_online_mask);396396+ cpumask_clear_cpu(cpumask_first(cpu_online_mask), downed_cpus);391397 if (num_online_cpus() > 1)392398 pr_notice(NAME "Disabling non-boot CPUs...\n");393399 put_online_cpus();394400395395- for_each_cpu_mask(cpu, downed_cpus) {401401+ for_each_cpu(cpu, downed_cpus) {396402 err = cpu_down(cpu);397403 if (!err)398404 pr_info(NAME "CPU%d is down.\n", cpu);399405 else400406 pr_err(NAME "Error taking CPU%d down: %d\n", cpu, err);401407 }408408+out:402409 if (num_online_cpus() > 1)403410 pr_warning(NAME "multiple CPUs still online, "404411 "may miss events.\n");···418411 int cpu;419412 int err;420413421421- if (cpus_weight(downed_cpus) == 0)414414+ if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)422415 return;423416 pr_notice(NAME "Re-enabling CPUs...\n");424424- for_each_cpu_mask(cpu, downed_cpus) {417417+ for_each_cpu(cpu, downed_cpus) {425418 err = cpu_up(cpu);426419 if (!err)427420 pr_info(NAME "enabled CPU%d.\n", cpu);
+67
arch/x86/mm/numa.c
···11+/* Common code for 32 and 64-bit NUMA */22+#include <linux/topology.h>33+#include <linux/module.h>44+#include <linux/bootmem.h>55+66+#ifdef CONFIG_DEBUG_PER_CPU_MAPS77+# define DBG(x...) printk(KERN_DEBUG x)88+#else99+# define DBG(x...)1010+#endif1111+1212+/*1313+ * Which logical CPUs are on which nodes1414+ */1515+cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];1616+EXPORT_SYMBOL(node_to_cpumask_map);1717+1818+/*1919+ * Allocate node_to_cpumask_map based on number of available nodes2020+ * Requires node_possible_map to be valid.2121+ *2222+ * Note: node_to_cpumask() is not valid until after this is done.2323+ * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.)2424+ */2525+void __init setup_node_to_cpumask_map(void)2626+{2727+ unsigned int node, num = 0;2828+2929+ /* setup nr_node_ids if not done yet */3030+ if (nr_node_ids == MAX_NUMNODES) {3131+ for_each_node_mask(node, node_possible_map)3232+ num = node;3333+ nr_node_ids = num + 1;3434+ }3535+3636+ /* allocate the map */3737+ for (node = 0; node < nr_node_ids; node++)3838+ alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);3939+4040+ /* cpumask_of_node() will now work */4141+ pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids);4242+}4343+4444+#ifdef CONFIG_DEBUG_PER_CPU_MAPS4545+/*4646+ * Returns a pointer to the bitmask of CPUs on Node 'node'.4747+ */4848+const struct cpumask *cpumask_of_node(int node)4949+{5050+ if (node >= nr_node_ids) {5151+ printk(KERN_WARNING5252+ "cpumask_of_node(%d): node > nr_node_ids(%d)\n",5353+ node, nr_node_ids);5454+ dump_stack();5555+ return cpu_none_mask;5656+ }5757+ if (node_to_cpumask_map[node] == NULL) {5858+ printk(KERN_WARNING5959+ "cpumask_of_node(%d): no node_to_cpumask_map!\n",6060+ node);6161+ dump_stack();6262+ return cpu_online_mask;6363+ }6464+ return node_to_cpumask_map[node];6565+}6666+EXPORT_SYMBOL(cpumask_of_node);6767+#endif
+8-103
arch/x86/mm/numa_64.c
···2020#include <asm/acpi.h>2121#include <asm/k8.h>22222323-#ifdef CONFIG_DEBUG_PER_CPU_MAPS2424-# define DBG(x...) printk(KERN_DEBUG x)2525-#else2626-# define DBG(x...)2727-#endif2828-2923struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;3024EXPORT_SYMBOL(node_data);3125···4147 */4248DEFINE_EARLY_PER_CPU(int, x86_cpu_to_node_map, NUMA_NO_NODE);4349EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_node_map);4444-4545-/*4646- * Which logical CPUs are on which nodes4747- */4848-cpumask_t *node_to_cpumask_map;4949-EXPORT_SYMBOL(node_to_cpumask_map);50505151/*5252 * Given a shift value, try to populate memnodemap[]···649661#endif650662651663652652-/*653653- * Allocate node_to_cpumask_map based on number of available nodes654654- * Requires node_possible_map to be valid.655655- *656656- * Note: node_to_cpumask() is not valid until after this is done.657657- * (Use CONFIG_DEBUG_PER_CPU_MAPS to check this.)658658- */659659-void __init setup_node_to_cpumask_map(void)660660-{661661- unsigned int node, num = 0;662662- cpumask_t *map;663663-664664- /* setup nr_node_ids if not done yet */665665- if (nr_node_ids == MAX_NUMNODES) {666666- for_each_node_mask(node, node_possible_map)667667- num = node;668668- nr_node_ids = num + 1;669669- }670670-671671- /* allocate the map */672672- map = alloc_bootmem_low(nr_node_ids * sizeof(cpumask_t));673673- DBG("node_to_cpumask_map at %p for %d nodes\n", map, nr_node_ids);674674-675675- pr_debug("Node to cpumask map at %p for %d nodes\n",676676- map, nr_node_ids);677677-678678- /* node_to_cpumask() will now work */679679- node_to_cpumask_map = map;680680-}681681-682664void __cpuinit numa_set_node(int cpu, int node)683665{684666 int *cpu_to_node_map = early_per_cpu_ptr(x86_cpu_to_node_map);···681723682724void __cpuinit numa_add_cpu(int cpu)683725{684684- cpu_set(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]);726726+ cpumask_set_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]);685727}686728687729void __cpuinit numa_remove_cpu(int cpu)688730{689689- cpu_clear(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]);731731+ cpumask_clear_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]);690732}691733692734#else /* CONFIG_DEBUG_PER_CPU_MAPS */···697739static void __cpuinit numa_set_cpumask(int cpu, int enable)698740{699741 int node = early_cpu_to_node(cpu);700700- cpumask_t *mask;742742+ struct cpumask *mask;701743 char buf[64];702744703703- if (node_to_cpumask_map == NULL) {704704- printk(KERN_ERR "node_to_cpumask_map NULL\n");745745+ mask = node_to_cpumask_map[node];746746+ if (mask == NULL) {747747+ printk(KERN_ERR "node_to_cpumask_map[%i] NULL\n", node);705748 dump_stack();706749 return;707750 }708751709709- mask = &node_to_cpumask_map[node];710752 if (enable)711711- cpu_set(cpu, *mask);753753+ cpumask_set_cpu(cpu, mask);712754 else713713- cpu_clear(cpu, *mask);755755+ cpumask_clear_cpu(cpu, mask);714756715757 cpulist_scnprintf(buf, sizeof(buf), mask);716758 printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n",···756798 }757799 return per_cpu(x86_cpu_to_node_map, cpu);758800}759759-760760-761761-/* empty cpumask */762762-static const cpumask_t cpu_mask_none;763763-764764-/*765765- * Returns a pointer to the bitmask of CPUs on Node 'node'.766766- */767767-const cpumask_t *cpumask_of_node(int node)768768-{769769- if (node_to_cpumask_map == NULL) {770770- printk(KERN_WARNING771771- "cpumask_of_node(%d): no node_to_cpumask_map!\n",772772- node);773773- dump_stack();774774- return (const cpumask_t *)&cpu_online_map;775775- }776776- if (node >= nr_node_ids) {777777- printk(KERN_WARNING778778- "cpumask_of_node(%d): node > nr_node_ids(%d)\n",779779- node, nr_node_ids);780780- dump_stack();781781- return &cpu_mask_none;782782- }783783- return &node_to_cpumask_map[node];784784-}785785-EXPORT_SYMBOL(cpumask_of_node);786786-787787-/*788788- * Returns a bitmask of CPUs on Node 'node'.789789- *790790- * Side note: this function creates the returned cpumask on the stack791791- * so with a high NR_CPUS count, excessive stack space is used. The792792- * node_to_cpumask_ptr function should be used whenever possible.793793- */794794-cpumask_t node_to_cpumask(int node)795795-{796796- if (node_to_cpumask_map == NULL) {797797- printk(KERN_WARNING798798- "node_to_cpumask(%d): no node_to_cpumask_map!\n", node);799799- dump_stack();800800- return cpu_online_map;801801- }802802- if (node >= nr_node_ids) {803803- printk(KERN_WARNING804804- "node_to_cpumask(%d): node > nr_node_ids(%d)\n",805805- node, nr_node_ids);806806- dump_stack();807807- return cpu_mask_none;808808- }809809- return node_to_cpumask_map[node];810810-}811811-EXPORT_SYMBOL(node_to_cpumask);812801813802/*814803 * --------- end of debug versions of the numa functions ---------
+1-1
arch/x86/oprofile/op_model_p4.c
···380380{381381#ifdef CONFIG_SMP382382 int cpu = smp_processor_id();383383- return (cpu != first_cpu(per_cpu(cpu_sibling_map, cpu)));383383+ return cpu != cpumask_first(__get_cpu_var(cpu_sibling_map));384384#endif385385 return 0;386386}
+3-3
arch/x86/xen/smp.c
···158158 rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);159159 if (rc >= 0) {160160 num_processors++;161161- cpu_set(i, cpu_possible_map);161161+ set_cpu_possible(i, true);162162 }163163 }164164}···197197 while ((num_possible_cpus() > 1) && (num_possible_cpus() > max_cpus)) {198198 for (cpu = nr_cpu_ids - 1; !cpu_possible(cpu); cpu--)199199 continue;200200- cpu_clear(cpu, cpu_possible_map);200200+ set_cpu_possible(cpu, false);201201 }202202203203 for_each_possible_cpu (cpu) {···210210 if (IS_ERR(idle))211211 panic("failed fork for CPU %d", cpu);212212213213- cpu_set(cpu, cpu_present_map);213213+ set_cpu_present(cpu, true);214214 }215215}216216
···154154{155155 int err;156156157157+ if (!alloc_cpumask_var(&marked_cpus, GFP_KERNEL))158158+ return -ENOMEM;159159+ cpumask_clear(marked_cpus);160160+157161 start_cpu_work();158162159163 err = task_handoff_register(&task_free_nb);···183179 task_handoff_unregister(&task_free_nb);184180out1:185181 end_sync();182182+ free_cpumask_var(marked_cpus);186183 goto out;187184}188185···195190 profile_event_unregister(PROFILE_TASK_EXIT, &task_exit_nb);196191 task_handoff_unregister(&task_free_nb);197192 end_sync();193193+ free_cpumask_var(marked_cpus);198194}199195200196···569563 mark_done(cpu);570564571565 mutex_unlock(&buffer_mutex);572572-}573573-574574-int __init buffer_sync_init(void)575575-{576576- if (!alloc_cpumask_var(&marked_cpus, GFP_KERNEL))577577- return -ENOMEM;578578-579579- cpumask_clear(marked_cpus);580580- return 0;581581-}582582-583583-void buffer_sync_cleanup(void)584584-{585585- free_cpumask_var(marked_cpus);586566}587567588568/* The function can be used to add a buffer worth of data directly to
-4
drivers/oprofile/buffer_sync.h
···1919/* sync the given CPU's buffer */2020void sync_buffer(int cpu);21212222-/* initialize/destroy the buffer system. */2323-int buffer_sync_init(void);2424-void buffer_sync_cleanup(void);2525-2622#endif /* OPROFILE_BUFFER_SYNC_H */
···764764extern char numa_zonelist_order[];765765#define NUMA_ZONELIST_ORDER_LEN 16 /* string buffer size */766766767767-#include <linux/topology.h>768768-/* Returns the number of the current Node. */769769-#ifndef numa_node_id770770-#define numa_node_id() (cpu_to_node(raw_smp_processor_id()))771771-#endif772772-773767#ifndef CONFIG_NEED_MULTIPLE_NODES774768775769extern struct pglist_data contig_page_data;
+6-5
include/linux/topology.h
···3838#endif39394040#ifndef nr_cpus_node4141-#define nr_cpus_node(node) \4242- ({ \4343- node_to_cpumask_ptr(__tmp__, node); \4444- cpus_weight(*__tmp__); \4545- })4141+#define nr_cpus_node(node) cpumask_weight(cpumask_of_node(node))4642#endif47434844#define for_each_node_with_cpus(node) \···194198#endif195199#ifndef topology_core_cpumask196200#define topology_core_cpumask(cpu) cpumask_of(cpu)201201+#endif202202+203203+/* Returns the number of the current Node. */204204+#ifndef numa_node_id205205+#define numa_node_id() (cpu_to_node(raw_smp_processor_id()))197206#endif198207199208#endif /* _LINUX_TOPOLOGY_H */
+22-21
kernel/sched.c
···38183818 */38193819#define MAX_PINNED_INTERVAL 5123820382038213821+/* Working cpumask for load_balance and load_balance_newidle. */38223822+static DEFINE_PER_CPU(cpumask_var_t, load_balance_tmpmask);38233823+38213824/*38223825 * Check this_cpu to ensure it is balanced within domain. Attempt to move38233826 * tasks if there is an imbalance.38243827 */38253828static int load_balance(int this_cpu, struct rq *this_rq,38263829 struct sched_domain *sd, enum cpu_idle_type idle,38273827- int *balance, struct cpumask *cpus)38303830+ int *balance)38283831{38293832 int ld_moved, all_pinned = 0, active_balance = 0, sd_idle = 0;38303833 struct sched_group *group;38313834 unsigned long imbalance;38323835 struct rq *busiest;38333836 unsigned long flags;38373837+ struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask);3834383838353839 cpumask_setall(cpus);38363840···39893985 * this_rq is locked.39903986 */39913987static int39923992-load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd,39933993- struct cpumask *cpus)39883988+load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd)39943989{39953990 struct sched_group *group;39963991 struct rq *busiest = NULL;···39973994 int ld_moved = 0;39983995 int sd_idle = 0;39993996 int all_pinned = 0;39973997+ struct cpumask *cpus = __get_cpu_var(load_balance_tmpmask);4000399840013999 cpumask_setall(cpus);40024000···41384134 struct sched_domain *sd;41394135 int pulled_task = 0;41404136 unsigned long next_balance = jiffies + HZ;41414141- cpumask_var_t tmpmask;41424142-41434143- if (!alloc_cpumask_var(&tmpmask, GFP_ATOMIC))41444144- return;4145413741464138 for_each_domain(this_cpu, sd) {41474139 unsigned long interval;···41484148 if (sd->flags & SD_BALANCE_NEWIDLE)41494149 /* If we've pulled tasks over stop searching: */41504150 pulled_task = load_balance_newidle(this_cpu, this_rq,41514151- sd, tmpmask);41514151+ sd);4152415241534153 interval = msecs_to_jiffies(sd->balance_interval);41544154 if (time_after(next_balance, sd->last_balance + interval))···41634163 */41644164 this_rq->next_balance = next_balance;41654165 }41664166- free_cpumask_var(tmpmask);41674166}4168416741694168/*···43124313 unsigned long next_balance = jiffies + 60*HZ;43134314 int update_next_balance = 0;43144315 int need_serialize;43154315- cpumask_var_t tmp;43164316-43174317- /* Fails alloc? Rebalancing probably not a priority right now. */43184318- if (!alloc_cpumask_var(&tmp, GFP_ATOMIC))43194319- return;4320431643214317 for_each_domain(cpu, sd) {43224318 if (!(sd->flags & SD_LOAD_BALANCE))···43364342 }4337434343384344 if (time_after_eq(jiffies, sd->last_balance + interval)) {43394339- if (load_balance(cpu, rq, sd, idle, &balance, tmp)) {43454345+ if (load_balance(cpu, rq, sd, idle, &balance)) {43404346 /*43414347 * We've pulled tasks over so either we're no43424348 * longer idle, or one of our SMT siblings is···43704376 */43714377 if (likely(update_next_balance))43724378 rq->next_balance = next_balance;43734373-43744374- free_cpumask_var(tmp);43754379}4376438043774381/*···77057713{77067714 int group;7707771577087708- cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map);77167716+ cpumask_and(mask, topology_thread_cpumask(cpu), cpu_map);77097717 group = cpumask_first(mask);77107718 if (sg)77117719 *sg = &per_cpu(sched_group_core, group).sg;···77347742 cpumask_and(mask, cpu_coregroup_mask(cpu), cpu_map);77357743 group = cpumask_first(mask);77367744#elif defined(CONFIG_SCHED_SMT)77377737- cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map);77457745+ cpumask_and(mask, topology_thread_cpumask(cpu), cpu_map);77387746 group = cpumask_first(mask);77397747#else77407748 group = cpu;···80778085 SD_INIT(sd, SIBLING);80788086 set_domain_attribute(sd, attr);80798087 cpumask_and(sched_domain_span(sd),80808080- &per_cpu(cpu_sibling_map, i), cpu_map);80888088+ topology_thread_cpumask(i), cpu_map);80818089 sd->parent = p;80828090 p->child = sd;80838091 cpu_to_cpu_group(i, cpu_map, &sd->groups, tmpmask);···80888096 /* Set up CPU (sibling) groups */80898097 for_each_cpu(i, cpu_map) {80908098 cpumask_and(this_sibling_map,80918091- &per_cpu(cpu_sibling_map, i), cpu_map);80998099+ topology_thread_cpumask(i), cpu_map);80928100 if (i != cpumask_first(this_sibling_map))80938101 continue;80948102···87648772#ifdef CONFIG_USER_SCHED87658773 alloc_size *= 2;87668774#endif87758775+#ifdef CONFIG_CPUMASK_OFFSTACK87768776+ alloc_size += num_possible_cpus() * cpumask_size();87778777+#endif87678778 /*87688779 * As sched_init() is called before page_alloc is setup,87698780 * we use alloc_bootmem().···88048809 ptr += nr_cpu_ids * sizeof(void **);88058810#endif /* CONFIG_USER_SCHED */88068811#endif /* CONFIG_RT_GROUP_SCHED */88128812+#ifdef CONFIG_CPUMASK_OFFSTACK88138813+ for_each_possible_cpu(i) {88148814+ per_cpu(load_balance_tmpmask, i) = (void *)ptr;88158815+ ptr += cpumask_size();88168816+ }88178817+#endif /* CONFIG_CPUMASK_OFFSTACK */88078818 }8808881988098820#ifdef CONFIG_SMP
+3-3
mm/page_alloc.c
···21392139 int n, val;21402140 int min_val = INT_MAX;21412141 int best_node = -1;21422142- node_to_cpumask_ptr(tmp, 0);21422142+ const struct cpumask *tmp = cpumask_of_node(0);2143214321442144 /* Use the local node if we haven't already */21452145 if (!node_isset(node, *used_node_mask)) {···21602160 val += (n < node);2161216121622162 /* Give preference to headless and unused nodes */21632163- node_to_cpumask_ptr_next(tmp, n);21642164- if (!cpus_empty(*tmp))21632163+ tmp = cpumask_of_node(n);21642164+ if (!cpumask_empty(tmp))21652165 val += PENALTY_FOR_NODE_WITH_CPUS;2166216621672167 /* Slight preference for less loaded node */
+1-1
mm/quicklist.c
···2929 int node = numa_node_id();3030 struct zone *zones = NODE_DATA(node)->node_zones;3131 int num_cpus_on_node;3232- node_to_cpumask_ptr(cpumask_on_node, node);3232+ const struct cpumask *cpumask_on_node = cpumask_of_node(node);33333434 node_free_pages =3535#ifdef CONFIG_ZONE_DMA