]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sched_clock: prevent scd->clock from moving backwards, take #2
authorThomas Gleixner <tglx@linutronix.de>
Mon, 22 Dec 2008 22:05:28 +0000 (23:05 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 18 Jan 2009 18:35:28 +0000 (10:35 -0800)
commit 1c5745aa380efb6417b5681104b007c8612fb496 upstream.

Redo:

  5b7dba4: sched_clock: prevent scd->clock from moving backwards

which had to be reverted due to s2ram hangs:

  ca7e716: Revert "sched_clock: prevent scd->clock from moving backwards"

... this time with resume restoring GTOD later in the sequence
taken into account as well.

The "timekeeping_suspended" flag is not very nice but we cannot call into
GTOD before it has been properly resumed and the scheduler will run very
early in the resume sequence.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
include/linux/time.h
kernel/sched_clock.c
kernel/time/timekeeping.c

index e15206a7e82ec9278b25fc062585302f9ed71687..0095ad11d7e2077d5d41de3b2346bf343093cf6f 100644 (file)
@@ -99,6 +99,7 @@ extern unsigned long read_persistent_clock(void);
 extern int update_persistent_clock(struct timespec now);
 extern int no_sync_cmos_clock __read_mostly;
 void timekeeping_init(void);
+extern int timekeeping_suspended;
 
 unsigned long get_seconds(void);
 struct timespec current_kernel_time(void);
index e8ab096ddfe399dc3007e32b169b46d02ed9cb48..a0b0852414cc599169efd81c5789f03ee50dad8b 100644 (file)
@@ -124,7 +124,7 @@ static u64 __update_sched_clock(struct sched_clock_data *scd, u64 now)
 
        clock = scd->tick_gtod + delta;
        min_clock = wrap_max(scd->tick_gtod, scd->clock);
-       max_clock = scd->tick_gtod + TICK_NSEC;
+       max_clock = wrap_max(scd->clock, scd->tick_gtod + TICK_NSEC);
 
        clock = wrap_max(clock, min_clock);
        clock = wrap_min(clock, max_clock);
@@ -227,6 +227,9 @@ EXPORT_SYMBOL_GPL(sched_clock_idle_sleep_event);
  */
 void sched_clock_idle_wakeup_event(u64 delta_ns)
 {
+       if (timekeeping_suspended)
+               return;
+
        sched_clock_tick();
        touch_softlockup_watchdog();
 }
index e91c29f961c900d7739c0dc2f27b81c480cdb55c..4220a2e1faab0144bff2b3d6fd515551ca92451a 100644 (file)
@@ -46,6 +46,9 @@ struct timespec xtime __attribute__ ((aligned (16)));
 struct timespec wall_to_monotonic __attribute__ ((aligned (16)));
 static unsigned long total_sleep_time;         /* seconds */
 
+/* flag for if timekeeping is suspended */
+int __read_mostly timekeeping_suspended;
+
 static struct timespec xtime_cache __attribute__ ((aligned (16)));
 void update_xtime_cache(u64 nsec)
 {
@@ -92,6 +95,8 @@ void getnstimeofday(struct timespec *ts)
        unsigned long seq;
        s64 nsecs;
 
+       WARN_ON(timekeeping_suspended);
+
        do {
                seq = read_seqbegin(&xtime_lock);
 
@@ -261,8 +266,6 @@ void __init timekeeping_init(void)
        write_sequnlock_irqrestore(&xtime_lock, flags);
 }
 
-/* flag for if timekeeping is suspended */
-static int timekeeping_suspended;
 /* time in seconds when suspend began */
 static unsigned long timekeeping_suspend_time;
 /* xtime offset when we went into suspend */