From patchwork Mon Jun 24 12:25:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tangnianyao X-Patchwork-Id: 13709424 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 9CC8DC2BD09 for ; Mon, 24 Jun 2024 12:25:59 +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=CNyYE3y+WtR53eKiKBpAGu3US4846CvQ3q9YsY29g0Q=; b=LyoY53GVAEgEKkK7QQcx7tRygH n8VykxesogK/03YAH5xwz1AiVQK6gulZGwYqWRcb/eN1ugHR24VJWPNj2K7xVuqjCTJVVgVc12VNe 6CSC1d0fs3vlh9gmIhdAuqiMIf6qdVHYOFcfGX7Ngzfbda03AToz5i8dXUWsi2PL/FqGlKi/PQcCj +y+Coa5Fd+ZAM8OA/dDkVaeEnCCGQqjv0dq2K9N9mnkEWs1vY6+GJ17IsixATkMCa181hHrs/vUDU ddp8c25c0mJlJb9Nb15PZdicZBWkU42+GUP+5yAYod6RT0AWus+ANxpFfWAf15hJVrQWAav65f9mS yZooy2ig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLila-0000000GlTF-31Qm; Mon, 24 Jun 2024 12:25:50 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLilU-0000000GlQY-33aR for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 12:25:46 +0000 Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4W76XL4lg3zPpLQ; Mon, 24 Jun 2024 20:21:54 +0800 (CST) Received: from kwepemd500014.china.huawei.com (unknown [7.221.188.63]) by mail.maildlp.com (Postfix) with ESMTPS id F10EE140156; Mon, 24 Jun 2024 20:25:32 +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, 24 Jun 2024 20:25:32 +0800 From: Nianyao Tang To: , , , CC: , , Subject: [PATCH] irqchip/gic-v4.1: Use the ITS of the NUMA node where current cpu is located Date: Mon, 24 Jun 2024 12:25:10 +0000 Message-ID: <20240624122510.3906474-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: dggems703-chm.china.huawei.com (10.3.19.180) 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-20240624_052544_983802_999E3AC4 X-CRM114-Status: GOOD ( 13.13 ) 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 When GICv4.1 enabled, guest sending IPI use the last ITS reported. On multi-NUMA environment with more than one ITS, it makes IPI performance various from VM to VM, depending on which NUMA the VM is deployed on. We can use closer ITS instead of the last ITS reported. Modify find_4_1_its to find the ITS of the NUMA node where current cpu is located and save it with per cpu variable. Signed-off-by: Nianyao Tang --- drivers/irqchip/irq-gic-v3-its.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 3c755d5dad6e..d35b42f3b2af 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -193,6 +193,8 @@ static DEFINE_RAW_SPINLOCK(vmovp_lock); static DEFINE_IDA(its_vpeid_ida); +static DEFINE_PER_CPU(struct its_node *, its_on_cpu); + #define gic_data_rdist() (raw_cpu_ptr(gic_rdists->rdist)) #define gic_data_rdist_cpu(cpu) (per_cpu_ptr(gic_rdists->rdist, cpu)) #define gic_data_rdist_rd_base() (gic_data_rdist()->rd_base) @@ -4058,19 +4060,26 @@ 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 = NULL; + struct its_node *its_non_cpu_node = NULL; + int cpu = smp_processor_id(); - if (!its) { - list_for_each_entry(its, &its_nodes, entry) { - if (is_v4_1(its)) - return its; - } + if (per_cpu(its_on_cpu, cpu)) + return per_cpu(its_on_cpu, cpu); - /* Oops? */ - its = NULL; - } + list_for_each_entry(its, &its_nodes, entry) { + if (is_v4_1(its) && its->numa_node == cpu_to_node(cpu)) { + per_cpu(its_on_cpu, cpu) = its; + return its; + } + else if (is_v4_1(its)) + its_non_cpu_node = its; + } - return its; + if (!per_cpu(its_on_cpu, cpu) && its_non_cpu_node) + per_cpu(its_on_cpu, cpu) = its_non_cpu_node; + + return its_non_cpu_node; } static void its_vpe_4_1_send_inv(struct irq_data *d)