linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] completion: Document that reinit_completion() must be called after complete_all()
@ 2017-08-16 15:27 Steven Rostedt
  2017-08-16 16:47 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2017-08-16 15:27 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Zijlstra, Paul E. McKenney, Linus Torvalds,
	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.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index 13fc5ae..cc9d926 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -47,6 +47,9 @@ 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.
+ *
+ * A call to reinit_completion() must be used on @x if it is to be used
+ * again after this call.
  */
 void complete_all(struct completion *x)
 {

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

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

On Wed, Aug 16, 2017 at 8:27 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.

I think this is misleading.

People reading that comment will just say "why doesn't complete_all()
just reinit the thing then?"

So the comment should probably say that it needs to be reinited after
all the existing completion users have actually woken up, so that it
explains why the reinit isn't just done by complete_all().

                    Linus

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

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

On Wed, 16 Aug 2017 09:47:38 -0700
Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Wed, Aug 16, 2017 at 8:27 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.  
> 
> I think this is misleading.
> 
> People reading that comment will just say "why doesn't complete_all()
> just reinit the thing then?"
> 
> So the comment should probably say that it needs to be reinited after
> all the existing completion users have actually woken up, so that it
> explains why the reinit isn't just done by complete_all().
> 

Agreed. I'll send a v2.

Thanks,

-- Steve

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-16 15:27 [PATCH] completion: Document that reinit_completion() must be called after complete_all() Steven Rostedt
2017-08-16 16:47 ` Linus Torvalds
2017-08-16 16:59   ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).