WARNING - OLD ARCHIVES

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/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [linux-2.6.18-xen] x86 time: Ensure gettimeofday() is mo

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] x86 time: Ensure gettimeofday() is monotonically increasing.
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 19 Jun 2007 14:42:59 -0700
Delivery-date: Tue, 19 Jun 2007 14:41:22 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1182263776 -3600
# Node ID 87bb8705768a66ceabb15a419c5f86580bffb6bf
# Parent  a413dd61e7e5e1bba11bab447184cf5e6b43513a
x86 time: Ensure gettimeofday() is monotonically increasing.
Signed-off-by: Atsushi SAKAI <sakaia@xxxxxxxxxxxxxx>
---
 arch/i386/kernel/time-xen.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+)

diff -r a413dd61e7e5 -r 87bb8705768a arch/i386/kernel/time-xen.c
--- a/arch/i386/kernel/time-xen.c       Fri Jun 15 13:33:47 2007 -0600
+++ b/arch/i386/kernel/time-xen.c       Tue Jun 19 15:36:16 2007 +0100
@@ -113,6 +113,9 @@ static struct timespec shadow_tv;
 static struct timespec shadow_tv;
 static u32 shadow_tv_version;
 
+static struct timeval monotonic_tv;
+static spinlock_t monotonic_lock = SPIN_LOCK_UNLOCKED;
+
 /* 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);
@@ -363,6 +366,7 @@ void do_gettimeofday(struct timeval *tv)
        unsigned long seq;
        unsigned long usec, sec;
        unsigned long max_ntp_tick;
+       unsigned long flags;
        s64 nsec;
        unsigned int cpu;
        struct shadow_time_info *shadow;
@@ -423,6 +427,18 @@ void do_gettimeofday(struct timeval *tv)
                sec++;
        }
 
+       spin_lock_irqsave(&monotonic_lock, flags);
+       if ((sec > monotonic_tv.tv_sec) ||
+           ((sec == monotonic_tv.tv_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;
+       }
+       spin_unlock_irqrestore(&monotonic_lock, flags);
+
        tv->tv_sec = sec;
        tv->tv_usec = usec;
 }
@@ -471,6 +487,12 @@ int do_settimeofday(struct timespec *tv)
                __normalize_time(&sec, &nsec);
                __update_wallclock(sec, nsec);
        }
+
+       /* Reset monotonic gettimeofday() timeval. */
+       spin_lock(&monotonic_lock);
+       monotonic_tv.tv_sec = 0;
+       monotonic_tv.tv_usec = 0;
+       spin_unlock(&monotonic_lock);
 
        write_sequnlock_irq(&xtime_lock);
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] x86 time: Ensure gettimeofday() is monotonically increasing., Xen patchbot-linux-2.6.18-xen <=