Re: [PATCH v3 5/5] KVM: LAPIC: Optimize timer latency further
From: Sean Christopherson
Date: Mon May 20 2019 - 11:10:55 EST
On Mon, May 20, 2019 at 04:19:47PM +0800, Wanpeng Li wrote:
> On Sat, 18 May 2019 at 03:50, Sean Christopherson
> <sean.j.christopherson@xxxxxxxxx> wrote:
> >
> > On Thu, May 16, 2019 at 11:06:20AM +0800, Wanpeng Li wrote:
> > > From: Wanpeng Li <wanpengli@xxxxxxxxxxx>
> > > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> > > index 6b92eaf..955cfcb 100644
> > > --- a/arch/x86/kvm/svm.c
> > > +++ b/arch/x86/kvm/svm.c
> > > @@ -5638,6 +5638,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
> > > clgi();
> > > kvm_load_guest_xcr0(vcpu);
> > >
> > > + if (lapic_in_kernel(vcpu) &&
> > > + vcpu->arch.apic->lapic_timer.timer_advance_ns)
> >
> > Nit: align the two lines of the if statement, doing so makes it easier to
> > differentiate between the condition and execution, e.g.:
> >
> > if (lapic_in_kernel(vcpu) &&
> > vcpu->arch.apic->lapic_timer.timer_advance_ns)
> > kvm_wait_lapic_expire(vcpu);
>
> This can result in checkpatch.pl complain:
>
> WARNING: suspect code indent for conditional statements (8, 24)
> #94: FILE: arch/x86/kvm/vmx/vmx.c:6436:
> + if (lapic_in_kernel(vcpu) &&
> [...]
> + kvm_wait_lapic_expire(vcpu);
That warning fires when the last line of the check and the code block of
the if statement are aligned (and the indent isn't a full tab stop, which
is why your original code isn't flagged). Examples with explicit leading
whitespace:
Good:
\tif (lapic_in_kernel(vcpu) &&
\t\s\s\s\svcpu->arch.apic->lapic_timer.timer_advance_ns)
\t\tkvm_wait_lapic_expire(vcpu);
Bad:
\tif (lapic_in_kernel(vcpu) &&
\t\s\s\s\svcpu->arch.apic->lapic_timer.timer_advance_ns)
\t\s\s\s\skvm_wait_lapic_expire(vcpu);