This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


[Xen-devel] [PATCH] [Bugfix][pv-ops] Guest get stucked after migration

To: xen-devel@xxxxxxxxxxxxxxxxxxx, Jeremy Fitzhardinge <Jeremy.Fitzhardinge@xxxxxxxxxx>, Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Subject: [Xen-devel] [PATCH] [Bugfix][pv-ops] Guest get stucked after migration
From: Frank Pan <frankpzh@xxxxxxxxx>
Date: Tue, 22 Mar 2011 02:26:19 +0800
Delivery-date: Mon, 21 Mar 2011 11:33:27 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=NzSgD1sMxMNprZlNKAvSx50VzljOF9rO23bSlYxNtWE=; b=BCMGwQGAc9IYM+xqyigQHMmQn5/5bzexC6qUw1TJYmLg86I5vfqxbNZ3VwhIPHNo3w objA/OBg3h07s7IlnzZ0skGY9LB+t1+V1K2fHTzgj4+ISMvalXyERjiED5ikc537lJkz hlCMpVleoeADvWgrDBOKj25snShnj9UyP48I4=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=xs7nyBvD7dmCtDhirABAySlGw/FVfdHUYUyXbAFIZ3adEBRKmRb9Ik8e+O4YoeduQX yXSlSRs2we2jadb4iVZZuZVEipifw6NrV9NXRuVda6y9L/FDcTcwkmu8zwI7inh6gKwB 8v4GNPgDVLPEdrgpjVygbx58P1+zE6qge6niQ=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
In recent pv-ops kernel, pvclock is not guaranteed as monotone.
After a migration, pvclock can produce smaller cycle count.

[The test is performed on next-2.6.32 tree]
The issue occured when uptime(sender) > uptime(target), and with
CONFIG_GENERIC_TIME. The guest get stucked after the migration,
doing a huge loop inside update_wall_time, until the overflow of
64-bit unsigned offset.

The following patch fixed this issue by introducing a global sign.
Xen pvclock will update the cycle_last with the newest cycle count
on the first read after migration.

Signed-off-by: Frank Pan <frankpzh@xxxxxxxxx>
 linux-2.6-xen/arch/x86/xen/time.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/linux-2.6-xen/arch/x86/xen/time.c
index ab35140..ac6fe2a 100644
--- a/linux-2.6-xen/arch/x86/xen/time.c
+++ b/linux-2.6-xen/arch/x86/xen/time.c
@@ -41,6 +41,9 @@ static DEFINE_PER_CPU(struct vcpu_runstate_info,
 static DEFINE_PER_CPU(u64, residual_stolen);
 static DEFINE_PER_CPU(u64, residual_blocked);

+/* xen_clocksource_get_cycles should update cycle_last after resume */
+static int just_resume = 0;
 /* return an consistent snapshot of 64-bit time/counter value */
 static u64 get64(const u64 *p)
@@ -177,7 +180,13 @@ cycle_t xen_clocksource_read(void)

 static cycle_t xen_clocksource_get_cycles(struct clocksource *cs)
-       return xen_clocksource_read();
+       cycle_t c = xen_clocksource_read();
+       if (unlikely(just_resume)) {
+               cs->cycle_last = c++;
+               just_resume = 0;
+       }
+       return c;

 static void xen_read_wallclock(struct timespec *ts)
@@ -441,6 +450,7 @@ void xen_timer_resume(void)
        int cpu;

+       just_resume = 1;

        if (xen_clockevent != &xen_vcpuop_clockevent)

潘震皓, Frank Pan

Computer Science and Technology
Tsinghua University

Attachment: 0001-Bugfix-pv-ops-Guest-get-stucked-after-migration.patch
Description: Text Data

Xen-devel mailing list