lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANRm+Cyajk9LEry3KSEt=q6EHB2v7WN87xYOa0pWhVqeJxeOeQ@mail.gmail.com>
Date:   Sun, 29 Sep 2019 08:57:55 +0800
From:   Wanpeng Li <kernellwp@...il.com>
To:     Sean Christopherson <sean.j.christopherson@...el.com>
Cc:     LKML <linux-kernel@...r.kernel.org>, kvm <kvm@...r.kernel.org>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Radim Krčmář <rkrcmar@...hat.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>,
        Marcelo Tosatti <mtosatti@...hat.com>
Subject: Re: [PATCH] KVM: Don't shrink/grow vCPU halt_poll_ns if host side
 polling is disabled

On Fri, 27 Sep 2019 at 22:42, Sean Christopherson
<sean.j.christopherson@...el.com> wrote:
>
> On Fri, Sep 27, 2019 at 04:27:02PM +0800, Wanpeng Li wrote:
> > From: Wanpeng Li <wanpengli@...cent.com>
> >
> > Don't waste cycles to shrink/grow vCPU halt_poll_ns if host
> > side polling is disabled.
> >
> > Cc: Marcelo Tosatti <mtosatti@...hat.com>
> > Signed-off-by: Wanpeng Li <wanpengli@...cent.com>
> > ---
> >  virt/kvm/kvm_main.c | 28 +++++++++++++++-------------
> >  1 file changed, 15 insertions(+), 13 deletions(-)
> >
> > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > index e6de315..b368be4 100644
> > --- a/virt/kvm/kvm_main.c
> > +++ b/virt/kvm/kvm_main.c
> > @@ -2359,20 +2359,22 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
> >       kvm_arch_vcpu_unblocking(vcpu);
> >       block_ns = ktime_to_ns(cur) - ktime_to_ns(start);
> >
> > -     if (!vcpu_valid_wakeup(vcpu))
> > -             shrink_halt_poll_ns(vcpu);
> > -     else if (halt_poll_ns) {
> > -             if (block_ns <= vcpu->halt_poll_ns)
> > -                     ;
> > -             /* we had a long block, shrink polling */
> > -             else if (vcpu->halt_poll_ns && block_ns > halt_poll_ns)
> > +     if (!kvm_arch_no_poll(vcpu)) {
>
> Can vcpu->halt_poll_ns be cached and used both here and in the similar
> check above?  E.g.:
>
>         unsigned int vcpu_halt_poll_ns;
>
>         vcpu_halt_poll_ns = kvm_arch_no_poll(vcpu) ? 0 : vcpu->halt_poll_ns;
>
>         if (vcpu_halt_poll_ns) {
>                 ...
>         }

This is not correct, !kvm_arch_no_poll(vcpu) && vcpu->halt_poll_ns ==
0, you will stop grow.

>
> > +             if (!vcpu_valid_wakeup(vcpu))
> >                       shrink_halt_poll_ns(vcpu);
> > -             /* we had a short halt and our poll time is too small */
> > -             else if (vcpu->halt_poll_ns < halt_poll_ns &&
> > -                     block_ns < halt_poll_ns)
> > -                     grow_halt_poll_ns(vcpu);
> > -     } else
> > -             vcpu->halt_poll_ns = 0;
> > +             else if (halt_poll_ns) {
> > +                     if (block_ns <= vcpu->halt_poll_ns)
> > +                             ;
> > +                     /* we had a long block, shrink polling */
> > +                     else if (vcpu->halt_poll_ns && block_ns > halt_poll_ns)
> > +                             shrink_halt_poll_ns(vcpu);
> > +                     /* we had a short halt and our poll time is too small */
> > +                     else if (vcpu->halt_poll_ns < halt_poll_ns &&
> > +                             block_ns < halt_poll_ns)
> > +                             grow_halt_poll_ns(vcpu);
> > +             } else
> > +                     vcpu->halt_poll_ns = 0;
>
>
> Not your code,

Not the truth. :)

>but it'd be a good time to add braces to the 'if' and
> 'else'.  Per Documentation/process/coding-style.rst:
>
>   Do not unnecessarily use braces where a single statement will do.
>
>   ...
>
>   This does not apply if only one branch of a conditional statement is a single
>   statement; in the latter case use braces in both branches:
>
>         if (condition) {
>                 do_this();
>                 do_that();
>         } else {
>                 otherwise();
>         }

Will do in v2.

    Wanpeng

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