All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH] drm/i915: Maintain LRU order of inactive objects upon access by CPU (v2)
Date: Sat,  7 Aug 2010 21:45:03 +0100	[thread overview]
Message-ID: <1281213903-20409-1-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20100807193439.GA14399@viiv.ffwll.ch>

In order to reduce the penalty of fallbacks under memory pressure and to
avoid a potential immediate ping-pong of evicting a mmaped buffer, we
move the object to the tail of the inactive list when a page is freshly
faulted or the object is moved into the CPU domain.

We choose not to protect the CPU objects from casual eviction,
preferring to keep the GPU active for as long as possible.

v2: Daniel Vetter found a bug where I forgot that pinned objects are
kept off the inactive list.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index b5a7b00..8f3e0c1 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -57,6 +57,14 @@ static void i915_gem_free_object_tail(struct drm_gem_object *obj);
 static LIST_HEAD(shrink_list);
 static DEFINE_SPINLOCK(shrink_list_lock);
 
+static inline bool
+i915_gem_object_is_inactive(struct drm_i915_gem_object *obj_priv)
+{
+	return obj_priv->gtt_space &&
+		!obj_priv->active &&
+		obj_priv->pin_count == 0;
+}
+
 int i915_gem_do_init(struct drm_device *dev, unsigned long start,
 		     unsigned long end)
 {
@@ -1036,6 +1044,11 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
 		ret = i915_gem_object_set_to_cpu_domain(obj, write_domain != 0);
 	}
 
+	
+	/* Maintain LRU order of "inactive" objects */
+	if (ret == 0 && i915_gem_object_is_inactive(obj_priv))
+		list_move_tail(&obj_priv->list, &dev_priv->mm.inactive_list);
+
 	drm_gem_object_unreference(obj);
 	mutex_unlock(&dev->struct_mutex);
 	return ret;
@@ -1137,6 +1150,7 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
 	struct drm_gem_object *obj = vma->vm_private_data;
 	struct drm_device *dev = obj->dev;
+	drm_i915_private_t *dev_priv = dev->dev_private;
 	struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
 	pgoff_t page_offset;
 	unsigned long pfn;
@@ -1166,6 +1180,9 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 			goto unlock;
 	}
 
+	if (i915_gem_object_is_inactive(obj_priv))
+		list_move_tail(&obj_priv->list, &dev_priv->mm.inactive_list);
+
 	pfn = ((dev->agp->base + obj_priv->gtt_offset) >> PAGE_SHIFT) +
 		page_offset;
 
-- 
1.7.1

  reply	other threads:[~2010-08-07 20:45 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-07 10:01 Rebased series on drm-intel-next Chris Wilson
2010-08-07 10:01 ` [PATCH 01/20] drm/i915: Append the object onto the inactive list on binding Chris Wilson
2010-08-07 10:01 ` [PATCH 02/20] drm/i915: prepare for fair lru eviction Chris Wilson
2010-08-07 10:01 ` [PATCH 03/20] drm/i915: Use a common seqno for all rings Chris Wilson
2010-08-07 10:01 ` [PATCH 04/20] drm/i915: Move the eviction logic to its own file Chris Wilson
2010-08-07 10:01 ` [PATCH 05/20] drm/i915: Implement fair lru eviction across both rings. (v2) Chris Wilson
2010-08-07 10:01 ` [PATCH 06/20] drm/i915: Maintain LRU order of inactive objects upon access by CPU Chris Wilson
2010-08-07 19:34   ` Daniel Vetter
2010-08-07 20:45     ` Chris Wilson [this message]
2010-08-07 10:01 ` [PATCH 07/20] drm/i915: Record error batch buffers using iomem Chris Wilson
2010-08-07 10:01 ` [PATCH 08/20] drm/i915/sdvo: Markup a few constant strings Chris Wilson
2010-08-07 10:01 ` [PATCH 09/20] drm/i915: Enable aspect/centering panel fitting for Ironlake Chris Wilson
2010-08-07 10:01 ` [PATCH 10/20] drm/i915: Write to display base last Chris Wilson
2010-08-07 10:01 ` [PATCH 11/20] drm/i915: Truncate the shmem backing pages on purge Chris Wilson
2010-08-07 10:01 ` [PATCH 12/20] drm/i915/display: Add pipe/plane information to dpms debugging Chris Wilson
2010-08-07 10:01 ` [PATCH 13/20] drm/i915/opregion: Use ASLE response codes defined in 0.1 Chris Wilson
2010-08-07 10:01 ` [PATCH 14/20] drm/i915: Update watermarks for Ironlake after dpms changes Chris Wilson
2010-08-07 10:01 ` [PATCH 15/20] drm/i915/ringbuffer: Set ring->gem_buffer = NULL on init unwind Chris Wilson
2010-08-07 10:01 ` [PATCH 16/20] drm/i915: Ensure that while(INREG()) are bounded (v2) Chris Wilson
2010-09-21 14:22   ` Carlos R. Mafra
2010-09-21 14:35     ` Chris Wilson
2010-09-21 15:55       ` Jesse Barnes
2010-09-22  8:32         ` Carlos R. Mafra
2010-09-22  8:43           ` Chris Wilson
2010-09-22 10:48             ` Carlos R. Mafra
2010-09-22 10:57               ` Chris Wilson
2010-09-22 13:42                 ` Carlos R. Mafra
2010-09-22 14:29                   ` Chris Wilson
2010-09-22 15:26                     ` Carlos R. Mafra
2010-09-22 15:47                       ` Chris Wilson
2010-08-07 10:01 ` [PATCH 17/20] drm/i915/edp: Flush the write before waiting for PLLs Chris Wilson
2010-08-07 10:01 ` [PATCH 18/20] drm/i915: FBC is updated within set_base() so remove second call in mode_set() Chris Wilson
2010-08-07 10:01 ` [PATCH 19/20] drm/i915: Only update i845/i865 CURBASE when disabled (v2) Chris Wilson
2010-08-07 10:01 ` [PATCH 20/20] drm/i915: Apply i830 errata for cursor alignment Chris Wilson
2010-08-08 18:31   ` 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=1281213903-20409-1-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --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 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.