diff options
Diffstat (limited to 'kernel/sched/completion.c')
-rw-r--r-- | kernel/sched/completion.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c index 9d1fe32d..7052d3f 100644 --- a/kernel/sched/completion.c +++ b/kernel/sched/completion.c @@ -268,6 +268,15 @@ bool try_wait_for_completion(struct completion *x) unsigned long flags; int ret = 1; + /* + * Since x->done will need to be locked only + * in the non-blocking case, we check x->done + * first without taking the lock so we can + * return early in the blocking case. + */ + if (!ACCESS_ONCE(x->done)) + return 0; + spin_lock_irqsave(&x->wait.lock, flags); if (!x->done) ret = 0; |