[Intel-gfx] [PATCH i-g-t] intel_gpu_top: Improve error message when insufficient privilege

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Tue Feb 1 15:19:46 UTC 2022

From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Print out end user friendly help text when the running user has
insufficient privilege for accessing system wide performance counters.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Issue: https://gitlab.freedesktop.org/drm/intel/-/issues/5018
 tools/intel_gpu_top.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 81c724d1fe1c..0404a5881b40 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -1761,6 +1761,15 @@ int main(int argc, char **argv)
 	if (ret) {
 			"Failed to initialize PMU! (%s)\n", strerror(errno));
+		if (errno == EACCES && geteuid())
+			fprintf(stderr,
+"When running as a normal user CAP_PERFMON is required to access performance\n"
+"monitoring. See \"man 7 capabilities\", \"man 8 setcap\", or contact your\n"
+"distribution vendor for assistance.\n"
+"More information can be found at 'Perf events and tool security' document:\n"
 		ret = EXIT_FAILURE;
 		goto err;

More information about the Intel-gfx mailing list