From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2H95-0004Xx-94 for qemu-devel@nongnu.org; Fri, 27 Nov 2015 06:24:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a2H92-0001yy-Jp for qemu-devel@nongnu.org; Fri, 27 Nov 2015 06:24:55 -0500 Received: from relay.parallels.com ([195.214.232.42]:56280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2H92-0001y9-Ax for qemu-devel@nongnu.org; Fri, 27 Nov 2015 06:24:52 -0500 References: <1448464821-8199-1-git-send-email-asmetanin@virtuozzo.com> <1448464821-8199-8-git-send-email-asmetanin@virtuozzo.com> <20151127081244.GC2808@rkaganb.sw.ru> <56583544.3040600@redhat.com> From: Andrey Smetanin Message-ID: <56583D71.4050009@virtuozzo.com> Date: Fri, 27 Nov 2015 14:24:33 +0300 MIME-Version: 1.0 In-Reply-To: <56583544.3040600@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v1 7/7] kvm/x86: Hyper-V SynIC timers Reply-To: asmetanin@virtuozzo.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , Roman Kagan , kvm@vger.kernel.org, Gleb Natapov , "K. Y. Srinivasan" , Haiyang Zhang , Vitaly Kuznetsov , "Denis V. Lunev" , qemu-devel@nongnu.org On 11/27/2015 01:49 PM, Paolo Bonzini wrote: > > > On 27/11/2015 09:12, Roman Kagan wrote: >>>> + n = div64_u64(time_now - stimer->exp_time, stimer->count) + 1; >>>> + stimer->exp_time += n * stimer->count; >> This is actually just a reminder calculation so I'd rather do it >> directly with div64_u64_rem(). > > It took me a while to understand why it was a remained. :) Expanding > Andrey's formula you get > > exp_time = exp_time + count + (time_now - exp_time) / count * count > > the remainder, (time_now - exp_time) % count would be > > time_now - exp_time - (time_now - exp_time) / count * count > > so -((time_now - exp_time) % count) is > > exp_time - time_now + (time_now - exp_time) / count * count > > so Andrey's expression is > > exp_time = time_now + (count - (time_now - exp_time) % count) > > Yeah, that looks nice. I'll redo this way. > > Paolo >