From mboxrd@z Thu Jan 1 00:00:00 1970 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 8A0BC1CA9C; Thu, 25 Jan 2024 10:08:31 +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=1706177311; cv=none; b=RHSlx+ETJIAWO18bhvaUPXBRCMa3GmZFuhITkwi4Q7ntLDgpCacw/5ksn4d+9vCPf1IccHwnXWYLX+/FU4q+xD4a1C5JpMlklkx5XwmNtOWOCgZXEgCjj6GlXBIqdCLAR4xTolXgzu/krT8vtY55CqBBgfb6ifZEPUKMshG4OAU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706177311; c=relaxed/simple; bh=+tITBzDqPrtOmavLo2l72bnF/pJ1I0RIn/MseVnx2A8=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=sjel1W8G6lAsjEic2WPDPrrDQrBFUwpYG9g6S4Rv9kc0221Hx8cTouQBIrW+x2cdTTUAAQeyYQtmLvkkpmYxxq3bW9gdAAK0cWFMauAKzVgqM6Q2QWCWJwJL/VT9vz2VVnFrnXG6W7VPbs3xm7F8Lupejy4qMn6rhbwqFNDKyiA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WoMZKOtN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WoMZKOtN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CB3DC43390; Thu, 25 Jan 2024 10:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706177311; bh=+tITBzDqPrtOmavLo2l72bnF/pJ1I0RIn/MseVnx2A8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WoMZKOtN4zYAxIAxA/4gMDOaXPKIi8pyRk4T/r+sZw+Zlqq9Qj+IoRA14dBwO8k/w a+lq0KT+o/VZRCl7u2jDHBnAhvoWLOCxivzFRinREjWZFBnyXi+syrrYkQOEyT48Gy XAGjPRoAGmUBq6ONJW+STPxcW5Zod5/m2FIAgMJihbHf81kzGa5k1iGiKuRNE05fh2 NmKkpGxLtIjxD+WiaCklQ9VniK0gkIFct2GH1aSo9LCTyGZRL8Jz0baSDm4dbILAn4 eOFVZz7aC6E8lOBQyB2/fuKEE3bjeXehEvm2Fr6W3d/qHf20R+pT1XU7hP/VtOF+t+ 1pZ8ORNUG5uQA== 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.95) (envelope-from ) id 1rSweq-00EgK8-QS; Thu, 25 Jan 2024 10:08:28 +0000 Date: Thu, 25 Jan 2024 10:08:28 +0000 Message-ID: <864jf19143.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu , Raghavendra Rao Ananta , Jing Zhang Subject: Re: [PATCH 09/15] KVM: arm64: vgic: Ensure the irq refcount is nonzero when taking a ref In-Reply-To: <20240124204909.105952-10-oliver.upton@linux.dev> References: <20240124204909.105952-1-oliver.upton@linux.dev> <20240124204909.105952-10-oliver.upton@linux.dev> 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/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: oliver.upton@linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, rananta@google.com, jingzhangos@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Wed, 24 Jan 2024 20:49:03 +0000, Oliver Upton wrote: > > It will soon be possible for get() and put() calls to happen in > parallel, which means in most cases we must ensure the refcount is > nonzero when taking a new reference. Switch to using > vgic_try_get_irq_kref() where necessary, and document the few conditions > where an IRQ's refcount is guaranteed to be nonzero. > > Signed-off-by: Oliver Upton > --- > arch/arm64/kvm/vgic/vgic-its.c | 18 ++++++++---------- > arch/arm64/kvm/vgic/vgic.c | 3 ++- > 2 files changed, 10 insertions(+), 11 deletions(-) > > diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c > index 1d912a595b71..7219f4a0a93d 100644 > --- a/arch/arm64/kvm/vgic/vgic-its.c > +++ b/arch/arm64/kvm/vgic/vgic-its.c > @@ -75,18 +75,11 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid, > * check that we don't add a second list entry with the same LPI. > */ > oldirq = xa_load(&dist->lpi_xa, intid); > - if (oldirq) { > + if (oldirq && vgic_try_get_irq_kref(oldirq)) { nit: move the NULL-check inside the helper, since you always have to do it. Thanks, M. -- Without deviation from the norm, progress is not possible.