aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@openvz.org>2011-05-19 19:45:48 -0400
committerIngo Molnar <mingo@elte.hu>2011-05-20 07:41:08 -0400
commita39d1f3f67f6a3d72b24f0d8bf9a295a27ea448e (patch)
treeaa58b457692aae263f6ae701480f4ea094c6df82 /arch/x86
parenta27d0b5e7d913b38880678ac05690f1dc737c4fd (diff)
x86, x2apic: Track the x2apic cluster sibling map
In the case of x2apic cluster mode, we can group IPI register writes based on the cluster group instead of individual per-cpu destination messages. For this purpose, track the cpu's that belong to the same x2apic cluster. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com> Cc: steiner@sgi.com Cc: yinghai@kernel.org Link: http://lkml.kernel.org/r/20110519234637.421800999@sbsiddha-MOBL3.sc.intel.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/apic/x2apic_cluster.c72
1 files changed, 70 insertions, 2 deletions
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
index b2617993de19..4b2bb1381ffa 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -11,6 +11,7 @@
11#include <asm/ipi.h> 11#include <asm/ipi.h>
12 12
13static DEFINE_PER_CPU(u32, x86_cpu_to_logical_apicid); 13static DEFINE_PER_CPU(u32, x86_cpu_to_logical_apicid);
14static DEFINE_PER_CPU(cpumask_var_t, cpus_in_cluster);
14 15
15static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id) 16static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
16{ 17{
@@ -48,6 +49,11 @@ static void
48 native_x2apic_icr_write(cfg, apicid); 49 native_x2apic_icr_write(cfg, apicid);
49} 50}
50 51
52static inline u32 x2apic_cluster(int cpu)
53{
54 return per_cpu(x86_cpu_to_logical_apicid, cpu) >> 16;
55}
56
51/* 57/*
52 * for now, we send the IPI's one by one in the cpumask. 58 * for now, we send the IPI's one by one in the cpumask.
53 * TBD: Based on the cpu mask, we can send the IPI's to the cluster group 59 * TBD: Based on the cpu mask, we can send the IPI's to the cluster group
@@ -163,14 +169,76 @@ static void x2apic_send_IPI_self(int vector)
163 169
164static void init_x2apic_ldr(void) 170static void init_x2apic_ldr(void)
165{ 171{
172 unsigned int this_cpu = smp_processor_id();
173 unsigned int cpu;
174
175 per_cpu(x86_cpu_to_logical_apicid, this_cpu) = apic_read(APIC_LDR);
176
177 __cpu_set(this_cpu, per_cpu(cpus_in_cluster, this_cpu));
178 for_each_online_cpu(cpu) {
179 if (x2apic_cluster(this_cpu) != x2apic_cluster(cpu))
180 continue;
181 __cpu_set(this_cpu, per_cpu(cpus_in_cluster, cpu));
182 __cpu_set(cpu, per_cpu(cpus_in_cluster, this_cpu));
183 }
184}
185
186 /*
187 * At CPU state changes, update the x2apic cluster sibling info.
188 */
189static int __cpuinit
190update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
191{
192 unsigned int this_cpu = (unsigned long)hcpu;
193 unsigned int cpu;
194 int err = 0;
195
196 switch (action) {
197 case CPU_UP_PREPARE:
198 if (!zalloc_cpumask_var(&per_cpu(cpus_in_cluster, this_cpu),
199 GFP_KERNEL)) {
200 err = -ENOMEM;
201 }
202 break;
203 case CPU_UP_CANCELED:
204 case CPU_UP_CANCELED_FROZEN:
205 case CPU_DEAD:
206 for_each_online_cpu(cpu) {
207 if (x2apic_cluster(this_cpu) != x2apic_cluster(cpu))
208 continue;
209 __cpu_clear(this_cpu, per_cpu(cpus_in_cluster, cpu));
210 __cpu_clear(cpu, per_cpu(cpus_in_cluster, this_cpu));
211 }
212 free_cpumask_var(per_cpu(cpus_in_cluster, this_cpu));
213 break;
214 }
215
216 return notifier_from_errno(err);
217}
218
219static struct notifier_block __refdata x2apic_cpu_notifier = {
220 .notifier_call = update_clusterinfo,
221};
222
223static int x2apic_init_cpu_notifier(void)
224{
166 int cpu = smp_processor_id(); 225 int cpu = smp_processor_id();
167 226
168 per_cpu(x86_cpu_to_logical_apicid, cpu) = apic_read(APIC_LDR); 227 zalloc_cpumask_var(&per_cpu(cpus_in_cluster, cpu), GFP_KERNEL);
228
229 BUG_ON(!per_cpu(cpus_in_cluster, cpu));
230
231 __cpu_set(cpu, per_cpu(cpus_in_cluster, cpu));
232 register_hotcpu_notifier(&x2apic_cpu_notifier);
233 return 1;
169} 234}
170 235
171static int x2apic_cluster_probe(void) 236static int x2apic_cluster_probe(void)
172{ 237{
173 return x2apic_mode; 238 if (x2apic_mode)
239 return x2apic_init_cpu_notifier();
240 else
241 return 0;
174} 242}
175 243
176struct apic apic_x2apic_cluster = { 244struct apic apic_x2apic_cluster = {