History

KVM: vgic-v4: Track the number of VLPIs per vcpu

In order to find out whether a vcpu is likely to be the target of VLPIs (and to further optimize the way we deal with those), let's track the number of VLPIs a vcpu can receive. This gets implemented with an atomic variable that gets incremented or decremented on map, unmap and move of a VLPI.

Marc Zyngier committed 7 years ago

Commit 5bd90b01 parent 90908254 files · +8 −0Browse files

Unified · Split

4 files
  1. include/linux/irqchip/arm-gic-v4.h +2 −0
  2. virt/kvm/arm/vgic/vgic-init.c +1 −0
  3. virt/kvm/arm/vgic/vgic-its.c +3 −0
  4. virt/kvm/arm/vgic/vgic-v4.c +2 −0
include/linux/irqchip/arm-gic-v4.h+2−0
@@ -32,6 +32,8 @@ struct its_vm { · 31 unmodified lines
3232 struct its_vpe {
3333 struct page *vpt_page;
3434 struct its_vm *its_vm;
35+ /* per-vPE VLPI tracking */
36+ atomic_t vlpi_count;
3537 /* Doorbell interrupt */
3638 int irq;
3739 irq_hw_number_t vpe_db_lpi;
virt/kvm/arm/vgic/vgic-init.c+1−0
@@ -203,6 +203,7 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) · 202 unmodified lines
203203
204204 INIT_LIST_HEAD(&vgic_cpu->ap_list_head);
205205 raw_spin_lock_init(&vgic_cpu->ap_list_lock);
206+ atomic_set(&vgic_cpu->vgic_v3.its_vpe.vlpi_count, 0);
206207
207208 /*
208209 * Enable and configure all SGIs to be edge-triggered and
virt/kvm/arm/vgic/vgic-its.c+3−0
@@ -360,7 +360,10 @@ static int update_affinity(struct vgic_irq *irq, struct kvm_vcpu *vcpu) · 359 unmodified lines
360360 if (ret)
361361 return ret;
362362
363+ if (map.vpe)
364+ atomic_dec(&map.vpe->vlpi_count);
363365 map.vpe = &vcpu->arch.vgic_cpu.vgic_v3.its_vpe;
366+ atomic_inc(&map.vpe->vlpi_count);
364367
365368 ret = its_map_vlpi(irq->host_irq, &map);
366369 }
virt/kvm/arm/vgic/vgic-v4.c+2−0
@@ -309,6 +309,7 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq, · 308 unmodified lines
309309
310310 irq->hw = true;
311311 irq->host_irq = virq;
312+ atomic_inc(&map.vpe->vlpi_count);
312313
313314 out:
314315 mutex_unlock(&its->its_lock);
@@ -342,6 +343,7 @@ int kvm_vgic_v4_unset_forwarding(struct kvm *kvm, int virq, · 27 unmodified lines
342343
343344 WARN_ON(!(irq->hw && irq->host_irq == virq));
344345 if (irq->hw) {
346+ atomic_dec(&irq->target_vcpu->arch.vgic_cpu.vgic_v3.its_vpe.vlpi_count);
345347 irq->hw = false;
346348 ret = its_unmap_vlpi(virq);
347349 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t