From: "Volkin, Bradley D" Subject: Re: [PATCH v2 1/5] drm/i915: Implement a framework for batch buffer pools Date: Wed, 9 Jul 2014 08:59:29 -0700 Message-ID: <20140709155929.GA21216@bdvolkin-ubuntu-desktop> References: <1404858400-18879-1-git-send-email-bradley.d.volkin@intel.com> <1404858400-18879-2-git-send-email-bradley.d.volkin@intel.com> <20140709073708.GC12556@nuc-i3427.alporthouse.com> <20140709151047.GA20891@bdvolkin-ubuntu-desktop> <20140709153008.GE8986@nuc-i3427.alporthouse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 9EBD96E11B for ; Wed, 9 Jul 2014 08:59:00 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20140709153008.GE8986@nuc-i3427.alporthouse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Chris Wilson Cc: "intel-gfx@lists.freedesktop.org" List-Id: intel-gfx@lists.freedesktop.org On Wed, Jul 09, 2014 at 08:30:08AM -0700, Chris Wilson wrote: > On Wed, Jul 09, 2014 at 08:10:47AM -0700, Volkin, Bradley D wrote: > > On Wed, Jul 09, 2014 at 12:37:08AM -0700, Chris Wilson wrote: > > > On Tue, Jul 08, 2014 at 03:26:36PM -0700, bradley.d.volkin@intel.com wrote: > > > > From: Brad Volkin > > > > > > > > This adds a small module for managing a pool of batch buffers. > > > > The only current use case is for the command parser, as described > > > > in the kerneldoc in the patch. The code is simple, but separating > > > > it out makes it easier to change the underlying algorithms and to > > > > extend to future use cases should they arise. > > > > > > > > The interface is simple: init to create an empty pool, fini to > > > > clean it up; get to obtain a new buffer, put to return it to the > > > > pool. Note that all buffers must be returned to the pool before > > > > freeing it. > > > > > > > > Buffers are purgeable while in the pool, but not explicitly > > > > truncated in order to avoid overhead during execbuf. > > > > > > > > Locking is currently based on the caller holding the struct_mutex. > > > > We already do that in the places where we will use the batch pool > > > > for the command parser. > > > > > > > > v2: > > > > - s/BUG_ON/WARN_ON/ for locking assertions > > > > - Remove the cap on pool size > > > > - Switch from alloc/free to init/fini > > > > > > You are missing the madvise mechanics. > > > > _get() and _put() set obj->madv, which I thought was enough for what I've > > described (i.e. purgeable while in the pool but not explicitly truncated). > > Is that not enough for the shrinker to truncate as needed? Or do you want > > them explicitly truncated while in the pool? I was worried about the extra > > cost of getting the backing storage back during execbuf. > > You need to check that the shrinker hasn't truncated your backing > storage whilst it was marked DONTNEED. It just amounts to checking for > obj->madv == __I915_MADV_PURGED in pool_get() and discarding the cache > entry if it has been truncated. Ok. When we hit a purged object, do you think it's worth doing a retry loop (as in libdrm's cache) or just fall straight through to allocating a new object? Brad > -Chris > > -- > Chris Wilson, Intel Open Source Technology Centre