From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tvrtko Ursulin Subject: [RFC 01/12] drm: Track clients by tgid and not tid Date: Thu, 12 Jan 2023 16:55:58 +0000 Message-ID: <20230112165609.1083270-2-tvrtko.ursulin@linux.intel.com> References: <20230112165609.1083270-1-tvrtko.ursulin@linux.intel.com> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673542639; x=1705078639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aC20zrLtbmafnfXUOIpvUqX1idswNb59e1zqrjldwBE=; b=DBJcLer0BepSz4kg4NE2/Tf4bwnThF4kBEwnQg9nYtdnOuv6vcqVfHGU Lbjuj+AoHLSVrJfzSVet9NAKvmeosB7HaXLtCdjNIX/4XXva0VKwqIF+g gvw0Tdzx2uABvH6NMoOns0yFlqDVQWfji2MiDQq0NEw3y+Gyo6dJNi84P LlGEaCTQnCkyQikimlaDtK2Y2GKTBdtiAkSVuHaJn44qOGvQs4gzoXCg+ XGz0wNtWdt03LXoDLELurJoNJofsXh7fQlWBtfmfOq+WFRb8t0gGtEgAd iBkv5mekHXpIZ5S7ejqE3DfIeoR3b6SZFqJF8xmFAVGXW5c84YbcUPyFF g==; In-Reply-To: <20230112165609.1083270-1-tvrtko.ursulin@linux.intel.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Content-Type: text/plain; charset="iso-8859-1" To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Rob Clark , Kenny.Ho@amd.com, Daniel Vetter , Johannes Weiner , linux-kernel@vger.kernel.org, =?UTF-8?q?St=C3=A9phane=20Marchesin?= , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , linux-graphics-maintainer@vmware.com, Zefan Li , Dave Airlie , Tejun Heo , cgroups@vger.kernel.org, "T . J . Mercier" , Zack Rusin From: Tvrtko Ursulin 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 Cc: Zack Rusin Cc: linux-graphics-maintainer@vmware.com Cc: Alex Deucher Cc: "Christian K=C3=B6nig" Reviewed-by: Zack Rusin --- 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 00edc7002ee8..ca0181332578 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -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 =3D pid_task(file->pid, PIDTYPE_PID); + task =3D pid_task(file->pid, PIDTYPE_TGID); seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid), task ? task->comm : ""); rcu_read_unlock(); diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 4f643a490dc3..4855230ba2c6 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 *dat= a) 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 *dat= a) bool is_current_master =3D drm_is_current_master(priv); =20 rcu_read_lock(); /* locks pid_task()->comm */ - task =3D pid_task(priv->pid, PIDTYPE_PID); + task =3D pid_task(priv->pid, PIDTYPE_TGID); uid =3D task ? __task_cred(task)->euid : GLOBAL_ROOT_UID; seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n", task ? task->comm : "", diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index a51ff8cee049..c1018c470047 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); =20 - file->pid =3D get_pid(task_pid(current)); + file->pid =3D get_pid(task_tgid(current)); file->minor =3D minor; =20 /* for compatibility root is always authenticated */ diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c b/drivers/gpu/drm/vmwgfx/v= mwgfx_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 =3D pid_task(file->pid, PIDTYPE_PID); + task =3D pid_task(file->pid, PIDTYPE_TGID); seq_printf(m, "pid %8d command %s:\n", pid_nr(file->pid), task ? task->comm : ""); rcu_read_unlock(); --=20 2.34.1