diff options
author | Mike Travis <travis@sgi.com> | 2008-12-16 20:33:52 -0500 |
---|---|---|
committer | Mike Travis <travis@sgi.com> | 2008-12-16 20:40:56 -0500 |
commit | e7986739a76cde5079da08809d8bbc6878387ae0 (patch) | |
tree | dd99ed6af66d459fe164f75ded7f95262dc0fb0d /arch/x86/kernel/genx2apic_phys.c | |
parent | 36f5101a60de8f79c0d1ca06e50660bf5129e02c (diff) |
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.
Signed-off-by: Mike Travis <travis@sgi.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/genx2apic_phys.c')
-rw-r--r-- | arch/x86/kernel/genx2apic_phys.c | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/arch/x86/kernel/genx2apic_phys.c b/arch/x86/kernel/genx2apic_phys.c index d042211768b7..41c27b2f3d01 100644 --- a/arch/x86/kernel/genx2apic_phys.c +++ b/arch/x86/kernel/genx2apic_phys.c | |||
@@ -29,16 +29,15 @@ static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id) | |||
29 | 29 | ||
30 | /* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */ | 30 | /* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */ |
31 | 31 | ||
32 | static cpumask_t x2apic_target_cpus(void) | 32 | static const cpumask_t *x2apic_target_cpus(void) |
33 | { | 33 | { |
34 | return cpumask_of_cpu(0); | 34 | return &cpumask_of_cpu(0); |
35 | } | 35 | } |
36 | 36 | ||
37 | static cpumask_t x2apic_vector_allocation_domain(int cpu) | 37 | static void x2apic_vector_allocation_domain(int cpu, cpumask_t *retmask) |
38 | { | 38 | { |
39 | cpumask_t domain = CPU_MASK_NONE; | 39 | cpus_clear(*retmask); |
40 | cpu_set(cpu, domain); | 40 | cpu_set(cpu, *retmask); |
41 | return domain; | ||
42 | } | 41 | } |
43 | 42 | ||
44 | static void __x2apic_send_IPI_dest(unsigned int apicid, int vector, | 43 | static void __x2apic_send_IPI_dest(unsigned int apicid, int vector, |
@@ -54,32 +53,53 @@ static void __x2apic_send_IPI_dest(unsigned int apicid, int vector, | |||
54 | x2apic_icr_write(cfg, apicid); | 53 | x2apic_icr_write(cfg, apicid); |
55 | } | 54 | } |
56 | 55 | ||
57 | static void x2apic_send_IPI_mask(cpumask_t mask, int vector) | 56 | static void x2apic_send_IPI_mask(const cpumask_t *mask, int vector) |
58 | { | 57 | { |
59 | unsigned long flags; | 58 | unsigned long flags; |
60 | unsigned long query_cpu; | 59 | unsigned long query_cpu; |
61 | 60 | ||
62 | local_irq_save(flags); | 61 | local_irq_save(flags); |
63 | for_each_cpu_mask(query_cpu, mask) { | 62 | for_each_cpu_mask_nr(query_cpu, *mask) { |
64 | __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu), | 63 | __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu), |
65 | vector, APIC_DEST_PHYSICAL); | 64 | vector, APIC_DEST_PHYSICAL); |
66 | } | 65 | } |
67 | local_irq_restore(flags); | 66 | local_irq_restore(flags); |
68 | } | 67 | } |
69 | 68 | ||
70 | static void x2apic_send_IPI_allbutself(int vector) | 69 | static void x2apic_send_IPI_mask_allbutself(const cpumask_t *mask, int vector) |
71 | { | 70 | { |
72 | cpumask_t mask = cpu_online_map; | 71 | unsigned long flags; |
72 | unsigned long query_cpu; | ||
73 | unsigned long this_cpu = smp_processor_id(); | ||
74 | |||
75 | local_irq_save(flags); | ||
76 | for_each_cpu_mask_nr(query_cpu, *mask) { | ||
77 | if (query_cpu != this_cpu) | ||
78 | __x2apic_send_IPI_dest( | ||
79 | per_cpu(x86_cpu_to_apicid, query_cpu), | ||
80 | vector, APIC_DEST_PHYSICAL); | ||
81 | } | ||
82 | local_irq_restore(flags); | ||
83 | } | ||
73 | 84 | ||
74 | cpu_clear(smp_processor_id(), mask); | 85 | static void x2apic_send_IPI_allbutself(int vector) |
86 | { | ||
87 | unsigned long flags; | ||
88 | unsigned long query_cpu; | ||
89 | unsigned long this_cpu = smp_processor_id(); | ||
75 | 90 | ||
76 | if (!cpus_empty(mask)) | 91 | local_irq_save(flags); |
77 | x2apic_send_IPI_mask(mask, vector); | 92 | for_each_online_cpu(query_cpu) |
93 | if (query_cpu != this_cpu) | ||
94 | __x2apic_send_IPI_dest( | ||
95 | per_cpu(x86_cpu_to_apicid, query_cpu), | ||
96 | vector, APIC_DEST_PHYSICAL); | ||
97 | local_irq_restore(flags); | ||
78 | } | 98 | } |
79 | 99 | ||
80 | static void x2apic_send_IPI_all(int vector) | 100 | static void x2apic_send_IPI_all(int vector) |
81 | { | 101 | { |
82 | x2apic_send_IPI_mask(cpu_online_map, vector); | 102 | x2apic_send_IPI_mask(&cpu_online_map, vector); |
83 | } | 103 | } |
84 | 104 | ||
85 | static int x2apic_apic_id_registered(void) | 105 | static int x2apic_apic_id_registered(void) |
@@ -87,7 +107,7 @@ static int x2apic_apic_id_registered(void) | |||
87 | return 1; | 107 | return 1; |
88 | } | 108 | } |
89 | 109 | ||
90 | static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask) | 110 | static unsigned int x2apic_cpu_mask_to_apicid(const cpumask_t *cpumask) |
91 | { | 111 | { |
92 | int cpu; | 112 | int cpu; |
93 | 113 | ||
@@ -95,8 +115,8 @@ static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask) | |||
95 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | 115 | * We're using fixed IRQ delivery, can only return one phys APIC ID. |
96 | * May as well be the first. | 116 | * May as well be the first. |
97 | */ | 117 | */ |
98 | cpu = first_cpu(cpumask); | 118 | cpu = first_cpu(*cpumask); |
99 | if ((unsigned)cpu < NR_CPUS) | 119 | if ((unsigned)cpu < nr_cpu_ids) |
100 | return per_cpu(x86_cpu_to_apicid, cpu); | 120 | return per_cpu(x86_cpu_to_apicid, cpu); |
101 | else | 121 | else |
102 | return BAD_APICID; | 122 | return BAD_APICID; |
@@ -145,6 +165,7 @@ struct genapic apic_x2apic_phys = { | |||
145 | .send_IPI_all = x2apic_send_IPI_all, | 165 | .send_IPI_all = x2apic_send_IPI_all, |
146 | .send_IPI_allbutself = x2apic_send_IPI_allbutself, | 166 | .send_IPI_allbutself = x2apic_send_IPI_allbutself, |
147 | .send_IPI_mask = x2apic_send_IPI_mask, | 167 | .send_IPI_mask = x2apic_send_IPI_mask, |
168 | .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself, | ||
148 | .send_IPI_self = x2apic_send_IPI_self, | 169 | .send_IPI_self = x2apic_send_IPI_self, |
149 | .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, | 170 | .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, |
150 | .phys_pkg_id = phys_pkg_id, | 171 | .phys_pkg_id = phys_pkg_id, |