Skip to contentSkip to conversation

tools/intel_gpu_top: Add support for stdout logging

PATCH In review Tvrtko Ursulin 3 participants 6 messages Feb 11, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tools/intel_gpu_top: Add support for stdout logging

From: Tvrtko Ursulin <[email protected]>

Two new output modes are added: listing of text data to standard out (-l on the command line), and dumping of JSON formatted records (-J), also to standard out.

The first mode is selected automatically when non-interactive standard out is detected.

Example of text output:

 Freq MHz      IRQ RC6 Power     IMC MiB/s           RCS/0           BCS/0           VCS/0           VCS/1          VECS/0
 req  act       /s   %     W     rd     wr       %  se  wa       %  se  wa       %  se  wa       %  se  wa       %  se  wa
   0    0        0   0  0.00    360      0    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0
 350  350        0 100  0.00     35      2    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0
 350  350        0 100  0.00     34      2    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0
 350  350        0 100  0.00    143      6    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0
 350  350        0 100  0.00    169      7    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0
 350  350        0 100  0.00    169      7    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0    0.00   0   0

Example of JSON output:

{
        "period": {
                "duration": 1002.525224,
                "unit": "ms"
        },
        "frequency": {
                "requested": 349.118398,
                "actual": 349.118398,
                "unit": "MHz"
        },
        "interrupts": {
                "count": 0.000000,
                "unit": "irq/s"
        },
        "rc6": {
                "value": 99.897752,
                "unit": "%"
        },
        "power": {
                "value": 0.000000,
                "unit": "W"
        },
        "imc-bandwidth": {
                "reads": 149.683843,
                "writes": 6.104093,
                "unit": "MiB/s"
        },
        "engines": {
                "Render/3D/0": {
                        "busy": 0.000000,
                        "sema": 0.000000,
                        "wait": 0.000000,
                        "unit": "%"
                },
                "Blitter/0": {
                        "busy": 0.000000,
                        "sema": 0.000000,
                        "wait": 0.000000,
                        "unit": "%"
                },
                "Video/0": {
                        "busy": 0.000000,
                        "sema": 0.000000,
                        "wait": 0.000000,
                        "unit": "%"
                },
                "Video/1": {
                        "busy": 0.000000,
                        "sema": 0.000000,
                        "wait": 0.000000,
                        "unit": "%"
                },
                "VideoEnhance/0": {
                        "busy": 0.000000,
                        "sema": 0.000000,
                        "wait": 0.000000,
                        "unit": "%"
                }
        }
}

v2:
* Show example output in commit message.
* Install signal handler to complete output on SIGINT. (Chris Wilson)

v3:
* Use asprintf where possible. (Chris Wilson)

References: https://bugs.freedesktop.org/show_bug.cgi?id=108689
Cc: Eero Tamminen <[email protected]>
Cc: [email protected]
Cc: Chris Wilson <[email protected]>

---
 man/intel_gpu_top.rst |   9 +-
 tools/intel_gpu_top.c | 761 +++++++++++++++++++++++++++++++++++-------
 2 files changed, 644 insertions(+), 126 deletions(-)
man/intel_gpu_top.rst +7 -2
index 19c712307d28..d5bda093c8e8 100644
@@ -7,9 +7,9 @@ Display a top-like summary of Intel GPU usage
 ---------------------------------------------
 .. include:: defs.rst
 :Author: IGT Developers <[email protected]>
-:Date: 2018-04-04
+:Date: 2019-02-08
 :Version: |PACKAGE_STRING|
-:Copyright: 2009,2011,2012,2016,2018 Intel Corporation
+:Copyright: 2009,2011,2012,2016,2018,2019 Intel Corporation
 :Manual section: |MANUAL_SECTION|
 :Manual group: |MANUAL_GROUP|
 
@@ -31,6 +31,11 @@ OPTIONS
 -s <ms>
     Refresh period in milliseconds.
 
+-l
+    List text data to standard out.
+
+-J
+    Output JSON formatted data to standard output.
 -h
     Show help text.
 
tools/intel_gpu_top.c +637 -124

867 lines not on this page · raw message

Signature · 6 lines
2.19.1

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

PATCH 2/2 tools/intel_gpu_top: Add file output capability

From: Tvrtko Ursulin <[email protected]>

A new -o command switch enables logging to a file.

v2:
* Support "-o -" for explicit stdout selection. (Chris Wilson)

References: https://bugs.freedesktop.org/show_bug.cgi?id=108689

---
 man/intel_gpu_top.rst | 19 ++++++++-----
 tools/intel_gpu_top.c | 63 ++++++++++++++++++++++++++++---------------
 2 files changed, 53 insertions(+), 29 deletions(-)
