Skip to contentSkip to conversation

intel_gpu_top: Show banner messages when cycling sort modes

PATCH In review Tvrtko Ursulin 3 participants 6 messages Feb 3, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 intel_gpu_top: Show banner messages when cycling sort modes

From: Tvrtko Ursulin <[email protected]>

It is useful to let the user know what is the currently active sort mode.

---
 tools/intel_gpu_top.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
tools/intel_gpu_top.c +13 -2
index 584aa21b198a..b409106f3718 100644
@@ -1479,6 +1479,8 @@ print_header_token(const char *cont, int lines, int con_w, int con_h, int *rem,
 	return lines;
 }
 
+static const char *header_msg;
+
 static int
 print_header(const struct igt_device_card *card,
 	     const char *codename,
@@ -1593,8 +1595,14 @@ print_header(const struct igt_device_card *card,
 		if (lines++ < con_h)
 			printf("\n");
 
-		if (lines++ < con_h)
-			printf("\n");
+		if (lines++ < con_h) {
+			if (header_msg) {
+				printf(" >>> %s\n", header_msg);
+				header_msg = NULL;
+			} else {
+				printf("\n");
+			}
+		}
 	}
 
 	return lines;
@@ -2146,12 +2154,15 @@ static void select_client_sort(void)
 	switch (++client_sort % 3) {
 	case 0:
 		client_cmp = client_last_cmp;
+		header_msg = "Sorting clients by current GPU usage.";
 		break;
 	case 1:
 		client_cmp = client_total_cmp;
+		header_msg = "Sorting clients by accummulated GPU usage.";
 		break;
 	case 2:
 		client_cmp = client_id_cmp;
+		header_msg = "Sorting clients by sysfs id.";
 	}
 }
 
Signature · 6 lines
2.27.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

PATCH 2/2 intel_gpu_top: Add option to sort by PID

From: Tvrtko Ursulin <[email protected]>

Useful to mimick top view.

---
 man/intel_gpu_top.rst |  2 +-
 tools/intel_gpu_top.c | 46 +++++++++++++++++++++++++++++++------------
 2 files changed, 34 insertions(+), 14 deletions(-)
man/intel_gpu_top.rst +1 -1
index 118d8b953a70..b145d85c0440 100644
@@ -56,7 +56,7 @@ Supported keys:
     'q'    Exit from the tool.
     '1'    Toggle between aggregated engine class and physical engine mode.
     'n'    Toggle display of numeric client busyness overlay.
-    's'    Toggle between sort modes (runtime, total runtime, client id).
+    's'    Toggle between sort modes (runtime, total runtime, pid, client id).
     'i'    Toggle display of clients which used no GPU time.
 
 DEVICE SELECTION
tools/intel_gpu_top.c +33 -13

60 lines not on this page · raw message

Signature · 6 lines
2.27.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Reviewed-by on v1 2/2
#2 lore raw

Re: [igt-dev] [Intel-gfx] [PATCH i-g-t 2/2] intel_gpu_top: Add option to sort by PID

Quoting Tvrtko Ursulin (2021-02-03 11:44:56)

Quoted 77 lines

From: Tvrtko Ursulin <[email protected]>

Useful to mimick top view.

---
 man/intel_gpu_top.rst |  2 +-
 tools/intel_gpu_top.c | 46 +++++++++++++++++++++++++++++++------------
 2 files changed, 34 insertions(+), 14 deletions(-)
man/intel_gpu_top.rst +1 -1
index 118d8b953a70..b145d85c0440 100644
@@ -56,7 +56,7 @@ Supported keys:
     'q'    Exit from the tool.
     '1'    Toggle between aggregated engine class and physical engine mode.
     'n'    Toggle display of numeric client busyness overlay.
-    's'    Toggle between sort modes (runtime, total runtime, client id).
+    's'    Toggle between sort modes (runtime, total runtime, pid, client id).
     'i'    Toggle display of clients which used no GPU time.
 
 DEVICE SELECTION
tools/intel_gpu_top.c +27 -10
index b409106f3718..24a87d2f4f3f 100644
@@ -959,6 +959,24 @@ static int client_id_cmp(const void *_a, const void *_b)
        return (int)b->id - a->id;
 }
 
+static int client_pid_cmp(const void *_a, const void *_b)
+{
+       const struct client *a = _a;
+       const struct client *b = _b;
+       int pid_a, pid_b;
+
+       pid_a = a->status == ALIVE ? a->pid : INT_MAX;
+       pid_b = b->status == ALIVE ? b->pid : INT_MAX;
+
+       pid_b -= pid_a;
+       if (pid_b > 0)
+               return -1;
+       if (pid_b < 0)
+               return 1;
+
+       return (int)a->id - b->id;
+}
+
 static int (*client_cmp)(const void *, const void *) = client_last_cmp;
 
 static void sort_clients(struct clients *clients)
@@ -2149,21 +2167,23 @@ static void interactive_stdin(void)
 
 static void select_client_sort(void)
 {
+       struct {
+               int (*cmp)(const void *, const void *);
+               const char *msg;
+       } cmp[] = {
+               { client_last_cmp, "Sorting clients by current GPU usage." },
+               { client_total_cmp, "Sorting clients by accummulated GPU usage." },
+               { client_pid_cmp, "Sorting clients by pid." },
+               { client_id_cmp, "Sorting clients by sysfs id." },
+       };
        static unsigned int client_sort;
 
-       switch (++client_sort % 3) {
-       case 0:
-               client_cmp = client_last_cmp;
-               header_msg = "Sorting clients by current GPU usage.";
-               break;
-       case 1:
-               client_cmp = client_total_cmp;
-               header_msg = "Sorting clients by accummulated GPU usage.";
-               break;
-       case 2:

tools/intel_gpu_top.c static void interactive_stdin(void) · line 2187

Quoted 10 lines
tools/intel_gpu_top.c +6 -3
-               client_cmp = client_id_cmp;
-               header_msg = "Sorting clients by sysfs id.";
-       }
+       ++client_sort;
+       if (client_sort >= ARRAY_SIZE(cmp))
+               client_sort = 0;
+
+       client_cmp = cmp[client_sort].cmp;
+       header_msg = cmp[client_sort].msg;
 }

