Skip to content

Commit 5a021df

Browse files
committed
KVM: arm64: vgic: Use xarray to find LPI in vgic_get_lpi()
Iterating over the LPI linked-list is less than ideal when the desired index is already known. Use the INTID to index the LPI xarray instead. Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 1d6f83f commit 5a021df

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

arch/arm64/kvm/vgic/vgic.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ struct vgic_global kvm_vgic_global_state __ro_after_init = {
5555
*/
5656

5757
/*
58-
* Iterate over the VM's list of mapped LPIs to find the one with a
59-
* matching interrupt ID and return a reference to the IRQ structure.
58+
* Index the VM's xarray of mapped LPIs and return a reference to the IRQ
59+
* structure. The caller is expected to call vgic_put_irq() later once it's
60+
* finished with the IRQ.
6061
*/
6162
static struct vgic_irq *vgic_get_lpi(struct kvm *kvm, u32 intid)
6263
{
@@ -66,20 +67,10 @@ static struct vgic_irq *vgic_get_lpi(struct kvm *kvm, u32 intid)
6667

6768
raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
6869

69-
list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) {
70-
if (irq->intid != intid)
71-
continue;
72-
73-
/*
74-
* This increases the refcount, the caller is expected to
75-
* call vgic_put_irq() later once it's finished with the IRQ.
76-
*/
70+
irq = xa_load(&dist->lpi_xa, intid);
71+
if (irq)
7772
vgic_get_irq_kref(irq);
78-
goto out_unlock;
79-
}
80-
irq = NULL;
8173

82-
out_unlock:
8374
raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
8475

8576
return irq;

0 commit comments

Comments
 (0)