drm: Track clients by tgid and not tid
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Tue, 14 Mar 2023 14:18:55 +0000 (14:18 +0000)
committerChristian König <christian.koenig@amd.com>
Wed, 15 Mar 2023 13:03:00 +0000 (14:03 +0100)
Thread group id (aka pid from userspace point of view) is a more
interesting thing to show as an owner of a DRM fd, so track and show that
instead of the thread id.

In the next patch we will make the owner updated post file descriptor
handover, which will also be tgid based to avoid ping-pong when multiple
threads access the fd.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230314141904.1210824-2-tvrtko.ursulin@linux.intel.com
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
drivers/gpu/drm/drm_debugfs.c
drivers/gpu/drm/drm_file.c
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c

index d8e683688daab516833dd8d6c423082db4f6b485..863cb668e0005d5694b473ea7b72a906061a1b2b 100644 (file)
@@ -969,7 +969,7 @@ static int amdgpu_debugfs_gem_info_show(struct seq_file *m, void *unused)
                 * Therefore, we need to protect this ->comm access using RCU.
                 */
                rcu_read_lock();
-               task = pid_task(file->pid, PIDTYPE_PID);
+               task = pid_task(file->pid, PIDTYPE_TGID);
                seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid),
                           task ? task->comm : "<unknown>");
                rcu_read_unlock();
index 4f643a490dc3989b7b8e4eb867053ed3a896305a..4855230ba2c6ca062bea78ad53cd3c7c591dd1a0 100644 (file)
@@ -80,7 +80,7 @@ static int drm_clients_info(struct seq_file *m, void *data)
        seq_printf(m,
                   "%20s %5s %3s master a %5s %10s\n",
                   "command",
-                  "pid",
+                  "tgid",
                   "dev",
                   "uid",
                   "magic");
@@ -94,7 +94,7 @@ static int drm_clients_info(struct seq_file *m, void *data)
                bool is_current_master = drm_is_current_master(priv);
 
                rcu_read_lock(); /* locks pid_task()->comm */
-               task = pid_task(priv->pid, PIDTYPE_PID);
+               task = pid_task(priv->pid, PIDTYPE_TGID);
                uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID;
                seq_printf(m, "%20s %5d %3d   %c    %c %5d %10u\n",
                           task ? task->comm : "<unknown>",
index a51ff8cee0494bd908cce56cde7e5e9f36cc735c..c1018c4700479225750217c9a77278ca681abd0e 100644 (file)
@@ -156,7 +156,7 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor)
        if (!file)
                return ERR_PTR(-ENOMEM);
 
-       file->pid = get_pid(task_pid(current));
+       file->pid = get_pid(task_tgid(current));
        file->minor = minor;
 
        /* for compatibility root is always authenticated */
index d6baf73a64589ab6fdf1e8264907e1d8259bfbaf..c0da89e16e6fa765e21f040a2ba63a2c2b4f83bf 100644 (file)
@@ -241,7 +241,7 @@ static int vmw_debugfs_gem_info_show(struct seq_file *m, void *unused)
                 * Therefore, we need to protect this ->comm access using RCU.
                 */
                rcu_read_lock();
-               task = pid_task(file->pid, PIDTYPE_PID);
+               task = pid_task(file->pid, PIDTYPE_TGID);
                seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid),
                           task ? task->comm : "<unknown>");
                rcu_read_unlock();