Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Anholt <eric@anholt.net>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 2/4] Add io_ variants of wait_event() and wait_event_interruptible()
Date: Mon,  1 Nov 2010 13:23:42 -0700	[thread overview]
Message-ID: <1288643024-5706-3-git-send-email-eric@anholt.net> (raw)
In-Reply-To: <1288643024-5706-1-git-send-email-eric@anholt.net>

These tell the scheduler that we're waiting on IO, and still "busy".

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 include/linux/wait.h |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/include/linux/wait.h b/include/linux/wait.h
index 3efc9f3..b299c2b 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -202,6 +202,19 @@ do {									\
 	finish_wait(&wq, &__wait);					\
 } while (0)
 
+#define __io_wait_event(wq, condition) 					\
+do {									\
+	DEFINE_WAIT(__wait);						\
+									\
+	for (;;) {							\
+		prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE);	\
+		if (condition)						\
+			break;						\
+		io_schedule();						\
+	}								\
+	finish_wait(&wq, &__wait);					\
+} while (0)
+
 /**
  * wait_event - sleep until a condition gets true
  * @wq: the waitqueue to wait on
@@ -221,6 +234,13 @@ do {									\
 	__wait_event(wq, condition);					\
 } while (0)
 
+#define io_wait_event(wq, condition) 					\
+do {									\
+	if (condition)	 						\
+		break;							\
+	__io_wait_event(wq, condition);					\
+} while (0)
+
 #define __wait_event_timeout(wq, condition, ret)			\
 do {									\
 	DEFINE_WAIT(__wait);						\
@@ -260,6 +280,24 @@ do {									\
 	__ret;								\
 })
 
+#define __io_wait_event_interruptible(wq, condition, ret)		\
+do {									\
+	DEFINE_WAIT(__wait);						\
+									\
+	for (;;) {							\
+		prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE);	\
+		if (condition)						\
+			break;						\
+		if (!signal_pending(current)) {				\
+			io_schedule();					\
+			continue;					\
+		}							\
+		ret = -ERESTARTSYS;					\
+		break;							\
+	}								\
+	finish_wait(&wq, &__wait);					\
+} while (0)
+
 #define __wait_event_interruptible(wq, condition, ret)			\
 do {									\
 	DEFINE_WAIT(__wait);						\
@@ -301,6 +339,14 @@ do {									\
 	__ret;								\
 })
 
+#define io_wait_event_interruptible(wq, condition)			\
+({									\
+	int __ret = 0;							\
+	if (!(condition))						\
+		__io_wait_event_interruptible(wq, condition, __ret);	\
+	__ret;								\
+})
+
 #define __wait_event_interruptible_timeout(wq, condition, ret)		\
 do {									\
 	DEFINE_WAIT(__wait);						\
-- 
1.7.2.3

  parent reply	other threads:[~2010-11-01 20:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-01 20:23 [RFC] Hack to avoid C-state reduction during graphics activity Eric Anholt
2010-11-01 20:23 ` [PATCH 1/4] sched: Export io_schedule_timeout() Eric Anholt
2010-11-01 20:23 ` Eric Anholt [this message]
2010-11-01 20:23 ` [PATCH 3/4] drm/i915: Declare waits on GPU as io waits, to reduce C-state reduction Eric Anholt
2010-11-01 20:23 ` [PATCH 4/4] cpuidle: Hack iowait weighting to avoid C-state reduction for graphics Eric Anholt
2010-11-02 12:20   ` [Intel-gfx] " ykzhao
2010-11-02 15:42     ` Eric Anholt
2010-11-02 20:00       ` [Intel-gfx] " Alexey Fisher
2010-11-02 20:44         ` Chris Wilson
2010-11-01 21:00 ` [RFC] Hack to avoid C-state reduction during graphics activity Andrew Lutomirski
2010-11-01 21:43   ` Eric Anholt

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=1288643024-5706-3-git-send-email-eric@anholt.net \
    --to=eric@anholt.net \
    --cc=intel-gfx@lists.freedesktop.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