Re: [PATCH 2/2] drm/ttm: optimize the pool shrinker a bit v2

From: Andrew Morton
Date: Thu Apr 15 2021 - 16:33:16 EST


On Thu, 15 Apr 2021 13:56:24 +0200 "Christian König" <ckoenig.leichtzumerken@xxxxxxxxx> wrote:

> @@ -530,6 +525,11 @@ void ttm_pool_fini(struct ttm_pool *pool)
> for (j = 0; j < MAX_ORDER; ++j)
> ttm_pool_type_fini(&pool->caching[i].orders[j]);
> }
> +
> + /* We removed the pool types from the LRU, but we need to also make sure
> + * that no shrinker is concurrently freeing pages from the pool.
> + */
> + sync_shrinkers();

It isn't immediately clear to me how this works. ttm_pool_fini() has
already freed all the pages hasn't it? So why would it care if some
shrinkers are still playing with the pages?

Or is it the case that ttm_pool_fini() is assuming that there will be
some further action against these pages, which requires that shrinkers
no longer be accessing the pages and which further assumes that future
shrinker invocations will not be able to look up these pages?

IOW, a bit more explanation about the dynamics here would help!