LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] kernel: workqueue: clarify wq_worker_last_func() caller requirements
@ 2019-02-06 15:05 Johannes Weiner
  2019-02-06 16:31 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Weiner @ 2019-02-06 15:05 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Andrew Morton, Peter Zijlstra, linux-mm, linux-kernel, kernel-team

This function can only be called safely from very specific scheduler
contexts. Document those.

Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 kernel/workqueue.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Andrew suggested including the explanations that came up during the
code review in the function doc. As the function has since been
merged, sending as follow-up for 5.1. Thanks!

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index fc5d23d752a5..23a67b9430da 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -918,6 +918,16 @@ struct task_struct *wq_worker_sleeping(struct task_struct *task)
  * 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.
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] kernel: workqueue: clarify wq_worker_last_func() caller requirements
  2019-02-06 15:05 [PATCH] kernel: workqueue: clarify wq_worker_last_func() caller requirements Johannes Weiner
@ 2019-02-06 16:31 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2019-02-06 16:31 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Peter Zijlstra, linux-mm, linux-kernel, kernel-team

On Wed, Feb 06, 2019 at 04:05:28PM +0100, Johannes Weiner wrote:
> This function can only be called safely from very specific scheduler
> contexts. Document those.
> 
> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06 15:05 [PATCH] kernel: workqueue: clarify wq_worker_last_func() caller requirements Johannes Weiner
2019-02-06 16:31 ` Tejun Heo

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git
	git clone --mirror https://lore.kernel.org/lkml/10 lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git