Skip to content

Commit b6976f3

Browse files
Christian KönigChristianKoenigAMD
authored andcommitted
drm/ttm: stop pooling cached NUMA pages v2
We only pool write combined and uncached allocations because they require extra overhead on allocation and release. If we also pool cached NUMA it not only means some extra unnecessary overhead, but also that under memory pressure it can happen that pages from the wrong NUMA node enters the pool and are re-used over and over again. This can lead to performance reduction after running into memory pressure. v2: restructure and cleanup the code a bit from the internal hack to test this. Signed-off-by: Christian König <[email protected]> Fixes: 4482d3c ("drm/ttm: add NUMA node id to the pool") CC: [email protected] Reviewed-by: Felix Kuehling <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent cf92bb7 commit b6976f3

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

drivers/gpu/drm/ttm/ttm_pool.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,23 @@ static struct ttm_pool_type *ttm_pool_select_type(struct ttm_pool *pool,
288288
enum ttm_caching caching,
289289
unsigned int order)
290290
{
291-
if (pool->use_dma_alloc || pool->nid != NUMA_NO_NODE)
291+
if (pool->use_dma_alloc)
292292
return &pool->caching[caching].orders[order];
293293

294294
#ifdef CONFIG_X86
295295
switch (caching) {
296296
case ttm_write_combined:
297+
if (pool->nid != NUMA_NO_NODE)
298+
return &pool->caching[caching].orders[order];
299+
297300
if (pool->use_dma32)
298301
return &global_dma32_write_combined[order];
299302

300303
return &global_write_combined[order];
301304
case ttm_uncached:
305+
if (pool->nid != NUMA_NO_NODE)
306+
return &pool->caching[caching].orders[order];
307+
302308
if (pool->use_dma32)
303309
return &global_dma32_uncached[order];
304310

@@ -566,11 +572,17 @@ void ttm_pool_init(struct ttm_pool *pool, struct device *dev,
566572
pool->use_dma_alloc = use_dma_alloc;
567573
pool->use_dma32 = use_dma32;
568574

569-
if (use_dma_alloc || nid != NUMA_NO_NODE) {
570-
for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i)
571-
for (j = 0; j < NR_PAGE_ORDERS; ++j)
572-
ttm_pool_type_init(&pool->caching[i].orders[j],
573-
pool, i, j);
575+
for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) {
576+
for (j = 0; j < NR_PAGE_ORDERS; ++j) {
577+
struct ttm_pool_type *pt;
578+
579+
/* Initialize only pool types which are actually used */
580+
pt = ttm_pool_select_type(pool, i, j);
581+
if (pt != &pool->caching[i].orders[j])
582+
continue;
583+
584+
ttm_pool_type_init(pt, pool, i, j);
585+
}
574586
}
575587
}
576588
EXPORT_SYMBOL(ttm_pool_init);
@@ -599,10 +611,16 @@ void ttm_pool_fini(struct ttm_pool *pool)
599611
{
600612
unsigned int i, j;
601613

602-
if (pool->use_dma_alloc || pool->nid != NUMA_NO_NODE) {
603-
for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i)
604-
for (j = 0; j < NR_PAGE_ORDERS; ++j)
605-
ttm_pool_type_fini(&pool->caching[i].orders[j]);
614+
for (i = 0; i < TTM_NUM_CACHING_TYPES; ++i) {
615+
for (j = 0; j < NR_PAGE_ORDERS; ++j) {
616+
struct ttm_pool_type *pt;
617+
618+
pt = ttm_pool_select_type(pool, i, j);
619+
if (pt != &pool->caching[i].orders[j])
620+
continue;
621+
622+
ttm_pool_type_fini(pt);
623+
}
606624
}
607625

608626
/* We removed the pool types from the LRU, but we need to also make sure

0 commit comments

Comments
 (0)