Commit 0aa12fb439838a85802ab8b7fbb9bcfc3e6e05cb

Authored by Sage Weil
1 parent 240ed68eb5

sched: add wait_for_completion_killable_timeout

Add missing _killable_timeout variant for wait_for_completion that will
return when a timeout expires or the task is killed.

CC: Ingo Molnar <mingo@elte.hu>
CC: Andreas Herrmann <andreas.herrmann3@amd.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Mike Galbraith <efault@gmx.de>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Sage Weil <sage@newdream.net>

Showing 2 changed files with 19 additions and 0 deletions Side-by-side Diff

include/linux/completion.h
... ... @@ -83,6 +83,8 @@
83 83 unsigned long timeout);
84 84 extern unsigned long wait_for_completion_interruptible_timeout(
85 85 struct completion *x, unsigned long timeout);
  86 +extern unsigned long wait_for_completion_killable_timeout(
  87 + struct completion *x, unsigned long timeout);
86 88 extern bool try_wait_for_completion(struct completion *x);
87 89 extern bool completion_done(struct completion *x);
88 90  
... ... @@ -4161,6 +4161,23 @@
4161 4161 EXPORT_SYMBOL(wait_for_completion_killable);
4162 4162  
4163 4163 /**
  4164 + * wait_for_completion_killable_timeout: - waits for completion of a task (w/(to,killable))
  4165 + * @x: holds the state of this particular completion
  4166 + * @timeout: timeout value in jiffies
  4167 + *
  4168 + * This waits for either a completion of a specific task to be
  4169 + * signaled or for a specified timeout to expire. It can be
  4170 + * interrupted by a kill signal. The timeout is in jiffies.
  4171 + */
  4172 +unsigned long __sched
  4173 +wait_for_completion_killable_timeout(struct completion *x,
  4174 + unsigned long timeout)
  4175 +{
  4176 + return wait_for_common(x, timeout, TASK_KILLABLE);
  4177 +}
  4178 +EXPORT_SYMBOL(wait_for_completion_killable_timeout);
  4179 +
  4180 +/**
4164 4181 * try_wait_for_completion - try to decrement a completion without blocking
4165 4182 * @x: completion structure
4166 4183 *