LKML Archive on
help / color / mirror / Atom feed
* [PATCH RFC v3] sched: completion: locks should not be needed for reading completion state
@ 2015-01-23 16:20 Nicholas Mc Guire
  0 siblings, 0 replies; only message in thread
From: Nicholas Mc Guire @ 2015-01-23 16:20 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Peter Zijlstra, linux-kernel, Nicholas Mc Guire

Signed-off-by: Nicholas Mc Guire <>

v2: proper subsystem tag in subject line
v3: typo in return fixed

Sorry for this resend - just noticed that I had - carelessly lost the
second inversion somehow - logic should be correct now.

The ACCESS_ONCE is needed for calls in a loop that, if inlined, could
optimize out the re-fetching of x->done. An explicit memory barrier is 
not needed as complete() and complete_all() imply a barrier.

 kernel/sched/completion.c |    9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index 607f852..7c5cd70 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -288,13 +288,6 @@ EXPORT_SYMBOL(try_wait_for_completion);
 bool completion_done(struct completion *x)
-	unsigned long flags;
-	int ret = 1;
-	spin_lock_irqsave(&x->wait.lock, flags);
-	if (!x->done)
-		ret = 0;
-	spin_unlock_irqrestore(&x->wait.lock, flags);
-	return ret;
+	return !!ACCESS_ONCE(x->done);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-01-23 16:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-23 16:20 [PATCH RFC v3] sched: completion: locks should not be needed for reading completion state Nicholas Mc Guire

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