From patchwork Wed Sep 11 14:58:32 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: 13800764 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 265A7EE49BD for ; Wed, 11 Sep 2024 14:59:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D65F10E5EC; Wed, 11 Sep 2024 14:59:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="UQPxn5w1"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2073.outbound.protection.outlook.com [40.107.220.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 300B010E5EC for ; Wed, 11 Sep 2024 14:59:04 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kAfYFY8/qrzAJM/dytusH1+WM+FDmcwmFPY3+f0M5G1ytRKwwXNQdMZugpJn5cyQo6Q7e7+rlSCFuXvV9+IaTKuWD0dGUj6h8THzRQm4EYfTUcdBZ2t8BpMZ4NI2fHb7fxg3atUMip9mkKAyudn+ZMBZ00HDqqjEZ1+b4yVSdDygLXo33HHJyT4ILAc8gviXBaWHvLPiPHnRsSiUqk53nzvFvCNWRmEBuIXgYtCpWL6Yg0GJwrAxzHtXaTgP05FKxcSRInColUrp9R7Ju7BPS6oCmCw8lQ1Ah6fv+bwOpuShzIjQfoYNZ1idE8QoGyOIiP+TAkfzkj3JGThp8Ve7Cg== 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=EFmE5v6recG0aj44ta6SFAQGaKXxChJ+9iQ5Y+Z18Ek=; b=Fww+EuIKpnwnh9JRlN9Pu5puTCFJDn5b41qcRdUKKClM/k5Iy0LMsXLOu6IzHkbydMsuh7Ovr+O6aPQUQ+J4cKDs8DGdGQzoGpHfcxqor6IJaMeTTHakqS+WKdBSMFfXw8tj8mNZBhHWFbKShzmgWB7DMNqTI2deKV/P7/NVhJB/oj5SBPqEoxSennj/iY4eClVX1m7nxUpAeSu0QNaRCIg6CwkQoxS4JZq5SsudHlthxx9ecmxZt9GZdaYcdXyayaJ/NK1C84HzrhmXt7tArqAQH0ba2Jj4knAbD7a6yrW+fvWxPuOZKVhieBZXHS4azQtHtnmXY4OyxGDaOwABjw== 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=EFmE5v6recG0aj44ta6SFAQGaKXxChJ+9iQ5Y+Z18Ek=; b=UQPxn5w1wY8qRmj5PHPC0DVv8UNMGcSXxgTNwVo3vshBDYahLTRwjbQDbHVJOOVOwlYmrfwDmn8AzW6WW6sXnXdZtdnjbGQJKT0+MTyZXvwyndTM9ZFjBV+kyCZ7y/Jayu2iHjDWR/NzQ+5QqjnO5w95yHu2zt/9CSCFZN0WlJk= Received: from BN0PR08CA0024.namprd08.prod.outlook.com (2603:10b6:408:142::14) by DM4PR12MB5939.namprd12.prod.outlook.com (2603:10b6:8:6a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.17; Wed, 11 Sep 2024 14:59:00 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:408:142:cafe::5f) by BN0PR08CA0024.outlook.office365.com (2603:10b6:408:142::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Wed, 11 Sep 2024 14:59:00 +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 MN1PEPF0000F0E2.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Wed, 11 Sep 2024 14:59:00 +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; Wed, 11 Sep 2024 09:58:57 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH 1/3] drm: add DRM_SET_NAME ioctl Date: Wed, 11 Sep 2024 16:58:32 +0200 Message-ID: <20240911145836.734080-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: MN1PEPF0000F0E2:EE_|DM4PR12MB5939:EE_ X-MS-Office365-Filtering-Correlation-Id: d5bc8005-06b4-4cab-a5b3-08dcd27244bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: jHk2ebvEzismeZGK0qDD5AGJMkAIkZJgJg5kjWuwkPZGlqd4newiq8dB96znA7NtdxTf90z0pFewZ+qqJwo//4/AiCajn7hBC6sS0/NFImCqh+yFklnTDH074lQARZw0Ao102AuoqEq3XWgp7i06Hr555Rp2cJXPlNhzyxMaymzF8gUDfLzx/IQEFZ4lQIB/94CXzZZVRCn/dwv7iKEbnJCcymVVFBfqiqiekGZvWBxznVJ5dfdbK4vAIA/cUcO4lKNb600e3nmbqBZU9l8QhZziazZ6EO8D4DrPoeZvfG2YWW2nFRZN3q6xUKUo6TXKq3rGXwg6Ry4DR88+j2z0f0NV1tmFNNlKxuwq1Pbb/FAPAGML0A+Dnqrk8cO1VUa2k26E7rbKOjhMc6i0urX2tR5DuUlzsGc51I/r80aENWyHjbP+/NLKWaMpYw1VxGSmaJWePHQmWk3lzgXGYJ5/YfVg+z834IhqfcqGiM/ip+8AtdFS1WNlIudxMhpPWvu0C/DrTh1RgrYNT/BtWs4dhom8YYFCp3bBNEXqyncJ2BTuNSkJyS9LBbpIYeT2ErjUxUUwOtbTdZZZRI7Tf3Ms4FOn4T2g0vDRoaWP6zMbaUfqe2qhKNhllfQLtnN+pEdbuk7WSWTylMnTdv7CRbUdCHZOafN0oI9STXQKEDy187Ir2Ji1lrRsBQameIuGLgiigsJFwRDjYovNS62QQuk7RvESStB80xUln+n+FvvM2DPlFNMVGvFRdx67Tk59ioZ4sFQXJp7qaYrwCI77t6YRSg96pDEPh5uPITpcsP42O8/u2sHkyiJBjE2wKoJzVjZhTk8B/ZgmFH9uQ/0dQbHr13Z9Lx9aqNIo/45FfewWx+OBfkVfHxOCDG5bmLbhdETRZJhud+zgy+x8og3sAv014OuQH3Jzu+rqEUrbsXG7H7L7r79T52OCKY8oxDEdJQc6pA8JxDxhYSXiUpSIJGr8wHF9P3SC9EylwxbLA+I1E35afzSK6aLZUrMPvFwZ0LM9yrR7tjLhn875pe4vbuRVunX8KqHTdTm5F9lt8ZCojd54zJSwXUMv03/lq5j1uRvaPX1WIwvJMvxMDNKYwdebbZ3U3phN+Rcnf4+7QESkDkle8lNTyjbfWGN+ahg5tTcFQHuoFAddhAGQPTmoJkMWeSOLcrJjRjQkjas/XzRmqcUGdGP141xwJ+QN545nLfSPysHPrtDW4tlLVumqnyBZw6S8BoYW7x8mi+B0TnVLpyOh2WB3YVJ8GXDn2uV6ztTlU0qHBPup6/HBZ1fZ7kWbGBZXxSQmS4fbNOZJFNhm+IPAux6dN/KWtdfMPosUcudU/d60DERqeEm1TwL4u6zFkREnHIe81c6yz1tvUXH5CxfuUvX7uYvBe5GZ1BXGYwLl 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)(82310400026)(376014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 14:59:00.0345 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5bc8005-06b4-4cab-a5b3-08dcd27244bf 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: MN1PEPF0000F0E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5939 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 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 | 28 ++++++++++++++++++++++++++++ include/drm/drm_file.h | 9 +++++++++ include/uapi/drm/drm.h | 14 ++++++++++++++ 5 files changed, 64 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..558151c3912e 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); + kvfree(file->name); + kfree(file); } diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 51f39912866f..ba2f2120e99b 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -540,6 +540,32 @@ 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; + + 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); + + mutex_lock(&file_priv->name_lock); + if (file_priv->name) + kvfree(file_priv->name); + file_priv->name = new_name; + 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 +636,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 Wed Sep 11 14:58:33 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: 13800765 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 4F864EE49BD for ; Wed, 11 Sep 2024 14:59:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 459DD10E7BB; Wed, 11 Sep 2024 14:59:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Yluzb9GS"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2040.outbound.protection.outlook.com [40.107.220.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id CD3E310E7BB for ; Wed, 11 Sep 2024 14:59:06 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KoPF2ayIRm2kpGAzqhAmBohc4Mh0yOTtakRt3dAyYkEj4VDXIDmaFvHvh1Mp8hZXvjva+ATUGBoeg07OPVkL7hkqfRJkatA39Ji31DMRFt76VLeh+/mSPw22S1v6f1anJ2x9CaHtivfxe8nTKauyffH6c5JVMynuVG/Ptf4/djYTWCZ42rrSmD/ZOMaCXE18jj/rkJwZjV+qJNqJkAvOVAH+q2wJaukXTdukULPTAJLyf6HtAznUMfJ4ZOWvUXhtwKhiDCWWqvjE2Z1x6mrq9WbJZclD0EVh1rOjo8kHhPY6vvqUSX0HtEmCm6l22wwlxFUzuTPiPUQDl5bI/wTazg== 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=nS6k48MdjB7LAAw/7I3TQUY+lYVF5eAThZS9Xe1lAns=; b=JDocKR07mugEc7Ph8DLg6t6V0IRYAXwOdFALJWUbPg+yFe1SYn8kcPD5CR8MolFrmQP7+iR/+ZR0g8VR9/OeTqI78TJREgQOEVTQ9SUNHOUjcavZJVb8WCN2GBu82zEq+Khi3g5S54RCISOkJeH6HGO8upjdd31/SFywBTN/YbhTgefhbZTR/rSUg6/19P8dkEKxmDyxKrSUsKhk40RFofmTT/lM0fDnd14xsgye7LqlUhPxHZkMNOXzeN2Xq9bPRLniqXCpRfButb77ZCJUGVLmMdWYI9OsWUEZfbdfGuNoBq8/xjdxmCGN8mpEjIdqKHH+0BTFODm60GmQ96S01A== 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=nS6k48MdjB7LAAw/7I3TQUY+lYVF5eAThZS9Xe1lAns=; b=Yluzb9GSwz09G/paa+eig2M8jrXTJwT+wSMnFdeEDdja7kfwCUF6g3g14mOwaSK6dADiydIuE7Fu9/EYAvB7L/KfBxiIebKXhhan07w/1lrOVYzMNlAjgptQoW12BGqlMPOcIgsmqSfl5gaXDUqujvaouGxQbiiOHe6Z4Ijq56A= Received: from BN0PR08CA0009.namprd08.prod.outlook.com (2603:10b6:408:142::13) by BL1PR12MB5852.namprd12.prod.outlook.com (2603:10b6:208:397::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.17; Wed, 11 Sep 2024 14:59:01 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:408:142:cafe::78) by BN0PR08CA0009.outlook.office365.com (2603:10b6:408:142::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Wed, 11 Sep 2024 14:59:01 +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 MN1PEPF0000F0E2.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Wed, 11 Sep 2024 14:59:01 +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; Wed, 11 Sep 2024 09:58:59 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH 2/3] drm: use drm_file name in fdinfo Date: Wed, 11 Sep 2024 16:58:33 +0200 Message-ID: <20240911145836.734080-2-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240911145836.734080-1-pierre-eric.pelloux-prayer@amd.com> References: <20240911145836.734080-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: MN1PEPF0000F0E2:EE_|BL1PR12MB5852:EE_ X-MS-Office365-Filtering-Correlation-Id: c87bc805-282b-455e-607b-08dcd27245bc 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: s8n8qBUtditxt40jov+PhkkpG+7A943u647VxtHEH6TiqSIYldD1Av9Y7LDFTMa9A/ujgqET+rOUI1ml7BjnywOZRgupw38hprrzrcpu14m9nY6tHMDrbG93pGiYFT2yKRESkyOqOe9b9wX8n7JEGiPcU3anhFQdwcx5oUGHtRk6AKEi+2qtKDVAihNQrDRAE0jLAFFF6wy66MD9xBS/BMKSYytfLgdbFBLS+HXGRakCgWrnpJPMsUvzH4/ArGcEDJuJS3+FXAwtzbGxn4bBC6U/91zMcDHRlZr+KSfDPZwPz7y9o4/s97mmPteNWiXNhHajuBF09YEBKJn/qbFWsBn3y4qHXQQbdeD1doZf7WJvxsBDYYzyqjA0FDaE3AF6BR9bXU5UlIxvMDkm5UPOHCKJRdjpZ69xSXjGCmy19p50lMrIVbq4KRfl6BKWzs5R0HgvBDWkQ5MNqDOsXScWt0dL1gqLw4T5lZ5+eEQPiDYXWPSzyPsfRcjIIifi2tXJR7HIjvxqW27/0fuZWhyOZL8pFSWBcCYn2zofh32nC+R+phlFMBd9lLHeEEJW7TxcMmOHzMUONXGtKr3VN1eAVTk/U9hYNS3gkcKtGPNv0dzXTjfzMRl50Z+P1fKyg/bGjRjvFXVgTWbkHnIe1NiFppgLooaWyFxDsXikHO2qRDmi8yWKpi5z3X7nvjcZXZhDeMQlyqeUX10eWiFjiOu0/tZoGBWeP9w+mLzJEfac/bndDxQFZr41Pzsjw93Ottsq2IrjgN0YOFLPpMwZ8HSy7YdCsSKXTtTqldBCLQOKQkxNDNfghzwBZSuxx9mcL+0XEgVfANROf2KL+/jopTvPkQuh9u/vKWfluDBox/s9kuwe7FK9qBy5gPGN2KSdnfKjPqHhumlMm4Ha46U7oKNU5tMkKXkQWKlIe1on9AVMMyHEECiBLoU1WK/O3VmMWuA8FZrcmhTKnxRoGiy0/sfE79kJRaBvDC50QwctCzIoVGGSivsRy9XMpewwv+aMfTrJiY6Ci1ThmT/GSnFXrGCh+KA2sQgFptaJ4CIZthaqLIhKI7cqPR1uxD0XHmolvZLEB+kjw4h0F0Pt1x+1GD/6rK8+RiWHRz+l56PXKWKW884wHENNVt32CcPkHdlihAT8j37Gmoo0EYyPk8h8Qw3ObitYzDKcj8+sGoOVRwgWvEdv77pxVbuNdrXgctHiVcmjgOFliU6LfqAECcvhZ30uqjulpxushCYuiTF5QKIQh7aJe5hBwocn7soywkxrJWUJkYcZsLwvQQ4d9eXk7Z3bIlBI/343vAeFHjxf6SvSzUBvp8hO8tb0dHUkfTch/3YvP72Kv50szgbP+lRFB5KCcPgsF28s/G/3CNbDP6zf24lDXUjgeWR30SxLf7FA4OswFQUI3T0lBG70tYpEmaAjAO5pWu7qBJ85/DWgBYtkO2cMm7nexd5LiQB+aPx1nDMu 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: 11 Sep 2024 14:59:01.7064 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c87bc805-282b-455e-607b-08dcd27245bc 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: MN1PEPF0000F0E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5852 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 --- 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 558151c3912e..024c7b47ab04 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 Wed Sep 11 14:58:34 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: 13800766 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 E867EEE49BD for ; Wed, 11 Sep 2024 14:59:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4887910EA32; Wed, 11 Sep 2024 14:59:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="ymftcDIf"; dkim-atps=neutral Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2074.outbound.protection.outlook.com [40.107.102.74]) by gabe.freedesktop.org (Postfix) with ESMTPS id 23E5E10EA32 for ; Wed, 11 Sep 2024 14:59:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=k9qJ31B0EGb+jd8rxK0ZWi2v/8uUnFi3l4JT+vd+nTpuNpL2nBZCDVK2taLekuxwr9U0o2Q+2gEv0UZT4YlH/KpUaMALP8awePcASPrW88/HNageqeufhUZaMPzMhe1pqlCNm8pb4RM0bHVjgIzVIankDz6NSpUQzbWvdUcNfymeGFv6/jN6kUJ/qagLrZJJyi3v98m0ZMOR8m3kAtUnuizXg8MB//JfxzyF6JWkFuFQ0pboCXO8wzukMqbYIXyr6Kcxj5FKkO72Mi8bUlg6IIs26fLTqovlYqdedBFum8abR+Vc0GzY+GzQAAwuivzuFZ5Gmj8GgIkfnmHtzK+97w== 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=9ewsw6na8f9cxlEXlEVzHmSU9eHvgnfjSaT+vmWgGc0=; b=g1khqTBn14he8JjuufWYkMz4+cKc0Bg022Rxyu1mJ53wBiQ2smII06fR+7kQhkocXTRINbdOoGD5/He5QUZJ7eZnwHaLyWGVTFE/zhVWlRXy1Q4sP6RbrL749xXY7gxUqIQUw1/10BWCJQZ3UivqlPefFUhfcm+s3HKgtQcw7zy5bRSedfY/1/GuURE2kQj+kA6LxlHlGZgiJcahe3Rov5vDR478qL6tvjoB3sjp3imJWe+UzyO5ESgeNf4qVQJOpScLXnMn61jzb9HDd1t0o5xyHUaywEgvqjO+hs542hkZoFiqCw8Uye3JgaAMtYTIhxq22D3dQUF3/peGx0iudA== 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=9ewsw6na8f9cxlEXlEVzHmSU9eHvgnfjSaT+vmWgGc0=; b=ymftcDIfwMtYNIkG+LSxE88ZczyCIueLKoHVrT0Te2fJyDfGIVOqecqNcBW4KnIbcKuRC39rqh0q+GZBPqZtXwjYxUuldXV4cqZdEXf9dc9g+4jPnJq4PRKrUzvFmPYWqdUaw6Wg/zc7E064Ieb1SsbeuR82g6XHSqcX+aYyTj0= Received: from BN0PR08CA0029.namprd08.prod.outlook.com (2603:10b6:408:142::15) by DS0PR12MB6656.namprd12.prod.outlook.com (2603:10b6:8:d2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.28; Wed, 11 Sep 2024 14:59:04 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:408:142:cafe::bd) by BN0PR08CA0029.outlook.office365.com (2603:10b6:408:142::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Wed, 11 Sep 2024 14:59:04 +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 MN1PEPF0000F0E2.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Wed, 11 Sep 2024 14:59:04 +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; Wed, 11 Sep 2024 09:59:01 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH 3/3] drm/amdgpu: use drm_file name Date: Wed, 11 Sep 2024 16:58:34 +0200 Message-ID: <20240911145836.734080-3-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240911145836.734080-1-pierre-eric.pelloux-prayer@amd.com> References: <20240911145836.734080-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: MN1PEPF0000F0E2:EE_|DS0PR12MB6656:EE_ X-MS-Office365-Filtering-Correlation-Id: 55acc9f6-fb87-41ed-da93-08dcd2724739 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: hhSN9VuqhnICVwhsiKSXZdNVFoMlK06xSRZ0khKb6EhswjUTElV6TlIlOeJBB+fEBy93TfDvVeOfQvwDMHgwWDJi67zzdXaZoDBW7knqiKtNxS70tz3+e/6nx+Bs8ln+SVBUjk/ZrghJ/c4SDWTU0popEnr7VOhca/3u0b+HDJn/zFwclBBf+sPrLWcBxggUIy/tFf4fZwXCe9JxGqidCISbcMtNnlCac2OjUoFmIEYQ8nXvMsOJuroXPv1FJ9MTc35WEdNrpICuV6PYihDHkabUlrzNDC2PQbKAcAroSgBJZgyc8AV3pJwGBcNMJ1xXIn6QNRdnJr4tscp3QU0JQpK1uTdG2jsY2ti3a/HVHifHR8DpalK6LFNuZFAY8SP9Mi39J4xzPaNmWEmEK5bge5Hp9Clszc3FQGk6FrM/B6tV/rK9iqHNOMTogkwlfkrTCCah3pOdqdcPTBu/KWmVWR7maTI3wNrzeJE8CpnObQP2qE6y/QHMY0vICsFYK7tJrKnjQJXSEivY9IEklX3pmoxhiUhrdjWiqV2ZVaIRk4N4GaMp+YkxnJ3ODwRV2jNIYFq5GIQSTaeehjBdlzAlWpOxZwK366Z8pM7KhPkPqtM91YOmQ7UDA4OwcaNzqOSCZhqIxkxjRGzyeSDNCqyoNK7iIZNY6hZYC/c1/XN0mTwYrEvPV5Ya8uH8XVmUTY7USwC2j2CK8ECv4QGV0fk5vozZtTuO3t6nRLgHhySa2OSJYQXu1cGU3k7WkNGWc2c6Cl2ZFDk1VuroiHbtvf0/jehKRhcrbSQeC2pV2FiqXaMlZpI+TX+6buML1cyGdwX8poTmHDLLSJsQdcKTtRyKt//F3iCQAq1MXv0MxqjThf/8l4uSWRuqFotAhDf+P3MxW74jNJT6zC1M73EAKe24rO8Jo+BCf5xcmuZiHfWPJ2o6ijDWk5BOeuiTjXcICtIaDeeoB206fYjP7IN10zCGn3pEHuQ9PCnpda5YcCPIoI51dXljdcV139QkeNghUqX4ENM6kUI8z7AJYcvb7KqcgI2IpDqrki/OGUKo4b6xObvS1oAtm9IBvqdsz97C/gx9Rq+Ai/Hco5WDYERdb63lh5V8HNs2okuHTXe4DYL1ST56A2IsdvhrwUXeYs0/s9mopudsHH8PyFvFeV9H0lDXKBE7mLIYso2b19Iq8yDIY5XQCbdlztaacpF1ALCbLSTXBFeIk5Zcr48m/N6ge9uR3sIi0Fw13RoZgg/VUUr9/QyaqiVUlm6QFvY3Iz0CJstfb+8XwfCD6WB1DKpbHxsWz5iL4cXloOh2v0rMicBPCJQyoXEu8mjXb+aqvHH9iqu1nN+eL3qvS4S3yFalZmYSy4xib7sdjw5mbwuhLcXIMm/CEP5RBQIG0LIBi2bljSKhyiZIL2OXY1y5yVdv1O9rSWOBQvX0vQK9XVFCEWAVz/n8vev08hAld1acxQRcJYj0 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)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2024 14:59:04.1908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55acc9f6-fb87-41ed-da93-08dcd2724739 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: MN1PEPF0000F0E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6656 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 | 11 ++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 20 +++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 ++-- 5 files changed, 31 insertions(+), 8 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..0e0d49060ca8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -1012,8 +1012,15 @@ 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) { + mutex_lock(&file->name_lock); + seq_putc(m, '/'); + seq_puts(m, file->name); + mutex_unlock(&file->name_lock); + } + seq_puts(m, ":\n"); rcu_read_unlock(); spin_lock(&file->table_lock); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index e20d19ae01b2..385211846ae3 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,23 @@ 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) { + int n; + + mutex_lock(&file->name_lock); + n = strlen(vm->task_info->process_name); + if (n < NAME_MAX) { + if (file->name) { + vm->task_info->process_name[n] = '/'; + strscpy_pad(&vm->task_info->process_name[n + 1], + file->name, NAME_MAX - (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);