include/linux/timekeeping.h
Source file repositories/reference/linux-study-clean/include/linux/timekeeping.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/timekeeping.h- Extension
.h- Size
- 10122 bytes
- Lines
- 372
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/clocksource_ids.hlinux/ktime.h
Detected Declarations
struct system_time_snapshotstruct system_counterval_tstruct system_device_crosststampenum tk_offsetsfunction ktime_get_realfunction ktime_get_coarse_realfunction ktime_get_boottimefunction ktime_get_coarse_boottimefunction ktime_get_clocktaifunction ktime_get_coarse_clocktaifunction ktime_get_coarsefunction ktime_get_coarse_nsfunction ktime_get_coarse_real_nsfunction ktime_get_coarse_boottime_nsfunction ktime_get_coarse_clocktai_nsfunction ktime_mono_to_realfunction ktime_get_nsfunction ktime_get_real_nsfunction ktime_get_boottime_nsfunction ktime_get_clocktai_nsfunction ktime_get_raw_nsfunction ktime_get_boottime_ts64function ktime_get_coarse_boottime_ts64function ktime_get_boottime_secondsfunction ktime_get_clocktai_ts64function ktime_get_coarse_clocktai_ts64function ktime_get_clocktai_secondsfunction ktime_get_auxfunction ktime_get_aux_ts64
Annotated Snippet
struct system_time_snapshot {
u64 cycles;
u64 hw_cycles;
ktime_t systime;
ktime_t monoraw;
enum clocksource_ids cs_id;
enum clocksource_ids hw_csid;
unsigned int clock_was_set_seq;
u8 cs_was_changed_seq;
u8 valid;
};
/**
* struct system_counterval_t - system counter value with the ID of the
* corresponding clocksource
* @cycles: System counter value
* @cs_id: Clocksource ID corresponding to system counter value. Used by
* timekeeping code to verify comparability of two cycle values.
* The default ID, CSID_GENERIC, does not identify a specific
* clocksource.
* @use_nsecs: @cycles is in nanoseconds.
*/
struct system_counterval_t {
u64 cycles;
enum clocksource_ids cs_id;
bool use_nsecs;
};
/**
* struct system_device_crosststamp - system/device cross-timestamp
* (synchronized capture)
* @clock_id: System time Clock ID to capture
* @device: Device time
* @sys_counter: Clocksource counter value simultaneous with device time
* @sys_systime: System time for @clock_id
* @sys_monoraw: Monotonic raw simultaneous with device time
*/
struct system_device_crosststamp {
clockid_t clock_id;
ktime_t device;
struct system_counterval_t sys_counter;
ktime_t sys_systime;
ktime_t sys_monoraw;
};
extern bool ktime_real_to_base_clock(ktime_t treal,
enum clocksource_ids base_id, u64 *cycles);
extern bool timekeeping_clocksource_has_base(enum clocksource_ids id);
/*
* Get cross timestamp between system clock and device clock
*/
extern int get_device_system_crosststamp(
int (*get_time_fn)(ktime_t *device_time,
struct system_counterval_t *system_counterval,
void *ctx),
void *ctx,
struct system_time_snapshot *history,
struct system_device_crosststamp *xtstamp);
/*
* Simultaneously snapshot a given clock with MONOTONIC_RAW and the underlying
* clocksource counter value.
*/
extern void ktime_get_snapshot_id(clockid_t clock_id, struct system_time_snapshot *systime_snapshot);
/*
* Persistent clock related interfaces
*/
extern int persistent_clock_is_local;
extern void read_persistent_clock64(struct timespec64 *ts);
void read_persistent_wall_and_boot_offset(struct timespec64 *wall_clock,
struct timespec64 *boot_offset);
#ifdef CONFIG_GENERIC_CMOS_UPDATE
extern int update_persistent_clock64(struct timespec64 now);
#endif
#endif
Annotation
- Immediate include surface: `linux/errno.h`, `linux/clocksource_ids.h`, `linux/ktime.h`.
- Detected declarations: `struct system_time_snapshot`, `struct system_counterval_t`, `struct system_device_crosststamp`, `enum tk_offsets`, `function ktime_get_real`, `function ktime_get_coarse_real`, `function ktime_get_boottime`, `function ktime_get_coarse_boottime`, `function ktime_get_clocktai`, `function ktime_get_coarse_clocktai`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.