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 687E2C3DA64 for ; Sun, 28 Jul 2024 09:43:16 +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:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=I0PRJmaX5/urd8W2oUpPpn2s0gdOxrizir/hdj/4+Hs=; b=wKpRfUH0VVCKD/6Mrz1+p11P3a 9Toj8OgdMgOBVEVbvt21yGq+rKCDDGOGTcRmECn0nJ3r65Q83fTQ4O4bH3Ku9YTWOngaWRohy674i oZhhrGRI1IrU4hRXneZfmyZSujk3Fz3xbd95gjWCOIi1MZUpL7wagxHWVQaTE7CE+Akhe1aQVpb5q QSfKWG62VkOSnMGB7OxY9VACXYVl5VyHVR9hLVTgInqWelqA+Xvy7dsyMhzrwPk+OCv+wyPqhqxbF KqAqANTKmeZM1/Swow6eBlBDsgJbrXcBMtzR1teuE8FGqoNfCE0gppMNFBp01btgLC+/f5yTnjUIV 6Ez5t+YQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sY0Qi-00000008EOy-1Ho2; Sun, 28 Jul 2024 09:43:04 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sY0QI-00000008ELK-2c30 for linux-arm-kernel@lists.infradead.org; Sun, 28 Jul 2024 09:42:40 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 28E1ACE01F9; Sun, 28 Jul 2024 09:42:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DA19C116B1; Sun, 28 Jul 2024 09:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722159755; bh=o12tsrInDUp7TWLjhQ3FIg7eGUv0Ahvb5FlQ5xtUNQI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rgSWK+I9bzdBJW97j9tBQ4inV9Z1NxRsQzJaoTvt+ROTL13DwAlU3q6EZXkDgI65p 9niFi9cWLhXlcPUUkeZARowNodFMb+SYJ+c90L75Q0zznLfP9zf1vCdHfwc3V6VS1T 9bzfBeK0gj8SzTzvbj/vnOrBcgu8bvcoCQBi1m6GXFjguKAso0xeleV1yrObxdR4Tm vSUm99NPC+zi+n/YkbNYIbtQ18OKrweDWBwJBRA45014SEWLE267ru9RilR6qceZf8 fD11SJwfSdJuqmG4t9g5UJe038fbXmMn3OnEqLIOVE5npL8l4m9jBpTaF7PUiNEawH Tcsn1SIMmdz0A== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sY0QC-00G2bK-WB; Sun, 28 Jul 2024 10:42:33 +0100 Date: Sun, 28 Jul 2024 10:42:32 +0100 Message-ID: <87y15l4zuf.wl-maz@kernel.org> From: Marc Zyngier To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Zhou Wang Subject: Re: [PATCH] irqchip/gic-v4: Fix ordering between vmapp and vpe locks In-Reply-To: <875xsrvpt3.ffs@tglx> References: <20240723175203.3193882-1-maz@kernel.org> <875xsrvpt3.ffs@tglx> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tglx@linutronix.de, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, wangzhou1@hisilicon.com 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-20240728_024238_863265_6D9BCC9A X-CRM114-Status: GOOD ( 22.76 ) 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 Fri, 26 Jul 2024 21:52:40 +0100, Thomas Gleixner wrote: > > On Tue, Jul 23 2024 at 18:52, Marc Zyngier wrote: > > @@ -3808,7 +3802,7 @@ static int its_vpe_set_affinity(struct irq_data *d, > > struct its_vpe *vpe = irq_data_get_irq_chip_data(d); > > unsigned int from, cpu = nr_cpu_ids; > > struct cpumask *table_mask; > > - unsigned long flags; > > + unsigned long flags, vmapp_flags; > > What's this flags business for? its_vpe_set_affinity() is called with > interrupts disabled, no? Duh. Of course. Cargo-culted braindead logic. I'll fix that. > > > /* > > * Changing affinity is mega expensive, so let's be as lazy as > > @@ -3822,7 +3816,14 @@ static int its_vpe_set_affinity(struct irq_data *d, > > * protect us, and that we must ensure nobody samples vpe->col_idx > > * during the update, hence the lock below which must also be > > * taken on any vLPI handling path that evaluates vpe->col_idx. > > + * > > + * Finally, we must protect ourselves against concurrent > > + * updates of the mapping state on this VM should the ITS list > > + * be in use. > > */ > > + if (its_list_map) > > + raw_spin_lock_irqsave(&vpe->its_vm->vmapp_lock, vmapp_flags); > > Confused. This changes the locking from unconditional to > conditional. What's the rationale here? I think I'm confused too. I've written this as a mix of the VMOVP lock (which must be conditional) and the new VMAPP lock, which must be taken to avoid racing against a new vcpu coming up. And of course, this makes zero sense. I'll get some sleep first, and then fix this correctly. Thanks for spotting it. M. -- Without deviation from the norm, progress is not possible.