Commit e0793a4e authored by Tetsuo Handa's avatar Tetsuo Handa Committed by Greg Kroah-Hartman

drm/ttm: Choose a pool to shrink correctly in ttm_dma_pool_shrink_scan().

commit 46c2df68 upstream.

We can use "unsigned int" instead of "atomic_t" by updating start_pool
variable under _manager->lock. This patch will make it possible to avoid
skipping when choosing a pool to shrink in round-robin style, after next
patch changes mutex_lock(_manager->lock) to !mutex_trylock(_manager->lork).
Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 283cac7e
...@@ -1004,9 +1004,9 @@ EXPORT_SYMBOL_GPL(ttm_dma_unpopulate); ...@@ -1004,9 +1004,9 @@ EXPORT_SYMBOL_GPL(ttm_dma_unpopulate);
static unsigned long static unsigned long
ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
{ {
static atomic_t start_pool = ATOMIC_INIT(0); static unsigned start_pool;
unsigned idx = 0; unsigned idx = 0;
unsigned pool_offset = atomic_add_return(1, &start_pool); unsigned pool_offset;
unsigned shrink_pages = sc->nr_to_scan; unsigned shrink_pages = sc->nr_to_scan;
struct device_pools *p; struct device_pools *p;
unsigned long freed = 0; unsigned long freed = 0;
...@@ -1017,7 +1017,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) ...@@ -1017,7 +1017,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
mutex_lock(&_manager->lock); mutex_lock(&_manager->lock);
if (!_manager->npools) if (!_manager->npools)
goto out; goto out;
pool_offset = pool_offset % _manager->npools; pool_offset = ++start_pool % _manager->npools;
list_for_each_entry(p, &_manager->pools, pools) { list_for_each_entry(p, &_manager->pools, pools) {
unsigned nr_free; unsigned nr_free;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment