summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm
diff options
context:
space:
mode:
authorRoger He <Hongbo.He@amd.com>2017-11-21 09:47:16 +0100
committerAlex Deucher <alexander.deucher@amd.com>2017-12-06 18:48:15 +0100
commit1bfcbad18fc0c2618ae141ff2d8c384cf81bf98e (patch)
tree3d7abc99b4cbcec55d4f3a4f7a5927ff9a073ca3 /drivers/gpu/drm/ttm
parentdrm/ttm: add page order support in ttm_pages_put (diff)
downloadlinux-1bfcbad18fc0c2618ae141ff2d8c384cf81bf98e.tar.xz
linux-1bfcbad18fc0c2618ae141ff2d8c384cf81bf98e.zip
drm/ttm: roundup the shrink request to prevent skip huge pool
e.g. shrink reqeust is less than 512, the logic will skip huge pool Reviewed-by: Chunming Zhou <david1.zhou@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Roger He <Hongbo.He@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/ttm')
-rw-r--r--drivers/gpu/drm/ttm/ttm_page_alloc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index 337c228b44ad..116897a20514 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -442,17 +442,19 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
/* select start pool in round robin fashion */
for (i = 0; i < NUM_POOLS; ++i) {
unsigned nr_free = shrink_pages;
+ unsigned page_nr;
+
if (shrink_pages == 0)
break;
pool = &_manager->pools[(i + pool_offset)%NUM_POOLS];
+ page_nr = (1 << pool->order);
/* OK to use static buffer since global mutex is held. */
- nr_free_pool = (nr_free >> pool->order);
- if (nr_free_pool == 0)
- continue;
-
+ nr_free_pool = roundup(nr_free, page_nr) >> pool->order;
shrink_pages = ttm_page_pool_free(pool, nr_free_pool, true);
- freed += ((nr_free_pool - shrink_pages) << pool->order);
+ freed += (nr_free_pool - shrink_pages) << pool->order;
+ if (freed >= sc->nr_to_scan)
+ break;
}
mutex_unlock(&lock);
return freed;