From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754679AbcESL4N (ORCPT ); Thu, 19 May 2016 07:56:13 -0400 Received: from e06smtp05.uk.ibm.com ([195.75.94.101]:44415 "EHLO e06smtp05.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754464AbcESL4M (ORCPT ); Thu, 19 May 2016 07:56:12 -0400 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: borntraeger@de.ibm.com X-IBM-RcptTo: kvm@vger.kernel.org;linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: halt-polling: poll if emulated lapic timer will fire soon To: Wanpeng Li References: <1463649990-5889-1-git-send-email-wanpeng.li@hotmail.com> <573DA24D.3080507@de.ibm.com> <573DA6A8.1000401@de.ibm.com> Cc: "linux-kernel@vger.kernel.org" , kvm , Wanpeng Li , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , David Matlack From: Christian Borntraeger Message-ID: <573DA9D3.3070205@de.ibm.com> Date: Thu, 19 May 2016 13:56:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16051911-0021-0000-0000-00001BE73A60 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/19/2016 01:48 PM, Wanpeng Li wrote: > 2016-05-19 19:42 GMT+08:00 Christian Borntraeger : >> On 05/19/2016 01:35 PM, Wanpeng Li wrote: >>> 2016-05-19 19:23 GMT+08:00 Christian Borntraeger : >>>> On 05/19/2016 11:26 AM, Wanpeng Li wrote: >>>> >>>> I think in general a good idea to poll if a timer will expire soon. >>>> >>>> Some patch comments: >>>> >>>> Same for all non-x86 archs: >>>>> +static inline unsigned int kvm_arch_timer_remaining(struct kvm_vcpu *vcpu) {} >>>> >>>> A function returning int, without a return statement? >>>> That gives at least a compiler warning. >>> >>> How about return 0 for all non-x86 archs? >> >> We will provide an s390 implementation soon, but until then a proper >> default would be good. >> >> [....] >>>>> + if (vcpu->halt_poll_ns || (remaining < halt_poll_ns_base)) { >> >> but then remaining is 0 and the 2nd condition will always be true, no? > > Nice catch! > > How about something like below: > > + if (vcpu->halt_poll_ns || > + (remaining != 0 && remaining < halt_poll_ns_base)) { Maybe just use -1UL to have a "will never expire" and change the return value into u64 while changing that.