Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1403799

Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will fire soon

From Christian Borntraeger <borntraeger@de.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will fire soon
Date 2016-05-19 17:00 +0200
Message-ID <rAxAC-16l-29@gated-at.bofh.it> (permalink)
References <rAwbv-kQ-3@gated-at.bofh.it> <rAwEx-vI-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 05/19/2016 03:57 PM, Paolo Bonzini wrote:
> 
> 
> On 19/05/2016 15:27, Wanpeng Li wrote:
>> From: Wanpeng Li <wanpeng.li@hotmail.com>
>>
>> If an emulated lapic timer will fire soon(in the scope of 10us the
>> base of dynamic halt-polling, lower-end of message passing workload
>> latency TCP_RR's poll time < 10us) we can treat it as a short halt,
>> and poll to wait it fire, the fire callback apic_timer_fn() will set
>> KVM_REQ_PENDING_TIMER, and this flag will be check during busy poll.
>> This can avoid context switch overhead and the latency which we wake
>> up vCPU.
> 
> Would this work too and be simpler?

Hmm, your patch does only fiddle with the grow/shrink logic (which might
be a good idea independently of this change), but the original patch 
actually takes into account that we have a guaranteed maximum time by a 
wakeup timer - IOW we know exactly what the maximum poll time is.

> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 4fd482fb9260..8d42f5304d94 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1964,16 +1964,12 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
> 
>  	old = val = vcpu->halt_poll_ns;
>  	grow = READ_ONCE(halt_poll_ns_grow);
> -	/* 10us base */
> -	if (val == 0 && grow)
> -		val = 10000;
> -	else
> -		val *= grow;
> +	val *= grow;
> 
>  	if (val > halt_poll_ns)
>  		val = halt_poll_ns;
> 
> -	vcpu->halt_poll_ns = val;
> +	vcpu->halt_poll_ns = max(10000u, val);

>  	trace_kvm_halt_poll_ns_grow(vcpu->vcpu_id, val, old);
>  }
> 
> @@ -1988,7 +1984,7 @@ static void shrink_halt_poll_ns(struct kvm_vcpu *vcpu)
>  	else
>  		val /= shrink;
> 
> -	vcpu->halt_poll_ns = val;
> +	vcpu->halt_poll_ns = max(10000u, val);

That would prevent halt_poll_ns from going 0, no?


>  	trace_kvm_halt_poll_ns_shrink(vcpu->vcpu_id, val, old);
>  }
> 
> 
> (Plus moving 10000 into a module parameter?)  Can you measure higher CPU
> utilization than with your patch?  David, what do you think?
> 
> Thanks,
> 
> Paolo
> 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2] KVM: halt-polling: poll if emulated lapic timer will fire soon Wanpeng Li <kernellwp@gmail.com> - 2016-05-19 15:30 +0200
  Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Christian Borntraeger <borntraeger@de.ibm.com> - 2016-05-19 15:50 +0200
  Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Paolo Bonzini <pbonzini@redhat.com> - 2016-05-19 16:00 +0200
    Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Christian Borntraeger <borntraeger@de.ibm.com> - 2016-05-19 17:00 +0200
      Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Paolo Bonzini <pbonzini@redhat.com> - 2016-05-19 17:00 +0200
        Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Paolo Bonzini <pbonzini@redhat.com> - 2016-05-19 17:10 +0200
          Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Christian Borntraeger <borntraeger@de.ibm.com> - 2016-05-19 17:50 +0200
        Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Christian Borntraeger <borntraeger@de.ibm.com> - 2016-05-19 17:10 +0200
    Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Wanpeng Li <kernellwp@gmail.com> - 2016-05-24 04:50 +0200
  Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon David Matlack <dmatlack@google.com> - 2016-05-19 20:10 +0200
    Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon David Matlack <dmatlack@google.com> - 2016-05-19 20:40 +0200
      Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Yang Zhang <yang.zhang.wz@gmail.com> - 2016-05-20 04:10 +0200
        Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Wanpeng Li <kernellwp@gmail.com> - 2016-05-20 08:00 +0200
        Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon David Matlack <dmatlack@google.com> - 2016-05-20 20:40 +0200
          Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Yang Zhang <yang.zhang.wz@gmail.com> - 2016-05-23 03:30 +0200
            Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon David Matlack <dmatlack@google.com> - 2016-05-23 20:10 +0200
              Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Yang Zhang <yang.zhang.wz@gmail.com> - 2016-05-24 03:20 +0200
                Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon David Matlack <dmatlack@google.com> - 2016-05-24 03:20 +0200
                Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will  fire soon Yang Zhang <yang.zhang.wz@gmail.com> - 2016-05-24 05:00 +0200

csiph-web