Message ID | 20241009-devel-anna-maria-b4-timers-ptp-timekeeping-v2-7-554456a44a15@linutronix.de (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | timekeeping: Rework to prepare support of indenpendent PTP clocks | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On Wed, Oct 9, 2024 at 1:29 AM Anna-Maria Behnsen <anna-maria@linutronix.de> wrote: > > From: Thomas Gleixner <tglx@linutronix.de> > > From: Thomas Gleixner <tglx@linutronix.de> > > tk_core requires shadow_timekeeper to allow timekeeping_advance() updating > without holding the timekeeper sequence count write locked. This allows the > readers to make progress up to the actual update where the shadow > timekeeper is copied over to the real timekeeper. > > As long as there is only a single timekeeper, having them separate is > fine. But when the timekeeper infrastructure will be reused for per ptp > clock timekeepers, shadow_timekeeper needs to be part of tk_core. > > No functional change. > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de> Acked-by: John Stultz <jstultz@google.com>
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index e747e46a1a2d..267b28cf2ab0 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -50,11 +50,11 @@ DEFINE_RAW_SPINLOCK(timekeeper_lock); static struct { seqcount_raw_spinlock_t seq; struct timekeeper timekeeper; + struct timekeeper shadow_timekeeper; } tk_core ____cacheline_aligned = { .seq = SEQCNT_RAW_SPINLOCK_ZERO(tk_core.seq, &timekeeper_lock), }; -static struct timekeeper shadow_timekeeper; /* flag for if timekeeping is suspended */ int __read_mostly timekeeping_suspended; @@ -776,8 +776,7 @@ static void timekeeping_update(struct timekeeper *tk, unsigned int action) * timekeeper structure on the next update with stale data */ if (action & TK_MIRROR) - memcpy(&shadow_timekeeper, &tk_core.timekeeper, - sizeof(tk_core.timekeeper)); + memcpy(&tk_core.shadow_timekeeper, &tk_core.timekeeper, sizeof(tk_core.timekeeper)); } /** @@ -2274,8 +2273,8 @@ static u64 logarithmic_accumulation(struct timekeeper *tk, u64 offset, */ static bool timekeeping_advance(enum timekeeping_adv_mode mode) { + struct timekeeper *tk = &tk_core.shadow_timekeeper; struct timekeeper *real_tk = &tk_core.timekeeper; - struct timekeeper *tk = &shadow_timekeeper; unsigned int clock_set = 0; int shift = 0, maxshift; u64 offset;