[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aHpK9xMDsK7tHjT1@yury>
Date: Fri, 18 Jul 2025 09:24:07 -0400
From: Yury Norov <yury.norov@...il.com>
To: Huacai Chen <chenhuacai@...nel.org>
Cc: Tianrui Zhao <zhaotianrui@...ngson.cn>, Bibo Mao <maobibo@...ngson.cn>,
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 Fri, Jul 18, 2025 at 12:13:46PM +0800, Huacai Chen wrote:
> Hi, Yury,
>
> On Thu, Jul 17, 2025 at 12:59 AM Yury Norov <yury.norov@...il.com> 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;
> Is it necessary to keep these two lines?
No. They duplicate the existing logic, and the new one based on
for_each_set_bit(). That's why I remove them.
Thanks,
Yury
> > -
> > - 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)
> > --
> > 2.43.0
> >
> >
Powered by blists - more mailing lists