[PATCH i-g-t] lib/igt_drm_fdinfo: Handle amdgpu memory stats

Tvrtko Ursulin tursulin at igalia.com
Fri May 3 12:37:31 UTC 2024


From: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>

Code so far only handles the clients using the common DRM helper.

Handle the amdgpu driver which uses a slightly different set of keys. More
specifically, outputs drm-memory-<region> instead of drm-total-<region>.

With this added gputop starts showing total memory usage for amdgpu.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
Cc: Alex Deucher <alexander.deucher at amd.com>
Cc: Christian König <christian.keonig at amd.com>
Cc: Rob Clark <robdclark at chromium.org>
Cc: Lucas De Marchi <lucas.demarchi at intel.com>
---
 lib/igt_drm_fdinfo.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c
index cab677df29a9..89992f1477ec 100644
--- a/lib/igt_drm_fdinfo.c
+++ b/lib/igt_drm_fdinfo.c
@@ -262,6 +262,10 @@ __igt_parse_drm_fdinfo(int dir, const char *fd, struct drm_client_fdinfo *info,
 			idx = parse_region(l, info, strlen("drm-total-"),
 					   region_map, region_entries, &val);
 			UPDATE_REGION(idx, total, val);
+		} else if (!strncmp(l, "drm-memory-", 11)) {
+			idx = parse_region(l, info, strlen("drm-memory-"),
+					   region_map, region_entries, &val);
+			UPDATE_REGION(idx, total, val);
 		} else if (!strncmp(l, "drm-shared-", 11)) {
 			idx = parse_region(l, info, strlen("drm-shared-"),
 					   region_map, region_entries, &val);
-- 
2.44.0



More information about the igt-dev mailing list