-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

Reviewed-by on v1 1/2
#3 lore raw
In reply to Tvrtko Ursulin

Quoting Tvrtko Ursulin (2021-02-03 11:44:55)

Quoted 23 lines

From: Tvrtko Ursulin <[email protected]>

It is useful to let the user know what is the currently active sort mode.

---
 tools/intel_gpu_top.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
tools/intel_gpu_top.c +2 -0
index 584aa21b198a..b409106f3718 100644
@@ -1479,6 +1479,8 @@ print_header_token(const char *cont, int lines, int con_w, int con_h, int *rem,
        return lines;
 }
 
+static const char *header_msg;
+
 static int
 print_header(const struct igt_device_card *card,
             const char *codename,

tools/intel_gpu_top.c print_header(const struct igt_device_card *card, · line 1601

Quoted 9 lines
tools/intel_gpu_top.c +4 -2
@@ -1593,8 +1595,14 @@ print_header(const struct igt_device_card *card,
                if (lines++ < con_h)
                        printf("\n");
 
-               if (lines++ < con_h)
-                       printf("\n");
+               if (lines++ < con_h) {
+                       if (header_msg) {
+                               printf(" >>> %s\n", header_msg);
+                               header_msg = NULL;

I was just about to ask if we showed it once, then cleared it 1s later.

Quoted 10 lines
tools/intel_gpu_top.c +4 -0
+                       } else {
+                               printf("\n");
+                       }
+               }
        }
 
        return lines;
@@ -2146,12 +2154,15 @@ static void select_client_sort(void)
        switch (++client_sort % 3) {
        case 0:

tools/intel_gpu_top.c static void select_client_sort(void) · line 2165

Quoted 10 lines
tools/intel_gpu_top.c +3 -0
                client_cmp = client_last_cmp;
+               header_msg = "Sorting clients by current GPU usage.";
                break;
        case 1:
                client_cmp = client_total_cmp;
+               header_msg = "Sorting clients by accummulated GPU usage.";
                break;
        case 2:
                client_cmp = client_id_cmp;
+               header_msg = "Sorting clients by sysfs id.";

Do we care about "sysfs"? Just "Sorting clients by id."? -Chris
_______________________________________________
igt-dev mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#4 lore raw
Quoted 43 lines · Chris Wilson

Quoting Tvrtko Ursulin (2021-02-03 11:44:55)

Quoted 23 lines

From: Tvrtko Ursulin <[email protected]>

It is useful to let the user know what is the currently active sort mode.

---
  tools/intel_gpu_top.c | 15 +++++++++++++--
  1 file changed, 13 insertions(+), 2 deletions(-)
tools/intel_gpu_top.c +2 -0
index 584aa21b198a..b409106f3718 100644
@@ -1479,6 +1479,8 @@ print_header_token(const char *cont, int lines, int con_w, int con_h, int *rem,
         return lines;
  }
 
+static const char *header_msg;
+
  static int
  print_header(const struct igt_device_card *card,
              const char *codename,

tools/intel_gpu_top.c print_header(const struct igt_device_card *card, · line 1601

Quoted 9 lines
tools/intel_gpu_top.c +4 -2
@@ -1593,8 +1595,14 @@ print_header(const struct igt_device_card *card,
                 if (lines++ < con_h)
                         printf("\n");
 
-               if (lines++ < con_h)
-                       printf("\n");
+               if (lines++ < con_h) {
+                       if (header_msg) {
+                               printf(" >>> %s\n", header_msg);
+                               header_msg = NULL;

I was just about to ask if we showed it once, then cleared it 1s later.

Quoted 6 lines
tools/intel_gpu_top.c +4 -0
+                       } else {
+                               printf("\n");
+                       }
+               }
         }
 
Quoted 16 lines
Quoted 4 lines
tools/intel_gpu_top.c +0 -0
         return lines;
@@ -2146,12 +2154,15 @@ static void select_client_sort(void)
         switch (++client_sort % 3) {
         case 0:

tools/intel_gpu_top.c static void select_client_sort(void) · line 2165

Quoted 10 lines
tools/intel_gpu_top.c +3 -0
                 client_cmp = client_last_cmp;
+               header_msg = "Sorting clients by current GPU usage.";
                 break;
         case 1:
                 client_cmp = client_total_cmp;
+               header_msg = "Sorting clients by accummulated GPU usage.";
                 break;
         case 2:
                 client_cmp = client_id_cmp;
+               header_msg = "Sorting clients by sysfs id.";

Do we care about "sysfs"? Just "Sorting clients by id."?

I was even doubting if having this sort is justified at all. Drop after next patch (pid sort)?

Regards,

Tvrtko
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#5 lore raw

[igt-dev] ✗ Fi.CI.BUILD: failure for series starting with [i-g-t,1/2] intel_gpu_top: Show banner messages when cycling sort modes

In reply to Tvrtko Ursulin
== Series Details ==

== Series Details ==

Series: series starting with [i-g-t,1/2] intel_gpu_top: Show banner messages when cycling sort modes
URL : https://patchwork.freedesktop.org/series/86640/
State : failure

== Summary ==

Applying: intel_gpu_top: Show banner messages when cycling sort modes Patch failed at 0001 intel_gpu_top: Show banner messages when cycling sort modes When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev