public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ben Widawsky <benjamin.widawsky@intel.com>
To: Intel GFX <intel-gfx@lists.freedesktop.org>
Cc: Ben Widawsky <ben@bwidawsk.net>,
	Ben Widawsky <benjamin.widawsky@intel.com>
Subject: [PATCH 3/8] drm/i915: evict VM instead of everything
Date: Wed, 11 Sep 2013 14:57:50 -0700	[thread overview]
Message-ID: <1378936675-27587-3-git-send-email-benjamin.widawsky@intel.com> (raw)
In-Reply-To: <1378936675-27587-1-git-send-email-benjamin.widawsky@intel.com>

When reserving objects during execbuf, it is possible to come across an
object which will not fit given the current fragmentation of the address
space. We do not have any defragment in drm_mm, so the strategy is to
instead evict everything, and reallocate objects.

With the upcoming addition of multiple VMs, there is no point to evict
everything since doing so is overkill for the specific case mentioned
above.

Recommended-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_drv.h            |  1 +
 drivers/gpu/drm/i915/i915_gem_evict.c      | 17 ++++++++++++++++-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  8 +++++++-
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 81ba5bb..7caf71d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2106,6 +2106,7 @@ int __must_check i915_gem_evict_something(struct drm_device *dev,
 					  unsigned cache_level,
 					  bool mappable,
 					  bool nonblock);
+int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle);
 int i915_gem_evict_everything(struct drm_device *dev);
 
 /* i915_gem_stolen.c */
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index e9033f0..a3e279d 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -155,7 +155,22 @@ found:
 	return ret;
 }
 
-static int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle)
+/**
+ * i915_gem_evict_vm - Try to free up VM space
+ *
+ * @vm: Address space to evict from
+ * @do_idle: Boolean directing whether to idle first.
+ *
+ * VM eviction is about freeing up virtual address space. If one wants fine
+ * grained eviction, they should see evict something for more details. In terms
+ * of freeing up actual system memory, this function may not accomplish the
+ * desired result. An object may be shared in multiple address space, and this
+ * function will not assert those objects be freed.
+ *
+ * Using do_idle will result in a more complete eviction because it retires, and
+ * inactivates current BOs.
+ */
+int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle)
 {
 	struct i915_vma *vma, *next;
 	int ret;
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index c8a01c1..ee93357 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -549,10 +549,16 @@ i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring,
 {
 	struct drm_i915_gem_object *obj;
 	struct i915_vma *vma;
+	struct i915_address_space *vm;
 	struct list_head ordered_vmas;
 	bool has_fenced_gpu_access = INTEL_INFO(ring->dev)->gen < 4;
 	int retry;
 
+	if (list_empty(vmas))
+		return 0;
+
+	vm = list_first_entry(vmas, struct i915_vma, exec_list)->vm;
+
 	INIT_LIST_HEAD(&ordered_vmas);
 	while (!list_empty(vmas)) {
 		struct drm_i915_gem_exec_object2 *entry;
@@ -641,7 +647,7 @@ err:		/* Decrement pin count for bound objects */
 		if (ret != -ENOSPC || retry++)
 			return ret;
 
-		ret = i915_gem_evict_everything(ring->dev);
+		ret = i915_gem_evict_vm(vm, true);
 		if (ret)
 			return ret;
 	} while (1);
-- 
1.8.4

  parent reply	other threads:[~2013-09-11 21:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11 21:57 [PATCH 1/8] drm/i915: Synchronize pread/pwrite with wait_rendering Ben Widawsky
2013-09-11 21:57 ` [PATCH 2/8] drm/i915: Extract vm specific part of eviction Ben Widawsky
2013-09-11 21:57 ` Ben Widawsky [this message]
2013-09-11 22:45   ` [PATCH 3/8] drm/i915: evict VM instead of everything Daniel Vetter
2013-09-11 21:57 ` [PATCH 4/8] drm/i915: trace vm eviction " Ben Widawsky
2013-09-11 22:02   ` Chris Wilson
2013-09-11 21:57 ` [PATCH 5/8] drm/i915: Convert active API to VMA Ben Widawsky
2013-09-11 22:14   ` Chris Wilson
2013-09-11 21:57 ` [PATCH 6/8] drm/i915: Add bind/unbind object functions to VM Ben Widawsky
2013-09-11 22:25   ` Chris Wilson
2013-09-11 22:49     ` Daniel Vetter
2013-09-11 21:57 ` [PATCH 7/8] drm/i915: Use the new vm [un]bind functions Ben Widawsky
2013-09-11 22:39   ` Chris Wilson
2013-09-14  1:08     ` Ben Widawsky
2013-09-14 15:31       ` Chris Wilson
2013-09-11 21:57 ` [PATCH 8/8] drm/i915: eliminate vm->insert_entries() Ben Widawsky
  -- strict thread matches above, loose matches on Subject: below --
2013-08-30 23:43 [PATCH 0/8] [RESEND] VMA patches Ben Widawsky
2013-08-30 23:43 ` [PATCH 3/8] drm/i915: evict VM instead of everything Ben Widawsky
2013-08-31  0:04   ` Chris Wilson

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=1378936675-27587-3-git-send-email-benjamin.widawsky@intel.com \
    --to=benjamin.widawsky@intel.com \
    --cc=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