From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Cc: Rob Clark <robdclark@chromium.org> Subject: [Intel-gfx] [PATCH i-g-t 3/3] gputop: Add memory information Date: Thu, 27 Jul 2023 10:20:25 +0100 [thread overview] Message-ID: <20230727092025.1895728-4-tvrtko.ursulin@linux.intel.com> (raw) In-Reply-To: <20230727092025.1895728-1-tvrtko.ursulin@linux.intel.com> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Show total and resident memory usage for clients which support it. For simplicity all memory regions are summed up and shown under a single heading. v2: * Use unsigned int and not just unsigned in print_size. (Kamil) Co-developed-by: Rob Clark <robdclark@chromium.org> Signed-off-by: Rob Clark <robdclark@chromium.org> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com> Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com> --- tools/gputop.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tools/gputop.c b/tools/gputop.c index 681f0a6bb748..ac106abea2ee 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[] = { " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" }; @@ -80,7 +81,11 @@ print_client_header(struct igt_drm_client *c, int lines, int con_w, int con_h, return lines; putchar('\n'); - len = printf("%*s ", c->clients->max_pid_len, "PID"); + if (c->regions->num_regions) + len = printf("%*s MEM RSS ", + c->clients->max_pid_len, "PID"); + else + len = printf("%*s ", c->clients->max_pid_len, "PID"); if (c->engines->num_engines) { unsigned int i; @@ -121,12 +126,28 @@ newheader(const struct igt_drm_client *c, const struct igt_drm_client *pc) return !pc || c->drm_minor != pc->drm_minor; } +static int +print_size(uint64_t sz) +{ + char units[] = {'B', 'K', 'M', 'G'}; + unsigned int u; + + for (u = 0; u < ARRAY_SIZE(units) - 1; u++) { + if (sz < 1024) + break; + sz /= 1024; + } + + return printf("%7"PRIu64"%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, unsigned int period_us, int *engine_w) { unsigned int i; + uint64_t sz; int len; /* Filter out idle clients. */ @@ -143,6 +164,17 @@ print_client(struct igt_drm_client *c, struct igt_drm_client **prevc, *prevc = c; len = printf("%*s ", c->clients->max_pid_len, c->pid_str); + + if (c->regions->num_regions) { + for (sz = 0, i = 0; i < c->regions->max_region_id; i++) + sz += c->memory[i].total; + len += print_size(sz); + + for (sz = 0, i = 0; i < c->regions->max_region_id; i++) + sz += c->memory[i].resident; + len += print_size(sz); + } + lines++; for (i = 0; c->samples > 1 && i <= c->engines->max_engine_id; i++) { -- 2.39.2
WARNING: multiple messages have this Message-ID (diff)
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Cc: Rob Clark <robdclark@chromium.org>, Tvrtko Ursulin <tvrtko.ursulin@intel.com> Subject: [igt-dev] [PATCH i-g-t 3/3] gputop: Add memory information Date: Thu, 27 Jul 2023 10:20:25 +0100 [thread overview] Message-ID: <20230727092025.1895728-4-tvrtko.ursulin@linux.intel.com> (raw) In-Reply-To: <20230727092025.1895728-1-tvrtko.ursulin@linux.intel.com> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Show total and resident memory usage for clients which support it. For simplicity all memory regions are summed up and shown under a single heading. v2: * Use unsigned int and not just unsigned in print_size. (Kamil) Co-developed-by: Rob Clark <robdclark@chromium.org> Signed-off-by: Rob Clark <robdclark@chromium.org> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com> Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com> --- tools/gputop.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tools/gputop.c b/tools/gputop.c index 681f0a6bb748..ac106abea2ee 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[] = { " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" }; @@ -80,7 +81,11 @@ print_client_header(struct igt_drm_client *c, int lines, int con_w, int con_h, return lines; putchar('\n'); - len = printf("%*s ", c->clients->max_pid_len, "PID"); + if (c->regions->num_regions) + len = printf("%*s MEM RSS ", + c->clients->max_pid_len, "PID"); + else + len = printf("%*s ", c->clients->max_pid_len, "PID"); if (c->engines->num_engines) { unsigned int i; @@ -121,12 +126,28 @@ newheader(const struct igt_drm_client *c, const struct igt_drm_client *pc) return !pc || c->drm_minor != pc->drm_minor; } +static int +print_size(uint64_t sz) +{ + char units[] = {'B', 'K', 'M', 'G'}; + unsigned int u; + + for (u = 0; u < ARRAY_SIZE(units) - 1; u++) { + if (sz < 1024) + break; + sz /= 1024; + } + + return printf("%7"PRIu64"%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, unsigned int period_us, int *engine_w) { unsigned int i; + uint64_t sz; int len; /* Filter out idle clients. */ @@ -143,6 +164,17 @@ print_client(struct igt_drm_client *c, struct igt_drm_client **prevc, *prevc = c; len = printf("%*s ", c->clients->max_pid_len, c->pid_str); + + if (c->regions->num_regions) { + for (sz = 0, i = 0; i < c->regions->max_region_id; i++) + sz += c->memory[i].total; + len += print_size(sz); + + for (sz = 0, i = 0; i < c->regions->max_region_id; i++) + sz += c->memory[i].resident; + len += print_size(sz); + } + lines++; for (i = 0; c->samples > 1 && i <= c->engines->max_engine_id; i++) { -- 2.39.2
next prev parent reply other threads:[~2023-07-27 9:20 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-27 9:20 [Intel-gfx] [PATCH i-g-t 0/3] gputop memory usage Tvrtko Ursulin 2023-07-27 9:20 ` [igt-dev] " Tvrtko Ursulin 2023-07-27 9:20 ` [Intel-gfx] [PATCH i-g-t 1/3] lib/igt_drm_fdinfo: Parse " Tvrtko Ursulin 2023-07-27 9:20 ` [igt-dev] " Tvrtko Ursulin 2023-07-27 14:46 ` [Intel-gfx] " Kamil Konieczny 2023-07-27 14:46 ` [igt-dev] " Kamil Konieczny 2023-07-27 9:20 ` [Intel-gfx] [PATCH i-g-t 2/3] lib/igt_drm_clients: Store memory info in the client Tvrtko Ursulin 2023-07-27 9:20 ` [igt-dev] " Tvrtko Ursulin 2023-07-27 14:10 ` [Intel-gfx] " Kamil Konieczny 2023-07-27 14:10 ` [igt-dev] " Kamil Konieczny 2023-07-27 15:17 ` [Intel-gfx] " Tvrtko Ursulin 2023-07-27 15:17 ` [igt-dev] " Tvrtko Ursulin 2023-07-28 14:46 ` [Intel-gfx] " Tvrtko Ursulin 2023-07-28 14:46 ` [igt-dev] " Tvrtko Ursulin 2023-08-07 14:40 ` [Intel-gfx] " Kamil Konieczny 2023-08-07 14:40 ` [igt-dev] " Kamil Konieczny 2023-07-27 9:20 ` Tvrtko Ursulin [this message] 2023-07-27 9:20 ` [igt-dev] [PATCH i-g-t 3/3] gputop: Add memory information Tvrtko Ursulin 2023-07-27 10:51 ` [igt-dev] ○ CI.xeBAT: info for gputop memory usage (rev2) Patchwork 2023-07-27 11:00 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork 2023-07-27 12:31 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork -- strict thread matches above, loose matches on Subject: below -- 2023-07-05 16:31 [Intel-gfx] [PATCH i-g-t 0/3] gputop memory usage Tvrtko Ursulin 2023-07-05 16:31 ` [Intel-gfx] [PATCH i-g-t 3/3] gputop: Add memory information Tvrtko Ursulin 2023-07-26 17:32 ` Kamil Konieczny 2023-07-27 9:09 ` Tvrtko Ursulin
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=20230727092025.1895728-4-tvrtko.ursulin@linux.intel.com \ --to=tvrtko.ursulin@linux.intel.com \ --cc=Intel-gfx@lists.freedesktop.org \ --cc=igt-dev@lists.freedesktop.org \ --cc=robdclark@chromium.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.