Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gyeyoung Baek <gye976@gmail.com>
To: igt-dev@lists.freedesktop.org
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Subject: [PATCH i-g-t 3/3] tools/gputop: Show device node and driver name in client header
Date: Sat, 21 Nov 2026 18:41:57 +0900	[thread overview]
Message-ID: <20261121094225.628262-4-gye976@gmail.com> (raw)
In-Reply-To: <20261121094225.628262-1-gye976@gmail.com>

Show the device node name and the driver name in the client header
instead of "DRM minor N".

Before:
  DRM minor 128
  DRM minor 0

After:
  renderD128 (panthor)
  accel0 (rocket)

The minor alone does not tell which device or driver the clients belong
to, and since accel nodes share minor numbers with DRM nodes,
"DRM minor 0" cannot even tell card0 from accel0.

Take the node name from sysfs and the driver name from the drm-driver
fdinfo key.

Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
---
 lib/igt_drm_clients.c |  1 +
 lib/igt_drm_clients.h |  1 +
 tools/gputop.c        | 33 ++++++++++++++++++++++++++++++---
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/lib/igt_drm_clients.c b/lib/igt_drm_clients.c
index 4ab49a6b5..94e27f84b 100644
--- a/lib/igt_drm_clients.c
+++ b/lib/igt_drm_clients.c
@@ -188,6 +188,7 @@ igt_drm_client_add(struct igt_drm_clients *clients,
 
 	c->id = info->id;
 	c->rdev = rdev;
+	snprintf(c->driver, sizeof(c->driver), "%s", info->driver);
 	c->clients = clients;
 
 	/* Engines */
diff --git a/lib/igt_drm_clients.h b/lib/igt_drm_clients.h
index f2a7bab97..54bd12147 100644
--- a/lib/igt_drm_clients.h
+++ b/lib/igt_drm_clients.h
@@ -65,6 +65,7 @@ struct igt_drm_client {
 	struct igt_drm_client_engines *engines; /* Engines used by this client, to map with busynees data. */
 	unsigned long id; /* DRM client id from fdinfo. */
 	dev_t rdev; /* Device number of the DRM or accel node this client fd refers to. */
+	char driver[128]; /* DRM driver name from fdinfo. */
 	unsigned int pid; /* PID which has this DRM fd open. */
 	char pid_str[10]; /* Cached PID representation. */
 	char name[24]; /* Process name of the owning PID. */
diff --git a/tools/gputop.c b/tools/gputop.c
index e89a1e53e..fb1ee0fcf 100644
--- a/tools/gputop.c
+++ b/tools/gputop.c
@@ -252,27 +252,54 @@ static char *get_frequencies(dev_t rdev)
 	return NULL;
 }
 
+/*
+ * Get the device node name (e.g. card0, renderD128) from sysfs, falling back
+ * to the major:minor numbers.
+ */
+static void get_node_name(dev_t rdev, char *buf, size_t size)
+{
+	char path[64];
+	char link[256];
+	const char *name;
+	ssize_t len;
+
+	snprintf(path, sizeof(path), "/sys/dev/char/%u:%u",
+		 major(rdev), minor(rdev));
+	len = readlink(path, link, sizeof(link) - 1);
+	if (len == -1) {
+		snprintf(buf, size, "%u:%u", major(rdev), minor(rdev));
+		return;
+	}
+	link[len] = '\0';
+
+	name = strrchr(link, '/');
+	snprintf(buf, size, "%s", name ? name + 1 : link);
+}
+
 static int
 print_client_header(struct igt_drm_client *c, int lines, int con_w, int con_h,
 		    int *engine_w)
 {
 	int ret, len;
 	char *freq_info = NULL;
+	char node[256];
 
 	if (lines++ >= con_h)
 		return lines;
 
+	get_node_name(c->rdev, node, sizeof(node));
+
 	printf(ANSI_HEADER);
 
 	/* Get frequency information */
 	freq_info = get_frequencies(c->rdev);
 
 	if (freq_info) {
-		ret = printf("DRM minor %u   Frequency(MHz) %s",
-			     minor(c->rdev), freq_info);
+		ret = printf("%s (%s)   Frequency(MHz) %s",
+			     node, c->driver, freq_info);
 		free(freq_info);
 	} else {
-		ret = printf("DRM minor %u", minor(c->rdev));
+		ret = printf("%s (%s)", node, c->driver);
 	}
 
 	n_spaces(con_w - ret);
-- 
2.43.0


      parent reply	other threads:[~2026-11-21  9:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21  9:41 [PATCH i-g-t 0/3] gputop: Support accel devices Gyeyoung Baek
2026-11-21  9:41 ` [PATCH i-g-t 1/3] lib/igt_drm_clients: Track clients by dev_t instead of DRM minor Gyeyoung Baek
2026-11-21  9:41 ` [PATCH i-g-t 2/3] lib/igt_drm_clients: Also scan accel device nodes Gyeyoung Baek
2026-11-21  9:41 ` Gyeyoung Baek [this message]

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=20261121094225.628262-4-gye976@gmail.com \
    --to=gye976@gmail.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=tvrtko.ursulin@igalia.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