From: Avi Kivity <avi@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 07/30] KVM: ia64: dynamic nr online cpus
Date: Sat, 28 Feb 2009 03:41:26 +0200 [thread overview]
Message-ID: <1235785309-12835-8-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1235785309-12835-1-git-send-email-avi@redhat.com>
From: Jes Sorensen <jes@sgi.com>
Account for number of online cpus and use that in loops iterating over
the list of vpus instead of scanning the full array unconditionally.
This patch is a building block to facilitate allowing to bump up
the size of MAX_VCPUS significantly.
Signed-off-by: Jes Sorensen <jes@sgi.com>
Acked-by : Xiantao Zhang <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
arch/ia64/include/asm/kvm_host.h | 10 ++++++----
arch/ia64/kvm/kvm-ia64.c | 12 ++++++++----
arch/ia64/kvm/vcpu.c | 5 ++++-
3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
index 46f8b0e..4542651 100644
--- a/arch/ia64/include/asm/kvm_host.h
+++ b/arch/ia64/include/asm/kvm_host.h
@@ -157,10 +157,10 @@ struct kvm_vm_data {
struct kvm_vcpu_data vcpu_data[KVM_MAX_VCPUS];
};
-#define VCPU_BASE(n) KVM_VM_DATA_BASE + \
- offsetof(struct kvm_vm_data, vcpu_data[n])
-#define VM_BASE KVM_VM_DATA_BASE + \
- offsetof(struct kvm_vm_data, kvm_vm_struct)
+#define VCPU_BASE(n) (KVM_VM_DATA_BASE + \
+ offsetof(struct kvm_vm_data, vcpu_data[n]))
+#define KVM_VM_BASE (KVM_VM_DATA_BASE + \
+ offsetof(struct kvm_vm_data, kvm_vm_struct))
#define KVM_MEM_DIRTY_LOG_BASE KVM_VM_DATA_BASE + \
offsetof(struct kvm_vm_data, kvm_mem_dirty_log)
@@ -464,6 +464,8 @@ struct kvm_arch {
unsigned long metaphysical_rr4;
unsigned long vmm_init_rr;
+ int online_vcpus;
+
struct kvm_ioapic *vioapic;
struct kvm_vm_stat stat;
struct kvm_sal_data rdv_sal_data;
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index dbf527a..9c77e39 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -314,7 +314,7 @@ static struct kvm_vcpu *lid_to_vcpu(struct kvm *kvm, unsigned long id,
union ia64_lid lid;
int i;
- for (i = 0; i < KVM_MAX_VCPUS; i++) {
+ for (i = 0; i < kvm->arch.online_vcpus; i++) {
if (kvm->vcpus[i]) {
lid.val = VCPU_LID(kvm->vcpus[i]);
if (lid.id == id && lid.eid == eid)
@@ -388,7 +388,7 @@ static int handle_global_purge(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
call_data.ptc_g_data = p->u.ptc_g_data;
- for (i = 0; i < KVM_MAX_VCPUS; i++) {
+ for (i = 0; i < kvm->arch.online_vcpus; i++) {
if (!kvm->vcpus[i] || kvm->vcpus[i]->arch.mp_state ==
KVM_MP_STATE_UNINITIALIZED ||
vcpu == kvm->vcpus[i])
@@ -788,6 +788,8 @@ struct kvm *kvm_arch_create_vm(void)
return ERR_PTR(-ENOMEM);
kvm_init_vm(kvm);
+ kvm->arch.online_vcpus = 0;
+
return kvm;
}
@@ -1154,7 +1156,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
/*Initialize itc offset for vcpus*/
itc_offset = 0UL - ia64_getreg(_IA64_REG_AR_ITC);
- for (i = 0; i < KVM_MAX_VCPUS; i++) {
+ for (i = 0; i < kvm->arch.online_vcpus; i++) {
v = (struct kvm_vcpu *)((char *)vcpu +
sizeof(struct kvm_vcpu_data) * i);
v->arch.itc_offset = itc_offset;
@@ -1288,6 +1290,8 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
goto fail;
}
+ kvm->arch.online_vcpus++;
+
return vcpu;
fail:
return ERR_PTR(r);
@@ -1828,7 +1832,7 @@ struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
struct kvm_vcpu *lvcpu = kvm->vcpus[0];
int i;
- for (i = 1; i < KVM_MAX_VCPUS; i++) {
+ for (i = 1; i < kvm->arch.online_vcpus; i++) {
if (!kvm->vcpus[i])
continue;
if (lvcpu->arch.xtp > kvm->vcpus[i]->arch.xtp)
diff --git a/arch/ia64/kvm/vcpu.c b/arch/ia64/kvm/vcpu.c
index 4d8be4c..d4d2805 100644
--- a/arch/ia64/kvm/vcpu.c
+++ b/arch/ia64/kvm/vcpu.c
@@ -807,12 +807,15 @@ static inline void vcpu_set_itm(struct kvm_vcpu *vcpu, u64 val);
static void vcpu_set_itc(struct kvm_vcpu *vcpu, u64 val)
{
struct kvm_vcpu *v;
+ struct kvm *kvm;
int i;
long itc_offset = val - ia64_getreg(_IA64_REG_AR_ITC);
unsigned long vitv = VCPU(vcpu, itv);
+ kvm = (struct kvm *)KVM_VM_BASE;
+
if (vcpu->vcpu_id == 0) {
- for (i = 0; i < KVM_MAX_VCPUS; i++) {
+ for (i = 0; i < kvm->arch.online_vcpus; i++) {
v = (struct kvm_vcpu *)((char *)vcpu +
sizeof(struct kvm_vcpu_data) * i);
VMX(v, itc_offset) = itc_offset;
--
1.6.0.6
next prev parent reply other threads:[~2009-02-28 1:45 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-28 1:41 [PATCH 00/30] KVM Updates for the 2.6.30 merge window (3/3) Avi Kivity
2009-02-28 1:41 ` [PATCH 01/30] KVM: ia64: vTLB change for enabling windows 2008 boot Avi Kivity
2009-02-28 1:41 ` [PATCH 02/30] KVM: ia64: Add the support for translating PAL Call's pointer args Avi Kivity
2009-02-28 1:41 ` [PATCH 03/30] KVM: ia64: Implement some pal calls needed for windows 2008 Avi Kivity
2009-02-28 1:41 ` [PATCH 04/30] KVM: s390: Fix printk on SIGP set arch Avi Kivity
2009-02-28 1:41 ` [PATCH 05/30] KVM: s390: Fix problem state check for b2 intercepts Avi Kivity
2009-02-28 1:41 ` [PATCH 06/30] KVM: s390: Fix SIGP set prefix ioctl Avi Kivity
2009-02-28 1:41 ` Avi Kivity [this message]
2009-02-28 1:41 ` [PATCH 08/30] KVM: make irq ack notifications aware of routing table Avi Kivity
2009-02-28 1:41 ` [PATCH 09/30] x86: Add EFER descriptions for FFXSR Avi Kivity
2009-02-28 1:41 ` [PATCH 10/30] KVM: Add FFXSR support Avi Kivity
2009-02-28 1:41 ` [PATCH 11/30] KVM: Drop unused evaluations from string pio handlers Avi Kivity
2009-02-28 1:41 ` [PATCH 12/30] KVM: Use irq routing API for MSI Avi Kivity
2009-02-28 1:41 ` [PATCH 13/30] KVM: VMX: Use kvm_mmu_page_fault() handle EPT violation mmio Avi Kivity
2009-02-28 1:41 ` [PATCH 14/30] KVM: Fix kvmclock on !constant_tsc boxes Avi Kivity
2009-02-28 1:41 ` [PATCH 15/30] KVM: MMU: handle compound pages in kvm_is_mmio_pfn Avi Kivity
2009-02-28 1:41 ` [PATCH 16/30] KVM: MMU: remove redundant check in mmu_set_spte Avi Kivity
2009-02-28 1:41 ` [PATCH 17/30] KVM: MMU: remove assertion in kvm_mmu_alloc_page Avi Kivity
2009-02-28 1:41 ` [PATCH 18/30] KVM: Report IRQ injection status to userspace Avi Kivity
2009-02-28 1:41 ` [PATCH 19/30] KVM: SVM: set accessed bit for VMCB segment selectors Avi Kivity
2009-02-28 1:41 ` [PATCH 20/30] KVM: MMU: Fix another largepage memory leak Avi Kivity
2009-02-28 1:41 ` [PATCH 21/30] KVM: Report IRQ injection status for MSI delivered interrupts Avi Kivity
2009-02-28 1:41 ` [PATCH 22/30] KVM: ppc: Add emulation of E500 register mmucsr0 Avi Kivity
2009-02-28 1:41 ` [PATCH 23/30] KVM: define KVM_CAP_DEVICE_DEASSIGNMENT Avi Kivity
2009-02-28 1:41 ` [PATCH 24/30] KVM: fix kvm_vm_ioctl_deassign_device Avi Kivity
2009-02-28 1:41 ` [PATCH 25/30] ia64: Move the macro definitions related to MSI to one header file Avi Kivity
2009-02-28 1:41 ` [PATCH 26/30] KVM: ia64: Fix the build errors due to lack of macros related to MSI Avi Kivity
2009-02-28 1:41 ` [PATCH 27/30] KVM: VMX: Update necessary state when guest enters long mode Avi Kivity
2009-02-28 1:41 ` [PATCH 28/30] KVM: is_long_mode() should check for EFER.LMA Avi Kivity
2009-02-28 1:41 ` [PATCH 29/30] KVM: fix sparse warnings: context imbalance Avi Kivity
2009-02-28 1:41 ` [PATCH 30/30] KVM: fix sparse warnings: Should it be static? Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1235785309-12835-8-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome