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.

Dependency Surface

Detected Declarations

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

Implementation Notes