The patch titled Subject: kernel: workqueue: clarify wq_worker_last_func() caller requirements has been added to the -mm tree. Its filename is kernel-workqueue-clarify-wq_worker_last_func-caller-requirements.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/kernel-workqueue-clarify-wq_worker_last_func-caller-requirements.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/kernel-workqueue-clarify-wq_worker_last_func-caller-requirements.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Johannes Weiner <hannes@xxxxxxxxxxx> Subject: 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/20190206150528.31198-1-hannes@xxxxxxxxxxx Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx> Suggested-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Acked-by: Tejun Heo <tj@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/kernel/workqueue.c~kernel-workqueue-clarify-wq_worker_last_func-caller-requirements +++ a/kernel/workqueue.c @@ -918,6 +918,16 @@ struct task_struct *wq_worker_sleeping(s * CONTEXT: * spin_lock_irq(rq->lock) * + * 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. + * * Return: * The last work function %current executed as a worker, NULL if it * hasn't executed any work yet. _ Patches currently in -mm which might be from hannes@xxxxxxxxxxx are fs-kernfs-add-poll-file-operation.patch kernel-cgroup-add-poll-file-operation.patch kernel-workqueue-clarify-wq_worker_last_func-caller-requirements.patch