From: "Adrián Larumbe" <adrian.larumbe@collabora.com>
To: tursulin@ursulin.net, robdclark@chromium.org,
kamil.konieczny@linux.intel.com, lucas.demarchi@intel.com,
igt-dev@lists.freedesktop.org
Cc: healych@amazon.com, adrian.larumbe@collabora.com,
"Daniel Vetter" <daniel@ffwll.ch>,
"Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Subject: [PATCH v5 2/2] tools/gputop: toggle sysfs profiling knob if available for device
Date: Tue, 16 Jul 2024 21:57:24 +0100 [thread overview]
Message-ID: <20240716205756.2973341-3-adrian.larumbe@collabora.com> (raw)
In-Reply-To: <20240716205756.2973341-1-adrian.larumbe@collabora.com>
For every DRM device that enables its job accounting HW from user space,
toggle it right before obtaining per-client fdinfo numbers.
Make sure profiling status is returned to its original state before
exiting, by handling the SIGINT signal just like in intel_gpu_top.
Also add the static IGT profiling library to gputop's list of build
dependencies.
Cc: Tvrtko Ursulin <tursulin@ursulin.net>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Acked-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
tools/gputop.c | 33 ++++++++++++++++++++++++++++++++-
tools/meson.build | 2 +-
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/tools/gputop.c b/tools/gputop.c
index 6c7cf6927464..23388c92b63a 100644
--- a/tools/gputop.c
+++ b/tools/gputop.c
@@ -29,6 +29,7 @@
#include "igt_core.h"
#include "igt_drm_clients.h"
#include "igt_drm_fdinfo.h"
+#include "igt_profiling.h"
#include "drmtest.h"
enum utilization_type {
@@ -391,10 +392,19 @@ static int parse_args(int argc, char * const argv[], struct gputop_args *args)
return 1;
}
+static volatile bool stop_top;
+
+static void sigint_handler(int sig)
+{
+ (void) sig;
+ stop_top = true;
+}
+
int main(int argc, char **argv)
{
struct gputop_args args;
unsigned int period_us;
+ struct igt_profiled_device *profiled_devices = NULL;
struct igt_drm_clients *clients = NULL;
int con_w = -1, con_h = -1;
int ret;
@@ -413,9 +423,22 @@ int main(int argc, char **argv)
if (!clients)
exit(1);
+
+ profiled_devices = igt_devices_profiled();
+ if (profiled_devices != NULL) {
+ igt_devices_configure_profiling(profiled_devices, true);
+
+ if (signal(SIGINT, sigint_handler) == SIG_ERR) {
+ fprintf(stderr, "Failed to install signal handler!\n");
+ igt_devices_configure_profiling(profiled_devices, false);
+ igt_devices_free_profiling(profiled_devices);
+ profiled_devices = NULL;
+ }
+ }
+
igt_drm_clients_scan(clients, NULL, NULL, 0, NULL, 0);
- while (n != 0) {
+ while ((n != 0) && !stop_top) {
struct igt_drm_client *c, *prevc = NULL;
int i, engine_w = 0, lines = 0;
@@ -443,9 +466,17 @@ int main(int argc, char **argv)
usleep(period_us);
if (n > 0)
n--;
+
+ if (profiled_devices != NULL)
+ igt_devices_update_original_profiling_state(profiled_devices);
}
igt_drm_clients_free(clients);
+ if (profiled_devices != NULL) {
+ igt_devices_configure_profiling(profiled_devices, false);
+ igt_devices_free_profiling(profiled_devices);
+ }
+
return 0;
}
diff --git a/tools/meson.build b/tools/meson.build
index c02c020d0b31..df26c4b95e3f 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -69,7 +69,7 @@ endif
executable('gputop', 'gputop.c',
install : true,
install_rpath : bindir_rpathdir,
- dependencies : [lib_igt_drm_clients,lib_igt_drm_fdinfo,math])
+ dependencies : [lib_igt_drm_clients,lib_igt_drm_fdinfo,lib_igt_profiling,math])
intel_l3_parity_src = [ 'intel_l3_parity.c', 'intel_l3_udev_listener.c' ]
executable('intel_l3_parity', sources : intel_l3_parity_src,
--
2.45.1
next prev parent reply other threads:[~2024-07-16 20:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 20:57 [PATCH v5 0/2] Add gputop support for sysfs profiling knob Adrián Larumbe
2024-07-16 20:57 ` [PATCH v5 1/2] lib: Add DRM driver sysfs profiling knob toggling functions Adrián Larumbe
2024-07-17 13:52 ` Kamil Konieczny
2024-07-16 20:57 ` Adrián Larumbe [this message]
2024-07-17 13:58 ` [PATCH v5 2/2] tools/gputop: toggle sysfs profiling knob if available for device Kamil Konieczny
2024-07-16 21:36 ` ✗ CI.xeBAT: failure for Add gputop support for sysfs profiling knob Patchwork
2024-07-17 14:01 ` Kamil Konieczny
2024-07-16 21:45 ` ✓ Fi.CI.BAT: success " Patchwork
2024-07-16 22:27 ` ✗ CI.xeFULL: failure " Patchwork
2024-07-17 14:02 ` Kamil Konieczny
2024-07-17 6:07 ` ✗ Fi.CI.IGT: " Patchwork
2024-07-17 14:03 ` Kamil Konieczny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240716205756.2973341-3-adrian.larumbe@collabora.com \
--to=adrian.larumbe@collabora.com \
--cc=daniel@ffwll.ch \
--cc=healych@amazon.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=lucas.demarchi@intel.com \
--cc=robdclark@chromium.org \
--cc=tursulin@ursulin.net \
--cc=zbigniew.kempczynski@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox