diff options
author | Alexander Gordeev <agordeev@redhat.com> | 2012-06-14 03:49:35 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-06-14 06:53:13 -0400 |
commit | a5a391561bc25898ba1a702a0c4b028aa5b11ce9 (patch) | |
tree | cffb5bfe08a132cfe8e2fe24e6cf860fd6b77284 /arch/x86/kernel | |
parent | cac4afbc3da58d9e5701b34bd4c1f11ea13328d4 (diff) |
x86/apic: Eliminate cpu_mask_to_apicid() operation
Since there are only two locations where cpu_mask_to_apicid() is
called from, remove the operation and use only
cpu_mask_to_apicid_and() instead.
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Suggested-and-acked-by: Suresh Siddha <suresh.b.siddha@intel.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/20120614074935.GE3383@dhcp-26-207.brq.redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r-- | arch/x86/kernel/apic/apic.c | 24 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic_flat_64.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic_noop.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic_numachip.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/apic/bigsmp_32.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/apic/es7000_32.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/apic/numaq_32.c | 8 | ||||
-rw-r--r-- | arch/x86/kernel/apic/probe_32.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/apic/summit_32.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/apic/x2apic_cluster.c | 17 | ||||
-rw-r--r-- | arch/x86/kernel/apic/x2apic_phys.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/apic/x2apic_uv_x.c | 29 |
13 files changed, 16 insertions, 79 deletions
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 7e9bbe73bc5a..048a4f806d46 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c | |||
@@ -2123,23 +2123,6 @@ void default_init_apic_ldr(void) | |||
2123 | apic_write(APIC_LDR, val); | 2123 | apic_write(APIC_LDR, val); |
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | static inline int __default_cpu_to_apicid(int cpu, unsigned int *apicid) | ||
2127 | { | ||
2128 | if (likely((unsigned int)cpu < nr_cpu_ids)) { | ||
2129 | *apicid = per_cpu(x86_cpu_to_apicid, cpu); | ||
2130 | return 0; | ||
2131 | } else { | ||
2132 | return -EINVAL; | ||
2133 | } | ||
2134 | } | ||
2135 | |||
2136 | int default_cpu_mask_to_apicid(const struct cpumask *cpumask, | ||
2137 | unsigned int *apicid) | ||
2138 | { | ||
2139 | int cpu = cpumask_first_and(cpumask, cpu_online_mask); | ||
2140 | return __default_cpu_to_apicid(cpu, apicid); | ||
2141 | } | ||
2142 | |||
2143 | int default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 2126 | int default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
2144 | const struct cpumask *andmask, | 2127 | const struct cpumask *andmask, |
2145 | unsigned int *apicid) | 2128 | unsigned int *apicid) |
@@ -2151,7 +2134,12 @@ int default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | |||
2151 | break; | 2134 | break; |
2152 | } | 2135 | } |
2153 | 2136 | ||
2154 | return __default_cpu_to_apicid(cpu, apicid); | 2137 | if (likely((unsigned int)cpu < nr_cpu_ids)) { |
2138 | *apicid = per_cpu(x86_cpu_to_apicid, cpu); | ||
2139 | return 0; | ||
2140 | } else { | ||
2141 | return -EINVAL; | ||
2142 | } | ||
2155 | } | 2143 | } |
2156 | 2144 | ||
2157 | /* | 2145 | /* |
diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c index bddc92566d0a..00c77cf78e9e 100644 --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c | |||
@@ -191,7 +191,6 @@ static struct apic apic_flat = { | |||
191 | .set_apic_id = set_apic_id, | 191 | .set_apic_id = set_apic_id, |
192 | .apic_id_mask = 0xFFu << 24, | 192 | .apic_id_mask = 0xFFu << 24, |
193 | 193 | ||
194 | .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, | ||
195 | .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, | 194 | .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, |
196 | 195 | ||
197 | .send_IPI_mask = flat_send_IPI_mask, | 196 | .send_IPI_mask = flat_send_IPI_mask, |
@@ -308,7 +307,6 @@ static struct apic apic_physflat = { | |||
308 | .set_apic_id = set_apic_id, | 307 | .set_apic_id = set_apic_id, |
309 | .apic_id_mask = 0xFFu << 24, | 308 | .apic_id_mask = 0xFFu << 24, |
310 | 309 | ||
311 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, | ||
312 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, | 310 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
313 | 311 | ||
314 | .send_IPI_mask = physflat_send_IPI_mask, | 312 | .send_IPI_mask = physflat_send_IPI_mask, |
diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c index ac9edf247b15..65c07fc630a1 100644 --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c | |||
@@ -159,7 +159,6 @@ struct apic apic_noop = { | |||
159 | .set_apic_id = NULL, | 159 | .set_apic_id = NULL, |
160 | .apic_id_mask = 0x0F << 24, | 160 | .apic_id_mask = 0x0F << 24, |
161 | 161 | ||
162 | .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, | ||
163 | .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, | 162 | .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, |
164 | 163 | ||
165 | .send_IPI_mask = noop_send_IPI_mask, | 164 | .send_IPI_mask = noop_send_IPI_mask, |
diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c index c028132ad358..bc552cff2578 100644 --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c | |||
@@ -234,7 +234,6 @@ static struct apic apic_numachip __refconst = { | |||
234 | .set_apic_id = set_apic_id, | 234 | .set_apic_id = set_apic_id, |
235 | .apic_id_mask = 0xffU << 24, | 235 | .apic_id_mask = 0xffU << 24, |
236 | 236 | ||
237 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, | ||
238 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, | 237 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
239 | 238 | ||
240 | .send_IPI_mask = numachip_send_IPI_mask, | 239 | .send_IPI_mask = numachip_send_IPI_mask, |
diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c index df342fe4d6aa..d50e3640d5ae 100644 --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c | |||
@@ -188,7 +188,6 @@ static struct apic apic_bigsmp = { | |||
188 | .set_apic_id = NULL, | 188 | .set_apic_id = NULL, |
189 | .apic_id_mask = 0xFF << 24, | 189 | .apic_id_mask = 0xFF << 24, |
190 | 190 | ||
191 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, | ||
192 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, | 191 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
193 | 192 | ||
194 | .send_IPI_mask = bigsmp_send_IPI_mask, | 193 | .send_IPI_mask = bigsmp_send_IPI_mask, |
diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c index b35cfb9b6962..2c5317ea1b83 100644 --- a/arch/x86/kernel/apic/es7000_32.c +++ b/arch/x86/kernel/apic/es7000_32.c | |||
@@ -525,7 +525,7 @@ static int es7000_check_phys_apicid_present(int cpu_physical_apicid) | |||
525 | return 1; | 525 | return 1; |
526 | } | 526 | } |
527 | 527 | ||
528 | static int | 528 | static inline int |
529 | es7000_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id) | 529 | es7000_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id) |
530 | { | 530 | { |
531 | unsigned int round = 0; | 531 | unsigned int round = 0; |
@@ -643,7 +643,6 @@ static struct apic __refdata apic_es7000_cluster = { | |||
643 | .set_apic_id = NULL, | 643 | .set_apic_id = NULL, |
644 | .apic_id_mask = 0xFF << 24, | 644 | .apic_id_mask = 0xFF << 24, |
645 | 645 | ||
646 | .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid, | ||
647 | .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, | 646 | .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, |
648 | 647 | ||
649 | .send_IPI_mask = es7000_send_IPI_mask, | 648 | .send_IPI_mask = es7000_send_IPI_mask, |
@@ -710,7 +709,6 @@ static struct apic __refdata apic_es7000 = { | |||
710 | .set_apic_id = NULL, | 709 | .set_apic_id = NULL, |
711 | .apic_id_mask = 0xFF << 24, | 710 | .apic_id_mask = 0xFF << 24, |
712 | 711 | ||
713 | .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid, | ||
714 | .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, | 712 | .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, |
715 | 713 | ||
716 | .send_IPI_mask = es7000_send_IPI_mask, | 714 | .send_IPI_mask = es7000_send_IPI_mask, |
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 0deb773404e5..0540f083f452 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -1492,7 +1492,8 @@ static void __init setup_timer_IRQ0_pin(unsigned int ioapic_idx, | |||
1492 | * We use logical delivery to get the timer IRQ | 1492 | * We use logical delivery to get the timer IRQ |
1493 | * to the first CPU. | 1493 | * to the first CPU. |
1494 | */ | 1494 | */ |
1495 | if (unlikely(apic->cpu_mask_to_apicid(apic->target_cpus(), &dest))) | 1495 | if (unlikely(apic->cpu_mask_to_apicid_and(apic->target_cpus(), |
1496 | apic->target_cpus(), &dest))) | ||
1496 | dest = BAD_APICID; | 1497 | dest = BAD_APICID; |
1497 | 1498 | ||
1498 | entry.dest_mode = apic->irq_dest_mode; | 1499 | entry.dest_mode = apic->irq_dest_mode; |
diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c index 2b55514c328b..d661ee95cabf 100644 --- a/arch/x86/kernel/apic/numaq_32.c +++ b/arch/x86/kernel/apic/numaq_32.c | |||
@@ -407,13 +407,6 @@ static inline int numaq_check_phys_apicid_present(int phys_apicid) | |||
407 | * physical broadcast to stop people from breaking us | 407 | * physical broadcast to stop people from breaking us |
408 | */ | 408 | */ |
409 | static int | 409 | static int |
410 | numaq_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *apicid) | ||
411 | { | ||
412 | *apicid = 0x0F; | ||
413 | return 0; | ||
414 | } | ||
415 | |||
416 | static int | ||
417 | numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 410 | numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
418 | const struct cpumask *andmask, | 411 | const struct cpumask *andmask, |
419 | unsigned int *apicid) | 412 | unsigned int *apicid) |
@@ -499,7 +492,6 @@ static struct apic __refdata apic_numaq = { | |||
499 | .set_apic_id = NULL, | 492 | .set_apic_id = NULL, |
500 | .apic_id_mask = 0x0F << 24, | 493 | .apic_id_mask = 0x0F << 24, |
501 | 494 | ||
502 | .cpu_mask_to_apicid = numaq_cpu_mask_to_apicid, | ||
503 | .cpu_mask_to_apicid_and = numaq_cpu_mask_to_apicid_and, | 495 | .cpu_mask_to_apicid_and = numaq_cpu_mask_to_apicid_and, |
504 | 496 | ||
505 | .send_IPI_mask = numaq_send_IPI_mask, | 497 | .send_IPI_mask = numaq_send_IPI_mask, |
diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c index 2c6f003b2e4b..eef6bcd1bf1e 100644 --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c | |||
@@ -108,7 +108,6 @@ static struct apic apic_default = { | |||
108 | .set_apic_id = NULL, | 108 | .set_apic_id = NULL, |
109 | .apic_id_mask = 0x0F << 24, | 109 | .apic_id_mask = 0x0F << 24, |
110 | 110 | ||
111 | .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, | ||
112 | .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, | 111 | .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, |
113 | 112 | ||
114 | .send_IPI_mask = default_send_IPI_mask_logical, | 113 | .send_IPI_mask = default_send_IPI_mask_logical, |
diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c index 79d360f6729e..bbad180f2890 100644 --- a/arch/x86/kernel/apic/summit_32.c +++ b/arch/x86/kernel/apic/summit_32.c | |||
@@ -263,7 +263,7 @@ static int summit_check_phys_apicid_present(int physical_apicid) | |||
263 | return 1; | 263 | return 1; |
264 | } | 264 | } |
265 | 265 | ||
266 | static int | 266 | static inline int |
267 | summit_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id) | 267 | summit_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *dest_id) |
268 | { | 268 | { |
269 | unsigned int round = 0; | 269 | unsigned int round = 0; |
@@ -516,7 +516,6 @@ static struct apic apic_summit = { | |||
516 | .set_apic_id = NULL, | 516 | .set_apic_id = NULL, |
517 | .apic_id_mask = 0xFF << 24, | 517 | .apic_id_mask = 0xFF << 24, |
518 | 518 | ||
519 | .cpu_mask_to_apicid = summit_cpu_mask_to_apicid, | ||
520 | .cpu_mask_to_apicid_and = summit_cpu_mask_to_apicid_and, | 519 | .cpu_mask_to_apicid_and = summit_cpu_mask_to_apicid_and, |
521 | 520 | ||
522 | .send_IPI_mask = summit_send_IPI_mask, | 521 | .send_IPI_mask = summit_send_IPI_mask, |
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c index 1885a73b7f33..943d03fc6fc4 100644 --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c | |||
@@ -97,22 +97,6 @@ static void x2apic_send_IPI_all(int vector) | |||
97 | } | 97 | } |
98 | 98 | ||
99 | static int | 99 | static int |
100 | x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *apicid) | ||
101 | { | ||
102 | int cpu = cpumask_first_and(cpumask, cpu_online_mask); | ||
103 | int i; | ||
104 | |||
105 | if (cpu >= nr_cpu_ids) | ||
106 | return -EINVAL; | ||
107 | |||
108 | *apicid = 0; | ||
109 | for_each_cpu_and(i, cpumask, per_cpu(cpus_in_cluster, cpu)) | ||
110 | *apicid |= per_cpu(x86_cpu_to_logical_apicid, i); | ||
111 | |||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | static int | ||
116 | x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 100 | x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
117 | const struct cpumask *andmask, | 101 | const struct cpumask *andmask, |
118 | unsigned int *apicid) | 102 | unsigned int *apicid) |
@@ -270,7 +254,6 @@ static struct apic apic_x2apic_cluster = { | |||
270 | .set_apic_id = x2apic_set_apic_id, | 254 | .set_apic_id = x2apic_set_apic_id, |
271 | .apic_id_mask = 0xFFFFFFFFu, | 255 | .apic_id_mask = 0xFFFFFFFFu, |
272 | 256 | ||
273 | .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, | ||
274 | .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and, | 257 | .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and, |
275 | 258 | ||
276 | .send_IPI_mask = x2apic_send_IPI_mask, | 259 | .send_IPI_mask = x2apic_send_IPI_mask, |
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c index f109388a0e80..e03a1e180e81 100644 --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c | |||
@@ -123,7 +123,6 @@ static struct apic apic_x2apic_phys = { | |||
123 | .set_apic_id = x2apic_set_apic_id, | 123 | .set_apic_id = x2apic_set_apic_id, |
124 | .apic_id_mask = 0xFFFFFFFFu, | 124 | .apic_id_mask = 0xFFFFFFFFu, |
125 | 125 | ||
126 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, | ||
127 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, | 126 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, |
128 | 127 | ||
129 | .send_IPI_mask = x2apic_send_IPI_mask, | 128 | .send_IPI_mask = x2apic_send_IPI_mask, |
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c index 307aa076bd62..026de0114d15 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c | |||
@@ -269,27 +269,6 @@ static void uv_init_apic_ldr(void) | |||
269 | { | 269 | { |
270 | } | 270 | } |
271 | 271 | ||
272 | static inline int __uv_cpu_to_apicid(int cpu, unsigned int *apicid) | ||
273 | { | ||
274 | if (likely((unsigned int)cpu < nr_cpu_ids)) { | ||
275 | *apicid = per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits; | ||
276 | return 0; | ||
277 | } else { | ||
278 | return -EINVAL; | ||
279 | } | ||
280 | } | ||
281 | |||
282 | static int | ||
283 | uv_cpu_mask_to_apicid(const struct cpumask *cpumask, unsigned int *apicid) | ||
284 | { | ||
285 | /* | ||
286 | * We're using fixed IRQ delivery, can only return one phys APIC ID. | ||
287 | * May as well be the first. | ||
288 | */ | ||
289 | int cpu = cpumask_first_and(cpumask, cpu_online_mask); | ||
290 | return __uv_cpu_to_apicid(cpu, apicid); | ||
291 | } | ||
292 | |||
293 | static int | 272 | static int |
294 | uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | 273 | uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask, |
295 | const struct cpumask *andmask, | 274 | const struct cpumask *andmask, |
@@ -306,7 +285,12 @@ uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask, | |||
306 | break; | 285 | break; |
307 | } | 286 | } |
308 | 287 | ||
309 | return __uv_cpu_to_apicid(cpu, apicid); | 288 | if (likely((unsigned int)cpu < nr_cpu_ids)) { |
289 | *apicid = per_cpu(x86_cpu_to_apicid, cpu) | uv_apicid_hibits; | ||
290 | return 0; | ||
291 | } else { | ||
292 | return -EINVAL; | ||
293 | } | ||
310 | } | 294 | } |
311 | 295 | ||
312 | static unsigned int x2apic_get_apic_id(unsigned long x) | 296 | static unsigned int x2apic_get_apic_id(unsigned long x) |
@@ -384,7 +368,6 @@ static struct apic __refdata apic_x2apic_uv_x = { | |||
384 | .set_apic_id = set_apic_id, | 368 | .set_apic_id = set_apic_id, |
385 | .apic_id_mask = 0xFFFFFFFFu, | 369 | .apic_id_mask = 0xFFFFFFFFu, |
386 | 370 | ||
387 | .cpu_mask_to_apicid = uv_cpu_mask_to_apicid, | ||
388 | .cpu_mask_to_apicid_and = uv_cpu_mask_to_apicid_and, | 371 | .cpu_mask_to_apicid_and = uv_cpu_mask_to_apicid_and, |
389 | 372 | ||
390 | .send_IPI_mask = uv_send_IPI_mask, | 373 | .send_IPI_mask = uv_send_IPI_mask, |