[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3b5ad9c2-23ad-4f3b-412a-fe6c1a4c855a@loongson.cn>
Date: Fri, 18 Jul 2025 10:37:00 +0800
From: Bibo Mao <maobibo@...ngson.cn>
To: Yury Norov <yury.norov@...il.com>, Tianrui Zhao
<zhaotianrui@...ngson.cn>, Huacai Chen <chenhuacai@...nel.org>,
WANG Xuerui <kernel@...0n.name>, kvm@...r.kernel.org,
loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] LoongArch: KVM:: simplify kvm_deliver_intr()
On 2025/7/17 上午12:59, Yury Norov wrote:
> From: "Yury Norov (NVIDIA)" <yury.norov@...il.com>
>
> The function opencodes for_each_set_bit() macro, which makes it bulky.
> Using the proper API makes all the housekeeping code going away.
>
> Signed-off-by: Yury Norov (NVIDIA) <yury.norov@...il.com>
> ---
> arch/loongarch/kvm/interrupt.c | 25 ++++---------------------
> 1 file changed, 4 insertions(+), 21 deletions(-)
>
> diff --git a/arch/loongarch/kvm/interrupt.c b/arch/loongarch/kvm/interrupt.c
> index 4c3f22de4b40..8462083f0301 100644
> --- a/arch/loongarch/kvm/interrupt.c
> +++ b/arch/loongarch/kvm/interrupt.c
> @@ -83,28 +83,11 @@ void kvm_deliver_intr(struct kvm_vcpu *vcpu)
> unsigned long *pending = &vcpu->arch.irq_pending;
> unsigned long *pending_clr = &vcpu->arch.irq_clear;
>
> - if (!(*pending) && !(*pending_clr))
> - return;
> -
> - if (*pending_clr) {
> - priority = __ffs(*pending_clr);
> - while (priority <= INT_IPI) {
> - kvm_irq_clear(vcpu, priority);
> - priority = find_next_bit(pending_clr,
> - BITS_PER_BYTE * sizeof(*pending_clr),
> - priority + 1);
> - }
> - }
> + for_each_set_bit(priority, pending_clr, INT_IPI + 1)
> + kvm_irq_clear(vcpu, priority);
>
> - if (*pending) {
> - priority = __ffs(*pending);
> - while (priority <= INT_IPI) {
> - kvm_irq_deliver(vcpu, priority);
> - priority = find_next_bit(pending,
> - BITS_PER_BYTE * sizeof(*pending),
> - priority + 1);
> - }
> - }
> + for_each_set_bit(priority, pending, INT_IPI + 1)
> + kvm_irq_deliver(vcpu, priority);
> }
>
> int kvm_pending_timer(struct kvm_vcpu *vcpu)
>
Hi Yury,
Thanks for your patch. And it looks good to me.
Reviewed-by: Bibo Mao <maobibo@...ngson.cn>
Regards
Bibo Mao
Powered by blists - more mailing lists