mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>, linux-kernel@vger.kernel.org
Cc: Oleg Drokin <oleg.drokin@intel.com>,
	Andreas Dilger <andreas.dilger@intel.com>,
	James Simmons <jsimmons@infradead.org>,
	Patrick Farrell <paf@cray.com>
Subject: Re: [PATCH 1/2] sched/wait: add wait_event_idle() functions.
Date: Sat, 23 Dec 2017 09:59:19 +1100	[thread overview]
Message-ID: <87608y8j3s.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20171222080656.5p54fdhxqqxdtvyo@hirez.programming.kicks-ass.net>

[-- Attachment #1: Type: text/plain, Size: 4574 bytes --]


[removing close lustre-devel list as requested, adding assorted Lustre individuals]

On Fri, Dec 22 2017, Peter Zijlstra wrote:

> On Fri, Dec 22, 2017 at 02:11:04PM +1100, NeilBrown wrote:
>> The new TASK_IDLE state (TASK_UNINTERRUPTIBLE | __TASK_NOLOAD)
>> is not much used.  One way to make it easier to use is to
>> add wait_event*() family functions that make use of it.
>> This patch adds:
>>   wait_event_idle()
>>   wait_event_idle_timeout()
>>   wait_event_idle_exclusive()
>> 
>> This set were chosen because lustre needs them before
>> it can discard its own l_wait_event() macro.
>
> Seems sane enough; please take through the tree that introduces the
> first users of this.

Will do.

>
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

Thanks,
NeilBrown


>
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>>  include/linux/wait.h |   77 ++++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 77 insertions(+)
>> 
>> diff --git a/include/linux/wait.h b/include/linux/wait.h
>> index 158715445ffb..3aea0780c9d0 100644
>> --- a/include/linux/wait.h
>> +++ b/include/linux/wait.h
>> @@ -597,6 +597,83 @@ do {										\
>>  	__ret;									\
>>  })
>>  
>> +/**
>> + * wait_event_idle - wait for a condition with contributing to system load
>> + * @wq_head: the waitqueue to wait on
>> + * @condition: a C expression for the event to wait for
>> + *
>> + * The process is put to sleep (TASK_IDLE) until the
>> + * @condition evaluates to true.
>> + * The @condition is checked each time the waitqueue @wq_head is woken up.
>> + *
>> + * wake_up() has to be called after changing any variable that could
>> + * change the result of the wait condition.
>> + *
>> + */
>> +#define wait_event_idle(wq_head, condition)					\
>> +do {										\
>> +	might_sleep();								\
>> +	if (!(condition))							\
>> +		___wait_event(wq_head, condition, TASK_IDLE, 0, 0, schedule());	\
>> +} while (0)
>> +
>> +/**
>> + * wait_event_idle_exclusive - wait for a condition with contributing to system load
>> + * @wq_head: the waitqueue to wait on
>> + * @condition: a C expression for the event to wait for
>> + *
>> + * The process is put to sleep (TASK_IDLE) until the
>> + * @condition evaluates to true.
>> + * The @condition is checked each time the waitqueue @wq_head is woken up.
>> + *
>> + * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag
>> + * set thus when other process waits process on the list if this
>> + * process is awaken further processes are not considered.
>> + *
>> + * wake_up() has to be called after changing any variable that could
>> + * change the result of the wait condition.
>> + *
>> + */
>> +#define wait_event_idle_exclusive(wq_head, condition)				\
>> +do {										\
>> +	might_sleep();								\
>> +	if (!(condition))							\
>> +		___wait_event(wq_head, condition, TASK_IDLE, 1, 0, schedule());	\
>> +} while (0)
>> +
>> +#define __wait_event_idle_timeout(wq_head, condition, timeout)			\
>> +	___wait_event(wq_head, ___wait_cond_timeout(condition),			\
>> +		      TASK_IDLE, 0, timeout,					\
>> +		      __ret = schedule_timeout(__ret))
>> +
>> +/**
>> + * wait_event_idle_timeout - sleep without load until a condition gets true or a timeout elapses
>> + * @wq_head: 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_IDLE) until the
>> + * @condition evaluates to true. The @condition is checked each time
>> + * the waitqueue @wq_head 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,
>> + * or the remaining jiffies (at least 1) if the @condition evaluated
>> + * to %true before the @timeout elapsed.
>> + */
>> +#define wait_event_idle_timeout(wq_head, condition, timeout)			\
>> +({										\
>> +	long __ret = timeout;							\
>> +	might_sleep();								\
>> +	if (!___wait_cond_timeout(condition))					\
>> +		__ret = __wait_event_timeout(wq_head, condition, timeout);	\
>> +	__ret;									\
>> +})
>> +
>>  extern int do_wait_intr(wait_queue_head_t *, wait_queue_entry_t *);
>>  extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_entry_t *);
>>  
>> 
>> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2017-12-22 22:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-22  3:11 [PATCH 0/2] Add new wait_event macros to support lustre NeilBrown
2017-12-22  3:11 ` [PATCH 1/2] sched/wait: add wait_event_idle() functions NeilBrown
2017-12-22  8:06   ` Peter Zijlstra
2017-12-22 22:59     ` NeilBrown [this message]
2017-12-22  3:11 ` [PATCH 2/2] sched/wait: add wait_event_idle_exclusive_lifo() NeilBrown
2017-12-22  8:08   ` Peter Zijlstra
2017-12-22  8:22     ` Peter Zijlstra
2017-12-22 23:10     ` NeilBrown

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=87608y8j3s.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome