Skip to content

Commit 6168024

Browse files
committed
timekeeping: Add clock_valid flag to timekeeper
In preparation for supporting independent auxiliary timekeepers, add a clock valid field and set it to true for the system timekeeper. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: John Stultz <jstultz@google.com> Link: https://lore.kernel.org/all/20250519083026.287145536@linutronix.de
1 parent 8c782ac commit 6168024

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

include/linux/timekeeper_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct tk_read_base {
7373
* @raw_sec: CLOCK_MONOTONIC_RAW time in seconds
7474
* @clock_was_set_seq: The sequence number of clock was set events
7575
* @cs_was_changed_seq: The sequence number of clocksource change events
76+
* @clock_valid: Indicator for valid clock
7677
* @monotonic_to_boot: CLOCK_MONOTONIC to CLOCK_BOOTTIME offset
7778
* @cycle_interval: Number of clock cycles in one NTP interval
7879
* @xtime_interval: Number of clock shifted nano seconds in one NTP
@@ -149,6 +150,7 @@ struct timekeeper {
149150
/* Cachline 3 and 4 (timekeeping internal variables): */
150151
unsigned int clock_was_set_seq;
151152
u8 cs_was_changed_seq;
153+
u8 clock_valid;
152154

153155
struct timespec64 monotonic_to_boot;
154156

kernel/time/timekeeping.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,11 +1665,12 @@ read_persistent_wall_and_boot_offset(struct timespec64 *wall_time,
16651665
*boot_offset = ns_to_timespec64(local_clock());
16661666
}
16671667

1668-
static __init void tkd_basic_setup(struct tk_data *tkd, enum timekeeper_ids tk_id)
1668+
static __init void tkd_basic_setup(struct tk_data *tkd, enum timekeeper_ids tk_id, bool valid)
16691669
{
16701670
raw_spin_lock_init(&tkd->lock);
16711671
seqcount_raw_spinlock_init(&tkd->seq, &tkd->lock);
16721672
tkd->timekeeper.id = tkd->shadow_timekeeper.id = tk_id;
1673+
tkd->timekeeper.clock_valid = tkd->shadow_timekeeper.clock_valid = valid;
16731674
}
16741675

16751676
/*
@@ -1699,7 +1700,7 @@ void __init timekeeping_init(void)
16991700
struct timekeeper *tks = &tk_core.shadow_timekeeper;
17001701
struct clocksource *clock;
17011702

1702-
tkd_basic_setup(&tk_core, TIMEKEEPER_CORE);
1703+
tkd_basic_setup(&tk_core, TIMEKEEPER_CORE, true);
17031704

17041705
read_persistent_wall_and_boot_offset(&wall_time, &boot_offset);
17051706
if (timespec64_valid_settod(&wall_time) &&

0 commit comments

Comments
 (0)