All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Dave Airlie <airlied@gmail.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm/i915: Preallocate mm node for GTT mmap offset
Date: Tue, 18 Dec 2012 22:40:44 +0000	[thread overview]
Message-ID: <20ab6b$5e6ffj@AZSMGA002.ch.intel.com> (raw)
In-Reply-To: <CAPM=9twjcJNR5MnzoG1U6vJisMRzZiHF2rFXBTgq__Q0Lc0ymA@mail.gmail.com>

On Wed, 19 Dec 2012 08:10:24 +1000, Dave Airlie <airlied@gmail.com> wrote:
> > As the shrinker may be invoked for the allocation, and it may reap
> > neighbouring objects in the offset range mm, we need to be careful in
> > the order in which we allocate the node, search for free space and then
> > insert the node into the mmap offset range manager.
> 
> Maybe I'm being a bit stupid here, but this seems like a pointless
> micro optimisation thrown in with a
> deinlining.

The actual bug fix is the removal of the allocation between searching
for a free node and inserting it into the tree:

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 24efae4..b885f2c 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -353,8 +353,8 @@ drm_gem_create_mmap_offset(struct drm_gem_object *obj)
 	map->handle = obj;
 
 	/* Get a DRM GEM mmap offset allocated... */
-	list->file_offset_node = drm_mm_search_free(&mm->offset_manager,
-			obj->size / PAGE_SIZE, 0, false);
+	list->file_offset_node = kzalloc(sizeof(*list->file_offset_node),
+					 GFP_KERNEL);
 
 	if (!list->file_offset_node) {
 		DRM_ERROR("failed to allocate offset for bo %d\n", obj->name);
@@ -362,12 +362,11 @@ drm_gem_create_mmap_offset(struct drm_gem_object *obj)
 		goto out_free_list;
 	}
 
-	list->file_offset_node = drm_mm_get_block(list->file_offset_node,
-			obj->size / PAGE_SIZE, 0);
-	if (!list->file_offset_node) {
-		ret = -ENOMEM;
+	ret = drm_mm_insert_node(&mm->offset_manage,
+				 list->file_offset_node,
+				 obj->size / PAGE_SIZE, 0);
+	if (ret)
 		goto out_free_list;
-	}
 
 	list->hash.key = list->file_offset_node->start;
 	ret = drm_ht_insert_item(&mm->offset_hash, &list->hash);

-- 
Chris Wilson, Intel Open Source Technology Centre

  reply	other threads:[~2012-12-20  4:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07 20:37 [PATCH 1/3] drm: Export routines for inserting preallocated nodes into the mm manager Chris Wilson
2012-12-07 20:37 ` [PATCH 2/3] drm/i915: Preallocate the drm_mm_node prior to manipulating the GTT drm_mm manager Chris Wilson
2012-12-12 10:18   ` Jani Nikula
2012-12-12 10:27     ` Chris Wilson
2012-12-07 20:37 ` [PATCH 3/3] drm/i915: Preallocate mm node for GTT mmap offset Chris Wilson
2012-12-12 10:48   ` Jani Nikula
2012-12-12 10:55     ` Chris Wilson
2012-12-18 21:11       ` Daniel Vetter
2012-12-18 22:36         ` Daniel Vetter
2012-12-18 22:10   ` Dave Airlie
2012-12-18 22:40     ` Chris Wilson [this message]
2012-12-12 10:02 ` [PATCH 1/3] drm: Export routines for inserting preallocated nodes into the mm manager Jani Nikula
2012-12-18  0:28 ` Daniel Vetter
2012-12-18  9:13   ` 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='20ab6b$5e6ffj@AZSMGA002.ch.intel.com' \
    --to=chris@chris-wilson.co.uk \
    --cc=airlied@gmail.com \
    --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.