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 54B9DC44500 for ; Thu, 22 Jan 2026 10:19:54 +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-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Subject:Cc:To:From: Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SXqm8cLyGJINTJnNw7mHjFMFgxY9ML6/1MUEvatflpE=; b=jipmlJXPKeGkBN8tS1HkAjjsCM z6poBAQUCDBENRZ0HpQhCyRHie/+4zL4piE7PWsi/FwuzkLJQJpEVI+MOk8ALtoQUbnwZze9EWDfV POOUpom3isHUbVOhW3YLfA8xxMB5z+GTEw1u0ZVeRHGIMbthskQZeVr1iMzOTTkjCZy5O+ZUVrIoF BYh+gzKW3G4D0rUlQi3JcGx3yBV8VB0HVRbcUt3BYZ2FwdIvCvcSX3hPLsUPrZw6+Ln6zoGgzLegm 5bcRBCvrrJggGysm0N9kVT8A0dNBWJuRK4ofmynYf61EsRIj/whqyi5KmVfRDh8itdfMzLqtaQdbZ Hk7e4GFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1virn3-00000006opA-00Ay; Thu, 22 Jan 2026 10:19:49 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1virn1-00000006oou-3b6T for linux-arm-kernel@lists.infradead.org; Thu, 22 Jan 2026 10:19:47 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id DE59860053; Thu, 22 Jan 2026 10:19:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92310C116C6; Thu, 22 Jan 2026 10:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769077186; bh=L3IZIC+janpa8bX+oY0ioO1Giiv4Fy8ez5t+eXi0T44=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=N1P/WZwRllaQdaCucmkBP+pPH7El0CU0NjCzFfOIfRnIiBl7Szv1Y+ZjV79tzN9xn ajY4po3Ld1ovsW50CNxyjMjN5JvsynFADJNZk3qATuDLQ3ml0m+U0rwL3X47A+ouUt mwh0kEwcMyyGHlw4E3c2iNeL8c7etpIeoDwmlB2skGqjXE1Rs1H1qtFAbbTmnP5CgD mF/MVPNvgLVcKYukr0STFjfmUVhlW/TWfdoqi3CWowxRQ8YugXv//iesAKhGqaI/Cj /v6WsfPEpsZJydwSHS/3/q9H+77I3G58POJU8n+jo9ozUSxRl6zKcBcvYHgjwUV5UK IUGABtKslDErg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1virmy-00000004do1-0e5m; Thu, 22 Jan 2026 10:19:44 +0000 Date: Thu, 22 Jan 2026 10:19:43 +0000 Message-ID: <86v7guar0g.wl-maz@kernel.org> From: Marc Zyngier To: Paolo Bonzini Cc: Thomas Gleixner , Ankit Soni , Sean Christopherson , Oliver Upton , Joerg Roedel , David Woodhouse , Lu Baolu , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Sairaj Kodilkar , Vasant Hegde , Maxim Levitsky , Joao Martins , Francesco Lavra , David Matlack , Naveen Rao , Crystal Wood Subject: Re: possible deadlock due to irq_set_thread_affinity() calling into the scheduler (was Re: [PATCH v3 38/62] KVM: SVM: Take and hold ir_list_lock across IRTE updates in IOMMU) In-Reply-To: <5bea843b-dec8-4f15-bb7c-1d0550542034@redhat.com> References: <20250611224604.313496-2-seanjc@google.com> <20250611224604.313496-40-seanjc@google.com> <42513cb3-3c2e-4aa8-b748-23b6656a5096@redhat.com> <874iovu742.ffs@tglx> <87pl7jsrdg.ffs@tglx> <5bea843b-dec8-4f15-bb7c-1d0550542034@redhat.com> 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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: pbonzini@redhat.com, tglx@kernel.org, Ankit.Soni@amd.com, seanjc@google.com, oliver.upton@linux.dev, joro@8bytes.org, dwmw2@infradead.org, baolu.lu@linux.intel.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, sarunkod@amd.com, vasant.hegde@amd.com, mlevitsk@redhat.com, joao.m.martins@oracle.com, francescolavra.fl@gmail.com, dmatlack@google.com, Naveen.Rao@amd.com, crwood@redhat.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false 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 Wed, 21 Jan 2026 18:13:43 +0000, Paolo Bonzini wrote: >=20 > Sorry, not sure how the previous email ended up encrypted. >=20 > On 1/8/26 22:53, Thomas Gleixner wrote: > > On Thu, Jan 08 2026 at 22:28, Thomas Gleixner wrote: > >> On Mon, Dec 22 2025 at 15:09, Paolo Bonzini wrote: > >>> Of the three, the most sketchy is (a); notably, __setup_irq() calls > >>> wake_up_process outside desc->lock. Therefore I'd like so much to tr= eat > >>> it as a kernel/irq/ bug; and the simplest (perhaps too simple...) fix= is > >>=20 > >> It's not more sketchy than VIRT assuming that it can do what it wants > >> under rq->lock. =F0=9F=99=82 > >=20 > > And just for the record, that's not the only place in the irq core which > > has that lock chain. > >=20 > > irq_set_affinity_locked() // invoked with desc::lock held > > if (desc->affinity_notify) > > schedule_work() // Ends up taking rq::lock > >=20 > > and that's the case since cd7eab44e994 ("genirq: Add IRQ affinity > > notifiers"), which was added 15 years ago. > >=20 > > Are you still claiming that this is a kernel/irq bug? >=20 > Not really, I did say I'd like to treat it as a kernel/irq bug... > but certainly didn't have hopes high enough to "claim" that. > I do think that it's ugly to have locks that are internal, > non-leaf and held around callbacks; but people smarter than > me have thought about it and you can't call it a bug anyway. >=20 > For x86/AMD we have a way to fix it, so that part is not a problem. >=20 > For the call(*) to irq_set_affinity() in arch/arm64/kvm/'s > vgic_v4_load() I think it can be solved as well. > kvm_make_request(KVM_REQ_RELOAD_GICv4) will delay vgic_v4_load() > to a safe spot, so just cache the previous smp_processor_id() and, > if it is different, do the kvm_make_request() and return instead > of calling irq_set_affinity(). >=20 > vgic_v3_load() is the only place that calls it from the preempt > notifier, so this behavior can be tied to a "bool delay_set_affinity" > argument to vgic_v4_load() or placed in a different function. >=20 > Marc/Oliver, does that sound doable? Potentially. But there are a few gotchas that may need surgery beyond KVM itself, all the way down to the ITS code that abstract the differences between v4.0 and v4.1. I'll have a look over the weekend. Thanks, M. --=20 Without deviation from the norm, progress is not possible.