summaryrefslogtreecommitdiff
path: root/tools/intel_gpu_top.c
AgeCommit message (Collapse)Author
2019-02-25tools/intel_gpu_top: Add file output capabilityTvrtko Ursulin
A new -o command switch enables logging to a file. v2: * Support "-o -" for explicit stdout selection. (Chris Wilson) Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> References: https://bugs.freedesktop.org/show_bug.cgi?id=108689 Cc: Eero Tamminen <eero.t.tamminen@intel.com> Cc: 3.14pi@ukr.net Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-02-25tools/intel_gpu_top: Add support for stdout loggingTvrtko Ursulin
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) v4: * Check asprintf return value, not the pointer. * Rename fmt_d/dd to fmt_width/precision. (Chris Wilson) Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> References: https://bugs.freedesktop.org/show_bug.cgi?id=108689 Cc: Eero Tamminen <eero.t.tamminen@intel.com> Cc: 3.14pi@ukr.net Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-05-31intel-gpu-top: Rewrite the tool to be safe to useTvrtko Ursulin
intel-gpu-top is a dangerous tool which can hang machines due unsafe mmio register access. This patch rewrites it to use only PMU. Only overall command streamer busyness and GPU global data such as power and frequencies are included in this new version. For access to more GPU functional unit level data, an OA metric based tool like gpu-top should be used instead. v2: * Sort engines by class and instance. * Do not wait for one sampling period to display something on screen. * Move code out of the asserts. (Rinat Ibragimov) * Continuously adapt to terminal size. (Rinat Ibragimov) v3: * Change layout and precision of some field. (Chris Wilson) Eero Tamminen: * Use more user friendly engine names. * Don't error out if a counter is missing. * Add IMC read/write bandwidth. * Report minimum required kernel version. v4: * Really support 4.16 by skipping of missing engines. * Simpler and less hacky float printing. * Preserve copyright header. (Antonio Argenziano) * Simplify engines_ptr macro. (Rinat Ibragimov) v5: * Get RAPL unit from sysfs. * Consolidate sysfs paths with a macro. * Tidy error handling by carrying over and reporting errno. * Check against console height on all prints. * More readable minimum kernel version message. (Eero Tamminen) * Column banner for per engine stats. (Eero Tamminen) v6: * Man page update. (Eero Tamminen) Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Cc: Petri Latvala <petri.latvala@intel.com> Cc: Eero Tamminen <eero.t.tamminen@intel.com> Cc: Rinat Ibragimov <ibragimovrinat@mail.ru> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> # v1 Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> # v0.5 Reviewed-by: Matthew Auld <matthew.auld@intel.com>
2018-01-11include inttypes.h for PRI definesMike Frysinger
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96620 Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2017-11-21tools: Stop opening the driver just to find the debugfsChris Wilson
Since the tools want to work without the module loaded, remove the assumption that we want to load the driver to find debugfs. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Ville Syrjala <ville.syrjala@linux.intel.com>
2017-09-08build: Nuke #ifdef HAVE_CONFIG_H cargo-cultDaniel Vetter
We have it. Daniel Stone said the #ifdef HAVE_CONFIG_H comes from the X11 transition to the modular build, where in the imake -> modular build transition config.h wasn't universally available. Now we just make this a requirement (so yeah Android better generate one too). v2: Improve commit message a bit. Reviewed-by: Eric Anholt <eric@anholt.net> Acked-by: Jani Nikula <jani.nikula@intel.com> Acked-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Acked-by: Petri Latvala <petri.latvala@intel.com> Acked-by: Daniel Stone <daniels@collabora.com> Acked-by: Radoslaw Szwichtenberg <radoslaw.szwichtenberg@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2017-08-08intel_gpu_top: Use drm_open_driver, don't need drm masterPetri Latvala
Signed-off-by: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
2017-03-21Restore "lib: Open debugfs files for the given DRM device"Chris Wilson
This reverts commit 25fbae15262cf570e207e62f50e7c5233e06bc67, restoring commit 301ad44cdf1b868b1ab89096721da91fa8541fdc Author: Tomeu Vizoso <tomeu.vizoso@collabora.com> Date: Thu Mar 2 10:37:11 2017 +0100 lib: Open debugfs files for the given DRM device with fixes. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2017-03-21Revert "lib: Open debugfs files for the given DRM device"Tomeu Vizoso
This reverts commit 301ad44cdf1b868b1ab89096721da91fa8541fdc. When a render-only device is opened and gem_quiescent_gpu is called, we need to use the debugfs dir for the master device instead. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2017-03-21lib: Open debugfs files for the given DRM deviceTomeu Vizoso
When opening a DRM debugfs file, locate the right path based on the given DRM device FD. This is needed so, in setups with more than one DRM device, any operations on debugfs files affect the expected DRM device. v2: - rebased and fixed new API additions v3: - updated chamelium test, which was missed previously - use the minor of the device for the debugfs path, not the major - have a proper exit handler for calling igt_hpd_storm_reset with the right device fd. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Robert Foss <robert.foss@collabora.com> Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-01-08Fix a bunch of printf typesVille Syrjälä
igt_kms.c: In function ‘igt_crtc_set_background’: igt_kms.c:1940:2: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘uint64_t’ [-Wformat=] LOG(display, "%s.%d: crtc_set_background(%lu)\n", ^ intel_firmware_decode.c: In function ‘csr_open’: intel_firmware_decode.c:169:2: warning: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 3 has type ‘__off_t’ [-Wformat=] printf("Firmware: %s (%zd bytes)\n", filename, st.st_size); ^ intel_gpu_top.c: In function ‘main’: intel_gpu_top.c:683:10: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=] stats[i] - last_stats[i]); ^ hsw_compute_wrpll.c: In function ‘main’: hsw_compute_wrpll.c:644:3: warning: format ‘%li’ expects argument of type ‘long int’, but argument 7 has type ‘long long int’ [-Wformat=] igt_fail_on_f(ref->r2 != r2 || ref->n2 != n2 || ref->p != p, ^ gem_gtt_hog.c: In function ‘__real_main155’: gem_gtt_hog.c:177:2: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat=] igt_info("Time to execute %lu children: %7.3fms\n", ^ kms_flip.c: In function ‘run_test_step’: kms_flip.c:985:3: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 10 has type ‘__time_t’ [-Wformat=] igt_assert_f(end - start > 0.9 * frame_time(o) && ^ kms_flip.c:985:3: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 11 has type ‘__suseconds_t’ [-Wformat=] kms_frontbuffer_tracking.c: In function ‘setup_sink_crc’: kms_frontbuffer_tracking.c:1364:3: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘ssize_t’ [-Wformat=] igt_info("Unexpected sink CRC error, rc=:%ld errno:%d %s\n", ^ Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2014-03-22lib/intel_io: rename mmio setup functionsDaniel Vetter
Makes their intent a bit clearer. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-22lib: rename intel_gpu_tools.h to intel_io.hDaniel Vetter
With the header cleanup we can now give this header a suitable name, since it now really only contains register access and other I/O functions and assorted definitions. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-03-22lib: remove uncessary #includes from headersDaniel Vetter
Only include what the header itself needs. The big fish here is intel-gpu-tools.h. More will follow. One ugly thing removed here is the duplicated GEN6_TD_CTL #define, one of which was broken. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-01-07intel_reg: Renamed INST_DONE to INSTDONEDamien Lespiau
That's how the registers are named in the kernel defines. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04build: Guard the inclusions of config.h with HAVE_CONFIG_HDamien Lespiau
autoconf can be configured to not generate a config.h but to give the defines with command line arguments instead. In this case, there's no config.h to include. To work in both cases autoconf adds a HAVE_CONFIG_H define on the command line to signal there's a config.h to include. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2012-08-30clang: Fix static analysis warnings from clangBen Widawsky
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
2012-05-16intel_gpu_top: allow to work on Gen7Eugeni Dodonov
Somehow nobody noticed this before, but we were missing blt and bsd6 initialization on Gen7. Reported-by: Philippe Lecluse <philippe.lecluse@intel.com> Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2012-03-19intel_gpu_top: Trust the register access is safeChris Wilson
Fixes intel_gpu_top on gen3 which otherwise refuses to do mmio. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-06Move free(cmd) to after last use of cmd in intel_gpu_topAlan Coopersmith
Error: Use after free (CWE 416) Use after free of pointer 'cmd' in call to fprintf at line 496 of tools/intel_gpu_top.c in function 'main'. Previously freed at line 491 with free. [ This bug was found by the Parfait 0.4.2 bug checking tool. For more information see http://labs.oracle.com/projects/parfait/ ] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-01-09tools/intel_gpu_top: fixup new warningsDaniel Vetter
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-01-08Solaris defines struct winsize in termios.hAlan Coopersmith
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2011-11-09intel_gpu_top: use debugfs interface for forcewakeEugeni Dodonov
Using debugfs facilities for forcewake-related stuff. Acked-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2011-10-19top: Avoid FPE by removing meaningless metricChris Wilson
2011-10-14Allow to output statistics to stdout.Eugeni Dodonov
This allows intel_gpu_top to run both in statistics-collecting mode (collecting the per-ring statistics in gnuplot-friendly format) and ncurses top-like mode at the same time. It also allows to output the statistics directly to stdout, by using "-o -", so the results can be parsed directly via a popen() parsing. If you are using intel_gpu_top as previously (without any command-line arguments), it should change nothing for you. If you were using its logging facilities (e.g., the '-o file'), note that the logging will keep running, but the detailed top-like interface will be on the screen at the same time. Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2011-09-05intel_gpu_top: access hardware before running profiling commandEugeni Dodonov
Without this patch, intel_gpu_top will try to get access to the hardware after running the profiling command in the background. In case such access fails, the main process quits, but the background one will continue running. So let's move this test up, so it is done before we fork. Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2011-09-05intel_gpu_tools: describe -e option in usage screenEugeni Dodonov
This patch adds a short description of '-e' option to the usage screen. Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2011-09-05intel_gpu_top: adopt to kernel coding styleEugeni Dodonov
This patch fixes adopts the code to the kernel coding_style.
2011-09-05intel_gpu_top: support profiling user-specified commandsEugeni Dodonov
This patch adds support for running intel_gpu_top to profile specific commands. The required command will be carried out in separate process, and main intel_gpu_top will leave when the child process will exit. Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2011-09-05intel_gpu_top: support non-interactive modeEugeni Dodonov
This patch adds support for non-interactive mode, invoked by running with '-o output' switch. In this case, no interactive output is being performed, but the execution statistics are being saved into the output file. The output file is generated in both human and gnuplot-readable format. Unlike interactive mode, where non-supported pipes and non-active registers are skipped, the content of such pipes and registers is recorded into the log file to simplify parsing and standardize the list of columns. Also, unlike interactive mode, the registers are not sorted according to the usage - this way, their variation over time can be analysed offline. Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2011-09-05This patch initializes the last_stats[] for registers prior to startingEugeni Dodonov
the monitoring itself. This way, the first measure will already contain the difference from the previous value instead of non-initialized value. Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2011-09-05Revert "intel_gpu_top: initialize monitoring statistics at startup"Eugeni Dodonov
This reverts commit 431fe7803d37f344275fdaceb57c1fbaeee8541c. Will be replaced with more fine-grained commits.
2011-09-05intel_gpu_top: initialize monitoring statistics at startupEugeni Dodonov
This patch initializes the last_stats[] for registers prior to starting the monitoring itself. This way, the first measure will already contain the difference from the previous value instead of non-initialized value. Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2011-09-05intel_gpu_tool: initial support for non-screen outputEugeni Dodonov
This patch adds initial support for non-stdio output, to be used for non-interactive monitoring. Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2011-09-05intel_gpu_top: suport command line parameters and variable samples perEugeni Dodonov
second This patch adds support for getopt, and adds two default parameters to it: -h to show usage notes; and -s to allow user to define number of samples to acquire per second. Manpage documentation is also adjusted accordingly. Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2011-09-05intel_gpu_top: account for time spent in syscallsEugeni Dodonov
This allows intel_gpu_top to properly account for time spent inside system calls. Effectively, with previous implementation, intel_gpu_top could spent longer than 1s between consecutive measures. This attempts to minimize the extra time spent while polling for data. Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2011-02-01Search for the first Intel dri device.Chris Wilson
This is vital in a multi-GPU system so that we only test the Intel card and not the discrete GPUs. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-01-09gpu-top: Correct computation of ring sizeChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-01-07intel_gpu_top: Include BLT ringChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-01-07intel_gpu_top: Wake the GT power well to read gen6 ring registersChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-12-16intel_gpu_top: Print stats regs on Ironlake as well.Eric Anholt
2010-10-01intel_gpu_top: Sample BSD rings as well as renderChris Wilson
Show how busy the GPU is when decoding video as well as rendering. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-07-19intel_gpu_top: Fix the "limit printing to terminal height" again.Eric Anholt
2010-04-08Enable compilation on non-Intel, non-DRM systems.Chris Wilson
A few of the tools can be performed post-mortem from a different system, so it is useful to be able to compile those tools on those foreign systems. Obviously, any program to interact with the PCI device or talk to GEM will fail on a non-Intel system. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-02-25intel_gpu_top: Print stats lines even when there's no done bit on the line.Eric Anholt
2010-02-25intel_gpu_top: Print the vertex/primitive statistics on gen4+.Eric Anholt
This requires that the window be much wider. I'm not sure how we really want to lay out this interface usably, but so far giant windows are working well enough for me.
2009-12-15intel_gpu_top: Fix broken clock reporting.Shuang He
Signed-off-by: Eric Anholt <eric@anholt.net>
2009-12-10Limit printing to terminal height in intel_gpu_top.Kenneth Graunke
When using intel_gpu_top in a small terminal, the most important information (ring idle/busy units) scrolls off the top of the screen. This patch limits the number of lines printed to the terminal height so that the most idle units (at the bottom) are truncated instead. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2009-06-30intel_gpu_top: Move instdone bit definitions to lib to share with _dump.Eric Anholt
2009-06-23Add more 965 INSTDONE bits.Eric Anholt
This shows off the units that are stuck busy in the ut2004 hang.