diff options
Diffstat (limited to 'kernel/sched/completion.c')
-rw-r--r-- | kernel/sched/completion.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c index 607f852b4d04..7052d3fd4e7b 100644 --- a/kernel/sched/completion.c +++ b/kernel/sched/completion.c | |||
@@ -268,6 +268,15 @@ bool try_wait_for_completion(struct completion *x) | |||
268 | unsigned long flags; | 268 | unsigned long flags; |
269 | int ret = 1; | 269 | int ret = 1; |
270 | 270 | ||
271 | /* | ||
272 | * Since x->done will need to be locked only | ||
273 | * in the non-blocking case, we check x->done | ||
274 | * first without taking the lock so we can | ||
275 | * return early in the blocking case. | ||
276 | */ | ||
277 | if (!ACCESS_ONCE(x->done)) | ||
278 | return 0; | ||
279 | |||
271 | spin_lock_irqsave(&x->wait.lock, flags); | 280 | spin_lock_irqsave(&x->wait.lock, flags); |
272 | if (!x->done) | 281 | if (!x->done) |
273 | ret = 0; | 282 | ret = 0; |
@@ -288,13 +297,6 @@ EXPORT_SYMBOL(try_wait_for_completion); | |||
288 | */ | 297 | */ |
289 | bool completion_done(struct completion *x) | 298 | bool completion_done(struct completion *x) |
290 | { | 299 | { |
291 | unsigned long flags; | 300 | return !!ACCESS_ONCE(x->done); |
292 | int ret = 1; | ||
293 | |||
294 | spin_lock_irqsave(&x->wait.lock, flags); | ||
295 | if (!x->done) | ||
296 | ret = 0; | ||
297 | spin_unlock_irqrestore(&x->wait.lock, flags); | ||
298 | return ret; | ||
299 | } | 301 | } |
300 | EXPORT_SYMBOL(completion_done); | 302 | EXPORT_SYMBOL(completion_done); |