[PATCH i-g-t 12/12] RFC: gputop: Add support for ticks unit
Lucas De Marchi
lucas.demarchi at intel.com
Fri Apr 5 06:00:56 UTC 2024
Add support for "ticks" that take out the CPU time elapsed from account
and rather uses the GPU timestamp as recorded from fdinfo. The busyness
is calculated as, for each engine class:
u[i+1] - u[i]
pct = -----------------
Gt[i+1] - Gt[i]
where u[i] is the number of GPU ticks used by a client on an engine and
Gt[i] is the GPU timestamp in ticks. Main advantage over previous "ns"
unit type is that there's only one clock domain involved and it's
expected to work better with SR-IOV when each VF gets a certain quanta
of the GPU - that quanta should be reported as 100% GPU utilization,
which would never be achieved if the CPU clock domain was involved.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
lib/igt_drm_clients.c | 2 ++
lib/igt_drm_clients.h | 1 +
tools/gputop.c | 8 ++++++--
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/igt_drm_clients.c b/lib/igt_drm_clients.c
index da966769f..22c56b279 100644
--- a/lib/igt_drm_clients.c
+++ b/lib/igt_drm_clients.c
@@ -195,6 +195,7 @@ igt_drm_client_add(struct igt_drm_clients *clients,
c->val2 = calloc(c->engines->max_engine_id + 1, sizeof(*c->val2));
c->last = calloc(c->engines->max_engine_id + 1, sizeof(*c->last));
c->last2 = calloc(c->engines->max_engine_id + 1, sizeof(*c->last2));
+ c->unit = calloc(c->engines->max_engine_id + 1, sizeof(*c->unit));
assert(c->val && c->last);
/* Memory regions */
@@ -237,6 +238,7 @@ void igt_drm_client_free(struct igt_drm_client *c, bool clear)
free(c->val2);
free(c->last);
free(c->last2);
+ free(c->unit);
if (c->regions) {
for (i = 0; i <= c->regions->max_region_id; i++)
diff --git a/lib/igt_drm_clients.h b/lib/igt_drm_clients.h
index cfc53a344..9c2e96d1e 100644
--- a/lib/igt_drm_clients.h
+++ b/lib/igt_drm_clients.h
@@ -69,6 +69,7 @@ struct igt_drm_client {
unsigned long *val2; /* Array of engine busyness data2, relative to previous scan. */
uint64_t *last; /* Array of engine busyness data as parsed from fdinfo. */
uint64_t *last2; /* Array of engine busyness data2 as parsed from fdinfo. */
+ enum drm_client_engine_unit *unit; /* Array of unit used for engine busyness data. */
struct drm_client_meminfo *memory; /* Array of region memory utilisation as parsed from fdinfo. */
};
diff --git a/tools/gputop.c b/tools/gputop.c
index ea23e1de5..3649bf4d7 100644
--- a/tools/gputop.c
+++ b/tools/gputop.c
@@ -183,8 +183,12 @@ print_client(struct igt_drm_client *c, struct igt_drm_client **prevc,
if (!c->engines->capacity[i])
continue;
- pct = (double)c->val[i] / period_us / 1e3 * 100 /
- c->engines->capacity[i];
+ if (c->unit[i] == DRM_CLIENT_ENGINE_UNIT_NS)
+ pct = (double)c->val[i] / period_us / 1e3 * 100 /
+ c->engines->capacity[i];
+ else if (c->unit[i] == DRM_CLIENT_ENGINE_UNIT_TICKS)
+ pct = (double)(c->val2[i] * 100) / c->val[1] /
+ c->engines->capacity[i];
/*
* Guard against fluctuations between our scanning period and
--
2.44.0
More information about the igt-dev
mailing list