From: Yury Norov <yury.norov@gmail.com>
To: Huacai Chen <chenhuacai@kernel.org>
Cc: Tianrui Zhao <zhaotianrui@loongson.cn>,
Bibo Mao <maobibo@loongson.cn>, WANG Xuerui <kernel@xen0n.name>,
kvm@vger.kernel.org, loongarch@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] LoongArch: KVM:: simplify kvm_deliver_intr()
Date: Fri, 18 Jul 2025 09:24:07 -0400 [thread overview]
Message-ID: <aHpK9xMDsK7tHjT1@yury> (raw)
In-Reply-To: <CAAhV-H729+VA4fAWX1SOhCAptSDSwLDAOp_RwB0hkDtvm0hMLg@mail.gmail.com>
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@gmail.com> wrote:
> >
> > From: "Yury Norov (NVIDIA)" <yury.norov@gmail.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@gmail.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
> >
> >
next prev parent reply other threads:[~2025-07-18 13:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-16 16:59 [PATCH 0/2] LoongArch: KVM: simplify KVM routines Yury Norov
2025-07-16 16:59 ` [PATCH 1/2] LoongArch: KVM: rework kvm_send_pv_ipi() Yury Norov
2025-07-18 2:25 ` Bibo Mao
2025-07-16 16:59 ` [PATCH 2/2] LoongArch: KVM:: simplify kvm_deliver_intr() Yury Norov
2025-07-18 2:37 ` Bibo Mao
2025-07-18 4:13 ` Huacai Chen
2025-07-18 13:24 ` Yury Norov [this message]
2025-07-20 8:50 ` [PATCH 0/2] LoongArch: KVM: simplify KVM routines Huacai Chen
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=aHpK9xMDsK7tHjT1@yury \
--to=yury.norov@gmail.com \
--cc=chenhuacai@kernel.org \
--cc=kernel@xen0n.name \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=maobibo@loongson.cn \
--cc=zhaotianrui@loongson.cn \
/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