Skip to content

Commit 4b04700

Browse files
hnaztorvalds
authored andcommitted
kernel: workqueue: clarify wq_worker_last_func() caller requirements
This function can only be called safely from very specific scheduler contexts. Document those. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Johannes Weiner <[email protected]> Suggested-by: Andrew Morton <[email protected]> Acked-by: Tejun Heo <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 6eb3c3d commit 4b04700

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

kernel/workqueue.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,16 @@ struct task_struct *wq_worker_sleeping(struct task_struct *task)
920920
* CONTEXT:
921921
* spin_lock_irq(rq->lock)
922922
*
923+
* This function is called during schedule() when a kworker is going
924+
* to sleep. It's used by psi to identify aggregation workers during
925+
* dequeuing, to allow periodic aggregation to shut-off when that
926+
* worker is the last task in the system or cgroup to go to sleep.
927+
*
928+
* As this function doesn't involve any workqueue-related locking, it
929+
* only returns stable values when called from inside the scheduler's
930+
* queuing and dequeuing paths, when @task, which must be a kworker,
931+
* is guaranteed to not be processing any works.
932+
*
923933
* Return:
924934
* The last work function %current executed as a worker, NULL if it
925935
* hasn't executed any work yet.

0 commit comments

Comments
 (0)