qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v1 7/7] kvm/x86: Hyper-V SynIC timers


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v1 7/7] kvm/x86: Hyper-V SynIC timers
Date: Fri, 27 Nov 2015 11:49:40 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0


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.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]