drm/amdgpu: group BOs by log2 of the size on the LRU v2
Subsystems (2)
PATCH 1/2 drm/amdgpu: group BOs by log2 of the size on the LRU v2
From: Christian König <[email protected]>
This allows us to have small BOs on the LRU before big ones.
v2: fix of by one and list corruption bug
Signed-off-by Christian König <[email protected]>
Reviewed-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 11 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 61 +++++++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +11 -0
@@ -391,6 +391,14 @@ unsigned amdgpu_fence_count_emitted(struct amdgpu_ring *ring);/* * TTM. */ + +#define AMDGPU_TTM_LRU_SIZE 20 + +struct amdgpu_mman_lru { +struct list_head *lru[TTM_NUM_MEM_TYPES ]; +struct list_head *swap_lru; +}; +struct amdgpu_mman {struct ttm_bo_global_ref bo_global_ref;struct drm_global_reference mem_global_ref;
@@ -408,6 +416,9 @@ struct amdgpu_mman {struct amdgpu_ring *buffer_funcs_ring;/* Scheduler entity for buffer moves */ struct amd_sched_entity entity; + +/* custom LRU management */ +struct amdgpu_mman_lru log2_size[AMDGPU_TTM_LRU_SIZE ]; }; int amdgpu_copy_buffer(struct amdgpu_ring *ring,
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +59 -2
83 lines not on this page · raw message
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 drm/amdgpu: remove sorting of CS BOs
From: Christian König <[email protected]>
Not needed any more.
Signed-off-by Christian König <[email protected]>
Reviewed-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 23 ----------------------- 1 file changed, 23 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -23
@@ -24,7 +24,6 @@* Authors: * Jerome Glisse <[email protected]> */ -#include <linux/list_sort.h> #include <linux/pagemap.h> #include <drm/drmP.h> #include <drm/amdgpu_drm.h>
@@ -527,16 +526,6 @@ static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)return 0 ; } -static int cmp_size_smaller_first (void *priv,struct list_head *a, -struct list_head *b) -{ - struct amdgpu_bo_list_entry *la = list_entry(a, struct amdgpu_bo_list_entry, tv.head); - struct amdgpu_bo_list_entry *lb = list_entry(b, struct amdgpu_bo_list_entry, tv.head); - -/* Sort A before B if A is smaller. */ -return (int )la->robj->tbo.num_pages - (int )lb->robj->tbo.num_pages; -} -/** * cs_parser_fini() - clean parser states * @parser: parser structure holding parsing context.
@@ -553,18 +542,6 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, boif (!error) {amdgpu_vm_move_pt_bos_in_lru (parser->adev, &fpriv->vm); -/* Sort the buffer list from the smallest to largest buffer, -* which affects the order of buffers in the LRU list. -* This assures that the smallest buffers are added first -* to the LRU list, so they are likely to be later evicted -* first, instead of large buffers whose eviction is more -* expensive. -* -* This slightly lowers the number of bytes moved by TTM -* per frame under memory pressure. -*/ -list_sort (NULL , &parser->validated, cmp_size_smaller_first); -ttm_eu_fence_buffer_objects (&parser->ticket, &parser->validated, parser->fence);
Signature · 6 lines
2.5.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/amdgpu: remove sorting of CS BOs
Quoted 3 lines · Christian König
From: Christian König <[email protected]>
Not needed any more.
Applied the series.
Alex
Quoted 56 lines
Signed-off-by Christian König <[email protected]>Reviewed-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 23 ----------------------- 1 file changed, 23 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-24@@ -24,7 +24,6 @@* Authors: * Jerome Glisse <[email protected]> */ -#include <linux/list_sort.h> #include <linux/pagemap.h> #include <drm/drmP.h> #include <drm/amdgpu_drm.h> @@ -527,16 +526,6 @@ static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)return 0 ; } -static int cmp_size_smaller_first (void *priv,struct list_head *a, -struct list_head *b) -{ - struct amdgpu_bo_list_entry *la = list_entry(a, struct amdgpu_bo_list_entry, tv.head); - struct amdgpu_bo_list_entry *lb = list_entry(b, struct amdgpu_bo_list_entry, tv.head); - -/* Sort A before B if A is smaller. */ -return (int )la->robj->tbo.num_pages - (int )lb->robj->tbo.num_pages; -} -/** * cs_parser_fini() - clean parser states * @parser: parser structure holding parsing context. @@ -553,18 +542,6 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, boif (!error) {amdgpu_vm_move_pt_bos_in_lru (parser->adev, &fpriv->vm); -/* Sort the buffer list from the smallest to largest buffer, -* which affects the order of buffers in the LRU list. -* This assures that the smallest buffers are added first -* to the LRU list, so they are likely to be later evicted -* first, instead of large buffers whose eviction is more -* expensive. -* -* This slightly lowers the number of bytes moved by TTM -* per frame under memory pressure. -*/ -list_sort (NULL , &parser->validated, cmp_size_smaller_first); -ttm_eu_fence_buffer_objects (&parser->ticket, &parser->validated, parser->fence); --
Quoted 2 lines
2.5.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel