Skip to content

Commit f1a3fac

Browse files
tangnianyaoKAGA-KOKO
authored andcommitted
irqchip/gic-v4.1: Use local 4_1 ITS to generate VSGI
On multi-node GICv4.1 system, VSGI senders always use one certain 4_1 ITS, because find_4_1_its() returns the first its_node in the list, regardless of which node the VSGI sender is on. This brings guest VSGI performance drop when VM is not running on the same node as this returned ITS. On a 2-socket environment, each with one ITS and 32 cpu, GICv4.1 enabled, 4U8G guest, 4 vcpu is running on same socket. When the VM is on socket0, kvm-unit-tests ipi_hw result is 850ns. When the VM is on socket1, it is 750ns. The reason is that the VSGI sender always uses the last reported ITS (that on socket1) to inject VSGI. The access from a CPU to a other-socket ITS will cost 100ns more compared to an access to the local ITS. Using the local ITS results in a 12% reduction in IPI latency. Modify find_4_1_its() to return the first per-CPU local_4_1_its, which is initialized when the VPE table is inherited from the ITS or from another CPU. If it fails to find a local 4_1 ITS, it returns any 4_1 ITS like before. Suggested-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Nianyao Tang <tangnianyao@huawei.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/all/20250515145359.2795959-1-tangnianyao@huawei.com
1 parent 96a8cb6 commit f1a3fac

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/irqchip/irq-gic-v3-its.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ struct its_node {
125125
int vlpi_redist_offset;
126126
};
127127

128+
static DEFINE_PER_CPU(struct its_node *, local_4_1_its);
129+
128130
#define is_v4(its) (!!((its)->typer & GITS_TYPER_VLPIS))
129131
#define is_v4_1(its) (!!((its)->typer & GITS_TYPER_VMAPP))
130132
#define device_ids(its) (FIELD_GET(GITS_TYPER_DEVBITS, (its)->typer) + 1)
@@ -2778,6 +2780,7 @@ static u64 inherit_vpe_l1_table_from_its(void)
27782780
}
27792781
val |= FIELD_PREP(GICR_VPROPBASER_4_1_SIZE, GITS_BASER_NR_PAGES(baser) - 1);
27802782

2783+
*this_cpu_ptr(&local_4_1_its) = its;
27812784
return val;
27822785
}
27832786

@@ -2815,6 +2818,7 @@ static u64 inherit_vpe_l1_table_from_rd(cpumask_t **mask)
28152818
gic_data_rdist()->vpe_l1_base = gic_data_rdist_cpu(cpu)->vpe_l1_base;
28162819
*mask = gic_data_rdist_cpu(cpu)->vpe_table_mask;
28172820

2821+
*this_cpu_ptr(&local_4_1_its) = *per_cpu_ptr(&local_4_1_its, cpu);
28182822
return val;
28192823
}
28202824

@@ -4180,7 +4184,7 @@ static struct irq_chip its_vpe_irq_chip = {
41804184

41814185
static struct its_node *find_4_1_its(void)
41824186
{
4183-
static struct its_node *its = NULL;
4187+
struct its_node *its = *this_cpu_ptr(&local_4_1_its);
41844188

41854189
if (!its) {
41864190
list_for_each_entry(its, &its_nodes, entry) {

0 commit comments

Comments
 (0)