[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANRm+Cwbho+33dO1jNUF8W+J2s9w2kZSXJ-WEftYqashfUZ5pA@mail.gmail.com>
Date: Tue, 24 May 2016 10:48:53 +0800
From: Wanpeng Li <kernellwp@...il.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
kvm <kvm@...r.kernel.org>, Wanpeng Li <wanpeng.li@...mail.com>,
Radim Krčmář <rkrcmar@...hat.com>,
David Matlack <dmatlack@...gle.com>,
Christian Borntraeger <borntraeger@...ibm.com>
Subject: Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will
fire soon
2016-05-19 21:57 GMT+08:00 Paolo Bonzini <pbonzini@...hat.com>:
>
>
> On 19/05/2016 15:27, Wanpeng Li wrote:
>> From: Wanpeng Li <wanpeng.li@...mail.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?
>
> 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);
> 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?
Add ~6% more time in C0 above mine.
Regards,
Wanpeng Li
Powered by blists - more mailing lists