2019-07-31 12:39:04

by Wanpeng Li

[permalink] [raw]
Subject: [PATCH 1/3] KVM: Don't need to wakeup vCPU twice afer timer fire

From: Wanpeng Li <[email protected]>

kvm_set_pending_timer() will take care to wake up the sleeping vCPU which
has pending timer, don't need to check this in apic_timer_expired() again.

Cc: Paolo Bonzini <[email protected]>
Cc: Radim Krčmář <[email protected]>
Signed-off-by: Wanpeng Li <[email protected]>
---
arch/x86/kvm/lapic.c | 8 --------
1 file changed, 8 deletions(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 0aa1586..685d17c 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1548,7 +1548,6 @@ static void kvm_apic_inject_pending_timer_irqs(struct kvm_lapic *apic)
static void apic_timer_expired(struct kvm_lapic *apic)
{
struct kvm_vcpu *vcpu = apic->vcpu;
- struct swait_queue_head *q = &vcpu->wq;
struct kvm_timer *ktimer = &apic->lapic_timer;

if (atomic_read(&apic->lapic_timer.pending))
@@ -1566,13 +1565,6 @@ static void apic_timer_expired(struct kvm_lapic *apic)

atomic_inc(&apic->lapic_timer.pending);
kvm_set_pending_timer(vcpu);
-
- /*
- * For x86, the atomic_inc() is serialized, thus
- * using swait_active() is safe.
- */
- if (swait_active(q))
- swake_up_one(q);
}

static void start_sw_tscdeadline(struct kvm_lapic *apic)
--
2.7.4


2019-07-31 13:03:02

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH 1/3] KVM: Don't need to wakeup vCPU twice afer timer fire

On 31/07/19 13:27, Wanpeng Li wrote:
> From: Wanpeng Li <[email protected]>
>
> kvm_set_pending_timer() will take care to wake up the sleeping vCPU which
> has pending timer, don't need to check this in apic_timer_expired() again.

No, it doesn't. kvm_make_request never kicks the vCPU.

Paolo

> Cc: Paolo Bonzini <[email protected]>
> Cc: Radim Krčmář <[email protected]>
> Signed-off-by: Wanpeng Li <[email protected]>
> ---
> arch/x86/kvm/lapic.c | 8 --------
> 1 file changed, 8 deletions(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 0aa1586..685d17c 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1548,7 +1548,6 @@ static void kvm_apic_inject_pending_timer_irqs(struct kvm_lapic *apic)
> static void apic_timer_expired(struct kvm_lapic *apic)
> {
> struct kvm_vcpu *vcpu = apic->vcpu;
> - struct swait_queue_head *q = &vcpu->wq;
> struct kvm_timer *ktimer = &apic->lapic_timer;
>
> if (atomic_read(&apic->lapic_timer.pending))
> @@ -1566,13 +1565,6 @@ static void apic_timer_expired(struct kvm_lapic *apic)
>
> atomic_inc(&apic->lapic_timer.pending);
> kvm_set_pending_timer(vcpu);
> -
> - /*
> - * For x86, the atomic_inc() is serialized, thus
> - * using swait_active() is safe.
> - */
> - if (swait_active(q))
> - swake_up_one(q);
> }
>
> static void start_sw_tscdeadline(struct kvm_lapic *apic)
>

2019-07-31 13:15:24

by Vitaly Kuznetsov

[permalink] [raw]
Subject: Re: [PATCH 1/3] KVM: Don't need to wakeup vCPU twice afer timer fire

Paolo Bonzini <[email protected]> writes:

> On 31/07/19 13:27, Wanpeng Li wrote:
>> From: Wanpeng Li <[email protected]>
>>
>> kvm_set_pending_timer() will take care to wake up the sleeping vCPU which
>> has pending timer, don't need to check this in apic_timer_expired() again.
>
> No, it doesn't. kvm_make_request never kicks the vCPU.
>

Hm, but kvm_set_pending_timer() currently looks like:

void kvm_set_pending_timer(struct kvm_vcpu *vcpu)
{
kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu);
kvm_vcpu_kick(vcpu);
}

--
Vitaly

2019-07-31 17:44:10

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH 1/3] KVM: Don't need to wakeup vCPU twice afer timer fire

On 31/07/19 15:14, Vitaly Kuznetsov wrote:
> Paolo Bonzini <[email protected]> writes:
>
>> On 31/07/19 13:27, Wanpeng Li wrote:
>>> From: Wanpeng Li <[email protected]>
>>>
>>> kvm_set_pending_timer() will take care to wake up the sleeping vCPU which
>>> has pending timer, don't need to check this in apic_timer_expired() again.
>>
>> No, it doesn't. kvm_make_request never kicks the vCPU.
>>
>
> Hm, but kvm_set_pending_timer() currently looks like:
>
> void kvm_set_pending_timer(struct kvm_vcpu *vcpu)
> {
> kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu);
> kvm_vcpu_kick(vcpu);
> }

Doing "git fetch" could have helped indeed.

Paolo