[PATCH 2/3] smp: speed up cpu_count()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <avi@xxxxxxxxxx>
---
 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux