From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: [igt-dev] [PATCH i-g-t 3/8] lib/igt_drm_clients: Record client drm minor
Date: Tue, 31 Jan 2023 11:32:32 +0000 [thread overview]
Message-ID: <20230131113237.3707217-4-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20230131113237.3707217-1-tvrtko.ursulin@linux.intel.com>
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Prepare for supporting clients belonging to multiple DRM cards by storing
the DRM minor in the client record.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
lib/igt_drm_clients.c | 22 ++++++++++++++--------
lib/igt_drm_clients.h | 1 +
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/lib/igt_drm_clients.c b/lib/igt_drm_clients.c
index eabd43773f2d..c23a3fae9793 100644
--- a/lib/igt_drm_clients.c
+++ b/lib/igt_drm_clients.c
@@ -115,7 +115,7 @@ igt_drm_client_update(struct igt_drm_client *c, unsigned int pid, char *name,
static void
igt_drm_client_add(struct igt_drm_clients *clients,
const struct drm_client_fdinfo *info,
- unsigned int pid, char *name)
+ unsigned int pid, char *name, unsigned int drm_minor)
{
struct igt_drm_client *c;
@@ -140,6 +140,7 @@ igt_drm_client_add(struct igt_drm_clients *clients,
}
c->id = info->id;
+ c->drm_minor = drm_minor;
c->clients = clients;
c->val = calloc(clients->num_classes, sizeof(c->val));
c->last = calloc(clients->num_classes, sizeof(c->last));
@@ -286,16 +287,21 @@ static bool get_task_name(const char *buffer, char *out, unsigned long sz)
return true;
}
-static bool is_drm_fd(int fd_dir, const char *name)
+static bool is_drm_fd(int fd_dir, const char *name, unsigned int *minor)
{
struct stat stat;
int ret;
ret = fstatat(fd_dir, name, &stat, 0);
- return ret == 0 &&
- (stat.st_mode & S_IFMT) == S_IFCHR &&
- major(stat.st_rdev) == 226;
+ if (ret == 0 &&
+ (stat.st_mode & S_IFMT) == S_IFCHR &&
+ major(stat.st_rdev) == 226) {
+ *minor = minor(stat.st_rdev);
+ return true;
+ }
+
+ return false;
}
/**
@@ -348,10 +354,10 @@ igt_drm_clients_scan(struct igt_drm_clients *clients,
return clients;
while ((proc_dent = readdir(proc_dir)) != NULL) {
+ unsigned int client_pid, minor = 0;
int pid_dir = -1, fd_dir = -1;
struct dirent *fdinfo_dent;
char client_name[64] = { };
- unsigned int client_pid;
DIR *fdinfo_dir = NULL;
char buf[4096];
size_t count;
@@ -393,7 +399,7 @@ igt_drm_clients_scan(struct igt_drm_clients *clients,
if (!isdigit(fdinfo_dent->d_name[0]))
continue;
- if (!is_drm_fd(fd_dir, fdinfo_dent->d_name))
+ if (!is_drm_fd(fd_dir, fdinfo_dent->d_name, &minor))
continue;
if (!__igt_parse_drm_fdinfo(dirfd(fdinfo_dir),
@@ -412,7 +418,7 @@ igt_drm_clients_scan(struct igt_drm_clients *clients,
info.id);
if (!c)
igt_drm_client_add(clients, &info, client_pid,
- client_name);
+ client_name, minor);
else
igt_drm_client_update(c, client_pid,
client_name, &info);
diff --git a/lib/igt_drm_clients.h b/lib/igt_drm_clients.h
index bced19adb055..ffa219c9c9fd 100644
--- a/lib/igt_drm_clients.h
+++ b/lib/igt_drm_clients.h
@@ -44,6 +44,7 @@ struct igt_drm_client {
enum igt_drm_client_status status;
unsigned int id; /* DRM client id from fdinfo. */
+ unsigned int drm_minor; /* DRM minor of this client. */
unsigned int pid; /* PID which has this DRM fd open. */
char name[24]; /* Process name of the owning PID. */
char print_name[24]; /* Name without any non-printable characters. */
--
2.34.1
next prev parent reply other threads:[~2023-01-31 11:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-31 11:32 [igt-dev] [PATCH i-g-t v3 0/8] Vendor agnostic gputop Tvrtko Ursulin
2023-01-31 11:32 ` [igt-dev] [PATCH i-g-t 1/8] lib: Extract igt_drm_clients from intel_gpu_top Tvrtko Ursulin
2023-01-31 11:32 ` [igt-dev] [PATCH i-g-t 2/8] lib: Allow specifying custom engine map Tvrtko Ursulin
2023-01-31 11:32 ` Tvrtko Ursulin [this message]
2023-01-31 11:32 ` [igt-dev] [PATCH i-g-t 4/8] lib/igt_drm_clients: Support multiple DRM cards Tvrtko Ursulin
2023-01-31 11:32 ` [igt-dev] [PATCH i-g-t 5/8] lib/igt_drm_fdinfo: Track largest engine index Tvrtko Ursulin
2023-01-31 11:32 ` [igt-dev] [PATCH i-g-t 6/8] lib/igt_drm_clients: Decouple hardcoded engine assumptions Tvrtko Ursulin
2023-01-31 11:32 ` [igt-dev] [PATCH i-g-t 7/8] lib/igt_drm_clients: Enforce client status sort order in the library Tvrtko Ursulin
2023-01-31 11:32 ` [igt-dev] [PATCH i-g-t 8/8] gputop: Basic vendor agnostic GPU top tool Tvrtko Ursulin
2023-02-03 16:42 ` Kamil Konieczny
2023-02-06 9:19 ` Tvrtko Ursulin
2023-02-06 14:04 ` Kamil Konieczny
2023-04-05 17:57 ` Rob Clark
2023-04-06 11:08 ` Tvrtko Ursulin
2023-04-06 14:21 ` Rob Clark
2023-04-06 14:31 ` Tvrtko Ursulin
2023-05-12 14:18 ` Rob Clark
2023-05-15 11:10 ` Tvrtko Ursulin
2023-01-31 12:14 ` [igt-dev] ✓ Fi.CI.BAT: success for Vendor agnostic gputop (rev5) Patchwork
2023-01-31 15:55 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2023-04-06 14:15 [igt-dev] [PATCH i-g-t v4 0/8] Vendor agnostic gputop Tvrtko Ursulin
2023-04-06 14:15 ` [igt-dev] [PATCH i-g-t 3/8] lib/igt_drm_clients: Record client drm minor Tvrtko Ursulin
2023-04-17 10:57 [igt-dev] [PATCH i-g-t v5 0/8] Vendor agnostic gputop Tvrtko Ursulin
2023-04-17 10:57 ` [igt-dev] [PATCH i-g-t 3/8] lib/igt_drm_clients: Record client drm minor Tvrtko Ursulin
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=20230131113237.3707217-4-tvrtko.ursulin@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=igt-dev@lists.freedesktop.org \
--cc=tvrtko.ursulin@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