public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Paul McKenney <paulmck@linux.vnet.ibm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/6] sched, wait: Collapse __wait_event macros -v4
Date: Mon, 30 Sep 2013 19:40:54 +0200	[thread overview]
Message-ID: <20130930174054.GA28129@redhat.com> (raw)
In-Reply-To: <20130930152242.207382649@infradead.org>

On 09/30, Peter Zijlstra wrote:
>
> Compile and boot tested on x86_64.

Looks fine, but I'll try to actually read this series tomorrow.
Not that I think this needs my review ;)

But at first glance, I think that something like below makes sense
as 7/6.

Once again, of course I do not blame this series, but
wait_event_timeout(wq, true, 0) still returns 0.

Oleg.


--- x/include/linux/wait.h
+++ x/include/linux/wait.h
@@ -184,9 +184,14 @@ wait_queue_head_t *bit_waitqueue(void *,
  	bool __cond = (condition);					\
  	if (__cond && !__ret)						\
  		__ret = 1;						\
- 	__cond || !__ret;						\
+ 	__cond;								\
 })
 
+#define ___wait_schedule_timeout(tout)					\
+	if (!tout)							\
+		break;							\
+	tout = schedule_timeout(tout)
+
 #define ___wait_signal_pending(state)					\
 	((state == TASK_INTERRUPTIBLE && signal_pending(current)) ||	\
 	 (state == TASK_KILLABLE && fatal_signal_pending(current)))
@@ -248,7 +253,7 @@ do {									\
 #define __wait_event_timeout(wq, condition, timeout)			\
 	___wait_event(wq, ___wait_cond_timeout(condition),		\
 		      TASK_UNINTERRUPTIBLE, 0, timeout,			\
-		      __ret = schedule_timeout(__ret))
+		      ___wait_schedule_timeout(__ret))
 
 /**
  * wait_event_timeout - sleep until a condition gets true or a timeout elapses
@@ -270,7 +275,7 @@ do {									\
 #define wait_event_timeout(wq, condition, timeout)			\
 ({									\
 	long __ret = timeout;						\
-	if (!(condition)) 						\
+	if (!___wait_cond_timeout(condition)) 				\
 		__ret = __wait_event_timeout(wq, condition, timeout);	\
 	__ret;								\
 })
@@ -305,7 +310,7 @@ do {									\
 #define __wait_event_interruptible_timeout(wq, condition, timeout)	\
 	___wait_event(wq, ___wait_cond_timeout(condition),		\
 		      TASK_INTERRUPTIBLE, 0, timeout,			\
-		      __ret = schedule_timeout(__ret))
+		      ___wait_schedule_timeout(__ret))
 
 /**
  * wait_event_interruptible_timeout - sleep until a condition gets true or a timeout elapses
@@ -328,7 +333,7 @@ do {									\
 #define wait_event_interruptible_timeout(wq, condition, timeout)	\
 ({									\
 	long __ret = timeout;						\
-	if (!(condition))						\
+	if (!___wait_cond_timeout(condition))				\
 		__ret = __wait_event_interruptible_timeout(wq, 		\
 						condition, timeout);	\
 	__ret;								\
@@ -739,7 +744,7 @@ do {									\
 	___wait_event(wq, ___wait_cond_timeout(condition),		\
 		      TASK_INTERRUPTIBLE, 0, ret,	      		\
 		      spin_unlock_irq(&lock);				\
-		      __ret = schedule_timeout(__ret);			\
+		      ___wait_schedule_timeout(__ret);			\
 		      spin_lock_irq(&lock));
 
 /**
@@ -770,7 +775,7 @@ do {									\
 						  timeout)		\
 ({									\
 	long __ret = timeout;						\
-	if (!(condition))						\
+	if (!___wait_cond_timeout(condition))				\
 		__ret = __wait_event_interruptible_lock_irq_timeout(	\
 					wq, condition, lock, timeout);	\
 	__ret;								\


  parent reply	other threads:[~2013-09-30 17:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-30 15:22 [PATCH 0/6] sched, wait: Collapse __wait_event macros -v4 Peter Zijlstra
2013-09-30 15:22 ` [PATCH 1/6] sched, wait: Make the signal_pending() checks consistent Peter Zijlstra
2013-09-30 15:22 ` [PATCH 2/6] sched, wait: Change timeout logic Peter Zijlstra
2013-09-30 15:48   ` Linus Torvalds
2013-09-30 16:09     ` Peter Zijlstra
2013-09-30 15:22 ` [PATCH 3/6] sched, wait: Change the wait_exclusive control flow Peter Zijlstra
2013-09-30 15:22 ` [PATCH 4/6] sched, wait: Collapse __wait_event macros Peter Zijlstra
2013-09-30 15:22 ` [PATCH 5/6] sched, wait: Also use ___wait_event() for __wait_event_hrtimeout Peter Zijlstra
2013-09-30 15:22 ` [PATCH 6/6] sched, wait: Make the __wait_event*() interface more friendly Peter Zijlstra
2013-10-01  6:39   ` Ingo Molnar
2013-09-30 15:50 ` [PATCH 0/6] sched, wait: Collapse __wait_event macros -v4 Linus Torvalds
2013-09-30 16:11   ` Peter Zijlstra
2013-09-30 17:40 ` Oleg Nesterov [this message]
2013-09-30 18:00   ` Oleg Nesterov
2013-09-30 18:09   ` Peter Zijlstra
2013-09-30 18:13     ` Oleg Nesterov
2013-10-01 14:09       ` Oleg Nesterov
2013-10-01 14:39         ` Peter Zijlstra
2013-10-01 15:16           ` Oleg Nesterov
2013-10-01 17:01 ` [RFC] introduce prepare_to_wait_event() Oleg Nesterov
2013-10-01 17:25   ` Peter Zijlstra
2013-10-01 17:33     ` Oleg Nesterov
2013-10-01 17:44       ` Peter Zijlstra

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=20130930174054.GA28129@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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