kernel/time/tick-sched.c
Source file repositories/reference/linux-study-clean/kernel/time/tick-sched.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/time/tick-sched.c- Extension
.c- Size
- 41847 bytes
- Lines
- 1592
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/compiler.hlinux/cpu.hlinux/err.hlinux/hrtimer.hlinux/interrupt.hlinux/kernel_stat.hlinux/percpu.hlinux/nmi.hlinux/profile.hlinux/sched/signal.hlinux/sched/clock.hlinux/sched/stat.hlinux/sched/nohz.hlinux/sched/loadavg.hlinux/module.hlinux/irq_work.hlinux/posix-timers.hlinux/context_tracking.hlinux/mm.hasm/irq_regs.htick-internal.htrace/events/timer.h
Detected Declarations
function tick_do_update_jiffies64function tick_init_jiffy_updatefunction tick_sched_flag_testfunction tick_sched_flag_setfunction tick_sched_flag_clearfunction tick_limited_update_jiffies64function tick_sched_do_timerfunction longfunction tick_sched_handlefunction tick_nohz_handlerfunction check_tick_dependencyfunction can_stop_full_tickfunction nohz_full_kick_funcfunction tick_nohz_full_kickfunction tick_nohz_full_kick_cpufunction tick_nohz_kick_taskfunction tick_nohz_full_kick_allfunction tick_nohz_dep_set_allfunction tick_nohz_dep_setfunction tick_nohz_dep_clearfunction tick_nohz_dep_set_cpufunction tick_nohz_dep_clear_cpufunction tick_nohz_dep_set_taskfunction tick_nohz_dep_clear_taskfunction tick_nohz_dep_set_signalfunction tick_nohz_dep_clear_signalfunction __tick_nohz_task_switchfunction tick_nohz_full_setupfunction tick_nohz_cpu_hotpluggablefunction tick_nohz_cpu_downfunction tick_nohz_initfunction setup_tick_nohzfunction tick_nohz_is_activefunction tick_nohz_tick_stoppedfunction tick_nohz_tick_stopped_cpufunction tick_nohz_update_jiffiesfunction tick_forward_nowfunction tick_nohz_restartfunction local_timer_softirq_pendingfunction get_jiffies_updatefunction tick_nohz_next_eventfunction irq_work_needs_cpufunction tick_nohz_stop_tickfunction tick_nohz_stop_tickfunction tick_nohz_retain_tickfunction tick_nohz_full_stop_tickfunction tick_nohz_restart_sched_tickfunction __tick_nohz_full_update_tick
Annotated Snippet
if (++ts->stalled_jiffies >= MAX_STALLED_JIFFIES) {
if (tick_limited_update_jiffies64(ts, now)) {
ts->stalled_jiffies = 0;
ts->last_tick_jiffies = READ_ONCE(jiffies);
}
}
}
if (tick_sched_flag_test(ts, TS_FLAG_INIDLE))
ts->got_idle_tick = 1;
}
static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
{
/*
* When we are idle and the tick is stopped, we have to touch
* the watchdog as we might not schedule for a really long
* time. This happens on completely idle SMP systems while
* waiting on the login prompt. We also increment the "start of
* idle" jiffy stamp so the idle accounting adjustment we do
* when we go busy again does not account too many ticks.
*/
if (IS_ENABLED(CONFIG_NO_HZ_COMMON) &&
tick_sched_flag_test(ts, TS_FLAG_STOPPED)) {
touch_softlockup_watchdog_sched();
/*
* In case the current tick fired too early past its expected
* expiration, make sure we don't bypass the next clock reprogramming
* to the same deadline.
*/
ts->next_tick = 0;
}
update_process_times(user_mode(regs));
profile_tick(CPU_PROFILING);
}
/*
* We rearm the timer until we get disabled by the idle code.
* Called with interrupts disabled.
*/
static enum hrtimer_restart tick_nohz_handler(struct hrtimer *timer)
{
struct tick_sched *ts = container_of(timer, struct tick_sched, sched_timer);
struct pt_regs *regs = get_irq_regs();
ktime_t now = ktime_get();
tick_sched_do_timer(ts, now);
/*
* Do not call when we are not in IRQ context and have
* no valid 'regs' pointer
*/
if (regs)
tick_sched_handle(ts, regs);
else
ts->next_tick = 0;
/*
* In dynticks mode, tick reprogram is deferred:
* - to the idle task if in dynticks-idle
* - to IRQ exit if in full-dynticks.
*/
if (unlikely(tick_sched_flag_test(ts, TS_FLAG_STOPPED)))
return HRTIMER_NORESTART;
hrtimer_forward(timer, now, TICK_NSEC);
return HRTIMER_RESTART;
}
#ifdef CONFIG_NO_HZ_FULL
cpumask_var_t tick_nohz_full_mask;
EXPORT_SYMBOL_GPL(tick_nohz_full_mask);
bool tick_nohz_full_running;
EXPORT_SYMBOL_GPL(tick_nohz_full_running);
static atomic_t tick_dep_mask;
static bool check_tick_dependency(atomic_t *dep)
{
int val = atomic_read(dep);
if (likely(!tracepoint_enabled(tick_stop)))
return !!val;
if (val & TICK_DEP_MASK_POSIX_TIMER) {
trace_tick_stop(0, TICK_DEP_MASK_POSIX_TIMER);
return true;
}
Annotation
- Immediate include surface: `linux/compiler.h`, `linux/cpu.h`, `linux/err.h`, `linux/hrtimer.h`, `linux/interrupt.h`, `linux/kernel_stat.h`, `linux/percpu.h`, `linux/nmi.h`.
- Detected declarations: `function tick_do_update_jiffies64`, `function tick_init_jiffy_update`, `function tick_sched_flag_test`, `function tick_sched_flag_set`, `function tick_sched_flag_clear`, `function tick_limited_update_jiffies64`, `function tick_sched_do_timer`, `function long`, `function tick_sched_handle`, `function tick_nohz_handler`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.