* Re: [PATCH v3] irqchip/gic-v4.1: Use local 4_1 ITS to generate VSGI
2025-05-15 14:53 [PATCH v3] irqchip/gic-v4.1: Use local 4_1 ITS to generate VSGI Nianyao Tang
@ 2025-05-15 7:16 ` Marc Zyngier
0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2025-05-15 7:16 UTC (permalink / raw)
To: Nianyao Tang
Cc: tglx, linux-arm-kernel, linux-kernel, guoyang2, wangwudi,
wangzhou1
On Thu, 15 May 2025 15:53:59 +0100,
Nianyao Tang <tangnianyao@huawei.com> wrote:
>
> On multi-node GICv4.1 system, VSGI senders always use one certain 4_1 ITS,
> because find_4_1_its return the first its_node in 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 VM on socket0, kvm-unit-tests ipi_hw result is 850ns.
> When VM on socket1, it is 750ns. The reason is VSGI sender always
> use the last reported ITS(that on socket1) to inject VSGI. The access
> from cpu to other-socket ITS will cost 100ns more compared to cpu to
> local ITS.
>
> By using a local ITS, we can get 12% reduction in IPI latency.
>
> Modify find_4_1_its to first return per-cpu local_4_1_its, which is
> init when inherit the VPE table from the ITS or from another CPU.
> If fail to find local 4_1 ITS, return any 4_1 ITS like before.
>
> Signed-off-by: Nianyao Tang <tangnianyao@huawei.com>
> Suggested-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/all/87tthgrt7s.wl-maz@kernel.org
Reviewed-by: Marc Zyngier <maz@kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v3] irqchip/gic-v4.1: Use local 4_1 ITS to generate VSGI
@ 2025-05-15 14:53 Nianyao Tang
2025-05-15 7:16 ` Marc Zyngier
0 siblings, 1 reply; 2+ messages in thread
From: Nianyao Tang @ 2025-05-15 14:53 UTC (permalink / raw)
To: maz, tglx, linux-arm-kernel, linux-kernel
Cc: guoyang2, wangwudi, tangnianyao, wangzhou1
On multi-node GICv4.1 system, VSGI senders always use one certain 4_1 ITS,
because find_4_1_its return the first its_node in 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 VM on socket0, kvm-unit-tests ipi_hw result is 850ns.
When VM on socket1, it is 750ns. The reason is VSGI sender always
use the last reported ITS(that on socket1) to inject VSGI. The access
from cpu to other-socket ITS will cost 100ns more compared to cpu to
local ITS.
By using a local ITS, we can get 12% reduction in IPI latency.
Modify find_4_1_its to first return per-cpu local_4_1_its, which is
init when inherit the VPE table from the ITS or from another CPU.
If fail to find local 4_1 ITS, return any 4_1 ITS like before.
Signed-off-by: Nianyao Tang <tangnianyao@huawei.com>
Suggested-by: Marc Zyngier <maz@kernel.org>
---
drivers/irqchip/irq-gic-v3-its.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 0115ad6c8259..1b1d32f746b4 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -125,6 +125,8 @@ struct its_node {
int vlpi_redist_offset;
};
+static DEFINE_PER_CPU(struct its_node *, local_4_1_its);
+
#define is_v4(its) (!!((its)->typer & GITS_TYPER_VLPIS))
#define is_v4_1(its) (!!((its)->typer & GITS_TYPER_VMAPP))
#define device_ids(its) (FIELD_GET(GITS_TYPER_DEVBITS, (its)->typer) + 1)
@@ -2778,6 +2780,8 @@ static u64 inherit_vpe_l1_table_from_its(void)
}
val |= FIELD_PREP(GICR_VPROPBASER_4_1_SIZE, GITS_BASER_NR_PAGES(baser) - 1);
+ *this_cpu_ptr(&local_4_1_its) = its;
+
return val;
}
@@ -2815,6 +2819,8 @@ static u64 inherit_vpe_l1_table_from_rd(cpumask_t **mask)
gic_data_rdist()->vpe_l1_base = gic_data_rdist_cpu(cpu)->vpe_l1_base;
*mask = gic_data_rdist_cpu(cpu)->vpe_table_mask;
+ *this_cpu_ptr(&local_4_1_its) = *per_cpu_ptr(&local_4_1_its, cpu);
+
return val;
}
@@ -4180,8 +4186,9 @@ static struct irq_chip its_vpe_irq_chip = {
static struct its_node *find_4_1_its(void)
{
- static struct its_node *its = NULL;
+ struct its_node *its;
+ its = *this_cpu_ptr(&local_4_1_its);
if (!its) {
list_for_each_entry(its, &its_nodes, entry) {
if (is_v4_1(its))
--
2.30.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-15 7:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-15 14:53 [PATCH v3] irqchip/gic-v4.1: Use local 4_1 ITS to generate VSGI Nianyao Tang
2025-05-15 7:16 ` Marc Zyngier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).