[PATCH i-g-t v7 0/5] Close any open drm device after engine initialization in GPUTOP

Soham Purkait
2026-01-30T09:58:33Z

During engine initialization for a specific device, the helper
functions require an open card_fd to query engines and configurations
needed to compute engine busyness via PMU. However, KMS tests require
that no other DRM client be active, and keeping card_fd open causes
gputop to appear as a DRM client. Therefore, card_fd is closed immediately
after discovery.
Additionally, this patch removes the lib/xe/* dependency and perform
engine discovery using direct ioctl calls, simplifying the implementation
and reducing external dependencies, while also providing a fallback to
report only client busyness when engine busyness counters are not
accessible to non-root users.

GPUTOP engine busyness is also capable of running without superuser access
through setting CAP_PERFMON or an appropriate perf_event_paranoid setting,
Otherwise user could continue with only GPU client busyness if required.

Steps to enable engine busyness to run without root (using CAP_PERFMON):
$ cd /path/to/igt-gpu-tools/
$ sudo setcap cap_perfmon=+ep $(pwd)/build/tools/gputop
$ sudo sh -c "echo $(pwd)/build/lib > /etc/ld.so.conf.d/lib-igt.conf"
$ sudo ldconfig
Steps to revert once done:
$ sudo setcap cap_perfmon=-ep $(pwd)/build/tools/gputop
$ sudo rm /etc/ld.so.conf.d/lib-igt.conf
$ sudo ldconfig

Steps to enable engine busyness to run without root (using perf_event_paranoid):
# Save current value
$ orig_val=$(sysctl -n kernel.perf_event_paranoid)
# Set the value to allow running GPUTOP without root privileges
$ sudo sysctl -w kernel.perf_event_paranoid=-1
Steps to revert once done:
$ sudo sysctl -w kernel.perf_event_paranoid=$orig_val

Soham Purkait (5):
tools: Rename tools/gputop to tools/gputop.src
tools/gputop.src/utils: Add clamp macro to remove dependency on
lib/xe/*
tools/gputop.src/xe_gputop: Refactor xe_populate_engines to close
card_fd and use direct ioctl calls
tools/gputop.src/gputop: Enable support for multiple GPUs and
instances
tools/gputop.src/gputop: Add command line option for device filter

tools/{ => gputop.src}/gputop.c | 286 +++++++++++++++++++----
tools/gputop.src/meson.build | 1 +
tools/{gputop => gputop.src}/utils.c | 0
tools/{gputop => gputop.src}/utils.h | 11 +-
tools/{gputop => gputop.src}/xe_gputop.c | 100 ++++++--
tools/{gputop => gputop.src}/xe_gputop.h | 3 +-
tools/meson.build | 12 +-
7 files changed, 344 insertions(+), 69 deletions(-)
rename tools/{ => gputop.src}/gputop.c (58%)
create mode 100644 tools/gputop.src/meson.build
rename tools/{gputop => gputop.src}/utils.c (100%)
rename tools/{gputop => gputop.src}/utils.h (89%)
rename tools/{gputop => gputop.src}/xe_gputop.c (83%)
rename tools/{gputop => gputop.src}/xe_gputop.h (95%)

--
2.34.1