kthread_mod_delayed_work(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… kthread_mod_delayed_work(9) β€” from the Kernel API Manual, bestie

okay so picture this: you're deep in kernel land, you've got a kthread worker, you've got some delayed work, and you just wanna change the vibe of when it fires. that's this function. welcome 🫢


✨ NAME ✨

kthread_mod_delayed_work β€” modify delay of or queue a kthread delayed work

like, either you're rescheduling the timer on work that's already pending, or you're queueing it up fresh. lowkey iconic that it does both πŸ’…


🌸 SYNOPSIS 🌸

bool kthread_mod_delayed_work (struct kthread_worker *worker , struct
kthread_delayed_work *dwork , unsigned long delay );

periodt. that's the whole signature. it returns a bool, so jot that down.


πŸŽ€ ARGUMENTS πŸŽ€

  • worker β€” the kthread worker you're using. your main character worker, if you will πŸ‘‘
  • dwork β€” the kthread delayed work you wanna queue up. this is the thing getting rescheduled πŸ¦‹
  • delay β€” how many jiffies to wait before queueing. yes, jiffies. not seconds, not vibes. jiffies ⏱️

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea. if dwork is idle, this is literally equivalent to kthread_queue_delayed_work β€” same thing, no diff, slay.

otherwise? you're modifying dwork's timer so that it expires after delay. and bestie, if delay is zero, the work is guaranteed to be queued immediately. like, immediately immediately. no cap πŸ”₯

now the messy part πŸ™ˆ β€” there's a special case when the work is being canceled in parallel. and yeah, that can happen either because of the real kthread_cancel_delayed_work_sync, or because of yet another kthread_mod_delayed_work call. it's giving chaos, honestly. so what do we do? we let the other command win and we return true here. that's it. the other one gets the crown πŸ‘‘

and why does that matter? because that return value can be used for reference counting, and the number of queued works stays the same. so it's not just a random true, it's load-bearing. also, the caller is supposed to synchronize these operations a reasonable way β€” that's on you, not on this function, iykyk 😌

real talk: this function is safe to call from any context including IRQ handler. yes, even there. that's the whole point. if you want the deets, go peek at __kthread_cancel_work and kthread_delayed_work_timer_fn.

⭐ RETURN ⭐

  • false β€” if dwork was idle and queued
  • true β€” otherwise

flip a coin, but make it kernel code πŸͺ™


🌈 SEE ALSO 🌈

all the siblings, the cousins, and the whole extended fam πŸ’œ β€” and yes, the kernel file lives at ./kernel/kthread.c:


and that's the whole page, bestie 🧚 this one's shipped out of ./kernel, dated October 2026, and it's the kthread_mod_delayed_work(9) page from the Kernel API Manual πŸ’…βœ¨ mwah, go reschedule something responsibly πŸ“

πŸ“¦ where this page comes from