Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Zhang Zekun <zhangzekun11@huawei.com>
Cc: <oliver.upton@linux.dev>, <james.morse@arm.com>,
	<suzuki.poulose@arm.com>, <yuzenghui@huawei.com>,
	<kvmarm@lists.linux.dev>
Subject: Re: [PATCH] KVM: arm64: vgic-v4: Use helper function irq_get_irq_data()
Date: Fri, 09 Aug 2024 13:38:23 +0100	[thread overview]
Message-ID: <868qx527nk.wl-maz@kernel.org> (raw)
In-Reply-To: <20240809083906.2534-1-zhangzekun11@huawei.com>

On Fri, 09 Aug 2024 09:39:06 +0100,
Zhang Zekun <zhangzekun11@huawei.com> 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 <zhangzekun11@huawei.com>
> ---
>  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.

      reply	other threads:[~2024-08-09 12:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09  8:39 [PATCH] KVM: arm64: vgic-v4: Use helper function irq_get_irq_data() Zhang Zekun
2024-08-09 12:38 ` Marc Zyngier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=868qx527nk.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=james.morse@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=oliver.upton@linux.dev \
    --cc=suzuki.poulose@arm.com \
    --cc=yuzenghui@huawei.com \
    --cc=zhangzekun11@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox