Re: [RFC 02/13] drm: Track clients by tgid and not tid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2022-11-11 at 10:44 +0000, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
> 
> 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@xxxxxxxxx>
> Cc: Zack Rusin <zackr@xxxxxxxxxx>
> Cc: linux-graphics-maintainer@xxxxxxxxxx
> Cc: Alex Deucher <alexander.deucher@xxxxxxx>
> Cc: "Christian König" <christian.koenig@xxxxxxx>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +-
>  drivers/gpu/drm/drm_debugfs.c           | 4 ++--
>  drivers/gpu/drm/drm_file.c              | 2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_gem.c     | 2 +-
>  4 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> index 8ef31d687ef3..4b940f8bd72b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> @@ -967,7 +967,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();
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index ee445f4605ba..42f657772025 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -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>",
> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
> index ba5041137b29..5cde5014cea1 100644
> --- a/drivers/gpu/drm/drm_file.c
> +++ b/drivers/gpu/drm/drm_file.c
> @@ -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 */
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
> b/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
> index ce609e7d758f..f2985337aa53 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
> @@ -260,7 +260,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();


Yea, that probably makes a lot more sense. Looks good.

Reviewed-by: Zack Rusin <zackr@xxxxxxxxxx>




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux