intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: intel-gfx@lists.freedesktop.org
Cc: Ben Widawsky <ben@bwidawsk.net>
Subject: [PATCH 14/15] drm/i915: Implement batch scheduler
Date: Fri, 18 Nov 2011 18:24:31 -0800	[thread overview]
Message-ID: <1321669472-8045-15-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1321669472-8045-1-git-send-email-ben@bwidawsk.net>

While the fairness scheduler also currently uses batches to attempt to
keep things fair, that is an implementation detail. A fairness scheduler
should still be fair even if we achieve a better granularity on future
products.  The batch scheduler on the other hand is meant to remain
relevant even in light of newer scheduling metrics.

The batch scheduler introduces a per-client high and low watermark.
These watermarks define when the client will get blocked, and when it
will get unblocked in terms of number of batches submitted.

For example, if we wanted to run X as unthrottled, we could use a
high watermark of -1, and a low watermark of 0. In theory it is also
accomplished by high watermark = low watermark.

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_dma.c            |    2 +
 drivers/gpu/drm/i915/i915_drv.h            |    5 +++-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   32 +++++++++++++++++++++------
 3 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index df06a7e..a871b95 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -2211,6 +2211,8 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file)
 	INIT_LIST_HEAD(&file_priv->client_link);
 	file_priv->outstanding_requests = 0;
 	file_priv->forced_throttles = 0;
+	file_priv->high_watermark = 50;
+	file_priv->low_watermark = 5;
 
 	mutex_lock(&dev->struct_mutex);
 	dev_priv->num_clients++;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a12445b..9933e01 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -746,7 +746,8 @@ typedef struct drm_i915_private {
 	struct {
 		#define I915_SCHEDULER_NONE 0
 		#define I915_SCHEDULER_FAIR 1
-		#define I915_SCHEDULER_INVALID 2
+		#define I915_SCHEDULER_BATCH 2
+		#define I915_SCHEDULER_INVALID 3
 		unsigned type;
 		/* Point at which we consider blocking */
 		unsigned high_watermark;
@@ -942,6 +943,8 @@ struct drm_i915_file_private {
 	struct list_head request_list;
 	int outstanding_requests;
 	int forced_throttles;
+	unsigned high_watermark;
+	unsigned low_watermark;
 
 	struct list_head client_link;
 };
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index c2e96be..a24e890 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -968,17 +968,35 @@ i915_schedule(struct drm_device *dev, struct intel_ring_buffer *ring, struct drm
 	struct drm_i915_gem_request *request = NULL;
 	u32 seqno = 0;
 	int ret, i = 0;
+	uint32_t high_watermark = 0, low_watermark = 0;
 
-#define BLOCK_CONDITION ( \
-	(dev_priv->scheduler.type != I915_SCHEDULER_NONE) && \
-	(file_priv->outstanding_requests > dev_priv->scheduler.high_watermark))
+	switch (dev_priv->scheduler.type) {
+	case I915_SCHEDULER_NONE:
+		return I915_DONE;
+	case I915_SCHEDULER_FAIR:
+		high_watermark = dev_priv->scheduler.high_watermark;
+		low_watermark = dev_priv->scheduler.low_watermark;
+		break;
+	case I915_SCHEDULER_BATCH:
+		/* Can't do anything until we hold the spinlock */
+		break;
+	default:
+		WARN_ON(1);
+		return I915_DONE;
+	}
+
+#define BLOCK_CONDITION (file_priv->outstanding_requests > high_watermark)
 #define OUT_CONDITION ( \
 	(atomic_read(&dev_priv->mm.wedged)) || \
 	(dev_priv->mm.suspended))
-#define RUNNABLE ( \
-	file_priv->outstanding_requests < dev_priv->scheduler.low_watermark)
+#define RUNNABLE (file_priv->outstanding_requests < low_watermark)
 
 	spin_lock(&file_priv->lock);
+	if (dev_priv->scheduler.type == I915_SCHEDULER_BATCH) {
+		BUG_ON(high_watermark != 0 || low_watermark != 0);
+		high_watermark = file_priv->high_watermark;
+		low_watermark = file_priv->low_watermark;
+	}
 	if (!BLOCK_CONDITION) {
 		spin_unlock(&file_priv->lock);
 		return I915_DONE;
@@ -997,7 +1015,7 @@ i915_schedule(struct drm_device *dev, struct intel_ring_buffer *ring, struct drm
 	}
 
 	list_for_each_entry(request, &file_priv->request_list, client_list) {
-		if (i == dev_priv->scheduler.low_watermark) {
+		if (i == low_watermark) {
 			seqno = request->seqno;
 			break;
 		}
@@ -1005,7 +1023,7 @@ i915_schedule(struct drm_device *dev, struct intel_ring_buffer *ring, struct drm
 	}
 	spin_unlock(&file_priv->lock);
 
-	BUG_ON(seqno == 0 || i < dev_priv->scheduler.low_watermark);
+	BUG_ON(seqno == 0 || i < low_watermark);
 
 	ret = i915_wait_request(ring, seqno, true);
 	BUG_ON(!mutex_is_locked(&dev->struct_mutex));
-- 
1.7.7.3

  parent reply	other threads:[~2011-11-19  2:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-19  2:24 [PATCH 00/15] [RFC] Forced throttling/scheduling Ben Widawsky
2011-11-19  2:24 ` [PATCH 01/15] drm/i915: refactor debugfs open function Ben Widawsky
2011-11-20 18:50   ` Kenneth Graunke
2011-11-19  2:24 ` [PATCH 02/15] drm/i915: refactor debugfs create functions Ben Widawsky
2011-11-19  2:24 ` [PATCH 03/15] drm/i915: relative_constants_mode race fix Ben Widawsky
2011-11-23 22:30   ` Ben Widawsky
2011-11-19  2:24 ` [PATCH 04/15] drm/i915: drop lock support for i915_wait_request Ben Widawsky
2011-11-19  2:24 ` [PATCH 05/15] drm/i915: remove mm structure from file_priv Ben Widawsky
2011-11-19  2:24 ` [PATCH 06/15] drm/i915: Keep track of drm_file in file_priv Ben Widawsky
2011-11-19  2:24 ` [PATCH 07/15] drm/i915: Keep track of request counts Ben Widawsky
2011-11-19  2:24 ` [PATCH 08/15] drm/i915: fairness Ben Widawsky
2011-11-19  2:24 ` [PATCH 09/15] drm/i915: Keep track of open i915 clients Ben Widawsky
2011-11-19  2:24 ` [PATCH 10/15] drm/i915: debugfs entry for " Ben Widawsky
2011-11-19  2:24 ` [PATCH 11/15] drm/i915: debugfs entries for scheduler params Ben Widawsky
2011-11-19  2:24 ` [PATCH 12/15] drm/i915: infrastructure to support scheduler types Ben Widawsky
2011-11-19  2:24 ` [PATCH 13/15] drm/i915: get/set scheduler type from debugfs Ben Widawsky
2011-11-19  2:24 ` Ben Widawsky [this message]
2011-11-19  2:24 ` [PATCH 15/15] drm/i915: Add handling for batch parameters in debugfs Ben Widawsky
2011-11-29 14:30 ` [PATCH 00/15] [RFC] Forced throttling/scheduling Eugeni Dodonov
2012-04-02 18:28 ` Ben Widawsky

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=1321669472-8045-15-git-send-email-ben@bwidawsk.net \
    --to=ben@bwidawsk.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;
as well as URLs for NNTP newsgroup(s).