qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Qemu-ppc] Migrating decrementer


From: David Gibson
Subject: Re: [Qemu-devel] [Qemu-ppc] Migrating decrementer
Date: Fri, 26 Feb 2016 15:35:14 +1100
User-agent: Mutt/1.5.24 (2015-08-30)

On Thu, Feb 25, 2016 at 09:50:20AM +0000, Mark Cave-Ayland wrote:
> On 25/02/16 05:00, Mark Cave-Ayland wrote:
> 
> > On 25/02/16 04:33, Mark Cave-Ayland wrote:
> > 
> >> cpu_start/resume():
> >>     cpu->tb_env->tb_offset =
> >>         qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) * tb_env->tb_freq +
> >>             cpu->tb_env->tb_offset -
> >>         qemu_clock_get_ns(QEMU_CLOCK_HOST)
> > 
> > Actually just realised this is slightly wrong and in fact should be:
> > 
> > cpu_start/resume():
> >     cpu->tb_env->tb_offset =
> >         muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
> >                  cpu->tb_env->tb_freq, NANOSECONDS_PER_SECOND) +
> >             cpu->tb_env->tb_offset -
> >         qemu_clock_get_ns(QEMU_CLOCK_HOST)
> 
> Sign. And let me try that again, this time after caffeine:
> 
> cpu_start/resume():
>     cpu->tb_env->tb_offset =
>         muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
>                  cpu->tb_env->tb_freq, NANOSECONDS_PER_SECOND) +
>             cpu->tb_env->tb_offset -
>         cpu_get_host_ticks();
> 
> This should translate to: at CPU start, calculate the difference between
> the current guest virtual timebase and the host timebase, storing the
> difference in cpu->tb_env->tb_offset.

Ummm... I think that's right.  Except that you need to make sure you
calculate the tb_offset just once, and set the same value to all guest
CPUs.  Otherwise the guest TBs may be slightly out of sync with each
other, which is bad (the host should have already ensure that all host
TBs are in sync with each other).

We really should make helper routines that each Power machine type can
use for this.  Unfortunately we can't put it directly into the common
ppc cpu migration code because of the requirement to keep the TBs
synced across the machine.

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

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