From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Wilson Subject: Re: [PATCH 3/3] drm/i915: Preallocate mm node for GTT mmap offset Date: Tue, 18 Dec 2012 22:40:44 +0000 Message-ID: <20ab6b$5e6ffj@AZSMGA002.ch.intel.com> References: <1354912628-7776-1-git-send-email-chris@chris-wilson.co.uk> <1354912628-7776-3-git-send-email-chris@chris-wilson.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga14.intel.com (mga14.intel.com [143.182.124.37]) by gabe.freedesktop.org (Postfix) with ESMTP id BD038E5FA5 for ; Wed, 19 Dec 2012 20:33:41 -0800 (PST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Dave Airlie Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Wed, 19 Dec 2012 08:10:24 +1000, Dave Airlie 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