[Intel-gfx] [PATCH] intel: When re-use cache is full, wait instead of allocating

Eric Anholt eric at anholt.net
Tue Dec 16 02:40:53 CET 2008


On Mon, 2008-12-15 at 15:08 -0800, Keith Packard wrote:
> This limits application memory usage by waiting for the GPU to free memory
> rather than simply continuing to allocate more memory.

I think I theoretically prefer the current behavior in the presence of
max_entries where you still alloc a new buffer (so you're not syncing)
but you free the buffer being unreferenced instead of adding it to the
cache.

Of course, I haven't run with max_entries yet since we shouldn't need
it.

> Signed-off-by: Keith Packard <keithp at keithp.com>
> ---
>  libdrm/intel/intel_bufmgr_gem.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c
> index 323007a..9f6ef68 100644
> --- a/libdrm/intel/intel_bufmgr_gem.c
> +++ b/libdrm/intel/intel_bufmgr_gem.c
> @@ -350,8 +350,12 @@ drm_intel_gem_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name,
>  	bo_gem = bucket->head;
>          busy.handle = bo_gem->gem_handle;
>  
> -        ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_BUSY, &busy);
> -        alloc_from_cache = (ret == 0 && busy.busy == 0);
> +	if (bucket->max_entries != -1 && bucket->num_entries >= bucket->max_entries)
> +	    alloc_from_cache = 1;
> +	else {
> +	    ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_BUSY, &busy);
> +	    alloc_from_cache = (ret == 0 && busy.busy == 0);
> +	}
>  
>  	if (alloc_from_cache) {
>  	    bucket->head = bo_gem->next;
-- 
Eric Anholt
eric at anholt.net                         eric.anholt at intel.com


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/intel-gfx/attachments/20081215/fcc03a18/attachment.sig>


More information about the Intel-gfx mailing list