All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vihas Mak <makvihas@gmail.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: pbonzini@redhat.com, seanjc@google.com, wanpengli@tencent.com,
	jmattson@google.com, joro@8bytes.org, tglx@linutronix.de,
	mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
	x86@kernel.org, hpa@zytor.com, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: fix cocci warnings
Date: Mon, 15 Nov 2021 17:03:18 +0530	[thread overview]
Message-ID: <CAH1kMwSvLj8oK46V8m+FUM=t8h5Zch_Pi+zui+AYq6efDR0Sgw@mail.gmail.com> (raw)
In-Reply-To: <87o86leo34.fsf@redhat.com>

> and I find '|=' to not be very natural with booleans. I'm not sure it's
> worth changing though.

I see. But there are many functions in which '|=' is used on booleans.
get_mmio_spte(), __rmap_write_protect(), kvm_handle_gfn_range and many more.
That's why I thought it would be better if the code follows the same convention.

Thanks,
Vihas


On Mon, Nov 15, 2021 at 3:29 PM Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>
> Vihas Mak <makvihas@gmail.com> writes:
>
> > change 0 to false and 1 to true to fix following cocci warnings:
> >
> >         arch/x86/kvm/mmu/mmu.c:1485:9-10: WARNING: return of 0/1 in function 'kvm_set_pte_rmapp' with return type bool
> >         arch/x86/kvm/mmu/mmu.c:1636:10-11: WARNING: return of 0/1 in function 'kvm_test_age_rmapp' with return type bool
> >
> > Signed-off-by: Vihas Mak <makvihas@gmail.com>
> > Cc: Sean Christopherson <seanjc@google.com>
> > Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> > Cc: Wanpeng Li <wanpengli@tencent.com>
> > Cc: Jim Mattson <jmattson@google.com>
> > Cc: Joerg Roedel <joro@8bytes.org>
> > ---
> >  arch/x86/kvm/mmu/mmu.c | 10 +++++-----
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> > index 337943799..2fcea4a78 100644
> > --- a/arch/x86/kvm/mmu/mmu.c
> > +++ b/arch/x86/kvm/mmu/mmu.c
> > @@ -1454,7 +1454,7 @@ static bool kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
> >  {
> >       u64 *sptep;
> >       struct rmap_iterator iter;
> > -     int need_flush = 0;
> > +     bool need_flush = false;
> >       u64 new_spte;
> >       kvm_pfn_t new_pfn;
> >
> > @@ -1466,7 +1466,7 @@ static bool kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
> >               rmap_printk("spte %p %llx gfn %llx (%d)\n",
> >                           sptep, *sptep, gfn, level);
> >
> > -             need_flush = 1;
> > +             need_flush = true;
> >
> >               if (pte_write(pte)) {
> >                       pte_list_remove(kvm, rmap_head, sptep);
> > @@ -1482,7 +1482,7 @@ static bool kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
> >
> >       if (need_flush && kvm_available_flush_tlb_with_range()) {
> >               kvm_flush_remote_tlbs_with_address(kvm, gfn, 1);
> > -             return 0;
> > +             return false;
> >       }
> >
> >       return need_flush;
> > @@ -1623,8 +1623,8 @@ static bool kvm_test_age_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
> >
> >       for_each_rmap_spte(rmap_head, &iter, sptep)
> >               if (is_accessed_spte(*sptep))
> > -                     return 1;
> > -     return 0;
> > +                     return true;
> > +     return false;
> >  }
> >
> >  #define RMAP_RECYCLE_THRESHOLD 1000
>
> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>
> One minor remark: 'kvm_set_pte_rmapp()' handler is passed to
> 'kvm_handle_gfn_range()' which does
>
>         bool ret = false;
>
>         for_each_slot_rmap_range(...)
>                 ret |= handler(...);
>
> and I find '|=' to not be very natural with booleans. I'm not sure it's
> worth changing though.
>
> --
> Vitaly
>

  reply	other threads:[~2021-11-15 11:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-14 16:43 [PATCH] KVM: x86: fix cocci warnings Vihas Mak
2021-11-15  9:59 ` Vitaly Kuznetsov
2021-11-15 11:33   ` Vihas Mak [this message]
2021-11-16  9:50   ` Paolo Bonzini
2021-11-16 18:16     ` Nick Desaulniers
2021-11-15 11:43 ` Peter Zijlstra
2021-11-15 17:06   ` Paolo Bonzini
2021-11-15 20:49     ` Peter Zijlstra
2021-11-16  7:38       ` Paolo Bonzini

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='CAH1kMwSvLj8oK46V8m+FUM=t8h5Zch_Pi+zui+AYq6efDR0Sgw@mail.gmail.com' \
    --to=makvihas@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.