Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Track clients by tgid and not tid

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

authored by

Tvrtko Ursulin and committed by
Christian König
4230cea8 e2945e6c

+5 -5
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
··· 969 969 * Therefore, we need to protect this ->comm access using RCU. 970 970 */ 971 971 rcu_read_lock(); 972 - task = pid_task(file->pid, PIDTYPE_PID); 972 + task = pid_task(file->pid, PIDTYPE_TGID); 973 973 seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid), 974 974 task ? task->comm : "<unknown>"); 975 975 rcu_read_unlock();
+2 -2
drivers/gpu/drm/drm_debugfs.c
··· 80 80 seq_printf(m, 81 81 "%20s %5s %3s master a %5s %10s\n", 82 82 "command", 83 - "pid", 83 + "tgid", 84 84 "dev", 85 85 "uid", 86 86 "magic"); ··· 94 94 bool is_current_master = drm_is_current_master(priv); 95 95 96 96 rcu_read_lock(); /* locks pid_task()->comm */ 97 - task = pid_task(priv->pid, PIDTYPE_PID); 97 + task = pid_task(priv->pid, PIDTYPE_TGID); 98 98 uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID; 99 99 seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n", 100 100 task ? task->comm : "<unknown>",
+1 -1
drivers/gpu/drm/drm_file.c
··· 156 156 if (!file) 157 157 return ERR_PTR(-ENOMEM); 158 158 159 - file->pid = get_pid(task_pid(current)); 159 + file->pid = get_pid(task_tgid(current)); 160 160 file->minor = minor; 161 161 162 162 /* for compatibility root is always authenticated */
+1 -1
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
··· 241 241 * Therefore, we need to protect this ->comm access using RCU. 242 242 */ 243 243 rcu_read_lock(); 244 - task = pid_task(file->pid, PIDTYPE_PID); 244 + task = pid_task(file->pid, PIDTYPE_TGID); 245 245 seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid), 246 246 task ? task->comm : "<unknown>"); 247 247 rcu_read_unlock();