From patchwork Thu Oct 3 12:43:09 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: 13821018 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 91139CF34A7 for ; Thu, 3 Oct 2024 12:45:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1A7C810E831; Thu, 3 Oct 2024 12:45:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="B98a9CK0"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2059.outbound.protection.outlook.com [40.107.223.59]) by gabe.freedesktop.org (Postfix) with ESMTPS id E5B4D10E19A; Thu, 3 Oct 2024 12:45:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cdXjHoF1NCdNhO3joFx04+4RQtt/XiP3a3velp7GxtBnODezsPYT/Ya6t95U9Ko+CCT3FyEexbiFZA954gtTzhHJDds3+E6WcvD9vV8JByxEloa8Wa1b724RYUVQyh8T+ZD1zwJoNABRAzGONSBhOYD0RRM1uy+0Z6h8JiygMwyPEAv1nEm8qFWUB1Z09/LIT6AYXazyJDYl+Y6rcWJzpOixstyRSR1xKznYHiWFUaOhsAcFrfJHS+sQ+CR4m+ATXhaDUko5txycrfiwRgyst9pQGImaMZj9zwEp4IZrtJOLSaZTcI1g2T2rWBcA123LOqiHoFiMWYzShgGZ9Xw05g== 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=xlN4u7u3v26s09Gt/KP+IGN6P7IlrCcW0nqp7UKtfcI=; b=AAYtpFnp99WQCPjF7iMmFssAwGtZf688vU6QafV+P/StrFIeNxioV+EdraVKjw9vuSr5JZZDftvloh3+seKvbiU7OgjqMGx8jXGxHO7yciryOH9DOPgJ5sgjXGjxxO5T4btePV/OXUaciYbnBf4pd4qD2ZtHxRyuHOrcvLSTg2Jlbx3iVKAPmHxXfxIgBchwtBuXskNpQv3n1tT133RrvcTfy5cum5po0H3iVjIq0C3MPET8gG9QuqD2m7B94ceFpDF+UeglkLIX5uoELwJ+St58isJy/PIRyElXYgtdq/LeMXU+AXnudrF52IQAwHBV4PlGGHQyBueUUUtYHpIRag== 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=xlN4u7u3v26s09Gt/KP+IGN6P7IlrCcW0nqp7UKtfcI=; b=B98a9CK0dNUkKnJDGOSDlpb8IkK+Ahn0Zq1DzDECXFX7ntQ1DYJDxIuI4cNsUVDv+3HqSp7xRqijMb/pWCmBDBbfZECn+uyUwZzZT9iTTd4wy+ivFQleoQRZY0x4B/2dIU1ymXGgvlAENeKVbLfg5pJglAXWWYexVNh0EmSQ11I= Received: from SN4PR0501CA0016.namprd05.prod.outlook.com (2603:10b6:803:40::29) by PH7PR12MB9103.namprd12.prod.outlook.com (2603:10b6:510:2f5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Thu, 3 Oct 2024 12:45:37 +0000 Received: from SA2PEPF00003F68.namprd04.prod.outlook.com (2603:10b6:803:40:cafe::f4) by SN4PR0501CA0016.outlook.office365.com (2603:10b6:803:40::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16 via Frontend Transport; Thu, 3 Oct 2024 12:45:36 +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 SA2PEPF00003F68.mail.protection.outlook.com (10.167.248.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 12:45:36 +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; Thu, 3 Oct 2024 07:45:33 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , , CC: Pierre-Eric Pelloux-Prayer , "Tvrtko Ursulin" Subject: [PATCH v5 1/6] drm: add DRM_SET_CLIENT_NAME ioctl Date: Thu, 3 Oct 2024 14:43:09 +0200 Message-ID: <20241003124506.470931-2-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> References: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F68:EE_|PH7PR12MB9103:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f37ba1d-04ab-437e-37ab-08dce3a9477c 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: jisvpYs9I4DGQVgrqp+XhYCKjrpjEAGNOgZXzxtgItnMn6VOksHitdIyECdZ/2Jo+NSDyxC5Icm02tuGrIWh1TFe2GFI9fWakmuj6upyFzdWhzvKDw2QDI//8MSDem/ioQxPPuw+5MPMZdZNdzwQ9SC+3gU1u4xdaaKJjQPXiEPkq2pxQXSAvqSzhT6oShciiB60jLRyObMHhYFbvIXsxPgGhWTziflowmghuXvoqpK+ehLF4XJEkbBOayAc1maXaN0ik74DT6dUCELwDipIX3MEyQwdF5FjIUrJiETeWJTV7CW79khOefauekFbXu8uTQnZwzGi6OmdG263jDas0ZFJ88HzC9yoVUpzxHFIbWJTDfMhB/7paMBjTFzY1Fr3/iw+eWisgWqCxMAWVK1laZP8x8UxRpd1XSa8+ETMas3XFERvae3KAn8vrxFJdHHwquKp+E0DmQXAmMJ7zA4+geMvZ2a1ltCo1oOxRfCOQNlnwzxwsAxkj7ThW8DEggwgxAbTBy9FVxqCpdG9SiHcMzMJNbYL0lhC2B6kPq/Vqi82VKDC74T1B4J5lku2iCafSl+/z9tetA6njoH6WnXZfcnQaxJzMnSrD/4/o3SaubFPRHpFfPPmmki16fhnQ2HxBQBkOfg20gXlcKHD1fD6ar2c4jn1XZ5D/qyPzCvi5a605WNFSPEshQydh5eQCFgtNjWs8M4kAO3c82Io24uyDG+FsRwAj7zwbdVcItQYssRbjO7Lw1/UBUjHG4OUwYt289rEjORBIPn7bmSBlgZJD16qbFg2Bn544XfxOPoVBlDfQgZBC4F80dj0yPcyBBo/lQJMMnHWZRaM6dDel2bthF6ql41d+w3vk+VLfDMXGSU7Xh+PiUGdOr5fl2s1O2yGHbLS3+ekLOogvquqsF2pV7RwZZUDbKmplztTwTyds3PZARXYUsaExDX1C6VaX8E97FfXTn+RDixqgkExGCetVq+mOCJUTvcYsj5LEfspw4G9UDpRFo5yxSXanymsGFPqlkC5P9wIXRoN1ICyrS05JoeNaekaNTzQa912FUzQMcvFVQ3kFnpOsbxs+SfjwdEmSfMBVEczXlwSydKGHPEI5Znnw/ix7tS0Bapby7KyWKpH7pQ9Bf6+pUElLmop2brV2fJj+PaWNh85mJjGJn5CJVPRVzPKtwm5Bd+eZRmBqtLkhuShrk302fRqfVh3LZR953y2ykZKaA54/jtB8RCbZn3WBP5jfI/l8WVxuYvI4x/aJEYuyyo+h9IbEpwGh/48jMjUKZmD07JUWWZbdc9aJ6bPDKZOEhS19cUp0aZ9NR7exAakvX2deDAr/su0sbIQ 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: 03 Oct 2024 12:45:36.7287 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f37ba1d-04ab-437e-37ab-08dce3a9477c 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: SA2PEPF00003F68.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9103 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 client_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 If the string passed by userspace contains chars that would mess up output when it's going to be printed (in dmesg, fdinfo, etc), -EINVAL is returned. A 0-length string is a valid use, and clears the existing name. Reviewed-by: Tvrtko Ursulin Reviewed-by: Dmitry Osipenko Signed-off-by: Pierre-Eric Pelloux-Prayer --- drivers/gpu/drm/drm_debugfs.c | 14 +++++++--- drivers/gpu/drm/drm_file.c | 5 ++++ drivers/gpu/drm/drm_ioctl.c | 51 +++++++++++++++++++++++++++++++++++ include/drm/drm_file.h | 9 +++++++ include/uapi/drm/drm.h | 17 ++++++++++++ 5 files changed, 92 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 6b239a24f1df..5c99322a4c6f 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -78,12 +78,14 @@ 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 %*s\n", "command", "tgid", "dev", "uid", - "magic"); + "magic", + DRM_CLIENT_NAME_MAX_LEN, + "name"); /* dev->filelist is sorted youngest first, but we want to present * oldest first (i.e. kernel, servers, clients), so walk backwardss. @@ -94,19 +96,23 @@ static int drm_clients_info(struct seq_file *m, void *data) struct task_struct *task; struct pid *pid; + mutex_lock(&priv->client_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 %*s\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, + DRM_CLIENT_NAME_MAX_LEN, + priv->client_name ? priv->client_name : ""); rcu_read_unlock(); + mutex_unlock(&priv->client_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..64f5e15304e7 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->client_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->client_name_lock); + kfree(file->client_name); + kfree(file); } diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 51f39912866f..f593dc569d31 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -540,6 +540,55 @@ int drm_version(struct drm_device *dev, void *data, return err; } +/* + * Check if the passed string contains control char or spaces or + * anything that would mess up a formatted output. + */ +static int drm_validate_value_string(const char *value, size_t len) +{ + int i; + + for (i = 0; i < len; i++) { + if (!isascii(value[i]) || !isgraph(value[i])) + return -EINVAL; + } + return 0; +} + +static int drm_set_client_name(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + struct drm_set_client_name *name = data; + size_t len = name->name_len; + void __user *user_ptr; + char *new_name; + + if (len > DRM_CLIENT_NAME_MAX_LEN) { + return -EINVAL; + } else if (len) { + user_ptr = u64_to_user_ptr(name->name); + + new_name = memdup_user_nul(user_ptr, len); + if (IS_ERR(new_name)) + return PTR_ERR(new_name); + + if (strlen(new_name) != len || + drm_validate_value_string(new_name, len) < 0) { + kfree(new_name); + return -EINVAL; + } + } else { + new_name = NULL; + } + + mutex_lock(&file_priv->client_name_lock); + kfree(file_priv->client_name); + file_priv->client_name = new_name; + mutex_unlock(&file_priv->client_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 +659,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_CLIENT_NAME, drm_set_client_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..d4f1c115ea0f 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; + + /** + * @client_name: + * + * Userspace-provided name; useful for accounting and debugging. + */ + const char *client_name; + /** @name_lock: Protects @client_name. */ + struct mutex client_name_lock; }; /** diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 16122819edfe..7fba37b94401 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -1024,6 +1024,13 @@ struct drm_crtc_queue_sequence { __u64 user_data; /* user data passed to event */ }; +#define DRM_CLIENT_NAME_MAX_LEN 64 +struct drm_set_client_name { + __u64 name_len; + __u64 name; +}; + + #if defined(__cplusplus) } #endif @@ -1288,6 +1295,16 @@ extern "C" { */ #define DRM_IOCTL_MODE_CLOSEFB DRM_IOWR(0xD0, struct drm_mode_closefb) +/** + * DRM_IOCTL_SET_CLIENT_NAME - Attach a name to a drm_file + * + * Having a name allows for easier tracking and debugging. + * The length of the name (without null ending char) must be + * <= DRM_CLIENT_NAME_MAX_LEN. + * The call will fail if the name contains whitespaces or non-printable chars. + */ +#define DRM_IOCTL_SET_CLIENT_NAME DRM_IOWR(0xD1, struct drm_set_client_name) + /* * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f. From patchwork Thu Oct 3 12:43:10 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: 13821019 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 04BCBCF34A4 for ; Thu, 3 Oct 2024 12:45:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7AC1510E832; Thu, 3 Oct 2024 12:45:46 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="mkaiZE1a"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2075.outbound.protection.outlook.com [40.107.94.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F55B10E832; Thu, 3 Oct 2024 12:45:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G5nUOloyKY/jZKxDIhEl3+3zW/oNeVA/aF88xZ2zD7GkES3as74UlC0Lr76dxR2MqqPX3zXzSbw9szbMBPFwUL41Z71JacMthrCA02gYtJYOSdbFIX18LElip6PiYjqbhUaoF0SpqaJlHpBMtkMPtp1NDrHBcA16gO63NR1kHkBJa3vwyoEKkdc17XExoJ4wGBtjB0FsiP9KCVmb7FYKRY56QH4xPogZy8Q8TVsPBtATpf6kL99LcwfGANvmoXtqcXtmj+Nm5auwHRyAQ+WSZjM3iAsuSRuaXnzT/4Cc3sA91Y3v7Xy9J7vj4H8HSTqHmBght49jNsRniYjf8JCi+Q== 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=9f+kHca6uPX+a7qhLf96OaSWInnJjf7xkV4/At6HyT8=; b=JxMp8TxKBCPeMwYqX7UCYmFR95dvH0PoMhAxZvhhVp+XZ29q3nGbAlxevsKeFuo/F46GBZ5ifvtITnW9BC2OH/WYZPMSA4ZGZzZq6hOYksf5IZODLA0J8ih9EDPv20nSf1ILLbpd01GfZlJJYCUeBTsfurq50WEWCgEIedtjGfaUHVWlgNrRSBpCytAwg0OceP8R3QTe17znjfbh41b278MoZ1CNJmHf1PYext6Avyda+Ibt1RoZI3oNMKKtspyYQVmEz/kDdRaY6rJSllhD0cN6FMu4cHncidRb2iqItfBAuK+8mhD4R9raeYFbwVnJ7NYyKphW3XQs5QdNMGqBjQ== 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=9f+kHca6uPX+a7qhLf96OaSWInnJjf7xkV4/At6HyT8=; b=mkaiZE1aSRcUu8lsTNFi6CTaaVN0YBttUByRWZgZJjyIHGUgTx61tP7Fc7kc9ClRUbkvBUVx7cHsRDEAqJ9i3iLNJVh7wD9dOhDgqi5klYeKbXK2kd/NDU/Trj6DwtKbhBMI/ZGH1vTsxyg/rw21rS/YhZBNdnTFUNSwxb5AB78= Received: from SN4PR0501CA0021.namprd05.prod.outlook.com (2603:10b6:803:40::34) by SN7PR12MB6886.namprd12.prod.outlook.com (2603:10b6:806:262::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 12:45:39 +0000 Received: from SA2PEPF00003F68.namprd04.prod.outlook.com (2603:10b6:803:40:cafe::85) by SN4PR0501CA0021.outlook.office365.com (2603:10b6:803:40::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16 via Frontend Transport; Thu, 3 Oct 2024 12:45:39 +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 SA2PEPF00003F68.mail.protection.outlook.com (10.167.248.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 12:45:39 +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; Thu, 3 Oct 2024 07:45:36 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , , CC: Pierre-Eric Pelloux-Prayer , "Tvrtko Ursulin" Subject: [PATCH v5 2/6] drm: use drm_file client_name in fdinfo Date: Thu, 3 Oct 2024 14:43:10 +0200 Message-ID: <20241003124506.470931-3-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> References: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F68:EE_|SN7PR12MB6886:EE_ X-MS-Office365-Filtering-Correlation-Id: 37efc26b-75d6-45eb-4a16-08dce3a94935 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: =?utf-8?q?8yLeAOivkzo60bozn1Wox0Ksi9htsHP?= =?utf-8?q?hb8ii6ybJjmk/ENS4sVpeRXH1CRDO96a4pOJN+GjQIIqWfjUDuzilytsVv/wNZRXZ?= =?utf-8?q?ux3rw+fDUAt7PNqH0RS3eWrdWM5WUqhYJJ4cchy3TERLuMOCsVnQcQ9km3E2AeAok?= =?utf-8?q?c5k1d/BhXq9Bj/xYdlC4JmPTqk71zotF22nKQqyu+ZOUmXsvy2l6sSC3/kG7uK+EO?= =?utf-8?q?qGGIA79/lFif/V0wdNKbwBNHWukPKa5kRf60tQDVu+tbaz5IsFYo+2R3eJsF0NwCV?= =?utf-8?q?DWW+C3daE5zBB3SxVrCfJ3Q/sEEV9ZFOn6XXQ+V1EUk8TD5867HqopF29Fa3r+zGu?= =?utf-8?q?XYdGN0x9NXC6sTxGqDDo95czNU0mtBioF5zxpsvJPOFbYt8wC4uu5R3DUxpx040hb?= =?utf-8?q?1DUeiWCtviieihtlk+QKZEOiHE51teYL745wgYjwPgh6tgXXuqhht13JfnHt8Sl+a?= =?utf-8?q?gfBrdo43j94DBJU3CmLpl9T7oQTgFzz307ubkoccZ2bt9kWeUSOqLprO4cLpjCr4y?= =?utf-8?q?76q1znZyZnTar3+zAGIDJ8HlxT94YhSzV1ygusDI3474bcN/GcNsjeJC69ri2Cbam?= =?utf-8?q?t2jRadu7jO7zX7vjoFddyaE+w2trtQmVStN+6aXqI6oloRcoABMEWt43qts1YPn61?= =?utf-8?q?KtHhWDHk+fpPSkQmF+NPsXYJNEwewqCWHS9ixqAYErrLpKt7jqnThgHWzCNznkVct?= =?utf-8?q?GZUsr83u/YaxEs7WAm4QzBXTBmZkTxoJTy4r7uYpTn/5PVquOmjsuVc9cIRboBs+w?= =?utf-8?q?tVnZ6AZPRxxcSmY1OdGjDlHAKxNoKPWWT3Bt4HuJ4aOnL49m/j6460FTOWUzyZpxB?= =?utf-8?q?I8JwaJVRgdphyVb45bUb6UX+GJDF4RyAhWZPyKxoASyGH5+kIb3b/i0Jsb6g7RBcN?= =?utf-8?q?9fLV0ESCvOAti+NYGW9N1EkuwCf4jv6Dq+WWKvPOzPPhfUKSDaeDIM4qJhWRqlVwx?= =?utf-8?q?LZ6blO+IswOi3sJqltpqfEsrvoxMhd5jlCApre8Cg1i/8tVqM+Iupygz3MiZpZljJ?= =?utf-8?q?Au/sIK93PebCkRSzHGa7JjuSFKY6mGqCbPfcXgogRRZeicShHO3JcCxesaWV05kSL?= =?utf-8?q?/nmPGEpNcR7wNRC0oijiZcnF9Dd1A5sKYhNZ9rKORGyklh7oe+MbvP0ZI/ItTrfq/?= =?utf-8?q?YWiD3+cOy29QBJjU6P8lcrs3JlmELt3pENrSyZwuN5WKI+QBMmf4NFiLg48ZzrMWl?= =?utf-8?q?Tdhr+SgFVRGxvNc4DRoFLnlTq9yzII07WExR+XMBGBfR1wumfb8E1gM3xoO0cJc7q?= =?utf-8?q?/Q8L8hF4U96+Md0HW7LxrPObtRdz1lPLm13MNiLf7FjRuuBtkRwrDzpF5Mxf2ysY0?= =?utf-8?q?5jcfR3SLIElZ?= 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: 03 Oct 2024 12:45:39.6193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37efc26b-75d6-45eb-4a16-08dce3a94935 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: SA2PEPF00003F68.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6886 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. Reviewed-by: Christian König Reviewed-by: Tvrtko Ursulin 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..566e122e6e60 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_CLIENT_NAME. + + Utilization ^^^^^^^^^^^ diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 64f5e15304e7..1c9e03477a24 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->client_name_lock); + if (file->client_name) + drm_printf(&p, "drm-client-name:\t%s\n", file->client_name); + mutex_unlock(&file->client_name_lock); + if (dev->driver->show_fdinfo) dev->driver->show_fdinfo(&p, file); } From patchwork Thu Oct 3 12:43:11 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: 13821020 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 2CBBDCF34A4 for ; Thu, 3 Oct 2024 12:45:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A145310E83A; Thu, 3 Oct 2024 12:45:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="zMitrvhN"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2089.outbound.protection.outlook.com [40.107.220.89]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5BBFD10E839; Thu, 3 Oct 2024 12:45:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oV1RxDzZMzCTTIIHzcBf5SQPP7x54TKzeeeXLEfoZHAsnCbK6/ySTKRayrNfaQoZQIuFoaRVzFgeYz9LARUmXZedt7Ja9TBMOrdVFISAned4x0Xm8r9CyazPHzqFCIYITlDqnIzjeOYU/mSK/tTFezZAlTa57fGjR2NJcTcKgc+KQgSb41vO4TRiHldza2fmLTkSVW9Ip13w2CoYTUhOg4O443OH56PfSKwDz3Z3niT+MZ5xSDMPrJ0VTs2jHXRL3zqYWqdFBAaTeAC6EgeNV+6vshkTtKNmdGrkVe6QI2HIMgRz6/KGpFCkeYUiTiO+/cV/gRcF++oSdAmXV2xrnw== 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=V6Ji6fF12ns6v0fDQNTLY9BV8iKUhhpqNgU+Iwxjn3w=; b=GkN8w7e7gfrAHR8DzxcIL54ldiFGQclxb/Rc9J56ced6XXba42Sxy3bNNXV0Fv8PwU62N9eRmP54cdvi7MdOybFAbdOdIpECDuUvBuImysz6wFaoLn4b46SiGlq/6OVA5C7ifBWlaTJ3wEuLdwsVCLpFNjGjltPLjuvquVO1KITfedTb950Bptq0vwW4APitrQkOaGOYBKTYcpgr2xmxHNcKBBCLbg8WfaNV+nsnJy69y/sy7SB3ggUs6IxmgxVSkvu6aaKGzvgiHUE1T+q65XRRI9JZrt/dUthGFxFe8n77Rq+mD6nYWCwgH6WNV6Szm4uHiLGm8nDBTCIeEmpRRA== 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=V6Ji6fF12ns6v0fDQNTLY9BV8iKUhhpqNgU+Iwxjn3w=; b=zMitrvhNUDDoi61TyGGES1w2FBlNVtaeCDDBWYwP3bFRnNT/IW4SyvmEdpPIB05VTd8WonqkPHGs2s2G6a6n57yiXBeJnUxUHBKOdDWXS9oyoF0AsDOk/6PVKKPTMgdNkY2OGCBJMo/62LXn/Ag+fqCTYPjFJ0AMpUkZIVfpPs0= Received: from SN4PR0501CA0021.namprd05.prod.outlook.com (2603:10b6:803:40::34) by SJ2PR12MB8112.namprd12.prod.outlook.com (2603:10b6:a03:4f8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 12:45:42 +0000 Received: from SA2PEPF00003F68.namprd04.prod.outlook.com (2603:10b6:803:40:cafe::a2) by SN4PR0501CA0021.outlook.office365.com (2603:10b6:803:40::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16 via Frontend Transport; Thu, 3 Oct 2024 12:45:42 +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 SA2PEPF00003F68.mail.protection.outlook.com (10.167.248.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 12:45:41 +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; Thu, 3 Oct 2024 07:45:39 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v5 3/6] drm/amdgpu: delay the use of amdgpu_vm_set_task_info Date: Thu, 3 Oct 2024 14:43:11 +0200 Message-ID: <20241003124506.470931-4-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> References: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F68:EE_|SJ2PR12MB8112:EE_ X-MS-Office365-Filtering-Correlation-Id: 759ee60f-0c28-4ce8-4cd6-08dce3a94a9d 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: xm0tirfFt7ZYPXqTut+yCHDj/HqSBwCSbP9HQikjgd9gJmqolcaLSDayLhSUpaiMnU3l+iwoU0xnze6DW8t0bco2xcNTnmSDOgunY3a2GjKeaxUS+IGa7madvGWXheqLkjCTgtKG2ZlPm/e4tI/8hfxoWx98d3uQ5NATBu8wjJNmzerFMnIzZffmbpPbviZCsityyOfJxHm7HsIoquopNGDTdDWyF8RsJXUbC6pXQ1lWf//8qbaVV4ESxX5IannFy0lAA2pqeq1zZzeDVjP4kuojXTOQfKuTMlcuaFP4vXEGdfFk08C22N4N1WvoDK9nF/hXiNNuwn5xunbIFPVNdlzU/gNaikK5mUmfrbdTQJKt5B/gu+7NNz+QFj6++qUe0cZO7M5Jnao0EW0RcIzXIEhEm6iaOnY9/d1HH7F7MN+0rOLq8Fm9ufrtc2SD9Hb+G4onuhNduyqEUMXMzj7/V/nKL5c7ME183kexsutGszdBNNPDBshjSS+rub76ttom4ckFOcchqx+MVH7kOKZvwzhtKFGR0kJYnFxifhin6ErMF2H1RIRfLOxsytFlY9vpBPK7kBIbphcgnkQWi0Pe+j+DRv6trvo7/E2cctzvy8UaBcvDeiUP+DFwjB/mlJvzj33HiXd43XNPT9npZ4uGjq76YcaKe2Vo4cneiyb36WCcixlHp9Yf3N7PEa/7OnuvD9u30xZJdhHGFJJYI8wNZ+JWLKSiGlDaOa+FhumvO4DBlcfnq2vwasljThpKDrLU2FC2ZXS4wWYj1cfci5O/n2tTGaUV6tkfMDc6aPFILXLF6WXfkgIlvRB9eWGRV6eclbsWY/MzNiRrgUwI4Gt6suLql4pRRoZG4NfH2ITF3rTIRU/EonAaDr3gyNw02M4DMQaXgPIkYlgmkthPUq0CxznG4sRRmZpVmq/GZbFXXkNga/QIYZIAV7o262qIV5mFU66jyqntH6Xp3LZY6MgG4b6vVh/nlwGvFuZqfOhJh20ZDYz8jUcS2dsU3uh4yoiXOcXwcsjQTfnN4bgAaPZD3fWrwJSe/BW6DHXPPw/ajg8ElLqJZ0cymPMIx1yA7A+NAetKbIBUiJSlqYTgF3g2tgzHMhuTEj9CAlu89fB7AwzM4HS7InrU7fUwpFrvahKgSl3RR9WPgWAfYEg+k2z9Q+h/LGp+2weVq+YB/tYJn77hegmGbigBDYzwByarYBt7ZOBvoq88h1BBCaKbRsSLnar765KaY++LTildyVnZIg7utP74wlDjQrKMUlleS/Th+lV39e6oz4Y7vc+b8hsPncnvAemyY/7+NGCrYoVXx0RzS+pPvATrs+nbl/23Io2Hcvl7FInJxoO3Hz15BKZ+DZ0PbxbRyscyyxvs42aYlkm6o6M7r5Uht85Lu47OFxGJ 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: 03 Oct 2024 12:45:41.9631 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 759ee60f-0c28-4ce8-4cd6-08dce3a94a9d 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: SA2PEPF00003F68.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8112 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" At the point the VM is locked (through the root PDs dma_resv object), so it's safer to call amdgpu_vm_set_task_info. The original place was not protected against concurrent access, but the risk was limited to mangled process/task name. Signed-off-by: Pierre-Eric Pelloux-Prayer --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 1e475eb01417..891128ecee6d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -309,9 +309,6 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, p->gang_leader->uf_addr = uf_offset; kvfree(chunk_array); - /* Use this opportunity to fill in task info for the vm */ - amdgpu_vm_set_task_info(vm); - return 0; free_all_kdata: @@ -1180,6 +1177,9 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p) job->vm_pd_addr = amdgpu_gmc_pd_addr(vm->root.bo); } + /* Use this opportunity to fill in task info for the vm */ + amdgpu_vm_set_task_info(vm); + if (adev->debug_vm) { /* Invalidate all BOs to test for userspace bugs */ amdgpu_bo_list_for_each_entry(e, p->bo_list) { From patchwork Thu Oct 3 12:43:12 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: 13821021 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 3FF2BCF34A4 for ; Thu, 3 Oct 2024 12:45:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B47FD10E1EF; Thu, 3 Oct 2024 12:45:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="E3trAgBS"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2067.outbound.protection.outlook.com [40.107.223.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2334810E83B; Thu, 3 Oct 2024 12:45:51 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VI9HAckQ/MjDCKN5qtJVDsaxaq4hchMMrfv43ML56VmcEInRzYLny4d2gxPl1GoCDZ0qftbSLOLcgRnEzozGu2L2K1LuSPExVXX+L68ghAsgxS/ShUMAkFsTJ3kiz90RgxhoHJhE8nlGLNC/wRsjC4dUGC8BWSpnnITbst+sgSHKLHVlyu5SD2De/gjkNi7cAK8OcDUbg2qhDspfOXtVLx93ZDwOJiltIvtEvaRoRKK3GlPsLVHKj8f6QQddwFiZV4tdlTbsczOvuuxNcLjuekcsZ3VIfXb/YCRHk/EUt7lQLLagw9lQVat/8puh65dxFSHe5cBzlSZYubiNnwVSZA== 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=OMUvXfuM9MOggAOt1ZdfNfJXfG8ODxGRuWJFXsE80fI=; b=BQ/Zr/ZNGgbAd+veP6/KN7ZwpncSnnVPPuvJo0LAmwwyzI6cg2Rfteqr9cCD4aWH5qlmG7W9OoI2jWF0t1kZVIp3pjsrvr5XBIlu2+AsIa5LcbI1ISu79M7iEZxQ7fFUXZHC+GlRhsly2TI/YU1xS3leypOZGMKYeKSkdCXBpnQlrwKUilE9ipvLwGtyTK5fFmB4uhT9AcHjDuZUxNGJNeHPIxcZLJQIs+NsRbn3pD+H7Qn5x4w/r+DQznc6ACDCym4PsYYAimi0ZTZXQ7SEqS1aADu6oRL78EjTNmjo39MNH+d5fQeRZZGZ57vlGXmLrCt6rlWzf+qAbehENq2PxA== 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=OMUvXfuM9MOggAOt1ZdfNfJXfG8ODxGRuWJFXsE80fI=; b=E3trAgBSDvmhBbBJ9+C86KtrlQAvUi0416JrV0TfZaIoqawtsVm6DiIkyfh1pkGy9s4kFS9n6jWgYBSeBCnrerFuiaQUm1pNx2csunIXO5VgmTOHzzgKqP7eFWT921S3gaqy/toSBLpRBdxjCEi3EY3SdKNhrWpmjsjdG2mQNYM= Received: from SN4PR0501CA0007.namprd05.prod.outlook.com (2603:10b6:803:40::20) by BL1PR12MB5706.namprd12.prod.outlook.com (2603:10b6:208:385::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Thu, 3 Oct 2024 12:45:44 +0000 Received: from SA2PEPF00003F68.namprd04.prod.outlook.com (2603:10b6:803:40:cafe::4e) by SN4PR0501CA0007.outlook.office365.com (2603:10b6:803:40::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.9 via Frontend Transport; Thu, 3 Oct 2024 12:45: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 SA2PEPF00003F68.mail.protection.outlook.com (10.167.248.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 12:45: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; Thu, 3 Oct 2024 07:45:41 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v5 4/6] drm/amdgpu: alloc and init vm::task_info from first submit Date: Thu, 3 Oct 2024 14:43:12 +0200 Message-ID: <20241003124506.470931-5-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> References: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F68:EE_|BL1PR12MB5706:EE_ X-MS-Office365-Filtering-Correlation-Id: 52678788-1eee-4e53-780c-08dce3a94bed 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: 5W/2RBUsdcPjrZQ/K0376Xlz0sLZ/3YMxNh2t6E+l14ZR3MKC5is0dEw2V26LLp/7KGB7plpmD+o+34diiWrWoQbYOE9cfjzesahp7SrX6/HifI2dZ//NiNSAiRkEn2jbZ2Qwz2eX2guPSl13VJP2SBZjouYJisTgVB6UYKI0YfKS4iGBEsnXFgWHJCEk7f+fKAM1B7CfrqjSh1QJ7IIvu1x15slgtBPeegXwyciQWQxOq/PhjK3raZZOP1srhZkVwPw+wc2JLEpGxacA4bHujLbBxgFeijRrcWDIQ6YQhVfte+2x67q0MOwTBPveI1RrRMNw0Cl5ArLBG7bGV6hDjpCQf/558QE2VpcXPpiagfZBx1VvKX/Mla75J3fLFrYhf0+Ja44Wlg9i26C0cYwclpLhZU4kWQRvMxLTzXguDD+RH4DbSiJujvxQ+Cq5f15Ec/SbPI6vJZkYvqTQJdE584osA2hfh/BTLfFhOg6YxkpCMFH7LizmAjMlIuvfmCdF1YdNLhyS/Xv3aGOWLX8XsuPQi0+cVxLAQ9yCFTW5ygd7EFRgQipy7McJkVCHUNJ+xlDu40d03Kb//q54uSGuVveZs9MibG8FcReonzSo/1Meqafddoym4GabMOoLc6OF2OwgReW39/kopLBTLwnrsKfcHDGEKeGgwnw3Ax20BsKoAnBUnfotY/zlB2nCU4z5Xi4GzB0e8N3YpVEn0SH1mk2LW5Xv2TyjJVQAHF2PVypwSYIo0ioakkmrWcMq6PDhx77awkz2bre4KWlzKWR6JyMOlZ28IwmjFV9ZlUQoDRNPWhv5HsXwFluO6Yd5NJMQe4UQ6vUoKzhqJdtGACpyThflg7NGimm0K4LT/7eMGJZyaA6uEn30DU4SpU5pFg2GBNpF278UmWtTCEMz3QvAYRUm782e+VzuVFEaY5MoVieoMvorz6mxFMZc8lJccQ7QZuU+VR7teR4r8RG/G5YkmLS6m7rBhyuJyz4uDUQ1yb5ev4yljrsTC3Am5/KUOkgtslmrklaRUMshI4yZFS/f6DCOP3bufW4MDlcAEx13q9iJEFOSY5W4tIP0UearV+SBumrV/gdqqmlTqRxlJYOfCAIS2ZwWlyNCHjmYO10H0UVxLJ6l39/f+Fn18FmudUOqV09EJfrZvolO0m5NTiXBaHvVl9f8yduj4SP7NXNek4zlgN5XUSd3mpmfmPW3d3A1MojZqbgffmWY4pUbi/NeqPn+/H79em/8MkoB7+ML/Sezh5D1yG8EqQzwgQcZcEu+wnFaERLB2atz9ZWuhS/NOKgH0XBIu0RbkkBN7T3K20cqJF3SiFkxpQf4eEtGBXWltO5qsYlkwz0mkWx25NXextt37lzr2QAf7ZnLBTqphMfNz4kD+o3rVreYOU5hxLo 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: 03 Oct 2024 12:45:44.1349 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52678788-1eee-4e53-780c-08dce3a94bed 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: SA2PEPF00003F68.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5706 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" This will allow to use flexible array to store the process name and other information. This also means that process name will be determined once and for all, instead of at each submit. Signed-off-by: Pierre-Eric Pelloux-Prayer --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 29 ++++++++++++-------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index e20d19ae01b2..6cd5bd5362d4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2331,7 +2331,7 @@ amdgpu_vm_get_task_info_vm(struct amdgpu_vm *vm) { struct amdgpu_task_info *ti = NULL; - if (vm) { + if (vm && vm->task_info) { ti = vm->task_info; kref_get(&vm->task_info->refcount); } @@ -2361,6 +2361,10 @@ static int amdgpu_vm_create_task_info(struct amdgpu_vm *vm) if (!vm->task_info) return -ENOMEM; + /* Set process attributes now. */ + vm->task_info->tgid = current->group_leader->pid; + get_task_comm(vm->task_info->process_name, current->group_leader); + kref_init(&vm->task_info->refcount); return 0; } @@ -2372,20 +2376,16 @@ static int amdgpu_vm_create_task_info(struct amdgpu_vm *vm) */ void amdgpu_vm_set_task_info(struct amdgpu_vm *vm) { - if (!vm->task_info) - return; - - if (vm->task_info->pid == current->pid) + if (!vm->task_info) { + if (amdgpu_vm_create_task_info(vm)) + return; + } else if (vm->task_info->pid == current->pid) { return; + } + /* Update task attributes. */ vm->task_info->pid = current->pid; get_task_comm(vm->task_info->task_name, current); - - if (current->group_leader->mm != current->mm) - return; - - vm->task_info->tgid = current->group_leader->pid; - get_task_comm(vm->task_info->process_name, current->group_leader); } /** @@ -2482,10 +2482,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, if (r) goto error_free_root; - r = amdgpu_vm_create_task_info(vm); - if (r) - DRM_DEBUG("Failed to create task info for VM\n"); - amdgpu_bo_unreserve(vm->root.bo); amdgpu_bo_unref(&root_bo); @@ -2608,7 +2604,8 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) root = amdgpu_bo_ref(vm->root.bo); amdgpu_bo_reserve(root, true); - amdgpu_vm_put_task_info(vm->task_info); + if (vm->task_info) + amdgpu_vm_put_task_info(vm->task_info); amdgpu_vm_set_pasid(adev, vm, 0); dma_fence_wait(vm->last_unlocked, false); dma_fence_put(vm->last_unlocked); From patchwork Thu Oct 3 12:43:13 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: 13821022 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 40AB6CF34A8 for ; Thu, 3 Oct 2024 12:45:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A3E2310E83D; Thu, 3 Oct 2024 12:45:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="vMMjghMW"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2067.outbound.protection.outlook.com [40.107.93.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id CAFDF10E83D; Thu, 3 Oct 2024 12:45:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Zy4ZSsNNUihagS8XUzY101ZDmFJ2LzLNX958NrswVmUoWJRYmW5Ms89W/4ArHW+ktazoe4dVMmd88r+y/VgMMHtEdyQDe8i8O7evspHnoYZni9BsA5/u/tktG4JZcQNYgNWrtan32DMbjN9H0j9hAI0H8B+eGkDLSwfprcQyUSyNSrh2W7Izg5VIB505HZ+ibZF2uo07LwpBuxRu5MDANr1QfDf56ZWEiO5iiGkXJTY+muUTQn3YmVbbjqVUywlVd2UCgeqdly0bMMdLJpbqwCvvpRw+/nhryXvFaYyAwmktLZpx5zHPqUkx1659PaY+1lhqTijUF2eRrNhU9py0mg== 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=3Iggs00ZzAIwa2gnAVKT5mtbzHYVfL4Ni9ls0jz6rEM=; b=yeFj/Tp7o3+1EGLrgBWjJ6zGROGSXmt1uxvzW8f8ixCgWj2Y7aVPp+Y/ELSys7KbG/EaN4Q2wz+1l0WuGDsBRtTb/ynhQosM2nlEDQLByyJeXgiI8dktFzYTzXC7OfMBfPWiVsea42bLv0iEc4tVWKi3HR1vGj2gmbHlO9XP6mvndosHz4D8A9JymmdgxXJgPvuf/IZo7hUTb5SeKyghcOhkI+d5BP63sGTLi5i4RrVkQ+MMjPyRl/JBJctpiDd7z11WAENo1j/ZmE0UkRlVGHV8zmC+/3T5LjsRN9HM0QUTGKVsVXdtubSoRb1kfYSA2VbnzzQjasrWh9ELcEnJgA== 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=3Iggs00ZzAIwa2gnAVKT5mtbzHYVfL4Ni9ls0jz6rEM=; b=vMMjghMW7rodeHPhScGBDfG/YOiM1fQAZ6chqc3UwJKg377qkw7WdGTxdYaGGNP+8h7YeQrzglYNBIiLYaobpsOLJeFHuqb598Gk3rF37/JkFQC3HVh+az92iLjNg6v+ZfMBab7TN61/GfM12Kz7aiFB2peB/MVv+vb5aglrI10= Received: from SA1P222CA0063.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:2c1::12) by MW3PR12MB4346.namprd12.prod.outlook.com (2603:10b6:303:58::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Thu, 3 Oct 2024 12:45:47 +0000 Received: from SA2PEPF00003F61.namprd04.prod.outlook.com (2603:10b6:806:2c1:cafe::95) by SA1P222CA0063.outlook.office365.com (2603:10b6:806:2c1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 12:45:47 +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 SA2PEPF00003F61.mail.protection.outlook.com (10.167.248.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 12:45: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; Thu, 3 Oct 2024 07:45:43 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v5 5/6] drm/amdgpu: make process_name a flexible array Date: Thu, 3 Oct 2024 14:43:13 +0200 Message-ID: <20241003124506.470931-6-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> References: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F61:EE_|MW3PR12MB4346:EE_ X-MS-Office365-Filtering-Correlation-Id: b96dec65-725d-41af-3e08-08dce3a94d8d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: fIJz99pIH+MdEU7r9RFBHnife0eJqVaikl9dADOp5XSAaFuxNrQyBh5wzKERHWcegswgT9FYg6CTxlpRHenAYBL3pK7O7mZgm2DqMi/w4LlqTnA9fJ4Rm4DxW9HTkhFa5FsCsbCzj6g5Qi1YzFhWSDWRcPPr4rE2mvvp5iCtzXBLFYT4bqAFkQFj6ukF2GrkqELdbdV/6L6905T16ELBPFb1F2RXUilkHNuSNwxjOXM7D3Q4lxYf1wQCP4G/aPV2f/d9QHCsEhpJFHKf7FlyJio3TO2p3/ZNw6vj1bPzmSPmMJPUzG5R87eBiuOqajU+wm8Rq9B9P9UA7Zh2sEjk+kIQl+2Bl+/K7vV5Cr1KMNYCd72twFbJ0MUycd4MaWfnoR4qn3cz0AHabzEs2KGr3xSn6+exRhFdr63NdCTqi4/fEb1yV751U8bJwmY8JOWb+nnobtPJsaWS+5woLeYiUI3qRM2XaLPc+PnKfUVC8sSJGyx331TeVsY+7yyhZXE2mQoMcVUOE5H/IjXkOTnI0JgHqH6LT7ErNQ13WOjRtwQ8IUJOrD/3WwqiSjPfwucHoepSHS5txWGACLTP+9a/tHR8DmEwwIgVNFwQQW4IVZVoSIufJrbeIMnaBUmWEBIy6Ox3+qlCABknhGZ4pBci8YCgrJSMIqqryZNItTO4QhC8izQVTADLAEqPTr+neRf36FG8BYXAKm7K+q01+a6Y1lGeGT6ZpGxfaznGXbl5lK+OVKnL4JXrH7i3ZdJG8CZqnZ2pqnjmy3nm58bMjlkCeHNVp++sCckmy70vEaeOG2o7KYoPrRMiphCtCHugSGb/5u9N41p0yepQ4SkGhUGJyXklg25p0knQmavKCn7PIcEzfFIcxCz0Li6quB/xvjyZy0bhMcK11tl/3L+gimXZ6Z8P7lauvgikdrz9rdNyXDA6yQPSzHZJkSWfjN/4Xh/qSpPFk3rGkmklI1qaaQOsWoJ80zHUP1eIshGRicjsxImAtbAjF1VWBzOeusBq168ZONuzlfPmb8EZ5ZtDPwC5J3I3zEWjMfvNPyyZId/jSWOvpLoETOFA/pSXl41TitDF++i1KapL8M8OTArXPy87gljqhkETlk5x7+9GVwzPoB/M4DPG6p419/grXUSBVc9Kz7S9d8AFVkgzWCB1Ve4ClXtIzZvx+I551YQw3ZeG7YXPI0YuQ209uzo/zGpsfQ+5Bfwj1vxAUK7YydT31Dg7sicCQx5BJAjyYT37rJqnCa7z/gOZ5jQbqarD0fH46WjYpyiPKdnv90XrRVbbspYgHP9I4wUSe7+9bZJVYj4gk4OubzZw3Ebubb+dCqnqL+KH8xELx9gMrMJEfypx3bHAy+xjtcGRppM0a1jL9bzhi8bcuvMe0sdlRA35adASIVVl 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)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 12:45:46.8910 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b96dec65-725d-41af-3e08-08dce3a94d8d 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: SA2PEPF00003F61.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4346 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" And rename it process_desc, since it will soon contain more than just the process_name. Signed-off-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 13 +++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 2 +- 13 files changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c index cbef720de779..c2185e43e38d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -1786,7 +1786,7 @@ static int amdgpu_debugfs_vm_info_show(struct seq_file *m, void *unused) ti = amdgpu_vm_get_task_info_vm(vm); if (ti) { - seq_printf(m, "pid:%d\tProcess:%s ----------\n", ti->pid, ti->process_name); + seq_printf(m, "pid:%d\tProcess:%s ----------\n", ti->pid, ti->process_desc); amdgpu_vm_put_task_info(ti); } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c index 5ac59b62020c..4ca0a372984b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c @@ -220,8 +220,8 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count, coredump->reset_time.tv_nsec); if (coredump->reset_task_info.pid) - drm_printf(&p, "process_name: %s PID: %d\n", - coredump->reset_task_info.process_name, + drm_printf(&p, "process: %s PID: %d\n", + coredump->reset_task_info.process_desc, coredump->reset_task_info.pid); /* SOC Information */ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index ad6bf5d4e0a9..d1678eebbff3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c @@ -125,7 +125,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) if (ti) { dev_err(adev->dev, "Process information: process %s pid %d thread %s pid %d\n", - ti->process_name, ti->tgid, ti->task_name, ti->pid); + ti->process_desc, ti->tgid, ti->task_name, ti->pid); amdgpu_vm_put_task_info(ti); } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 6cd5bd5362d4..561ff832930e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2357,13 +2357,22 @@ amdgpu_vm_get_task_info_pasid(struct amdgpu_device *adev, u32 pasid) static int amdgpu_vm_create_task_info(struct amdgpu_vm *vm) { - vm->task_info = kzalloc(sizeof(struct amdgpu_task_info), GFP_KERNEL); + char process_name[TASK_COMM_LEN]; + size_t pname_len; + + get_task_comm(process_name, current->group_leader); + pname_len = strlen(process_name); + + vm->task_info = kzalloc( + struct_size(vm->task_info, process_desc, pname_len + 1), + GFP_KERNEL); + if (!vm->task_info) return -ENOMEM; /* Set process attributes now. */ vm->task_info->tgid = current->group_leader->pid; - get_task_comm(vm->task_info->process_name, current->group_leader); + strscpy(vm->task_info->process_desc, process_name, pname_len + 1); kref_init(&vm->task_info->refcount); return 0; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index d12d66dca8e9..44da250217be 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h @@ -232,11 +232,11 @@ struct amdgpu_vm_pte_funcs { }; struct amdgpu_task_info { - char process_name[TASK_COMM_LEN]; char task_name[TASK_COMM_LEN]; pid_t pid; pid_t tgid; struct kref refcount; + char process_desc[]; }; /** diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c index 9784a2892185..c82364e43a15 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c @@ -166,7 +166,7 @@ static int gmc_v10_0_process_interrupt(struct amdgpu_device *adev, if (task_info) { dev_err(adev->dev, " in process %s pid %d thread %s pid %d\n", - task_info->process_name, task_info->tgid, + task_info->process_desc, task_info->tgid, task_info->task_name, task_info->pid); amdgpu_vm_put_task_info(task_info); } diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c index 2797fd84432b..4dace3de1def 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c @@ -136,7 +136,7 @@ static int gmc_v11_0_process_interrupt(struct amdgpu_device *adev, if (task_info) { dev_err(adev->dev, " in process %s pid %d thread %s pid %d)\n", - task_info->process_name, task_info->tgid, + task_info->process_desc, task_info->tgid, task_info->task_name, task_info->pid); amdgpu_vm_put_task_info(task_info); } diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c index edcb5351f8cc..e56d702fbfed 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c @@ -129,7 +129,7 @@ static int gmc_v12_0_process_interrupt(struct amdgpu_device *adev, if (task_info) { dev_err(adev->dev, " in process %s pid %d thread %s pid %d)\n", - task_info->process_name, task_info->tgid, + task_info->process_desc, task_info->tgid, task_info->task_name, task_info->pid); amdgpu_vm_put_task_info(task_info); } diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index 86488c052f82..5fca64e71ada 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c @@ -1451,7 +1451,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev, task_info = amdgpu_vm_get_task_info_pasid(adev, entry->pasid); if (task_info) { dev_err(adev->dev, " for process %s pid %d thread %s pid %d\n", - task_info->process_name, task_info->tgid, + task_info->process_desc, task_info->tgid, task_info->task_name, task_info->pid); amdgpu_vm_put_task_info(task_info); } diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index c76ac0dfe572..c54c86dac14f 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c @@ -635,7 +635,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, if (task_info) { dev_err(adev->dev, " for process %s pid %d thread %s pid %d)\n", - task_info->process_name, task_info->tgid, + task_info->process_desc, task_info->tgid, task_info->task_name, task_info->pid); amdgpu_vm_put_task_info(task_info); } diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c index 23ef4eb36b40..ea1990c19803 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c @@ -2186,7 +2186,7 @@ static int sdma_v4_0_print_iv_entry(struct amdgpu_device *adev, if (task_info) { dev_dbg_ratelimited(adev->dev, " for process %s pid %d thread %s pid %d\n", - task_info->process_name, task_info->tgid, + task_info->process_desc, task_info->tgid, task_info->task_name, task_info->pid); amdgpu_vm_put_task_info(task_info); } diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c index c77889040760..df00bf480dcf 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c @@ -1701,7 +1701,7 @@ static int sdma_v4_4_2_print_iv_entry(struct amdgpu_device *adev, task_info = amdgpu_vm_get_task_info_pasid(adev, entry->pasid); if (task_info) { dev_dbg_ratelimited(adev->dev, " for process %s pid %d thread %s pid %d\n", - task_info->process_name, task_info->tgid, + task_info->process_desc, task_info->tgid, task_info->task_name, task_info->pid); amdgpu_vm_put_task_info(task_info); } diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_events.c index ea3792249209..95ba07ae3b89 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_events.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.c @@ -1267,7 +1267,7 @@ void kfd_signal_reset_event(struct kfd_node *dev) if (ti) { dev_err(dev->adev->dev, "Queues reset on process %s tid %d thread %s pid %d\n", - ti->process_name, ti->tgid, ti->task_name, ti->pid); + ti->process_desc, ti->tgid, ti->task_name, ti->pid); amdgpu_vm_put_task_info(ti); } } From patchwork Thu Oct 3 12:43:14 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: 13821023 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 945E7CF34A4 for ; Thu, 3 Oct 2024 12:45:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D58E10E843; Thu, 3 Oct 2024 12:45:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="d/XGZVxt"; dkim-atps=neutral Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2086.outbound.protection.outlook.com [40.107.96.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id EA1BC10E839; Thu, 3 Oct 2024 12:45:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PBei4riAKT7mhKPbkVejyMkLVyEdAjsJK2J5b1LsId2fSNMhQmxvYj4ycxrpSSiSVtQqkxYYy3ZsdcWI4HxDYhNriodZUZtOYXcS4PWvOS4n63o9Xr/5dcXyVd4MP19BxOJuR8slMQ98oGGCBT+/sU0TV5b0H62AhHpCtRYzIEPAovyEWxS6lcwndHMAM2KbvDMx3gQtVSEZLcXBG7T0fKqq665uYOR6msw4t90XvcL5UP1r+r+hrkKrGBV+7HJqxuNeydqcYGvTzfH92cgn6UZWd7/GDWsZWgXoqx/MWDati6STNjNaIHGrbUxUTD9ktoilqZklQ/Ip1V5Ris1A1A== 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=yowdtSHK/j4j19l0+TOb8v//t93Bdyd+0ZarGUsnhxc=; b=mFEKtHpjaPu+jjtLSx8fS9zaLma5GtlEcCPkowpnwF9TaC3I83zARyQGJQOWWbaTdWIOpIHU8QB7+bhTIbkazNon5EpDpcicDtxFRsZUZwIPdi4jodTV8bexs85X8cdk7rgvyRqDzz9h0rA/NaBD3lW578uHdlO1EtkhWYEtO1emSv6Hfok5mj9uU7nXxScjBhKGJ3tn4pwGlnJO4i5pzdhcXUtxFF2hgA3wWOtbFE4qmv/389Enr6QLiDniJVkFzROG7QyJcTqyqVNWjw+8Ot1THRv5Ap9Za9LTG+xo3/JIeiZ4VagFEJ219updsXknjA9iCM11mX2ykZrZNy31Bw== 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=yowdtSHK/j4j19l0+TOb8v//t93Bdyd+0ZarGUsnhxc=; b=d/XGZVxtYSOVvfhLvYH2quVKdRPPg8QLQnumUsYUx9WMjDWyGdaFHJbB2XT4kmhDNTKq2AF68OID4ZTY/ANJYCNYTOtZH8wQQ0QOMKHARiE9W2c+p4O51MOXwhV0/+DbetOuez0DeWNGrm0uJ7e3pGInwNW2F8mt1qgKj0bbrxc= Received: from SN4PR0501CA0012.namprd05.prod.outlook.com (2603:10b6:803:40::25) by DS0PR12MB6536.namprd12.prod.outlook.com (2603:10b6:8:d3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 12:45:49 +0000 Received: from SA2PEPF00003F68.namprd04.prod.outlook.com (2603:10b6:803:40:cafe::fa) by SN4PR0501CA0012.outlook.office365.com (2603:10b6:803:40::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15 via Frontend Transport; Thu, 3 Oct 2024 12:45:49 +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 SA2PEPF00003F68.mail.protection.outlook.com (10.167.248.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 12:45:49 +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; Thu, 3 Oct 2024 07:45:46 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v5 6/6] drm/amdgpu: use drm_file::name in task_info::process_desc Date: Thu, 3 Oct 2024 14:43:14 +0200 Message-ID: <20241003124506.470931-7-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> References: <20241003124506.470931-1-pierre-eric.pelloux-prayer@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F68:EE_|DS0PR12MB6536:EE_ X-MS-Office365-Filtering-Correlation-Id: 74777d48-c15d-47ac-1682-08dce3a94f18 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: iXbMnb5pesZTYAz9JDvNmvA1iBZvOZ0xd5korZFb7wng+9yrvYuMgMrPKA7WkKJ6tUNzRvnBskD0YhX9k+sZ6TdA/MEBUlwjX4bY1xy4n6L0N1n6Vceau29HPZCe1H24qJiar/ixse6GKVTUG8IARuoQN65VI+GHLGS3MyJnk2nrX1gv9BU1xKJAzB8KHB3WUAq9n5mH/fl3NeBmPYR+2EVPGU+zHJaFaX0qrIPeRUgypE4Uj8iaT7bsmQJ+nqymW+IDR48iBV3U6IFWrFq4MursQF6P3O1fWK8JdmOe0QYMLOgmN624cLCHhdtfy00HXa4jeJg2/UdiPcOvpUGrU0YycQ9mBclJoG+myDSCa81kfSOdGnKh7mRUD7429Dlf2jAJoZAYendzGIFHbWxsR5JsAR2yOd0u7UEKxbfMg96vPHefO8w2nE8yUfOBfRAHPqJn0aAQSkU5GBQdj1unXqlQ91aSFXG9COxD1PpRWhBrRmwlPuchG24zryQ1Pi5F3MWznDR4UtI1gHg4K4D/SK4u4+Bv7dbeeQlwVdAVQcOaPPD2+grWDnbgs5C8R6UoTsSmj+hZCscAPTJM61rLKLAQeQiOwxtBSXwdFjx4rey+sHwHwzWEN2gG8SQTLlL0Z3JdBkeGYqWbp9loUAiieiVvkeZh0ZsGmoARW5JzyN1GolGMuhN1v2Dxm3GO4V5f16L4XiiBAaL93JSHyuI130iZQnVWvW2VUK/OkJoJFIe+VaRzWMEffD04+p/R2ufm9lwbfea1YnwSkQW0Zn8xi6ZRxvPOcHTIE+T0KlhjbFNf1LAWWok1OXyrKQEhsH4Ae0zAXqZLp78hNbqRfZYilFdk6HGahWIsjt6YbDdLg+wjElym4LPdKquZWa121+1NbKmLDgAWtWoJr62vTh++ZL7XpTtyJMCxlAGC/qzg0YH9IVg5IVrBE/p4PnoSl3uGkZXCnOdbbmJe6U8GyFtwFFr1EaSB3Z38QLaX3lQO/j3n+fSARj6MEZ69lg1Yru8AAJFUt/DWin638tSizeAI/y1bzV+C9rTRnVPWzwqD8qDrwmFIJj8pcBOApeJTKj23HqLnZYXMC6JPqppYYfjvRO12GzM0yGKS65DmMfZJRFPSJr2EE1eQi/Hd2ov2AnSlNLoN8gkNIicspNzPemSkGLQ/4dG9oXhLEvaG+aSlBYx8RQHnT6YLaK/Wd9qiVUV7cumcwbiztONVAkv9zA35QH2NMV2X+zARoOXAu7qo63hmFTgGfHQ1t4MEVkx/ZKPbpHMiukL2HwLpv9nRkV/6jekZhrT7QcQaooiYZegX9UQnXESp4oMdjGix/4IDjCWqjMwCl8ycom+sTVrNEroU53EmLbWrIARaiMDQPe7Ux7RCaDHTkxWOzATT7RUaOQFJ 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: 03 Oct 2024 12:45:49.4787 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74777d48-c15d-47ac-1682-08dce3a94f18 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: SA2PEPF00003F68.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6536 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" If a drm_file name is set append it to the process name. 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 --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 1 + .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 34 ++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 ++ 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h index f9d119448442..ad909173e419 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h @@ -299,6 +299,7 @@ int amdgpu_amdkfd_gpuvm_set_vm_pasid(struct amdgpu_device *adev, struct amdgpu_vm *avm, u32 pasid); int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct amdgpu_device *adev, struct amdgpu_vm *avm, + struct drm_file *filp, void **process_info, struct dma_fence **ef); void amdgpu_amdkfd_gpuvm_release_process_vm(struct amdgpu_device *adev, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 6d5fd371d5ce..172882af6705 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1558,6 +1558,7 @@ int amdgpu_amdkfd_gpuvm_set_vm_pasid(struct amdgpu_device *adev, int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct amdgpu_device *adev, struct amdgpu_vm *avm, + struct drm_file *filp, void **process_info, struct dma_fence **ef) { @@ -1577,7 +1578,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, filp); return 0; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 891128ecee6d..5d43e24906d2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -1178,7 +1178,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p) } /* 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); if (adev->debug_vm) { /* Invalidate all BOs to test for userspace bugs */ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 561ff832930e..920660c23e0f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2355,24 +2355,41 @@ amdgpu_vm_get_task_info_pasid(struct amdgpu_device *adev, u32 pasid) amdgpu_vm_get_vm_from_pasid(adev, pasid)); } -static int amdgpu_vm_create_task_info(struct amdgpu_vm *vm) +static int amdgpu_vm_create_task_info(struct amdgpu_vm *vm, struct drm_file *filp) { char process_name[TASK_COMM_LEN]; - size_t pname_len; + size_t pname_len, pdesc_len; get_task_comm(process_name, current->group_leader); - pname_len = strlen(process_name); + pdesc_len = pname_len = strlen(process_name); + + mutex_lock(&filp->client_name_lock); + if (filp->client_name) + pdesc_len += strlen(filp->client_name) + 1; + + /* Add 1 for the NUL char. */ + pdesc_len += 1; vm->task_info = kzalloc( - struct_size(vm->task_info, process_desc, pname_len + 1), + struct_size(vm->task_info, process_desc, pdesc_len), GFP_KERNEL); - if (!vm->task_info) + if (!vm->task_info) { + mutex_unlock(&filp->client_name_lock); return -ENOMEM; + } /* Set process attributes now. */ vm->task_info->tgid = current->group_leader->pid; - strscpy(vm->task_info->process_desc, process_name, pname_len + 1); + strscpy(vm->task_info->process_desc, process_name, pdesc_len); + + if (filp->client_name) { + /* Append the drm-client-name. */ + vm->task_info->process_desc[pname_len] = '/'; + strscpy(&vm->task_info->process_desc[pname_len + 1], + filp->client_name, pdesc_len - (pname_len + 1)); + } + mutex_unlock(&filp->client_name_lock); kref_init(&vm->task_info->refcount); return 0; @@ -2382,11 +2399,12 @@ static int amdgpu_vm_create_task_info(struct amdgpu_vm *vm) * amdgpu_vm_set_task_info - Sets VMs task info. * * @vm: vm for which to set the info + * @filp: drm_file instance */ -void amdgpu_vm_set_task_info(struct amdgpu_vm *vm) +void amdgpu_vm_set_task_info(struct amdgpu_vm *vm, struct drm_file *filp) { if (!vm->task_info) { - if (amdgpu_vm_create_task_info(vm)) + if (amdgpu_vm_create_task_info(vm, filp)) return; } else if (vm->task_info->pid == current->pid) { return; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index 44da250217be..8df3dece54c2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h @@ -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 *filp); void amdgpu_vm_move_to_lru_tail(struct amdgpu_device *adev, struct amdgpu_vm *vm); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index a902950cc060..e473fe433d3f 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -1654,6 +1654,7 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd, struct file *drm_file) { struct amdgpu_fpriv *drv_priv; + struct drm_file *filp; struct amdgpu_vm *avm; struct kfd_process *p; struct dma_fence *ef; @@ -1673,8 +1674,10 @@ int kfd_process_device_init_vm(struct kfd_process_device *pdd, p = pdd->process; dev = pdd->dev; + filp = drm_file->private_data; ret = amdgpu_amdkfd_gpuvm_acquire_process_vm(dev->adev, avm, + filp, &p->kgd_process_info, &ef); if (ret) {