From mboxrd@z Thu Jan 1 00:00:00 1970 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 6E6AAC48260 for ; Tue, 13 Feb 2024 10:12:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=cvZWB3i05oCM9g0yuxs9PTvmRo0h/0jra36VOFlXRTc=; b=Hrsa/NveltM8PT u2BpC6HZSA10OjDYU1yVl7erNtJOnrFyJhPFH/bDgoCU/62e+62lEOohekcuwYMdTLHKM3bK24OC3 ev/kUjyDSgJ4tZq6rZCz1hQ8NMh1OmCNYBb2X4XN6uvVyAQL6jYZOl2AbtdTBhCM+3nK2qcDMP+01 J3ABj1DI8yUdexzQ/bEqDowt/d85WiNWZKzgRmiGQDWZsGcuYzmcRwgWeiIVUmt3Nz9qze+oBnMse /M+cqzhGnJt5I7+ZHP3/lRgncGYGNQZve5mcPS/kscj4E4Ov7HyoR7Ct0fG1yD11d6u0VfnRpz0Dx jwAqztt4HOVzCgsRPukA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZpm5-00000008mNI-2kXs; Tue, 13 Feb 2024 10:12:25 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZplu-00000008mKf-1iMm for linux-arm-kernel@lists.infradead.org; Tue, 13 Feb 2024 10:12:16 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CFD5D61336; Tue, 13 Feb 2024 10:12:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72445C433B1; Tue, 13 Feb 2024 10:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707819133; bh=mMMxy/y9GolMEAEGUBmVL1XVh2uwo1cUPLjZV/60nHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oVHtuQSS5rAbZ1AVPeHYrpxwnfcRK7mrTyqmOX+JCeYl70dD1z2PApTqhGHYevjO5 N3K2/evL/evnJP6U0fIerZuDwbV62Mut9wppUt1iB7KOHNpYXq1mj4jNrAbIMQ2E/O bqaGQEjAdZftbh4sh+lzDSQzbxJaKFuluhC9yyAluDfRPxJBlKxjOA9gI5IOG+qNzR 0ilHFl59zQZGIFg0HFmi16PkNxPqgrcKEg/OBkpCeC59Zlz4+smmvsrhmqAdv9M8xR XloDmzKogJbl5rD2j4qiqkATI63NHX71toptdVRjNUsXU0mtEFpihjwu9G2DO3FgmI VJpqC1Qszz61w== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rZplr-002j7r-AO; Tue, 13 Feb 2024 10:12:11 +0000 From: Marc Zyngier To: Thomas Gleixner Cc: Kunkun Jiang , Lorenzo Pieralisi , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 3/3] irqchip/gic-v3-its: Fix GICv4.1 VPE affinity update Date: Tue, 13 Feb 2024 10:12:06 +0000 Message-Id: <20240213101206.2137483-4-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213101206.2137483-1-maz@kernel.org> References: <20240213101206.2137483-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tglx@linutronix.de, jiangkunkun@huawei.com, lpieralisi@kernel.org, yuzenghui@huawei.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240213_021214_551079_124AB0D3 X-CRM114-Status: GOOD ( 20.34 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When updating the affinity of a VPE, we currently skip the VMOVP command if the two CPUs are part of the same VPE affinity. But this is wrong, as the doorbell corresponding to this VPE is still delivered on the 'old' CPU, which screws up the balancing. Furthermore, offlining that 'old' CPU results in doorbell interrupts generated for this VPE being discarded. The harsh reality is that we cannot easily elide VMOVP when a set_affinity request occurs. It needs to be obeyed, and if an optimisation is to be made, it is at the point where the affinity change request is made (such as in KVM). Drop the VMOVP elision altogether, and only use the vpe_table_mask to try and stay within the same ITS affinity group if at all possible. Fixes: dd3f050a216e (irqchip/gic-v4.1: Implement the v4.1 flavour of VMOVP) Reported-by: Kunkun Jiang Signed-off-by: Marc Zyngier Cc: stable@vger.kernel.org --- drivers/irqchip/irq-gic-v3-its.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 250b4562f308..53abd4779914 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -3826,8 +3826,9 @@ static int its_vpe_set_affinity(struct irq_data *d, bool force) { struct its_vpe *vpe = irq_data_get_irq_chip_data(d); - int from, cpu = cpumask_first(mask_val); + struct cpumask common, *table_mask; unsigned long flags; + int from, cpu; /* * Changing affinity is mega expensive, so let's be as lazy as @@ -3843,19 +3844,22 @@ static int its_vpe_set_affinity(struct irq_data *d, * taken on any vLPI handling path that evaluates vpe->col_idx. */ from = vpe_to_cpuid_lock(vpe, &flags); - if (from == cpu) - goto out; - - vpe->col_idx = cpu; + table_mask = gic_data_rdist_cpu(from)->vpe_table_mask; /* - * GICv4.1 allows us to skip VMOVP if moving to a cpu whose RD - * is sharing its VPE table with the current one. + * If we are offered another CPU in the same GICv4.1 ITS + * affinity, pick this one. Otherwise, any CPU will do. */ - if (gic_data_rdist_cpu(cpu)->vpe_table_mask && - cpumask_test_cpu(from, gic_data_rdist_cpu(cpu)->vpe_table_mask)) + if (table_mask && cpumask_and(&common, mask_val, table_mask)) + cpu = cpumask_test_cpu(from, &common) ? from : cpumask_first(&common); + else + cpu = cpumask_first(mask_val); + + if (from == cpu) goto out; + vpe->col_idx = cpu; + its_send_vmovp(vpe); its_vpe_db_proxy_move(vpe, from, cpu); -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel