diff options
author | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2021-02-10 09:35:46 +0000 |
---|---|---|
committer | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2021-02-10 14:47:06 +0000 |
commit | d0d6f5e14ef181c93e4b503b05d9c18fa480e09d (patch) | |
tree | 6c51c41eac616c2577ea2740057b420023551d4f | |
parent | f17027d8a28e3c5fdf1d5396a1b4a2c89095a656 (diff) |
intel_gpu_top: Interactive help screen
Show a list of supported interactive commands when pressing 'h'.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | man/intel_gpu_top.rst | 1 | ||||
-rw-r--r-- | tools/intel_gpu_top.c | 68 |
2 files changed, 61 insertions, 8 deletions
diff --git a/man/intel_gpu_top.rst b/man/intel_gpu_top.rst index 20658e29..f6d74852 100644 --- a/man/intel_gpu_top.rst +++ b/man/intel_gpu_top.rst @@ -54,6 +54,7 @@ RUNTIME CONTROL Supported keys: 'q' Exit from the tool. + 'h' Show interactive help. '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, pid, client id). diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index e7f69611..e22e3bed 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -2279,19 +2279,31 @@ bump: goto bump; } -static void process_stdin(unsigned int timeout_us) +static bool in_help; + +static void process_help_stdin(void) { - struct pollfd p = { .fd = 0, .events = POLLIN }; - int ret; + for (;;) { + int ret; + char c; - ret = poll(&p, 1, timeout_us / 1000); - if (ret <= 0) { - if (ret < 0) - stop_top = true; - return; + ret = read(0, &c, 1); + if (ret <= 0) + break; + + switch (c) { + case 'q': + case 'h': + in_help = false; + break; + }; } +} +static void process_normal_stdin(void) +{ for (;;) { + int ret; char c; ret = read(0, &c, 1); @@ -2322,6 +2334,9 @@ static void process_stdin(unsigned int timeout_us) case 's': select_client_sort(); break; + case 'h': + in_help = true; + break; case 'H': aggregate_pids ^= true; if (aggregate_pids) @@ -2333,6 +2348,38 @@ static void process_stdin(unsigned int timeout_us) } } +static void process_stdin(unsigned int timeout_us) +{ + struct pollfd p = { .fd = 0, .events = POLLIN }; + int ret; + + ret = poll(&p, 1, timeout_us / 1000); + if (ret <= 0) { + if (ret < 0) + stop_top = true; + return; + } + + if (in_help) + process_help_stdin(); + else + process_normal_stdin(); +} + +static void show_help_screen(void) +{ + printf( +"Help for interactive commands:\n\n" +" '1' Toggle between aggregated engine class and physical engine mode.\n" +" 'n' Toggle display of numeric client busyness overlay.\n" +" 's' Toggle between sort modes (runtime, total runtime, pid, client id).\n" +" 'i' Toggle display of clients which used no GPU time.\n" +" 'H' Toggle between per PID aggregation and individual clients.\n" +"\n" +" 'h' or 'q' Exit interactive help.\n" +"\n"); +} + int main(int argc, char **argv) { unsigned int period_us = DEFAULT_PERIOD_MS * 1000; @@ -2515,6 +2562,11 @@ int main(int argc, char **argv) t, lines, con_w, con_h, &consumed); + if (in_help) { + show_help_screen(); + break; + } + lines = print_imc(engines, t, lines, con_w, con_h); lines = print_engines(engines, t, lines, con_w, con_h); |