From: Rob Clark <robdclark@gmail.com>
To: igt-dev@lists.freedesktop.org
Cc: Rob Clark <robdclark@chromium.org>,
Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: [igt-dev] [PATCH igt 2/2] gputop: Add memory information
Date: Fri, 7 Apr 2023 14:56:25 -0700 [thread overview]
Message-ID: <20230407215625.1551410-3-robdclark@gmail.com> (raw)
In-Reply-To: <20230407215625.1551410-1-robdclark@gmail.com>
From: Rob Clark <robdclark@chromium.org>
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
lib/igt_drm_clients.c | 1 +
lib/igt_drm_clients.h | 3 +++
tools/gputop.c | 24 ++++++++++++++++++++++--
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/lib/igt_drm_clients.c b/lib/igt_drm_clients.c
index b3eda39c..9cd5cc5d 100644
--- a/lib/igt_drm_clients.c
+++ b/lib/igt_drm_clients.c
@@ -109,6 +109,7 @@ igt_drm_client_update(struct igt_drm_client *c, unsigned int pid, char *name,
c->last[i] = info->busy[i];
}
+ c->mem = info->mem;
c->samples++;
c->status = IGT_DRM_CLIENT_ALIVE;
}
diff --git a/lib/igt_drm_clients.h b/lib/igt_drm_clients.h
index df8022d4..1a631d20 100644
--- a/lib/igt_drm_clients.h
+++ b/lib/igt_drm_clients.h
@@ -8,6 +8,8 @@
#include <stdint.h>
+#include "lib/igt_drm_fdinfo.h"
+
/**
* SECTION:igt_drm_clients
* @short_description: Parsing driver exposed fdinfo to track DRM clients
@@ -56,6 +58,7 @@ struct igt_drm_client {
unsigned long last_runtime; /* Aggregate busyness on all engines since previous scan. */
unsigned long *val; /* Array of engine busyness data, relative to previous scan. */
uint64_t *last; /* Array of engine busyness data as parsed from fdinfo. */
+ struct drm_client_meminfo mem;
};
struct igt_drm_clients {
diff --git a/tools/gputop.c b/tools/gputop.c
index d259cac1..76677e7d 100644
--- a/tools/gputop.c
+++ b/tools/gputop.c
@@ -28,6 +28,7 @@
#include "igt_drm_clients.h"
#include "igt_drm_fdinfo.h"
+#include "drmtest.h"
static const char *bars[] = { " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" };
@@ -67,7 +68,7 @@ static int
print_client_header(struct igt_drm_client *c, int lines, int con_w, int con_h,
int *engine_w)
{
- const char *pidname = " PID NAME ";
+ const char *pidname = " PID MEM ACTIV NAME ";
int ret, len = strlen(pidname);
if (lines++ >= con_h || len >= con_w)
@@ -118,6 +119,21 @@ newheader(const struct igt_drm_client *c, const struct igt_drm_client *pc)
return !pc || c->drm_minor != pc->drm_minor;
}
+static void
+print_size(size_t sz)
+{
+ char units[] = {'B', 'K', 'M', 'G'};
+ unsigned u;
+
+ for (u = 0; u < ARRAY_SIZE(units) - 1; u++) {
+ if (sz < 1024)
+ break;
+ sz /= 1024;
+ }
+
+ printf("%4zd%c ", sz, units[u]);
+}
+
static int
print_client(struct igt_drm_client *c, struct igt_drm_client **prevc,
double t, int lines, int con_w, int con_h,
@@ -138,7 +154,11 @@ print_client(struct igt_drm_client *c, struct igt_drm_client **prevc,
*prevc = c;
- printf("%8u %17s ", c->pid, c->print_name);
+ printf("%8u ", c->pid);
+ print_size(c->mem.shared + c->mem.private);
+ print_size(c->mem.active);
+ printf("%17s ", c->print_name);
+
lines++;
for (i = 0; c->samples > 1 && i <= c->engines->max_engine_id; i++) {
--
2.39.2
next prev parent reply other threads:[~2023-04-07 21:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-07 21:56 [igt-dev] [PATCH igt 0/2] gputop memory information Rob Clark
2023-04-07 21:56 ` [igt-dev] [PATCH igt 1/2] lib/igt_drm_fdinfo: Parse memory usage Rob Clark
2023-04-13 15:18 ` Tvrtko Ursulin
2023-04-13 18:26 ` Rob Clark
2023-04-14 8:27 ` Tvrtko Ursulin
2023-04-07 21:56 ` Rob Clark [this message]
2023-04-13 15:27 ` [igt-dev] [PATCH igt 2/2] gputop: Add memory information Tvrtko Ursulin
2023-04-07 22:10 ` [igt-dev] ✗ Fi.CI.BUILD: failure for gputop " Patchwork
2023-05-22 16:58 ` [igt-dev] ✗ Fi.CI.BUILD: failure for gputop memory information (rev2) Patchwork
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=20230407215625.1551410-3-robdclark@gmail.com \
--to=robdclark@gmail.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=robdclark@chromium.org \
--cc=tvrtko.ursulin@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