From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: amit.shah@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
quintela@redhat.com
Subject: Re: [Qemu-devel] [Qemu-ppc] Migrating decrementer
Date: Fri, 26 Feb 2016 12:29:51 +0000 [thread overview]
Message-ID: <56D0453F.4080409@ilande.co.uk> (raw)
In-Reply-To: <20160226043514.GK20657@voom.fritz.box>
On 26/02/16 04:35, David Gibson wrote:
>> 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).
Nods. The reason I really like this solution is because it correctly
handles both paused/live machines and simplifies the migration logic
significantly. In fact, with this solution the only information you
would need in vmstate_ppc_timebase for migration would be the current
tb_offset so the receiving host can calculate the guest timebase from
the virtual clock accordingly.
> 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.
Effectively I believe there are 2 cases here: TCG and KVM. For TCG all
of this is a no-op since tb/decr are already derived from the virtual
clock + tb_offset already so that really just leaves KVM.
>From what you're saying we would need 2 hooks for KVM here: one on
machine start/resume which updates tb_offset for all vCPUs and one for
vCPU resume which updates just that one particular vCPU.
Just curious as to your comment regarding helper routines for each Power
machine type - is there any reason not to enable this globally for all
Power machine types? If tb_offset isn't supported by the guest then the
problem with not being able to handle a jump in timebase post-migration
still remains exactly the same.
The other question of course relates to the reason this thread was
started which is will this approach still support migrating the
decrementer? My feeling is that this would still work in that we would
encode the number of ticks before the decrementer reaches its interrupt
value into vmstate_ppc_timebase, whether high or low. For TCG it is easy
to ensure that the decrementer will still fire in n ticks time
post-migration (which solves my particular use case), but I don't have a
feeling as to whether this is possible, or indeed desirable for KVM.
ATB,
Mark.
next prev parent reply other threads:[~2016-02-26 12:30 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-06 18:22 [Qemu-devel] [PATCH 0/4] target-ppc: migration fixups (TCG related) Mark Cave-Ayland
2016-01-06 18:22 ` [Qemu-devel] [PATCH 1/4] target-ppc: add CPU IRQ state to PPC VMStateDescription Mark Cave-Ayland
2016-01-08 2:20 ` Alexey Kardashevskiy
2016-01-06 18:22 ` [Qemu-devel] [PATCH 2/4] target-ppc: use cpu_write_xer() helper in cpu_post_load Mark Cave-Ayland
2016-01-08 2:25 ` Alexey Kardashevskiy
2016-01-18 3:12 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2016-01-18 8:31 ` Mark Cave-Ayland
2016-01-19 0:11 ` David Gibson
2016-01-06 18:22 ` [Qemu-devel] [PATCH 3/4] target-ppc: add CPU access_type into the migration stream Mark Cave-Ayland
2016-01-08 2:29 ` Alexey Kardashevskiy
2016-01-25 19:03 ` Alexander Graf
2016-01-27 1:10 ` Alexey Kardashevskiy
2016-01-06 18:22 ` [Qemu-devel] [PATCH 4/4] target-ppc: ensure we include the decrementer value during migration Mark Cave-Ayland
2016-01-08 2:47 ` Alexey Kardashevskiy
2016-01-08 14:21 ` Mark Cave-Ayland
2016-01-11 1:18 ` Alexey Kardashevskiy
2016-01-11 4:55 ` David Gibson
2016-01-11 7:43 ` Mark Cave-Ayland
2016-01-12 2:44 ` David Gibson
2016-01-15 17:46 ` Mark Cave-Ayland
2016-01-18 4:51 ` David Gibson
2016-01-25 5:48 ` [Qemu-devel] Migrating decrementer (was: Re: [PATCH 4/4] target-ppc: ensure we include the decrementer value during migration) Mark Cave-Ayland
2016-01-25 11:10 ` David Gibson
2016-01-25 17:20 ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan
2016-01-26 5:51 ` David Gibson
2016-01-26 22:31 ` [Qemu-devel] Migrating decrementer Mark Cave-Ayland
2016-01-26 23:08 ` Mark Cave-Ayland
2016-02-01 0:52 ` David Gibson
2016-02-02 23:41 ` Mark Cave-Ayland
2016-02-03 4:59 ` David Gibson
2016-02-03 5:43 ` Alexander Graf
2016-02-23 21:27 ` Mark Cave-Ayland
2016-02-24 0:47 ` David Gibson
2016-02-24 12:31 ` Juan Quintela
2016-02-25 0:19 ` David Gibson
2016-02-25 4:33 ` Mark Cave-Ayland
2016-02-25 5:00 ` [Qemu-devel] [Qemu-ppc] " Mark Cave-Ayland
2016-02-25 9:50 ` Mark Cave-Ayland
2016-02-26 4:35 ` David Gibson
2016-02-26 12:29 ` Mark Cave-Ayland [this message]
2016-02-29 3:57 ` David Gibson
2016-02-29 20:21 ` Mark Cave-Ayland
2016-03-10 4:57 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56D0453F.4080409@ilande.co.uk \
--to=mark.cave-ayland@ilande.co.uk \
--cc=amit.shah@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).