From patchwork Mon Sep 16 13:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Eric Pelloux-Prayer X-Patchwork-Id: 13805440 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14975C3ABB2 for ; Mon, 16 Sep 2024 13:32:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 805CC10E36C; Mon, 16 Sep 2024 13:32:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="EKFemAxX"; dkim-atps=neutral Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2075.outbound.protection.outlook.com [40.107.100.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 00AAD10E36A for ; Mon, 16 Sep 2024 13:32:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vXkrLEMiO3qj4FnnlLBtZd5r08GiuyfkqW7y+NKNsSQrV3yEhQTS3qXVXcDoJfydX0hI6PJXGgTyRU0Ajq/VO1Hk7f16uLyn8AVbyn2OPxRSl+eqw3e2cDTVjDJbGgrs3rclFi2iwMS2iFrTjYK2UOPszcomBaqCf1ZoHXslzzWz0hutjfVeouRWSnxPzMuoRcMr38hsoAUi3ctzl6ln1vVrElrY7DyufluFp9dJkCcsn9bL1OyCr7eDGkeSPKlLHEyWj+Fadx1uXC84DK+LML1cxHH6KS7p943hoEqLJNQxkhEkNe6guynpz5RkZ7uv71AgNE7MuoRT8qSFxoGxcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mxBin7TpvrxHy4N5ztwKpib9uUQIoIcYM4Ix/WmF9M8=; b=KRWhbbzs5+xX5mAM95WZKuQhVr46eXKkta1G+Rd4O7L5jyJMZoGzbo5tVLVCRtkdnLSZw9QRFHVjBA8H4SvcJNAxp7+qduqf68gPh0bC00HTtE1h/S1daGBvE9xdk2zQPuEiW+hiJPXX0mro29+aIc4VpzxPDt7qLmfK1bqikztneQ63XNXU05WwWbVpQ0UrOVo6gLrmENI3HQECNJ91EmfAlYJUJRdVk1a6WM6iWmpWG+FMdMCfGmBaiKFQMLAmDR4YpPlbx2vDZLrRD/bUXQWn4ITQSS7IH4DiH1XfiFcQ+CngfrxDrY9B6gMlxAXBlK/uEyu7u1y/71L8eWkjJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mxBin7TpvrxHy4N5ztwKpib9uUQIoIcYM4Ix/WmF9M8=; b=EKFemAxXf8sstTPARPWKsesUqUF20riQH845EpweGc45wR9h8B07UsWc8Q1Y3CillBs72YPiMT6sqtZo6WTxuZUoikUvRIIzbfY6iSVUICKq5//4FG7cqP/7ILdmq1Kzv9NkRyEv9U5yrdZBnRITvpXXT2tX/uK8ssbdh72J484= Received: from BN9PR03CA0559.namprd03.prod.outlook.com (2603:10b6:408:138::24) by SN7PR12MB6766.namprd12.prod.outlook.com (2603:10b6:806:26a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.23; Mon, 16 Sep 2024 13:32:43 +0000 Received: from BL6PEPF0001AB73.namprd02.prod.outlook.com (2603:10b6:408:138:cafe::cf) by BN9PR03CA0559.outlook.office365.com (2603:10b6:408:138::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.25 via Frontend Transport; Mon, 16 Sep 2024 13:32:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB73.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Mon, 16 Sep 2024 13:32:42 +0000 Received: from patedamande.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 16 Sep 2024 08:32:40 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v2 1/3] drm: add DRM_SET_NAME ioctl Date: Mon, 16 Sep 2024 15:32:18 +0200 Message-ID: <20240916133223.1023773-1-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB73:EE_|SN7PR12MB6766:EE_ X-MS-Office365-Filtering-Correlation-Id: 8543d392-412f-47fc-d3a4-08dcd6540b02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: Cj89A9YxtmjdMrKj1CXDzDB6OAkqA56ETlWveVA9QVJZW9c280TA4pRC+VRTTVmzBH8jaBAffEHaJY7ttSJkMaOpBDOKnk8jIcjCLNCMTWVnhVjI0ZF03ft99/lxigDoHVtg01ybzw7qir/8svrcM0dc9N5whvkSV1SYcKbHR8Es4hAXEv0bnTBPixMV1PFDV0xum2preHw7Tggx3uqzQI6nHEmu1eA2JGM2qyZq1KoBIHDxt9pzAclsppnpGznUmPw1d56nLFCsV67aj/onBa2ZcI/paYaF86q6yQd+QaDx3FO3H89LUDeQY3y8GFEdR9B539XUJD+CLO+IKG+oNQy8gdbCNwzBtp6chSVe+gE5b0uzjx3UXRcd0gxZCRFTYc7zdR83OnkRL+uPQMZsarGL29YmcmqgkT/Ar2DVaG3YYdrn7vDbdN0IQ6ACkAKmkerAPFb1zx36augffPVr4DUKwY8MvuYKqeQT9FIa/woivlsdhe0NGN7LDaHQ6ZRK+gg1gzkGP0vAp1gSkhvEJ+BPEjWlMWc2mzHj86IWpVWRgP/rVUyjEJKxfsKGMlcu0BP6DuWFw29kaovxKALuPI7VotZUvy/les6GBJgqEeo9P1wZ+ZfEeBPKORg0wu5jDAlKiQQRjzUYuaP4iyOjZIZ4gKwdnHzjnYyHNbgaqUWFsMZKBsQo0L7YTwPL3s0gQ1zAtFjQ7+9bqwlB5QhVWwQGM7klAmpUctYUId2KjoKc7hze91PrP5zklz+AGyUmtQkMFLAWsyErOhv8GEInlUyQs0OTI37uTYOAhvdz+tnkXxzPE12WMHmS0TAHQ+YC8ovNtW+6dsRU2+60GBDVwpW3NSK9V7qbVfeFQt1F6K2flTfRHxTbPxdqPj0f8l2wFsxQY1XkS8tuByV59hideZEIH8LViqO0tFgYXTYv4/Sgys56UAipeILFen7evyuiIop9gq59H9mAVOQAlMciIfmy9PhU8A3MNQtLhuXJZ7PX8Gf48cA4b2oOnY/oVO6mXoQdNfZLgV6FiZJXRQIAkaAOHAOYvx5oPG395PsMqUO0zGAHwMZX1J4axeCnTm7X0hn3ewTkrvXs9zHPR7TEcNB2JGYTdLyuRvGK4uvnZ3Xn5A59cb/Yv0IKch8/DJYsWRJj3+7D8etlVycvAqJKcdscffSejYY1N6qbhWdFaxhOEMw086B+Iwy+xBGfXn7o/USchxfNOLM9v7LBNyFd3vGYtiDxd66njyB5t/dxiAXu2MZMkMadMzyHUwJGAi5weJ1yq3kd/px5GNGElRw8ejlS/TfoFhcoYOUJDsbjDIy426CO8YasyuMVvOSRrnis34ZGD1WL0PxcfgXVtUW//WmRHRzxyND8KBr7qt26r5Hn1ym2kACZvbbkQw57pP3D X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2024 13:32:42.9474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8543d392-412f-47fc-d3a4-08dcd6540b02 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB73.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6766 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Giving the opportunity to userspace to associate a free-form name with a drm_file struct is helpful for tracking and debugging. This is similar to the existing DMA_BUF_SET_NAME ioctl. Access to name is protected by a mutex, and the 'clients' debugfs file has been updated to print it. Userspace MR to use this ioctl: https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1428 The string passed by userspace is filtered a bit, to avoid messing output when it's going to be printed (in dmesg, fdinfo, etc): * all chars failing isgraph() are replaced by '-' * if a 0-length string is passed the name is cleared Signed-off-by: Pierre-Eric Pelloux-Prayer --- drivers/gpu/drm/drm_debugfs.c | 12 ++++++---- drivers/gpu/drm/drm_file.c | 5 +++++ drivers/gpu/drm/drm_ioctl.c | 42 +++++++++++++++++++++++++++++++++++ include/drm/drm_file.h | 9 ++++++++ include/uapi/drm/drm.h | 14 ++++++++++++ 5 files changed, 78 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 6b239a24f1df..b7492225ae88 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -78,12 +78,13 @@ static int drm_clients_info(struct seq_file *m, void *data) kuid_t uid; seq_printf(m, - "%20s %5s %3s master a %5s %10s\n", + "%20s %5s %3s master a %5s %10s %20s\n", "command", "tgid", "dev", "uid", - "magic"); + "magic", + "name"); /* dev->filelist is sorted youngest first, but we want to present * oldest first (i.e. kernel, servers, clients), so walk backwardss. @@ -94,19 +95,22 @@ static int drm_clients_info(struct seq_file *m, void *data) struct task_struct *task; struct pid *pid; + mutex_lock(&priv->name_lock); rcu_read_lock(); /* Locks priv->pid and pid_task()->comm! */ pid = rcu_dereference(priv->pid); task = pid_task(pid, PIDTYPE_TGID); uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID; - seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n", + seq_printf(m, "%20s %5d %3d %c %c %5d %10u %20s\n", task ? task->comm : "", pid_vnr(pid), priv->minor->index, is_current_master ? 'y' : 'n', priv->authenticated ? 'y' : 'n', from_kuid_munged(seq_user_ns(m), uid), - priv->magic); + priv->magic, + priv->name ? priv->name : ""); rcu_read_unlock(); + mutex_unlock(&priv->name_lock); } mutex_unlock(&dev->filelist_mutex); return 0; diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 01fde94fe2a9..e9dd0e90a1f9 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -158,6 +158,7 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor) spin_lock_init(&file->master_lookup_lock); mutex_init(&file->event_read_lock); + mutex_init(&file->name_lock); if (drm_core_check_feature(dev, DRIVER_GEM)) drm_gem_open(dev, file); @@ -259,6 +260,10 @@ void drm_file_free(struct drm_file *file) WARN_ON(!list_empty(&file->event_list)); put_pid(rcu_access_pointer(file->pid)); + + mutex_destroy(&file->name_lock); + kfree(file->name); + kfree(file); } diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 51f39912866f..b7d7bede0ab3 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -540,6 +540,46 @@ int drm_version(struct drm_device *dev, void *data, return err; } +static int drm_set_name(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + struct drm_set_name *name = data; + void *user_ptr; + char *new_name; + size_t i, len; + + if (name->name_len >= NAME_MAX) + return -EINVAL; + + user_ptr = u64_to_user_ptr(name->name); + + new_name = memdup_user_nul(user_ptr, name->name_len); + + if (IS_ERR(new_name)) + return PTR_ERR(new_name); + + /* Filter out control char / spaces / new lines etc in the name + * since it's going to be used in dmesg or fdinfo's output. + */ + len = strlen(new_name); + for (i = 0; i < len; i++) { + if (!isgraph(new_name[i])) + new_name[i] = '-'; + } + + mutex_lock(&file_priv->name_lock); + kfree(file_priv->name); + if (len > 0) { + file_priv->name = new_name; + } else { + kfree(new_name); + file_priv->name = NULL; + } + mutex_unlock(&file_priv->name_lock); + + return 0; +} + static int drm_ioctl_permit(u32 flags, struct drm_file *file_priv) { /* ROOT_ONLY is only for CAP_SYS_ADMIN */ @@ -610,6 +650,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_PRIME_HANDLE_TO_FD, drm_prime_handle_to_fd_ioctl, DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_PRIME_FD_TO_HANDLE, drm_prime_fd_to_handle_ioctl, DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SET_NAME, drm_set_name, DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANERESOURCES, drm_mode_getplane_res, 0), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, 0), DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER), diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index 8c0030c77308..df26eee8f79c 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -388,6 +388,15 @@ struct drm_file { * Per-file buffer caches used by the PRIME buffer sharing code. */ struct drm_prime_file_private prime; + + /** + * @name: + * + * Userspace-provided name; useful for accounting and debugging. + */ + const char *name; + /** @name_lock: Protects @name. */ + struct mutex name_lock; }; /** diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 16122819edfe..fc62bb21f79e 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -1024,6 +1024,12 @@ struct drm_crtc_queue_sequence { __u64 user_data; /* user data passed to event */ }; +struct drm_set_name { + __u64 name_len; + __u64 name; +}; + + #if defined(__cplusplus) } #endif @@ -1288,6 +1294,14 @@ extern "C" { */ #define DRM_IOCTL_MODE_CLOSEFB DRM_IOWR(0xD0, struct drm_mode_closefb) +/** + * DRM_IOCTL_SET_NAME - Attach a name to a drm_file + * + * This ioctl is similar to DMA_BUF_SET_NAME - it allows for easier tracking + * and debugging. + */ +#define DRM_IOCTL_SET_NAME DRM_IOWR(0xD1, struct drm_set_name) + /* * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f. From patchwork Mon Sep 16 13:32:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre-Eric Pelloux-Prayer X-Patchwork-Id: 13805439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DCDE5C3ABB2 for ; Mon, 16 Sep 2024 13:32:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EFB210E36A; Mon, 16 Sep 2024 13:32:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="iWs9Fc3h"; dkim-atps=neutral Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2062.outbound.protection.outlook.com [40.107.95.62]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC6E610E36A for ; Mon, 16 Sep 2024 13:32:48 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Chj2x4enfY4kdJLzppV29vZjjXsmOy6YvJou5mjCyTDHxmqbUehzzdjMc0BNDDtYtAZfmfxIGWhBcUtzEgR0UJ9usU0WQ/Ql5TvJ067xKGt2oZnZTpikM+PLh0qtTNkYd9Eype/eyReJzV0rKdd6nDlWdWTNERPDuoevhs2ltHBoTgq2u8mg69JkaHZPRWgbNo6wNvAohDBOZU0NJhzlxIXYgSR9AIOuIm5qSg6z5wCWvm9ipjGYxHrEMianbcozUZUsAZE7ymIG7KOUNqEf+LKVXcZifBkSi7wrNZ4o3LU2gv24od8iY64XiXioCaU8FZzGyyZmCucZ2HilVpbtLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aMO43FFRdWMXeU1mrRzowYjSmO8hoiIQrOvxuMHVUJ4=; b=HgUzL7ANwzzIZmXKfGwKQRuH4rHaqplyt2LGK3G8h9JQlI+fXf0ExGzP5eZyuHbIGUtuKsiptSdJt6aV+7Ybw/x9Dgt5rhMn/HAB0jfkxtogyyg25MAlGsxLOsHXDyztnX1o/9UhDPV72ilmUkvt1ySr1lX7enBveMmeo0f4Nk12lyw0AuimzKEM0JA5GteSI9De78qkTCpnLrwMzCOAPaDyS4EzUrXXJCkAnUdlEPHZfoM8+JbPJFTb+4hjB4Q2GVaLJaxoFF9QY8WmTGr7bKxEapWAETzyzWMfGYg3xuU1+oIvuQ1TaG+Ulb86cUEidlDGizaI4WditpLB60rQ9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aMO43FFRdWMXeU1mrRzowYjSmO8hoiIQrOvxuMHVUJ4=; b=iWs9Fc3haDUsEefu7qVp9yi7PJdsqDK1cXCk098MGO024xJ5U/EgpoLQr/VUfmZGGvEmHJNl6nF5xTi9RAwHICuVU0J53RL0nWoZl8hLGuglkH0s58kgoTdY4oelO0cYKcR/m4oK/f4ThuoqcFIOCBST1GM5N/O3/S/t+kxldzI= Received: from BN0PR03CA0050.namprd03.prod.outlook.com (2603:10b6:408:e7::25) by IA1PR12MB7615.namprd12.prod.outlook.com (2603:10b6:208:428::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Mon, 16 Sep 2024 13:32:44 +0000 Received: from BL6PEPF0001AB78.namprd02.prod.outlook.com (2603:10b6:408:e7:cafe::71) by BN0PR03CA0050.outlook.office365.com (2603:10b6:408:e7::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Mon, 16 Sep 2024 13:32:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB78.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Mon, 16 Sep 2024 13:32:44 +0000 Received: from patedamande.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 16 Sep 2024 08:32:42 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v2 2/3] drm: use drm_file name in fdinfo Date: Mon, 16 Sep 2024 15:32:19 +0200 Message-ID: <20240916133223.1023773-2-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240916133223.1023773-1-pierre-eric.pelloux-prayer@amd.com> References: <20240916133223.1023773-1-pierre-eric.pelloux-prayer@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB78:EE_|IA1PR12MB7615:EE_ X-MS-Office365-Filtering-Correlation-Id: 60daa1a7-95a6-4804-9c67-08dcd6540bf2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: vOBIYTBO4Q5VEM/z65nyGYKg/jWt88u2MhDoKFhdEy8G4KwSpsLkTPBqAshxmV4IOQtR0zqNQT8e3SGQKaBaTlB3Ee252ZXuNje6kaYdTQi6HEYI2xtLDTzudjaJjqtfXz1fAkQaoPE6bX5YAWcLdT3MNR/IQXlyqMLDKUvteFMNjmZSfx3dxQOEmQG0eLwvkfpN2Q+7ugBgw6wMZwEvjCaHpFhVqf9BFvatYNg70IKFoP8G2TWekNu9qkCFVt+P3mcyL1KWm5ddeQKrKM3cmwXmufSFGWx+uk21xq/wpKggyfoOWmRPutbmwRYJ2scyMVaDkDMhX5sy/G82mJw4CQ2XNK4pcWxftqIRXpVUvdsximv41GfNZSX5ZJVdje2XfFOEpm1Ki6CK989aGHN0xZCv4OewTLPfaXrOT24mM4+4X1gNP3C/Q8pUgiR4ddceNrjgbBzdYkU2Uw1WCC+Lgl4axHXFHqqS9MUPTWstdl757dLQMCWrX1Nmma2emCMl7gc7BFZxUXahwJ5WGXPTRi4aPomLfKdpr0DxFbLxazvB+1d4+lFAMCpMjl7YLVg+j54UiYXK24rmRWDX16JTsrX6igUID8ugxxeC+jbobUmISnkkxda7nSHLlWLXwQ5kN5R4mvxhck/INUoGR4+QR8yEALAwdZjDMURTcre4rO60BbAkdnd1/weIvanmb5X0Mkdy+ywwa814fa15hvONzIC/fwuNT1Iv/n3bwIL66Z22VVrSEfyO701rmHq9SnzI6V4swvOXdR4BqlFNqSANVzpGLJV8r+tkx9feX+4HQZnDcDEiKmQoG5FH2CPH/2VAuld0INNs8rs/3ph/dT0VijTcpMnYNTlP4zx1Z0ZxQnB6e29P2KEdPCAbpCoWGacArOcA/YqdDIHDZNxuDAF//Hk4z1EJxcglXRmB+RcOWakQ1rg2+BxRimsQ2FL/qdkt9vs9xocaZU4Kxg+j1tSUvfqqjCi1Bd73iuj7R/2VIcwq6rLFCZ8T2rGMLvnGk3Fb3Qd9eJGIO9ty9QNHseGoke65IAEMzRXzwLNwd/EjR3CKgRBAakecHY16IEcFo5Qqgj02rjmxRzTin1Cf5FbT1vs9Lx9fbSPw0tlon3XHOiQDwiSY8JkjzEWi00SpwBdiGwtv48h+FTqheCSFdj6GRrRFNYkY8GyDU2gNq54+gI548wZfMb3r2ka+SRQimEBacIByUZ/j6VQPdqD48yNm418jIiPqWX4NaVzJ39JdkDqgJhDb6VSNUgGTBT9cB7GDucbRThX4UPqcDswPgHBa9utRqr8fuIRnXLw3WoUsyeVlYoWXaq9wH+BFNguzi+EhrDOqy5IA6/An9g0ovUgPgwHHut6Zh4HUwgsu2+kYelBIOgGSCTTJEjFGSVswssuAkvM60wG2ADCqUZGSGDYRarPt6rA7XMgok7EBps3opaYeZhk0EkDqzIC8kjOePcvS X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2024 13:32:44.5188 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60daa1a7-95a6-4804-9c67-08dcd6540bf2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB78.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7615 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add an optional drm-client-name field to drm fdinfo's output. Signed-off-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Christian König Reviewed-by: Tvrtko Ursulin --- Documentation/gpu/drm-usage-stats.rst | 5 +++++ drivers/gpu/drm/drm_file.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst index a80f95ca1b2f..ed1d7edbbc5f 100644 --- a/Documentation/gpu/drm-usage-stats.rst +++ b/Documentation/gpu/drm-usage-stats.rst @@ -73,6 +73,11 @@ scope of each device, in which case `drm-pdev` shall be present as well. Userspace should make sure to not double account any usage statistics by using the above described criteria in order to associate data to individual clients. +- drm-client-name: + +String optionally set by userspace using DRM_IOCTL_SET_NAME. + + Utilization ^^^^^^^^^^^ diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index e9dd0e90a1f9..6a3621f50784 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -955,6 +955,11 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f) PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); } + mutex_lock(&file->name_lock); + if (file->name) + drm_printf(&p, "drm-client-name:\t%s\n", file->name); + mutex_unlock(&file->name_lock); + if (dev->driver->show_fdinfo) dev->driver->show_fdinfo(&p, file); } From patchwork Mon Sep 16 13:32:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Eric Pelloux-Prayer X-Patchwork-Id: 13805441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 72D62C3ABA2 for ; Mon, 16 Sep 2024 13:32:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F55A10E36B; Mon, 16 Sep 2024 13:32:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="DWF4nGlh"; dkim-atps=neutral Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2044.outbound.protection.outlook.com [40.107.95.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 29A9E10E36C for ; Mon, 16 Sep 2024 13:32:51 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HGlJib+7tKTcxwID4owc7QPSiE3Zw/4VBaUXqZ+0TdAl1v8qChF5tvRZzShq9Gx6Km6WNAP58CRKRj+BiWn3yfaceK+YgCqgCYSrOqzwxrXkwBCaK/LlyFJWiVoQ2ab69oh9yPRVGgRud2gjatoTf/Ob9GGOwgrwSkWE9D+jE09rFVX9uFZRjNoCmJEoUstXPhh/8nGc2WS5un2N17jbVWfKQC7U772tmhfGVwX4t7964j4WARwvb6d8ywcHNcVNS3RDw2Eor2rpIvaKOhoBZBcZEneVK4MkD0gy15WR9XjtiO/84QabGu7XsH6cOP5pc8bUmM1B+o0rgpF2ol4pWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U3bkblEfbxCTfGa+hLazBLN9IC5sG4y/zPKsY4CQH+4=; b=Ugh61GD9bJHgdEUGQjm7gExHcyFflSxmx3K7gqRne7HmA9OCsQyJo1pXqdx9Z2WoutMYE8H1H557f5RTNzZI2LYWjNwY/7DxPSOJbtACDGxlpjICZA79+cUZ0N7/eA9KfnzK8rmeClApYSo6sd8A8hdnaiAg9EHczSuySZ7gROGnYG8STeuwLf3cZ1aQXsc0WpC76HI3vWevckWnFYFy23EQhiEesPd0O8IS04nr7uvsgm7o9RIKrsp4YjGkMQzxIB25cs76Q488mv/u1qWtftA7QxtsDBbPGplG348GKVJcFAdkeIISYrBeMenfP3KPoa4QZY+p10cQcqZITgq7WA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U3bkblEfbxCTfGa+hLazBLN9IC5sG4y/zPKsY4CQH+4=; b=DWF4nGlhfToB7jxXZ2Cvj/kQwM6chD73t/VFWW2R1hH+hxFlW7gwm6ZKvE98LUoQcPeF9B0DCKVffu18su7pCJoUtl9UXgISEQkrgESGDOqrQZLPMSYxjBBSwkhDrysWR9riSaj5fvbAbhHgT71M4ECr8QR3+pq5lbVrnDcHetg= Received: from BN9PR03CA0983.namprd03.prod.outlook.com (2603:10b6:408:109::28) by PH0PR12MB8822.namprd12.prod.outlook.com (2603:10b6:510:28d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.23; Mon, 16 Sep 2024 13:32:46 +0000 Received: from BL6PEPF0001AB72.namprd02.prod.outlook.com (2603:10b6:408:109:cafe::e4) by BN9PR03CA0983.outlook.office365.com (2603:10b6:408:109::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Mon, 16 Sep 2024 13:32:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB72.mail.protection.outlook.com (10.167.242.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Mon, 16 Sep 2024 13:32:46 +0000 Received: from patedamande.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 16 Sep 2024 08:32:44 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v2 3/3] drm/amdgpu: use drm_file name Date: Mon, 16 Sep 2024 15:32:20 +0200 Message-ID: <20240916133223.1023773-3-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240916133223.1023773-1-pierre-eric.pelloux-prayer@amd.com> References: <20240916133223.1023773-1-pierre-eric.pelloux-prayer@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB72:EE_|PH0PR12MB8822:EE_ X-MS-Office365-Filtering-Correlation-Id: 7195c9e2-3a43-4e7a-6652-08dcd6540cee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: qXjIg51vU9Oo3OMJkmXU7SIGMu0B3UkZcBLeJyFDoq9jvdqGOfehAdK03yv+DY8yGnGd3VBfXxZwbwU+d0bwtWvHR6Vu1ehu9ABJrkb1LlCA87pD8jmDaudIkw0eNVT9txZQj10xM5Qfmp1xLlo20VGkZkk4bm1toMAwnYDKvUMO5S7uw5zQybWSj1JuVWe2Cjs+pFJ9b0LB9OIhj5AArWDR+l/yx9g7zFahIORm5qMlBGWEi5pzTzym/sEs1lRuTKEijOj/3Vy2u4mZjQpnlSHnqfJ9SWW0AG50ptJpf/LcPoLz4TazLmStcqx3iLrP7LBjzlVjeZ6fB2YJTKuDChXEnQCiKwKWti5YLxy4i7IOf4+xp6xRdpS1ps6WLLWGr5VsnZndooYW8chaNOvgcjOgl8p8URPYX+oJ6iS5qxuKmKRf0JGVuC6kiP1s0kjQlKMIrl0mI8dgD8ZjmaJS2j/lgjvr9B0TLWx8uaL0Qb2mVw/bnm3bBKmLgUGVx5A0OBjILG81/L5sgAPLT3DM+1LAsoMbglkpqRW0fPQlKJMp1K3CDHRMfJQMbZmJXdKb7REqsGPjLeUsdFHCK316yWzSmgZBCNKrFx9GASP8sEUPOZwK/dekeEN2PDOyWT6YiV+9DslSjw1C3XyOxmdTVe1B8k+c0WgIIolfGtME4DMg7NMx3r7gM4SW9fbO8C0mSFqa64dLhmYTWEbRyzeO2+Xej3S2i4beHh7+L9iZDEcNuk/lw9CYT8lb20ro0J7PVt+wPZYkvXz+xTTGbbSKxqgQax4qMUQoFZVKTaKdmzi0TGeVuJ2UVyIBPVNgri8HzabHhyQRiHPuFvMFT70FJjyJTrGm674F+pZpVVGhf+rFnCnq0q6Xcl+EaGMgrtlRdehxJlBmpRDZU9LOBpMRN/JgJUuRcHmcQd67lVt/P3G4Uzyi1WC3YgBA9+zjCKoZz3m+7XVvcou9os0kZQBhUG5HLhC+zCj7Cd1ulLjXhsgNNAdLs8Vb6gV9//C7yrPv9EDKL+uk0NvBUfokdqLEe4Ppgd36CtaIIoFzJZHrVVwBJXQCP8Go/Y2BK6fi5mEGlxFiSZnPmkkgo2EniBkPfm0g2Gzuf+aPS2xybezh/Bo5uZZ+BofZWUXLuKbIvMQC8yA82mkpWwXPMGXnTtbJEFIpy4w2EJM9H/JDdzFBdKxo2fTA3XJU2voAEIv72khfbZNhldGW9eFbhat0GoK0ZWDm6H4Wj+4/oS3P5e6dmzEWjF9kCHApnooRFE+na+GzBX9uaLHcxunQhRsyPd0HXf46LF1bp8NbPHEFDlcB4eNON4voiiwAkrTEIg+QeVDm3GwBnHfu4W8++DjjXVpzPh5u4kDEIIHI16BDbB19FIemKE2IMV92kWp8aJ6WV3nR2FXWuP3jq7jK5sYqzSbTvLAIsDN4DRWizGoqGdHrtlhqOjFTTc1CaDeOYROqceEa X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2024 13:32:46.1690 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7195c9e2-3a43-4e7a-6652-08dcd6540cee X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB72.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8822 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In debugfs gem_info/vm_info files, timeout handler and page fault reports. This information is useful with the virtio/native-context driver: this allows the guest applications identifier to visible in amdgpu's output. The output in amdgpu_vm_info/amdgpu_gem_info looks like this: pid:12255 Process:glxgears/test-set-fd-name ---------- Signed-off-by: Pierre-Eric Pelloux-Prayer --- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 16 +++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 25 +++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 +-- 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 6d5fd371d5ce..1712feb2c238 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1577,7 +1577,7 @@ int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct amdgpu_device *adev, if (ret) return ret; - amdgpu_vm_set_task_info(avm); + amdgpu_vm_set_task_info(avm, NULL); return 0; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 1e475eb01417..d32dc547cc80 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -310,7 +310,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, kvfree(chunk_array); /* Use this opportunity to fill in task info for the vm */ - amdgpu_vm_set_task_info(vm); + amdgpu_vm_set_task_info(vm, p->filp); return 0; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 0e617dff8765..0c52168edbaf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -997,6 +997,10 @@ static int amdgpu_debugfs_gem_info_show(struct seq_file *m, void *unused) if (r) return r; + r = mutex_lock_interruptible(&file->name_lock); + if (r) + goto out; + list_for_each_entry(file, &dev->filelist, lhead) { struct task_struct *task; struct drm_gem_object *gobj; @@ -1012,8 +1016,13 @@ static int amdgpu_debugfs_gem_info_show(struct seq_file *m, void *unused) rcu_read_lock(); pid = rcu_dereference(file->pid); task = pid_task(pid, PIDTYPE_TGID); - seq_printf(m, "pid %8d command %s:\n", pid_nr(pid), - task ? task->comm : ""); + seq_printf(m, "pid %8d command %s", pid_nr(pid), + task ? task->comm : ""); + if (file->name) { + seq_putc(m, '/'); + seq_puts(m, file->name); + } + seq_puts(m, ":\n"); rcu_read_unlock(); spin_lock(&file->table_lock); @@ -1024,7 +1033,8 @@ static int amdgpu_debugfs_gem_info_show(struct seq_file *m, void *unused) } spin_unlock(&file->table_lock); } - + mutex_unlock(&file->name_lock); +out: mutex_unlock(&dev->filelist_mutex); return 0; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index e20d19ae01b2..5701d74159d4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2370,7 +2370,7 @@ static int amdgpu_vm_create_task_info(struct amdgpu_vm *vm) * * @vm: vm for which to set the info */ -void amdgpu_vm_set_task_info(struct amdgpu_vm *vm) +void amdgpu_vm_set_task_info(struct amdgpu_vm *vm, struct drm_file *file) { if (!vm->task_info) return; @@ -2385,7 +2385,28 @@ void amdgpu_vm_set_task_info(struct amdgpu_vm *vm) return; vm->task_info->tgid = current->group_leader->pid; - get_task_comm(vm->task_info->process_name, current->group_leader); + __get_task_comm(vm->task_info->process_name, TASK_COMM_LEN, + current->group_leader); + /* Append drm_client_name if set. */ + if (file && file->name) { + mutex_lock(&file->name_lock); + + /* Assert that process_name is big enough to store process_name, + * so: (TASK_COMM_LEN - 1) + '/' + '\0'. + * This way we can concat file->name without worrying about space. + */ + static_assert(sizeof(vm->task_info->process_name) >= TASK_COMM_LEN + 1); + if (file->name) { + int n; + + n = strlen(vm->task_info->process_name); + vm->task_info->process_name[n] = '/'; + strscpy_pad(&vm->task_info->process_name[n + 1], + file->name, + sizeof(vm->task_info->process_name) - (n + 1)); + } + mutex_unlock(&file->name_lock); + } } /** diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index d12d66dca8e9..cabec384b4d4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h @@ -232,7 +232,7 @@ struct amdgpu_vm_pte_funcs { }; struct amdgpu_task_info { - char process_name[TASK_COMM_LEN]; + char process_name[NAME_MAX]; char task_name[TASK_COMM_LEN]; pid_t pid; pid_t tgid; @@ -561,7 +561,7 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid, u32 vmid, u32 node_id, uint64_t addr, uint64_t ts, bool write_fault); -void amdgpu_vm_set_task_info(struct amdgpu_vm *vm); +void amdgpu_vm_set_task_info(struct amdgpu_vm *vm, struct drm_file *file); void amdgpu_vm_move_to_lru_tail(struct amdgpu_device *adev, struct amdgpu_vm *vm);