mirror of
https://github.com/torvalds/linux.git
synced 2026-04-24 17:42:27 -04:00
drm/ttm: Handle cgroup based eviction in TTM
cgroup resource allocation has to be handled in TTM, so -EAGAIN from cgroups can be converted into -ENOSPC, and the limitcg can be properly evicted in ttm code. When hitting a resource limit through -EAGAIN, the cgroup for which the limit is hit is also returned. This allows eviction to delete only from cgroups which are a subgroup of the current cgroup. The returned CSS is used to determine if eviction is valuable for a given resource, and allows TTM to only target specific resources to lower memory usage. Co-developed-by: Friedrich Vock <friedrich.vock@gmx.de> Signed-off-by: Friedrich Vock <friedrich.vock@gmx.de> Co-developed-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20241204134410.1161769-4-dev@lankhorst.se Signed-off-by: Maxime Ripard <mripard@kernel.org>
This commit is contained in:
committed by
Maxime Ripard
parent
7b0af165e2
commit
2b624a2c18
@@ -258,13 +258,13 @@ static void ttm_bo_unreserve_basic(struct kunit *test)
|
||||
bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
|
||||
bo->priority = bo_prio;
|
||||
|
||||
err = ttm_resource_alloc(bo, place, &res1);
|
||||
err = ttm_resource_alloc(bo, place, &res1, NULL);
|
||||
KUNIT_ASSERT_EQ(test, err, 0);
|
||||
|
||||
bo->resource = res1;
|
||||
|
||||
/* Add a dummy resource to populate LRU */
|
||||
ttm_resource_alloc(bo, place, &res2);
|
||||
ttm_resource_alloc(bo, place, &res2, NULL);
|
||||
|
||||
dma_resv_lock(bo->base.resv, NULL);
|
||||
ttm_bo_unreserve(bo);
|
||||
@@ -300,12 +300,12 @@ static void ttm_bo_unreserve_pinned(struct kunit *test)
|
||||
dma_resv_lock(bo->base.resv, NULL);
|
||||
ttm_bo_pin(bo);
|
||||
|
||||
err = ttm_resource_alloc(bo, place, &res1);
|
||||
err = ttm_resource_alloc(bo, place, &res1, NULL);
|
||||
KUNIT_ASSERT_EQ(test, err, 0);
|
||||
bo->resource = res1;
|
||||
|
||||
/* Add a dummy resource to the pinned list */
|
||||
err = ttm_resource_alloc(bo, place, &res2);
|
||||
err = ttm_resource_alloc(bo, place, &res2, NULL);
|
||||
KUNIT_ASSERT_EQ(test, err, 0);
|
||||
KUNIT_ASSERT_EQ(test,
|
||||
list_is_last(&res2->lru.link, &priv->ttm_dev->unevictable), 1);
|
||||
@@ -355,7 +355,7 @@ static void ttm_bo_unreserve_bulk(struct kunit *test)
|
||||
ttm_bo_set_bulk_move(bo1, &lru_bulk_move);
|
||||
dma_resv_unlock(bo1->base.resv);
|
||||
|
||||
err = ttm_resource_alloc(bo1, place, &res1);
|
||||
err = ttm_resource_alloc(bo1, place, &res1, NULL);
|
||||
KUNIT_ASSERT_EQ(test, err, 0);
|
||||
bo1->resource = res1;
|
||||
|
||||
@@ -363,7 +363,7 @@ static void ttm_bo_unreserve_bulk(struct kunit *test)
|
||||
ttm_bo_set_bulk_move(bo2, &lru_bulk_move);
|
||||
dma_resv_unlock(bo2->base.resv);
|
||||
|
||||
err = ttm_resource_alloc(bo2, place, &res2);
|
||||
err = ttm_resource_alloc(bo2, place, &res2, NULL);
|
||||
KUNIT_ASSERT_EQ(test, err, 0);
|
||||
bo2->resource = res2;
|
||||
|
||||
@@ -401,7 +401,7 @@ static void ttm_bo_put_basic(struct kunit *test)
|
||||
bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
|
||||
bo->type = ttm_bo_type_device;
|
||||
|
||||
err = ttm_resource_alloc(bo, place, &res);
|
||||
err = ttm_resource_alloc(bo, place, &res, NULL);
|
||||
KUNIT_ASSERT_EQ(test, err, 0);
|
||||
bo->resource = res;
|
||||
|
||||
@@ -518,7 +518,7 @@ static void ttm_bo_pin_unpin_resource(struct kunit *test)
|
||||
|
||||
bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
|
||||
|
||||
err = ttm_resource_alloc(bo, place, &res);
|
||||
err = ttm_resource_alloc(bo, place, &res, NULL);
|
||||
KUNIT_ASSERT_EQ(test, err, 0);
|
||||
bo->resource = res;
|
||||
|
||||
@@ -569,7 +569,7 @@ static void ttm_bo_multiple_pin_one_unpin(struct kunit *test)
|
||||
|
||||
bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
|
||||
|
||||
err = ttm_resource_alloc(bo, place, &res);
|
||||
err = ttm_resource_alloc(bo, place, &res, NULL);
|
||||
KUNIT_ASSERT_EQ(test, err, 0);
|
||||
bo->resource = res;
|
||||
|
||||
|
||||
@@ -542,7 +542,7 @@ static void ttm_bo_validate_no_placement_signaled(struct kunit *test)
|
||||
bo->ttm = old_tt;
|
||||
}
|
||||
|
||||
err = ttm_resource_alloc(bo, place, &bo->resource);
|
||||
err = ttm_resource_alloc(bo, place, &bo->resource, NULL);
|
||||
KUNIT_EXPECT_EQ(test, err, 0);
|
||||
KUNIT_ASSERT_EQ(test, man->usage, size);
|
||||
|
||||
@@ -603,7 +603,7 @@ static void ttm_bo_validate_no_placement_not_signaled(struct kunit *test)
|
||||
bo = ttm_bo_kunit_init(test, test->priv, size, NULL);
|
||||
bo->type = params->bo_type;
|
||||
|
||||
err = ttm_resource_alloc(bo, place, &bo->resource);
|
||||
err = ttm_resource_alloc(bo, place, &bo->resource, NULL);
|
||||
KUNIT_EXPECT_EQ(test, err, 0);
|
||||
|
||||
placement = kunit_kzalloc(test, sizeof(*placement), GFP_KERNEL);
|
||||
|
||||
@@ -302,7 +302,7 @@ static void ttm_sys_man_free_basic(struct kunit *test)
|
||||
res = kunit_kzalloc(test, sizeof(*res), GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_NULL(test, res);
|
||||
|
||||
ttm_resource_alloc(bo, place, &res);
|
||||
ttm_resource_alloc(bo, place, &res, NULL);
|
||||
|
||||
man = ttm_manager_type(priv->devs->ttm_dev, mem_type);
|
||||
man->func->free(man, res);
|
||||
|
||||
Reference in New Issue
Block a user