From: Lucas De Marchi <lucas.demarchi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH i-g-t v3 09/13] lib/igt_drm_clients: Move engine fields to substruct
Date: Fri, 3 May 2024 23:46:39 -0700 [thread overview]
Message-ID: <20240504064643.25863-10-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20240504064643.25863-1-lucas.demarchi@intel.com>
Instead of keep adding arrays, move all the arrays indexed by engine to
a substruct.
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
lib/igt_drm_clients.c | 20 +++++++++-----------
lib/igt_drm_clients.h | 12 ++++++++----
tools/gputop.c | 2 +-
tools/intel_gpu_top.c | 14 +++++++-------
4 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/lib/igt_drm_clients.c b/lib/igt_drm_clients.c
index 3f4265015..91d71a7bd 100644
--- a/lib/igt_drm_clients.c
+++ b/lib/igt_drm_clients.c
@@ -109,13 +109,14 @@ igt_drm_client_update(struct igt_drm_client *c, unsigned int pid, char *name,
for (i = 0; i <= c->engines->max_engine_id; i++) {
assert(i < ARRAY_SIZE(info->engine_time));
- if (info->engine_time[i] < c->last_engine_time[i])
+ if (info->engine_time[i] < c->utilization[i].last_engine_time)
continue; /* It will catch up soon. */
c->total_engine_time += info->engine_time[i];
- c->delta_engine_time[i] = info->engine_time[i] - c->last_engine_time[i];
- c->agg_delta_engine_time += c->delta_engine_time[i];
- c->last_engine_time[i] = info->engine_time[i];
+ c->utilization[i].delta_engine_time =
+ info->engine_time[i] - c->utilization[i].last_engine_time;
+ c->agg_delta_engine_time += c->utilization[i].delta_engine_time;
+ c->utilization[i].last_engine_time = info->engine_time[i];
}
/* Memory regions */
@@ -183,11 +184,9 @@ igt_drm_client_add(struct igt_drm_clients *clients,
c->engines->max_engine_id = i;
}
- c->delta_engine_time = calloc(c->engines->max_engine_id + 1,
- sizeof(*c->delta_engine_time));
- c->last_engine_time = calloc(c->engines->max_engine_id + 1,
- sizeof(*c->last_engine_time));
- assert(c->delta_engine_time && c->last_engine_time);
+ c->utilization = calloc(c->engines->max_engine_id + 1,
+ sizeof(*c->utilization));
+ assert(c->utilization);
/* Memory regions */
c->regions = calloc(1, sizeof(*c->regions));
@@ -225,8 +224,7 @@ void igt_drm_client_free(struct igt_drm_client *c, bool clear)
}
free(c->engines);
- free(c->delta_engine_time);
- free(c->last_engine_time);
+ free(c->utilization);
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 f2ff13182..d44daa6dc 100644
--- a/lib/igt_drm_clients.h
+++ b/lib/igt_drm_clients.h
@@ -63,10 +63,14 @@ struct igt_drm_client {
char name[24]; /* Process name of the owning PID. */
char print_name[24]; /* Name without any non-printable characters. */
unsigned int samples; /* Count of times scanning updated this client. */
- unsigned long total_engine_time; /* Aggregate of @agg_delta_engine_time, i.e. engine time on all engines since client start. */
- unsigned long agg_delta_engine_time; /* Aggregate of @delta_engine_time, i.e. engine time on all engines since previous scan. */
- unsigned long *delta_engine_time; /* Array of engine time data, relative to previous scan. */
- uint64_t *last_engine_time; /* Array of engine time data as parsed from fdinfo. */
+
+ unsigned long total_engine_time; /* Aggregate of @utilization.agg_delta_engine_time, i.e. engine time on all engines since client start. */
+ unsigned long agg_delta_engine_time; /* Aggregate of @utilization.delta_engine_time, i.e. engine time on all engines since previous scan. */
+ struct igt_drm_client_utilization {
+ unsigned long delta_engine_time; /* Engine time data, relative to previous scan. */
+ uint64_t last_engine_time; /* Engine time data as parsed from fdinfo. */
+ } *utilization; /* Array of engine utilization */
+
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 80bc94be4..aa88a8021 100644
--- a/tools/gputop.c
+++ b/tools/gputop.c
@@ -208,7 +208,7 @@ print_client(struct igt_drm_client *c, struct igt_drm_client **prevc,
if (!c->engines->capacity[i])
continue;
- pct = (double)c->delta_engine_time[i] / period_us / 1e3 * 100 /
+ pct = (double)c->utilization[i].delta_engine_time / period_us / 1e3 * 100 /
c->engines->capacity[i];
/*
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 35122493c..9b65ae4eb 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -893,9 +893,9 @@ static struct igt_drm_clients *display_clients(struct igt_drm_clients *clients)
strcpy(ac->pid_str, c->pid_str);
strcpy(ac->print_name, c->print_name);
ac->engines = c->engines;
- ac->delta_engine_time = calloc(c->engines->max_engine_id + 1,
- sizeof(ac->delta_engine_time[0]));
- assert(ac->delta_engine_time);
+ ac->utilization = calloc(c->engines->max_engine_id + 1,
+ sizeof(*ac->utilization));
+ assert(ac->utilization);
ac->regions = c->regions;
ac->memory = calloc(c->regions->max_region_id + 1,
sizeof(ac->memory[0]));
@@ -912,7 +912,7 @@ static struct igt_drm_clients *display_clients(struct igt_drm_clients *clients)
ac->agg_delta_engine_time += c->agg_delta_engine_time;
for (i = 0; i <= c->engines->max_engine_id; i++)
- ac->delta_engine_time[i] += c->delta_engine_time[i];
+ ac->utilization[i].delta_engine_time += c->utilization[i].delta_engine_time;
for (i = 0; i <= c->regions->max_region_id; i++) {
ac->memory[i].total += c->memory[i].total;
@@ -946,7 +946,7 @@ static void free_display_clients(struct igt_drm_clients *clients)
* or borrowed fields which we don't want the library to try and free.
*/
igt_for_each_drm_client(clients, c, tmp) {
- free(c->delta_engine_time);
+ free(c->utilization);
free(c->memory);
}
@@ -2161,7 +2161,7 @@ print_client(struct igt_drm_client *c, struct engines *engines, double t, int li
continue;
}
- pct = (double)c->delta_engine_time[i] / period_us / 1e3 * 100;
+ pct = (double)c->utilization[i].delta_engine_time / period_us / 1e3 * 100;
/*
* Guard against possible time-drift between sampling
@@ -2235,7 +2235,7 @@ print_client(struct igt_drm_client *c, struct engines *engines, double t, int li
iclients->classes.names[i]);
pops->open_struct(buf);
- pct = (double)c->delta_engine_time[i] / period_us / 1e3 * 100;
+ pct = (double)c->utilization[i].delta_engine_time / period_us / 1e3 * 100;
snprintf(buf, sizeof(buf), "%f", pct);
__json_add_member("busy", buf);
--
2.43.0
next prev parent reply other threads:[~2024-05-04 6:46 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-04 6:46 [PATCH i-g-t v3 00/12] gputop: Add support for xe Lucas De Marchi
2024-05-04 6:46 ` [PATCH i-g-t v3 01/13] lib/igt_drm_fdinfo: Extract ignore_space() Lucas De Marchi
2024-05-06 20:21 ` Umesh Nerlige Ramappa
2024-05-04 6:46 ` [PATCH i-g-t v3 02/13] lib/igt_drm_fdinfo: Allow any number of spaces before unit Lucas De Marchi
2024-05-06 20:28 ` Umesh Nerlige Ramappa
2024-05-06 20:32 ` Umesh Nerlige Ramappa
2024-05-06 20:38 ` Lucas De Marchi
2024-05-04 6:46 ` [PATCH i-g-t v3 03/13] fixup! " Lucas De Marchi
2024-05-06 20:33 ` Umesh Nerlige Ramappa
2024-05-04 6:46 ` [PATCH i-g-t v3 04/13] lib/igt_drm_fdinfo: Stop passing key twice Lucas De Marchi
2024-05-04 6:46 ` [PATCH i-g-t v3 05/13] lib/igt_drm_fdinfo: Remove prefix arg from parse functions Lucas De Marchi
2024-05-04 6:46 ` [PATCH i-g-t v3 06/13] lib/igt_drm_fdinfo: Parse drm-cycles Lucas De Marchi
2024-05-07 1:11 ` Umesh Nerlige Ramappa
2024-05-04 6:46 ` [PATCH i-g-t v3 07/13] lib/igt_drm_fdinfo: Start tracking available engine keys Lucas De Marchi
2024-05-07 1:14 ` Umesh Nerlige Ramappa
2024-05-04 6:46 ` [PATCH i-g-t v3 08/13] treewide: Rename engine busyness variables Lucas De Marchi
2024-05-08 18:45 ` Umesh Nerlige Ramappa
2024-05-21 13:47 ` Lucas De Marchi
2024-05-04 6:46 ` Lucas De Marchi [this message]
2024-05-08 18:45 ` [PATCH i-g-t v3 09/13] lib/igt_drm_clients: Move engine fields to substruct Umesh Nerlige Ramappa
2024-05-04 6:46 ` [PATCH i-g-t v3 10/13] lib/igt_drm_clients: Record drm-cycles Lucas De Marchi
2024-05-08 18:48 ` Umesh Nerlige Ramappa
2024-05-04 6:46 ` [PATCH i-g-t v3 11/13] lib/igt_drm_fdinfo: Parse drm-total-cycles Lucas De Marchi
2024-05-08 18:49 ` Umesh Nerlige Ramappa
2024-05-04 6:46 ` [PATCH i-g-t v3 12/13] lib/igt_drm_clients: Record total cycles Lucas De Marchi
2024-05-08 19:01 ` Umesh Nerlige Ramappa
2024-05-08 19:07 ` Umesh Nerlige Ramappa
2024-05-04 6:46 ` [PATCH i-g-t v3 13/13] gputop: Add support to drm-cycles/drm-total-cycles Lucas De Marchi
2024-05-08 19:11 ` Umesh Nerlige Ramappa
2024-05-04 7:31 ` ✓ Fi.CI.BAT: success for gputop: Add support for xe (rev4) Patchwork
2024-05-04 7:36 ` ✓ CI.xeBAT: " Patchwork
2024-05-04 8:33 ` ✗ CI.xeFULL: failure " Patchwork
2024-05-04 12:50 ` ✗ Fi.CI.IGT: " Patchwork
2024-05-06 10:37 ` [PATCH i-g-t v3 00/12] gputop: Add support for xe Tvrtko Ursulin
2024-05-06 20:40 ` Lucas De Marchi
2024-05-08 16:25 ` (subset) " Lucas De Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240504064643.25863-10-lucas.demarchi@intel.com \
--to=lucas.demarchi@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=tursulin@ursulin.net \
--cc=umesh.nerlige.ramappa@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox