aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel/smp.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/kernel/smp.c')
-rw-r--r--arch/x86_64/kernel/smp.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index e3cdbf9a88bd..1e379ed17b1d 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -27,6 +27,7 @@
27#include <asm/mach_apic.h> 27#include <asm/mach_apic.h>
28#include <asm/mmu_context.h> 28#include <asm/mmu_context.h>
29#include <asm/proto.h> 29#include <asm/proto.h>
30#include <asm/apicdef.h>
30 31
31/* 32/*
32 * Smarter SMP flushing macros. 33 * Smarter SMP flushing macros.
@@ -413,3 +414,27 @@ asmlinkage void smp_call_function_interrupt(void)
413 atomic_inc(&call_data->finished); 414 atomic_inc(&call_data->finished);
414 } 415 }
415} 416}
417
418int safe_smp_processor_id(void)
419{
420 int apicid, i;
421
422 if (disable_apic)
423 return 0;
424
425 apicid = hard_smp_processor_id();
426 if (x86_cpu_to_apicid[apicid] == apicid)
427 return apicid;
428
429 for (i = 0; i < NR_CPUS; ++i) {
430 if (x86_cpu_to_apicid[i] == apicid)
431 return i;
432 }
433
434 /* No entries in x86_cpu_to_apicid? Either no MPS|ACPI,
435 * or called too early. Either way, we must be CPU 0. */
436 if (x86_cpu_to_apicid[0] == BAD_APICID)
437 return 0;
438
439 return 0; /* Should not happen */
440}