Skip to content

Commit b19f4db

Browse files
KAGA-KOKObwhacks
authored andcommitted
time: Move common updates to a function
This is a backport of cc06268 [John Stultz: While not a bugfix itself, it allows following fixes to backport in a more straightforward manner.] CC: Thomas Gleixner <tglx@linutronix.de> CC: Eric Dumazet <eric.dumazet@gmail.com> CC: Richard Cochran <richardcochran@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Prarit Bhargava <prarit@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Linux Kernel <linux-kernel@vger.kernel.org> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
1 parent 09e66e8 commit b19f4db

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

‎kernel/time/timekeeping.c‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,19 @@ static struct timespec total_sleep_time;
166166
*/
167167
static struct timespec raw_time;
168168

169+
/* must hold write on xtime_lock */
170+
static void timekeeping_update(bool clearntp)
171+
{
172+
if (clearntp) {
173+
timekeeper.ntp_error = 0;
174+
ntp_clear();
175+
}
176+
update_vsyscall(&xtime, &wall_to_monotonic,
177+
timekeeper.clock, timekeeper.mult);
178+
}
179+
180+
181+
169182
/* flag for if timekeeping is suspended */
170183
int __read_mostly timekeeping_suspended;
171184

@@ -366,11 +379,7 @@ int do_settimeofday(const struct timespec *tv)
366379

367380
xtime = *tv;
368381

369-
timekeeper.ntp_error = 0;
370-
ntp_clear();
371-
372-
update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
373-
timekeeper.mult);
382+
timekeeping_update(true);
374383

375384
write_sequnlock_irqrestore(&xtime_lock, flags);
376385

@@ -403,11 +412,7 @@ int timekeeping_inject_offset(struct timespec *ts)
403412
xtime = timespec_add(xtime, *ts);
404413
wall_to_monotonic = timespec_sub(wall_to_monotonic, *ts);
405414

406-
timekeeper.ntp_error = 0;
407-
ntp_clear();
408-
409-
update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
410-
timekeeper.mult);
415+
timekeeping_update(true);
411416

412417
write_sequnlock_irqrestore(&xtime_lock, flags);
413418

@@ -636,10 +641,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta)
636641

637642
__timekeeping_inject_sleeptime(delta);
638643

639-
timekeeper.ntp_error = 0;
640-
ntp_clear();
641-
update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
642-
timekeeper.mult);
644+
timekeeping_update(true);
643645

644646
write_sequnlock_irqrestore(&xtime_lock, flags);
645647

@@ -1052,9 +1054,7 @@ static void update_wall_time(void)
10521054
wall_to_monotonic.tv_sec -= leap;
10531055
}
10541056

1055-
/* check to see if there is a new clocksource to use */
1056-
update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
1057-
timekeeper.mult);
1057+
timekeeping_update(false);
10581058
}
10591059

10601060
/**

0 commit comments

Comments
 (0)