From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751800AbdJFOwC (ORCPT ); Fri, 6 Oct 2017 10:52:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59778 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750950AbdJFOwA (ORCPT ); Fri, 6 Oct 2017 10:52:00 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 606057EA92 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [PATCH v8] KVM: LAPIC: Apply change to TDCR right away to the timer To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li References: <1507300712-9317-1-git-send-email-wanpeng.li@hotmail.com> From: Paolo Bonzini Message-ID: <12d7651f-868e-aaec-6e91-a53f9819d817@redhat.com> Date: Fri, 6 Oct 2017 16:51:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1507300712-9317-1-git-send-email-wanpeng.li@hotmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 06 Oct 2017 14:52:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/10/2017 16:38, Wanpeng Li wrote: > + now = ktime_get(); > + remaining = ktime_sub(apic->lapic_timer.target_expiration, now); Still need to compare against zero here. I guess Radim can do it. Paolo > + ns_remaining_old = ktime_to_ns(remaining); > + ns_remaining_new = mul_u64_u32_div(ns_remaining_old, > + apic->divide_count, old_divisor); > + > + apic->lapic_timer.tscdeadline += nsec_to_cycles(apic->vcpu, ns_remaining_new) - > + nsec_to_cycles(apic->vcpu, ns_remaining_old); > + apic->lapic_timer.target_expiration = ktime_add_ns(now, ns_remaining_new);