timer_shutdown_sync(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… timer_shutdown_sync ✨ Kernel API Manual

okay so bestie, gather round, because this here is timer_shutdown_sync(9) from the Kernel API Manual and it is literally the glow-up function you've been waiting for. πŸŽ€


🌸 NAME 🌸

timer_shutdown_sync β€” shut a timer down and make sure it can never, ever rearm itself again πŸ’… periodt.


✨ SYNOPSIS ✨

int timer_shutdown_sync (struct timer_list *timer );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • timer β€” the timer you're shutting down. that's the whole vibe. that's the one. 🫢

πŸ”₯ DESCRIPTION πŸ”₯

the way this works is: when the function returns, it is guaranteed that all of the following are true, no cap:

  • timer is not queued
  • The callback function of timer is not running
  • timer cannot be enqueued again. Any attempt to rearm timer is silently ignored.

for the synchronization rules, go read timer_delete_sync β€” that's where the receipts live. iykyk. πŸ“œ

this function is useful for final teardown of an infrastructure where the timer is subject to a circular dependency problem. and yes bestie, that is exactly as cursed as it sounds. πŸ’€

a common pattern for this is a timer and a workqueue where the timer can schedule work and work can arm the timer. on shutdown the workqueue must be destroyed and the timer must be prevented from rearming. unless the code has conditionals like 'if (mything->in_shutdown)' to prevent that, there is no way to get this correct with timer_delete_sync. like, none. it's giving impossible. 😭

timer_shutdown_sync is solving the problem. the correct ordering of calls in this case is:

timer_shutdown_sync(mything->timer);
workqueue_destroy(mything->workqueue);

after this 'mything' can be safely freed. πŸ¦‹βœ¨

and yes, this obviously implies that the timer is not required to be functional for the rest of the shutdown operation. main character timer doesn't need to keep working, she's retiring. πŸ‘‘


⭐ RETURN ⭐

  • 0 β€” The timer was not pending
  • 1 β€” The timer was pending

🌈 SEE ALSO 🌈

Kernel file ./kernel/time/timer.c:


that's the whole page bestie, ily, go shut down some timers responsibly πŸ’œπŸ“

source: ./kernel/time · October 2026 · timer_shutdown_sync(9) 🧚✨

πŸ“¦ where this page comes from