drm/amdgpu: Use drm_print_memory_stats helper from fdinfo
authorTvrtko Ursulin <tvrtko.ursulin@igalia.com>
Mon, 20 May 2024 11:13:38 +0000 (12:13 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 8 Oct 2024 13:43:25 +0000 (09:43 -0400)
commit04bdba46542c953e26f3ba4ac84dd65fbb4e7382
tree46c1ba2412460f412b25239a87b65b26607498ed
parentfc282e9e8651842db8bd48d449566f4d3b82da9c
drm/amdgpu: Use drm_print_memory_stats helper from fdinfo

Convert fdinfo memory stats to use the common drm_print_memory_stats
helper.

This achieves alignment with the common keys as documented in
drm-usage-stats.rst, adding specifically drm-total- key the driver was
missing until now.

Additionally I made the code stop skipping total size for objects which
currently do not have a backing store, and I added resident, active and
purgeable reporting.

Legacy keys have been preserved, with the outlook of only potentially
removing only the drm-memory- when the time gets right.

The example output now looks like this:

 pos: 0
 flags: 02100002
 mnt_id: 24
 ino: 1239
 drm-driver: amdgpu
 drm-client-id: 4
 drm-pdev: 0000:04:00.0
 pasid: 32771
 drm-total-cpu: 0
 drm-shared-cpu: 0
 drm-active-cpu: 0
 drm-resident-cpu: 0
 drm-purgeable-cpu: 0
 drm-total-gtt: 2392 KiB
 drm-shared-gtt: 0
 drm-active-gtt: 0
 drm-resident-gtt: 2392 KiB
 drm-purgeable-gtt: 0
 drm-total-vram: 44564 KiB
 drm-shared-vram: 31952 KiB
 drm-active-vram: 0
 drm-resident-vram: 44564 KiB
 drm-purgeable-vram: 0
 drm-memory-vram: 44564 KiB
 drm-memory-gtt:  2392 KiB
 drm-memory-cpu:  0 KiB
 amd-memory-visible-vram: 44564 KiB
 amd-evicted-vram: 0 KiB
 amd-evicted-visible-vram: 0 KiB
 amd-requested-vram: 44564 KiB
 amd-requested-visible-vram: 11952 KiB
 amd-requested-gtt: 2392 KiB
 drm-engine-compute: 46464671 ns

v2:
 * Track purgeable via AMDGPU_GEM_CREATE_DISCARDABLE.

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Rob Clark <robdclark@chromium.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h