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 A60571DFF5 for ; Fri, 9 Aug 2024 12:38:33 +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=1723207113; cv=none; b=olUv4pQVaGWE9pXvMHGwt5NH6kcNNONA2qRfHp51B7R/oUrL7l1hlstMEvRA/r/RxyeXVTkO+VfjMHXsvZXjZ6zCem7hJfV7UI9PQFfuCn2mePmW/s77pg0PF9XIsw0LNy7d2p9XpsJotA8/oP6ov9fZ0mdNI9VyVJRENG2ZYWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723207113; c=relaxed/simple; bh=ssPfoXbt81Fg6MwEoQ5t/2yiiU4J51bXCCA03eZCzLE=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=Ar6vsCEVNOet7bi0MlhZn/h1wLTio7GjBQ04PM7EYKzxgAWsz2A8bB9jKBIx8qy8AcE5jz5tPrncIcLzCtAfEwCGg26Mo1oHnRIcbmtBCj25OP3mlhr0YkSPYY4Pu3HdjVwdvtJrh7qxoE3u/im82+q20x9wy9RCG9YhscguCD8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=auMqGMLm; 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="auMqGMLm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B908C32782; Fri, 9 Aug 2024 12:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723207113; bh=ssPfoXbt81Fg6MwEoQ5t/2yiiU4J51bXCCA03eZCzLE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=auMqGMLmbyHBLQLRtPVfEUbvbusGu4sICR9x8yIZTNXXVNHKoyS3besfdqlWM3T/A j46PKS8ifkv7OSpLdiwKqr5xhPlEKr9fMzprMQa7UHPXyO7jHmMwBQDq/pDfj5tRgO wtckt0/AkKRPgam7+3hQGbwRBx6okp/VCOO5pN+/C2ZFSkanpWn3Eywe5pIeJejaQJ zlhwQix10POLnrGTTd1qcaXfEWR0CpB5k/RpKfbCMmZo3ZRtPi6TwwxmapumFxb6nt CfgcQfHUwyNEtdh9bH/eKAcQsWKdWSOg90wKXfAvcoxN9LVqCZdJ13fsNGMFyNS4kM mtokqg9yiQLOg== 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 1scOt5-002Kks-3C; Fri, 09 Aug 2024 13:38:31 +0100 Date: Fri, 09 Aug 2024 13:38:23 +0100 Message-ID: <868qx527nk.wl-maz@kernel.org> From: Marc Zyngier To: Zhang Zekun Cc: , , , , Subject: Re: [PATCH] KVM: arm64: vgic-v4: Use helper function irq_get_irq_data() In-Reply-To: <20240809083906.2534-1-zhangzekun11@huawei.com> References: <20240809083906.2534-1-zhangzekun11@huawei.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/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev 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: zhangzekun11@huawei.com, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, kvmarm@lists.linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 09 Aug 2024 09:39:06 +0100, Zhang Zekun wrote: > > The returned value of irq_to_desc() is only used to get the irq_data > by calling irq_desc_get_irq_data(), and there is a helper function > irq_get_irq_data() which has already provided the functionality. So, > use irq_get_irq_data() to make the code more simple. Unfortunately, simpler doesn't equate to better. > > Signed-off-by: Zhang Zekun > --- > arch/arm64/kvm/vgic/vgic-v4.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c > index 74a67ad87f29..2707ab0ab0a5 100644 > --- a/arch/arm64/kvm/vgic/vgic-v4.c > +++ b/arch/arm64/kvm/vgic/vgic-v4.c > @@ -124,7 +124,6 @@ static void vgic_v4_enable_vsgis(struct kvm_vcpu *vcpu) > */ > for (i = 0; i < VGIC_NR_SGIS; i++) { > struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, i); > - struct irq_desc *desc; > unsigned long flags; > int ret; > > @@ -138,8 +137,7 @@ static void vgic_v4_enable_vsgis(struct kvm_vcpu *vcpu) > > /* Transfer the full irq state to the vPE */ > vgic_v4_sync_sgi_config(vpe, irq); > - desc = irq_to_desc(irq->host_irq); > - ret = irq_domain_activate_irq(irq_desc_get_irq_data(desc), > + ret = irq_domain_activate_irq(irq_get_irq_data(irq->host_irq), > false); And you are still performing two lookups (one in the domain, one in the mapple tree), when everything could be solve with one: diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c index 74a67ad87f29..9f0f15b376f2 100644 --- a/arch/arm64/kvm/vgic/vgic-v4.c +++ b/arch/arm64/kvm/vgic/vgic-v4.c @@ -134,11 +134,10 @@ static void vgic_v4_enable_vsgis(struct kvm_vcpu *vcpu) goto unlock; irq->hw = true; - irq->host_irq = irq_find_mapping(vpe->sgi_domain, i); + desc = __irq_resolve_mapping(vpe->sgi_domain, i, &irq->host_irq); /* Transfer the full irq state to the vPE */ vgic_v4_sync_sgi_config(vpe, irq); - desc = irq_to_desc(irq->host_irq); ret = irq_domain_activate_irq(irq_desc_get_irq_data(desc), false); if (!WARN_ON(ret)) { So no, I'm not going to change this just to drop a local variable. If we are going to change something, it is to improve the *result*. Thanks, M. -- Without deviation from the norm, progress is not possible.