[PATCH i-g-t v3 07/13] lib/igt_drm_fdinfo: Start tracking available engine keys
Lucas De Marchi
lucas.demarchi at intel.com
Sat May 4 06:46:37 UTC 2024
Start tracking what are the available keys related to engine utilization
that were parsed from fdinfo. This can be later used by application to
make decisions on which of them to use.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
lib/igt_drm_fdinfo.c | 7 ++++---
lib/igt_drm_fdinfo.h | 8 ++++++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c
index f0a30677c..79b72c54d 100644
--- a/lib/igt_drm_fdinfo.c
+++ b/lib/igt_drm_fdinfo.c
@@ -190,10 +190,11 @@ out:
} \
} while (0)
-#define UPDATE_ENGINE(idx, engine, val) \
+#define UPDATE_ENGINE(idx, engine, val, utilization_key) \
do { \
if (idx >= 0) { \
info->engine[idx] = val; \
+ info->utilization_mask |= utilization_key; \
if (!info->capacity[idx]) \
info->capacity[idx] = 1; \
if (!engines_found[idx]) { \
@@ -259,11 +260,11 @@ __igt_parse_drm_fdinfo(int dir, const char *fd, struct drm_client_fdinfo *info,
} else if (strstartswith(l, "drm-engine-", &keylen)) {
idx = parse_engine(l + keylen, info,
name_map, map_entries, &val);
- UPDATE_ENGINE(idx, busy, val);
+ UPDATE_ENGINE(idx, busy, val, DRM_FDINFO_UTILIZATION_ENGINE_TIME);
} else if (strstartswith(l, "drm-cycles-", &keylen)) {
idx = parse_engine(l + keylen, info,
name_map, map_entries, &val);
- UPDATE_ENGINE(idx, cycles, val);
+ UPDATE_ENGINE(idx, cycles, val, DRM_FDINFO_UTILIZATION_CYCLES);
} else if (strstartswith(l, "drm-total-", &keylen)) {
idx = parse_region(l + keylen, info,
region_map, region_entries, &val);
diff --git a/lib/igt_drm_fdinfo.h b/lib/igt_drm_fdinfo.h
index 17a47f94a..3f641d79d 100644
--- a/lib/igt_drm_fdinfo.h
+++ b/lib/igt_drm_fdinfo.h
@@ -41,6 +41,11 @@ struct drm_client_meminfo {
uint64_t active;
};
+enum drm_fdinfo_utilization {
+ DRM_FDINFO_UTILIZATION_ENGINE_TIME = 1U << 0,
+ DRM_FDINFO_UTILIZATION_CYCLES = 1U << 1,
+};
+
struct drm_client_fdinfo {
char driver[128];
char pdev[128];
@@ -51,6 +56,9 @@ struct drm_client_fdinfo {
unsigned int capacity[DRM_CLIENT_FDINFO_MAX_ENGINES];
char names[DRM_CLIENT_FDINFO_MAX_ENGINES][256];
+ /* mask of enum drm_fdinfo_utilization parsed from fdinfo */
+ unsigned int utilization_mask;
+
/* drm-engine-<engine> values */
uint64_t busy[DRM_CLIENT_FDINFO_MAX_ENGINES];
/* drm-cycles-<engine> values */
--
2.43.0
More information about the igt-dev
mailing list