Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

timekeeping: Rework timekeeping_resume() to use shadow_timekeeper

Updates of the timekeeper can be done by operating on the shadow timekeeper
and afterwards copying the result into the real timekeeper. This has the
advantage, that the sequence count write protected region is kept as small
as possible.

While the sequence count held time is not relevant for the resume path as
there is no concurrency, there is no reason to have this function
different than all the other update sites.

Convert timekeeping_inject_offset() to use this scheme and cleanup the
variable declaration while at it.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <jstultz@google.com>
Link: https://lore.kernel.org/all/20241009-devel-anna-maria-b4-timers-ptp-timekeeping-v2-21-554456a44a15@linutronix.de

authored by

Anna-Maria Behnsen and committed by
Thomas Gleixner
b2350d95 2b473e65

+10 -12
+10 -12
kernel/time/timekeeping.c
··· 1943 1943 */ 1944 1944 void timekeeping_resume(void) 1945 1945 { 1946 - struct timekeeper *tk = &tk_core.timekeeper; 1947 - struct clocksource *clock = tk->tkr_mono.clock; 1948 - unsigned long flags; 1946 + struct timekeeper *tks = &tk_core.shadow_timekeeper; 1947 + struct clocksource *clock = tks->tkr_mono.clock; 1949 1948 struct timespec64 ts_new, ts_delta; 1950 - u64 cycle_now, nsec; 1951 1949 bool inject_sleeptime = false; 1950 + u64 cycle_now, nsec; 1951 + unsigned long flags; 1952 1952 1953 1953 read_persistent_clock64(&ts_new); 1954 1954 ··· 1956 1956 clocksource_resume(); 1957 1957 1958 1958 raw_spin_lock_irqsave(&tk_core.lock, flags); 1959 - write_seqcount_begin(&tk_core.seq); 1960 1959 1961 1960 /* 1962 1961 * After system resumes, we need to calculate the suspended time and ··· 1969 1970 * The less preferred source will only be tried if there is no better 1970 1971 * usable source. The rtc part is handled separately in rtc core code. 1971 1972 */ 1972 - cycle_now = tk_clock_read(&tk->tkr_mono); 1973 + cycle_now = tk_clock_read(&tks->tkr_mono); 1973 1974 nsec = clocksource_stop_suspend_timing(clock, cycle_now); 1974 1975 if (nsec > 0) { 1975 1976 ts_delta = ns_to_timespec64(nsec); ··· 1981 1982 1982 1983 if (inject_sleeptime) { 1983 1984 suspend_timing_needed = false; 1984 - __timekeeping_inject_sleeptime(tk, &ts_delta); 1985 + __timekeeping_inject_sleeptime(tks, &ts_delta); 1985 1986 } 1986 1987 1987 1988 /* Re-base the last cycle value */ 1988 - tk->tkr_mono.cycle_last = cycle_now; 1989 - tk->tkr_raw.cycle_last = cycle_now; 1989 + tks->tkr_mono.cycle_last = cycle_now; 1990 + tks->tkr_raw.cycle_last = cycle_now; 1990 1991 1991 - tk->ntp_error = 0; 1992 + tks->ntp_error = 0; 1992 1993 timekeeping_suspended = 0; 1993 - timekeeping_update(&tk_core, tk, TK_MIRROR | TK_CLOCK_WAS_SET); 1994 - write_seqcount_end(&tk_core.seq); 1994 + timekeeping_update_from_shadow(&tk_core, TK_CLOCK_WAS_SET); 1995 1995 raw_spin_unlock_irqrestore(&tk_core.lock, flags); 1996 1996 1997 1997 touch_softlockup_watchdog();