kthread_mod_delayed_work(9)
π 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_workandkthread_delayed_work_timer_fn.
β RETURN β
falseβ ifdworkwas idle and queuedtrueβ 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:
kthread_should_stop(9)kthread_should_park(9)kthread_freezable_should_stop(9)kthread_func(9)kthread_data(9)kthread_probe_data(9)kthread_complete_and_exit(9)kthread_create_on_node(9)kthread_bind(9)kthread_create_on_cpu(9)kthread_unpark(9)kthread_park(9)kthread_stop(9)kthread_stop_put(9)kthread_affine_preferred(9)kthreads_update_housekeeping(9)kthread_worker_fn(9)kthread_create_worker_on_node(9)kthread_create_worker_on_cpu(9)kthread_queue_work(9)kthread_delayed_work_timer_fn(9)kthread_queue_delayed_work(9)kthread_flush_work(9)kthread_cancel_work_sync(9)kthread_cancel_delayed_work_sync(9)kthread_flush_worker(9)kthread_destroy_worker(9)kthread_use_mm(9)kthread_unuse_mm(9)kthread_associate_blkcg(9)kthread_blkcg(9)
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
- 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