|author||Johannes Weiner <email@example.com>||2019-03-07 16:29:30 -0800|
|committer||Linus Torvalds <firstname.lastname@example.org>||2019-03-07 18:32:01 -0800|
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://email@example.com Signed-off-by: Johannes Weiner <firstname.lastname@example.org> Suggested-by: Andrew Morton <email@example.com> Acked-by: Tejun Heo <firstname.lastname@example.org> Signed-off-by: Andrew Morton <email@example.com> Signed-off-by: Linus Torvalds <firstname.lastname@example.org>
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 56814902bc56..d51c37dd9422 100644
@@ -920,6 +920,16 @@ struct task_struct *wq_worker_sleeping(struct task_struct *task)
+ * This function is called during schedule() when a kworker is going
+ * to sleep. It's used by psi to identify aggregation workers during
+ * dequeuing, to allow periodic aggregation to shut-off when that
+ * worker is the last task in the system or cgroup to go to sleep.
+ * As 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, when @task, which must be a kworker,
+ * is guaranteed to not be processing any works.
* The last work function %current executed as a worker, NULL if it
* hasn't executed any work yet.