All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix clock_gettime to increment monotonically on PV-domain/x86
@ 2007-06-15  9:47 Atsushi SAKAI
  2007-06-15 10:19 ` [PATCH] Fix clock_gettime to increment monotonically onPV-domain/x86 Jan Beulich
  0 siblings, 1 reply; 15+ messages in thread
From: Atsushi SAKAI @ 2007-06-15  9:47 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 282 bytes --]

Hi, Keir

  This patch intends to increment do_gettimeofday monotonically.
This is for PV-domain/x86.

Signed-off-by: Atsushi SAKAI <sakaia@jp.fujitsu.com>

By applying patch, the time rollback for SMP is fixed.
This is important fixes for database software.

Thanks
Atsushi SAKAI


[-- Attachment #2: fix_timerollback_pvx86.patch --]
[-- Type: application/octet-stream, Size: 1320 bytes --]

diff -r 089696e0c603 linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Thu May 17 11:42:46 2007 +0100
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Fri Jun 15 18:10:03 2007 +0900
@@ -113,6 +113,8 @@ static struct timespec shadow_tv;
 static struct timespec shadow_tv;
 static u32 shadow_tv_version;
 
+static struct timeval monotonic_tv;
+
 /* Keep track of last time we did processing/updating of jiffies and xtime. */
 static u64 processed_system_time;   /* System time (ns) at last processing. */
 static DEFINE_PER_CPU(u64, processed_system_time);
@@ -413,15 +415,25 @@ void do_gettimeofday(struct timeval *tv)
 			get_time_values_from_xen(cpu);
 			continue;
 		}
+
+		/* for monotonic counting */
+		while (usec >= USEC_PER_SEC) {
+			usec -= USEC_PER_SEC;
+			sec++;
+		}
+		if ( sec > monotonic_tv.tv_sec || 
+			(monotonic_tv.tv_sec == sec && usec > monotonic_tv.tv_usec))
+		{
+			monotonic_tv.tv_sec = sec;
+			monotonic_tv.tv_usec = usec;
+		} else {
+			sec = monotonic_tv.tv_sec;
+			usec = monotonic_tv.tv_usec;
+		}
 	} while (read_seqretry(&xtime_lock, seq) ||
 		 (local_time_version != shadow->version));
 
 	put_cpu();
-
-	while (usec >= USEC_PER_SEC) {
-		usec -= USEC_PER_SEC;
-		sec++;
-	}
 
 	tv->tv_sec = sec;
 	tv->tv_usec = usec;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2007-06-19  9:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-15  9:47 [PATCH] Fix clock_gettime to increment monotonically on PV-domain/x86 Atsushi SAKAI
2007-06-15 10:19 ` [PATCH] Fix clock_gettime to increment monotonically onPV-domain/x86 Jan Beulich
2007-06-15 10:26   ` Keir Fraser
2007-06-15 11:12     ` Jan Beulich
2007-06-15 11:19       ` Keir Fraser
2007-06-15 12:47       ` John Levon
2007-06-15 12:59         ` Keir Fraser
2007-06-15 13:08           ` John Levon
2007-06-15 13:21             ` Keir Fraser
2007-06-15 14:00               ` John Levon
2007-06-15 14:18                 ` Keir Fraser
2007-06-15 14:32                   ` John Levon
2007-06-15 13:58             ` [PATCH] Fix clock_gettime to increment monotonicallyonPV-domain/x86 Atsushi SAKAI
2007-06-15 11:44     ` [PATCH] Fix clock_gettime to incrementmonotonically onPV-domain/x86 Atsushi SAKAI
2007-06-19  9:21       ` [PATCH] Fix clock_gettime to incrementmonotonicallyonPV-domain/x86 Atsushi SAKAI

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.