Skip to content

Commit 14a3b6a

Browse files
KAGA-KOKOjohnstultz-work
authored andcommitted
timekeeping: Store cycle_last value in timekeeper struct as well
For implementing a shadow timekeeper and a split calculation/update region we need to store the cycle_last value in the timekeeper and update the value in the clocksource struct only in the update region. Add the extra storage to the timekeeper. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
1 parent a076b21 commit 14a3b6a

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎include/linux/timekeeper_internal.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct timekeeper {
2020
u32 shift;
2121
/* Number of clock cycles in one NTP interval. */
2222
cycle_t cycle_interval;
23+
/* Last cycle value (also stored in clock->cycle_last) */
24+
cycle_t cycle_last;
2325
/* Number of clock shifted nano seconds in one NTP interval. */
2426
u64 xtime_interval;
2527
/* shifted nano seconds left over when rounding cycle_interval */

‎kernel/time/timekeeping.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void tk_setup_internals(struct timekeeper *tk, struct clocksource *clock)
101101

102102
old_clock = tk->clock;
103103
tk->clock = clock;
104-
clock->cycle_last = clock->read(clock);
104+
tk->cycle_last = clock->cycle_last = clock->read(clock);
105105

106106
/* Do the ns -> cycle conversion first, using original mult */
107107
tmp = NTP_INTERVAL_LENGTH;
@@ -266,7 +266,7 @@ static void timekeeping_forward_now(struct timekeeper *tk)
266266
clock = tk->clock;
267267
cycle_now = clock->read(clock);
268268
cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
269-
clock->cycle_last = cycle_now;
269+
tk->cycle_last = clock->cycle_last = cycle_now;
270270

271271
tk->xtime_nsec += cycle_delta * tk->mult;
272272

0 commit comments

Comments
 (0)