* Re: [PATCH] KVM: Adding 'else' to reduce checking.
@ 2020-01-16 8:51 linmiaohe
0 siblings, 0 replies; 3+ messages in thread
From: linmiaohe @ 2020-01-16 8:51 UTC (permalink / raw)
To: Haiwei Li, vkuznets
Cc: pbonzini, Sean Christopherson, wanpengli, jmattson, joro, tglx,
mingo, bp, hpa, linux-kernel, kvm, x86
Hi:
Haiwei Li <lihaiwei.kernel@gmail.com> writes:
> From 4e19436679a97e3cee73b4ae613ff91580c721d2 Mon Sep 17 00:00:00 2001
> From: Haiwei Li <lihaiwei@tencent.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@tencent.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;
> }
Except for the coding style figured out by Vitaly, this patch looks fine for me. So:
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: Adding 'else' to reduce checking.
2020-01-16 6:03 Haiwei Li
@ 2020-01-16 8:27 ` Vitaly Kuznetsov
0 siblings, 0 replies; 3+ messages in thread
From: Vitaly Kuznetsov @ 2020-01-16 8:27 UTC (permalink / raw)
To: Haiwei Li
Cc: pbonzini, Sean Christopherson, wanpengli, jmattson, joro, tglx,
mingo, bp, hpa, linux-kernel, kvm, x86
Haiwei Li <lihaiwei.kernel@gmail.com> writes:
> From 4e19436679a97e3cee73b4ae613ff91580c721d2 Mon Sep 17 00:00:00 2001
> From: Haiwei Li <lihaiwei@tencent.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@tencent.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@redhat.com>
--
Vitaly
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] KVM: Adding 'else' to reduce checking.
@ 2020-01-16 6:03 Haiwei Li
2020-01-16 8:27 ` Vitaly Kuznetsov
0 siblings, 1 reply; 3+ messages in thread
From: Haiwei Li @ 2020-01-16 6:03 UTC (permalink / raw)
To: linux-kernel, kvm, x86
Cc: pbonzini, Sean Christopherson, vkuznets, wanpengli, jmattson,
joro, tglx, mingo, bp, hpa
From 4e19436679a97e3cee73b4ae613ff91580c721d2 Mon Sep 17 00:00:00 2001
From: Haiwei Li <lihaiwei@tencent.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@tencent.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;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-16 8:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16 8:51 [PATCH] KVM: Adding 'else' to reduce checking linmiaohe
-- strict thread matches above, loose matches on Subject: below --
2020-01-16 6:03 Haiwei Li
2020-01-16 8:27 ` Vitaly Kuznetsov
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.