drm/ttm: Add optional support for two-ended allocation
Subsystems (3)
RFC 1/1 drm/ttm: Add optional support for two-ended allocation
Allocating small bos from one end and large ones from the other helps improve the quality of fragmentation.
I have measured a suitable threshold to reduce eviction by up to 20%,
and to cause no harm in normal cases that fit VRAM fully (PTS gaming suite). In some cases, even the VRAM-fitting cases improved slightly (openarena, urban terror).
This depends on "drm: Optionally create mm blocks from top-to-bottom" by Chris Wilson, and so is just RFC for now.
--- drivers/gpu/drm/ttm/ttm_bo.c | 4 +++- drivers/gpu/drm/ttm/ttm_bo_manager.c | 12 +++++++++--- include/drm/ttm/ttm_bo_driver.h | 5 ++++- 3 files changed, 16 insertions(+), 5 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +3 -1
@@ -1450,7 +1450,8 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,struct ttm_bo_global *glob, struct ttm_bo_driver *driver, uint64_t file_page_offset, - bool need_dma32) + bool need_dma32, + uint32_t alloc_threshold) { int ret = -EINVAL;
@@ -1473,6 +1474,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, bdev->dev_mapping =NULL ; bdev->glob = glob; bdev->need_dma32 = need_dma32; + bdev->alloc_threshold = alloc_threshold; bdev->val_seq =0 ;spin_lock_init (&bdev->fence_lock);mutex_lock (&glob->device_list_mutex);
drivers/gpu/drm/ttm/ttm_bo_manager.c +9 -3
@@ -55,6 +55,7 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;struct drm_mm *mm = &rman->mm;struct drm_mm_node *node =NULL ; +enum drm_mm_allocator_flags aflags =DRM_MM_CREATE_DEFAULT ;unsigned long lpfn;int ret;
@@ -66,11 +67,16 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,if (!node)return -ENOMEM ; +if (man->bdev->alloc_threshold && + man->bdev->alloc_threshold < (mem->num_pages *PAGE_SIZE )) + aflags =DRM_MM_CREATE_TOP ; +spin_lock (&rman->lock); - ret =drm_mm_insert_node_in_range (mm, node, mem->num_pages, - mem->page_alignment, + ret =drm_mm_insert_node_in_range_generic (mm, node, mem->num_pages, + mem->page_alignment,0 , placement->fpfn, lpfn, -DRM_MM_SEARCH_BEST ); +DRM_MM_SEARCH_BEST , + aflags);spin_unlock (&rman->lock);if (unlikely (ret)) {
include/drm/ttm/ttm_bo_driver.h +4 -1
@@ -565,6 +565,7 @@ struct ttm_bo_device {struct delayed_work wq;bool need_dma32; +uint32_t alloc_threshold; };/**
@@ -758,7 +759,9 @@ extern int ttm_bo_device_release(struct ttm_bo_device *bdev);extern int ttm_bo_device_init (struct ttm_bo_device *bdev,struct ttm_bo_global *glob,struct ttm_bo_driver *driver, -uint64_t file_page_offset,bool need_dma32); +uint64_t file_page_offset, +bool need_dma32, +uint32_t alloc_threshold);/** * ttm_bo_unmap_virtual
Signature · 1 line
1.8.3.1