aboutsummaryrefslogtreecommitdiff
path: root/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-09-16 13:15:30 +0300
committerAvi Kivity <avi@redhat.com>2009-09-22 11:57:13 +0300
commitfc91da88d3cc7493562ad8dc50ed56f9f0177565 (patch)
tree5635c29cb8c9f6178c6c4a6939d7c9b367a178a7 /kvm
parenttest: set up per-cpu area (diff)
downloadqemu-kvm-fc91da88d3cc7493562ad8dc50ed56f9f0177565.tar.gz
qemu-kvm-fc91da88d3cc7493562ad8dc50ed56f9f0177565.tar.bz2
qemu-kvm-fc91da88d3cc7493562ad8dc50ed56f9f0177565.zip
test: optimize smp_id()
Rather than reading it from the APIC, read it from the per-cpu area. Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'kvm')
-rw-r--r--kvm/user/test/lib/x86/smp.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/kvm/user/test/lib/x86/smp.c b/kvm/user/test/lib/x86/smp.c
index 25f0cae03..9eface511 100644
--- a/kvm/user/test/lib/x86/smp.c
+++ b/kvm/user/test/lib/x86/smp.c
@@ -71,13 +71,21 @@ int cpu_count(void)
int smp_id(void)
{
- return apic_read(APIC_ID);
+ unsigned id;
+
+ asm ("mov %%gs:0, %0" : "=r"(id));
+ return id;
+}
+
+static void setup_smp_id(void *data)
+{
+ asm ("mov %0, %%gs:0" : : "r"(apic_id()) : "memory");
}
void on_cpu(int cpu, void (*function)(void *data), void *data)
{
spin_lock(&ipi_lock);
- if (cpu == apic_id())
+ if (cpu == smp_id())
function(data);
else {
ipi_function = function;
@@ -98,4 +106,9 @@ void smp_init(void)
void ipi_entry(void);
set_ipi_descriptor(ipi_entry);
+
+ setup_smp_id(0);
+ for (i = 1; i < cpu_count(); ++i)
+ on_cpu(i, setup_smp_id, 0);
+
}