diff -Nru intel-gpu-tools-1.28/debian/changelog intel-gpu-tools-1.28/debian/changelog --- intel-gpu-tools-1.28/debian/changelog 2024-04-03 11:05:11.000000000 +0000 +++ intel-gpu-tools-1.28/debian/changelog 2024-04-15 08:51:29.000000000 +0000 @@ -1,3 +1,9 @@ +intel-gpu-tools (1.28-1ubuntu2) noble; urgency=medium + + * Fix various intel_gpu_top UI layout issues (LP: #1949314) + + -- Hector Cao Mon, 15 Apr 2024 10:51:29 +0200 + intel-gpu-tools (1.28-1ubuntu1) noble; urgency=medium * d/p : add support for new DG2/Alchemist IDs (LP: #2049714) diff -Nru intel-gpu-tools-1.28/debian/patches/series intel-gpu-tools-1.28/debian/patches/series --- intel-gpu-tools-1.28/debian/patches/series 2024-04-03 10:58:58.000000000 +0000 +++ intel-gpu-tools-1.28/debian/patches/series 2024-04-15 08:51:29.000000000 +0000 @@ -1 +1,5 @@ ubuntu/0001-Add-support-for-new-DG2-Alchemist-models.patch +ubuntu/0001-tools-intel_gpu_top-Fix-clients-header-width-when-no.patch +ubuntu/0002-tools-intel_gpu_top-Fix-client-layout-on-first-sampl.patch +ubuntu/0003-tools-intel_gpu_top-Optimise-interactive-display-a-b.patch +ubuntu/0004-tools-intel_gpu_top-Handle-narrow-terminals-more-gra.patch diff -Nru intel-gpu-tools-1.28/debian/patches/ubuntu/0001-tools-intel_gpu_top-Fix-clients-header-width-when-no.patch intel-gpu-tools-1.28/debian/patches/ubuntu/0001-tools-intel_gpu_top-Fix-clients-header-width-when-no.patch --- intel-gpu-tools-1.28/debian/patches/ubuntu/0001-tools-intel_gpu_top-Fix-clients-header-width-when-no.patch 1970-01-01 00:00:00.000000000 +0000 +++ intel-gpu-tools-1.28/debian/patches/ubuntu/0001-tools-intel_gpu_top-Fix-clients-header-width-when-no.patch 2024-04-15 08:51:29.000000000 +0000 @@ -0,0 +1,43 @@ +From d5ba26bd5df9f9b4e386b823fd7296ce33fedb56 Mon Sep 17 00:00:00 2001 +From: Tvrtko Ursulin +Date: Fri, 22 Sep 2023 10:41:44 +0100 +Subject: [PATCH] tools/intel_gpu_top: Fix clients header width when no clients + +Recent refactoring broke the clients header in cases when there are no +clients displayed. To fix it we need to account the width of the "NAME" +label. + +Signed-off-by: Tvrtko Ursulin +Reviewed-by: Kamil Konieczny +--- + tools/intel_gpu_top.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c +index 10601e66b..60fe06917 100644 +--- a/tools/intel_gpu_top.c ++++ b/tools/intel_gpu_top.c +@@ -1967,6 +1967,8 @@ print_clients_header(struct igt_drm_clients *clients, int lines, + int con_w, int con_h, int *class_w) + { + struct intel_clients *iclients = clients->private_data; ++ const int max_name_len = clients->max_name_len < 4 ? ++ 4 : clients->max_name_len; /* At least "NAME" */ + + if (output_mode == INTERACTIVE) { + unsigned int num_active = 0; +@@ -1990,9 +1992,8 @@ print_clients_header(struct igt_drm_clients *clients, int lines, + num_active++; + } + +- *class_w = width = +- (con_w - len - clients->max_name_len - 1) / +- num_active; ++ *class_w = width = (con_w - len - max_name_len - 1) / ++ num_active; + + for (i = 0; i <= iclients->classes.max_engine_id; i++) { + const char *name = iclients->classes.names[i]; +-- +2.39.2 + diff -Nru intel-gpu-tools-1.28/debian/patches/ubuntu/0002-tools-intel_gpu_top-Fix-client-layout-on-first-sampl.patch intel-gpu-tools-1.28/debian/patches/ubuntu/0002-tools-intel_gpu_top-Fix-client-layout-on-first-sampl.patch --- intel-gpu-tools-1.28/debian/patches/ubuntu/0002-tools-intel_gpu_top-Fix-client-layout-on-first-sampl.patch 1970-01-01 00:00:00.000000000 +0000 +++ intel-gpu-tools-1.28/debian/patches/ubuntu/0002-tools-intel_gpu_top-Fix-client-layout-on-first-sampl.patch 2024-04-15 08:51:29.000000000 +0000 @@ -0,0 +1,67 @@ +From a8ae1bd4859ff9503928b0ee2d2bfea194187d7e Mon Sep 17 00:00:00 2001 +From: Tvrtko Ursulin +Date: Fri, 22 Sep 2023 10:53:11 +0100 +Subject: [PATCH] tools/intel_gpu_top: Fix client layout on first sample period + +When I moved the client name to be last, I did not account for the fact +current code skips showing engine utilisation until at least two sampling +periods have passed. Consequence of this is that client name gets printed +as the second field and not under the "NAME" column header. + +Fix it by emitting spaces instead of engine utilisation until two samples +have been collected. + +v2: + * Fix n_spaces return type to signed. + +Signed-off-by: Tvrtko Ursulin +Reviewed-by: Kamil Konieczny +--- + tools/intel_gpu_top.c | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c +index 60fe06917..b6d1014f0 100644 +--- a/tools/intel_gpu_top.c ++++ b/tools/intel_gpu_top.c +@@ -928,12 +928,14 @@ static void free_display_clients(struct igt_drm_clients *clients) + + static const char *bars[] = { " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" }; + +-static void n_spaces(const unsigned int n) ++static int n_spaces(const int n) + { +- unsigned int i; ++ int i; + + for (i = 0; i < n; i++) + putchar(' '); ++ ++ return n; + } + + static void +@@ -2043,14 +2045,17 @@ print_client(struct igt_drm_client *c, struct engines *engines, double t, int li + + len = printf("%*s ", clients->max_pid_len, c->pid_str); + +- for (i = 0; +- c->samples > 1 && i <= iclients->classes.max_engine_id; +- i++) { ++ for (i = 0; i <= iclients->classes.max_engine_id; i++) { + double pct, max; + + if (!iclients->classes.capacity[i]) + continue; + ++ if (c->samples < 2) { ++ len += n_spaces(*class_w); ++ continue; ++ } ++ + pct = (double)c->val[i] / period_us / 1e3 * 100; + + /* +-- +2.39.2 + diff -Nru intel-gpu-tools-1.28/debian/patches/ubuntu/0003-tools-intel_gpu_top-Optimise-interactive-display-a-b.patch intel-gpu-tools-1.28/debian/patches/ubuntu/0003-tools-intel_gpu_top-Optimise-interactive-display-a-b.patch --- intel-gpu-tools-1.28/debian/patches/ubuntu/0003-tools-intel_gpu_top-Optimise-interactive-display-a-b.patch 1970-01-01 00:00:00.000000000 +0000 +++ intel-gpu-tools-1.28/debian/patches/ubuntu/0003-tools-intel_gpu_top-Optimise-interactive-display-a-b.patch 2024-04-15 08:51:29.000000000 +0000 @@ -0,0 +1,83 @@ +From 4f835f616fa55b2e2c961221724cd38e5473d7b0 Mon Sep 17 00:00:00 2001 +From: Tvrtko Ursulin +Date: Fri, 22 Sep 2023 11:10:52 +0100 +Subject: [PATCH] tools/intel_gpu_top: Optimise interactive display a bit + +Padding the percentage bars and table columns with spaces happens quite a +lot so lets do better than putchar at a time. Have a table of visually +empty strings and build the required length out of those chunks. + +While at it, also move the percentage bar table into its function scope. + +v2: + * Fix checkpatch and use ARRAY_SIZE. (Kamil) + +Signed-off-by: Tvrtko Ursulin +Cc: Kamil Konieczny +Reviewed-by: Kamil Konieczny +--- + tools/intel_gpu_top.c | 38 +++++++++++++++++++++++++++++++++----- + 1 file changed, 33 insertions(+), 5 deletions(-) + +diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c +index b6d1014f0..006879c4a 100644 +--- a/tools/intel_gpu_top.c ++++ b/tools/intel_gpu_top.c +@@ -926,14 +926,39 @@ static void free_display_clients(struct igt_drm_clients *clients) + free(clients); + } + +-static const char *bars[] = { " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" }; +- + static int n_spaces(const int n) + { +- int i; ++ static const char *spaces[] = { ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ " ", ++ }; ++ int i, r = n; + +- for (i = 0; i < n; i++) +- putchar(' '); ++ while (r) { ++ if (r > ARRAY_SIZE(spaces)) ++ i = ARRAY_SIZE(spaces) - 1; ++ else ++ i = r - 1; ++ fputs(spaces[i], stdout); ++ r -= i + 1; ++ } + + return n; + } +@@ -941,6 +966,9 @@ static int n_spaces(const int n) + static void + print_percentage_bar(double percent, double max, int max_len, bool numeric) + { ++ static const char *bars[] = { ++ " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" ++ }; + int bar_len, i, len = max_len - 2; + const int w = 8; + +-- +2.39.2 + diff -Nru intel-gpu-tools-1.28/debian/patches/ubuntu/0004-tools-intel_gpu_top-Handle-narrow-terminals-more-gra.patch intel-gpu-tools-1.28/debian/patches/ubuntu/0004-tools-intel_gpu_top-Handle-narrow-terminals-more-gra.patch --- intel-gpu-tools-1.28/debian/patches/ubuntu/0004-tools-intel_gpu_top-Handle-narrow-terminals-more-gra.patch 1970-01-01 00:00:00.000000000 +0000 +++ intel-gpu-tools-1.28/debian/patches/ubuntu/0004-tools-intel_gpu_top-Handle-narrow-terminals-more-gra.patch 2024-04-15 08:51:29.000000000 +0000 @@ -0,0 +1,53 @@ +From 9e4079c622d43dee45ddac00b2d6b06d6bdb327b Mon Sep 17 00:00:00 2001 +From: Tvrtko Ursulin +Date: Tue, 10 Oct 2023 12:01:07 +0100 +Subject: [PATCH] tools/intel_gpu_top: Handle narrow terminals more gracefully + +Instead of asserting just skip trying to print columns when terminal is +too narrow. + +At the same time fix some type confusion to fix calculations going huge. + +Signed-off-by: Tvrtko Ursulin +Closes: https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/issues/143 +Reviewed-by: Kamil Konieczny +--- + tools/intel_gpu_top.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c +index 006879c4a..00506c63d 100644 +--- a/tools/intel_gpu_top.c ++++ b/tools/intel_gpu_top.c +@@ -972,7 +972,8 @@ print_percentage_bar(double percent, double max, int max_len, bool numeric) + int bar_len, i, len = max_len - 2; + const int w = 8; + +- assert(max_len > 0); ++ if (len < 2) /* For edge lines '|' */ ++ return; + + bar_len = ceil(w * percent * len / max); + if (bar_len > w * len) +@@ -986,6 +987,8 @@ print_percentage_bar(double percent, double max, int max_len, bool numeric) + printf("%s", bars[i]); + + len -= (bar_len + (w - 1)) / w; ++ if (len < 1) ++ return; + n_spaces(len); + + putchar('|'); +@@ -2001,8 +2004,7 @@ print_clients_header(struct igt_drm_clients *clients, int lines, + 4 : clients->max_name_len; /* At least "NAME" */ + + if (output_mode == INTERACTIVE) { +- unsigned int num_active = 0; +- int len; ++ int len, num_active = 0; + + if (lines++ >= con_h) + return lines; +-- +2.39.2 +