aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2009-01-21 09:16:43 -0500
committerAvi Kivity <avi@redhat.com>2009-03-24 05:03:07 -0400
commit934d534f8a5a39e20d5682b3a3a45ff351706b59 (patch)
treef1e6ce5330028a9aa942623c6706af8ca2ce2130 /arch/ia64
parentb7e6e4d3602c738b8f61225d9f4514945df52f07 (diff)
KVM: ia64: dynamic nr online cpus
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>
Diffstat (limited to 'arch/ia64')
-rw-r--r--arch/ia64/include/asm/kvm_host.h10
-rw-r--r--arch/ia64/kvm/kvm-ia64.c12
-rw-r--r--arch/ia64/kvm/vcpu.c5
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 46f8b0eb5684..4542651e6acb 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 {
157 struct kvm_vcpu_data vcpu_data[KVM_MAX_VCPUS]; 157 struct kvm_vcpu_data vcpu_data[KVM_MAX_VCPUS];
158}; 158};
159 159
160#define VCPU_BASE(n) KVM_VM_DATA_BASE + \ 160#define VCPU_BASE(n) (KVM_VM_DATA_BASE + \
161 offsetof(struct kvm_vm_data, vcpu_data[n]) 161 offsetof(struct kvm_vm_data, vcpu_data[n]))
162#define VM_BASE KVM_VM_DATA_BASE + \ 162#define KVM_VM_BASE (KVM_VM_DATA_BASE + \
163 offsetof(struct kvm_vm_data, kvm_vm_struct) 163 offsetof(struct kvm_vm_data, kvm_vm_struct))
164#define KVM_MEM_DIRTY_LOG_BASE KVM_VM_DATA_BASE + \ 164#define KVM_MEM_DIRTY_LOG_BASE KVM_VM_DATA_BASE + \
165 offsetof(struct kvm_vm_data, kvm_mem_dirty_log) 165 offsetof(struct kvm_vm_data, kvm_mem_dirty_log)
166 166
@@ -464,6 +464,8 @@ struct kvm_arch {
464 unsigned long metaphysical_rr4; 464 unsigned long metaphysical_rr4;
465 unsigned long vmm_init_rr; 465 unsigned long vmm_init_rr;
466 466
467 int online_vcpus;
468
467 struct kvm_ioapic *vioapic; 469 struct kvm_ioapic *vioapic;
468 struct kvm_vm_stat stat; 470 struct kvm_vm_stat stat;
469 struct kvm_sal_data rdv_sal_data; 471 struct kvm_sal_data rdv_sal_data;
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index dbf527a57341..9c77e3939e97 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,
314 union ia64_lid lid; 314 union ia64_lid lid;
315 int i; 315 int i;
316 316
317 for (i = 0; i < KVM_MAX_VCPUS; i++) { 317 for (i = 0; i < kvm->arch.online_vcpus; i++) {
318 if (kvm->vcpus[i]) { 318 if (kvm->vcpus[i]) {
319 lid.val = VCPU_LID(kvm->vcpus[i]); 319 lid.val = VCPU_LID(kvm->vcpus[i]);
320 if (lid.id == id && lid.eid == eid) 320 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)
388 388
389 call_data.ptc_g_data = p->u.ptc_g_data; 389 call_data.ptc_g_data = p->u.ptc_g_data;
390 390
391 for (i = 0; i < KVM_MAX_VCPUS; i++) { 391 for (i = 0; i < kvm->arch.online_vcpus; i++) {
392 if (!kvm->vcpus[i] || kvm->vcpus[i]->arch.mp_state == 392 if (!kvm->vcpus[i] || kvm->vcpus[i]->arch.mp_state ==
393 KVM_MP_STATE_UNINITIALIZED || 393 KVM_MP_STATE_UNINITIALIZED ||
394 vcpu == kvm->vcpus[i]) 394 vcpu == kvm->vcpus[i])
@@ -788,6 +788,8 @@ struct kvm *kvm_arch_create_vm(void)
788 return ERR_PTR(-ENOMEM); 788 return ERR_PTR(-ENOMEM);
789 kvm_init_vm(kvm); 789 kvm_init_vm(kvm);
790 790
791 kvm->arch.online_vcpus = 0;
792
791 return kvm; 793 return kvm;
792 794
793} 795}
@@ -1154,7 +1156,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
1154 1156
1155 /*Initialize itc offset for vcpus*/ 1157 /*Initialize itc offset for vcpus*/
1156 itc_offset = 0UL - ia64_getreg(_IA64_REG_AR_ITC); 1158 itc_offset = 0UL - ia64_getreg(_IA64_REG_AR_ITC);
1157 for (i = 0; i < KVM_MAX_VCPUS; i++) { 1159 for (i = 0; i < kvm->arch.online_vcpus; i++) {
1158 v = (struct kvm_vcpu *)((char *)vcpu + 1160 v = (struct kvm_vcpu *)((char *)vcpu +
1159 sizeof(struct kvm_vcpu_data) * i); 1161 sizeof(struct kvm_vcpu_data) * i);
1160 v->arch.itc_offset = itc_offset; 1162 v->arch.itc_offset = itc_offset;
@@ -1288,6 +1290,8 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
1288 goto fail; 1290 goto fail;
1289 } 1291 }
1290 1292
1293 kvm->arch.online_vcpus++;
1294
1291 return vcpu; 1295 return vcpu;
1292fail: 1296fail:
1293 return ERR_PTR(r); 1297 return ERR_PTR(r);
@@ -1828,7 +1832,7 @@ struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
1828 struct kvm_vcpu *lvcpu = kvm->vcpus[0]; 1832 struct kvm_vcpu *lvcpu = kvm->vcpus[0];
1829 int i; 1833 int i;
1830 1834
1831 for (i = 1; i < KVM_MAX_VCPUS; i++) { 1835 for (i = 1; i < kvm->arch.online_vcpus; i++) {
1832 if (!kvm->vcpus[i]) 1836 if (!kvm->vcpus[i])
1833 continue; 1837 continue;
1834 if (lvcpu->arch.xtp > kvm->vcpus[i]->arch.xtp) 1838 if (lvcpu->arch.xtp > kvm->vcpus[i]->arch.xtp)
diff --git a/arch/ia64/kvm/vcpu.c b/arch/ia64/kvm/vcpu.c
index 4d8be4c252fa..d4d280505878 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);
807static void vcpu_set_itc(struct kvm_vcpu *vcpu, u64 val) 807static void vcpu_set_itc(struct kvm_vcpu *vcpu, u64 val)
808{ 808{
809 struct kvm_vcpu *v; 809 struct kvm_vcpu *v;
810 struct kvm *kvm;
810 int i; 811 int i;
811 long itc_offset = val - ia64_getreg(_IA64_REG_AR_ITC); 812 long itc_offset = val - ia64_getreg(_IA64_REG_AR_ITC);
812 unsigned long vitv = VCPU(vcpu, itv); 813 unsigned long vitv = VCPU(vcpu, itv);
813 814
815 kvm = (struct kvm *)KVM_VM_BASE;
816
814 if (vcpu->vcpu_id == 0) { 817 if (vcpu->vcpu_id == 0) {
815 for (i = 0; i < KVM_MAX_VCPUS; i++) { 818 for (i = 0; i < kvm->arch.online_vcpus; i++) {
816 v = (struct kvm_vcpu *)((char *)vcpu + 819 v = (struct kvm_vcpu *)((char *)vcpu +
817 sizeof(struct kvm_vcpu_data) * i); 820 sizeof(struct kvm_vcpu_data) * i);
818 VMX(v, itc_offset) = itc_offset; 821 VMX(v, itc_offset) = itc_offset;