cpumask: consolidate and apply x86 cpumask changes
Subsystems (3)
cover cpumask: consolidate and apply x86 cpumask changes
Here's a consolidation of the x86-only patches. It needs to be applied to tip/cpus4096 at:
8299608... Merge branches 'irq/sparseirq', ... into cpus4096
... with the following tree merged in:
git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-ingo.git master
This should put the HEAD at v2.6.28-rc6-944-g968ea6d .
Note that the kernel tree will not be buildable at this point. There's a combination of old and new API patches being applied. After applying the first patch below, it will again be buildable (and bootable).
The following patches are included:
1 x86 smp: modify send_IPI_mask interface to accept cpumask_t pointers 2 x86: enable MAXSMP 3 x86: move and enhance debug printk for nr_cpu_ids etc. 4 x86: Add cpu_mask_to_apicid_and 5 x86: update add-cpu_mask_to_apicid_and to use struct cpumask* 6 x86: Update io_apic.c to use new cpumask API 7 xen: convert to cpumask_var_t and new cpumask primitives. 8 x86: fixup_irqs() doesn't need an argument. 9 x86: cosmetic changes apic-related files. 10 x86: Set CONFIG_NR_CPUS even on UP 11 x86: prepare for cpumask iterators to only go to nr_cpu_ids 12 x86: Use cpumask accessors code for possible/present maps. 13 x86: Remove cpumask games in x86/kernel/cpu/intel_cacheinfo.c 14 x86: use work_on_cpu in x86/kernel/cpu/mcheck/mce_amd_64.c 15 x86: xen: use smp_call_function_many() 16 x86: Introduce topology_core_cpumask()/topology_thread_cpumask()
Other patches not here were mostly small fixups that were folded into the original patch, or a consoldition of patches (#6 above).
PATCH 1/16 x86 smp: modify send_IPI_mask interface to accept cpumask_t pointers
Impact: cleanup, change parameter passing
* Change genapic interfaces to accept cpumask_t pointers where possible.
* Modify external callers to use cpumask_t pointers in function calls.
* Create new send_IPI_mask_allbutself which is the same as the send_IPI_mask functions but removes smp_processor_id() from list. This removes another common need for a temporary cpumask_t variable.
* Functions that used a temp cpumask_t variable for:
cpumask_t allbutme = cpu_online_map;
cpu_clear(smp_processor_id(), allbutme);
if (!cpus_empty(allbutme))
...
become:
if (!cpus_equal(cpu_online_map, cpumask_of_cpu(cpu)))
... * Other minor code optimizations (like using cpus_clear instead of CPU_MASK_NONE, etc.)
Applies to linux-2.6.tip/master.
--- arch/x86/include/asm/bigsmp/apic.h | 14 +- arch/x86/include/asm/bigsmp/ipi.h | 9 - arch/x86/include/asm/es7000/apic.h | 38 +++---- arch/x86/include/asm/es7000/ipi.h | 9 - arch/x86/include/asm/genapic_32.h | 9 - arch/x86/include/asm/genapic_64.h | 11 +- arch/x86/include/asm/ipi.h | 21 +++ arch/x86/include/asm/mach-default/mach_apic.h | 17 +-- arch/x86/include/asm/mach-default/mach_ipi.h | 18 +-- arch/x86/include/asm/numaq/apic.h | 6 - arch/x86/include/asm/numaq/ipi.h | 9 - arch/x86/include/asm/smp.h | 6 - arch/x86/include/asm/summit/apic.h | 12 +- arch/x86/include/asm/summit/ipi.h | 9 - arch/x86/kernel/apic.c | 6 - arch/x86/kernel/crash.c | 5 arch/x86/kernel/genapic_flat_64.c | 76 +++++++++----- arch/x86/kernel/genx2apic_cluster.c | 60 +++++++---- arch/x86/kernel/genx2apic_phys.c | 55 +++++++--- arch/x86/kernel/genx2apic_uv_x.c | 43 ++++--- arch/x86/kernel/io_apic.c | 141 +++++++++++++------------- arch/x86/kernel/ipi.c | 26 +++- arch/x86/kernel/smp.c | 8 - arch/x86/kernel/tlb_32.c | 2 arch/x86/kernel/tlb_64.c | 2 arch/x86/mach-generic/bigsmp.c | 5 arch/x86/mach-generic/es7000.c | 5 arch/x86/mach-generic/numaq.c | 5 arch/x86/mach-generic/summit.c | 5 arch/x86/xen/smp.c | 17 +-- 30 files changed, 378 insertions(+), 271 deletions(-)
arch/x86/include/asm/bigsmp/apic.h +7 -7
@@ -9,12 +9,12 @@ static inline int apic_id_registered(voireturn (1 ); } -static inline cpumask_t target_cpus (void ) +static inline const cpumask_t *target_cpus (void ) {#ifdef CONFIG_SMP -return cpu_online_map; +return &cpu_online_map;#else -return cpumask_of_cpu (0 ); +return &cpumask_of_cpu (0 );#endif }
@@ -79,7 +79,7 @@ static inline int apicid_to_node(int logstatic inline int cpu_present_to_apicid (int mps_cpu) { -if (mps_cpu <NR_CPUS ) +if (mps_cpu < nr_cpu_ids)return (int )per_cpu (x86_bios_cpu_apicid, mps_cpu);return BAD_APICID ;
@@ -94,7 +94,7 @@ extern u8 cpu_2_logical_apicid[];/* Mapping from cpu number to logical apicid */ static inline int cpu_to_logical_apicid (int cpu) { -if (cpu >=NR_CPUS ) +if (cpu >= nr_cpu_ids)return BAD_APICID ;return cpu_physical_id (cpu); }
@@ -119,12 +119,12 @@ static inline int check_phys_apicid_pres }/* As we are using single CPU as destination, pick only one CPU here */ -static inline unsigned int cpu_mask_to_apicid (cpumask_t cpumask) +static inline unsigned int cpu_mask_to_apicid (const cpumask_t *cpumask) {int cpu;int apicid; - cpu =first_cpu (cpumask); + cpu =first_cpu (*cpumask); apicid =cpu_to_logical_apicid (cpu);return apicid; }
arch/x86/include/asm/bigsmp/ipi.h +5 -4
@@ -1,9 +1,10 @@#ifndef __ASM_MACH_IPI_H#define __ASM_MACH_IPI_H -void send_IPI_mask_sequence (cpumask_t mask,int vector); +void send_IPI_mask_sequence (const cpumask_t *mask,int vector); +void send_IPI_mask_allbutself (const cpumask_t *mask,int vector); -static inline void send_IPI_mask (cpumask_t mask,int vector) +static inline void send_IPI_mask (const cpumask_t *mask,int vector) {send_IPI_mask_sequence (mask, vector); }
@@ -14,12 +15,12 @@ static inline void send_IPI_allbutself(icpu_clear (smp_processor_id (), mask);if (!cpus_empty (mask)) - send_IPI_mask(mask, vector); + send_IPI_mask(&mask, vector); }static inline void send_IPI_all (int vector) { -send_IPI_mask (cpu_online_map, vector); +send_IPI_mask (&cpu_online_map, vector); }#endif /* __ASM_MACH_IPI_H */
arch/x86/include/asm/es7000/apic.h +20 -18
@@ -9,14 +9,14 @@ static inline int apic_id_registered(voireturn (1 ); } -static inline cpumask_t target_cpus_cluster (void ) +static inline const cpumask_t *target_cpus_cluster (void ) { -return CPU_MASK_ALL ; +return &CPU_MASK_ALL ; } -static inline cpumask_t target_cpus (void ) +static inline const cpumask_t *target_cpus (void ) { -return cpumask_of_cpu (smp_processor_id ()); +return &cpumask_of_cpu (smp_processor_id ()); }#define APIC_DFR_VALUE_CLUSTER (APIC_DFR_CLUSTER)
@@ -80,9 +80,10 @@ extern int apic_version [MAX_APICS];static inline void setup_apic_routing (void ) {int apic =per_cpu (x86_bios_cpu_apicid,smp_processor_id ()); -printk ("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n" , +printk ("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n" , (apic_version[apic] ==0x14 ) ? -"Physical Cluster" :"Logical Cluster" , nr_ioapics,cpus_addr (target_cpus ())[0 ]); +"Physical Cluster" :"Logical Cluster" , + nr_ioapics,cpus_addr (*target_cpus ())[0 ]); }static inline int multi_timer_check (int apic,int irq)
@@ -100,7 +101,7 @@ static inline int cpu_present_to_apicid( {if (!mps_cpu)return boot_cpu_physical_apicid; -else if (mps_cpu <NR_CPUS ) +else if (mps_cpu < nr_cpu_ids)return (int )per_cpu (x86_bios_cpu_apicid, mps_cpu);else return BAD_APICID ;
@@ -120,9 +121,9 @@ extern u8 cpu_2_logical_apicid[];static inline int cpu_to_logical_apicid (int cpu) {#ifdef CONFIG_SMP -if (cpu >=NR_CPUS ) -return BAD_APICID ; -return (int )cpu_2_logical_apicid[cpu]; +if (cpu >= nr_cpu_ids) +return BAD_APICID ; +return (int )cpu_2_logical_apicid[cpu];#else return logical_smp_processor_id ();#endif
@@ -146,14 +147,15 @@ static inline int check_phys_apicid_presreturn (1 ); } -static inline unsigned int cpu_mask_to_apicid_cluster (cpumask_t cpumask) +static inline unsigned int +cpu_mask_to_apicid_cluster (const struct cpumask *cpumask) {int num_bits_set;int cpus_found =0 ;int cpu;int apicid; - num_bits_set =cpus_weight (cpumask); + num_bits_set =cpumask_weight (cpumask);/* Return id to all */ if (num_bits_set ==NR_CPUS )return 0xFF ;
@@ -161,10 +163,10 @@ static inline unsigned int cpu_mask_to_a* The cpus in the mask must all be on the apic cluster. If are not * on the same apicid cluster return default value of TARGET_CPUS. */ - cpu =first_cpu (cpumask); + cpu =cpumask_first (cpumask); apicid =cpu_to_logical_apicid (cpu);while (cpus_found < num_bits_set) { -if (cpu_isset (cpu, cpumask)) { +if (cpumask_test_cpu (cpu, cpumask)) {int new_apicid =cpu_to_logical_apicid (cpu);if (apicid_cluster (apicid) !=apicid_cluster (new_apicid)){
@@ -179,14 +181,14 @@ static inline unsigned int cpu_mask_to_areturn apicid; } -static inline unsigned int cpu_mask_to_apicid (cpumask_t cpumask) +static inline unsigned int cpu_mask_to_apicid (const cpumask_t *cpumask) {int num_bits_set;int cpus_found =0 ;int cpu;int apicid; - num_bits_set =cpus_weight (cpumask); + num_bits_set =cpus_weight (*cpumask);/* Return id to all */ if (num_bits_set ==NR_CPUS )return cpu_to_logical_apicid (0 );
@@ -194,10 +196,10 @@ static inline unsigned int cpu_mask_to_a* The cpus in the mask must all be on the apic cluster. If are not * on the same apicid cluster return default value of TARGET_CPUS. */ - cpu =first_cpu (cpumask); + cpu =first_cpu (*cpumask); apicid =cpu_to_logical_apicid (cpu);while (cpus_found < num_bits_set) { -if (cpu_isset (cpu, cpumask)) { +if (cpu_isset (cpu, *cpumask)) {int new_apicid =cpu_to_logical_apicid (cpu);if (apicid_cluster (apicid) !=apicid_cluster (new_apicid)){
arch/x86/include/asm/es7000/ipi.h +5 -4
@@ -1,9 +1,10 @@#ifndef __ASM_ES7000_IPI_H#define __ASM_ES7000_IPI_H -void send_IPI_mask_sequence (cpumask_t mask,int vector); +void send_IPI_mask_sequence (const cpumask_t *mask,int vector); +void send_IPI_mask_allbutself (const cpumask_t *mask,int vector); -static inline void send_IPI_mask (cpumask_t mask,int vector) +static inline void send_IPI_mask (const cpumask_t *mask,int vector) {send_IPI_mask_sequence (mask, vector); }
@@ -13,12 +14,12 @@ static inline void send_IPI_allbutself(icpumask_t mask = cpu_online_map;cpu_clear (smp_processor_id (), mask);if (!cpus_empty (mask)) - send_IPI_mask(mask, vector); + send_IPI_mask(&mask, vector); }static inline void send_IPI_all (int vector) { -send_IPI_mask (cpu_online_map, vector); +send_IPI_mask (&cpu_online_map, vector); }#endif /* __ASM_ES7000_IPI_H */
arch/x86/include/asm/genapic_32.h +5 -4
@@ -24,7 +24,7 @@ struct genapic {int (*probe)(void );int (*apic_id_registered)(void ); -cpumask_t (*target_cpus)(void); +const cpumask_t *(*target_cpus)(void );int int_delivery_mode;int int_dest_mode;int ESR_DISABLE ;
@@ -57,12 +57,13 @@ struct genapic {unsigned (*get_apic_id)(unsigned long x);unsigned long apic_id_mask; -unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask); -cpumask_t (*vector_allocation_domain)(int cpu); +unsigned int (*cpu_mask_to_apicid)(const cpumask_t *cpumask); +void (*vector_allocation_domain)(int cpu,cpumask_t *retmask);#ifdef CONFIG_SMP /* ipi */ -void (*send_IPI_mask)(cpumask_t mask,int vector); +void (*send_IPI_mask)(const cpumask_t *mask,int vector); +void (*send_IPI_mask_allbutself)(const cpumask_t *mask,int vector);void (*send_IPI_allbutself)(int vector);void (*send_IPI_all)(int vector);#endif
arch/x86/include/asm/genapic_64.h +7 -4
@@ -1,6 +1,8 @@#ifndef _ASM_X86_GENAPIC_64_H#define _ASM_X86_GENAPIC_64_H +#include <linux/cpumask.h> +/* * Copyright 2004 James Cleverdon, IBM. * Subject to the GNU Public License, v.2
@@ -18,16 +20,17 @@ struct genapic {u32 int_delivery_mode;u32 int_dest_mode;int (*apic_id_registered)(void ); -cpumask_t (*target_cpus)(void); -cpumask_t (*vector_allocation_domain)(int cpu); +const cpumask_t *(*target_cpus)(void ); +void (*vector_allocation_domain)(int cpu,cpumask_t *retmask);void (*init_apic_ldr)(void );/* ipi */ -void (*send_IPI_mask)(cpumask_t mask,int vector); +void (*send_IPI_mask)(const cpumask_t *mask,int vector); +void (*send_IPI_mask_allbutself)(const cpumask_t *mask,int vector);void (*send_IPI_allbutself)(int vector);void (*send_IPI_all)(int vector);void (*send_IPI_self)(int vector);/* */ -unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask); +unsigned int (*cpu_mask_to_apicid)(const cpumask_t *cpumask);unsigned int (*phys_pkg_id)(int index_msb);unsigned int (*get_apic_id)(unsigned long x);unsigned long (*set_apic_id)(unsigned int id);
arch/x86/include/asm/ipi.h +19 -2
@@ -117,7 +117,7 @@ static inline void __send_IPI_dest_fieldnative_apic_mem_write (APIC_ICR , cfg); } -static inline void send_IPI_mask_sequence (cpumask_t mask,int vector) +static inline void send_IPI_mask_sequence (const cpumask_t *mask,int vector) {unsigned long flags;unsigned long query_cpu;
@@ -128,11 +128,28 @@ static inline void send_IPI_mask_sequenc* - mbligh */ local_irq_save (flags); -for_each_cpu_mask_nr (query_cpu, mask) { +for_each_cpu_mask_nr (query_cpu, *mask) {__send_IPI_dest_field (per_cpu (x86_cpu_to_apicid, query_cpu), vector,APIC_DEST_PHYSICAL ); } local_irq_restore(flags); } +static inline void send_IPI_mask_allbutself (const cpumask_t *mask,int vector) +{ +unsigned long flags; +unsigned int query_cpu; +unsigned int this_cpu =smp_processor_id (); + +/* See Hack comment above */ + +local_irq_save (flags); +for_each_cpu_mask_nr (query_cpu, *mask) +if (query_cpu != this_cpu) +__send_IPI_dest_field ( +per_cpu (x86_cpu_to_apicid, query_cpu), + vector,APIC_DEST_PHYSICAL ); +local_irq_restore (flags); +} +#endif /* _ASM_X86_IPI_H */
arch/x86/include/asm/mach-default/mach_apic.h +8 -9
@@ -8,12 +8,12 @@#define APIC_DFR_VALUE (APIC_DFR_FLAT) -static inline cpumask_t target_cpus (void ) +static inline const cpumask_t *target_cpus (void ) {#ifdef CONFIG_SMP -return cpu_online_map; +return &cpu_online_map;#else -return cpumask_of_cpu (0 ); +return &cpumask_of_cpu (0 );#endif }
@@ -61,9 +61,9 @@ static inline int apic_id_registered(voireturn physid_isset (read_apic_id (), phys_cpu_present_map); } -static inline unsigned int cpu_mask_to_apicid (cpumask_t cpumask) +static inline unsigned int cpu_mask_to_apicid (const cpumask_t *cpumask) { -return cpus_addr (cpumask)[0 ]; +return cpus_addr (*cpumask)[0 ]; }static inline u32 phys_pkg_id (u32 cpuid_apic,int index_msb)
@@ -88,7 +88,7 @@ static inline int apicid_to_node(int log#endif } -static inline cpumask_t vector_allocation_domain (int cpu) +static inline void vector_allocation_domain (int cpu,cpumask_t *retmask) {/* Careful. Some cpus do not strictly honor the set of cpus * specified in the interrupt destination when using lowest
@@ -98,8 +98,7 @@ static inline cpumask_t vector_allocatio* deliver interrupts to the wrong hyperthread when only one * hyperthread was specified in the interrupt desitination. */ -cpumask_t domain = { { [0 ] =APIC_ALL_CPUS , } }; - return domain; + *retmask = (cpumask_t) { { [0] = APIC_ALL_CPUS } }; }#endif
@@ -131,7 +130,7 @@ static inline int cpu_to_logical_apicid(static inline int cpu_present_to_apicid (int mps_cpu) { -if (mps_cpu <NR_CPUS &&cpu_present (mps_cpu)) +if (mps_cpu < nr_cpu_ids &&cpu_present (mps_cpu))return (int )per_cpu (x86_bios_cpu_apicid, mps_cpu);else return BAD_APICID ;
arch/x86/include/asm/mach-default/mach_ipi.h +9 -9
@@ -4,7 +4,8 @@/* Avoid include hell */ #define NMI_VECTOR 0x02 -void send_IPI_mask_bitmask (cpumask_t mask,int vector); +void send_IPI_mask_bitmask (const cpumask_t *mask,int vector); +void send_IPI_mask_allbutself (const cpumask_t *mask,int vector);void __send_IPI_shortcut (unsigned int shortcut,int vector);extern int no_broadcast;
@@ -12,28 +13,27 @@ extern int no_broadcast;#ifdef CONFIG_X86_64 #include <asm/genapic.h> #define send_IPI_mask (genapic->send_IPI_mask) +#define send_IPI_mask_allbutself (genapic->send_IPI_mask_allbutself)#else -static inline void send_IPI_mask (cpumask_t mask,int vector) +static inline void send_IPI_mask (const cpumask_t *mask,int vector) {send_IPI_mask_bitmask (mask, vector); } +void send_IPI_mask_allbutself (const cpumask_t *mask,int vector);#endif static inline void __local_send_IPI_allbutself (int vector) { -if (no_broadcast || vector ==NMI_VECTOR ) { -cpumask_t mask = cpu_online_map; - -cpu_clear (smp_processor_id (), mask); -send_IPI_mask (mask, vector); - }else +if (no_broadcast || vector ==NMI_VECTOR ) +send_IPI_mask_allbutself (&cpu_online_map, vector); +else __send_IPI_shortcut (APIC_DEST_ALLBUT , vector); }static inline void __local_send_IPI_all (int vector) {if (no_broadcast || vector ==NMI_VECTOR ) -send_IPI_mask (cpu_online_map, vector); +send_IPI_mask (&cpu_online_map, vector);else __send_IPI_shortcut (APIC_DEST_ALLINC , vector); }
arch/x86/include/asm/numaq/apic.h +3 -3
@@ -7,9 +7,9 @@#define APIC_DFR_VALUE (APIC_DFR_CLUSTER) -static inline cpumask_t target_cpus (void ) +static inline const cpumask_t *target_cpus (void ) { -return CPU_MASK_ALL ; +return &CPU_MASK_ALL ; }#define NO_BALANCE_IRQ (1)
@@ -122,7 +122,7 @@ static inline void enable_apic_mode(void* We use physical apicids here, not logical, so just return the default * physical broadcast to stop people from breaking us */ -static inline unsigned int cpu_mask_to_apicid (cpumask_t cpumask) +static inline unsigned int cpu_mask_to_apicid (const cpumask_t *cpumask) {return (int )0xF ; }
arch/x86/include/asm/numaq/ipi.h +5 -4
@@ -1,9 +1,10 @@#ifndef __ASM_NUMAQ_IPI_H#define __ASM_NUMAQ_IPI_H -void send_IPI_mask_sequence (cpumask_t ,int vector); +void send_IPI_mask_sequence (const cpumask_t *mask,int vector); +void send_IPI_mask_allbutself (const cpumask_t *mask,int vector); -static inline void send_IPI_mask (cpumask_t mask,int vector) +static inline void send_IPI_mask (const cpumask_t *mask,int vector) {send_IPI_mask_sequence (mask, vector); }
@@ -14,12 +15,12 @@ static inline void send_IPI_allbutself(icpu_clear (smp_processor_id (), mask);if (!cpus_empty (mask)) - send_IPI_mask(mask, vector); + send_IPI_mask(&mask, vector); }static inline void send_IPI_all (int vector) { -send_IPI_mask (cpu_online_map, vector); +send_IPI_mask (&cpu_online_map, vector); }#endif /* __ASM_NUMAQ_IPI_H */
arch/x86/include/asm/smp.h +3 -3
@@ -60,7 +60,7 @@ struct smp_ops {void (*cpu_die)(unsigned int cpu);void (*play_dead)(void ); -void (*send_call_func_ipi)(cpumask_t mask); +void (*send_call_func_ipi)(const cpumask_t *mask);void (*send_call_func_single_ipi)(int cpu); };
@@ -125,7 +125,7 @@ static inline void arch_send_call_functistatic inline void arch_send_call_function_ipi (cpumask_t mask) { - smp_ops.send_call_func_ipi (mask); + smp_ops.send_call_func_ipi (&mask); }void cpu_disable_common (void );
@@ -138,7 +138,7 @@ void native_cpu_die(unsigned int cpu);void native_play_dead (void );void play_dead_common (void ); -void native_send_call_func_ipi (cpumask_t mask); +void native_send_call_func_ipi (const cpumask_t *mask);void native_send_call_func_single_ipi (int cpu);extern void prefill_possible_map (void );
arch/x86/include/asm/summit/apic.h +6 -6
@@ -14,13 +14,13 @@#define APIC_DFR_VALUE (APIC_DFR_CLUSTER) -static inline cpumask_t target_cpus (void ) +static inline const cpumask_t *target_cpus (void ) {/* CPU_MASK_ALL (0xff) has undefined behaviour with * dest_LowestPrio mode logical clustered apic interrupt routing * Just start on cpu 0. IRQ balancing will spread load */ -return cpumask_of_cpu (0 ); +return &cpumask_of_cpu (0 ); }#define INT_DELIVERY_MODE (dest_LowestPrio)
@@ -137,14 +137,14 @@ static inline void enable_apic_mode(void { } -static inline unsigned int cpu_mask_to_apicid (cpumask_t cpumask) +static inline unsigned int cpu_mask_to_apicid (const cpumask_t *cpumask) {int num_bits_set;int cpus_found =0 ;int cpu;int apicid; - num_bits_set =cpus_weight (cpumask); + num_bits_set =cpus_weight (*cpumask);/* Return id to all */ if (num_bits_set ==NR_CPUS )return (int )0xFF ;
@@ -152,10 +152,10 @@ static inline unsigned int cpu_mask_to_a* The cpus in the mask must all be on the apic cluster. If are not * on the same apicid cluster return default value of TARGET_CPUS. */ - cpu =first_cpu (cpumask); + cpu =first_cpu (*cpumask); apicid =cpu_to_logical_apicid (cpu);while (cpus_found < num_bits_set) { -if (cpu_isset (cpu, cpumask)) { +if (cpu_isset (cpu, *cpumask)) {int new_apicid =cpu_to_logical_apicid (cpu);if (apicid_cluster (apicid) !=apicid_cluster (new_apicid)){
arch/x86/include/asm/summit/ipi.h +5 -4
@@ -1,9 +1,10 @@#ifndef __ASM_SUMMIT_IPI_H#define __ASM_SUMMIT_IPI_H -void send_IPI_mask_sequence (cpumask_t mask,int vector); +void send_IPI_mask_sequence (const cpumask_t *mask,int vector); +void send_IPI_mask_allbutself (const cpumask_t *mask,int vector); -static inline void send_IPI_mask (cpumask_t mask,int vector) +static inline void send_IPI_mask (const cpumask_t *mask,int vector) {send_IPI_mask_sequence (mask, vector); }
@@ -14,12 +15,12 @@ static inline void send_IPI_allbutself(icpu_clear (smp_processor_id (), mask);if (!cpus_empty (mask)) - send_IPI_mask(mask, vector); + send_IPI_mask(&mask, vector); }static inline void send_IPI_all (int vector) { -send_IPI_mask (cpu_online_map, vector); +send_IPI_mask (&cpu_online_map, vector); }#endif /* __ASM_SUMMIT_IPI_H */
arch/x86/kernel/apic.c +3 -3
@@ -141,7 +141,7 @@ static int lapic_next_event(unsigned lon struct clock_event_device *evt);static void lapic_timer_setup (enum clock_event_mode mode,struct clock_event_device *evt); -static void lapic_timer_broadcast (const struct cpumask *mask); +static void lapic_timer_broadcast (const cpumask_t *mask);static void apic_pm_activate (void );/*
@@ -453,10 +453,10 @@ static void lapic_timer_setup(enum clock/* * Local APIC timer broadcast function */ -static void lapic_timer_broadcast (const struct cpumask *mask) +static void lapic_timer_broadcast (const cpumask_t *mask) {#ifdef CONFIG_SMP -send_IPI_mask (*mask,LOCAL_TIMER_VECTOR ); +send_IPI_mask (mask,LOCAL_TIMER_VECTOR );#endif }
arch/x86/kernel/crash.c +1 -4
@@ -77,10 +77,7 @@ static int crash_nmi_callback(struct notstatic void smp_send_nmi_allbutself (void ) { -cpumask_t mask = cpu_online_map; -cpu_clear (safe_smp_processor_id (), mask); -if (!cpus_empty (mask)) -send_IPI_mask (mask,NMI_VECTOR ); +send_IPI_allbutself (NMI_VECTOR ); }static struct notifier_block crash_nmi_nb = {
arch/x86/kernel/genapic_flat_64.c +50 -26
169 lines not on this page · raw message
arch/x86/kernel/genx2apic_cluster.c +40 -20
112 lines not on this page · raw message
arch/x86/kernel/genx2apic_phys.c +38 -17
107 lines not on this page · raw message
arch/x86/kernel/genx2apic_uv_x.c +26 -17
90 lines not on this page · raw message
arch/x86/kernel/io_apic.c +71 -70
410 lines not on this page · raw message
arch/x86/kernel/ipi.c +19 -7
@@ -116,9 +116,9 @@ static inline void __send_IPI_dest_field/* * This is only used on smaller machines. */ -void send_IPI_mask_bitmask (cpumask_t cpumask,int vector) +void send_IPI_mask_bitmask (const cpumask_t *cpumask,int vector) { -unsigned long mask =cpus_addr (cpumask)[0 ]; +unsigned long mask =cpus_addr (*cpumask)[0 ];unsigned long flags;local_irq_save (flags);
@@ -127,7 +127,7 @@ void send_IPI_mask_bitmask(cpumask_t cpulocal_irq_restore (flags); } -void send_IPI_mask_sequence (cpumask_t mask,int vector) +void send_IPI_mask_sequence (const cpumask_t *mask,int vector) {unsigned long flags;unsigned int query_cpu;
@@ -139,12 +139,24 @@ void send_IPI_mask_sequence(cpumask_t ma*/ local_irq_save (flags); -for_each_possible_cpu (query_cpu) { -if (cpu_isset (query_cpu, mask)) { +for_each_cpu_mask_nr (query_cpu, *mask) +__send_IPI_dest_field (cpu_to_logical_apicid (query_cpu), vector); +local_irq_restore (flags); +} + +void send_IPI_mask_allbutself (const cpumask_t *mask,int vector) +{ +unsigned long flags; +unsigned int query_cpu; +unsigned int this_cpu =smp_processor_id (); + +/* See Hack comment above */ + +local_irq_save (flags); +for_each_cpu_mask_nr (query_cpu, *mask) +if (query_cpu != this_cpu)__send_IPI_dest_field (cpu_to_logical_apicid (query_cpu), vector); - } - }local_irq_restore (flags); }
arch/x86/kernel/smp.c +4 -4
@@ -118,22 +118,22 @@ static void native_smp_send_reschedule(iWARN_ON (1 );return ; } -send_IPI_mask (cpumask_of_cpu (cpu),RESCHEDULE_VECTOR ); +send_IPI_mask (&cpumask_of_cpu (cpu),RESCHEDULE_VECTOR ); }void native_send_call_func_single_ipi (int cpu) { -send_IPI_mask (cpumask_of_cpu (cpu),CALL_FUNCTION_SINGLE_VECTOR ); +send_IPI_mask (&cpumask_of_cpu (cpu),CALL_FUNCTION_SINGLE_VECTOR ); } -void native_send_call_func_ipi (cpumask_t mask) +void native_send_call_func_ipi (const cpumask_t *mask) {cpumask_t allbutself; allbutself = cpu_online_map;cpu_clear (smp_processor_id (), allbutself); -if (cpus_equal (mask, allbutself) && +if (cpus_equal (*mask, allbutself) &&cpus_equal (cpu_online_map, cpu_callout_map))send_IPI_allbutself (CALL_FUNCTION_VECTOR );else
arch/x86/kernel/tlb_32.c +1 -1
@@ -164,7 +164,7 @@ void native_flush_tlb_others(const cpuma* We have to send the IPI only to * CPUs affected. */ -send_IPI_mask (cpumask,INVALIDATE_TLB_VECTOR ); +send_IPI_mask (&cpumask,INVALIDATE_TLB_VECTOR );while (!cpus_empty (flush_cpumask))/* nothing. lockup detection does not belong here */
arch/x86/kernel/tlb_64.c +1 -1
@@ -191,7 +191,7 @@ void native_flush_tlb_others(const cpuma* We have to send the IPI only to * CPUs affected. */ -send_IPI_mask (cpumask,INVALIDATE_TLB_VECTOR_START + sender); +send_IPI_mask (&cpumask,INVALIDATE_TLB_VECTOR_START + sender);while (!cpus_empty (f->flush_cpumask))cpu_relax ();
arch/x86/mach-generic/bigsmp.c +3 -2
@@ -42,9 +42,10 @@ static const struct dmi_system_id bigsmp { } }; -static cpumask_t vector_allocation_domain (int cpu) +static void vector_allocation_domain (int cpu,cpumask_t *retmask) { -return cpumask_of_cpu (cpu); +cpus_clear (*retmask); +cpu_set (cpu, *retmask); }static int probe_bigsmp (void )
arch/x86/mach-generic/es7000.c +2 -3
@@ -87,7 +87,7 @@ static int __init acpi_madt_oem_check(ch }#endif -static cpumask_t vector_allocation_domain (int cpu) +static void vector_allocation_domain (int cpu,cpumask_t *retmask) {/* Careful. Some cpus do not strictly honor the set of cpus * specified in the interrupt destination when using lowest
@@ -97,8 +97,7 @@ static cpumask_t vector_allocation_domai* deliver interrupts to the wrong hyperthread when only one * hyperthread was specified in the interrupt desitination. */ -cpumask_t domain = { { [0 ] =APIC_ALL_CPUS , } }; -return domain; + *retmask = (cpumask_t ){ { [0 ] =APIC_ALL_CPUS , } }; } struct genapic __initdata_refok apic_es7000 = APIC_INIT("es7000", probe_es7000);
arch/x86/mach-generic/numaq.c +2 -3
@@ -38,7 +38,7 @@ static int acpi_madt_oem_check(char *oemreturn 0 ; } -static cpumask_t vector_allocation_domain (int cpu) +static void vector_allocation_domain (int cpu,cpumask_t *retmask) {/* Careful. Some cpus do not strictly honor the set of cpus * specified in the interrupt destination when using lowest
@@ -48,8 +48,7 @@ static cpumask_t vector_allocation_domai* deliver interrupts to the wrong hyperthread when only one * hyperthread was specified in the interrupt desitination. */ -cpumask_t domain = { { [0 ] =APIC_ALL_CPUS , } }; -return domain; + *retmask = (cpumask_t ){ { [0 ] =APIC_ALL_CPUS , } }; }struct genapic apic_numaq =APIC_INIT ("NUMAQ" , probe_numaq);
arch/x86/mach-generic/summit.c +2 -3
@@ -24,7 +24,7 @@ static int probe_summit(void)return 0 ; } -static cpumask_t vector_allocation_domain (int cpu) +static void vector_allocation_domain (int cpu,cpumask_t *retmask) {/* Careful. Some cpus do not strictly honor the set of cpus * specified in the interrupt destination when using lowest
@@ -34,8 +34,7 @@ static cpumask_t vector_allocation_domai* deliver interrupts to the wrong hyperthread when only one * hyperthread was specified in the interrupt desitination. */ -cpumask_t domain = { { [0 ] =APIC_ALL_CPUS , } }; -return domain; + *retmask = (cpumask_t ){ { [0 ] =APIC_ALL_CPUS , } }; }struct genapic apic_summit =APIC_INIT ("summit" , probe_summit);
arch/x86/xen/smp.c +8 -9
@@ -158,7 +158,7 @@ static void __init xen_fill_possible_map {int i, rc; -for (i =0 ; i <NR_CPUS ; i++) { +for (i =0 ; i < nr_cpu_ids; i++) { rc =HYPERVISOR_vcpu_op (VCPUOP_is_up, i,NULL );if (rc >=0 ) { num_processors++;
@@ -196,7 +196,7 @@ static void __init xen_smp_prepare_cpus(/* Restrict the possible_map according to max_cpus. */ while ((num_possible_cpus () >1 ) && (num_possible_cpus () > max_cpus)) { -for (cpu =NR_CPUS -1 ; !cpu_possible (cpu); cpu--) +for (cpu = nr_cpu_ids -1 ; !cpu_possible (cpu); cpu--)continue ;cpu_clear (cpu, cpu_possible_map); }
@@ -408,24 +408,22 @@ static void xen_smp_send_reschedule(intxen_send_IPI_one (cpu,XEN_RESCHEDULE_VECTOR ); } -static void xen_send_IPI_mask (cpumask_t mask,enum ipi_vector vector) +static void xen_send_IPI_mask (const cpumask_t *mask,enum ipi_vector vector) {unsigned cpu; -cpus_and (mask, mask, cpu_online_map); - -for_each_cpu_mask_nr (cpu, mask) +for_each_cpu_and (cpu, mask, &cpu_online_map)xen_send_IPI_one (cpu, vector); } -static void xen_smp_send_call_function_ipi (cpumask_t mask) +static void xen_smp_send_call_function_ipi (const cpumask_t *mask) {int cpu;xen_send_IPI_mask (mask,XEN_CALL_FUNCTION_VECTOR );/* Make sure other vcpus get a chance to run if they need to. */ -for_each_cpu_mask_nr (cpu, mask) { +for_each_cpu_mask_nr (cpu, *mask) {if (xen_vcpu_stolen (cpu)) {HYPERVISOR_sched_op (SCHEDOP_yield,0 );break ;
@@ -435,7 +433,8 @@ static void xen_smp_send_call_function_istatic void xen_smp_send_call_function_single_ipi (int cpu) { -xen_send_IPI_mask (cpumask_of_cpu (cpu),XEN_CALL_FUNCTION_SINGLE_VECTOR ); +xen_send_IPI_mask (&cpumask_of_cpu (cpu), +XEN_CALL_FUNCTION_SINGLE_VECTOR ); }static irqreturn_t xen_call_function_interrupt (int irq,void *dev_id)
PATCH 2/16 x86: enable MAXSMP
In reply to Mike TravisImpact: activates new off-stack cpumask code on MAXSMP (non-default) x86 configs
Set MAXSMP to enable CONFIG_CPUMASK_OFFSTACK which moves cpumask's off the stack (and in structs) when using cpumask_var_t.
--- arch/x86/Kconfig | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
arch/x86/Kconfig +4 -3
@@ -581,16 +581,17 @@ config IOMMU_HELPER config MAXSMP bool "Configure Maximum number of SMP Processors and NUMA Nodes" - depends on X86_64 && SMP && BROKEN + depends on X86_64 && SMP && DEBUG_KERNEL && EXPERIMENTAL + select CPUMASK_OFFSTACK default n help Configure maximum number of CPUS and NUMA Nodes for this architecture. If unsure, say N. config NR_CPUS - int "Maximum number of CPUs (2-512)" if !MAXSMP - range 2 512 depends on SMP + int "Maximum number of CPUs" if SMP && !MAXSMP + range 2 512 if SMP && !MAXSMP default "4096" if MAXSMP default "32" if X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000 default "8"
Signature · 3 lines
1.6.0 --
PATCH 3/16 x86: move and enhance debug printk for nr_cpu_ids etc.
In reply to Mike TravisImpact: cleanup, better debugging
This has proven useful in debugging, *before* we try to use for_each_possible_cpu(). It also now shows nr_cpumask_bits.
--- arch/x86/kernel/setup_percpu.c | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-)
arch/x86/kernel/setup_percpu.c +11 -6
@@ -152,6 +152,11 @@ void __init setup_per_cpu_areas(void) old_size =PERCPU_ENOUGH_ROOM ; align = max_t(unsigned long, PAGE_SIZE, align); size =roundup (old_size, align); + +printk (KERN_INFO +"NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%d nr_node_ids:%d\n" , +NR_CPUS , nr_cpumask_bits, nr_cpu_ids, nr_node_ids); +printk (KERN_INFO "PERCPU: Allocating %zd bytes of per cpu data\n" , size);
@@ -168,24 +173,24 @@ void __init setup_per_cpu_areas(void)"cpu %d has no node %d or node-local memory\n" , cpu, node);if (ptr) -printk (KERN_DEBUG "per cpu data for cpu%d at %016lx\n" , +printk (KERN_DEBUG +"per cpu data for cpu%d at %016lx\n" , cpu, __pa(ptr)); }else { ptr =__alloc_bootmem_node (NODE_DATA (node), size, align,__pa (MAX_DMA_ADDRESS ));if (ptr) -printk (KERN_DEBUG "per cpu data for cpu%d on node%d at %016lx\n" , - cpu, node,__pa (ptr)); +printk (KERN_DEBUG +"per cpu data for cpu%d on node%d " +"at %016lx\n" , + cpu, node,__pa (ptr)); }#endif per_cpu_offset (cpu) = ptr - __per_cpu_start;memcpy (ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); } -printk (KERN_DEBUG "NR_CPUS: %d, nr_cpu_ids: %d, nr_node_ids %d\n" , -NR_CPUS , nr_cpu_ids, nr_node_ids); -/* Setup percpu data maps */ setup_per_cpu_maps ();
Signature · 3 lines
1.6.0 --
PATCH 4/16 x86: Add cpu_mask_to_apicid_and
In reply to Mike TravisImpact: new API
Add a helper function that takes two cpumask's, and's them and then returns the apicid of the result. This removes a need in io_apic.c that uses a temporary cpumask to hold (mask & cfg->domain).
--- arch/x86/include/asm/bigsmp/apic.h | 16 ++++++++ arch/x86/include/asm/es7000/apic.h | 47 +++++++++++++++++++++++++ arch/x86/include/asm/genapic_32.h | 3 ++ arch/x86/include/asm/genapic_64.h | 2 + arch/x86/include/asm/mach-default/mach_apic.h | 10 +++++ arch/x86/include/asm/mach-generic/mach_apic.h | 1 + arch/x86/include/asm/numaq/apic.h | 6 +++ arch/x86/include/asm/summit/apic.h | 39 ++++++++++++++++++++ arch/x86/kernel/genapic_flat_64.c | 26 ++++++++++++++ arch/x86/kernel/genx2apic_cluster.c | 16 ++++++++ arch/x86/kernel/genx2apic_phys.c | 16 ++++++++ arch/x86/kernel/genx2apic_uv_x.c | 16 ++++++++ 12 files changed, 198 insertions(+), 0 deletions(-)
arch/x86/include/asm/bigsmp/apic.h +16 -0
@@ -129,6 +129,22 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)return apicid; } +static inline unsigned int cpu_mask_to_apicid_and (const cpumask_t *cpumask, +const cpumask_t *andmask) +{ +int cpu; + +/* +* We're using fixed IRQ delivery, can only return one phys APIC ID. +* May as well be the first. +*/ +while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) +if (cpu_isset (cpu, *andmask)) +return cpu_to_logical_apicid (cpu); + +return BAD_APICID ; +} +static inline u32 phys_pkg_id (u32 cpuid_apic,int index_msb) {return cpuid_apic >> index_msb;
arch/x86/include/asm/es7000/apic.h +47 -0
53 lines not on this page · raw message
arch/x86/include/asm/genapic_32.h +3 -0
@@ -58,6 +58,8 @@ struct genapic {unsigned (*get_apic_id)(unsigned long x);unsigned long apic_id_mask;unsigned int (*cpu_mask_to_apicid)(const cpumask_t *cpumask); +unsigned int (*cpu_mask_to_apicid_and)(const cpumask_t *cpumask, +const cpumask_t *andmask);void (*vector_allocation_domain)(int cpu,cpumask_t *retmask);#ifdef CONFIG_SMP
@@ -115,6 +117,7 @@ struct genapic {APICFUNC (get_apic_id) \ .apic_id_mask =APIC_ID_MASK , \ APICFUNC(cpu_mask_to_apicid) \ + APICFUNC(cpu_mask_to_apicid_and) \ APICFUNC(vector_allocation_domain) \ APICFUNC(acpi_madt_oem_check) \ IPIFUNC(send_IPI_mask) \
arch/x86/include/asm/genapic_64.h +2 -0
@@ -31,6 +31,8 @@ struct genapic {void (*send_IPI_self)(int vector);/* */ unsigned int (*cpu_mask_to_apicid)(const cpumask_t *cpumask); +unsigned int (*cpu_mask_to_apicid_and)(const cpumask_t *cpumask, +const cpumask_t *andmask);unsigned int (*phys_pkg_id)(int index_msb);unsigned int (*get_apic_id)(unsigned long x);unsigned long (*set_apic_id)(unsigned int id);
arch/x86/include/asm/mach-default/mach_apic.h +10 -0
@@ -28,6 +28,7 @@ static inline const cpumask_t *target_cpus(void)#define apic_id_registered (genapic->apic_id_registered)#define init_apic_ldr (genapic->init_apic_ldr)#define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid) +#define cpu_mask_to_apicid_and (genapic->cpu_mask_to_apicid_and)#define phys_pkg_id (genapic->phys_pkg_id)#define vector_allocation_domain (genapic->vector_allocation_domain)#define read_apic_id () (GET_APIC_ID(apic_read(APIC_ID)))
@@ -66,6 +67,15 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)return cpus_addr (*cpumask)[0 ]; } +static inline unsigned int cpu_mask_to_apicid (const cpumask_t *cpumask, +const cpumask_t *andmask) +{ +unsigned long mask1 =cpus_addr (*cpumask)[0 ]; +unsigned long mask2 =cpus_addr (*andmask)[0 ]; + +return (unsigned int )(mask1 & mask2); +} +static inline u32 phys_pkg_id (u32 cpuid_apic,int index_msb) {return cpuid_apic >> index_msb;
arch/x86/include/asm/mach-generic/mach_apic.h +1 -0
@@ -24,6 +24,7 @@#define check_phys_apicid_present (genapic->check_phys_apicid_present)#define check_apicid_used (genapic->check_apicid_used)#define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid) +#define cpu_mask_to_apicid_and (genapic->cpu_mask_to_apicid_and)#define vector_allocation_domain (genapic->vector_allocation_domain)#define enable_apic_mode (genapic->enable_apic_mode)#define phys_pkg_id (genapic->phys_pkg_id)
arch/x86/include/asm/numaq/apic.h +6 -0
@@ -127,6 +127,12 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)return (int )0xF ; } +static inline unsigned int cpu_mask_to_apicid_and (const cpumask_t *cpumask, +const cpumask_t *andmask) +{ +return (int )0xF ; +} +/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */ static inline u32 phys_pkg_id (u32 cpuid_apic,int index_msb) {
arch/x86/include/asm/summit/apic.h +39 -0
@@ -170,6 +170,45 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)return apicid; } +static inline unsigned int cpu_mask_to_apicid_and (const cpumask_t *cpumask, +const cpumask_t *andmask) +{ +int num_bits_set; +int num_bits_set2; +int cpus_found =0 ; +int cpu; +int apicid =0 ; + + num_bits_set =cpus_weight (*cpumask); + num_bits_set2 =cpus_weight (*andmask); + num_bits_set =min_t (int, num_bits_set, num_bits_set2); +/* Return id to all */ +if (num_bits_set >= nr_cpu_ids) +return 0xFF ; +/* +* The cpus in the mask must all be on the apic cluster. If are not +* on the same apicid cluster return default value of TARGET_CPUS. +*/ +while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) + if (cpu_isset(cpu, *andmask) + apicid =cpu_to_logical_apicid (cpu); +while (cpus_found < num_bits_set) { +if (cpu_isset (cpu, *cpumask) &&cpu_isset (cpu, *andmask)) { +int new_apicid =cpu_to_logical_apicid (cpu); +if (apicid_cluster (apicid) != +apicid_cluster (new_apicid)) { +printk (KERN_WARNING +"%s: Not a valid mask!\n" , __func__); +return 0xFF ; + } + apicid = apicid | new_apicid; + cpus_found++; + } + cpu++; + } +return apicid; +} +/* cpuid returns the value latched in the HW at reset, not the APIC ID * register's value. For any box whose BIOS changes APIC IDs, like * clustered APIC systems, we must use hard_smp_processor_id.
arch/x86/kernel/genapic_flat_64.c +26 -0
@@ -158,6 +158,15 @@ static unsigned int flat_cpu_mask_to_apicid(const cpumask_t *cpumask)return cpus_addr (*cpumask)[0 ] &APIC_ALL_CPUS ; } +static unsigned int flat_cpu_mask_to_apicid_and (const cpumask_t *cpumask, +const cpumask_t *andmask) +{ +unsigned long mask1 =cpus_addr (*cpumask)[0 ] &APIC_ALL_CPUS ; +unsigned long mask2 =cpus_addr (*andmask)[0 ] &APIC_ALL_CPUS ; + +return (int )(mask1 & mask2); +} +static unsigned int phys_pkg_id (int index_msb) {return hard_smp_processor_id () >> index_msb;
@@ -178,6 +187,7 @@ struct genapic apic_flat = { .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself, .send_IPI_self = apic_send_IPI_self, .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, + .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, .phys_pkg_id = phys_pkg_id, .get_apic_id = get_apic_id, .set_apic_id = set_apic_id,
@@ -254,6 +264,21 @@ static unsigned int physflat_cpu_mask_to_apicid(const cpumask_t *cpumask)return BAD_APICID ; } +static unsigned int physflat_cpu_mask_to_apicid_and (const cpumask_t *cpumask, +const cpumask_t *andmask) +{ +int cpu; + +/* +* We're using fixed IRQ delivery, can only return one phys APIC ID. +* May as well be the first. +*/ +while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) +if (cpu_isset (cpu, *andmask)) +return per_cpu (x86_cpu_to_apicid, cpu); +return BAD_APICID ; +} +struct genapic apic_physflat = { .name ="physical flat" , .acpi_madt_oem_check = physflat_acpi_madt_oem_check,
@@ -269,6 +294,7 @@ struct genapic apic_physflat = { .send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself, .send_IPI_self = apic_send_IPI_self, .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, + .cpu_mask_to_apicid_and = physflat_cpu_mask_to_apicid_and, .phys_pkg_id = phys_pkg_id, .get_apic_id = get_apic_id, .set_apic_id = set_apic_id,
arch/x86/kernel/genx2apic_cluster.c +16 -0
@@ -123,6 +123,21 @@ static unsigned int x2apic_cpu_mask_to_apicid(const cpumask_t *cpumask)return BAD_APICID ; } +static unsigned int x2apic_cpu_mask_to_apicid_and (const cpumask_t *cpumask, +const cpumask_t *andmask) +{ +int cpu; + +/* +* We're using fixed IRQ delivery, can only return one phys APIC ID. +* May as well be the first. +*/ +while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) +if (cpu_isset (cpu, *andmask)) +return per_cpu (x86_cpu_to_apicid, cpu); +return BAD_APICID ; +} +static unsigned int get_apic_id (unsigned long x) {unsigned int id;
@@ -172,6 +187,7 @@ struct genapic apic_x2apic_cluster = { .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself, .send_IPI_self = x2apic_send_IPI_self, .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, + .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and, .phys_pkg_id = phys_pkg_id, .get_apic_id = get_apic_id, .set_apic_id = set_apic_id,
arch/x86/kernel/genx2apic_phys.c +16 -0
@@ -122,6 +122,21 @@ static unsigned int x2apic_cpu_mask_to_apicid(const cpumask_t *cpumask)return BAD_APICID ; } +static unsigned int x2apic_cpu_mask_to_apicid_and (const cpumask_t *cpumask, +const cpumask_t *andmask) +{ +int cpu; + +/* +* We're using fixed IRQ delivery, can only return one phys APIC ID. +* May as well be the first. +*/ +while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) +if (cpu_isset (cpu, *andmask)) +return per_cpu (x86_cpu_to_apicid, cpu); +return BAD_APICID ; +} +static unsigned int get_apic_id (unsigned long x) {unsigned int id;
@@ -168,6 +183,7 @@ struct genapic apic_x2apic_phys = { .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself, .send_IPI_self = x2apic_send_IPI_self, .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, + .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and, .phys_pkg_id = phys_pkg_id, .get_apic_id = get_apic_id, .set_apic_id = set_apic_id,
arch/x86/kernel/genx2apic_uv_x.c +16 -0
@@ -179,6 +179,21 @@ static unsigned int uv_cpu_mask_to_apicid(const cpumask_t *cpumask)return BAD_APICID ; } +static unsigned int uv_cpu_mask_to_apicid_and (const cpumask_t *cpumask, +const cpumask_t *andmask) +{ +int cpu; + +/* +* We're using fixed IRQ delivery, can only return one phys APIC ID. +* May as well be the first. +*/ +while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) +if (cpu_isset (cpu, *andmask)) +return per_cpu (x86_cpu_to_apicid, cpu); +return BAD_APICID ; +} +static unsigned int get_apic_id (unsigned long x) {unsigned int id;
@@ -229,6 +244,7 @@ struct genapic apic_x2apic_uv_x = { .send_IPI_mask_allbutself = uv_send_IPI_mask_allbutself, .send_IPI_self = uv_send_IPI_self, .cpu_mask_to_apicid = uv_cpu_mask_to_apicid, + .cpu_mask_to_apicid_and = uv_cpu_mask_to_apicid_and, .phys_pkg_id = phys_pkg_id, .get_apic_id = get_apic_id, .set_apic_id = set_apic_id,
Signature · 3 lines
1.6.0 --
PATCH 5/16 x86: update add-cpu_mask_to_apicid_and to use struct cpumask*
In reply to Mike TravisImpact: use updated APIs
Various API updates for x86:add-cpu_mask_to_apicid_and
(Note: separate because previous patch has been "backported" to 2.6.27.)
--- arch/x86/include/asm/bigsmp/apic.h | 10 +++++----- arch/x86/include/asm/es7000/apic.h | 19 ++++++++++--------- arch/x86/include/asm/genapic_32.h | 4 ++-- arch/x86/include/asm/genapic_64.h | 4 ++-- arch/x86/include/asm/mach-default/mach_apic.h | 8 ++++---- arch/x86/include/asm/numaq/apic.h | 4 ++-- arch/x86/include/asm/summit/apic.h | 18 +++++++++--------- arch/x86/kernel/genapic_flat_64.c | 21 +++++++++++---------- arch/x86/kernel/genx2apic_cluster.c | 10 +++++----- arch/x86/kernel/genx2apic_phys.c | 10 +++++----- arch/x86/kernel/genx2apic_uv_x.c | 10 +++++----- 11 files changed, 60 insertions(+), 58 deletions(-)
arch/x86/include/asm/bigsmp/apic.h +5 -5
@@ -129,8 +129,8 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)return apicid; } -static inline unsigned int cpu_mask_to_apicid_and (const cpumask_t *cpumask, -const cpumask_t *andmask) +static inline unsigned int cpu_mask_to_apicid_and (const struct cpumask *cpumask, +const struct cpumask *andmask) {int cpu;
@@ -138,9 +138,9 @@ static inline unsigned int cpu_mask_to_apicid_and(const cpumask_t *cpumask,* We're using fixed IRQ delivery, can only return one phys APIC ID. * May as well be the first. */ -while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) -if (cpu_isset (cpu, *andmask)) -return cpu_to_logical_apicid (cpu); + cpu =cpumask_any_and (cpumask, andmask); +if (cpu < nr_cpu_ids) +return cpu_to_logical_apicid (cpu);return BAD_APICID ; }
arch/x86/include/asm/es7000/apic.h +10 -9
@@ -213,8 +213,8 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)return apicid; } -static inline unsigned int cpu_mask_to_apicid_and (const cpumask_t *cpumask, -const cpumask_t *andmask) +static inline unsigned int cpu_mask_to_apicid_and (const struct cpumask *cpumask, +const struct cpumask *andmask) {int num_bits_set;int num_bits_set2;
@@ -222,9 +222,9 @@ static inline unsigned int cpu_mask_to_apicid_and(const cpumask_t *cpumask,int cpu;int apicid =0 ; - num_bits_set =cpus_weight (*cpumask); - num_bits_set2 =cpus_weight (*andmask); - num_bits_set =min_t (int, num_bits_set, num_bits_set2); + num_bits_set =cpumask_weight (cpumask); + num_bits_set2 =cpumask_weight (andmask); + num_bits_set =min (num_bits_set, num_bits_set2);/* Return id to all */ if (num_bits_set >= nr_cpu_ids)#if definedCONFIG_ES7000_CLUSTERED_APIC
@@ -236,11 +236,12 @@ static inline unsigned int cpu_mask_to_apicid_and(const cpumask_t *cpumask,* The cpus in the mask must all be on the apic cluster. If are not * on the same apicid cluster return default value of TARGET_CPUS. */ -while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) - if (cpu_isset(cpu, *andmask) - apicid =cpu_to_logical_apicid (cpu); + cpu =cpumask_first_and (cpumask, andmask); + apicid =cpu_to_logical_apicid (cpu); +while (cpus_found < num_bits_set) { -if (cpu_isset (cpu, *cpumask) &&cpu_isset (cpu, *andmask)) { +if (cpumask_test_cpu (cpu, cpumask) && +cpumask_test_cpu (cpu, andmask)) {int new_apicid =cpu_to_logical_apicid (cpu);if (apicid_cluster (apicid) !=apicid_cluster (new_apicid)) {
arch/x86/include/asm/genapic_32.h +2 -2
@@ -58,8 +58,8 @@ struct genapic {unsigned (*get_apic_id)(unsigned long x);unsigned long apic_id_mask;unsigned int (*cpu_mask_to_apicid)(const cpumask_t *cpumask); -unsigned int (*cpu_mask_to_apicid_and)(const cpumask_t *cpumask, -const cpumask_t *andmask); +unsigned int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask, +const struct cpumask *andmask);void (*vector_allocation_domain)(int cpu,cpumask_t *retmask);#ifdef CONFIG_SMP
arch/x86/include/asm/genapic_64.h +2 -2
@@ -31,8 +31,8 @@ struct genapic {void (*send_IPI_self)(int vector);/* */ unsigned int (*cpu_mask_to_apicid)(const cpumask_t *cpumask); -unsigned int (*cpu_mask_to_apicid_and)(const cpumask_t *cpumask, -const cpumask_t *andmask); +unsigned int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask, +const struct cpumask *andmask);unsigned int (*phys_pkg_id)(int index_msb);unsigned int (*get_apic_id)(unsigned long x);unsigned long (*set_apic_id)(unsigned int id);
arch/x86/include/asm/mach-default/mach_apic.h +4 -4
@@ -67,11 +67,11 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)return cpus_addr (*cpumask)[0 ]; } -static inline unsigned int cpu_mask_to_apicid (const cpumask_t *cpumask, -const cpumask_t *andmask) +static inline unsigned int cpu_mask_to_apicid_and (const struct cpumask *cpumask, +const struct cpumask *andmask) { -unsigned long mask1 =cpus_addr (*cpumask)[0 ]; -unsigned long mask2 =cpus_addr (*andmask)[0 ]; +unsigned long mask1 =cpumask_bits (cpumask)[0 ]; +unsigned long mask2 =cpumask_bits (andmask)[0 ];return (unsigned int )(mask1 & mask2); }
arch/x86/include/asm/numaq/apic.h +2 -2
@@ -127,8 +127,8 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)return (int )0xF ; } -static inline unsigned int cpu_mask_to_apicid_and (const cpumask_t *cpumask, -const cpumask_t *andmask) +static inline unsigned int cpu_mask_to_apicid_and (const struct cpumask *cpumask, +const struct cpumask *andmask) {return (int )0xF ; }
arch/x86/include/asm/summit/apic.h +9 -9
@@ -170,8 +170,8 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)return apicid; } -static inline unsigned int cpu_mask_to_apicid_and (const cpumask_t *cpumask, -const cpumask_t *andmask) +static inline unsigned int cpu_mask_to_apicid_and (const struct cpumask *cpumask, +const struct cpumask *andmask) {int num_bits_set;int num_bits_set2;
@@ -179,9 +179,9 @@ static inline unsigned int cpu_mask_to_apicid_and(const cpumask_t *cpumask,int cpu;int apicid =0 ; - num_bits_set =cpus_weight (*cpumask); - num_bits_set2 =cpus_weight (*andmask); - num_bits_set =min_t (int, num_bits_set, num_bits_set2); + num_bits_set =cpumask_weight (cpumask); + num_bits_set2 =cpumask_weight (andmask); + num_bits_set =min (num_bits_set, num_bits_set2);/* Return id to all */ if (num_bits_set >= nr_cpu_ids)return 0xFF ;
@@ -189,11 +189,11 @@ static inline unsigned int cpu_mask_to_apicid_and(const cpumask_t *cpumask,* The cpus in the mask must all be on the apic cluster. If are not * on the same apicid cluster return default value of TARGET_CPUS. */ -while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) - if (cpu_isset(cpu, *andmask) - apicid =cpu_to_logical_apicid (cpu); + cpu =cpumask_first_and (cpumask, andmask); + apicid =cpu_to_logical_apicid (cpu);while (cpus_found < num_bits_set) { -if (cpu_isset (cpu, *cpumask) &&cpu_isset (cpu, *andmask)) { +if (cpumask_test_cpu (cpu, cpumask) + &&cpumask_test_cpu (cpu, andmask)) {int new_apicid =cpu_to_logical_apicid (cpu);if (apicid_cluster (apicid) !=apicid_cluster (new_apicid)) {
arch/x86/kernel/genapic_flat_64.c +11 -10
@@ -158,13 +158,13 @@ static unsigned int flat_cpu_mask_to_apicid(const cpumask_t *cpumask)return cpus_addr (*cpumask)[0 ] &APIC_ALL_CPUS ; } -static unsigned int flat_cpu_mask_to_apicid_and (const cpumask_t *cpumask, -const cpumask_t *andmask) +static unsigned int flat_cpu_mask_to_apicid_and (const struct cpumask *cpumask, +const struct cpumask *andmask) { -unsigned long mask1 =cpus_addr (*cpumask)[0 ] &APIC_ALL_CPUS ; -unsigned long mask2 =cpus_addr (*andmask)[0 ] &APIC_ALL_CPUS ; +unsigned long mask1 =cpumask_bits (cpumask)[0 ] &APIC_ALL_CPUS ; +unsigned long mask2 =cpumask_bits (andmask)[0 ] &APIC_ALL_CPUS ; -return (int )(mask1 & mask2); +return mask1 & mask2; }static unsigned int phys_pkg_id (int index_msb)
@@ -264,8 +264,9 @@ static unsigned int physflat_cpu_mask_to_apicid(const cpumask_t *cpumask)return BAD_APICID ; } -static unsigned int physflat_cpu_mask_to_apicid_and (const cpumask_t *cpumask, -const cpumask_t *andmask) +static unsigned int +physflat_cpu_mask_to_apicid_and (const struct cpumask *cpumask, +const struct cpumask *andmask) {int cpu;
@@ -273,9 +274,9 @@ static unsigned int physflat_cpu_mask_to_apicid_and(const cpumask_t *cpumask,* We're using fixed IRQ delivery, can only return one phys APIC ID. * May as well be the first. */ -while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) -if (cpu_isset (cpu, *andmask)) -return per_cpu (x86_cpu_to_apicid, cpu); + cpu =cpumask_any_and (cpumask, andmask); +if (cpu < nr_cpu_ids) +return per_cpu (x86_cpu_to_apicid, cpu);return BAD_APICID ; }
arch/x86/kernel/genx2apic_cluster.c +5 -5
@@ -123,8 +123,8 @@ static unsigned int x2apic_cpu_mask_to_apicid(const cpumask_t *cpumask)return BAD_APICID ; } -static unsigned int x2apic_cpu_mask_to_apicid_and (const cpumask_t *cpumask, -const cpumask_t *andmask) +static unsigned int x2apic_cpu_mask_to_apicid_and (const struct cpumask *cpumask, +const struct cpumask *andmask) {int cpu;
@@ -132,9 +132,9 @@ static unsigned int x2apic_cpu_mask_to_apicid_and(const cpumask_t *cpumask,* We're using fixed IRQ delivery, can only return one phys APIC ID. * May as well be the first. */ -while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) -if (cpu_isset (cpu, *andmask)) -return per_cpu (x86_cpu_to_apicid, cpu); + cpu =cpumask_any_and (cpumask, andmask); +if (cpu < nr_cpu_ids) +return per_cpu (x86_cpu_to_apicid, cpu);return BAD_APICID ; }
arch/x86/kernel/genx2apic_phys.c +5 -5
@@ -122,8 +122,8 @@ static unsigned int x2apic_cpu_mask_to_apicid(const cpumask_t *cpumask)return BAD_APICID ; } -static unsigned int x2apic_cpu_mask_to_apicid_and (const cpumask_t *cpumask, -const cpumask_t *andmask) +static unsigned int x2apic_cpu_mask_to_apicid_and (const struct cpumask *cpumask, +const struct cpumask *andmask) {int cpu;
@@ -131,9 +131,9 @@ static unsigned int x2apic_cpu_mask_to_apicid_and(const cpumask_t *cpumask,* We're using fixed IRQ delivery, can only return one phys APIC ID. * May as well be the first. */ -while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) -if (cpu_isset (cpu, *andmask)) -return per_cpu (x86_cpu_to_apicid, cpu); + cpu =cpumask_any_and (cpumask, andmask); +if (cpu < nr_cpu_ids) +return per_cpu (x86_cpu_to_apicid, cpu);return BAD_APICID ; }
arch/x86/kernel/genx2apic_uv_x.c +5 -5
@@ -179,8 +179,8 @@ static unsigned int uv_cpu_mask_to_apicid(const cpumask_t *cpumask)return BAD_APICID ; } -static unsigned int uv_cpu_mask_to_apicid_and (const cpumask_t *cpumask, -const cpumask_t *andmask) +static unsigned int uv_cpu_mask_to_apicid_and (const struct cpumask *cpumask, +const struct cpumask *andmask) {int cpu;
@@ -188,9 +188,9 @@ static unsigned int uv_cpu_mask_to_apicid_and(const cpumask_t *cpumask,* We're using fixed IRQ delivery, can only return one phys APIC ID. * May as well be the first. */ -while ((cpu =next_cpu (-1 , *cpumask)) < nr_cpu_ids) -if (cpu_isset (cpu, *andmask)) -return per_cpu (x86_cpu_to_apicid, cpu); + cpu =cpumask_any_and (cpumask, andmask); +if (cpu < nr_cpu_ids) +return per_cpu (x86_cpu_to_apicid, cpu);return BAD_APICID ; }
Signature · 3 lines
1.6.0 --
PATCH 6/16 x86: Update io_apic.c to use new cpumask API
In reply to Mike TravisImpact: cleanup, consolidate patches, use new API
Consolidate the following into a single patch to adapt to new sparseirq code in arch/x86/kernel/io_apic.c, add allocation of cpumask_var_t's in domain and old_domain, and reduce further merge conflicts. Only one file (arch/x86/kernel/io_apic.c) is changed in all of these patches.
0006-x86-io_apic-change-irq_cfg-domain-old_domain-to.patch 0007-x86-io_apic-set_desc_affinity.patch 0008-x86-io_apic-send_cleanup_vector.patch 0009-x86-io_apic-eliminate-remaining-cpumask_ts-from-st.patch 0021-x86-final-cleanups-in-io_apic-to-use-new-cpumask-AP.patch
--- arch/x86/kernel/io_apic.c | 304 ++++++++++++++++++++++------------------------ 1 file changed, 146 insertions(+), 158 deletions(-)
arch/x86/kernel/io_apic.c +146 -158
@@ -136,8 +136,8 @@ static struct irq_pin_list *get_one_freestruct irq_cfg {struct irq_pin_list *irq_2_pin; -cpumask_t domain; -cpumask_t old_domain; +cpumask_var_t domain; +cpumask_var_t old_domain;unsigned move_cleanup_count;u8 vector;u8 move_in_progress :1 ;
@@ -149,22 +149,22 @@ static struct irq_cfg irq_cfgx[] = {#else static struct irq_cfg irq_cfgx[NR_IRQS ] = { #endif - [0 ] = { .domain =CPU_MASK_ALL , .vector =IRQ0_VECTOR , }, - [1 ] = { .domain =CPU_MASK_ALL , .vector =IRQ1_VECTOR , }, - [2 ] = { .domain =CPU_MASK_ALL , .vector =IRQ2_VECTOR , }, - [3 ] = { .domain =CPU_MASK_ALL , .vector =IRQ3_VECTOR , }, - [4 ] = { .domain =CPU_MASK_ALL , .vector =IRQ4_VECTOR , }, - [5 ] = { .domain =CPU_MASK_ALL , .vector =IRQ5_VECTOR , }, - [6 ] = { .domain =CPU_MASK_ALL , .vector =IRQ6_VECTOR , }, - [7 ] = { .domain =CPU_MASK_ALL , .vector =IRQ7_VECTOR , }, - [8 ] = { .domain =CPU_MASK_ALL , .vector =IRQ8_VECTOR , }, - [9 ] = { .domain =CPU_MASK_ALL , .vector =IRQ9_VECTOR , }, - [10 ] = { .domain =CPU_MASK_ALL , .vector =IRQ10_VECTOR , }, - [11 ] = { .domain =CPU_MASK_ALL , .vector =IRQ11_VECTOR , }, - [12 ] = { .domain =CPU_MASK_ALL , .vector =IRQ12_VECTOR , }, - [13 ] = { .domain =CPU_MASK_ALL , .vector =IRQ13_VECTOR , }, - [14 ] = { .domain =CPU_MASK_ALL , .vector =IRQ14_VECTOR , }, - [15 ] = { .domain =CPU_MASK_ALL , .vector =IRQ15_VECTOR , }, + [0 ] = { .vector =IRQ0_VECTOR , }, + [1 ] = { .vector =IRQ1_VECTOR , }, + [2 ] = { .vector =IRQ2_VECTOR , }, + [3 ] = { .vector =IRQ3_VECTOR , }, + [4 ] = { .vector =IRQ4_VECTOR , }, + [5 ] = { .vector =IRQ5_VECTOR , }, + [6 ] = { .vector =IRQ6_VECTOR , }, + [7 ] = { .vector =IRQ7_VECTOR , }, + [8 ] = { .vector =IRQ8_VECTOR , }, + [9 ] = { .vector =IRQ9_VECTOR , }, + [10 ] = { .vector =IRQ10_VECTOR , }, + [11 ] = { .vector =IRQ11_VECTOR , }, + [12 ] = { .vector =IRQ12_VECTOR , }, + [13 ] = { .vector =IRQ13_VECTOR , }, + [14 ] = { .vector =IRQ14_VECTOR , }, + [15 ] = { .vector =IRQ15_VECTOR , }, };void __init arch_early_irq_init (void )
@@ -180,6 +180,10 @@ void __init arch_early_irq_init(void)for (i =0 ; i < count; i++) { desc =irq_to_desc (i); desc->chip_data = &cfg[i]; +alloc_bootmem_cpumask_var (&cfg[i].domain); +alloc_bootmem_cpumask_var (&cfg[i].old_domain); +if (i <NR_IRQS_LEGACY ) +cpumask_setall (cfg[i].domain); } }
@@ -204,6 +208,20 @@ static struct irq_cfg *get_one_free_irq_ node =cpu_to_node (cpu); cfg =kzalloc_node (sizeof (*cfg),GFP_ATOMIC , node); +if (cfg) { +/* FIXME: needs alloc_cpumask_var_node() */ +if (!alloc_cpumask_var (&cfg->domain,GFP_ATOMIC )) { +kfree (cfg); + cfg =NULL ; + }else if (!alloc_cpumask_var (&cfg->old_domain,GFP_ATOMIC )) { +free_cpumask_var (cfg->domain); +kfree (cfg); + cfg =NULL ; + }else { +cpumask_clear (cfg->domain); +cpumask_clear (cfg->old_domain); + } + }printk (KERN_DEBUG " alloc irq_cfg on cpu %d node %d\n" , cpu, node);return cfg;
@@ -362,6 +380,26 @@ static void ioapic_mask_entry(int apic, }#ifdef CONFIG_SMP +static void send_cleanup_vector (struct irq_cfg *cfg) +{ +cpumask_var_t cleanup_mask; + +if (unlikely (!alloc_cpumask_var (&cleanup_mask,GFP_ATOMIC ))) { +unsigned int i; + cfg->move_cleanup_count =0 ; +for_each_cpu_and (i, cfg->old_domain, cpu_online_mask) + cfg->move_cleanup_count++; +for_each_cpu_and (i, cfg->old_domain, cpu_online_mask) +send_IPI_mask (cpumask_of (i),IRQ_MOVE_CLEANUP_VECTOR ); + }else { +cpumask_and (cleanup_mask, cfg->old_domain, cpu_online_mask); + cfg->move_cleanup_count =cpumask_weight (cleanup_mask); +send_IPI_mask (cleanup_mask,IRQ_MOVE_CLEANUP_VECTOR ); +free_cpumask_var (cleanup_mask); + } + cfg->move_in_progress =0 ; +} +static void __target_IO_APIC_irq (unsigned int irq,unsigned int dest,struct irq_cfg *cfg) {int apic, pin;
@@ -400,40 +438,52 @@ static void __target_IO_APIC_irq(unsignestatic int assign_irq_vector (int irq,struct irq_cfg *cfg,const struct cpumask *mask); -static void set_ioapic_affinity_irq_desc (struct irq_desc *desc, -const struct cpumask *mask) +/* +* Either sets desc->affinity to a valid value, and returns cpu_mask_to_apicid +* of that, or returns BAD_APICID and leaves desc->affinity untouched. +*/ +static unsigned int +set_desc_affinity (struct irq_desc *desc,const struct cpumask *mask) {struct irq_cfg *cfg; -unsigned long flags; -unsigned int dest; -cpumask_t tmp;unsigned int irq;if (!cpumask_intersects (mask, cpu_online_mask)) -return ; +return BAD_APICID ; irq = desc->irq; cfg = desc->chip_data;if (assign_irq_vector (irq, cfg, mask)) -return ; +return BAD_APICID ; +cpumask_and (&desc->affinity, cfg->domain, mask);set_extra_move_desc (desc, mask); +return cpu_mask_to_apicid_and (&desc->affinity, cpu_online_mask); +} -cpumask_and (&tmp, &cfg->domain, mask); - dest =cpu_mask_to_apicid (&tmp); -/* -* Only the high 8 bits are valid. -*/ - dest =SET_APIC_LOGICAL_ID (dest); +static void +set_ioapic_affinity_irq_desc (struct irq_desc *desc,const struct cpumask *mask) +{ +struct irq_cfg *cfg; +unsigned long flags; +unsigned int dest; +unsigned int irq; + + irq = desc->irq; + cfg = desc->chip_data;spin_lock_irqsave (&ioapic_lock, flags); -__target_IO_APIC_irq (irq, dest, cfg); -cpumask_copy (&desc->affinity, mask); + dest =set_desc_affinity (desc, mask); +if (dest !=BAD_APICID ) { +/* Only the high 8 bits are valid. */ + dest =SET_APIC_LOGICAL_ID (dest); +__target_IO_APIC_irq (irq, dest, cfg); + }spin_unlock_irqrestore (&ioapic_lock, flags); } -static void set_ioapic_affinity_irq (unsigned int irq, -const struct cpumask *mask) +static void +set_ioapic_affinity_irq (unsigned int irq,const struct cpumask *mask) {struct irq_desc *desc;
@@ -1117,26 +1167,32 @@ __assign_irq_vector(int irq, struct irq_*/ static int current_vector =FIRST_DEVICE_VECTOR , current_offset =0 ;unsigned int old_vector; -int cpu; -cpumask_t tmp_mask; +int cpu, err; +cpumask_var_t tmp_mask;if ((cfg->move_in_progress) || cfg->move_cleanup_count)return -EBUSY ; +if (!alloc_cpumask_var (&tmp_mask,GFP_ATOMIC )) +return -ENOMEM ; + old_vector = cfg->vector;if (old_vector) { -cpus_and (tmp_mask, *mask, cpu_online_map); -cpus_and (tmp_mask, cfg->domain, tmp_mask); -if (!cpus_empty (tmp_mask)) -return 0 ; +cpumask_and (tmp_mask, mask, cpu_online_mask); +cpumask_and (tmp_mask, cfg->domain, tmp_mask); +if (!cpumask_empty (tmp_mask)) { +free_cpumask_var (tmp_mask); +return 0 ; + } }/* Only try and allocate irqs on cpus that are present */ -for_each_cpu_and (cpu, mask, &cpu_online_map) { + err = -ENOSPC ; +for_each_cpu_and (cpu, mask, cpu_online_mask) {int new_cpu;int vector, offset; -vector_allocation_domain (cpu, &tmp_mask); +vector_allocation_domain (cpu, tmp_mask); vector = current_vector; offset = current_offset;
@@ -1156,7 +1212,7 @@ next:if (vector ==SYSCALL_VECTOR ) goto next;#endif -for_each_cpu_and (new_cpu, &tmp_mask, &cpu_online_map) +for_each_cpu_and (new_cpu, tmp_mask, cpu_online_mask)if (per_cpu (vector_irq, new_cpu)[vector] !=-1 ) goto next;/* Found one! */
@@ -1164,15 +1220,17 @@ next: current_offset = offset;if (old_vector) { cfg->move_in_progress =1 ; - cfg->old_domain = cfg->domain; +cpumask_copy (cfg->old_domain, cfg->domain); } -for_each_cpu_and (new_cpu, &tmp_mask, &cpu_online_map) +for_each_cpu_and (new_cpu, tmp_mask, cpu_online_mask)per_cpu (vector_irq, new_cpu)[vector] = irq; cfg->vector = vector; - cfg->domain = tmp_mask; -return 0 ; +cpumask_copy (cfg->domain, tmp_mask); + err =0 ; +break ; } -return -ENOSPC ; +free_cpumask_var (tmp_mask); +return err; } static int
@@ -1189,23 +1247,20 @@ assign_irq_vector(int irq, struct irq_cfstatic void __clear_irq_vector (int irq,struct irq_cfg *cfg) { -cpumask_t mask;int cpu, vector;BUG_ON (!cfg->vector); vector = cfg->vector; -cpus_and (mask, cfg->domain, cpu_online_map); -for_each_cpu_mask_nr (cpu, mask) +for_each_cpu_and (cpu, cfg->domain, cpu_online_mask)per_cpu (vector_irq, cpu)[vector] =-1 ; cfg->vector =0 ; -cpus_clear (cfg->domain); +cpumask_clear (cfg->domain);if (likely (!cfg->move_in_progress))return ; -cpus_and (mask, cfg->old_domain, cpu_online_map); -for_each_cpu_mask_nr (cpu, mask) { +for_each_cpu_and (cpu, cfg->old_domain, cpu_online_mask) {for (vector =FIRST_EXTERNAL_VECTOR ; vector <NR_VECTORS ; vector++) {if (per_cpu (vector_irq, cpu)[vector] != irq)
@@ -1230,7 +1285,7 @@ void __setup_vector_irq(int cpu)if (!desc)continue ; cfg = desc->chip_data; -if (!cpu_isset (cpu, cfg->domain)) +if (!cpumask_test_cpu (cpu, cfg->domain))continue ; vector = cfg->vector;per_cpu (vector_irq, cpu)[vector] = irq;
@@ -1242,7 +1297,7 @@ void __setup_vector_irq(int cpu)continue ; cfg =irq_cfg (irq); -if (!cpu_isset (cpu, cfg->domain)) +if (!cpumask_test_cpu (cpu, cfg->domain))per_cpu (vector_irq, cpu)[vector] =-1 ; } }
@@ -1378,18 +1433,17 @@ static void setup_IO_APIC_irq(int apic, {struct irq_cfg *cfg;struct IO_APIC_route_entry entry; -cpumask_t mask; +unsigned int dest;if (!IO_APIC_IRQ (irq))return ; cfg = desc->chip_data; - mask = *TARGET_CPUS ; -if (assign_irq_vector (irq, cfg, &mask)) +if (assign_irq_vector (irq, cfg,TARGET_CPUS ))return ; -cpus_and (mask, cfg->domain, mask); + dest =cpu_mask_to_apicid_and (cfg->domain,TARGET_CPUS );apic_printk (APIC_VERBOSE ,KERN_DEBUG "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> "
@@ -1399,8 +1453,7 @@ static void setup_IO_APIC_irq(int apic,if (setup_ioapic_entry (mp_ioapics[apic].mp_apicid, irq, &entry, -cpu_mask_to_apicid (&mask), trigger, polarity, - cfg->vector)) { + dest, trigger, polarity, cfg->vector)) {printk ("Failed to setup ioapic entry for ioapic %d, pin %d\n" , mp_ioapics[apic].mp_apicid, pin);__clear_irq_vector (irq, cfg);
@@ -2122,7 +2175,7 @@ static int ioapic_retrigger_irq(unsignedunsigned long flags;spin_lock_irqsave (&vector_lock, flags); -send_IPI_mask (&cpumask_of_cpu (first_cpu (cfg->domain)), cfg->vector); +send_IPI_mask (cpumask_of (cpumask_first (cfg->domain)), cfg->vector);spin_unlock_irqrestore (&vector_lock, flags);return 1 ;
@@ -2175,15 +2228,13 @@ static void migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask) { struct irq_cfg *cfg; -cpumask_t tmpmask;struct irte irte;int modify_ioapic_rte;unsigned int dest;unsigned long flags;unsigned int irq; -cpus_and (tmpmask, *mask, cpu_online_map); -if (cpus_empty (tmpmask)) +if (!cpumask_intersects (mask, cpu_online_mask))return ; irq = desc->irq;
@@ -2196,8 +2247,7 @@ migrate_ioapic_irq_desc(struct irq_descset_extra_move_desc (desc, mask); -cpus_and (tmpmask, cfg->domain, *mask); - dest =cpu_mask_to_apicid (&tmpmask); + dest =cpu_mask_to_apicid_and (cfg->domain, mask); modify_ioapic_rte = desc->status &IRQ_LEVEL ;if (modify_ioapic_rte) {
@@ -2214,14 +2264,10 @@ migrate_ioapic_irq_desc(struct irq_desc*/ modify_irte (irq, &irte); -if (cfg->move_in_progress) { -cpus_and (tmpmask, cfg->old_domain, cpu_online_map); - cfg->move_cleanup_count =cpus_weight (tmpmask); -send_IPI_mask (&tmpmask,IRQ_MOVE_CLEANUP_VECTOR ); - cfg->move_in_progress =0 ; - } +if (cfg->move_in_progress) +send_cleanup_vector (cfg); - desc->affinity = *mask; +cpumask_copy (&desc->affinity, mask); }static int migrate_irq_remapped_level_desc (struct irq_desc *desc)
@@ -2247,7 +2293,7 @@ static int migrate_irq_remapped_level_de ret =0 ; desc->status &= ~IRQ_MOVE_PENDING ; -cpus_clear (desc->pending_mask); +cpumask_clear (&desc->pending_mask); unmask:unmask_IO_APIC_irq_desc (desc);
@@ -2333,7 +2379,7 @@ asmlinkage void smp_irq_move_cleanup_intif (!cfg->move_cleanup_count) goto unlock; -if ((vector == cfg->vector) &&cpu_isset (me, cfg->domain)) +if (vector == cfg->vector &&cpumask_test_cpu (me, cfg->domain)) goto unlock;__get_cpu_var (vector_irq)[vector] =-1 ;
@@ -2356,14 +2402,8 @@ static void irq_complete_move(struct irq vector = ~get_irq_regs ()->orig_ax; me =smp_processor_id (); -if ((vector == cfg->vector) &&cpu_isset (me, cfg->domain)) { -cpumask_t cleanup_mask; - -cpus_and (cleanup_mask, cfg->old_domain, cpu_online_map); - cfg->move_cleanup_count =cpus_weight (cleanup_mask); -send_IPI_mask (&cleanup_mask,IRQ_MOVE_CLEANUP_VECTOR ); - cfg->move_in_progress =0 ; - } +if (vector == cfg->vector &&cpumask_test_cpu (me, cfg->domain)) + send_cleanup_vector(cfg); }#else static inline void irq_complete_move (struct irq_desc **descp) {}
@@ -3088,16 +3128,13 @@ static int msi_compose_msg(struct pci_destruct irq_cfg *cfg;int err;unsigned dest; -cpumask_t tmp; cfg =irq_cfg (irq); - tmp = *TARGET_CPUS ; - err =assign_irq_vector (irq, cfg, &tmp); + err =assign_irq_vector (irq, cfg,TARGET_CPUS );if (err)return err; -cpus_and (tmp, cfg->domain, tmp); - dest =cpu_mask_to_apicid (&tmp); + dest =cpu_mask_to_apicid_and (cfg->domain,TARGET_CPUS );#ifdef CONFIG_INTR_REMAP if (irq_remapped (irq)) {
@@ -3157,19 +3194,12 @@ static void set_msi_irq_affinity(unsignestruct irq_cfg *cfg;struct msi_msg msg;unsigned int dest; -cpumask_t tmp; -if (!cpumask_intersects (mask, cpu_online_mask)) + dest =set_desc_affinity (desc, mask); +if (dest ==BAD_APICID )return ; cfg = desc->chip_data; -if (assign_irq_vector (irq, cfg, mask)) -return ; - -set_extra_move_desc (desc, mask); - -cpumask_and (&tmp, &cfg->domain, mask); - dest =cpu_mask_to_apicid (&tmp);read_msi_msg_desc (desc, &msg);
@@ -3179,7 +3209,6 @@ static void set_msi_irq_affinity(unsigne msg.address_lo |=MSI_ADDR_DEST_ID (dest);write_msi_msg_desc (desc, &msg); -cpumask_copy (&desc->affinity, mask); }#ifdef CONFIG_INTR_REMAP /*
@@ -3192,24 +3221,15 @@ ir_set_msi_irq_affinity(unsigned int irqstruct irq_desc *desc =irq_to_desc (irq);struct irq_cfg *cfg;unsigned int dest; -cpumask_t tmp, cleanup_mask;struct irte irte; -if (!cpumask_intersects (mask, cpu_online_mask)) -return ; -if (get_irte (irq, &irte))return ; - cfg = desc->chip_data; -if (assign_irq_vector (irq, cfg, mask)) + dest =set_desc_affinity (desc, mask); +if (dest ==BAD_APICID )return ; -set_extra_move_desc (desc, mask); - -cpumask_and (&tmp, &cfg->domain, mask); - dest =cpu_mask_to_apicid (&tmp); - irte.vector = cfg->vector; irte.dest_id =IRTE_DEST (dest);
@@ -3223,14 +3243,8 @@ ir_set_msi_irq_affinity(unsigned int irq* at the new destination. So, time to cleanup the previous * vector allocation. */ -if (cfg->move_in_progress) { -cpus_and (cleanup_mask, cfg->old_domain, cpu_online_map); - cfg->move_cleanup_count =cpus_weight (cleanup_mask); -send_IPI_mask (&cleanup_mask,IRQ_MOVE_CLEANUP_VECTOR ); - cfg->move_in_progress =0 ; - } - - cpumask_copy(&desc->affinity, mask); +if (cfg->move_in_progress) + send_cleanup_vector(cfg); }#endif
@@ -3421,25 +3435,18 @@ void arch_teardown_msi_irq(unsigned int #ifdef CONFIG_DMAR #ifdef CONFIG_SMP -static void dmar_msi_set_affinity(unsigned int irq, const cpumask_t *mask) +static void dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask) { struct irq_desc *desc = irq_to_desc(irq); struct irq_cfg *cfg; struct msi_msg msg; unsigned int dest; - cpumask_t tmp; - if (!cpumask_intersects(mask, cpu_online_mask)) + dest = set_desc_affinity(desc, mask); + if (dest == BAD_APICID) return; cfg = desc->chip_data; - if (assign_irq_vector(irq, cfg, mask)) - return; - - set_extra_move_desc(desc, mask); - - cpumask_and(&tmp, &cfg->domain, mask); - dest = cpu_mask_to_apicid(&tmp); dmar_msi_read(irq, &msg);
@@ -3449,7 +3456,6 @@ static void dmar_msi_set_affinity(unsign msg.address_lo |=MSI_ADDR_DEST_ID (dest); dmar_msi_write(irq, &msg); - cpumask_copy(&desc->affinity, mask); }#endif /* CONFIG_SMP */
@@ -3483,25 +3489,18 @@ int arch_setup_dmar_msi(unsigned int irq #ifdef CONFIG_HPET_TIMER #ifdef CONFIG_SMP -static void hpet_msi_set_affinity(unsigned int irq, const cpumask_t *mask) +static void hpet_msi_set_affinity(unsigned int irq, const struct cpumask *mask) { struct irq_desc *desc = irq_to_desc(irq); struct irq_cfg *cfg; struct msi_msg msg; unsigned int dest; - cpumask_t tmp; - if (!cpumask_intersects(mask, cpu_online_mask)) + dest = set_desc_affinity(desc, mask); + if (dest == BAD_APICID) return; cfg = desc->chip_data; - if (assign_irq_vector(irq, cfg, mask)) - return; - - set_extra_move_desc(desc, mask); - - cpumask_and(&tmp, &cfg->domain, mask); - dest = cpu_mask_to_apicid(&tmp); hpet_msi_read(irq, &msg);
@@ -3511,7 +3510,6 @@ static void hpet_msi_set_affinity(unsign msg.address_lo |=MSI_ADDR_DEST_ID (dest); hpet_msi_write(irq, &msg); - cpumask_copy(&desc->affinity, mask); }#endif /* CONFIG_SMP */
@@ -3566,27 +3564,19 @@ static void target_ht_irq(unsigned int i write_ht_irq_msg(irq, &msg); } -static void set_ht_irq_affinity (unsigned int irq,const cpumask_t *mask) +static void set_ht_irq_affinity (unsigned int irq,const struct cpumask *mask) {struct irq_desc *desc =irq_to_desc (irq);struct irq_cfg *cfg;unsigned int dest; -cpumask_t tmp; -if (!cpumask_intersects (mask, cpu_online_mask)) + dest =set_desc_affinity (desc, mask); +if (dest ==BAD_APICID )return ; cfg = desc->chip_data; -if (assign_irq_vector (irq, cfg, mask)) -return ; - -set_extra_move_desc (desc, mask); - -cpumask_and (&tmp, &cfg->domain, mask); - dest =cpu_mask_to_apicid (&tmp);target_ht_irq (irq, dest, cfg->vector); -cpumask_copy (&desc->affinity, mask); }#endif
@@ -3606,7 +3596,6 @@ int arch_setup_ht_irq(unsigned int irq, {struct irq_cfg *cfg;int err; -cpumask_t tmp; cfg =irq_cfg (irq); err =assign_irq_vector (irq, cfg,TARGET_CPUS );
@@ -3614,8 +3603,7 @@ int arch_setup_ht_irq(unsigned int irq,struct ht_irq_msg msg;unsigned dest; -cpus_and (tmp, cfg->domain, tmp); - dest =cpu_mask_to_apicid (&tmp); + dest =cpu_mask_to_apicid_and (cfg->domain,TARGET_CPUS ); msg.address_hi =HT_IRQ_HIGH_DEST_ID (dest);
@@ -3651,7 +3639,7 @@ int arch_setup_ht_irq(unsigned int irq,int arch_enable_uv_irq (char *irq_name,unsigned int irq,int cpu,int mmr_blade,unsigned long mmr_offset) { -const cpumask_t *eligible_cpu = &cpumask_of_cpu (cpu); +const struct cpumask *eligible_cpu =cpumask_of (cpu);struct irq_cfg *cfg;int mmr_pnode;unsigned long mmr_value;
@@ -3891,7 +3879,7 @@ void __init setup_ioapic_dest(void)int pin, ioapic, irq, irq_entry;struct irq_desc *desc;struct irq_cfg *cfg; -const cpumask_t *mask; +const struct cpumask *mask;if (skip_ioapic_setup ==1 )return ;
PATCH 7/16 xen: convert to cpumask_var_t and new cpumask primitives.
In reply to Mike TravisSimple change, and eventual space saving when NR_CPUS >> nr_cpu_ids.
--- arch/x86/xen/smp.c | 9 ++++++--- arch/x86/xen/suspend.c | 3 ++- arch/x86/xen/xen-ops.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-)
arch/x86/xen/smp.c +6 -3
@@ -33,7 +33,7 @@#include "xen-ops.h" #include "mmu.h" -cpumask_t xen_cpu_initialized_map; +cpumask_var_t xen_cpu_initialized_map; static DEFINE_PER_CPU(int, resched_irq); static DEFINE_PER_CPU(int, callfunc_irq);
@@ -192,7 +192,10 @@ static void __init xen_smp_prepare_cpus(unsigned int max_cpus)if (xen_smp_intr_init (0 ))BUG (); - xen_cpu_initialized_map =cpumask_of_cpu (0 ); +if (!alloc_cpumask_var (&xen_cpu_initialized_map,GFP_KERNEL )) +panic ("could not allocate xen_cpu_initialized_map\n" ); + +cpumask_copy (xen_cpu_initialized_map,cpumask_of (0 ));/* Restrict the possible_map according to max_cpus. */ while ((num_possible_cpus () >1 ) && (num_possible_cpus () > max_cpus)) {
@@ -221,7 +224,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)struct vcpu_guest_context *ctxt;struct desc_struct *gdt; -if (cpu_test_and_set (cpu, xen_cpu_initialized_map)) +if (cpumask_test_and_set_cpu (cpu, xen_cpu_initialized_map))return 0 ; ctxt =kzalloc (sizeof (*ctxt),GFP_KERNEL );
arch/x86/xen/suspend.c +2 -1
@@ -35,7 +35,8 @@ void xen_post_suspend(int suspend_cancelled)pfn_to_mfn (xen_start_info->console.domU.mfn); }else {#ifdef CONFIG_SMP - xen_cpu_initialized_map = cpu_online_map; +BUG_ON (xen_cpu_initialized_map ==NULL ); +cpumask_copy (xen_cpu_initialized_map, cpu_online_mask);#endif xen_vcpu_restore (); }
arch/x86/xen/xen-ops.h +1 -1
@@ -58,7 +58,7 @@ void __init xen_init_spinlocks(void);__cpuinit void xen_init_lock_cpu (int cpu);void xen_uninit_lock_cpu (int cpu); -extern cpumask_t xen_cpu_initialized_map; +extern cpumask_var_t xen_cpu_initialized_map;#else static inline void xen_smp_init (void ) {}#endif
Signature · 3 lines
1.6.0 --
PATCH 8/16 x86: fixup_irqs() doesnt need an argument.
In reply to Mike TravisImpact: cleanup, remove on-stack cpumask.
The "map" arg is always cpu_online_mask. Importantly, set_affinity always ands the argument with cpu_online_mask anyway, so we don't need to do it in fixup_irqs(), avoiding a temporary.
--- arch/x86/include/asm/irq.h | 2 +- arch/x86/kernel/irq_32.c | 13 +++++++------ arch/x86/kernel/irq_64.c | 15 ++++++++------- arch/x86/kernel/smpboot.c | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-)
arch/x86/include/asm/irq.h +1 -1
@@ -37,7 +37,7 @@ extern int irqbalance_disable(char *str)#ifdef CONFIG_HOTPLUG_CPU #include <linux/cpumask.h> -extern void fixup_irqs (cpumask_t map); +extern void fixup_irqs (void );#endif extern unsigned int do_IRQ (struct pt_regs *regs);
arch/x86/kernel/irq_32.c +7 -6
@@ -233,27 +233,28 @@ unsigned int do_IRQ(struct pt_regs *regs#ifdef CONFIG_HOTPLUG_CPU #include <mach_apic.h> -void fixup_irqs (cpumask_t map) +/* A cpu has been removed from cpu_online_mask. Reset irq affinities. */ +void fixup_irqs (void ) {unsigned int irq;static int warned;struct irq_desc *desc;for_each_irq_desc (irq, desc) { -cpumask_t mask; +const struct cpumask *affinity;if (!desc)continue ;if (irq ==2 )continue ; -cpus_and (mask, desc->affinity, map); -if (any_online_cpu (mask) ==NR_CPUS ) { + affinity = &desc->affinity; +if (cpumask_any_and (affinity, cpu_online_mask) >= nr_cpu_ids) {printk ("Breaking affinity for irq %i\n" , irq); - mask = map; + affinity = cpu_all_mask; }if (desc->chip->set_affinity) - desc->chip->set_affinity (irq, &mask); + desc->chip->set_affinity (irq, affinity);else if (desc->action && !(warned++))printk ("Cannot set affinity for irq %i\n" , irq); }
arch/x86/kernel/irq_64.c +8 -7
@@ -83,16 +83,17 @@ asmlinkage unsigned int do_IRQ(struct pt }#ifdef CONFIG_HOTPLUG_CPU -void fixup_irqs (cpumask_t map) +/* A cpu has been removed from cpu_online_mask. Reset irq affinities. */ +void fixup_irqs (void ) {unsigned int irq;static int warned;struct irq_desc *desc;for_each_irq_desc (irq, desc) { -cpumask_t mask;int break_affinity =0 ;int set_affinity =1 ; +const struct cpumask *affinity;if (!desc)continue ;
@@ -102,23 +103,23 @@ void fixup_irqs(cpumask_t map)/* interrupt's are disabled at this point */ spin_lock (&desc->lock); + affinity = &desc->affinity;if (!irq_has_action (irq) || -cpus_equal (desc->affinity, map)) { +cpumask_equal (affinity, cpu_online_mask)) {spin_unlock (&desc->lock);continue ; } -cpus_and (mask, desc->affinity, map); -if (cpus_empty (mask)) { +if (cpumask_any_and (affinity, cpu_online_mask) >= nr_cpu_ids) { break_affinity =1 ; - mask = map; + affinity = cpu_all_mask; }if (desc->chip->mask) desc->chip->mask (irq);if (desc->chip->set_affinity) - desc->chip->set_affinity (irq, &mask); + desc->chip->set_affinity (irq, affinity);else if (!(warned++)) set_affinity =0 ;
arch/x86/kernel/smpboot.c +1 -1
@@ -1346,7 +1346,7 @@ void cpu_disable_common(void)lock_vector_lock ();remove_cpu_from_maps (cpu);unlock_vector_lock (); -fixup_irqs (cpu_online_map); +fixup_irqs (); }int native_cpu_disable (void )
PATCH 9/16 x86: cosmetic changes apic-related files.
In reply to Mike TravisThis patch simply changes cpumask_t to struct cpumask and similar trivial modernizations.
--- arch/x86/include/asm/bigsmp/ipi.h | 14 ++---- arch/x86/include/asm/es7000/ipi.h | 13 ++---- arch/x86/include/asm/genapic_32.h | 11 +++-- arch/x86/include/asm/genapic_64.h | 11 +++-- arch/x86/include/asm/ipi.h | 10 +++-- arch/x86/include/asm/mach-default/mach_apic.h | 12 +++--- arch/x86/include/asm/mach-default/mach_ipi.h | 12 +++--- arch/x86/include/asm/numaq/ipi.h | 14 ++---- arch/x86/include/asm/smp.h | 4 +- arch/x86/kernel/genapic_flat_64.c | 50 +++++++++++++------------ arch/x86/kernel/genx2apic_cluster.c | 25 ++++++------ arch/x86/kernel/genx2apic_phys.c | 25 ++++++------ arch/x86/kernel/genx2apic_uv_x.c | 24 ++++++------ arch/x86/kernel/ipi.c | 14 +++--- arch/x86/kernel/smp.c | 6 +- arch/x86/xen/smp.c | 11 +++-- 16 files changed, 127 insertions(+), 129 deletions(-)
arch/x86/include/asm/bigsmp/ipi.h +5 -9
@@ -1,26 +1,22 @@#ifndef __ASM_MACH_IPI_H#define __ASM_MACH_IPI_H -void send_IPI_mask_sequence (const cpumask_t *mask,int vector); -void send_IPI_mask_allbutself (const cpumask_t *mask,int vector); +void send_IPI_mask_sequence (const struct cpumask *mask,int vector); +void send_IPI_mask_allbutself (const struct cpumask *mask,int vector); -static inline void send_IPI_mask (const cpumask_t *mask,int vector) +static inline void send_IPI_mask (const struct cpumask *mask,int vector) {send_IPI_mask_sequence (mask, vector); }static inline void send_IPI_allbutself (int vector) { -cpumask_t mask = cpu_online_map; -cpu_clear (smp_processor_id (), mask); - -if (!cpus_empty (mask)) -send_IPI_mask (&mask, vector); +send_IPI_mask_allbutself (cpu_online_mask, vector); }static inline void send_IPI_all (int vector) { -send_IPI_mask (&cpu_online_map, vector); +send_IPI_mask (cpu_online_mask, vector); }#endif /* __ASM_MACH_IPI_H */
arch/x86/include/asm/es7000/ipi.h +5 -8
@@ -1,25 +1,22 @@#ifndef __ASM_ES7000_IPI_H#define __ASM_ES7000_IPI_H -void send_IPI_mask_sequence (const cpumask_t *mask,int vector); -void send_IPI_mask_allbutself (const cpumask_t *mask,int vector); +void send_IPI_mask_sequence (const struct cpumask *mask,int vector); +void send_IPI_mask_allbutself (const struct cpumask *mask,int vector); -static inline void send_IPI_mask (const cpumask_t *mask,int vector) +static inline void send_IPI_mask (const struct cpumask *mask,int vector) {send_IPI_mask_sequence (mask, vector); }static inline void send_IPI_allbutself (int vector) { -cpumask_t mask = cpu_online_map; -cpu_clear (smp_processor_id (), mask); -if (!cpus_empty (mask)) -send_IPI_mask (&mask, vector); +send_IPI_mask_allbutself (cpu_online_mask, vector); }static inline void send_IPI_all (int vector) { -send_IPI_mask (&cpu_online_map, vector); +send_IPI_mask (cpu_online_mask, vector); }#endif /* __ASM_ES7000_IPI_H */
arch/x86/include/asm/genapic_32.h +6 -5
@@ -24,7 +24,7 @@ struct genapic {int (*probe)(void );int (*apic_id_registered)(void ); -const cpumask_t *(*target_cpus)(void ); +const struct cpumask *(*target_cpus)(void );int int_delivery_mode;int int_dest_mode;int ESR_DISABLE ;
@@ -57,15 +57,16 @@ struct genapic {unsigned (*get_apic_id)(unsigned long x);unsigned long apic_id_mask; -unsigned int (*cpu_mask_to_apicid)(const cpumask_t *cpumask); +unsigned int (*cpu_mask_to_apicid)(const struct cpumask *cpumask);unsigned int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask,const struct cpumask *andmask); -void (*vector_allocation_domain)(int cpu,cpumask_t *retmask); +void (*vector_allocation_domain)(int cpu,struct cpumask *retmask);#ifdef CONFIG_SMP /* ipi */ -void (*send_IPI_mask)(const cpumask_t *mask,int vector); -void (*send_IPI_mask_allbutself)(const cpumask_t *mask,int vector); +void (*send_IPI_mask)(const struct cpumask *mask,int vector); +void (*send_IPI_mask_allbutself)(const struct cpumask *mask, +int vector);void (*send_IPI_allbutself)(int vector);void (*send_IPI_all)(int vector);#endif
arch/x86/include/asm/genapic_64.h +6 -5
@@ -20,17 +20,18 @@ struct genapic {u32 int_delivery_mode;u32 int_dest_mode;int (*apic_id_registered)(void ); -const cpumask_t *(*target_cpus)(void ); -void (*vector_allocation_domain)(int cpu,cpumask_t *retmask); +const struct cpumask *(*target_cpus)(void ); +void (*vector_allocation_domain)(int cpu,struct cpumask *retmask);void (*init_apic_ldr)(void );/* ipi */ -void (*send_IPI_mask)(const cpumask_t *mask,int vector); -void (*send_IPI_mask_allbutself)(const cpumask_t *mask,int vector); +void (*send_IPI_mask)(const struct cpumask *mask,int vector); +void (*send_IPI_mask_allbutself)(const struct cpumask *mask, +int vector);void (*send_IPI_allbutself)(int vector);void (*send_IPI_all)(int vector);void (*send_IPI_self)(int vector);/* */ -unsigned int (*cpu_mask_to_apicid)(const cpumask_t *cpumask); +unsigned int (*cpu_mask_to_apicid)(const struct cpumask *cpumask);unsigned int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask,const struct cpumask *andmask);unsigned int (*phys_pkg_id)(int index_msb);
arch/x86/include/asm/ipi.h +6 -4
@@ -117,7 +117,8 @@ static inline void __send_IPI_dest_field(unsigned int mask, int vector,native_apic_mem_write (APIC_ICR , cfg); } -static inline void send_IPI_mask_sequence (const cpumask_t *mask,int vector) +static inline void send_IPI_mask_sequence (const struct cpumask *mask, +int vector) {unsigned long flags;unsigned long query_cpu;
@@ -128,14 +129,15 @@ static inline void send_IPI_mask_sequence(const cpumask_t *mask, int vector)* - mbligh */ local_irq_save (flags); -for_each_cpu_mask_nr (query_cpu, *mask) { +for_each_cpu (query_cpu, mask) {__send_IPI_dest_field (per_cpu (x86_cpu_to_apicid, query_cpu), vector,APIC_DEST_PHYSICAL ); }local_irq_restore (flags); } -static inline void send_IPI_mask_allbutself (const cpumask_t *mask,int vector) +static inline void send_IPI_mask_allbutself (const struct cpumask *mask, +int vector) {unsigned long flags;unsigned int query_cpu;
@@ -144,7 +146,7 @@ static inline void send_IPI_mask_allbutself(const cpumask_t *mask, int vector)/* See Hack comment above */ local_irq_save (flags); -for_each_cpu_mask_nr (query_cpu, *mask) +for_each_cpu (query_cpu, mask)if (query_cpu != this_cpu) __send_IPI_dest_field( per_cpu(x86_cpu_to_apicid, query_cpu),
arch/x86/include/asm/mach-default/mach_apic.h +6 -6
@@ -8,12 +8,12 @@#define APIC_DFR_VALUE (APIC_DFR_FLAT) -static inline const cpumask_t *target_cpus (void ) +static inline const struct cpumask *target_cpus (void ) {#ifdef CONFIG_SMP -return &cpu_online_map; +return cpu_online_mask;#else -return &cpumask_of_cpu (0 ); +return cpumask_of (0 );#endif }
@@ -62,9 +62,9 @@ static inline int apic_id_registered(void)return physid_isset (read_apic_id (), phys_cpu_present_map); } -static inline unsigned int cpu_mask_to_apicid (const cpumask_t *cpumask) +static inline unsigned int cpu_mask_to_apicid (const struct cpumask *cpumask) { -return cpus_addr (*cpumask)[0 ]; +return cpumask_bits (cpumask)[0 ]; } static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *cpumask,
@@ -98,7 +98,7 @@ static inline int apicid_to_node(int logical_apicid)#endif } -static inline void vector_allocation_domain (int cpu,cpumask_t *retmask) +static inline void vector_allocation_domain (int cpu,struct cpumask *retmask) {/* Careful. Some cpus do not strictly honor the set of cpus * specified in the interrupt destination when using lowest
arch/x86/include/asm/mach-default/mach_ipi.h +6 -6
@@ -4,8 +4,8 @@/* Avoid include hell */ #define NMI_VECTOR 0x02 -void send_IPI_mask_bitmask (const cpumask_t *mask,int vector); -void send_IPI_mask_allbutself (const cpumask_t *mask,int vector); +void send_IPI_mask_bitmask (const struct cpumask *mask,int vector); +void send_IPI_mask_allbutself (const struct cpumask *mask,int vector);void __send_IPI_shortcut (unsigned int shortcut,int vector);extern int no_broadcast;
@@ -15,17 +15,17 @@ extern int no_broadcast;#define send_IPI_mask (genapic->send_IPI_mask)#define send_IPI_mask_allbutself (genapic->send_IPI_mask_allbutself)#else -static inline void send_IPI_mask (const cpumask_t *mask,int vector) +static inline void send_IPI_mask (const struct cpumask *mask,int vector) {send_IPI_mask_bitmask (mask, vector); } -void send_IPI_mask_allbutself (const cpumask_t *mask,int vector); +void send_IPI_mask_allbutself (const struct cpumask *mask,int vector);#endif static inline void __local_send_IPI_allbutself (int vector) {if (no_broadcast || vector ==NMI_VECTOR ) -send_IPI_mask_allbutself (&cpu_online_map, vector); +send_IPI_mask_allbutself (cpu_online_mask, vector);else __send_IPI_shortcut (APIC_DEST_ALLBUT , vector); }
@@ -33,7 +33,7 @@ static inline void __local_send_IPI_allbutself(int vector)static inline void __local_send_IPI_all (int vector) {if (no_broadcast || vector ==NMI_VECTOR ) -send_IPI_mask (&cpu_online_map, vector); +send_IPI_mask (cpu_online_mask, vector);else __send_IPI_shortcut (APIC_DEST_ALLINC , vector); }
arch/x86/include/asm/numaq/ipi.h +5 -9
@@ -1,26 +1,22 @@#ifndef __ASM_NUMAQ_IPI_H#define __ASM_NUMAQ_IPI_H -void send_IPI_mask_sequence (const cpumask_t *mask,int vector); -void send_IPI_mask_allbutself (const cpumask_t *mask,int vector); +void send_IPI_mask_sequence (const struct cpumask *mask,int vector); +void send_IPI_mask_allbutself (const struct cpumask *mask,int vector); -static inline void send_IPI_mask (const cpumask_t *mask,int vector) +static inline void send_IPI_mask (const struct cpumask *mask,int vector) {send_IPI_mask_sequence (mask, vector); }static inline void send_IPI_allbutself (int vector) { -cpumask_t mask = cpu_online_map; -cpu_clear (smp_processor_id (), mask); - -if (!cpus_empty (mask)) -send_IPI_mask (&mask, vector); +send_IPI_mask_allbutself (cpu_online_mask, vector); }static inline void send_IPI_all (int vector) { -send_IPI_mask (&cpu_online_map, vector); +send_IPI_mask (cpu_online_mask, vector); }#endif /* __ASM_NUMAQ_IPI_H */
arch/x86/include/asm/smp.h +2 -2
@@ -60,7 +60,7 @@ struct smp_ops {void (*cpu_die)(unsigned int cpu);void (*play_dead)(void ); -void (*send_call_func_ipi)(const cpumask_t *mask); +void (*send_call_func_ipi)(const struct cpumask *mask);void (*send_call_func_single_ipi)(int cpu); };
@@ -138,7 +138,7 @@ void native_cpu_die(unsigned int cpu);void native_play_dead (void );void play_dead_common (void ); -void native_send_call_func_ipi (const cpumask_t *mask); +void native_send_call_func_ipi (const struct cpumask *mask);void native_send_call_func_single_ipi (int cpu);extern void prefill_possible_map (void );
arch/x86/kernel/genapic_flat_64.c +26 -24
130 lines not on this page · raw message
arch/x86/kernel/genx2apic_cluster.c +13 -12
@@ -22,18 +22,18 @@ static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)/* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */ -static const cpumask_t *x2apic_target_cpus (void ) +static const struct cpumask *x2apic_target_cpus (void ) { -return &cpumask_of_cpu (0 ); +return cpumask_of (0 ); }/* * for now each logical cpu is in its own vector allocation domain. */ -static void x2apic_vector_allocation_domain (int cpu,cpumask_t *retmask) +static void x2apic_vector_allocation_domain (int cpu,struct cpumask *retmask) { -cpus_clear (*retmask); -cpu_set (cpu, *retmask); +cpumask_clear (retmask); +cpumask_set_cpu (cpu, retmask); } static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
@@ -55,27 +55,28 @@ static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,* at once. We have 16 cpu's in a cluster. This will minimize IPI register * writes. */ -static void x2apic_send_IPI_mask (const cpumask_t *mask,int vector) +static void x2apic_send_IPI_mask (const struct cpumask *mask,int vector) {unsigned long flags;unsigned long query_cpu;local_irq_save (flags); -for_each_cpu_mask_nr (query_cpu, *mask) +for_each_cpu (query_cpu, mask)__x2apic_send_IPI_dest (per_cpu (x86_cpu_to_logical_apicid, query_cpu), vector,APIC_DEST_LOGICAL );local_irq_restore (flags); } -static void x2apic_send_IPI_mask_allbutself (const cpumask_t *mask,int vector) +static void x2apic_send_IPI_mask_allbutself (const struct cpumask *mask, +int vector) {unsigned long flags;unsigned long query_cpu;unsigned long this_cpu =smp_processor_id ();local_irq_save (flags); -for_each_cpu_mask_nr (query_cpu, *mask) +for_each_cpu (query_cpu, mask)if (query_cpu != this_cpu) __x2apic_send_IPI_dest( per_cpu(x86_cpu_to_logical_apicid, query_cpu),
@@ -100,7 +101,7 @@ static void x2apic_send_IPI_allbutself(int vector)static void x2apic_send_IPI_all (int vector) { -x2apic_send_IPI_mask (&cpu_online_map, vector); +x2apic_send_IPI_mask (cpu_online_mask, vector); }static int x2apic_apic_id_registered (void )
@@ -108,7 +109,7 @@ static int x2apic_apic_id_registered(void)return 1 ; } -static unsigned int x2apic_cpu_mask_to_apicid (const cpumask_t *cpumask) +static unsigned int x2apic_cpu_mask_to_apicid (const struct cpumask *cpumask) {int cpu;
@@ -116,7 +117,7 @@ static unsigned int x2apic_cpu_mask_to_apicid(const cpumask_t *cpumask)* We're using fixed IRQ delivery, can only return one phys APIC ID. * May as well be the first. */ - cpu =first_cpu (*cpumask); + cpu =cpumask_first (cpumask);if ((unsigned )cpu < nr_cpu_ids)return per_cpu (x86_cpu_to_logical_apicid, cpu);else
arch/x86/kernel/genx2apic_phys.c +13 -12
@@ -29,15 +29,15 @@ static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)/* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */ -static const cpumask_t *x2apic_target_cpus (void ) +static const struct cpumask *x2apic_target_cpus (void ) { -return &cpumask_of_cpu (0 ); +return cpumask_of (0 ); } -static void x2apic_vector_allocation_domain (int cpu,cpumask_t *retmask) +static void x2apic_vector_allocation_domain (int cpu,struct cpumask *retmask) { -cpus_clear (*retmask); -cpu_set (cpu, *retmask); +cpumask_clear (retmask); +cpumask_set_cpu (cpu, retmask); } static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
@@ -53,27 +53,28 @@ static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,x2apic_icr_write (cfg, apicid); } -static void x2apic_send_IPI_mask (const cpumask_t *mask,int vector) +static void x2apic_send_IPI_mask (const struct cpumask *mask,int vector) {unsigned long flags;unsigned long query_cpu;local_irq_save (flags); -for_each_cpu_mask_nr (query_cpu, *mask) { +for_each_cpu (query_cpu, mask) {__x2apic_send_IPI_dest (per_cpu (x86_cpu_to_apicid, query_cpu), vector,APIC_DEST_PHYSICAL ); }local_irq_restore (flags); } -static void x2apic_send_IPI_mask_allbutself (const cpumask_t *mask,int vector) +static void x2apic_send_IPI_mask_allbutself (const struct cpumask *mask, +int vector) {unsigned long flags;unsigned long query_cpu;unsigned long this_cpu =smp_processor_id ();local_irq_save (flags); -for_each_cpu_mask_nr (query_cpu, *mask) { +for_each_cpu (query_cpu, mask) {if (query_cpu != this_cpu) __x2apic_send_IPI_dest( per_cpu(x86_cpu_to_apicid, query_cpu),
@@ -99,7 +100,7 @@ static void x2apic_send_IPI_allbutself(int vector)static void x2apic_send_IPI_all (int vector) { -x2apic_send_IPI_mask (&cpu_online_map, vector); +x2apic_send_IPI_mask (cpu_online_mask, vector); }static int x2apic_apic_id_registered (void )
@@ -107,7 +108,7 @@ static int x2apic_apic_id_registered(void)return 1 ; } -static unsigned int x2apic_cpu_mask_to_apicid (const cpumask_t *cpumask) +static unsigned int x2apic_cpu_mask_to_apicid (const struct cpumask *cpumask) {int cpu;
@@ -115,7 +116,7 @@ static unsigned int x2apic_cpu_mask_to_apicid(const cpumask_t *cpumask)* We're using fixed IRQ delivery, can only return one phys APIC ID. * May as well be the first. */ - cpu =first_cpu (*cpumask); + cpu =cpumask_first (cpumask);if ((unsigned )cpu < nr_cpu_ids)return per_cpu (x86_cpu_to_apicid, cpu);else
arch/x86/kernel/genx2apic_uv_x.c +12 -12
@@ -75,15 +75,15 @@ EXPORT_SYMBOL(sn_rtc_cycles_per_second);/* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */ -static const cpumask_t *uv_target_cpus (void ) +static const struct cpumask *uv_target_cpus (void ) { -return &cpumask_of_cpu (0 ); +return cpumask_of (0 ); } -static void uv_vector_allocation_domain (int cpu,cpumask_t *retmask) +static void uv_vector_allocation_domain (int cpu,struct cpumask *retmask) { -cpus_clear (*retmask); -cpu_set (cpu, *retmask); +cpumask_clear (retmask); +cpumask_set_cpu (cpu, retmask); }int uv_wakeup_secondary (int phys_apicid,unsigned int start_rip)
@@ -122,20 +122,20 @@ static void uv_send_IPI_one(int cpu, int vector)uv_write_global_mmr64 (pnode,UVH_IPI_INT , val); } -static void uv_send_IPI_mask (const cpumask_t *mask,int vector) +static void uv_send_IPI_mask (const struct cpumask *mask,int vector) {unsigned int cpu; -for_each_cpu_mask_nr (cpu, *mask) +for_each_cpu (cpu, mask)uv_send_IPI_one (cpu, vector); } -static void uv_send_IPI_mask_allbutself (const cpumask_t *mask,int vector) +static void uv_send_IPI_mask_allbutself (const struct cpumask *mask,int vector) {unsigned int cpu;unsigned int this_cpu =smp_processor_id (); -for_each_cpu_mask_nr (cpu, *mask) +for_each_cpu (cpu, mask)if (cpu != this_cpu)uv_send_IPI_one (cpu, vector); }
@@ -152,7 +152,7 @@ static void uv_send_IPI_allbutself(int vector)static void uv_send_IPI_all (int vector) { -uv_send_IPI_mask (&cpu_online_map, vector); +uv_send_IPI_mask (cpu_online_mask, vector); }static int uv_apic_id_registered (void )
@@ -164,7 +164,7 @@ static void uv_init_apic_ldr(void) { } -static unsigned int uv_cpu_mask_to_apicid (const cpumask_t *cpumask) +static unsigned int uv_cpu_mask_to_apicid (const struct cpumask *cpumask) {int cpu;
@@ -172,7 +172,7 @@ static unsigned int uv_cpu_mask_to_apicid(const cpumask_t *cpumask)* We're using fixed IRQ delivery, can only return one phys APIC ID. * May as well be the first. */ - cpu =first_cpu (*cpumask); + cpu =cpumask_first (cpumask);if ((unsigned )cpu < nr_cpu_ids)return per_cpu (x86_cpu_to_apicid, cpu);else
arch/x86/kernel/ipi.c +7 -7
@@ -116,18 +116,18 @@ static inline void __send_IPI_dest_field(unsigned long mask, int vector)/* * This is only used on smaller machines. */ -void send_IPI_mask_bitmask (const cpumask_t *cpumask,int vector) +void send_IPI_mask_bitmask (const struct cpumask *cpumask,int vector) { -unsigned long mask =cpus_addr (*cpumask)[0 ]; +unsigned long mask =cpumask_bits (cpumask)[0 ];unsigned long flags;local_irq_save (flags); -WARN_ON (mask & ~cpus_addr (cpu_online_map)[0 ]); +WARN_ON (mask & ~cpumask_bits (cpu_online_mask)[0 ]);__send_IPI_dest_field (mask, vector);local_irq_restore (flags); } -void send_IPI_mask_sequence (const cpumask_t *mask,int vector) +void send_IPI_mask_sequence (const struct cpumask *mask,int vector) {unsigned long flags;unsigned int query_cpu;
@@ -139,12 +139,12 @@ void send_IPI_mask_sequence(const cpumask_t *mask, int vector)*/ local_irq_save (flags); -for_each_cpu_mask_nr (query_cpu, *mask) +for_each_cpu (query_cpu, mask)__send_IPI_dest_field (cpu_to_logical_apicid (query_cpu), vector);local_irq_restore (flags); } -void send_IPI_mask_allbutself (const cpumask_t *mask,int vector) +void send_IPI_mask_allbutself (const struct cpumask *mask,int vector) {unsigned long flags;unsigned int query_cpu;
@@ -153,7 +153,7 @@ void send_IPI_mask_allbutself(const cpumask_t *mask, int vector)/* See Hack comment above */ local_irq_save (flags); -for_each_cpu_mask_nr (query_cpu, *mask) +for_each_cpu (query_cpu, mask)if (query_cpu != this_cpu)__send_IPI_dest_field (cpu_to_logical_apicid (query_cpu), vector);
arch/x86/kernel/smp.c +3 -3
@@ -118,15 +118,15 @@ static void native_smp_send_reschedule(int cpu)WARN_ON (1 );return ; } -send_IPI_mask (&cpumask_of_cpu (cpu),RESCHEDULE_VECTOR ); +send_IPI_mask (cpumask_of (cpu),RESCHEDULE_VECTOR ); }void native_send_call_func_single_ipi (int cpu) { -send_IPI_mask (&cpumask_of_cpu (cpu),CALL_FUNCTION_SINGLE_VECTOR ); +send_IPI_mask (cpumask_of (cpu),CALL_FUNCTION_SINGLE_VECTOR ); } -void native_send_call_func_ipi (const cpumask_t *mask) +void native_send_call_func_ipi (const struct cpumask *mask) {cpumask_t allbutself;
arch/x86/xen/smp.c +6 -5
@@ -411,22 +411,23 @@ static void xen_smp_send_reschedule(int cpu)xen_send_IPI_one (cpu,XEN_RESCHEDULE_VECTOR ); } -static void xen_send_IPI_mask (const cpumask_t *mask,enum ipi_vector vector) +static void xen_send_IPI_mask (const struct cpumask *mask, +enum ipi_vector vector) {unsigned cpu; -for_each_cpu_and (cpu, mask, &cpu_online_map) +for_each_cpu_and (cpu, mask, cpu_online_mask)xen_send_IPI_one (cpu, vector); } -static void xen_smp_send_call_function_ipi (const cpumask_t *mask) +static void xen_smp_send_call_function_ipi (const struct cpumask *mask) {int cpu;xen_send_IPI_mask (mask,XEN_CALL_FUNCTION_VECTOR );/* Make sure other vcpus get a chance to run if they need to. */ -for_each_cpu_mask_nr (cpu, *mask) { +for_each_cpu (cpu, mask) {if (xen_vcpu_stolen (cpu)) {HYPERVISOR_sched_op (SCHEDOP_yield,0 );break ;
@@ -436,7 +437,7 @@ static void xen_smp_send_call_function_ipi(const cpumask_t *mask)static void xen_smp_send_call_function_single_ipi (int cpu) { -xen_send_IPI_mask (&cpumask_of_cpu (cpu), +xen_send_IPI_mask (cpumask_of (cpu),XEN_CALL_FUNCTION_SINGLE_VECTOR ); }
Signature · 3 lines
1.6.0 --
PATCH 10/16 x86: Set CONFIG_NR_CPUS even on UP
In reply to Mike TravisImpact: cleanup
--- arch/x86/Kconfig | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/Kconfig +3 -3
@@ -589,12 +589,12 @@ config MAXSMP If unsure, say N. config NR_CPUS - depends on SMP int "Maximum number of CPUs" if SMP && !MAXSMP range 2 512 if SMP && !MAXSMP + default "1" if !SMP default "4096" if MAXSMP - default "32" if X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000 - default "8" + default "32" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000) + default "8" if SMP help This allows you to specify the maximum number of CPUs which this kernel will support. The maximum supported value is 512 and the
Signature · 3 lines
1.6.0 --
PATCH 11/16 x86: prepare for cpumask iterators to only go to nr_cpu_ids
In reply to Mike TravisImpact: cleanup, futureproof
In fact, all cpumask ops will only be valid (in general) for bit numbers < nr_cpu_ids. So use that instead of NR_CPUS in various places.
This is always safe: no cpu number can be >= nr_cpu_ids, and nr_cpu_ids is initialized to NR_CPUS at boot.
--- arch/x86/kernel/apic.c | 2 +- arch/x86/mach-voyager/voyager_smp.c | 2 +- arch/x86/mm/numa_64.c | 4 ++-- arch/x86/mm/srat_64.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/apic.c +1 -1
@@ -2106,7 +2106,7 @@ __cpuinit int apic_is_clustered_box(void) bios_cpu_apicid =early_per_cpu_ptr (x86_bios_cpu_apicid);bitmap_zero (clustermap,NUM_APIC_CLUSTERS ); -for (i =0 ; i <NR_CPUS ; i++) { +for (i =0 ; i < nr_cpu_ids; i++) {/* are we being called early in kernel startup? */ if (bios_cpu_apicid) { id = bios_cpu_apicid[i];
arch/x86/mach-voyager/voyager_smp.c +1 -1
@@ -672,7 +672,7 @@ void __init smp_boot_cpus(void)/* loop over all the extended VIC CPUs and boot them. The * Quad CPUs must be bootstrapped by their extended VIC cpu */ -for (i =0 ; i <NR_CPUS ; i++) { +for (i =0 ; i < nr_cpu_ids; i++) {if (i == boot_cpu_id || !cpu_isset (i, phys_cpu_present_map))continue ;do_boot_cpu (i);
arch/x86/mm/numa_64.c +2 -2
@@ -278,7 +278,7 @@ void __init numa_init_array(void)int rr, i; rr =first_node (node_online_map); -for (i =0 ; i <NR_CPUS ; i++) { +for (i =0 ; i < nr_cpu_ids; i++) {if (early_cpu_to_node (i) !=NUMA_NO_NODE )continue ;numa_set_node (i, rr);
@@ -549,7 +549,7 @@ void __init initmem_init(unsigned long start_pfn, unsigned long last_pfn) memnodemap[0 ] =0 ;node_set_online (0 );node_set (0 , node_possible_map); -for (i =0 ; i <NR_CPUS ; i++) +for (i =0 ; i < nr_cpu_ids; i++)numa_set_node (i,0 );e820_register_active_regions (0 , start_pfn, last_pfn);setup_node_bootmem (0 , start_pfn <<PAGE_SHIFT , last_pfn <<PAGE_SHIFT );
arch/x86/mm/srat_64.c +1 -1
@@ -382,7 +382,7 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)if (!node_online (i))setup_node_bootmem (i, nodes[i].start, nodes[i].end); -for (i =0 ; i <NR_CPUS ; i++) { +for (i =0 ; i < nr_cpu_ids; i++) {int node =early_cpu_to_node (i);if (node ==NUMA_NO_NODE )
Signature · 3 lines
1.6.0 --
PATCH 12/16 x86: Use cpumask accessors code for possible/present maps.
In reply to Mike TravisImpact: use new API
Use the accessors rather than frobbing bits directly. Most of this is in arch code I haven't even compiled, but is straightforward.
--- arch/x86/kernel/apic.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/apic.c +2 -2
@@ -1903,8 +1903,8 @@ void __cpuinit generic_processor_info(int apicid, int version) }#endif -cpu_set (cpu, cpu_possible_map); -cpu_set (cpu, cpu_present_map); +set_cpu_possible (cpu, true); +set_cpu_present (cpu, true); }#ifdef CONFIG_X86_64
Signature · 3 lines
1.6.0 --
PATCH 13/16 x86: Remove cpumask games in x86/kernel/cpu/intel_cacheinfo.c
In reply to Mike TravisImpact: remove cpumask_t from stack.
We should not try to save and restore cpus_allowed on current.
We can't use work_on_cpu() here, since it's in the hotplug cpu path (if anyone else tries to get the hotplug lock from a workqueue we could deadlock against them).
Fortunately, we can just use smp_call_function_single() since the function can run from an interrupt.
--- arch/x86/kernel/cpu/intel_cacheinfo.c | 41 +++++++++++++++----------------- 1 files changed, 19 insertions(+), 22 deletions(-)
arch/x86/kernel/cpu/intel_cacheinfo.c +19 -22
@@ -534,31 +534,16 @@ static void __cpuinit free_cache_attributes(unsigned int cpu)per_cpu (cpuid4_info, cpu) =NULL ; } -static int __cpuinit detect_cache_attributes (unsigned int cpu) +static void get_cpu_leaves (void *_retval) { -struct _cpuid4_info *this_leaf; -unsigned long j; -int retval; -cpumask_t oldmask; - -if (num_cache_leaves ==0 ) -return -ENOENT ; - -per_cpu (cpuid4_info, cpu) =kzalloc ( -sizeof (struct _cpuid4_info ) * num_cache_leaves,GFP_KERNEL ); -if (per_cpu (cpuid4_info, cpu) ==NULL ) -return -ENOMEM ; - - oldmask = current->cpus_allowed; - retval =set_cpus_allowed_ptr (current, &cpumask_of_cpu (cpu)); -if (retval) - goto out; +int j, *retval = _retval, cpu =smp_processor_id ();/* Do cpuid and store the results */ for (j =0 ; j < num_cache_leaves; j++) { +struct _cpuid4_info *this_leaf; this_leaf =CPUID4_INFO_IDX (cpu, j); - retval =cpuid4_cache_lookup (j, this_leaf); -if (unlikely (retval <0 )) { + *retval =cpuid4_cache_lookup (j, this_leaf); +if (unlikely (*retval <0 )) {int i;for (i =0 ; i < j; i++)
@@ -567,9 +552,21 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu) }cache_shared_cpu_map_setup (cpu, j); } -set_cpus_allowed_ptr (current, &oldmask); +} + +static int __cpuinit detect_cache_attributes (unsigned int cpu) +{ +int retval; + +if (num_cache_leaves ==0 ) +return -ENOENT ; + +per_cpu (cpuid4_info, cpu) =kzalloc ( +sizeof (struct _cpuid4_info ) * num_cache_leaves,GFP_KERNEL ); +if (per_cpu (cpuid4_info, cpu) ==NULL ) +return -ENOMEM ; -out: +smp_call_function_single (cpu, get_cpu_leaves, &retval, true);if (retval) {kfree (per_cpu (cpuid4_info, cpu));per_cpu (cpuid4_info, cpu) =NULL ;
Signature · 3 lines
1.6.0 --
PATCH 14/16 x86: use work_on_cpu in x86/kernel/cpu/mcheck/mce_amd_64.c
In reply to Mike TravisImpact: Remove cpumask_t's from stack.
Simple transition to work_on_cpu(), rather than cpumask games.
--- arch/x86/kernel/cpu/mcheck/mce_amd_64.c | 108 ++++++++++++++++--------------- 1 files changed, 55 insertions(+), 53 deletions(-)
arch/x86/kernel/cpu/mcheck/mce_amd_64.c +55 -53
@@ -83,34 +83,41 @@ static DEFINE_PER_CPU(unsigned char, bank_map); /* see which banks are on */* CPU Initialization */ +struct thresh_restart { +struct threshold_block *b; +int reset; +u16 old_limit; +}; +/* must be called with correct cpu affinity */ -static void threshold_restart_bank (struct threshold_block *b, -int reset,u16 old_limit) +static long threshold_restart_bank (void *_tr) { +struct thresh_restart *tr = _tr;u32 mci_misc_hi, mci_misc_lo; -rdmsr (b->address, mci_misc_lo, mci_misc_hi); +rdmsr (tr->b->address, mci_misc_lo, mci_misc_hi); -if (b->threshold_limit < (mci_misc_hi &THRESHOLD_MAX )) - reset =1 ;/* limit cannot be lower than err count */ +if (tr->b->threshold_limit < (mci_misc_hi &THRESHOLD_MAX )) + tr->reset =1 ;/* limit cannot be lower than err count */ -if (reset) {/* reset err count and overflow bit */ +if (tr->reset) {/* reset err count and overflow bit */ mci_misc_hi = (mci_misc_hi & ~(MASK_ERR_COUNT_HI |MASK_OVERFLOW_HI )) | - (THRESHOLD_MAX - b->threshold_limit); - }else if (old_limit) {/* change limit w/o reset */ + (THRESHOLD_MAX - tr->b->threshold_limit); + }else if (tr->old_limit) {/* change limit w/o reset */ int new_count = (mci_misc_hi &THRESHOLD_MAX ) + - (old_limit - b->threshold_limit); + (tr->old_limit - tr->b->threshold_limit); mci_misc_hi = (mci_misc_hi & ~MASK_ERR_COUNT_HI ) | (new_count &THRESHOLD_MAX ); } - b->interrupt_enable ? + tr->b->interrupt_enable ? (mci_misc_hi = (mci_misc_hi & ~MASK_INT_TYPE_HI ) |INT_TYPE_APIC ) : (mci_misc_hi &= ~MASK_INT_TYPE_HI ); mci_misc_hi |=MASK_COUNT_EN_HI ; -wrmsr (b->address, mci_misc_lo, mci_misc_hi); +wrmsr (tr->b->address, mci_misc_lo, mci_misc_hi); +return 0 ; }/* cpu init entry point, called from mce.c with preempt off */
@@ -120,6 +127,7 @@ void __cpuinit mce_amd_feature_init(struct cpuinfo_x86 *c)unsigned int cpu =smp_processor_id ();u8 lvt_off;u32 low =0 , high =0 , address =0 ; +struct thresh_restart tr;for (bank =0 ; bank <NR_BANKS ; ++bank) {for (block =0 ; block <NR_BLOCKS ; ++block) {
@@ -162,7 +170,10 @@ void __cpuinit mce_amd_feature_init(struct cpuinfo_x86 *c)wrmsr (address, low, high); threshold_defaults.address = address; -threshold_restart_bank (&threshold_defaults,0 ,0 ); + tr.b = &threshold_defaults; + tr.reset =0 ; + tr.old_limit =0 ; +threshold_restart_bank (&tr); } } }
@@ -251,20 +262,6 @@ struct threshold_attr {ssize_t (*store) (struct threshold_block *,const char *,size_t count); }; -static void affinity_set (unsigned int cpu,cpumask_t *oldmask, -cpumask_t *newmask) -{ - *oldmask = current->cpus_allowed; -cpus_clear (*newmask); -cpu_set (cpu, *newmask); -set_cpus_allowed_ptr (current, newmask); -} - -static void affinity_restore (const cpumask_t *oldmask) -{ -set_cpus_allowed_ptr (current, oldmask); -} -#define SHOW_FIELDS (name) \ static ssize_t show_ ## name(struct threshold_block * b, char *buf) \ { \
@@ -277,15 +274,16 @@ static ssize_t store_interrupt_enable(struct threshold_block *b, const char *buf, size_t count) { char *end; -cpumask_t oldmask, newmask; +struct thresh_restart tr;unsigned long new =simple_strtoul (buf, &end,0 );if (end == buf)return -EINVAL ; b->interrupt_enable = !!new; -affinity_set (b->cpu, &oldmask, &newmask); -threshold_restart_bank (b,0 ,0 ); -affinity_restore (&oldmask); + tr.b = b; + tr.reset =0 ; + tr.old_limit =0 ; +work_on_cpu (b->cpu, threshold_restart_bank, &tr);return end - buf; }
@@ -294,8 +292,7 @@ static ssize_t store_threshold_limit(struct threshold_block *b, const char *buf, size_t count) { char *end; -cpumask_t oldmask, newmask; -u16 old; +struct thresh_restart tr;unsigned long new =simple_strtoul (buf, &end,0 );if (end == buf)return -EINVAL ;
@@ -303,34 +300,36 @@ static ssize_t store_threshold_limit(struct threshold_block *b, new =THRESHOLD_MAX ;if (new <1 ) new =1 ; - old = b->threshold_limit; + tr.old_limit = b->threshold_limit; b->threshold_limit = new; + tr.b = b; + tr.reset =0 ; -affinity_set (b->cpu, &oldmask, &newmask); -threshold_restart_bank (b,0 , old); -affinity_restore (&oldmask); +work_on_cpu (b->cpu, threshold_restart_bank, &tr);return end - buf; } -static ssize_t show_error_count (struct threshold_block *b,char *buf) +static long local_error_count (void *_b) { -u32 high, low; -cpumask_t oldmask, newmask; -affinity_set (b->cpu, &oldmask, &newmask); +struct threshold_block *b = _b; +u32 low, high; +rdmsr (b->address, low, high); -affinity_restore (&oldmask); -return sprintf (buf,"%x\n" , - (high &0xFFF ) - (THRESHOLD_MAX - b->threshold_limit)); +return (high &0xFFF ) - (THRESHOLD_MAX - b->threshold_limit); +} + +static ssize_t show_error_count (struct threshold_block *b,char *buf) +{ +return sprintf (buf,"%lx\n" ,work_on_cpu (b->cpu, local_error_count, b)); }static ssize_t store_error_count (struct threshold_block *b,const char *buf,size_t count) { -cpumask_t oldmask, newmask; -affinity_set (b->cpu, &oldmask, &newmask); -threshold_restart_bank (b,1 ,0 ); -affinity_restore (&oldmask); +struct thresh_restart tr = { .b = b, .reset =1 , .old_limit =0 }; + +work_on_cpu (b->cpu, threshold_restart_bank, &tr);return 1 ; }
@@ -463,12 +462,19 @@ out_free:return err; } +static long local_allocate_threshold_blocks (void *_bank) +{ +unsigned int *bank = _bank; + +return allocate_threshold_blocks (smp_processor_id (), *bank,0 , +MSR_IA32_MC0_MISC + *bank *4 ); +} +/* symlinks sibling shared banks to first core. first core owns dir/files. */ static __cpuinit int threshold_create_bank (unsigned int cpu,unsigned int bank) {int i, err =0 ;struct threshold_bank *b =NULL ; -cpumask_t oldmask, newmask;char name[32 ];sprintf (name,"threshold_bank%i" , bank);
@@ -519,11 +525,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)per_cpu (threshold_banks, cpu)[bank] = b; -affinity_set (cpu, &oldmask, &newmask); - err =allocate_threshold_blocks (cpu, bank,0 , -MSR_IA32_MC0_MISC + bank *4 ); -affinity_restore (&oldmask); - + err =work_on_cpu (cpu, local_allocate_threshold_blocks, &bank);if (err) goto out_free;
Signature · 3 lines
1.6.0 --
PATCH 15/16 x86: xen: use smp_call_function_many()
In reply to Mike TravisImpact: use new API, remove cpumask from stack.
Change smp_call_function_mask() callers to smp_call_function_many().
This removes a cpumask from the stack, and falls back should allocating the cpumask var fail (only possible with CONFIG_CPUMASKS_OFFSTACK).
--- arch/x86/xen/mmu.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-)
arch/x86/xen/mmu.c +15 -5
@@ -1079,7 +1079,7 @@ static void drop_other_mm_ref(void *info)static void xen_drop_mm_ref (struct mm_struct *mm) { -cpumask_t mask; +cpumask_var_t mask;unsigned cpu;if (current->active_mm == mm) {
@@ -1091,7 +1091,16 @@ static void xen_drop_mm_ref(struct mm_struct *mm) }/* Get the "official" set of cpus referring to our pagetable. */ - mask = mm->cpu_vm_mask; +if (!alloc_cpumask_var (&mask,GFP_ATOMIC )) { +for_each_online_cpu (cpu) { +if (!cpumask_test_cpu (cpu, &mm->cpu_vm_mask) + &&per_cpu (xen_current_cr3, cpu) !=__pa (mm->pgd)) +continue ; +smp_call_function_single (cpu, drop_other_mm_ref, mm,1 ); + } +return ; + } +cpumask_copy (mask, &mm->cpu_vm_mask);/* It's possible that a vcpu may have a stale reference to our cr3, because its in lazy mode, and it hasn't yet flushed
@@ -1100,11 +1109,12 @@ static void xen_drop_mm_ref(struct mm_struct *mm)if needed. */ for_each_online_cpu (cpu) {if (per_cpu (xen_current_cr3, cpu) ==__pa (mm->pgd)) -cpu_set (cpu, mask); +cpumask_set_cpu (cpu, mask); } -if (!cpus_empty (mask)) - smp_call_function_mask(mask, drop_other_mm_ref, mm, 1); +if (!cpumask_empty (mask)) +smp_call_function_many (mask, drop_other_mm_ref, mm,1 ); + free_cpumask_var(mask); }#else static void xen_drop_mm_ref (struct mm_struct *mm)
Signature · 3 lines
1.6.0 --
PATCH 16/16 x86: Introduce topology_core_cpumask()/topology_thread_cpumask()
In reply to Mike TravisImpact: new API
The old topology_core_siblings() and topology_thread_siblings() return a cpumask_t; these new ones return a (const) struct cpumask *.
--- arch/x86/include/asm/topology.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/x86/include/asm/topology.h +2 -0
@@ -226,6 +226,8 @@ extern cpumask_t cpu_coregroup_map(int cpu);#define topology_core_id (cpu) (cpu_data(cpu).cpu_core_id)#define topology_core_siblings (cpu) (per_cpu(cpu_core_map, cpu))#define topology_thread_siblings (cpu) (per_cpu(cpu_sibling_map, cpu)) +#define topology_core_cpumask (cpu) (&per_cpu(cpu_core_map, cpu)) +#define topology_thread_cpumask (cpu) (&per_cpu(cpu_sibling_map, cpu))/* indicates that pointers to the topology cpumask_t maps are valid */ #define arch_provides_topology_pointers yes
Signature · 3 lines
1.6.0 --