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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87d0bjiz5y.fsf@vitty.brq.redhat.com>
Date:   Thu, 16 Jan 2020 09:27:37 +0100
From:   Vitaly Kuznetsov <vkuznets@...hat.com>
To:     Haiwei Li <lihaiwei.kernel@...il.com>
Cc:     "pbonzini\@redhat.com" <pbonzini@...hat.com>,
        Sean Christopherson <sean.j.christopherson@...el.com>,
        "wanpengli\@tencent.com" <wanpengli@...cent.com>,
        "jmattson\@google.com" <jmattson@...gle.com>,
        "joro\@8bytes.org" <joro@...tes.org>,
        "tglx\@linutronix.de" <tglx@...utronix.de>,
        "mingo\@redhat.com" <mingo@...hat.com>, bp@...en8.de,
        "hpa\@zytor.com" <hpa@...or.com>,
        "linux-kernel\@vger.kernel.org" <linux-kernel@...r.kernel.org>,
        "kvm\@vger.kernel.org" <kvm@...r.kernel.org>,
        "x86\@kernel.org" <x86@...nel.org>
Subject: Re: [PATCH] KVM: Adding 'else' to reduce checking.

Haiwei Li <lihaiwei.kernel@...il.com> writes:

>  From 4e19436679a97e3cee73b4ae613ff91580c721d2 Mon Sep 17 00:00:00 2001
> From: Haiwei Li <lihaiwei@...cent.com>
> Date: Thu, 16 Jan 2020 13:51:03 +0800
> Subject: [PATCH] Adding 'else' to reduce checking.
>
> These two conditions are in conflict, adding 'else' to reduce checking.
>
> Signed-off-by: Haiwei Li <lihaiwei@...cent.com>
> ---
>   arch/x86/kvm/lapic.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 679692b..ef5802f 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1573,7 +1573,7 @@ static void 
> kvm_apic_inject_pending_timer_irqs(struct kvm_lapic *apic)
>          kvm_apic_local_deliver(apic, APIC_LVTT);
>          if (apic_lvtt_tscdeadline(apic))
>                  ktimer->tscdeadline = 0;
> -       if (apic_lvtt_oneshot(apic)) {
> +       else if (apic_lvtt_oneshot(apic)) {
>                  ktimer->tscdeadline = 0;
>                  ktimer->target_expiration = 0;
>          }

I bet the compiler will generate the exact same code
(apic_lvtt_tscdeadline() and apic_lvtt_oneshot() are inlines), however,
I think your patch is still worthy: 'else' makes it obvious it's either
one or another and not both.

One nitpick: coding style requires braces even for single statements in
case other branches require them so in your case it should now be:

if (apic_lvtt_tscdeadline(apic)) {
	ktimer->tscdeadline = 0;
} else if (apic_lvtt_oneshot(apic)) {
        ktimer->tscdeadline = 0;
        ktimer->target_expiration = 0;
}

With that,

Reviewed-by: Vitaly Kuznetsov <vkuznets@...hat.com>

-- 
Vitaly

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