mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
drm/amdgpu: track bo memory stats at runtime
Before, every time fdinfo is queried we try to lock all the BOs in the VM and calculate memory usage from scratch. This works okay if the fdinfo is rarely read and the VMs don't have a ton of BOs. If either of these conditions is not true, we get a massive performance hit. In this new revision, we track the BOs as they change states. This way when the fdinfo is queried we only need to take the status lock and copy out the usage stats with minimal impact to the runtime performance. With this new approach however, we would no longer be able to track active buffers. Signed-off-by: Yunxiang Li <Yunxiang.Li@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20241219151411.1150-6-Yunxiang.Li@amd.com Signed-off-by: Christian König <christian.koenig@amd.com>
This commit is contained in:
committed by
Christian König
parent
a541a6e865
commit
74ef9527bd
@@ -35,6 +35,7 @@
|
||||
#include "amdgpu_sync.h"
|
||||
#include "amdgpu_ring.h"
|
||||
#include "amdgpu_ids.h"
|
||||
#include "amdgpu_ttm.h"
|
||||
|
||||
struct drm_exec;
|
||||
|
||||
@@ -202,9 +203,13 @@ struct amdgpu_vm_bo_base {
|
||||
/* protected by bo being reserved */
|
||||
struct amdgpu_vm_bo_base *next;
|
||||
|
||||
/* protected by spinlock */
|
||||
/* protected by vm status_lock */
|
||||
struct list_head vm_status;
|
||||
|
||||
/* if the bo is counted as shared in mem stats
|
||||
* protected by vm status_lock */
|
||||
bool shared;
|
||||
|
||||
/* protected by the BO being reserved */
|
||||
bool moved;
|
||||
};
|
||||
@@ -324,10 +329,7 @@ struct amdgpu_vm_fault_info {
|
||||
struct amdgpu_mem_stats {
|
||||
struct drm_memory_stats drm;
|
||||
|
||||
/* buffers that requested this placement */
|
||||
uint64_t requested;
|
||||
/* buffers that requested this placement
|
||||
* but are currently evicted */
|
||||
/* buffers that requested this placement but are currently evicted */
|
||||
uint64_t evicted;
|
||||
};
|
||||
|
||||
@@ -345,6 +347,9 @@ struct amdgpu_vm {
|
||||
/* Lock to protect vm_bo add/del/move on all lists of vm */
|
||||
spinlock_t status_lock;
|
||||
|
||||
/* Memory statistics for this vm, protected by status_lock */
|
||||
struct amdgpu_mem_stats stats[__AMDGPU_PL_NUM];
|
||||
|
||||
/* Per-VM and PT BOs who needs a validation */
|
||||
struct list_head evicted;
|
||||
|
||||
@@ -525,6 +530,11 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
|
||||
bool clear);
|
||||
bool amdgpu_vm_evictable(struct amdgpu_bo *bo);
|
||||
void amdgpu_vm_bo_invalidate(struct amdgpu_bo *bo, bool evicted);
|
||||
void amdgpu_vm_update_stats(struct amdgpu_vm_bo_base *base,
|
||||
struct ttm_resource *new_res, int sign);
|
||||
void amdgpu_vm_bo_update_shared(struct amdgpu_bo *bo);
|
||||
void amdgpu_vm_bo_move(struct amdgpu_bo *bo, struct ttm_resource *new_mem,
|
||||
bool evicted);
|
||||
uint64_t amdgpu_vm_map_gart(const dma_addr_t *pages_addr, uint64_t addr);
|
||||
struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm,
|
||||
struct amdgpu_bo *bo);
|
||||
@@ -575,8 +585,7 @@ void amdgpu_vm_set_task_info(struct amdgpu_vm *vm);
|
||||
void amdgpu_vm_move_to_lru_tail(struct amdgpu_device *adev,
|
||||
struct amdgpu_vm *vm);
|
||||
void amdgpu_vm_get_memory(struct amdgpu_vm *vm,
|
||||
struct amdgpu_mem_stats *stats,
|
||||
unsigned int size);
|
||||
struct amdgpu_mem_stats stats[__AMDGPU_PL_NUM]);
|
||||
|
||||
int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
|
||||
struct amdgpu_bo_vm *vmbo, bool immediate);
|
||||
|
||||
Reference in New Issue
Block a user