man/intel_gpu_top.rst +12 -7
index d5bda093c8e8..d487baca0c63 100644
@@ -28,16 +28,21 @@ The tool gathers data using perf performance counters (PMU) exposed by i915 and
 OPTIONS
 =======
 
--s <ms>
-    Refresh period in milliseconds.
+-h
+    Show help text.
+
+-J
+    Output JSON formatted data.
 
 -l
-    List text data to standard out.
+    List plain text data.
 
--J
-    Output JSON formatted data to standard output.
--h
-    Show help text.
+-o <file path | ->
+    Output to the specified file instead of standard output.
+    '-' can also be specified to explicitly select standard output.
+
+-s <ms>
+    Refresh period in milliseconds.
 
 LIMITATIONS
 ===========
tools/intel_gpu_top.c +41 -22

142 lines not on this page · raw message

Signature · 6 lines
2.19.1

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

[igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/2] tools/intel_gpu_top: Add support for stdout logging

In reply to Tvrtko Ursulin
== Series Details ==

== Series Details ==

Series: series starting with [1/2] tools/intel_gpu_top: Add support for stdout logging
URL : https://patchwork.freedesktop.org/series/56490/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5586 -> IGTPW_2371
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/56490/revisions/1/mbox/

Known issues
------------

Here are the changes found in IGTPW_2371 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@kms_busy@basic-flip-a:
- fi-gdg-551: PASS -> FAIL [fdo#103182]

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: PASS -> FAIL [fdo#109485]

* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
- fi-byt-clapper: PASS -> FAIL [fdo#103191] / [fdo#107362]

#### Possible fixes ####

* igt@gem_exec_suspend@basic-s4-devices:
- fi-blb-e6850: INCOMPLETE [fdo#107718] -> PASS

* igt@kms_chamelium@dp-edid-read:
- fi-kbl-7500u: FAIL -> PASS

* igt@kms_pipe_crc_basic@hang-read-crc-pipe-a:
- fi-byt-clapper: FAIL [fdo#103191] / [fdo#107362] -> PASS

* igt@prime_vgem@basic-fence-flip:
- fi-gdg-551: FAIL [fdo#103182] -> PASS

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485

Participating hosts (47 -> 42)
------------------------------

Missing (5): fi-ilk-m540 fi-hsw-4200u fi-bsw-cyan fi-ctg-p8600 fi-icl-y

Build changes
-------------

* IGT: IGT_4816 -> IGTPW_2371

CI_DRM_5586: e54b6a76e1a6d0e4ba8b56f149673ea9907b2c59 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2371: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2371/
IGT_4816: f62577c85c9ef0539d468d6fad105b706a15139c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2371/
_______________________________________________
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 (2019-02-11 11:45:22)

tools/intel_gpu_top.c usage(const char *appname) · line 708

Quoted 8 lines
tools/intel_gpu_top.c +8 -0
+static enum {
+       INTERACTIVE,
+       STDOUT,
+       JSON
+} output_mode;
+
+struct cnt_item {
+       struct pmu_counter *pmu;

/* "%*.*f", fmt_d, fmt_dd, X */

I tried fmt_d == fmt_width and fmt_dd == fmt_decimals

It's called field width and precision in the manpage, so maybe fmt_width and fmt_precision.

Having figured that out, the use makes sense.

Quoted 36 lines
tools/intel_gpu_top.c +36 -0
+       unsigned int fmt_d;
+       unsigned int fmt_dd;
+       double d;
+       double t;
+       double s;
+       const char *name;
+       const char *unit;
+
+       /* Internal fields. */
+       char buf[16];
+};
+
+struct cnt_group {
+       const char *name;
+       const char *display_name;
+       struct cnt_item *items;
+};
+
+static unsigned int json_indent_level;
+
+static const char *json_indent[] = {
+       "",
+       "\t",
+       "\t\t",
+       "\t\t\t",
+       "\t\t\t\t",
+       "\t\t\t\t\t",
+};
+
+#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
+
+static unsigned int json_prev_struct_members;
+static unsigned int json_struct_members;
+
+static void
+json_open_struct(const char *name)

tools/intel_gpu_top.c usage(const char *appname) · line 754

Quoted 10 lines
tools/intel_gpu_top.c +10 -0
+{
+       assert(json_indent_level < ARRAY_SIZE(json_indent));
+
+       json_prev_struct_members = json_struct_members;
+       json_struct_members = 0;
+
+       if (name)
+               printf("%s%s\"%s\": {\n",
+                      json_prev_struct_members ? ",\n" : "",
+                      json_indent[json_indent_level],

"%*s", json_indent_level, "\t\t\t\t\t"
didn't stick?

I could follow the flow, dug into a few of the details, and only have some nits. One thing, could we feed in a perf record? I was thinking for testing the various output modes with known data, but may also be useful for replay.

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

#4 lore raw
Quoted 12 lines · Chris Wilson

Quoting Tvrtko Ursulin (2019-02-11 11:45:22)

tools/intel_gpu_top.c usage(const char *appname) · line 708

Quoted 8 lines
tools/intel_gpu_top.c +8 -0
+static enum {
+       INTERACTIVE,
+       STDOUT,
+       JSON
+} output_mode;
+
+struct cnt_item {
+       struct pmu_counter *pmu;

/* "%*.*f", fmt_d, fmt_dd, X */

Quoted 4 lines

I tried fmt_d == fmt_width and fmt_dd == fmt_decimals

It's called field width and precision in the manpage, so maybe fmt_width and fmt_precision.

Makes sense indeed.

Quoted 43 lines

Having figured that out, the use makes sense.

Quoted 41 lines
tools/intel_gpu_top.c +41 -0
+       unsigned int fmt_d;
+       unsigned int fmt_dd;
+       double d;
+       double t;
+       double s;
+       const char *name;
+       const char *unit;
+
+       /* Internal fields. */
+       char buf[16];
+};
+
+struct cnt_group {
+       const char *name;
+       const char *display_name;
+       struct cnt_item *items;
+};
+
+static unsigned int json_indent_level;
+
+static const char *json_indent[] = {
+       "",
+       "\t",
+       "\t\t",
+       "\t\t\t",
+       "\t\t\t\t",
+       "\t\t\t\t\t",
+};
+
+#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
+
+static unsigned int json_prev_struct_members;
+static unsigned int json_struct_members;
+
+static void
+json_open_struct(const char *name)
+{
+       assert(json_indent_level < ARRAY_SIZE(json_indent));
+
+       json_prev_struct_members = json_struct_members;
+       json_struct_members = 0;
Quoted 8 lines

tools/intel_gpu_top.c usage(const char *appname) · line 754

Quoted 5 lines
tools/intel_gpu_top.c +5 -0
+
+       if (name)
+               printf("%s%s\"%s\": {\n",
+                      json_prev_struct_members ? ",\n" : "",
+                      json_indent[json_indent_level],

"%*s", json_indent_level, "\t\t\t\t\t"
didn't stick?

No, I lost patience trying to make it do what I want. AFAIR it insisted on right justifying and the negative count also did not work.

Quoted 4 lines

I could follow the flow, dug into a few of the details, and only have some nits. One thing, could we feed in a perf record? I was thinking for testing the various output modes with known data, but may also be useful for replay.

Could do, should be too hard. Writing tests for tool output though sounds like something I won't have time to do in the near future.

Quoted 1 line

Thanks, I'll keep it when I fix the asprintf return value inspection which I butchered in a hasty copy and paste work.

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for series starting with [1/2] tools/intel_gpu_top: Add support for stdout logging

In reply to Tvrtko Ursulin
== Series Details ==

== Series Details ==

Series: series starting with [1/2] tools/intel_gpu_top: Add support for stdout logging
URL : https://patchwork.freedesktop.org/series/56490/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5586_full -> IGTPW_2371_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/56490/revisions/1/mbox/

Known issues
------------

Here are the changes found in IGTPW_2371_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_ctx_isolation@vecs0-s3:
- shard-kbl: PASS -> INCOMPLETE [fdo#103665]

* igt@gem_exec_schedule@preempt-self-blt:
- shard-apl: PASS -> INCOMPLETE [fdo#103927]

* igt@kms_atomic_transition@plane-all-modeset-transition-fencing:
- shard-hsw: PASS -> DMESG-WARN [fdo#102614] / [fdo#109225]

* igt@kms_busy@extended-modeset-hang-newfb-render-a:
- shard-hsw: PASS -> DMESG-WARN [fdo#107956]

* igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-b:
- shard-snb: PASS -> DMESG-WARN [fdo#107956]

* igt@kms_ccs@pipe-b-crc-sprite-planes-basic:
- shard-kbl: PASS -> FAIL [fdo#107725] / [fdo#108145]

* igt@kms_cursor_crc@cursor-128x128-sliding:
- shard-kbl: PASS -> FAIL [fdo#103232] +2

* igt@kms_cursor_crc@cursor-256x256-random:
- shard-apl: PASS -> FAIL [fdo#103232] +3
- shard-kbl: NOTRUN -> FAIL [fdo#103232]

* igt@kms_cursor_crc@cursor-64x64-suspend:
- shard-apl: PASS -> FAIL [fdo#103191] / [fdo#103232]
- shard-kbl: PASS -> FAIL [fdo#103191] / [fdo#103232]

* igt@kms_cursor_crc@cursor-alpha-opaque:
- shard-kbl: PASS -> FAIL [fdo#109350]
- shard-apl: PASS -> FAIL [fdo#109350]

* igt@kms_cursor_crc@cursor-size-change:
- shard-glk: PASS -> FAIL [fdo#103232]

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-pwrite:
- shard-apl: PASS -> FAIL [fdo#103167] +2

* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-cpu:
- shard-glk: PASS -> FAIL [fdo#103167] +6

* igt@kms_plane@plane-position-covered-pipe-c-planes:
- shard-apl: PASS -> FAIL [fdo#103166] +2

* igt@kms_plane_alpha_blend@pipe-b-constant-alpha-max:
- shard-glk: PASS -> FAIL [fdo#108145] +2

* igt@kms_plane_alpha_blend@pipe-c-alpha-opaque-fb:
- shard-apl: PASS -> FAIL [fdo#108145]

* igt@kms_plane_multiple@atomic-pipe-b-tiling-x:
- shard-glk: PASS -> FAIL [fdo#103166] +4

* igt@kms_setmode@basic:
- shard-hsw: PASS -> FAIL [fdo#99912]
- shard-kbl: PASS -> FAIL [fdo#99912]

#### Possible fixes ####

* igt@gem_exec_blt@dumb-buf-max:
- shard-glk: DMESG-WARN [fdo#105763] / [fdo#106538] -> PASS

* igt@i915_suspend@fence-restore-untiled:
- shard-snb: INCOMPLETE [fdo#105411] -> PASS

* igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-c:
- shard-apl: DMESG-WARN [fdo#107956] -> PASS

* igt@kms_cursor_crc@cursor-128x128-random:
- shard-apl: FAIL [fdo#103232] -> PASS +6
- shard-kbl: FAIL [fdo#103232] -> PASS +2

* igt@kms_cursor_crc@cursor-128x128-suspend:
- shard-apl: FAIL [fdo#103191] / [fdo#103232] -> PASS +1
- shard-kbl: FAIL [fdo#103191] / [fdo#103232] -> PASS

* igt@kms_cursor_legacy@cursor-vs-flip-atomic:
- shard-hsw: FAIL [fdo#103355] -> PASS

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-move:
- shard-glk: FAIL [fdo#103167] -> PASS +2

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-onoff:
- shard-apl: FAIL [fdo#103167] -> PASS +2

* igt@kms_plane_multiple@atomic-pipe-b-tiling-y:
- shard-kbl: FAIL [fdo#103166] -> PASS +1

* igt@kms_plane_multiple@atomic-pipe-c-tiling-yf:
- shard-apl: FAIL [fdo#103166] -> PASS +6

* igt@kms_setmode@basic:
- shard-apl: FAIL [fdo#99912] -> PASS

* igt@pm_rc6_residency@rc6-accuracy:
- shard-snb: {SKIP} [fdo#109271] -> PASS

#### Warnings ####

* igt@i915_suspend@shrink:
- shard-hsw: DMESG-WARN [fdo#109244] -> INCOMPLETE [fdo#103540] / [fdo#106886]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103355]: https://bugs.freedesktop.org/show_bug.cgi?id=103355
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
[fdo#105763]: https://bugs.freedesktop.org/show_bug.cgi?id=105763
[fdo#106538]: https://bugs.freedesktop.org/show_bug.cgi?id=106538
[fdo#106886]: https://bugs.freedesktop.org/show_bug.cgi?id=106886
[fdo#107725]: https://bugs.freedesktop.org/show_bug.cgi?id=107725
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#109225]: https://bugs.freedesktop.org/show_bug.cgi?id=109225
[fdo#109244]: https://bugs.freedesktop.org/show_bug.cgi?id=109244
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109350]: https://bugs.freedesktop.org/show_bug.cgi?id=109350
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912

Participating hosts (7 -> 5)
------------------------------

Missing (2): shard-skl shard-iclb

Build changes
-------------

* IGT: IGT_4816 -> IGTPW_2371
* Piglit: piglit_4509 -> None

CI_DRM_5586: e54b6a76e1a6d0e4ba8b56f149673ea9907b2c59 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2371: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2371/
IGT_4816: f62577c85c9ef0539d468d6fad105b706a15139c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2371/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev