From patchwork Tue Feb 13 10:38:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 200357 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp449394dyb; Tue, 13 Feb 2024 02:39:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMwOwKvNPGXTC84ru/B4I+BlpH54cfiP9BN3KIRZdXQw1BUKc9oEGRNwAoL1nhdwzzX6WA X-Received: by 2002:aa7:d289:0:b0:55f:39d3:6d5e with SMTP id w9-20020aa7d289000000b0055f39d36d5emr6710594edq.39.1707820759459; Tue, 13 Feb 2024 02:39:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707820759; cv=pass; d=google.com; s=arc-20160816; b=Ggu/TOuJhPZPapSBdVOTkZSBar7LU3bIqbRjfcDkCzVc3h8BkHd1eUucu2x3iSy0r1 rC/G+A5PPYAyMFj+0xw7SWgspBn7B7t1HD4E5bBr0vCbs+07CnGi9ApI6mlDxS65doaU u+gA+EW5xhwRTU2BMm2aTx0YIElPS0ii3XoW5Wu+bh/bjmfM5wNO+/F8fFOIqv77KDDk TMPQG/kXrVJ1VCjvFZiCuIij5LA1dyNNY//trUb6qaHlFiP4247NmXBUljFTfY3mHOn2 8m8SUz3OD46gjD2NzPKi7RfqajjosKcjOYkG31N58UR3RPpeAP98+CLr+bi0ifum+TZh 0SEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=i0Y8LXuXM+2quXl6GjfVoen1w/ZUhO5D8VOBXlYzfXc=; fh=k3TIc8VRsCvSMpUyHjG13O+ZIDTwDaMNejPcTscC25A=; b=Any3KcGDLlyNR4RJTxuCgaPSlPfkFdyHeP+AsV42HmopLoyM13yuAbvag5Su6shkAK szAhwPs6i2hchoH/M47Y7U3weQ7qfiJRBZPnqbxefU5FpiQygeCUHilkoax1ceykW3Jm E5jWKhwAt8ImAxi7yHxNGX9AD5mhBSM9rMaPMxQkrBeou0Gug1iSmUJnGaOsY/7MKpUi Uxe0kyQhpJgwhFF+xUUdGddlrdLl83iEDnAud/AcoNcPMi1JxuNiwgqjILmko2bF2CbW NSqOllyVtNbzIR47SwtsakHKW2Y7gKAjlfqOho1iZPlc7lg2PTnV02zoKSUZzbNdHgPk sFbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4TqKEk3C; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-63357-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63357-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCUGjkhtsQrW7sS9gLhGn8Syf/Gu9ZUossx3L1TgpZTr/ZQAq5xl6oIvBx/P9T54UIj0Men/j8SbBCme9cpkArMyN1BrUw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h14-20020a05640250ce00b0056178322e96si3279536edb.127.2024.02.13.02.39.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 02:39:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63357-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4TqKEk3C; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-63357-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63357-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E0DE51F243C2 for ; Tue, 13 Feb 2024 10:39:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A3D7D2C697; Tue, 13 Feb 2024 10:38:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4TqKEk3C"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JrIAE2bT" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BB8C249E8; Tue, 13 Feb 2024 10:38:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707820726; cv=none; b=U5P9aRTAS/k6tJMbW32NFz8qx1nMC0IkeDlTPh/F5D4LmxycfCrP3rmZPWgM1BKpU8NhyqAHRq4tRvglTv8SqVYcSFEj169pX+4jXm66LCoZJqRKS4L72ToLaEGB91OuXOr9cTkMpRvWWZHCe81H3US9J9ZghR+CMWtf4+QAW+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707820726; c=relaxed/simple; bh=w1V92yhJ7znW5mCLg9cJb/2PDW8YuAua0bO8eBGqGoE=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=aUDiFVK50WiOzFapZPjwbarxqxuByJHtauj3zWnJr3gkqsrdGVrqcTa1jAbnBQuDArKevaFSdnR2xCl6u+esHR52RWO3mE9D3foUzqaur0L52Ybz6c0fYNvn3Hr4Rgdrqi/tHuaktaXzjOAOUYUAus0XC2UculZwhkSpkDi3HAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4TqKEk3C; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JrIAE2bT; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Tue, 13 Feb 2024 10:38:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1707820723; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i0Y8LXuXM+2quXl6GjfVoen1w/ZUhO5D8VOBXlYzfXc=; b=4TqKEk3CzHdi5cGbHGNfpMgWHKs0/J7t8ttDMHNvHJAh2Dk6oqmDJVMlR6z/uvB5n9Z+Jx +ZytB+2ZCcq0kNyZOMf6V8zSPfmlZh+YE8nzLz40G2wCVj1oKxtJlCCPDQbQo8tNHtqde0 ilT6zwu0AS8JbpnnUZmITruYtukdPnyPbsDvHiJtmu1aMqfBZrwol4Eku0LfSwZITZCAnl vcijPP4N4f2XIr5lz9yFDFPwYhhEf+P2GeNFfPEh6I1CL7oz4yQpi01UUV74JWL2bZnkJ+ EAtIpB0QQYjnqHjjEwduU3ttKfOPyKDPrDN+oJs/TcMLThiJBterTHgbFsxcmw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707820723; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i0Y8LXuXM+2quXl6GjfVoen1w/ZUhO5D8VOBXlYzfXc=; b=JrIAE2bTwKYGzr9MGVPvm4L9co2hzupV5jlLbTy1D6Q3VT1kv407Rvs6NTmvh1XSFtV8Sa vtjZc8Nn2HxjlVBA== From: "tip-bot2 for Marc Zyngier" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/urgent] irqchip/gic-v3-its: Fix GICv4.1 VPE affinity update Cc: Kunkun Jiang , Marc Zyngier , Thomas Gleixner , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240213101206.2137483-4-maz@kernel.org> References: <20240213101206.2137483-4-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170782072242.398.18224261385789305537.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790779860388114828 X-GMAIL-MSGID: 1790779860388114828 The following commit has been merged into the irq/urgent branch of tip: Commit-ID: af9acbfc2c4b72c378d0b9a2ee023ed01055d3e2 Gitweb: https://git.kernel.org/tip/af9acbfc2c4b72c378d0b9a2ee023ed01055d3e2 Author: Marc Zyngier AuthorDate: Tue, 13 Feb 2024 10:12:06 Committer: Thomas Gleixner CommitterDate: Tue, 13 Feb 2024 11:29:52 +01:00 irqchip/gic-v3-its: Fix GICv4.1 VPE affinity update When updating the affinity of a VPE, the VMOVP command is currently skipped 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 VMOVP cannot be elided 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 Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20240213101206.2137483-4-maz@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 250b456..53abd47 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); From patchwork Tue Feb 13 10:12:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 200360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp449815dyb; Tue, 13 Feb 2024 02:40:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUMSHlzS5TEX3TxLEJ29xDLmyM9kxD3i7C+Wx/BZCvcj76JzRM/KWsmOPFnSLcEweeEAbGLbZAqWIIOJtOlMIxqmvJ9+w== X-Google-Smtp-Source: AGHT+IGt3E85IM+cYz0EZ/MS1YxTsLPFqFsU2MUphjqM0+gDJfioRHMmdRdejOvIhmPWFCIi8APj X-Received: by 2002:a05:6a00:9382:b0:6e0:9902:d7ce with SMTP id ka2-20020a056a00938200b006e09902d7cemr9126200pfb.10.1707820829619; Tue, 13 Feb 2024 02:40:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707820829; cv=pass; d=google.com; s=arc-20160816; b=S5gdFDATEC8dJtljOGPPxiq6i/7LejFwa/Y1cSNy/fizpPVpdD0oerMAHsN2TfQIvq C11oFeZ7ER4bVZgFW/Him5isuNAuO9ZY1ST81ofJvD07VesH5gh8MuNCxN6wPidm+okh zeieaAlenbxvbMGc5d304Cgi67duRxsPvDnju4XZC6Nn3giz8ImjuczM+3qwvKfI5Eii T6rjMRZnfjwDkN2Rv0uxoMgC1aMI/gfQqwRsl/720maIo+NMVufwZLCnCfNgh1sIUQNv Y2GGqNH4aotbXFDDzqxQoaZkrscsru/3+K2RHEigZOw9VZQ3TcKQeb5zHDMsuCQsf8Ea /SsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=HLLg4bnrB8iB1pGKv/dn69TSqpbZyIBsXpfD0YnZCE8=; fh=ybD85Xfe6QZxiWdoE/sFM/jRv6bXonQEPtCU7DSwxvA=; b=rpltLXsiCmbX76OBJHCZQ3DtshYpU7BMqvzzfLL0MzH5M36fq3kuhWH1z8pEZyF6bF KTKYUbuznOwmOlSpo3OGEH80few1B8uYwPiQmFZ3LEPaMIwe9bKfwwO76/8sr4CSEn1y BkS94tJpU+f5zlPCM1x5z2F/lNpNgjpa9SV4P3RREEebq65UTlM85LH2NsLxuVDPvCkk xgAMDjog/TuR2ktltlMl8DYYShtji2dBdIRQH7cm16tiPOcxcUHMAtp81RIm3THYrjPs 7GNICGKbA4uZYJNVl0puyZ9sEFO/RpxrPJI8/g3nPsuoEthfu3GPuHvC+IaYNTnal7j9 d8BA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oVHtuQSS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63318-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63318-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCU5UsR2h/iZ50NoYh9gWQUa3kafyeIQSOcVZcjLomqBXcPXDftqBBdiUXsRvT3qsxEqk8ahq83RZgHut+p/SXs4Mf+xEQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w16-20020a639350000000b005dc42fd8c40si1748344pgm.404.2024.02.13.02.40.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 02:40:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63318-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oVHtuQSS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-63318-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63318-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id ECA72B25D9A for ; Tue, 13 Feb 2024 10:13:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8076C2BAFA; Tue, 13 Feb 2024 10:12:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oVHtuQSS" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD195225D5; Tue, 13 Feb 2024 10:12:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707819133; cv=none; b=pILWZN2DfGZzqQMwlyn4ospe/lWE/+6Rmk2rn2gwJyNAaqZrel1BLHDvBlbkIoF2S4hyjcXSnxCB9mD1DrZBB7EGr43tx/E7kWyfQwgKgawGCDykLqKYJ6JoKjG44lRE6c+OW4XAGGCSy9H43fM1tusaOjvQ/iDRKy+THjAWWSM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707819133; c=relaxed/simple; bh=mMMxy/y9GolMEAEGUBmVL1XVh2uwo1cUPLjZV/60nHA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Is4VShz02+FMk8PVLPhfHLyEnPxWpNJh8wPDIn/57wskv+emKcu3neIpivA4NKMRD1lUwwT6COWjq+vxF0kc5Qm/9a18bsVRW4zMDaYYlhuek2MKtKrSyIBTlcY0GZEJJ6pfbqySwlvgCLqlhHL49D3dbadqTsQSvSlOZxAduJM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oVHtuQSS; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790779860388114828 X-GMAIL-MSGID: 1790779934192340683 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);