cpu_count() is used in important places, like vmexit.flat's measuring
loop, yet it is ridiculously slow as it talks to the firmware config
interface.

Speed it up by reading the value from memory.

Signed-off-by: Avi Kivity <a...@redhat.com>
---
 lib/x86/smp.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/x86/smp.c b/lib/x86/smp.c
index 8da614a..d41c332 100644
--- a/lib/x86/smp.c
+++ b/lib/x86/smp.c
@@ -78,7 +78,7 @@ void spin_unlock(struct spinlock *lock)
 
 int cpu_count(void)
 {
-    return fwcfg_get_nb_cpus();
+    return _cpu_count;
 }
 
 int smp_id(void)
@@ -130,6 +130,8 @@ void smp_init(void)
     int i;
     void ipi_entry(void);
 
+    _cpu_count = fwcfg_get_nb_cpus();
+
     set_ipi_descriptor(ipi_entry);
 
     setup_smp_id(0);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to