timekeeping: Introduce timekeeping_leap_insert
authorJohn Stultz <johnstul@us.ibm.com>
Fri, 14 Aug 2009 13:47:18 +0000 (15:47 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Sat, 15 Aug 2009 08:55:45 +0000 (10:55 +0200)
Move the adjustment of xtime, wall_to_monotonic and the update of the
vsyscall variables to the timekeeping code.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
LKML-Reference: <20090814134807.609730216@de.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/linux/time.h
kernel/time/ntp.c
kernel/time/timekeeping.c

index ea16c1a01d5188b3d9d39181d993d0c92508923b..e7c84455888401e10062eb4fc4535e7478d7e83a 100644 (file)
@@ -147,6 +147,7 @@ extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
 extern int timekeeping_valid_for_hres(void);
 extern void update_wall_time(void);
 extern void update_xtime_cache(u64 nsec);
+extern void timekeeping_leap_insert(int leapsecond);
 
 struct tms;
 extern void do_sys_times(struct tms *);
index 7fc64375ff43350ce59cb3a1d0db220c57d79a46..4800f933910ea4ed8f0f2d8ad4d2f660eb4a3467 100644 (file)
@@ -194,8 +194,7 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
        case TIME_OK:
                break;
        case TIME_INS:
-               xtime.tv_sec--;
-               wall_to_monotonic.tv_sec++;
+               timekeeping_leap_insert(-1);
                time_state = TIME_OOP;
                printk(KERN_NOTICE
                        "Clock: inserting leap second 23:59:60 UTC\n");
@@ -203,9 +202,8 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
                res = HRTIMER_RESTART;
                break;
        case TIME_DEL:
-               xtime.tv_sec++;
+               timekeeping_leap_insert(1);
                time_tai--;
-               wall_to_monotonic.tv_sec--;
                time_state = TIME_WAIT;
                printk(KERN_NOTICE
                        "Clock: deleting leap second 23:59:59 UTC\n");
@@ -219,7 +217,6 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
                        time_state = TIME_OK;
                break;
        }
-       update_vsyscall(&xtime, clock);
 
        write_sequnlock(&xtime_lock);
 
index 02c0b2c9c6748eff373c164f93e82a6c9a6bfe49..b8b70fb545fcbe46f6e15cf18abfdbc690d64185 100644 (file)
@@ -58,6 +58,13 @@ void update_xtime_cache(u64 nsec)
 
 struct clocksource *clock;
 
+/* must hold xtime_lock */
+void timekeeping_leap_insert(int leapsecond)
+{
+       xtime.tv_sec += leapsecond;
+       wall_to_monotonic.tv_sec -= leapsecond;
+       update_vsyscall(&xtime, clock);
+}
 
 #ifdef CONFIG_GENERIC_TIME
 /**