mod_timer(9)
π mod_timer(9) π
Hey bestie! Welcome to the Kernel API Manual, section 9 β this is literally the mod_timer(9) page and it's iconic. Iykyk. β¨
β¨ NAME β¨
mod_timer β Modify a timer's timeout π
So like, if you've got a timer and you need to change when it goes off, this is your girl. Periodt.
πΈ SYNOPSIS πΈ
int mod_timer (struct timer_list *timer , unsigned long expires );
π¦ ARGUMENTS π¦
timerβ the timer you're modifying. It's giving main character energy, fr fr. πexpiresβ the new absolute timeout in jiffies. Not relative, bestie β absolute. No cap. β°
π DESCRIPTION π
Okay so literally, calling mod_timer(timer, expires) is equivalent to this whole vibe:
timer_delete(timer); timer->expires = expires; add_timer(timer);
But mod_timer ate and left no crumbs because it's more efficient than writing out that open-coded sequence yourself. Slay. π
In case the timer is inactive, the timer_delete part is a total NOP β it's just vibing, doing absolutely nothing. But the timer is in any case activated with the new expiry time expires. So either way, she's going off at the new time. π₯
π¨ Caution vibes, bestie! If there are multiple unserialized concurrent users of the same timer, thenmod_timeris literally the only safe way to modify the timeout. Why? Becauseadd_timercannot modify an already running timer. So don't come for me withadd_timerwhen things are already in motion. This is not a drill. π
And if timer->function == NULL then the start operation is silently discarded. In this case the return value is 0 and, ngl, it's meaningless. So don't @ me. π
π RETURN π
0β The timer was inactive and started, or was in shutdown state and the operation was discarded. Basically, it's a "nothing happened" kinda vibe. π1β The timer was active and requeued to expire atexpires, or the timer was active and not modified becauseexpiresdid not change the effective expiry time. Either way, she's active and doing her thing. π
π SEE ALSO π
Here's the whole squad β every single reference, no skips, no cap: π«Ά
- Kernel file
./kernel/time/timer.c struct timer_base(9)__round_jiffies_relative(9)round_jiffies(9)round_jiffies_relative(9)__round_jiffies_up_relative(9)round_jiffies_up(9)round_jiffies_up_relative(9)timer_init_key(9)mod_timer_pending(9)timer_reduce(9)add_timer(9)add_timer_local(9)add_timer_global(9)add_timer_on(9)__timer_delete(9)timer_delete(9)timer_shutdown(9)__try_to_del_timer_sync(9)timer_delete_sync_try(9)__timer_delete_sync(9)timer_delete_sync(9)timer_shutdown_sync(9)fetch_next_timer_interrupt_remote(9)timer_unlock_remote_bases(9)timer_lock_remote_bases(9)timer_base_is_idle(9)timer_expire_remote(9)get_next_timer_interrupt(9)timer_base_try_to_set_idle(9)timer_clear_idle(9)__run_timers(9)
This page is brought to you by the ./kernel/time besties, dropping October 2026. mod_timer(9) out β stay slay, stay safe, and may your timers always be efficiently modified. πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms