From: Chris Wilson Subject: Re: [PATCH 1/3] drm: create unified vma offset manager Date: Wed, 19 Dec 2012 09:22:26 +0000 Message-ID: <84c8a8$71bnjn@orsmga001.jf.intel.com> References: <1355882180-27659-1-git-send-email-airlied@gmail.com> <1355882180-27659-2-git-send-email-airlied@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 97E90E5C80 for ; Wed, 19 Dec 2012 01:22:57 -0800 (PST) In-Reply-To: <1355882180-27659-2-git-send-email-airlied@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Dave Airlie , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Wed, 19 Dec 2012 11:56:18 +1000, Dave Airlie wrote: > From: Dave Airlie > > So we have to offset manager implementations for dealing with VMA offsets. > GEM had one using the hash table, TTM had one using an rbtree, > > I'd rather we just had one to rule them all, since ttm is using the rbtree > variant to allow sub mappings, to keep ABI we need to use that one. > > This also adds a bunch of inline helpers to avoid gem/ttm poking around > inside the vma_offset objects. TTM needs a reset helper to remove a vma_offset > when it copies an object to another one for buffer moves. The helpers > also let drivers avoid the map_list.hash_key << PAGE_SHIFT nonsense. Any clue as to the performance difference between the two implementations? What does it add to the cost of a pagefault? Hmm, don't have an i-g-t handy for scalability testing of the fault handlers. > +int drm_vma_offset_setup(struct drm_vma_offset_manager *man, > + struct drm_vma_offset_node *node, > + unsigned long num_pages) > +{ > + int ret; > + > +retry_pre_get: > + ret = drm_mm_pre_get(&man->addr_space_mm); > + if (unlikely(ret != 0)) > + return ret; > + > + write_lock(&man->vm_lock); > + node->vm_node = drm_mm_search_free(&man->addr_space_mm, > + num_pages, 0, 0); > + > + if (unlikely(node->vm_node == NULL)) { > + ret = -ENOMEM; ret = -ENOSPC; Depended upon by the higher layers for determining when to purge their caches; i-g-t/gem_mmap_offset_exhaustion > + goto out_unlock; > + } > + > + node->vm_node = drm_mm_get_block_atomic(node->vm_node, > + num_pages, 0); > + I'd feel happier if this tried to only take from the preallocated pool rather than actually try a GFP_ATOMIC allocation. > + if (unlikely(node->vm_node == NULL)) { > + write_unlock(&man->vm_lock); > + goto retry_pre_get; > + } > + > + node->num_pages = num_pages; > + drm_vma_offset_insert_rb(man, node); > + write_unlock(&man->vm_lock); > + > + return 0; > +out_unlock: > + write_unlock(&man->vm_lock); > + return ret; > + > +} > +EXPORT_SYMBOL(drm_vma_offset_setup); -- Chris Wilson, Intel Open Source Technology Centre