[PATCH v2 10/11] KVM: arm64: vgic-v3: Optimize affinity-based SGI injection

Zenghui Yu yuzenghui at huawei.com
Thu Sep 21 02:32:24 PDT 2023


On 2023/9/21 2:17, Marc Zyngier wrote:
> Our affinity-based SGI injection code is a bit daft. We iterate
> over all the CPUs trying to match the set of affinities that the
> guest is trying to reach, leading to some very bad behaviours
> if the selected targets are at a high vcpu index.
> 
> Instead, we can now use the fact that we have an optimised
> MPIDR to vcpu mapping, and only look at the relevant values.
> 
> This results in a much faster injection for large VMs, and
> in a near constant time, irrespective of the position in the
> vcpu index space.
> 
> As a bonus, this is mostly deleting a lot of hard-to-read
> code. Nobody will complain about that.
> 
> Suggested-by: Xu Zhao <zhaoxu.35 at bytedance.com>
> Tested-by: Joey Gouly <joey.gouly at arm.com>
> Tested-by: Shameer Kolothum <shameerali.kolothum.thodi at huawei.com>
> Signed-off-by: Marc Zyngier <maz at kernel.org>

Probably update the comment on top of vgic_v3_dispatch_sgi() to reflect
the new approach.

| * If the interrupt routing mode bit is not set, we iterate over all 
VCPUs to
| * check for matching ones. If this bit is set, we signal all, but not the
| * calling VCPU.

Zenghui



More information about the linux-arm-kernel mailing list