From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752190AbdJFPCG (ORCPT ); Fri, 6 Oct 2017 11:02:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41370 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751515AbdJFPCF (ORCPT ); Fri, 6 Oct 2017 11:02:05 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2D3537C842 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=rkrcmar@redhat.com Date: Fri, 6 Oct 2017 17:02:00 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Wanpeng Li Subject: Re: [PATCH v8] KVM: LAPIC: Apply change to TDCR right away to the timer Message-ID: <20171006150200.GE16466@flask> References: <1507300712-9317-1-git-send-email-wanpeng.li@hotmail.com> <12d7651f-868e-aaec-6e91-a53f9819d817@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <12d7651f-868e-aaec-6e91-a53f9819d817@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 06 Oct 2017 15:02:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-10-06 16:51+0200, Paolo Bonzini: > 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. I added the expression from v7 while applying, thanks. if (ktime_to_ns(remaining) < 0) remaining = 0; > > + 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);