public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] completion: Document that reinit_completion() must be  called after complete_all()
@ 2017-08-16 17:12 Steven Rostedt
  2017-08-16 17:18 ` Linus Torvalds
  2017-08-16 18:12 ` [tip:sched/core] sched/completion: " tip-bot for Steven Rostedt
  0 siblings, 2 replies; 6+ messages in thread
From: Steven Rostedt @ 2017-08-16 17:12 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Zijlstra, Linus Torvalds, Paul E. McKenney,
	Andrew Morton

The function complete_all() modifies the completion "done" variable to
UINT_MAX, and no other caller (wait_for_completion(), etc) will modify
it back to zero. That means that any call to complete_all() must have a
reinit_completion() before that completion can be used again.

Document this fact by the complete_all() function.

Also document that completion_done() will always return true if
complete_all() is called.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index 13fc5ae..2950f44 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -47,6 +47,13 @@ EXPORT_SYMBOL(complete);
  *
  * It may be assumed that this function implies a write memory barrier before
  * changing the task state if and only if any tasks are woken up.
+ *
+ * Since complete_all() sets the completion of @x permanently to done
+ * to allow multiple waiters to finish, a call to reinit_completion()
+ * must be used on @x if @x is to be used again. The code must make
+ * sure that all waiters have woken and finished before reinitializing
+ * @x. Also note that the function completion_done() can not be used
+ * to know if there are still waiters after complete_all() has been called.
  */
 void complete_all(struct completion *x)
 {
@@ -297,6 +304,7 @@ EXPORT_SYMBOL(try_wait_for_completion);
  *	Return: 0 if there are waiters (wait_for_completion() in progress)
  *		 1 if there are no waiters.
  *
+ *	Note, this will always return true if complete_all() was called on @X.
  */
 bool completion_done(struct completion *x)
 {

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

* Re: [PATCH v2] completion: Document that reinit_completion() must be called after complete_all()
  2017-08-16 17:12 [PATCH v2] completion: Document that reinit_completion() must be called after complete_all() Steven Rostedt
@ 2017-08-16 17:18 ` Linus Torvalds
  2017-08-16 17:20   ` Steven Rostedt
  2017-08-16 18:06   ` Ingo Molnar
  2017-08-16 18:12 ` [tip:sched/core] sched/completion: " tip-bot for Steven Rostedt
  1 sibling, 2 replies; 6+ messages in thread
From: Linus Torvalds @ 2017-08-16 17:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Ingo Molnar, Peter Zijlstra, Paul E. McKenney,
	Andrew Morton

On Wed, Aug 16, 2017 at 10:12 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> The function complete_all() modifies the completion "done" variable to
> UINT_MAX, and no other caller (wait_for_completion(), etc) will modify
> it back to zero. That means that any call to complete_all() must have a
> reinit_completion() before that completion can be used again.
>
> Document this fact by the complete_all() function.
>
> Also document that completion_done() will always return true if
> complete_all() is called.

Ack. Do I take it directly or is it indended for some other tree?

               Linus

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

* Re: [PATCH v2] completion: Document that reinit_completion() must be called after complete_all()
  2017-08-16 17:18 ` Linus Torvalds
@ 2017-08-16 17:20   ` Steven Rostedt
  2017-08-16 18:06   ` Ingo Molnar
  1 sibling, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2017-08-16 17:20 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: LKML, Ingo Molnar, Peter Zijlstra, Paul E. McKenney,
	Andrew Morton

On Wed, 16 Aug 2017 10:18:27 -0700
Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Wed, Aug 16, 2017 at 10:12 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> > The function complete_all() modifies the completion "done" variable to
> > UINT_MAX, and no other caller (wait_for_completion(), etc) will modify
> > it back to zero. That means that any call to complete_all() must have a
> > reinit_completion() before that completion can be used again.
> >
> > Document this fact by the complete_all() function.
> >
> > Also document that completion_done() will always return true if
> > complete_all() is called.  
> 
> Ack. Do I take it directly or is it indended for some other tree?
> 
>                Linus

You can take it, if nobody else wants to.

Thanks!

-- Steve

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

* Re: [PATCH v2] completion: Document that reinit_completion() must be called after complete_all()
  2017-08-16 17:18 ` Linus Torvalds
  2017-08-16 17:20   ` Steven Rostedt
@ 2017-08-16 18:06   ` Ingo Molnar
  2017-08-16 18:50     ` Linus Torvalds
  1 sibling, 1 reply; 6+ messages in thread
From: Ingo Molnar @ 2017-08-16 18:06 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Steven Rostedt, LKML, Peter Zijlstra, Paul E. McKenney,
	Andrew Morton


* Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Wed, Aug 16, 2017 at 10:12 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> > The function complete_all() modifies the completion "done" variable to
> > UINT_MAX, and no other caller (wait_for_completion(), etc) will modify
> > it back to zero. That means that any call to complete_all() must have a
> > reinit_completion() before that completion can be used again.
> >
> > Document this fact by the complete_all() function.
> >
> > Also document that completion_done() will always return true if
> > complete_all() is called.
> 
> Ack. Do I take it directly or is it indended for some other tree?

Will add it to the scheduler tree.

Thanks,

	Ingo

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

* [tip:sched/core] sched/completion: Document that reinit_completion() must be called after complete_all()
  2017-08-16 17:12 [PATCH v2] completion: Document that reinit_completion() must be called after complete_all() Steven Rostedt
  2017-08-16 17:18 ` Linus Torvalds
@ 2017-08-16 18:12 ` tip-bot for Steven Rostedt
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Steven Rostedt @ 2017-08-16 18:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, peterz, rostedt, paulmck, akpm, linux-kernel, mingo, hpa,
	torvalds

Commit-ID:  9c8783201cb58e9af8ddeb0cc68f37b0a44ca16c
Gitweb:     http://git.kernel.org/tip/9c8783201cb58e9af8ddeb0cc68f37b0a44ca16c
Author:     Steven Rostedt <rostedt@goodmis.org>
AuthorDate: Wed, 16 Aug 2017 13:12:02 -0400
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 16 Aug 2017 20:08:10 +0200

sched/completion: Document that reinit_completion() must be called after complete_all()

The complete_all() function modifies the completion's "done" variable to
UINT_MAX, and no other caller (wait_for_completion(), etc) will modify
it back to zero. That means that any call to complete_all() must have a
reinit_completion() before that completion can be used again.

Document this fact by the complete_all() function.

Also document that completion_done() will always return true if
complete_all() is called.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170816131202.195c2f4b@gandalf.local.home
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/completion.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index 13fc5ae..2950f44 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -47,6 +47,13 @@ EXPORT_SYMBOL(complete);
  *
  * It may be assumed that this function implies a write memory barrier before
  * changing the task state if and only if any tasks are woken up.
+ *
+ * Since complete_all() sets the completion of @x permanently to done
+ * to allow multiple waiters to finish, a call to reinit_completion()
+ * must be used on @x if @x is to be used again. The code must make
+ * sure that all waiters have woken and finished before reinitializing
+ * @x. Also note that the function completion_done() can not be used
+ * to know if there are still waiters after complete_all() has been called.
  */
 void complete_all(struct completion *x)
 {
@@ -297,6 +304,7 @@ EXPORT_SYMBOL(try_wait_for_completion);
  *	Return: 0 if there are waiters (wait_for_completion() in progress)
  *		 1 if there are no waiters.
  *
+ *	Note, this will always return true if complete_all() was called on @X.
  */
 bool completion_done(struct completion *x)
 {

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

* Re: [PATCH v2] completion: Document that reinit_completion() must be called after complete_all()
  2017-08-16 18:06   ` Ingo Molnar
@ 2017-08-16 18:50     ` Linus Torvalds
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Torvalds @ 2017-08-16 18:50 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Steven Rostedt, LKML, Peter Zijlstra, Paul E. McKenney,
	Andrew Morton

On Wed, Aug 16, 2017 at 11:06 AM, Ingo Molnar <mingo@kernel.org> wrote:
>
> Will add it to the scheduler tree.

Heh, I already took it, but I hadn't pushed out yet, so I undid it
all, and will get it from you. It's not like it's some timing-critical
fix ;)

               Linus

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

end of thread, other threads:[~2017-08-16 18:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-16 17:12 [PATCH v2] completion: Document that reinit_completion() must be called after complete_all() Steven Rostedt
2017-08-16 17:18 ` Linus Torvalds
2017-08-16 17:20   ` Steven Rostedt
2017-08-16 18:06   ` Ingo Molnar
2017-08-16 18:50     ` Linus Torvalds
2017-08-16 18:12 ` [tip:sched/core] sched/completion: " tip-bot for Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox