All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] sched/wait: wait_event*_timeout() needs ___wait_cond_timeout() too
@ 2013-10-07 18:30 Oleg Nesterov
  2013-10-07 18:31 ` [PATCH 1/1] " Oleg Nesterov
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2013-10-07 18:30 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: Paul McKenney, Linus Torvalds, Thomas Gleixner, Andrew Morton,
	linux-kernel

And another patch we already discussed.

wait_event_timeout(wq, true, 0) still returns 0, this doesn't look
right, and this doesn't match __wait_event_timeout(timeout => 0).

Sure, most probably nobody uses the constant timeout == 0, but this
can break the code which does something like

	if (nonblock)
		timeout = 0;
	else
		timeout = TIMEOUT;

	success = wait_event_timeout(wq, CONDITION, timeout);

Oleg.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] sched/wait: wait_event*_timeout() needs ___wait_cond_timeout() too
  2013-10-07 18:30 [PATCH 0/1] sched/wait: wait_event*_timeout() needs ___wait_cond_timeout() too Oleg Nesterov
@ 2013-10-07 18:31 ` Oleg Nesterov
  2013-10-17 16:49   ` [tip:sched/core] sched/wait: Add ___wait_cond_timeout() to wait_event*_timeout() too tip-bot for Oleg Nesterov
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2013-10-07 18:31 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: Paul McKenney, Linus Torvalds, Thomas Gleixner, Andrew Morton,
	linux-kernel

Commit 4c663cfc ("wait: fix false timeouts when using
wait_event_timeout()") introduced the additional condition checks
after a timeout but only in the "slow" __wait*() paths.

wait_event_timeout(wq, CONDITION, 0) still returns 0 if CONDITION
is already true and we do not call __wait*().

Now that we have ___wait_cond_timeout() we can use it instead to
ensure that __ret will be properly updated.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 include/linux/wait.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/wait.h b/include/linux/wait.h
index ff9e20f..ec099b0 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -273,7 +273,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;								\
 })
@@ -331,7 +331,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;								\
@@ -772,7 +772,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;								\
-- 
1.5.5.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [tip:sched/core] sched/wait: Add ___wait_cond_timeout() to wait_event*_timeout() too
  2013-10-07 18:31 ` [PATCH 1/1] " Oleg Nesterov
@ 2013-10-17 16:49   ` tip-bot for Oleg Nesterov
  0 siblings, 0 replies; 3+ messages in thread
From: tip-bot for Oleg Nesterov @ 2013-10-17 16:49 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, oleg, tglx

Commit-ID:  8922915b38cd8b72f8e5af614b95be71d1d299d4
Gitweb:     http://git.kernel.org/tip/8922915b38cd8b72f8e5af614b95be71d1d299d4
Author:     Oleg Nesterov <oleg@redhat.com>
AuthorDate: Mon, 7 Oct 2013 20:31:06 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 16 Oct 2013 14:22:17 +0200

sched/wait: Add ___wait_cond_timeout() to wait_event*_timeout() too

Commit 4c663cfc ("wait: fix false timeouts when using
wait_event_timeout()") introduced the additional condition checks
after a timeout but only in the "slow" __wait*() paths.

wait_event_timeout(wq, CONDITION, 0) still returns 0 if CONDITION
is already true and we do not call __wait*().

Now that we have ___wait_cond_timeout() we can use it instead to
ensure that __ret will be properly updated.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20131007183106.GA10973@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/wait.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/wait.h b/include/linux/wait.h
index a2726c7..04c0260 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -270,7 +270,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;								\
 })
@@ -328,7 +328,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;								\
@@ -769,7 +769,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;								\

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-17 16:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-07 18:30 [PATCH 0/1] sched/wait: wait_event*_timeout() needs ___wait_cond_timeout() too Oleg Nesterov
2013-10-07 18:31 ` [PATCH 1/1] " Oleg Nesterov
2013-10-17 16:49   ` [tip:sched/core] sched/wait: Add ___wait_cond_timeout() to wait_event*_timeout() too tip-bot for Oleg Nesterov

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.