From: Stefano Stabellini Subject: Re: HVM Migration of domU on Qemu-upstream DM causes stuck system clock with ACPI Date: Mon, 3 Jun 2013 11:30:47 +0100 Message-ID: References: <1717491994.10371605.1369131737226.JavaMail.root@zimbra002> <519B6D51.2060508@citrix.com> <951B3441BAE2324286D3AA6D@Ximines.local> <420439EA40B15FCBFDFF2BE3@nimrod.local> <1369557503.22605.11.camel@dagon.hellion.org.uk> <51A4C7EB.1010406@flexiant.com> <51A7767A.9030904@flexiant.com> <51A7791C.2020208@eu.citrix.com> <51A8608F.9000302@flexiant.com> <51A88151.3080001@eu.citrix.com> <0FE70400-1152-45F5-9BF9-973DF1DA9EE8@flexiant.com> <51A88E3E.5090208@eu.citrix.com> <1370004031.5199.133.camel@zakaz.uk.xensource.com> <51A8A0AC.1030301@eu.citrix.com> <51A8BD48.6060104@citrix.com> <51AC55DD.7000507@citrix.com> <51AC6EB6.2010108@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="1342847746-761403387-1370255447=:4589" Return-path: In-Reply-To: <51AC6EB6.2010108@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: Ian Campbell , Konrad Rzeszutek Wilk , George Dunlap , Stefano Stabellini , xen-devel@lists.xen.org, David Vrabel , Alex Bligh , Anthony PERARD , Diana Crisan List-Id: xen-devel@lists.xenproject.org --1342847746-761403387-1370255447=:4589 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: QUOTED-PRINTABLE On Mon, 3 Jun 2013, Roger Pau Monn=C3=A9 wrote: > On 03/06/13 12:05, Stefano Stabellini wrote: > > On Mon, 3 Jun 2013, Roger Pau Monn=C3=A9 wrote: > >> On 31/05/13 17:10, Roger Pau Monn=C3=A9 wrote: > >>> On 31/05/13 15:07, George Dunlap wrote: > >>>> On 31/05/13 13:40, Ian Campbell wrote: > >>>>> On Fri, 2013-05-31 at 12:57 +0100, Alex Bligh wrote: > >>>>>> --On 31 May 2013 12:49:18 +0100 George Dunlap > >>>>>> > >>>>>> wrote: > >>>>>> > >>>>>>> No -- Linux is asking, "Can you give me an alarm in 5ns?" And Xe= n is > >>>>>>> saying, "No". So Linux is saying, "OK, how about 5us? 10us? > >>>>>>> 20us?" By > >>>>>>> the time it reaches 4ms, Linux has had enough, and says, "If this= timer > >>>>>>> is so bad that it can't give me an event within 4ms it just won't= use > >>>>>>> timers at all, thank you very much." > >>>>>>> > >>>>>>> The problem appears to be that Linux thinks it's asking for > >>>>>>> something in > >>>>>>> the future, but is actually asking for something in the past. It= must > >>>>>>> look at its watch just before the final domain pause, and then as= ks for > >>>>>>> the time just after the migration resumes on the other side. So = it > >>>>>>> doesn't realize that 10ms (or something) has already passed, and = that > >>>>>>> it's actually asking for a timer in the past. The Xen timer driv= er in > >>>>>>> Linux specifically asks Xen for times set in the past to return a= n > >>>>>>> error. > >>>>>>> Xen is returning an error because the time is in the past, Linux = thinks > >>>>>>> it's getting an error because the time is too close in the future= and > >>>>>>> tries asking a little further away. > >>>>>>> > >>>>>>> Unfortunately I think this is something which needs to be fixed o= n the > >>>>>>> Linux side; I don't really see how we can work around it in Xen. > >>>>>> I don't think fixing it only on the Linux side is a great idea, no= t > >>>>>> least > >>>>>> as it makes any current Linux image not live migrateable reliably. > >>>>>> That's > >>>>>> pretty horrible. > >>>>> Ultimately though a guest bug is a guest bug, we don't really want = to be > >>>>> filling the hypervisor with lots of quirky exceptions to interfaces= in > >>>>> order to work around them, otherwise where does it end? > >>>>> > >>>>> A kernel side fix can be pushed to the distros fairly aggressively = (it's > >>>>> mostly just a case of getting an upstream stable backport then fili= ng > >>>>> bugs with the main ones, we've done it before) and for users upgrad= ing > >>>>> the kernel via the distros is really not so hard and mostly reuses = the > >>>>> process they must have in place for guest kernel security updates a= nd > >>>>> other important kernel bugs anyway. > >>>> > >>>> In any case, it seems I was wrong -- Linux does "look at its watch" > >>>> every time it asks. > >>>> > >>>> The generic timer interface is "set me a timer N nanoseconds in the > >>>> future"; the Xen timer implementation executes > >>>> pvclock_clocksource_read() and adds the delta. So it may well actua= lly > >>>> be a bug in Xen. > >>>> > >>>> Stand by for further investigation... > >> > >> I've been investigating further during the weekend, and although I'm n= ot > >> familiar with the timer code in Xen, I think the problem comes from th= e > >> fact that in __update_vcpu_system_time when Xen detects that the guest > >> is using a vtsc it adds offsets to the time passed to the guest, while > >> in VCPUOP_set_singleshot_timer Xen compares the time passed from the > >> guest using NOW(), which is just the Xen uptime, without taking into > >> account any offsets. > >> > >> This only happens after migration because Xen automatically switches t= o > >> vtsc when it detects that the guest has been migrated. I'm currently > >> setting up a Linux PVHVM on shared storage to perform some testing, bu= t > >> one possible solution might be to add tsc_mode=3D"native_paravirt" to = the > >> PVHVM config file, and another one would be fixing > >> VCPUOP_set_singleshot_timer to take into account the vtsc offsets and > >> correctly translate the time passed from the guest. > >=20 > > Good analisys! > > I think that the right solution would be to fix > > VCPUOP_set_singleshot_timer. >=20 > As a band aid I can confirm that adding tsc_mode=3D"native_paravirt" seem= s > to be working fine (with the tests I've done so far), but it requires > the admin to know whether a certain HVM will be using the PV timer or > not, which I guess it's not possible in every case. It needs to work out of the box > Xen could also force the TSC mode to native_paravirt when it detects > that a HVM guest is using the PV timer, but I don't think that's the > right approach. Is this something we aim to fix before the 4.3 release? I think it should be fixed and probably backported anywhere we claim XENFEAT_hvm_safe_pvclock --1342847746-761403387-1370255447=:4589 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --1342847746-761403387-1370255447=:4589--