Re: [PATCH v2 4/4] x86/kvm/hyper-v: avoid open-coding stimer_mark_pending() in kvm_hv_notify_acked_sint()

2018-11-27 Thread Roman Kagan
On Mon, Nov 26, 2018 at 04:47:32PM +0100, Vitaly Kuznetsov wrote:
> stimers_pending optimization only helps us to avoid multiple
> kvm_make_request() calls. This doesn't happen very often and these
> calls are very cheap in the first place, remove open-coded version of
> stimer_mark_pending() from kvm_hv_notify_acked_sint().

Frankly speaking, I've yet to see a guest that configures more than one
SynIC timer.  So it was indeed a bit of overengineering in the first
place.

> Suggested-by: Paolo Bonzini 
> Signed-off-by: Vitaly Kuznetsov 
> ---
>  arch/x86/kvm/hyperv.c | 12 +++-
>  1 file changed, 3 insertions(+), 9 deletions(-)

Reviewed-by: Roman Kagan 


Re: [PATCH v2 4/4] x86/kvm/hyper-v: avoid open-coding stimer_mark_pending() in kvm_hv_notify_acked_sint()

2018-11-27 Thread Roman Kagan
On Mon, Nov 26, 2018 at 04:47:32PM +0100, Vitaly Kuznetsov wrote:
> stimers_pending optimization only helps us to avoid multiple
> kvm_make_request() calls. This doesn't happen very often and these
> calls are very cheap in the first place, remove open-coded version of
> stimer_mark_pending() from kvm_hv_notify_acked_sint().

Frankly speaking, I've yet to see a guest that configures more than one
SynIC timer.  So it was indeed a bit of overengineering in the first
place.

> Suggested-by: Paolo Bonzini 
> Signed-off-by: Vitaly Kuznetsov 
> ---
>  arch/x86/kvm/hyperv.c | 12 +++-
>  1 file changed, 3 insertions(+), 9 deletions(-)

Reviewed-by: Roman Kagan 


Re: [PATCH v2 4/4] x86/kvm/hyper-v: avoid open-coding stimer_mark_pending() in kvm_hv_notify_acked_sint()

2018-11-26 Thread Paolo Bonzini
On 26/11/18 16:47, Vitaly Kuznetsov wrote:
> stimers_pending optimization only helps us to avoid multiple
> kvm_make_request() calls. This doesn't happen very often and these
> calls are very cheap in the first place, remove open-coded version of
> stimer_mark_pending() from kvm_hv_notify_acked_sint().

I wouldn't say very cheap, but still relatively cheap compared to a vmexit.

Paolo


Re: [PATCH v2 4/4] x86/kvm/hyper-v: avoid open-coding stimer_mark_pending() in kvm_hv_notify_acked_sint()

2018-11-26 Thread Paolo Bonzini
On 26/11/18 16:47, Vitaly Kuznetsov wrote:
> stimers_pending optimization only helps us to avoid multiple
> kvm_make_request() calls. This doesn't happen very often and these
> calls are very cheap in the first place, remove open-coded version of
> stimer_mark_pending() from kvm_hv_notify_acked_sint().

I wouldn't say very cheap, but still relatively cheap compared to a vmexit.

Paolo


[PATCH v2 4/4] x86/kvm/hyper-v: avoid open-coding stimer_mark_pending() in kvm_hv_notify_acked_sint()

2018-11-26 Thread Vitaly Kuznetsov
stimers_pending optimization only helps us to avoid multiple
kvm_make_request() calls. This doesn't happen very often and these
calls are very cheap in the first place, remove open-coded version of
stimer_mark_pending() from kvm_hv_notify_acked_sint().

Suggested-by: Paolo Bonzini 
Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/kvm/hyperv.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 9533133be566..e6a2a085644a 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -206,7 +206,7 @@ static void kvm_hv_notify_acked_sint(struct kvm_vcpu *vcpu, 
u32 sint)
struct kvm_vcpu_hv_synic *synic = vcpu_to_synic(vcpu);
struct kvm_vcpu_hv *hv_vcpu = vcpu_to_hv_vcpu(vcpu);
struct kvm_vcpu_hv_stimer *stimer;
-   int gsi, idx, stimers_pending;
+   int gsi, idx;
 
trace_kvm_hv_notify_acked_sint(vcpu->vcpu_id, sint);
 
@@ -214,19 +214,13 @@ static void kvm_hv_notify_acked_sint(struct kvm_vcpu 
*vcpu, u32 sint)
synic_clear_sint_msg_pending(synic, sint);
 
/* Try to deliver pending Hyper-V SynIC timers messages */
-   stimers_pending = 0;
for (idx = 0; idx < ARRAY_SIZE(hv_vcpu->stimer); idx++) {
stimer = _vcpu->stimer[idx];
if (stimer->msg_pending && stimer->config.enable &&
!stimer->config.direct_mode &&
-   stimer->config.sintx == sint) {
-   set_bit(stimer->index,
-   hv_vcpu->stimer_pending_bitmap);
-   stimers_pending++;
-   }
+   stimer->config.sintx == sint)
+   stimer_mark_pending(stimer, false);
}
-   if (stimers_pending)
-   kvm_make_request(KVM_REQ_HV_STIMER, vcpu);
 
idx = srcu_read_lock(>irq_srcu);
gsi = atomic_read(>sint_to_gsi[sint]);
-- 
2.19.1



[PATCH v2 4/4] x86/kvm/hyper-v: avoid open-coding stimer_mark_pending() in kvm_hv_notify_acked_sint()

2018-11-26 Thread Vitaly Kuznetsov
stimers_pending optimization only helps us to avoid multiple
kvm_make_request() calls. This doesn't happen very often and these
calls are very cheap in the first place, remove open-coded version of
stimer_mark_pending() from kvm_hv_notify_acked_sint().

Suggested-by: Paolo Bonzini 
Signed-off-by: Vitaly Kuznetsov 
---
 arch/x86/kvm/hyperv.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 9533133be566..e6a2a085644a 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -206,7 +206,7 @@ static void kvm_hv_notify_acked_sint(struct kvm_vcpu *vcpu, 
u32 sint)
struct kvm_vcpu_hv_synic *synic = vcpu_to_synic(vcpu);
struct kvm_vcpu_hv *hv_vcpu = vcpu_to_hv_vcpu(vcpu);
struct kvm_vcpu_hv_stimer *stimer;
-   int gsi, idx, stimers_pending;
+   int gsi, idx;
 
trace_kvm_hv_notify_acked_sint(vcpu->vcpu_id, sint);
 
@@ -214,19 +214,13 @@ static void kvm_hv_notify_acked_sint(struct kvm_vcpu 
*vcpu, u32 sint)
synic_clear_sint_msg_pending(synic, sint);
 
/* Try to deliver pending Hyper-V SynIC timers messages */
-   stimers_pending = 0;
for (idx = 0; idx < ARRAY_SIZE(hv_vcpu->stimer); idx++) {
stimer = _vcpu->stimer[idx];
if (stimer->msg_pending && stimer->config.enable &&
!stimer->config.direct_mode &&
-   stimer->config.sintx == sint) {
-   set_bit(stimer->index,
-   hv_vcpu->stimer_pending_bitmap);
-   stimers_pending++;
-   }
+   stimer->config.sintx == sint)
+   stimer_mark_pending(stimer, false);
}
-   if (stimers_pending)
-   kvm_make_request(KVM_REQ_HV_STIMER, vcpu);
 
idx = srcu_read_lock(>irq_srcu);
gsi = atomic_read(>sint_to_gsi[sint]);
-- 
2.19.1