include/linux/hrtimer.h
Source file repositories/reference/linux-study-clean/include/linux/hrtimer.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/hrtimer.h- Extension
.h- Size
- 11320 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/hrtimer_defs.hlinux/hrtimer_rearm.hlinux/hrtimer_types.hlinux/init.hlinux/list.hlinux/percpu-defs.hlinux/rbtree.hlinux/timer.h
Detected Declarations
struct hrtimer_sleeperstruct clock_event_deviceenum hrtimer_modefunction hrtimer_set_expiresfunction hrtimer_set_expires_rangefunction hrtimer_set_expires_range_nsfunction hrtimer_add_expiresfunction hrtimer_add_expires_nsfunction hrtimer_get_expiresfunction hrtimer_get_softexpiresfunction hrtimer_expires_remainingfunction hrtimer_highres_enabledfunction hrtimer_highres_enabledfunction __hrtimer_expires_remaining_adjustedfunction hrtimer_expires_remaining_adjustedfunction timerfd_clock_was_setfunction hrtimer_cancel_wait_runningfunction hrtimer_dummy_timeoutfunction destroy_hrtimer_on_stackfunction hrtimer_startfunction hrtimer_start_expiresfunction hrtimer_start_expires_userfunction hrtimer_restartfunction hrtimer_get_remainingfunction hrtimer_is_queuedfunction hrtimer_callback_runningfunction timefunction hrtimer_forward_now
Annotated Snippet
struct hrtimer_sleeper {
struct hrtimer timer;
struct task_struct *task;
};
static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
{
timer->node.expires = time;
timer->_softexpires = time;
}
static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta)
{
timer->_softexpires = time;
timer->node.expires = ktime_add_safe(time, delta);
}
static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, u64 delta)
{
timer->_softexpires = time;
timer->node.expires = ktime_add_safe(time, ns_to_ktime(delta));
}
static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time)
{
timer->node.expires = ktime_add_safe(timer->node.expires, time);
timer->_softexpires = ktime_add_safe(timer->_softexpires, time);
}
static inline void hrtimer_add_expires_ns(struct hrtimer *timer, u64 ns)
{
timer->node.expires = ktime_add_ns(timer->node.expires, ns);
timer->_softexpires = ktime_add_ns(timer->_softexpires, ns);
}
static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
{
return timer->node.expires;
}
static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer)
{
return timer->_softexpires;
}
ktime_t hrtimer_cb_get_time(const struct hrtimer *timer);
static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
{
return ktime_sub(timer->node.expires, hrtimer_cb_get_time(timer));
}
#ifdef CONFIG_HIGH_RES_TIMERS
extern unsigned int hrtimer_resolution;
struct clock_event_device;
extern void hrtimer_interrupt(struct clock_event_device *dev);
extern struct static_key_false hrtimer_highres_enabled_key;
static inline bool hrtimer_highres_enabled(void)
{
return static_branch_likely(&hrtimer_highres_enabled_key);
}
#else /* CONFIG_HIGH_RES_TIMERS */
#define hrtimer_resolution (unsigned int)LOW_RES_NSEC
static inline bool hrtimer_highres_enabled(void) { return false; }
#endif /* !CONFIG_HIGH_RES_TIMERS */
static inline ktime_t
__hrtimer_expires_remaining_adjusted(const struct hrtimer *timer, ktime_t now)
{
ktime_t rem = ktime_sub(timer->node.expires, now);
/*
* Adjust relative timers for the extra we added in
* hrtimer_start_range_ns() to prevent short timeouts.
*/
if (IS_ENABLED(CONFIG_TIME_LOW_RES) && timer->is_rel)
rem -= hrtimer_resolution;
return rem;
}
static inline ktime_t
hrtimer_expires_remaining_adjusted(const struct hrtimer *timer)
{
return __hrtimer_expires_remaining_adjusted(timer, hrtimer_cb_get_time(timer));
}
Annotation
- Immediate include surface: `linux/hrtimer_defs.h`, `linux/hrtimer_rearm.h`, `linux/hrtimer_types.h`, `linux/init.h`, `linux/list.h`, `linux/percpu-defs.h`, `linux/rbtree.h`, `linux/timer.h`.
- Detected declarations: `struct hrtimer_sleeper`, `struct clock_event_device`, `enum hrtimer_mode`, `function hrtimer_set_expires`, `function hrtimer_set_expires_range`, `function hrtimer_set_expires_range_ns`, `function hrtimer_add_expires`, `function hrtimer_add_expires_ns`, `function hrtimer_get_expires`, `function hrtimer_get_softexpires`.
- 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.