All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Hurley <peter@hurleysoftware.com>
To: "Kilian, Jens" <jens.kilian@advantest.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Missing wait_event_killable_timeout?
Date: Wed, 21 Oct 2015 10:08:22 -0400	[thread overview]
Message-ID: <56279C56.7050306@hurleysoftware.com> (raw)
In-Reply-To: <BY2PR05MB19767A6672D0773553EAAE0AEB380@BY2PR05MB1976.namprd05.prod.outlook.com>

Hi Jens,

On 10/21/2015 03:20 AM, Kilian, Jens wrote:
> I'd like to use a version of wait_event_killable() with a timeout, but it seems to be missing?  I found a mention of it in a recent LKML message though:
> 
> 	https://lkml.org/lkml/2015/10/14/337
> 
> Does this patch look reasonable?

Where is the in-tree user? Without that, someone will notice this
isn't being used and will remove it.

Regards,
Peter Hurley

> diff --git a/include/linux/wait.h b/include/linux/wait.h
> index 1e1bf9f..8419986 100644
> --- a/include/linux/wait.h
> +++ b/include/linux/wait.h
> @@ -738,6 +738,41 @@ do {									\
>  	__ret;								\
>  })
>  
> +#define __wait_event_killable_timeout(wq, condition, timeout)   	\
> +	___wait_event(wq, ___wait_cond_timeout(condition),		\
> +		      TASK_KILLABLE, 0, timeout,			\
> +		      __ret = schedule_timeout(__ret))
> +
> +/**
> + * wait_event_killable_timeout - sleep until a condition gets true or a timeout elapses
> + * @wq: the waitqueue to wait on
> + * @condition: a C expression for the event to wait for
> + * @timeout: timeout, in jiffies
> + *
> + * The process is put to sleep (TASK_KILLABLE) until the @condition
> + * evaluates to true or a signal is received.
> + * The @condition is checked each time the waitqueue @wq is woken up.
> + *
> + * wake_up() has to be called after changing any variable that could
> + * change the result of the wait condition.
> + *
> + * Returns:
> + * 0 if the @condition evaluated to %false after the @timeout elapsed,
> + * 1 if the @condition evaluated to %true after the @timeout elapsed,
> + * the remaining jiffies (at least 1) if the @condition evaluated
> + * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was
> + * interrupted by a signal.
> + */
> +#define wait_event_killable_timeout(wq, condition, timeout)	\
> +({									\
> +	long __ret = timeout;						\
> +	might_sleep();							\
> +	if (!___wait_cond_timeout(condition))				\
> +		__ret = __wait_event_killable_timeout(wq,		\
> +						condition, timeout);	\
> +	__ret;								\
> +})
> +
>  
>  #define __wait_event_lock_irq(wq, condition, lock, cmd)			\
>  	(void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0,	\
> 
> 


      reply	other threads:[~2015-10-21 14:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-21  7:20 Missing wait_event_killable_timeout? Kilian, Jens
2015-10-21 14:08 ` Peter Hurley [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=56279C56.7050306@hurleysoftware.com \
    --to=peter@hurleysoftware.com \
    --cc=jens.kilian@advantest.com \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.