From: "Xiong, James" <james.xi...@intel.com> When one of cached buffers is found to be evicted by kernel, most likely the buffers freed earlier than this buffer are gone too, go through the cached list in the bucket and purge.
Signed-off-by: Xiong, James <james.xi...@intel.com> --- src/mesa/drivers/dri/i965/brw_bufmgr.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c index 5235aa6..9f2e566 100644 --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c @@ -248,17 +248,20 @@ brw_bo_madvise(struct brw_bo *bo, int state) return madv.retained; } -/* drop the oldest entries that have been purged by the kernel */ +/* drop the entries that are older than the given time */ static void brw_bo_cache_purge_bucket(struct brw_bufmgr *bufmgr, - struct bo_cache_bucket *bucket) + struct bo_cache_bucket *bucket, + time_t time) { list_for_each_entry_safe(struct brw_bo, bo, &bucket->head, head) { - if (brw_bo_madvise(bo, I915_MADV_DONTNEED)) + if (bo->free_time >= time) { + brw_bo_madvise(bo, I915_MADV_DONTNEED); + list_del(&bo->head); + bo_free(bo); + } else { break; - - list_del(&bo->head); - bo_free(bo); + } } } @@ -319,8 +322,8 @@ retry: if (bo) { if (!brw_bo_madvise(bo, I915_MADV_WILLNEED)) { + brw_bo_cache_purge_bucket(bufmgr, bucket, bo->free_time); bo_free(bo); - brw_bo_cache_purge_bucket(bufmgr, bucket); return NULL; } -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev