[Intel-gfx] [PATCH libdrm 5/5] intel: purge cached bucket when its cached buffer is evicted
James Xiong
james.xiong at intel.com
Fri Mar 16 01:20:14 UTC 2018
From: "Xiong, James" <james.xiong at intel.com>
Previously when a cached MRU buffer was found to be evicted by kernel,
the bucket was emptied. The new implementation purged these buffers that
were freed before the evicted one.
Signed-off-by: Xiong, James <james.xiong at intel.com>
---
intel/intel_bufmgr_gem.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index e3d5a8d..69b361b 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -684,22 +684,20 @@ drm_intel_gem_bo_madvise(drm_intel_bo *bo, int madv)
madv);
}
-/* drop the oldest entries that have been purged by the kernel */
+/* drop the entries that are older than the given time */
static void
drm_intel_gem_bo_cache_purge_bucket(drm_intel_bufmgr_gem *bufmgr_gem,
- struct drm_intel_gem_bo_bucket *bucket)
+ struct drm_intel_gem_bo_bucket *bucket,
+ time_t time)
{
- while (!DRMLISTEMPTY(&bucket->head)) {
- drm_intel_bo_gem *bo_gem;
-
- bo_gem = DRMLISTENTRY(drm_intel_bo_gem,
- bucket->head.next, head);
- if (drm_intel_gem_bo_madvise_internal
- (bufmgr_gem, bo_gem, I915_MADV_DONTNEED))
- break;
-
- DRMLISTDEL(&bo_gem->head);
- drm_intel_gem_bo_free(&bo_gem->bo);
+ drm_intel_bo_gem *bo_gem, *temp;
+ DRMLISTFOREACHENTRYSAFE(bo_gem, temp, &bucket->head, head) {
+ if (bo_gem->free_time >= time) {
+ drm_intel_gem_bo_madvise_internal
+ (bufmgr_gem, bo_gem, I915_MADV_DONTNEED);
+ DRMLISTDEL(&bo_gem->head);
+ drm_intel_gem_bo_free(&bo_gem->bo);
+ }
}
}
@@ -753,9 +751,10 @@ retry:
if (bo_gem) {
if (!drm_intel_gem_bo_madvise_internal
(bufmgr_gem, bo_gem, I915_MADV_WILLNEED)) {
- drm_intel_gem_bo_free(&bo_gem->bo);
drm_intel_gem_bo_cache_purge_bucket(bufmgr_gem,
- bucket);
+ bucket,
+ bo_gem->free_time);
+ drm_intel_gem_bo_free(&bo_gem->bo);
return NULL;
}
--
2.7.4
More information about the Intel-gfx
mailing list