wq_worker_last_func(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ NAME ✨

Welcome to the Kernel API Manual, bestie! Today's page is wq_worker_last_func(9), and the NAME tea is: wq_worker_last_func β€” retrieve worker's last work function. πŸŽ€

πŸ’… SYNOPSIS πŸ’…

work_func_t wq_worker_last_func (struct task_struct *task );

🫢 ARGUMENTS 🫢

  • task β€” Task to retrieve last work function of. That's the task you're asking about, and it matters for the stable-value caveat below. πŸ’–

🌸 DESCRIPTION 🌸

Okay so this function determines the last function a worker executed. The scheduler calls it to get a worker's last known identity. πŸͺͺ It gets called during schedule when a kworker is going to sleep. Why? Because psi uses it to identify aggregation workers during dequeuing, so periodic aggregation can shut off when that worker is the last task in the system or cgroup to go to sleep. That's the whole point. πŸ’…

Caveat era, and this one is important: because this function doesn't involve any workqueue-related locking, it only returns stable values when called from inside the scheduler's queuing and dequeuing paths β€” and when task, which must be a kworker, is guaranteed to not be processing any works. Do not expect stable results outside that situation, bestie. No cap. 😭

πŸ”’ CONTEXT πŸ”’

Context check: raw_spin_lock_irq(rq->lock). πŸ”₯

⭐ RETURN ⭐

The last work function current executed as a worker β€” or NULL if it hasn't executed any work yet. That's the whole vibe check. βœ…

πŸ¦‹ SEE ALSO πŸ¦‹

Go be nosy in the Kernel file ./kernel/workqueue.c, then check out the whole workqueue extended universe:


Source/version: ./kernel Β· date: October 2026. Stay slay, hydrate, and may your worker always know its last function. πŸ’œβœ¨

πŸ“¦ where this page comes from