From: Avi Kivity Subject: [PATCH 2/3] smp: speed up cpu_count() Date: Thu, 6 Jan 2011 12:48:43 +0200 Message-ID: <1294310924-14174-3-git-send-email-avi@redhat.com> References: <1294310924-14174-1-git-send-email-avi@redhat.com> Cc: Rik van Riel To: Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:56614 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752932Ab1AFKtA (ORCPT ); Thu, 6 Jan 2011 05:49:00 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p06Amxqr022794 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Jan 2011 05:49:00 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p06Amx4V000385 for ; Thu, 6 Jan 2011 05:48:59 -0500 In-Reply-To: <1294310924-14174-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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