From patchwork Mon Jul 1 06:20:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tangnianyao X-Patchwork-Id: 13717579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F267C2BD09 for ; Mon, 1 Jul 2024 06:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=KLPzwO4jlyPT2MOmqiQCOLS7BRtGi4+sqzCJ/ugHcpI=; b=4VOpQKhELIQwMhVPPI/ZkGx6eH aHEa7HDt+xIrRbebnH+ntkJE4Ipb+KO+RfQCbA82Noswe3A7kRnXaP8HN10IwW0vqRdGJDfZYlnJV EsGTjNmJUitEsjdZawFEjUK4kDOTgbZG7EUol/u+vRemJppn6YOZLVjoIbeyg+IfECbqViTDf6BAf 6BZwYb1MCL2Gnf3q1xE1064ztS5Hpt40lMuEPwl1KPz+KYLDHDGac5GWN7EIDAWa6N0CC18BP5A7W SyeyWaixFShuQ6WmLxJsNLVz56j650UTIhik0swJe08gy6G33bqZTPSrjoCkTzdNW0BEvOn61gyfX CLgCVvBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOAPt-00000001rFL-0jjb; Mon, 01 Jul 2024 06:21:33 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOAPf-00000001rBA-2skH for linux-arm-kernel@lists.infradead.org; Mon, 01 Jul 2024 06:21:22 +0000 Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WCG5d64q0z1T4Hs; Mon, 1 Jul 2024 14:16:37 +0800 (CST) Received: from kwepemd500014.china.huawei.com (unknown [7.221.188.63]) by mail.maildlp.com (Postfix) with ESMTPS id 4A370180A9C; Mon, 1 Jul 2024 14:21:08 +0800 (CST) Received: from 228-1616.huawei.com (10.67.246.68) by kwepemd500014.china.huawei.com (7.221.188.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Mon, 1 Jul 2024 14:21:07 +0800 From: Nianyao Tang To: , , , CC: , , Subject: [RESPIN PATCH] irqchip/gic-v4.1: Use local 4_1 ITS to generate VSGI Date: Mon, 1 Jul 2024 06:20:42 +0000 Message-ID: <20240701062042.4128863-1-tangnianyao@huawei.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-Originating-IP: [10.67.246.68] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemd500014.china.huawei.com (7.221.188.63) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240630_232119_967812_931C8222 X-CRM114-Status: GOOD ( 12.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 deployed 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 deployed 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 lasted 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. To use local ITS, we can get 12% reduction in IPI latency. The patch modify find_4_1_its to firstly return per-cpu local_4_1_its, which is init when inherit the VPE table from the ITS on secondary CPUs. If fail to find local 4_1 ITS, return any 4_1 ITS like before. Signed-off-by: Nianyao Tang Reviewed-by: Marc Zyngier --- 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 3c755d5dad6e..f99c0a86320b 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -119,6 +119,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) @@ -2709,6 +2711,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; } @@ -2746,6 +2750,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; } @@ -4058,8 +4064,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))