public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Steven Rostedt <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org,
	paulmck@linux.vnet.ibm.com, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com,
	torvalds@linux-foundation.org
Subject: [tip:sched/core] sched/completion: Document that reinit_completion() must be called after complete_all()
Date: Wed, 16 Aug 2017 11:12:51 -0700	[thread overview]
Message-ID: <tip-9c8783201cb58e9af8ddeb0cc68f37b0a44ca16c@git.kernel.org> (raw)
In-Reply-To: <20170816131202.195c2f4b@gandalf.local.home>

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)
 {

      parent reply	other threads:[~2017-08-16 18:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-bot for Steven Rostedt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-9c8783201cb58e9af8ddeb0cc68f37b0a44ca16c@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox