From patchwork Fri Sep 27 08:48:37 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: 13814028 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 726BFCEBF8B for ; Fri, 27 Sep 2024 08:49:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 924A010EC8A; Fri, 27 Sep 2024 08:49:39 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="N8gy/a3h"; dkim-atps=neutral Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2054.outbound.protection.outlook.com [40.107.244.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6C9A10EC85; Fri, 27 Sep 2024 08:49:37 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B2kHi7uKugrCSyt4GWltG9etOjiCcClZ3zByJ8X82aO11ebVoWm3d/YMUyR/Z05ntq9+Q1pxXn6bNWV9EUJdW4FO3/9rJr9sPp7cyeoUppkeSfIYU2DqCslS0NcaegcARCzjiCYhJ8DbV90W8R0Eid0/sqdNzIewWz0tzOo/h7XSrP2z8lpqzloHe05pSAgKjjbR4wTm8eNMMh0i5MfAOKwUsFl2ox0v/RHrFc1vsd7d/qu2E4d79zEaMsbkIak8qFWv5cmeGz4RGb/xhRWzUnp/K7BwWcOYl0n7OHwcPyqAJnv/BiLxLDtIYLPY85zaQkOwBq679xzInxj8WvCrdA== 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=8TWxvS1gAAc2vuvvWzVkLgCBNimbGdd07BtLlJIAljE=; b=T9XKxYiC6aJOX4tB+n1/8pMYCMA/YXZXQL9SMAZQwo5L8EfaQJYsP5t3K1ej9C2DWgqFwy2BZPo13qRlHsNFxHeXnAG3BsnOJ3nFSPkR309ZqVco5+PR3ho4zysXsPa4q6ZhAyaIoI4K+pD0JdMrSyhA3NWrZnMFJ3yY8p4RQ2HhCLvvCo0ddhr5EMT+ZxNtU+XiHC91+B4YRba4d0dqRt/Cha36j+dVdjKZpnk0Mxlw4dWVCwymCSr9+c2vcz/9mFQLtbsyKBfY7kTDr8G2z0gThsOJU5i219WQ1qFsQUbvxF2zcVRYxXqzis9NneMP5jybAu93h6iCySy8bbgFMA== 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=8TWxvS1gAAc2vuvvWzVkLgCBNimbGdd07BtLlJIAljE=; b=N8gy/a3h1mgqRx7YG9NdO6yjFrKDE+QjXC+6soHo2TB5E8jk3yCGLZmIkRCAn7jesxYNm9J56bpOLj98PGU8G29RLuOUWgWzt3yLT8wXnGFFPs7oZtHwE1c1p7r0sgiOBxBcmdMp1z2KwW5P+PM5cFOZX+GnhQrzMv2X3dOey+Q= Received: from BLAP220CA0012.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::17) by CY5PR12MB6276.namprd12.prod.outlook.com (2603:10b6:930:f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.22; Fri, 27 Sep 2024 08:49:32 +0000 Received: from BL6PEPF0001AB52.namprd02.prod.outlook.com (2603:10b6:208:32c:cafe::e2) by BLAP220CA0012.outlook.office365.com (2603:10b6:208:32c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.17 via Frontend Transport; Fri, 27 Sep 2024 08:49:32 +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 BL6PEPF0001AB52.mail.protection.outlook.com (10.167.241.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 08:49:32 +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; Fri, 27 Sep 2024 03:49:29 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , CC: Pierre-Eric Pelloux-Prayer , "Tvrtko Ursulin" Subject: [PATCH v4 1/6] drm: add DRM_SET_CLIENT_NAME ioctl Date: Fri, 27 Sep 2024 10:48:37 +0200 Message-ID: <20240927084848.263718-2-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927084848.263718-1-pierre-eric.pelloux-prayer@amd.com> References: <20240927084848.263718-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: BL6PEPF0001AB52:EE_|CY5PR12MB6276:EE_ X-MS-Office365-Filtering-Correlation-Id: 48320d37-9586-4a97-fc22-08dcded14e47 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: x1orUmQDjPG/2kXk0GMNwe71HVFGpMw76GJVjDLVQiMNMAie+eBZmF5OCBRttnoZF3XfnrZkfx3Or70mZSJAHXQKwqgsI/kXQWfUjNgwJ39p2T9kikIPZICz8qGmdRRimDiyCpZU3MIih5MOxXeyR7dwkanmqIq/SkifS9o46VCMoBix95EZ3+RPBq5bPs37/TQK6hi/QfbNY9j/eUS0hd5V6WneT9VyM7wy6hNtO00elbNydjGYsw8JP61goMY+NSVLio60/pZMS3RpEob4G2AWgLJyRRkXoIpSOPqbEJeFV11C3LuFp6wZWVa+rRlY3z6nICdQw1RML2QPmNV1sJq5IjM+S6rvJU+39FKy47XGhnJ1DjuzAVDwxY3HnrNrzCaZbOpOJi9BTHV0P5iuJv3FRMZNFDQG2FQrY/0Shgv5j/296/Osf5IhyUMmEFoQHwIIl7No/JLbhYKv+SRy8+/bUlkssqHrMqof/3FMhNS53PaORuSCkKDDpzEE+pGOfx60oWNqb9qPzKYdf+8MdgbwnaXOIP/IPfnlRHBc8j+T5NjE+ibEeqfWL9skLzn0pR5Y3aWdVFyFBDcziAF38ptnr791t7S+fqrRAcUpUo1uCQ+lYHRKjCVV09iq3P5HpGMRqKwRWfjqP8ehgBGhtBphCv1xvNQ7Yu9usjQ71K+qPTIGuY7nBAcWE8WlPt6+4lP5ui+QTKHNFhn9S5WY2UJbXlcS5EkdbXdfNax2W/lfnqq730FRaMb6gi1XtxlMdbyjkI7FVTVJuJrDS68fHw4kxB8MCcU3z+Hq4ur6K0BOMvGXLUTMxYQ3M/YM5xvRPrh35x5M7bXHIWkzs487B7XEWa6lrnZ+o0oUzcfeHYW69J2CfEAVnYSlYc4XtV61bMigyVe94re2Ww0wKKlCH1sVj0woNEcI59R79phrm2dX9CUyKgcdViLylTbsTfYLZtHWyNSRnoeQDCGsiMb+AW2xC1HUzJ8Hlfjx0jNb9ntY4r4aXo0UnG6bp9wCcUdCov+X3XqSFz8ON0Dc2ZnhMUjts9UzRgsOo865KiNYVETA5bICZEMJYaQ1YB6o/Hmau96qHj1d3JEWAxc2d/ejSMnvUP04geaaKW4e78DY7hTAOmeihUB8uuUcBZ3x1HOJkxrbmoaYv9fx/0t62tJeuNwZmzoCK1xvbbO5+mLESyjAycAJ0HM2W2Y1r7cz+Txk7s1Jd/lLIyOLha6TjdctqvuaCQ0c58PoDVK3iY0QoLt22pXicAVKwiltbAsnEL5eHXfspYkuKw9XPFw0xUHIh3hhkXVb+RbVRgErNYr+jG/VRk1P9TzICB9DiSQtHM02 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: 27 Sep 2024 08:49:32.1858 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48320d37-9586-4a97-fc22-08dcded14e47 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: BL6PEPF0001AB52.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6276 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 Signed-off-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Dmitry Osipenko --- drivers/gpu/drm/drm_debugfs.c | 14 ++++++--- drivers/gpu/drm/drm_file.c | 5 ++++ drivers/gpu/drm/drm_ioctl.c | 55 +++++++++++++++++++++++++++++++++++ include/drm/drm_file.h | 9 ++++++ include/uapi/drm/drm.h | 17 +++++++++++ 5 files changed, 96 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..df8d59bd5241 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -540,6 +540,59 @@ 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 (value[i] <= 32 || value[i] >= 127) + 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; + void __user *user_ptr; + char *new_name; + size_t len; + + if (name->name_len > DRM_CLIENT_NAME_MAX_LEN) + 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); + + len = strlen(new_name); + + if (len != name->name_len || + drm_validate_value_string(new_name, len) < 0) { + kfree(new_name); + return -EINVAL; + } + + mutex_lock(&file_priv->client_name_lock); + kfree(file_priv->client_name); + if (len > 0) { + file_priv->client_name = new_name; + } else { + kfree(new_name); + file_priv->client_name = NULL; + } + 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 +663,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 Fri Sep 27 08:48:38 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: 13814029 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 27EDCCEBF88 for ; Fri, 27 Sep 2024 08:49:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7A7610EC88; Fri, 27 Sep 2024 08:49:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="I7URn1Wx"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id B4AFD10EC8C; Fri, 27 Sep 2024 08:49:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dipxB55kousNSj3V/ImvgHlz3jMc66kLenEvzVQgWsL51LNGSxkrU0rF6sAun48APkGUDs7gPBYkSdLRdyTzP/YlVpgurW+HOd+nTtI5z4IZSj2hHYkFP4K+TY8dY5MYJ1gQvSO3ZOlfUYfIHeQCYJQpi7P4/dAfuPKlF2gNxotqW8p97iKvOLThfp3n+lPAzxEKmY46dYhyjmU4mIGuwuI6MckzX/wuwD0LoprDEA9olOeBFfL2W9FAyTbBZVYUEUxZAs61ADnCEDi0Y7uOt5fIp5Q6ct1qDH9fpST3RNLOTY7iwacgw6t43gAhrUGIgkr9LXPXLaxuD+olDDm1Ug== 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=TSL4RoJFg3UMdlJ77f4EyTfIoedLysvohnqyX3bsGIrTvAtPOfu9gUdo2a4js1OleNk1gdAH8Zq5AIpLl3v+jaJ/H3D/AplS3tJfrh0CMkmsbvlfmWjDTeBFRjiwm47+17ZkJAQLm4mJBLNmIzZtHAbIsU0gprosskl1VI5nUbGPsuQl0ch0C6Qoa4vA1TwcCqxGaWwIETS1KvZWKFM6BNTOj1YKlh3QFWyPcczdgeJMnj4M0aIrjDNd1yolzKZFeZhE2sv0yOufBUN4UR2g/IZR4T/eKwS7ns0l80Tevpc4bccXg0hN4MxLBUrbfseo0HqVmzxtY31FMlNUFgmCOg== 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=I7URn1WxWgAed35KCQV4GsVpuUdUZNAbdQ5JE80OjCM0aN1SNk91S4Al2tT6gJKsCN3WZLDzS8NuKoiD2j44OXhgE4WxuVjd4LqK+Y9jCXcLpawBf79QjmnwRCmEOUWyFtwAQrHSv+Kfac++s8s55TM4v3jmWJtpsef1W4BPY6Q= Received: from BL6PEPF0001641D.NAMP222.PROD.OUTLOOK.COM (2603:10b6:22e:400:0:1004:0:12) by SA3PR12MB7950.namprd12.prod.outlook.com (2603:10b6:806:31c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Fri, 27 Sep 2024 08:49:35 +0000 Received: from BL6PEPF0001AB53.namprd02.prod.outlook.com (2a01:111:f403:f903::3) by BL6PEPF0001641D.outlook.office365.com (2603:1036:903:4::a) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.28 via Frontend Transport; Fri, 27 Sep 2024 08:49:34 +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 BL6PEPF0001AB53.mail.protection.outlook.com (10.167.241.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8005.15 via Frontend Transport; Fri, 27 Sep 2024 08:49:34 +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; Fri, 27 Sep 2024 03:49:31 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , CC: Pierre-Eric Pelloux-Prayer , "Tvrtko Ursulin" Subject: [PATCH v4 2/6] drm: use drm_file client_name in fdinfo Date: Fri, 27 Sep 2024 10:48:38 +0200 Message-ID: <20240927084848.263718-3-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927084848.263718-1-pierre-eric.pelloux-prayer@amd.com> References: <20240927084848.263718-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: BL6PEPF0001AB53:EE_|SA3PR12MB7950:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d037905-6e09-4d54-832a-08dcded14f9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?SD8lfKUpewc+BNaF8rQh2Aix+54pcm3?= =?utf-8?q?wCGpRfAxlw+8WUuds4kqsJzrPnV4uM4csD0CJESKYOSnuf+/uFPfdUD/LL8Mxmp5d?= =?utf-8?q?8jZIm3yta7pwjpT3C+n+C3Fyz9G5rw9p2oJbFvvs/6Mahbz5mrHa7Ys/uTHGxdizN?= =?utf-8?q?ZX/RBa4oSZ5xck9mkx9rTr5GI6/7uhtyxW/Og3RSZ6HrRdSW5ddA4B8jk+AiXRCzp?= =?utf-8?q?LPEEwwIxAXocNqEO81q1xM4s82LJEFsp4MeimrrIRw2hwst4MhYhCPO5dT1qvSlQC?= =?utf-8?q?i7fQX9JOddqXREO/OVMDJN4gXMmPNtVO3KkOwf5/yBD5wys2yiaW0UQEnvdV3TPmL?= =?utf-8?q?lixdGsZAmsRtINFZDrUFRwAjp8TcATPgyQONp0WlD+3+UR+oY+9y2GpVGKawR4MFQ?= =?utf-8?q?U0vn3pFGQFz7ivuQUlFWSS3dHq0eeRyxY9/qyZm1vx/C8Qa15EttdbdiK6btLtu/7?= =?utf-8?q?T2V22Lh40pX0hB7VNVY8fCOceBHl3QvR56QhZvycu8OLseujxe31BJvJGeuYngfTE?= =?utf-8?q?AiCN0icdR0uySfrF17vWBkV+sxmsBEf088Zok5n8YWFgPT0tcDW+uDkJuXXhXkXPQ?= =?utf-8?q?APBW2ZfAIvomMiOWSIgxDczpQmudRrfbG4KtmeMgE8ProuK9OEaOhHPH0i33mi8K0?= =?utf-8?q?CUrg/0fJvnIk+OPKo3UeesvzLj64CqA1AI8oUumHtZl8ZdoTIftWJYK8I6iashz+P?= =?utf-8?q?/vfa2fI3ekpiEOD9I7njZPYVSIUrUtLN9KNVCsOFqlBp9NPxSieOzcDEwB6wQQnUp?= =?utf-8?q?bbasn1UAaeOBp3s+iQgvsJHeK2bkeBmdrzJ5tuqn9ZniNa5Zh3WtTf35SAQvLTudH?= =?utf-8?q?4Vq1qX99zzu1EwFtY25HM13CEHgxBtghoxUFCIbkpqxrpAensc05VzxScgtb9X03f?= =?utf-8?q?TFg7t23Maes02Tk7+9cv2RY7QyST89146DPwwtiuTFTU0pAWeesrE1aceS+0pdC48?= =?utf-8?q?zyoiAEaH88Gp1/adOcMaOiWswYxh4fMJ16Uw1wAHlwCyaGNL77XUjVDTPSlX59Nxg?= =?utf-8?q?V3+pkkq37moqlNQIR5lOpBfIwbw2Ra5F6KFsFHKgh4F67WJNFhl46hW0ctptwhogA?= =?utf-8?q?dcjMyTJ/nM24n5rXFexG4yYnBDOtSfDLB56ONYDg/eAp9zppdn03u5TCG2+AMtE1t?= =?utf-8?q?zADKQ08n1SKIIBPckWEdrfZmfHbWdoarb2+Bcck2sfTZwzr77g0MYkbEey/ArsJA8?= =?utf-8?q?kLcEGcFYivJvSBW4LPu0igeRVqX17jGNwCPpSIAp0S13aRTTBdIBq6HCtxzIIIbPa?= =?utf-8?q?4z5HaHqKuhIrFh/7okD0HTR5hVvB1IdnF6pmn3qCVCQJCMPggYawGAFe6fsfIdARM?= =?utf-8?q?fzfwfw0Y1SRo?= 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)(82310400026)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 08:49:34.4043 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d037905-6e09-4d54-832a-08dcded14f9a 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: BL6PEPF0001AB53.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7950 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 Fri Sep 27 08:48:39 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: 13814031 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 8EBE1CEBF8B for ; Fri, 27 Sep 2024 08:49:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1013C10EC90; Fri, 27 Sep 2024 08:49:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="P0w0bx7N"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2075.outbound.protection.outlook.com [40.107.223.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id C705210EC90; Fri, 27 Sep 2024 08:49:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ASeBD37MdIZ9y4m2/tEMcsoPDLG11zrNiMmdP7ZytbG6uuemHLyMevG0maH5kWaeDZAqoHLaOSnTPslwxQFdALRYePdZS80GeEeA6FvZsglfsBlZxhGZxz6dqVzUP8+gVBU02eO03lR97HlRjsgWOQP9ztjdkb9cruXhxMO69I/zR+R0mC4H79WJLApUQCcVyHZ2OLx1i77hWkIYM8mF1UB7ELKGlyF9zJPm7+tqubPeT0AAyJmbDP2jfVufT6E4kGkj+Fjk+Kt05DBRG8rGMZm0K5vRqf4/hQRj8PQ6H7arXy1d8kUV07LjE/pgC1b7UY1FjF6YwbQUIj1rkbCshA== 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=nhbuAL9dpSp1/uk19wvJ4cWbjRsxVuYB0uDvOOXbjaVPjcY426VfevTyBotJ4oJKcWb6rvu6cOXSw/6VFh/3nYIcu5ba5BjPYtYSCU0YGixDP2t4EcrZRgL3gIMthzrOSapUopsst1NuILKXRY3MSg/1g/SeSFPd7L4BzHN86tcyYXo7+TeB9VJHdUkRfEN9jFmqJ3oPyKjjZ+vXV+Xbtpt+G4FlsdNEEbG0W8PEJVa2zM92YxESTQZHhHCtUts1tcndXpcDFTbgcNKEU4H5mBhtXK5SdaPAMC4AVxPeHVkg5+8sy3wv9Ipbl6Vv/rQ8YYP0oOAE/3cVnbezfh2CZA== 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=P0w0bx7NB4xRGmmAzJOa8Zi8QFQgUp5KRNcC6Yy1w0pIhDv/XB8TGEA+g+dXGNwYw8cPTsmBMkiVVHc5dUTwVva5X1/UiFDMmdRDCWKJ4HJc4pnB+brXxbwuquAdzLlw7IEg4hjx6Y/PG+O6sDJS11dmLlL61ereWXAMKhqyGZQ= Received: from MN2PR20CA0056.namprd20.prod.outlook.com (2603:10b6:208:235::25) by PH0PR12MB7888.namprd12.prod.outlook.com (2603:10b6:510:28b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Fri, 27 Sep 2024 08:49:41 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:208:235:cafe::56) by MN2PR20CA0056.outlook.office365.com (2603:10b6:208:235::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.25 via Frontend Transport; Fri, 27 Sep 2024 08:49:41 +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.8005.15 via Frontend Transport; Fri, 27 Sep 2024 08:49:40 +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; Fri, 27 Sep 2024 03:49:34 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v4 3/6] drm/amdgpu: delay the use of amdgpu_vm_set_task_info Date: Fri, 27 Sep 2024 10:48:39 +0200 Message-ID: <20240927084848.263718-4-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927084848.263718-1-pierre-eric.pelloux-prayer@amd.com> References: <20240927084848.263718-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: MN1PEPF0000F0E2:EE_|PH0PR12MB7888:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b4a4325-542e-4272-00f4-08dcded1536a 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: cCGj1u3b3qkkbbHcp7AsjGXQpHQNaXhePEhnkIZ6DUrLpLfSyMgzflmvUPKg5WLvaE67ZDKZO8LG9cbRA6Cj9EfwnGUyg/QdDj4JtbExg+XwS+1cLY0G9+IFLNhkjxHTom7yAtOGfgKR/FRotxQZSXR7fI8Yh1RCi9GXtfB8yJ3iG5maP6gF6pfH8IOQokBecKsfteeAvE02d0LP6E7tNmy4fLpTIBcQol8oxHaRTGNHdyLZIIQU9QH5ibOXlwzggJT64c7Tgi88BarIEsa7uxWyx9NbAIl+83deBhkz7o4MFeGUSzMlLLOJRR1fjCQS5HsC+jIxyRj4U9IueM1mj0ttycFS6OnWyp4J+J6W+Qk2OWyVO9X+63NsgxYUB4eOVT0RULW8KSUDTPkhCIO/YVgfTmbR9mNIr0iBhzdDvqpme7I3IPrNVZ3Cl/S5AocYAZmqvGuGDfD9je9BSzBEBORj4b7g7SX/EQ1u2wTMoOu2D2ZAD2kAlF91zNPHPzVHD8J13s44SlZ/3PELE4+AYN5o8BZy1T6P5dOSG5on58rIaNcgAzrS9/zF5PCvEFMEqz/aWupfNDMI89W6kdVOwtqiYLtYJ0Ue/mYeQ6F7oWNqyzp0J7R9mxhtfraZR0y/XJ4Zy/dSSd0KnhwkmYQuGW6goDRQU/kn2NOfCBY8hpvb3wtbdJZF/HbGwpu7JGQOCjugOnqGc5o9hZu1WKO7GLdqTuELkJYtxpQglFq0ggOfNLO6lGIkfdbAGytjxCDXqTrKeicb3ByTOjpQVYLr9TEY72zlZQwCcUtRZuhbymKhd/zdilFiy6vE4EgvySYoNw7ZJw7NpOoURddClxbeQbcw0v6Q7nBFj4j4DRzRL4DZxRiIUftqZnyWEAuyeqvsvhYghRa9xCtx+GuCvsPdX12Sdx1v55sAHYZ80HiSSQpRHD0Eo5rYO8WYPWsAxyncnvr7cdwc6O/KPjnS64WYDMTl5kw+HVVLbIwHuh9jgTB9fbdyEp7UDPkG53gVASLhiFpJLMQakJETKeUhvz0FHjzuU80Gq0kXXwLkOvoADGxmw79ZN+oa8CTjE4ZYhfyKL1feD5Q7NYD2vwJDIcPsiWWc/iB4GouTxjWs7gCGuiB7v4bR3WXylkoeyLjI2c7e8AGUrJ6rFpRNkE7fxzWeILuqBy0dFOnr8w5b4xPY49x1UsgHMKG7kQBgAkTBZKPkHKnrbqR87T1WK0ar3gkt+H/mirpx4j4Pqw3g5F+eL5DUNea6hbZc0F+66IWqNXUShUqzgd6DXRfF7NrtkBoiQHYkPMvGRo96d9CHkRCYIfBUbHzedLQzYoBi5gwlQqJ7DrnB9f1I2IDoKYHiDTBA1+6X7pyqBfNe7wJ9SaqwJNeqvISgIKk03hqn7nZyrkp4GNv2b7BwkEnmybp/KBZNm47GSHZ1PvlupmUYSLFVu0MHxoBJ2rtnis78kdEavU0h 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: 27 Sep 2024 08:49:40.7973 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b4a4325-542e-4272-00f4-08dcded1536a 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: PH0PR12MB7888 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 Fri Sep 27 08:48:40 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: 13814032 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 54C53CEBF86 for ; Fri, 27 Sep 2024 08:49:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A52D10EC94; Fri, 27 Sep 2024 08:49:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="JqhH8fNd"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2049.outbound.protection.outlook.com [40.107.236.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id BE3B110EC8D; Fri, 27 Sep 2024 08:49:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gHWtwt/VM1Evi7dCzMSPzBi1E1dsLEANZPI3a4CNSDvfJlFqOofZZZ8PfUCwMV2N4hY2xZOTx3UHsdRwNpEW+qHoxLoMFb0kgUWnzExtGounVUA2GNHS3G6R0FZRcp70pnzMs0GKSwJBohCFbQjVsFijHgMl/W7QqNLnHG9u+NnnSZ32SQtu0E12u3Qpdg7gmHa5Uwz0XhFkMm7yIpJ+kqj7ByPM8AeK/wV1wdCp1LKfJX4DRIVMPYmHqbOo+JZ6RFttLXivRIcT/0jZJPyELHi/nu4/XGQOJXPqibEykeDTd2YKHZV23ueN+jFqF2Z953VKA7Xa/sKESaZRcgfGAA== 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=f+igef01FCNRezzyY/o6UHKcqU9NVWvTSOyfTrM/IAsbxby7f7KIk1wuAhPxJC1MwBfBI1GsivF/KwPYBh9aG5pbjbLFoVpSLzPXzopY8PW/b378ZVHlDlYTwabza1Fhu0Bqtrha54UgBTcAzx07VJJksMixSxxHvhsW67vGxJrASNbdmUgLWIPYcNow9MAAI9tUF0MymqynwE+LPOpaXftCoThrvV5a5O2GJvJQn3bQSPBtXmZHTkaB37ndYVSqGozY8gyJ001MWdkdCMNPcpZikRNbifshrAqm3ApRgONTiSTZ1krT0K4kNE1okDAfxTAnghz+y3FqwEySfTan1g== 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=JqhH8fNd+ifo5YmiqHq/rHq7VsgDfIxUhLRJn+l2aqRCQEvkicj8SOOS8c62n/E+5ABkhJ5MPkLR3AOee0T+T/c7dXtml2dv5kg1NHFBSXixQwhJh21LP3V/xS3msPhvRIz+Lsl7+hLvSL8npfWpvRs8HDPDyZ1rP5sEJgzKAjA= Received: from MN2PR20CA0066.namprd20.prod.outlook.com (2603:10b6:208:235::35) by MW6PR12MB8999.namprd12.prod.outlook.com (2603:10b6:303:247::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.28; Fri, 27 Sep 2024 08:49:42 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:208:235:cafe::61) by MN2PR20CA0066.outlook.office365.com (2603:10b6:208:235::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.21 via Frontend Transport; Fri, 27 Sep 2024 08:49:41 +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.8005.15 via Frontend Transport; Fri, 27 Sep 2024 08:49: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; Fri, 27 Sep 2024 03:49:36 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v4 4/6] drm/amdgpu: alloc and init vm::task_info from first submit Date: Fri, 27 Sep 2024 10:48:40 +0200 Message-ID: <20240927084848.263718-5-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927084848.263718-1-pierre-eric.pelloux-prayer@amd.com> References: <20240927084848.263718-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: MN1PEPF0000F0E2:EE_|MW6PR12MB8999:EE_ X-MS-Office365-Filtering-Correlation-Id: 84c7a99d-7e3e-45fb-371c-08dcded153e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: C5gRPKnoWcB6/FK7q1ac6XqFrhdt02oDd3xpoGE5quFSwW+fKEzfiSTSzMCkl5QuS17M1u4Xf6yxt2LC9zS8jHTBOEGGm1mt8whJwWdmFIO3AeH3plFp7lSbYvgL6KCFPSu3dMF4UbLhbafQz1DS7trhCEBfSrWVJd7QWxVA3l01wui0L8u44rQ3SRL0KQY5vrvKMINZu5kwN0zmCaVJcs1toAUWH0ubdQC+AdCh7mk/zhRhAXqhClTXgN6+tZVxjQObUUUffPwCaEE4PNiOTUxjo/7xNsgJsC+pKF4cE5qbfqXVOoXEgxpEVC17BfIl91UzI2NT5DWPpTb4RmcqTud49FoE2HiGHe34wx/19ECowVqdrXK7SqdK1JBvv0nbJ7fQ62SR4g65xDtLpnZ0Lor9nclvUIHTOYPZW1cdp8H2qtMjDx5bOKH1xwAZDt2YNpCrLUdGkR08UkTjiDPuFiyoVhOFAH3OlxofMdoUdIE73M/ZNx3wxyJaT5DIBfThUy/sIGj/zCufApPF1u8PQALCa/FABglVP3AT+lQUDX1CMkc4yfX1hJEjxXw3unorMYxHEluv9rIOQyH7JFy6PpWu2iErBVnXBU4h/Pg0yaFJFZ326jkXJqIPjQNA5e7jmaWT8odTFIIUoGA5b+VQoC4kOZiDkQQ8I8x+O78fOex17TFYJO9FrK/GXsp+mzPnckg86dH3cZgPHRcxN3zQS4ElaEOaw7CuYk6CMg6joDgUimP3ifGVCcp484L9UulqcnAG9NWOGS3owvprcbT37yYuqSkiSYiJz9fXhCiR2Xtx8b3oeeKwfU/9ipml7KHt5wGMe6QusO9h+LPTwlYf3Pk3gFd6J4nLij7sUCIbIYn/lBZtnQ2LOIPvFMSVLhL6DfzeG1B8w+Pa+a5CiVzHUzp/clsi0Kbado7hnzo+ycq7oSN5DS22+cA1Fo60dgkTkDePeB86qKff60ziSfcjT023hen66yll+IOgNTkkuowQHTM3URRPfdgz1N3HBwWuDJbtM4kzJILR85IRXAewiJw91/V3T2elEuHTR8iHSxKQ1WcxwotpIwZ22uzNuOiud1MxycAMNlPBHlPCMkND0l/SOBJg07aQurvPe9URDjjls0pP3w2fK7LGsh1WOhDbqV9V3N82xRMBoPAeIsqfS2VXyI6EpbqNqKWfM6jt7jP/fwiKSz3AQ6IM47dPJvkri7NKkRlOKbunMC4NkIMBdEX25kXnkvIUwSpSpiY2tTsKLLw47p1o14h6jN1UZA0x6mgk3R3bF8rlVJTR+1Y1FLeaS8CUKcuNcD8uheLKCgRJ3s2Qj+efCAnkFnWsVULw7ph9bpjwfTI1Ybn2fygD7TWHswkAPmbXTIP/MFdIDS2K29Mhj29caaUVtk3C63gM 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)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 08:49:41.5786 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 84c7a99d-7e3e-45fb-371c-08dcded153e1 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: MW6PR12MB8999 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 Fri Sep 27 08:48:41 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: 13814030 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 06C5ECEBF86 for ; Fri, 27 Sep 2024 08:49:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 65A1310EC8E; Fri, 27 Sep 2024 08:49:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="46Pt7fcC"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2087.outbound.protection.outlook.com [40.107.220.87]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1224410EC8D; Fri, 27 Sep 2024 08:49:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IMGrLljCAkIw3HxIrM6AnghYAD58OH3zTg3vCKQ88q7CPpWEfXUikEfqI9/vReKRk7wEHPpTPOPee6NBINe4JNCSOl3xo92KEtaRpqEAhQyugSHUnGKrh5f/JEtcozU/ork7G6SHpRldGKZyj3PDlNbXfk/sWjalcBh2IctTg9htzRewsD6k1O4hrc/JZXOXdkw658eKL13Rez6eQ4iPK4U1TdrY01F9TTghdeiA3+EPGp5/v5piAzxBeBV9Rt/2n3ijJSFX7ioLa25qfzdLbWQJJiikm+tx13tBmcCBPTTHxH3woCko87NEmiDkava3Xm7YQs+ZauKwf/zY6w0AHw== 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=eBuKALi4se0gRlCS/U4Xce/SJYbnTBUgSzeVI5R/dWw=; b=xR0gVXmViPTSQMW9T3+Z84na+QWDG+XTZrt3pfObNgRbLph2z5IzHJrlJVTNxDHQ8i1BnnicOm12ZnunTFNfguatZ2AZKvtAcx5Y40hb79Xndvrvw+fV8d7I9Ky9B15haSDk0Gfp+ZEWLAwoI00mfvQErqGATtsfQtmNApTUFtYjc63JTsJVuCQJ/aYnC3ZKrTb66kE1KyetUeXaH4b+37NFmUncBlL9lVBW6no4ZFrQouhas9LQOelEO8zmB6KujiyRZiFx716Pg29Q+/w2QHJo0S23ah12h8EL2obbNHnkTR+buX/carXGKxOh7wn5ZL1IvbsmZBn6+O/J1HdXmA== 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=eBuKALi4se0gRlCS/U4Xce/SJYbnTBUgSzeVI5R/dWw=; b=46Pt7fcCSH474NcwWT2hWqxLq5vSzwON4b5oUTyrLMTbo93yVN+7+irTpQZDK4Id6kNaZQVXv1mcyNGKc958+cXv2CV++1Cjjk9GA8md9gmHbJrVVM61sYpUIFyXyApJU34krRPLko1+SO89Te2KwsOsHhD1LwXCD/n/S66Kzzw= Received: from MN2PR20CA0041.namprd20.prod.outlook.com (2603:10b6:208:235::10) by BL1PR12MB5874.namprd12.prod.outlook.com (2603:10b6:208:396::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.22; Fri, 27 Sep 2024 08:49:42 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:208:235:cafe::7b) by MN2PR20CA0041.outlook.office365.com (2603:10b6:208:235::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.20 via Frontend Transport; Fri, 27 Sep 2024 08:49: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 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.8005.15 via Frontend Transport; Fri, 27 Sep 2024 08:49:42 +0000 Received: from patedamande.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 27 Sep 2024 03:49:38 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v4 5/6] drm/amdgpu: make process_name a flexible array Date: Fri, 27 Sep 2024 10:48:41 +0200 Message-ID: <20240927084848.263718-6-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927084848.263718-1-pierre-eric.pelloux-prayer@amd.com> References: <20240927084848.263718-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: MN1PEPF0000F0E2:EE_|BL1PR12MB5874:EE_ X-MS-Office365-Filtering-Correlation-Id: a65eaec1-0ccf-4a12-30f8-08dcded1547c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: L8/0Nf871PcSIht4KRv7xBUb1yRpDJFjx8iHSnE1ANqyw1yr/EYZaPSkHkp0+E17I9XEhzpKtkzCDLZrIXPNwb5Xd3FblBJ5FJ5TUNznH9Lcx43oa7HRBNbUBRJIA2GtNg3XinBB4lNY2kZwczQ5tmbjz0dsKP84SbyWvkPIOPMtnEVYVlOAH9GtoJgYhuvj6rrzb7Lm891Z9II/gz3YI4v8+mUdM4ViTFk987DOw2Iu+vIEyi3pTYBjiWi9fVrIjVhMpYm7hMx3JJX7c6n39Q95Q7NS4SWdqiQD8gZ1VdxNov4tT1VuG68P5j5c5/sgJJtz7cZIGZinSAAHQsB3mA2TczIok1C/hbTaOi8xVgkamLV6D/oUcDnWHRdLizAHWPbgOaM7GFw9jrCXN9Bt4gQVECBiQ/5SCzmI0vBPPL39YGeD6PRxg9S/V3qsWHMdrEAMUiSZT3Y7DOV3w3JVcAnYwHrpJ2xgA1vbWq3NyxgLYB7V9i6u13u70vVs2LamnVVZbmG1s72voPmjbxZ9ZotZtSxAyBuXms4S19P/vfI7q/UGzYufQfPG7X15qtnzLJArymbbyV1E0sQIn3bRsV29DtUM3hL1SQfztzi1bFkwCJazKRwo+A9iGgn3mr7iDh/xUD1KPVUrfTqsWzu04TWOVQywYx1eIWT1vk3AaKka17xbkK6a4uW7zkpsijXBFj3RaH8cWuN9hkdqc/DG02pMnCO0EmYCfKfDdCTYwSulNWw2H1qIawaXT8jFxNLM8aFInqq31ou9viTbtjwRfZFeWAyJsFy0bxXRkZ8xfCfkL0Muo5GTvxLY7/uPSM0ROJ9G3cWU5TiP/cyacU7Bsdr9JcoAt8+TiTolk2FtRLSfPi+2rz26kJpAFESNw5QPj3e7OKBEYT0y2yfI6vU+xN2KQTS6jYuWfNjvAG88cGEw+T4INkKNcvZw2kguT7TmRQG7wXWWdLpuuzo+qBMAwoNvcOjMsp/94KSE7IKXiqq7oUUy7uzsC69YJr5iySnwd4LIccdaedJeFYprpN8YAi5g/CylTPM8Zo3rkaLkhZjUd4txrXhvx2v2XoHegrv0ayelcoFW6midMmNGLzkUgLU/T638KtWkEr/BI9hwnl0yQMMA5iHptTIPZ287oVq8uV8QYs6TgmfJNqXhrgUUNdtB4XLJV+fkegDf/H/g2FhvSr+UxwbTe5exP9MZh0RRhtRI5ffYk+GgTcSnHsf6JYAoBIR368RpRgW4iMZVhpH4cSORConz0P818QHKayRG36VqnWUa5tT9GJwjAfCEeKib4CXdu3+hSXKaL+MNFFwi0ot04N+St8gD6EKUXUDBirKF4OOMgW2DOyxctTiqzcRJMwqtiLfOJ1NDSWDJsxpfVQhq3lpxrfGQSzVMMWJNXRIsG9xrEapB9wpzqL4FCd0knEpxDsOggnvWPkPifRfupQTzzbfNP6AQ8pQI6cFX 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)(82310400026)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 08:49:42.5942 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a65eaec1-0ccf-4a12-30f8-08dcded1547c 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: BL1PR12MB5874 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 --- 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..cec0a5cffcc8 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]; + int desc_len; + + get_task_comm(process_name, current->group_leader); + desc_len = strlen(process_name); + + vm->task_info = kzalloc( + struct_size(vm->task_info, process_desc, desc_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, desc_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 Fri Sep 27 08:48:42 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: 13814033 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 EC40BCEBF88 for ; Fri, 27 Sep 2024 08:49:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 58B2510EC91; Fri, 27 Sep 2024 08:49:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="uxUEHx05"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2076.outbound.protection.outlook.com [40.107.223.76]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3FBF010EC91; Fri, 27 Sep 2024 08:49:51 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NqwtbOSfZJVM5TGj8rDm6MvMCp9rcUtdemSCMvEU3GCdpp3Lhzuay03bAR/+OHTYlGJKaiDGGtBsjxxPXQIzSpSUgM9a/GRXEbUjRyvIEV4L/dwlOfLywKou1yJdK6+2R0ooPXU1Mk1XZSR9q1Es2adyB8eKqtkAdaVds0cME3IeGP3pHuJxYPvqUnthTkz5EHK3/CkhPiaVZ/YAeQiLHs7klRRF+A7FU495mpk8O1AR8Q9qnyEGBol1JCOsIYAH6FDkpF3rWP8MtzoroBlPbzRsetrv4u4GTQ2dJejvCIO4Y9keZ/HrJ3hVcs1EGQZCfnDQfb5Uw82FDCIUtIBtAQ== 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=IH7FhNaOJojb17QkzJTj03dM9VACVcDjDPBTbLbg2m0=; b=NWFimuSyOjsHENsbhqPTVsBwpeNGhsBb9g1UrbabjlL1EhhTDA28y2kuQQ5C2Y3sGMC5UsTsHmE0pUXAqSeWle3djec7lQw10ylSVBNr/5b4kWxb3b26mR37luhANFuJXPs/hhBEyKaZd+O3xuDHFy/dlR7wqBrj72XTc1fO7rYITBes9hIlw/iHe8koSlw7fpbkEIh1yVJ2rR3Z5rrBOU3912NpB+wcer6ZeHLZjfD4+Pdf8Sb4qWefmlFzgdVSvA8+hdxBB5vnFisM3taKAUAVxHYoVkUW4KrWxSg/ximDODlzGiuikfiIkRCCYDgOF5q++yn94H8SyvUEhRUsVg== 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=IH7FhNaOJojb17QkzJTj03dM9VACVcDjDPBTbLbg2m0=; b=uxUEHx05kjsWPCsG8fmCeBuQUnbk2pppJZrQRpQfv+F6RwYfNqK9blIBgqN1wf/42QQzkr4Yva2RQ4yAkz2C2DDfontA+P+6mo7w13x5HJQwL8TANZ1Z3tH6ZsvLwFtCdUPZM1VYNVC4Rrh8dTPIEZobjCXpW915nUKq25MTC+E= Received: from MN2PR20CA0053.namprd20.prod.outlook.com (2603:10b6:208:235::22) by SJ0PR12MB5611.namprd12.prod.outlook.com (2603:10b6:a03:426::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.23; Fri, 27 Sep 2024 08:49:43 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:208:235:cafe::42) by MN2PR20CA0053.outlook.office365.com (2603:10b6:208:235::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.22 via Frontend Transport; Fri, 27 Sep 2024 08:49:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by 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.8005.15 via Frontend Transport; Fri, 27 Sep 2024 08:49:42 +0000 Received: from patedamande.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 27 Sep 2024 03:49:40 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v4 6/6] drm/amdgpu: use drm_file::name in task_info::process_desc Date: Fri, 27 Sep 2024 10:48:42 +0200 Message-ID: <20240927084848.263718-7-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240927084848.263718-1-pierre-eric.pelloux-prayer@amd.com> References: <20240927084848.263718-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: MN1PEPF0000F0E2:EE_|SJ0PR12MB5611:EE_ X-MS-Office365-Filtering-Correlation-Id: f80de1ac-01ed-4b51-69ca-08dcded154b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: UTlVMwOYZHKvkMlh3H448rGMdmVCqTu8jxvtqu4Wk9dTPmDY7D5MuPNWq4Nd9Dw2SJGgWc0I7b4o/LPIFHXlT4nT+UoYJEYzt7vUXYzucHBHni5skFul2qOxyxW42Q+C4KZCiwLhT9WLAnZ16A3V+6Ukw5jP7Exx/hWtbwQ1hln/RInaMnysb4V56XT/QsMvzdkkHcIP0Ev1FP4p9djAJjI6rN3qCugqkoEVrDY313Q555ULiMg2at02enK/t6yj3aqx2BUK34h09piFmZRET4WIFKLN0uxC+yevDlAU6Fi4dM5wBQ8qb12NMQ7KxWRdX8G343NaOi87GilLyDxHxTYtkjF0AqNE/oAVwbcvyxZ0qTMZA7k1ckxuFzo25VZ6bbZPJ0Je+OHx1JEFGJA8zXCb62gL/4qDMpfasf7krzJtzSB2fQeQZpdItePcSwgf3kMaZ9oevxbQWuI3pjLuy7ukPUphq35qd7Mxgfz96QxjYd+3N23a8JnRY1SEKynkJSYHE0fIIpco3vH6ibG2qwY64QueMie8Y4GcsNu92JwAkenMeDpBSi0tN+g8hLkUtD2UshJ572n6wP+cztJEAcWyZxegwkfAdS+7i0gzSP1OAmBsEFdO07BvLvTFhAQE8Dd7EMf0tBNe/ZzLnUJ8BFzpVL4qgkzTTARNHq/CVCJFd879etK4BD/MLeR3a+oUq909v999ElO4Ro9l+NuVkqSdDtxEgLYLPPT1nKh7NFWR1LJXHsCMlDIMU3TlQMeEQboDlb2ANI4PPznmLHjruqwMYkHbF1dv70+Npmo6AYbBsBgzwlsyahTSTOk7b9fG6G1YSbXvXou0zYhhMNbF2MbAtjgPy8ye+wVpN9AJ2URte6fa2GPW5gsAY5FxUq1oZtv1NooByISUcd166Js6Tzrn5XOc1I97flg/MqbPSgU51XWxWoFgUweEUVP2mUh44puNLoikQOBZr6pM3tDekq7M3M5fRWugVxQ5G0h30DUwzCZumSj2tOJ/QRLQTlRF6BHx6iPL+G9h1FHoBGkd3kStYLJOkkjvsNEakw1XTmKwMAD6g2o7pt+Vk/nutntAOzaPmNzCtandhPePb1w6PPOvITKjEllPiYkpWGl9Oth3wxSoyHCnGm4WGtKX+UnOW4pxD6LWVzDrkeVic+a7cxl0dsQrQK57+8s1u/SZeMZP1ZcCQVhewzg+DyAfjrx88b3bJXPEHQqzg/jEvUiFE3Cw8agar70haS4J8+WujbFO6zkiDh+kPyBA61MOUXxdjGuKBBfNQ8qPnh9/e79g0aDvEQm+O1XRoYTahlUgaGvypK6g6bEeMkfQsBqA0ugSS+BmbWM8843Kbs2KqYGicwZCzqqBXFOOxu3HdRZ7SgkMAUbT2VegXdFOQ8QyIY3lI6N/klh6AxROpp7HOgLYx1wjbxSWiJwTkWlfNOzps7sbEDmAM1j9b3H3Ec/8SAUl 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)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2024 08:49:42.9692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f80de1ac-01ed-4b51-69ca-08dcded154b5 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: SJ0PR12MB5611 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 | 26 +++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 +++ 6 files changed, 29 insertions(+), 8 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 cec0a5cffcc8..f6e2be6d4e9e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2355,25 +2355,40 @@ 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]; - int desc_len; + size_t desc_len; get_task_comm(process_name, current->group_leader); desc_len = strlen(process_name); + mutex_lock(&filp->client_name_lock); + if (filp->client_name) + desc_len += 1 + strlen(filp->client_name); + vm->task_info = kzalloc( struct_size(vm->task_info, process_desc, desc_len + 1), 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, desc_len + 1); + if (filp->client_name) { + size_t p_len = strlen(process_name); + + vm->task_info->process_desc[p_len] = '/'; + strscpy(&vm->task_info->process_desc[p_len + 1], + filp->client_name, (desc_len + 1) - (p_len + 1)); + } + mutex_unlock(&filp->client_name_lock); + kref_init(&vm->task_info->refcount); return 0; } @@ -2382,11 +2397,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) {