From patchwork Fri Sep 20 09:06:43 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: 13808397 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 15662CF58F1 for ; Fri, 20 Sep 2024 09:10:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2560710E7E8; Fri, 20 Sep 2024 09:10:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="XT+dT13b"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2082.outbound.protection.outlook.com [40.107.93.82]) by gabe.freedesktop.org (Postfix) with ESMTPS id EA5EC10E7E8; Fri, 20 Sep 2024 09:10:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZmH5ryaMAXHuzygWLbl/oMKFbORC2BmyGUePL3YKzx82diRlOGy+OTqnj+OTEOipUyLWX9FS7vCY0LhlE9Zmnh+rll3TJr53z7h1qmopDkowK1kiIkhLfhmHBeVasaifMBY47Wn1aHiUwuUo8dFyj7BI7sBt1zpflVBUlHggeqy2KbzqX9PnjMOymzFRmo7ggSGFOwpKA8HA35YrbKC2cCJ5BhvoSl6jM4BG18eqAH1Ixgk3iwgf5OEMgB8/n7rfhl0RzilK21MFP8ddkPO21ALxnSTlQZJ/szDwuWkCuxN9jLNYsj/vlZUJnxxnmNK7SwJHjHZk0/aWxe/hSY7Bzw== 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=41q39kXnXPva8W/RvA4hsrqiJHzL1JsBuYPHxqjYyKA=; b=AoC7pEOhUbV+P/Vh+AzNdJfeb+g9DD+e5cqv5uWmRG2hUw9psYixLe6kWJdG46Uj5Rujp/1IUr3nspNrtihL7SbE2k67XyBO+b2+rq4Z005ugnEj1JKDWlK8z7M5peo3nzploJwk7EnPANVE5k31wlzLtkCNyzpOysMO7yOqE3Y9N1Pfv9/hOpFbe2Kjh257NMr3064I9i2FU/mR1/K4QyyERMv3qc41BGkqzfGi4lqjVeKt2uQCZE1JEBHlMm0bHumVL3sC1UC9G/qCRSSWXvt+dFS3ZKWa8TCgUP613TS+f5gSZqq26dRFuzBf7kmGDzWoBpVa99P9M8GYTJi/Ug== 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=41q39kXnXPva8W/RvA4hsrqiJHzL1JsBuYPHxqjYyKA=; b=XT+dT13bZ/Mmb0cgFuVALAO36pCcnD0Pt8LkUKtGnKkRwzdgky4uBRpChDGS/bnjwFZSY1i4TlfviyMIXa2BJ+BYMW22i2xrO+SlOr5xCCauYcvapwvzdjNhah+K4cYGSazjdeVNdNlvFT2hqm+vOLY4tWHC3Z/47at04wqFysk= Received: from CH2PR14CA0026.namprd14.prod.outlook.com (2603:10b6:610:60::36) by BY5PR12MB4148.namprd12.prod.outlook.com (2603:10b6:a03:208::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.22; Fri, 20 Sep 2024 09:09:56 +0000 Received: from DS3PEPF000099DA.namprd04.prod.outlook.com (2603:10b6:610:60:cafe::7b) by CH2PR14CA0026.outlook.office365.com (2603:10b6:610:60::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.30 via Frontend Transport; Fri, 20 Sep 2024 09:09:56 +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 DS3PEPF000099DA.mail.protection.outlook.com (10.167.17.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 20 Sep 2024 09:09:56 +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, 20 Sep 2024 04:09:53 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v3 1/6] drm: add DRM_SET_NAME ioctl Date: Fri, 20 Sep 2024 11:06:43 +0200 Message-ID: <20240920090920.1342694-2-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920090920.1342694-1-pierre-eric.pelloux-prayer@amd.com> References: <20240920090920.1342694-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: DS3PEPF000099DA:EE_|BY5PR12MB4148:EE_ X-MS-Office365-Filtering-Correlation-Id: 9afecf10-5624-429f-0015-08dcd953fee2 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: t7IAUFE+LiKM4CbQmgYN2+RGvpqqeeWz1JZkSomGHfQE2fIZh9qK1cidDG3ox9+eARd2g0xIfl/m4iVHuOZBymvbWYtZYZxAyC6hmYffq0UUCScrSliyyaCsjAy8lt37Ec+h03GugGO1mdp43GMQSLoik1OZqTsgPP5KganlJmDUojtC94FF+qfd3/PBfrMiad3q4ECLxPDvDh7kXsvBoCvAGpJROYtapLWqF5hL30zwz/JI3IWhph2hnr7rc3KZygwmtXwVqFbyuoxIhw74QO0ERcRXp9sURpPIfvxy5eocaiDby67IpdDp168It3fpTwyrOfCPnqCOibvimxrXRGU6pMdKZCbk6NnwT9NJ4MDlsne/kGtXrpbrHzo3DcnB7wt8VGIdYKoxWMmG+QwaRyGMfXvCnQwAEJ9ZwLdTOIruNJgZWkO12jieqezg5AglDXnxLG0FxA/PNHI4qvVqC8yeZoZqxDXXw/4u1+pn8fJ+fv8h9kaPLgIW3k/STxQv+9EaqVvs3TECZvJOngVaIfMkNXtL3pNgQjPVq2zHvC+WzKdmWyiBtsUj2oqYL73ZVpAoHhMNSiO1mRKmI0qpp5kT+ysgJ6+s3rnZj0qmNkIlOjgWyNkn7CX3FucECraYya7gDKiE0/+BHFbznZ4b/16G/QvE9SgCvxJoPULpETbeW3/EEfy5UYUDMIdKL0DKGWAnWlPZFx3GqcoitWvEztSD60ZgzsIDDDTt5VssK3Wp53GpfsMlhquYiIEWRjEtTrc7qnLK3S6dOfzxg48DHJW3FPOVf7OC5+6Fe3HxzZqFW1gkBEBAf3XbsuM5cgu9kBTc2d+jNfFCM5yNuaumZS8faZbF37w7Dvl7shZmcExHUf2woD0hwLhMjQF7S6ilahgcvt5li+N1i9IXtmrgLLYIlIVbVoBPk00CRKr+OfYKQucegkkrGvh5Ms+/EW2stdxBwgWhYjMDaSjV/O7nCIhf+U4GazIQ+Px26nmoWlKiTYIHFUKjh3fsbGhZvMZ6bk0cbPf16HSnctWEemJMngPHwZb2Ehx1dZqL/91a/xcDgHV8G5ZqDQCFV1W6RaPy/K9jrjrKC7GmJM6TwIRfhpcRrS1M/i7/b0TnsXYJoAZcgd/UfXCfUu1siWq3d+9eEph6dLo+oPuFv1oIvhhumvd3/INnuv9878NcodUhNrwCOZ9Jf0O+I8k2mlxVPslHddQcMOgmMrWacwCQdRLQjNQJDJiMSOhoKqJmvZnQgiOag75Pg67pFpDyoMkrBhwpahqTy22BT6XTc347AyDo102S1SBO+fboqB+RQyvaTdmrGZNoGzLRHVRPgKf4Cwe/ 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: 20 Sep 2024 09:09:56.0723 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9afecf10-5624-429f-0015-08dcd953fee2 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: DS3PEPF000099DA.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4148 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Giving the opportunity to userspace to associate a free-form name with a drm_file struct is helpful for tracking and debugging. This is similar to the existing DMA_BUF_SET_NAME ioctl. Access to name is protected by a mutex, and the 'clients' debugfs file has been updated to print it. Userspace MR to use this ioctl: https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1428 The string passed by userspace is filtered a bit, to avoid messing output when it's going to be printed (in dmesg, fdinfo, etc): * all chars failing isgraph() are replaced by '-' * if a 0-length string is passed the name is cleared Signed-off-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Tvrtko Ursulin --- drivers/gpu/drm/drm_debugfs.c | 12 ++++++--- drivers/gpu/drm/drm_file.c | 5 ++++ drivers/gpu/drm/drm_ioctl.c | 48 +++++++++++++++++++++++++++++++++++ include/drm/drm_file.h | 9 +++++++ include/uapi/drm/drm.h | 17 +++++++++++++ 5 files changed, 87 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 6b239a24f1df..482e71160544 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -78,12 +78,13 @@ static int drm_clients_info(struct seq_file *m, void *data) kuid_t uid; seq_printf(m, - "%20s %5s %3s master a %5s %10s\n", + "%20s %5s %3s master a %5s %10s %20s\n", "command", "tgid", "dev", "uid", - "magic"); + "magic", + "name"); /* dev->filelist is sorted youngest first, but we want to present * oldest first (i.e. kernel, servers, clients), so walk backwardss. @@ -94,19 +95,22 @@ static int drm_clients_info(struct seq_file *m, void *data) struct task_struct *task; struct pid *pid; + mutex_lock(&priv->name_lock); rcu_read_lock(); /* Locks priv->pid and pid_task()->comm! */ pid = rcu_dereference(priv->pid); task = pid_task(pid, PIDTYPE_TGID); uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID; - seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n", + seq_printf(m, "%20s %5d %3d %c %c %5d %10u %20s\n", task ? task->comm : "", pid_vnr(pid), priv->minor->index, is_current_master ? 'y' : 'n', priv->authenticated ? 'y' : 'n', from_kuid_munged(seq_user_ns(m), uid), - priv->magic); + priv->magic, + priv->name ?: ""); rcu_read_unlock(); + mutex_unlock(&priv->name_lock); } mutex_unlock(&dev->filelist_mutex); return 0; diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 01fde94fe2a9..e9dd0e90a1f9 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -158,6 +158,7 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor) spin_lock_init(&file->master_lookup_lock); mutex_init(&file->event_read_lock); + mutex_init(&file->name_lock); if (drm_core_check_feature(dev, DRIVER_GEM)) drm_gem_open(dev, file); @@ -259,6 +260,10 @@ void drm_file_free(struct drm_file *file) WARN_ON(!list_empty(&file->event_list)); put_pid(rcu_access_pointer(file->pid)); + + mutex_destroy(&file->name_lock); + kfree(file->name); + kfree(file); } diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 51f39912866f..46dadbd1bb35 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -540,6 +540,52 @@ int drm_version(struct drm_device *dev, void *data, return err; } +static int drm_set_name(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + struct drm_set_name *name = data; + void __user *user_ptr; + char *new_name; + size_t i, len; + + if (name->name_len > DRM_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) { + kfree(new_name); + return -EINVAL; + } + + /* + * Filter out control char / spaces / new lines etc in the name + * since it's going to be used in dmesg or fdinfo's output. + */ + for (i = 0; i < len; i++) { + if (!isgraph(new_name[i])) + new_name[i] = '-'; + } + + mutex_lock(&file_priv->name_lock); + kfree(file_priv->name); + if (len > 0) { + file_priv->name = new_name; + } else { + kfree(new_name); + file_priv->name = NULL; + } + mutex_unlock(&file_priv->name_lock); + + return 0; +} + static int drm_ioctl_permit(u32 flags, struct drm_file *file_priv) { /* ROOT_ONLY is only for CAP_SYS_ADMIN */ @@ -610,6 +656,8 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_PRIME_HANDLE_TO_FD, drm_prime_handle_to_fd_ioctl, DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_PRIME_FD_TO_HANDLE, drm_prime_fd_to_handle_ioctl, DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_SET_NAME, drm_set_name, DRM_RENDER_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANERESOURCES, drm_mode_getplane_res, 0), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, 0), DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER), diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index 8c0030c77308..df26eee8f79c 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -388,6 +388,15 @@ struct drm_file { * Per-file buffer caches used by the PRIME buffer sharing code. */ struct drm_prime_file_private prime; + + /** + * @name: + * + * Userspace-provided name; useful for accounting and debugging. + */ + const char *name; + /** @name_lock: Protects @name. */ + struct mutex name_lock; }; /** diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 16122819edfe..f5e92e4f909b 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_NAME_MAX_LEN 64 +struct drm_set_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_NAME - Attach a name to a drm_file + * + * This ioctl is similar to DMA_BUF_SET_NAME - it allows for easier tracking + * and debugging. + * The length of the name must <= DRM_NAME_MAX_LEN. All characters that are + * non-printable or whitespaces will be replaced by -. + */ +#define DRM_IOCTL_SET_NAME DRM_IOWR(0xD1, struct drm_set_name) + /* * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f. From patchwork Fri Sep 20 09:06:44 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: 13808400 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 0FBD2CF58F6 for ; Fri, 20 Sep 2024 09:10:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B2C010E7F3; Fri, 20 Sep 2024 09:10:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="0hvUOiP+"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2053.outbound.protection.outlook.com [40.107.93.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9084210E7EE; Fri, 20 Sep 2024 09:10:04 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UG3EVYm6QZbHw79wAY8MEUKmxB45bsywNn6k65VSg+FDTnlsbjiAt7p2rM1fqcmKDHlwkMMJOXbkdwSIs9OoOhyOIelpxz80aqARY7UmV3AaqpoBfVK9urDdAxbWwM2MYCY1OsH94fGylWq2qFKNnOwkgZOlaNH2fIdm7xeke8Rnj4S4iPeS9eni/vFN+nP910Ns/pBp/PdPRHkuxRAdGAML4oWsKVqb87T+QVeYL47JLNRh6Y+aKm31L/Bicov/ZWKZlqQpNjzHqcTi2MBCTry+DOdq/4hhtyjrmh1vaBryP5ziIgRsaitoJVc29LO0Q7RxnSLia8JvaBl8o1lA9Q== 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=eCKYioUh/xSi+FChhIX5m+ewWmMbpsGmqYyWM4vHzGY=; b=YgmVOcjrofEhf500jWDjfvlABz1SyE3vEy+Fnz2fAQUg2KloVGeILjbv/SQWAfSgO6HCDA0fhQa33V4eVETgdg31zzpcv7jr/3h5DpLcho7Q9wAAfhTnT3y/mThwU2r1s1+jMvG0FB5UfhPCVctlrdTSy3C2oMhaeqvVd3qh2lyyLHeJMXNKb4ECcIb6Rom4YOkrrRS3XWEM628aMJDU3BO9NrF/HZ5lLBGkRa2v1XU6Z4i4pKkO5N1mR+4+E2M1AVZrZLNkG5MKPSeeXMXek8hZubxJEI/pb+3ZCNR6QC9ka2P5MOmgtXYbCMeqSLLEN/gRGw1lAe+lroi9Stq9QA== 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=eCKYioUh/xSi+FChhIX5m+ewWmMbpsGmqYyWM4vHzGY=; b=0hvUOiP+TbuoZ/hbjKow0BvUJnvPFeB7U7ThtIbBtYyMwslb7FO9Q+rRC+e4LTeT/5fq/mS0C+ts4tbcrCB0MbQnUn0X1nh5x6udTU61G5yzeLnvTOVrEM6Lvlhji2y+FgHxvN5/AV03SyLTosqBwJ7j1VvXFWmiNEaIkywyz8Q= Received: from CH2PR18CA0020.namprd18.prod.outlook.com (2603:10b6:610:4f::30) by CH3PR12MB8996.namprd12.prod.outlook.com (2603:10b6:610:170::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.21; Fri, 20 Sep 2024 09:09:58 +0000 Received: from DS3PEPF000099D3.namprd04.prod.outlook.com (2603:10b6:610:4f:cafe::9a) by CH2PR18CA0020.outlook.office365.com (2603:10b6:610:4f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.30 via Frontend Transport; Fri, 20 Sep 2024 09:09:58 +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 DS3PEPF000099D3.mail.protection.outlook.com (10.167.17.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 20 Sep 2024 09:09:58 +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, 20 Sep 2024 04:09:55 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , CC: Pierre-Eric Pelloux-Prayer , "Tvrtko Ursulin" Subject: [PATCH v3 2/6] drm: use drm_file name in fdinfo Date: Fri, 20 Sep 2024 11:06:44 +0200 Message-ID: <20240920090920.1342694-3-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920090920.1342694-1-pierre-eric.pelloux-prayer@amd.com> References: <20240920090920.1342694-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: DS3PEPF000099D3:EE_|CH3PR12MB8996:EE_ X-MS-Office365-Filtering-Correlation-Id: ea85149f-1ca4-4b0f-2ca7-08dcd9540036 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?OSsXAfOuVaxrK2UsJTdMgkRJJD+fSIJ?= =?utf-8?q?Fbn/+qYOZRj7E292LuxdDIOZkoq9JbRjPpX6FBtTVZLOuBDkoMGWpBhDGtZ4fBzmU?= =?utf-8?q?RXImiguuxdEMaw3osJ7ZdWxBBnambLVTgf/es1pc/B5hPeY257mq2dBm3UAwhmD25?= =?utf-8?q?VPLsOx6M9qg+66HlvGxI4EqejbuQQ3BD9tP0vQphNgGmqv7yTpQ6ztIO67JbeJZgf?= =?utf-8?q?HBU3cCYPN+ByKwe3wKvEQjJQpYwSUwbLFb77J9YMbv9NHoPQhzei5hdfH25q/Klfa?= =?utf-8?q?G/2aMGpkjyjPZ8Fs9y7zvUrtJ0NumE9peAybD3s2dXqYyXfxU58OnrWAAlGftTtZm?= =?utf-8?q?T5Y2gUpIGIMtDdeyCBNvFSf4ABzaBglsD5HHXqP/gxqcjMBQjTwQweOWzicwvhwVE?= =?utf-8?q?31VFzDc5bvQ+OTaPL7FlJgEsevYCC1kGRqCiTg95CaOx4R2aucMjl+6TAN+uR6CXB?= =?utf-8?q?JwZCFrp3XHsH/mQg9Kwd12x6zkLCRSYwLdfI50eIlYt85ZA8kXSwQ8nEaPVRMNwIe?= =?utf-8?q?K7xzegKYNzUThr4iEMT7pzDhMwoH7Ay3e2Hc96MzAT35tcgqJYMHQ2ZMkhY0aJ/+I?= =?utf-8?q?wdydTp88aIfwmQ8ZgBaqtJLBMKPjuE02lx6l0C2qgSjYqmFl4bdekGrsIJ0KdpWng?= =?utf-8?q?onwQNWFpyqppl98u51bLpc+siwOWEmFGCV3ifjIBCvl0ods7nQ8wEGikSVy1lFeX4?= =?utf-8?q?+RLg9V6ThGNl3+z/vDChJBvmOFY4l9l0Jpry1YNI9m2asRz9d4R08oeQHmxsguKHY?= =?utf-8?q?N3fn6QU/oWtEatBUpJw9PwThNmOnvdAr2nuIXSdS96Ty/QL9tpdCcAMD4DwiK9y0N?= =?utf-8?q?6FvSJ+GD1PmWLthSlXfvUG0q/L5YFezVSBsOeWdD7C2Ai9GPvzVd2XLcb2Ubzz1ea?= =?utf-8?q?Bt3NHmkSwOOU29KwVDpqZ0omW/5fZXP7IBIAAz5czUbERcefXsyK0ns2/0R7x0uSE?= =?utf-8?q?jQPNPJAAP/VHV+BFZJ5dAcYnFQmjnSLE7LSsJjR2g1LQlyGe6Xkvi5Lkt9AyB/2lC?= =?utf-8?q?X9vAdVMiT/GzRCAjZB+e6hvoCK1pmY7vkvg0Q6Y2WncZ0z0ZVYCRygg3Sksgi6HY0?= =?utf-8?q?Cb8Nzf7Gizn8UnDSf6+9PS+nydtEifkELcMWOwHzavHqK5BxB0NCMedCRtnbQLX+U?= =?utf-8?q?LszQMBbCds8UjJQsspXdGQCN51WQHRkfY1BcipaHBEOoEHy/aTjjEwVdkNm4gOzJP?= =?utf-8?q?z7EY4pYyKHpgkBH5HynyYHhvTSOTK2wnzcDW+zDcZyoRLDKYSzZRkicwYlgg6CSrI?= =?utf-8?q?NRON9jKx9YepFg5JeBsr0cHQ662nr879wrgWfaC/xRmsq1DoJZMHS9bxUUIm4UppM?= =?utf-8?q?jnOEyFhw4cBlSx5ik6V16MASlnouCpatwz3FiP2Rh//ThEt6RMsGq4kRiOqvmHb60?= =?utf-8?q?ekENyXbT+3K?= 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)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2024 09:09:58.2704 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea85149f-1ca4-4b0f-2ca7-08dcd9540036 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: DS3PEPF000099D3.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8996 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..ed1d7edbbc5f 100644 --- a/Documentation/gpu/drm-usage-stats.rst +++ b/Documentation/gpu/drm-usage-stats.rst @@ -73,6 +73,11 @@ scope of each device, in which case `drm-pdev` shall be present as well. Userspace should make sure to not double account any usage statistics by using the above described criteria in order to associate data to individual clients. +- drm-client-name: + +String optionally set by userspace using DRM_IOCTL_SET_NAME. + + Utilization ^^^^^^^^^^^ diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index e9dd0e90a1f9..6a3621f50784 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -955,6 +955,11 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f) PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); } + mutex_lock(&file->name_lock); + if (file->name) + drm_printf(&p, "drm-client-name:\t%s\n", file->name); + mutex_unlock(&file->name_lock); + if (dev->driver->show_fdinfo) dev->driver->show_fdinfo(&p, file); } From patchwork Fri Sep 20 09:06:45 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: 13808398 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 EEDF9CF58F6 for ; Fri, 20 Sep 2024 09:10:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 41A3610E7EC; Fri, 20 Sep 2024 09:10:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="3TqK5BR2"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2066.outbound.protection.outlook.com [40.107.94.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 689B410E7EC; Fri, 20 Sep 2024 09:10:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aJ6WyKQHMq0XS6vOu28mDktTgE7HrUShSx0KcvheamK2Mj868llOeQwIjO8muCn5WJoRbscDDStE42br57cwyBxXo8ScfTvBzReyWHi0oHsN2wwSMBJOZiKQnEZmaM7rspmmp/i35YWrcVmpvi/vFtEJOFshv0lRnt4MkOjAGkXQ/+Kfs86ifu0Ni6AWI0xPV9TkQI2ARqH9lwQZQlhEIPHZb//xZye9XrOVKQX+Mgv8fnsz3vY6YBi2SmtQHVxhbaUlEFCoDZfckbkGgNKHJav3t/M17x+E/tlttYWe09/GehbedeRsvlqLBKUs6UoaSbytypb/LG/gvNqtQvDSmw== 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=s5drVreCTzL25bFSIjmeZYyEEAZJNDvOd/LsBiDFV5c=; b=uBULqNZei03hInHYyr0x8FQuNFdRuTCysC51mLhniAqySY+4aiiVPjl/VP4C/IgqIAbs6TU8D8g+BRqdvx+t0TUsgnbySxFoJD5ziLMIBgq4P64w0ts3JbVrfrYXsHBVDA1gvT+PlOKLV2nvc40hYrsa/5y25AW/13LoWR9brUoUPHuCYEK6b7x0vn9OU7I/pa0oZEpWzOG9ZNuSDuiMcGj7rAWCCNZ/MBLSGH6Y9ocgmH1uFTCbH8WkgeruDtmvxrrlgd9eazgoe6gOxG0WIu9LuL9A0uxXQKFQX5H4cCzEMrKCCMaSYYg4DWR14DaTNuRpiZvtvBhYew+4sEwROA== 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=s5drVreCTzL25bFSIjmeZYyEEAZJNDvOd/LsBiDFV5c=; b=3TqK5BR2Rl+ag1mCnBje5ZcicsG4EUz6YdmbIqLypom0QcAbrBnTgD6azSFXR98DmDgxZEL47tjFG/FCvlV4rPRsYai5S6JPbZ9zznivLP3PTvEZohTYxN9iTk1waCZ1VWLScHt7HluLgg62OnKP4zafj8IinqC68OV+OlDCGJw= Received: from CH0PR13CA0042.namprd13.prod.outlook.com (2603:10b6:610:b2::17) by CY8PR12MB7539.namprd12.prod.outlook.com (2603:10b6:930:96::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.22; Fri, 20 Sep 2024 09:10:00 +0000 Received: from DS3PEPF000099D4.namprd04.prod.outlook.com (2603:10b6:610:b2:cafe::b6) by CH0PR13CA0042.outlook.office365.com (2603:10b6:610:b2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.15 via Frontend Transport; Fri, 20 Sep 2024 09:10:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D4.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 20 Sep 2024 09:10:00 +0000 Received: from patedamande.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Sep 2024 04:09:57 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v3 3/6] drm/amdgpu: delay the use of amdgpu_vm_set_task_info Date: Fri, 20 Sep 2024 11:06:45 +0200 Message-ID: <20240920090920.1342694-4-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920090920.1342694-1-pierre-eric.pelloux-prayer@amd.com> References: <20240920090920.1342694-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: DS3PEPF000099D4:EE_|CY8PR12MB7539:EE_ X-MS-Office365-Filtering-Correlation-Id: 24d85494-52f7-4c32-6d34-08dcd9540145 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: w1kuZezKSdquTSXAlFGLuVvDtuGZVCy+5Bs+DLxLAY07pkr5+EYbi4RGwUjl0T+JmqadVj49fL5YonoWcplW2FIIKuLSF8o94/buosoUdpXKy/1iKEQoKeqGXqcKjcFFeM1Zifz5/mHkLQClsOMurTmXGQ4+9jzBiPtZj1ZVsb9eUy3WdzYPR0eAl7CK3TATKxaOfdQDr8/XS9aaQQwv3e9eC+VCx72gtIEit0G54Sy2vY8ztegWtdz4JjhwG3flXVK3R7qLCtOnCfstpZVRmkZiVGJLhXp7OOz+r0mSnib7lg4Kk5k839TTCnZOAxNhx1k4m11hVgYhBwo9tBuzHOwss8znTTqVGXh8MT59z/qpKEu10+zf+S1Z4rWUzu5hlVUnsPUQvUl/kXiIzU71Rt4q1OMqbp5LvEwviVJhC4vrncn0Da7hIsskNbu9RGysbT895x7qXF5G/deVZaNiKFsdFG5F4N9u1kXfgaZKOR2Id4Knr4W1ClKwNCJVbyTKdJDBTGVGLsmvkwnNfWs95vVovnf3MM+rVKuo2fYMsPAdGAbcr1J+7slQH7oRhwEflX5zY0yH7jfLcsxVANVO76nCrSn10FScJdmYxVQ65Sxn7YQ0qEt0hrQwcnSDggFkqni61ztJSouV8HmJj5eS82cvqy7novt5uwKmqCfCpYqkOHl5OapKRj2JTvJL5TXgXT+JxdHyRr0gsDTPGhFxIxcjX1oSLYHEKcyC1WOPVSeeMcKcYNW8YGgvJSMBHQXtY6FdMrEkxCC/poFzfSBgTbnxynMzzkTsGs7ETcNka2K36wvHIr1jzA9POeO3RGRzzB+XIVA+v20di8opfhjNCLbI3Cqe/YQbZptdTCDqsBIh7zM6IVrUn2/95RnC6BiNwRNNPoarw3Fp6oliOPllyc1SVRDHg4ltjTf2RB5rvBgqFIWmHkb1n/P7lOkMLIa7m1FOk0P65e/VR/d/UqkC7QwBxu8Wp2fC+7YF1clKHYXThmQy4TmWvLExIkSN3l8VhnZdaQKTuy/n8yMFSQfQUIzTZe4eZGPi1ne4Ieb+OCGI8TuVdMjnq3dItYdh9VA8vb+yCAoh8rEDHenF7KM6j8Byb/LioBhi3nXswKnRxThDFMMMhH7dvBoj1E8DLFERAXmDQZUfAMfHmLLcVzQ4EBQnRn73CNcDqusRVWWUlT7Tta8Ted9DUVEW0PM8aG0TZVIgTn4cf7bqSTFQllSDtiQ03oWfpWULuzhOxo4D5ry74QUls+lDQGDRYqNcMT2wDIPodRUuXsnMp1TrOrGyoYYiOHafmx5fZKz2Gb0lhWCZrgeWwH2gWLePcf193ItqQ0fcDae4QyoJRV58TrziXnAv2CeVV16FLXsBFrBRt9v0BQcdjBNQ/T98nWj1p2XYS0FGPzRyVXJ5mu4c8GVjwQ0Utf31sVpM3Y7FM8h04KKs67LBrkR7Q8JXRtQRi007 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: 20 Sep 2024 09:10:00.0481 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 24d85494-52f7-4c32-6d34-08dcd9540145 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: DS3PEPF000099D4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7539 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 this point the vm is locked so we safely modify it without risk of concurrent access. 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 20 09:06:46 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: 13808399 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 AE3FCCF58F4 for ; Fri, 20 Sep 2024 09:10:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2912010E2DD; Fri, 20 Sep 2024 09:10:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="yCuZq9Zs"; dkim-atps=neutral Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2058.outbound.protection.outlook.com [40.107.100.58]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8742610E2DD; Fri, 20 Sep 2024 09:10:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xUUjBq9MfbRfIcuUvw2UAHzRJRXJfIRajE1uCXhfZ7fv2knXnUUxW6l4wO903QOGMno1ecCgytpqyhGu5EJpodQEOykD3m+0PUMblIEZvGalPuQYjQPyslrlGxwQg3TSL31I5iDcQOjl4blLy/YlqDbYQsleAsOkThcNoGWL6B2yAYfoWuxaCnDNGBhpKE63WHIB+ID/5wlUK5A7OZWJ27FzqdN7QC+nOWh6Stcu8If+krddkP0OoTva7lK12w1O0c8wH6Ta2zn6WMdKN95IPFIBTo+vZcY0nRBopYTwEgAWVexSJ9//mTfR3ib5mQW0h8GUUdFsNG3GOu7TCUmwfA== 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=EhLWwvpA16TjFh0vRsEEdXs/mj4rKCQa3I0Mez4qh6Q=; b=uLvp3wmSmACT3xEZ3pTPtCweLucaXzTVRh1KxCxAZ4vUDXjjxjRoNSql44BxXJ8U8MqV1iElSB9HtLyjktJwta5zSiWigyaAM0kZBKYPfGLNKhZfGcS/QblQEL5DLFC2nvr13essnJRfG/NH0nz5v47MzSJGr+jQVxQwS1oq2upxZbiWcdCqdKCUygV2bZYV+aX1c9kDGrxwuX4lJB8/RTBW9VQ/ObWx5jcvLRRleqDqD9aVijbq2lTiZkij7NT5ovExRfzUCEivJfFf+zWzZzedbmz3o+Sbt4tZ6sbm8eY4ml4TzCAYiCplRHxikIKIubEZtQLzcCQTe1wxlAWDAw== 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=EhLWwvpA16TjFh0vRsEEdXs/mj4rKCQa3I0Mez4qh6Q=; b=yCuZq9ZsZLe/t7cSQTtraCCcqRJqweF+3Mwq2+rWlfv8ZMfFq/4jIg+2YxyWH7JVk224feRbIEaJec6WfseYqt6TIqTUWWZuwYOwfrXjonIxuktCZNXke55RpvryNxBxa/FP6mxxwZMs4wAKMRaO0Z/SnKD7Gt/7BS1sDuZ52PE= Received: from CH0PR13CA0057.namprd13.prod.outlook.com (2603:10b6:610:b2::32) by PH7PR12MB7938.namprd12.prod.outlook.com (2603:10b6:510:276::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Fri, 20 Sep 2024 09:10:02 +0000 Received: from DS3PEPF000099D4.namprd04.prod.outlook.com (2603:10b6:610:b2:cafe::3f) by CH0PR13CA0057.outlook.office365.com (2603:10b6:610:b2::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.25 via Frontend Transport; Fri, 20 Sep 2024 09:10:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D4.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 20 Sep 2024 09:10:01 +0000 Received: from patedamande.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 20 Sep 2024 04:09:59 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v3 4/6] drm/amdgpu: alloc and init vm::task_info from first submit Date: Fri, 20 Sep 2024 11:06:46 +0200 Message-ID: <20240920090920.1342694-5-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920090920.1342694-1-pierre-eric.pelloux-prayer@amd.com> References: <20240920090920.1342694-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: DS3PEPF000099D4:EE_|PH7PR12MB7938:EE_ X-MS-Office365-Filtering-Correlation-Id: b7986ac9-b28d-47c1-6251-08dcd954023d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: 2+GGZJXd5HzJSMuQKlrzvrYXFsrgIeHCmbpcJZuHkBrwhHMcrlxtD2RLbQQ2rTqJseZ2GYbbI4ne6Lat7cdGHSgXHBm6v/dos9VZge99Pcfro3EZ31ibVTcYpjXprdaTADBQ1Bk1IusNmV9QfWEE/ai1ePHMo4zTHRL2NQZlaWnGB3NE4x4oau49K0Hk0PKOHu4JOq/+/ShiSpOO2EmPM6Q7Um0kSKm25i11yNMzR8LUkg5F5p34BIf1Xvw9bsNSrXfycrwHpqjO6Z8bgQUhdsxogd00l89r7LaEXZutjVsAtSlY5mEFTNxAIyZECS5EMaZCp2EIfIdxoTg3ZOfb6mSZD678HpOQ8NbcK8NcgDXTXhhxhVvZzYwlb28AxWt6/WIgf7SDsYPNGl2joyWIlsKVytHcQVHdZPq89+AHUkRz8JbF5pWFHCZq5ortLmaaHFRJfBAZPYGgKuZr/RgyFrvXIme+Kr4EgPLzLEcqxld6Lt9ProNXgtQqmwphtzKQ66jOdEJdq4RDbcWcFsB5tbO7+Il5oAPmw8CZ+xWsEWOrLNoYnswHOGcVYgCel61ImT7ZuNDTjoFUid7/+QIAX7sIMptD1ugP96qHvDBTVbYqfNEWjM2FxxoUWoXVtXJ8t+qeDJns/U+aB92pEy/3PORiuSoqC4ukfhSqEce9JQhatOgpouso0wVcqNyyDMOUtrlPk1SGqecFiUXeDeGZ268wHoz/LkGQZoemHmVhUziD9BisYL62JHZSUh0GkDy7d56kKh4Ioy7Ea8jKcHCRxjDX/ALFBEcMhPvl89E0Zc24BLBeOoUXGrWC3Pfweul5qxHtL4nfiCXl6INVWuW/9onhxOFLmjOgerVVBi0qVQ2YDegboDRPT4qOKAA6h4D4KXYv3H96BTmm71evvAi/9Bii71Wa2/zLnhQmadPUZVH+uecF5zLYkK94xxvSbl63MAKQIwzjhPKS9zemOrz/UedNZkxgsTdrwElccbiiz5b6u/hvVGRATP5tgwyY1bsOXryTOwT5W+NxWa+I0iwikic8x9LRdKf3JxWNYoIXDGVtlLRWC+SDmYLOmZUBsFoJOdyfsqn0/gDAkHruFMrzmIcx7Rw8r0JET8cXVFgosIQtaH6ZrXo9OuuJ80ztASFzWKcF+/0HwXn+h3Lz6+y8ozmaBuR30UBcMn+XhoKnjQLg8n/ZWAN0av778k6u7/GbULEN55srP9D3/vmMVhInniBFqTlvHhF7X6jbKMA+0E6OI9220B/FyvoTkvAA9x3mNTDbOK+9dk3psB3jgVMeEUEUlE7ghqDu20JfPvWz15ifZCx7z4TmV5LrwJmhUdonl0Ly9S6r2NAzQ9U0LJ11qkxjl66zXSUiCNtmz+6xhQ0lSKmbqVHIdR5JnATGMrmv 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)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2024 09:10:01.7044 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7986ac9-b28d-47c1-6251-08dcd954023d 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: DS3PEPF000099D4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7938 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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index e20d19ae01b2..690676cab022 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); } @@ -2372,8 +2372,12 @@ 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) { + if (amdgpu_vm_create_task_info(vm)) + return; + + get_task_comm(vm->task_info->process_name, current->group_leader); + } if (vm->task_info->pid == current->pid) return; @@ -2385,7 +2389,6 @@ void amdgpu_vm_set_task_info(struct amdgpu_vm *vm) return; vm->task_info->tgid = current->group_leader->pid; - get_task_comm(vm->task_info->process_name, current->group_leader); } /** @@ -2482,7 +2485,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"); @@ -2608,7 +2610,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 20 09:06:47 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: 13808402 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 79412CF58F5 for ; Fri, 20 Sep 2024 09:10:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF6F610E7F7; Fri, 20 Sep 2024 09:10:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="MB8MJ03+"; 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 48DA510E7F5; Fri, 20 Sep 2024 09:10:12 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=D4iSBQvzJZnMTtmpoIS5VkbwWLmMOUll/gSdFIdiISq6t5yQw1Wugev+cSW45wCgxeBeCFDRRpRcKR7YhkrrZtPx1VZp4zvoq+cPRXVmu1XkuvzE9trebFh8Ufd5/jTZhuYB4vNDLPAbt3ViQfkudYJ7nVqwjA0QQ38CPE9gTenf9q3KrBlzQZHigryr49TYKGhk8Zlhp/RRH4Ncb/LtUgNYFBTKaIJOkWQsIsrvDEOGnMKbHUi0T9NsCsvuuUbQuEvcpkYrl0KpkgAyRNXXRz8X648pO7halODSEIUe/Cbd1AsdKPaoixARefbnxrlnMRRkQEywIs/IroSWM54myg== 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=Rzq2PWwBF5hjtU43AMv1Dq7nuQPiVX+F4y1egAzNB1o=; b=ei89dILGs4DVm7hY8GY5gG7L7HYYXb9SZCpI4cN3QAp2qNzWXKlm3b7059T/NHwbfoDeY2hrxNL5s4x2UkRyK9e61a3eDjeOx4bP8hh5XIL2xVIG87qxwsGlMZ18J+7AIY5YV7uyDCrnxMfPDJgHfPjVP/8zWpI2Bch99a+ZEhGn80I0ueK8wBYVKze4V111gI2BjLJS3EH8fgvfrDDd/DjxKEkYuD+H9cjnsgIjmc74WRFyO5JTXdlVUMPAJbrYAAkas21Ez+mkFzImDDIuVaVLKYTUF8SaHMV3rvUMBDgE0PrhvvEveSaC6xEvGBC5FUBCV32w0b8LyZSWuXfQTA== 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=Rzq2PWwBF5hjtU43AMv1Dq7nuQPiVX+F4y1egAzNB1o=; b=MB8MJ03+TB7Ih76DC2l8sj8B183CzioqD1gTdLJ795y8DgLGEctmQy6OSpcUAnGSOLIIxGCcwljUb4btsd/XqXqg1uOKUaLZ8xsAjaBkbm6SgtT9FwxetzTDSEdlGYCxNW3/AEOa+YcXxKlwFVkBsR730ulMMb+ysWGcqKTUiiA= Received: from CH0PR13CA0039.namprd13.prod.outlook.com (2603:10b6:610:b2::14) by SJ2PR12MB9140.namprd12.prod.outlook.com (2603:10b6:a03:55f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.22; Fri, 20 Sep 2024 09:10:04 +0000 Received: from DS3PEPF000099D4.namprd04.prod.outlook.com (2603:10b6:610:b2:cafe::19) by CH0PR13CA0039.outlook.office365.com (2603:10b6:610:b2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24 via Frontend Transport; Fri, 20 Sep 2024 09:10:03 +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 DS3PEPF000099D4.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 20 Sep 2024 09:10:03 +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, 20 Sep 2024 04:10:01 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v3 5/6] drm/amdgpu: make process_name a flexible array Date: Fri, 20 Sep 2024 11:06:47 +0200 Message-ID: <20240920090920.1342694-6-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920090920.1342694-1-pierre-eric.pelloux-prayer@amd.com> References: <20240920090920.1342694-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: DS3PEPF000099D4:EE_|SJ2PR12MB9140:EE_ X-MS-Office365-Filtering-Correlation-Id: e70fa6bb-7ffa-4443-7b82-08dcd954037a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: jnyI0iGQQq+bMs0UZhMzyh1Ge5nHufo3K0ZogPF0cNf+8QhQm5ScXI+slBjYGVDj41gQKWAklr0713Gxh6/byGPxiO91oaNpgqWzqZfngqVkph7fegKO533Nl8enfzyZG9NS5Q6IxdCKdX0MmZhf+1atxkxOzCilJbeC1cFEK7bMM4AklKVAW7AhmW36s6DY2A+KYhmd2c8tudQuqQ7BhSSlaiBuj8PPrmw6wz6J1eHecRyTufkxaEnyGJ7b0T5i9htr31xJlETNmthxd5SoNLq8H0C4jASt2W2NjC8c9p0O7zhbgGBY10BLPajJZEfs4MrrxP09OUIzreW4Pzkb65BIcl1E8Ek0wi9553c3eZomfReemuYJ++OLSjbeDTvGfFqpWolmPZFOB/kZCdca3/63QMfWWRkq5UWr9eZU5Bj1Z1uayCgNz2mFb0jzBHp7l45TcLBWZeLlHr9gGY9LKeLt1MlOca9Ek+NCQBzjZYa8fKM1eqyuhsxIlsA9HBQDZVcUpuboMy73zcRZwrTasXMTtJFTv0P3Irv6rED/N87iryvsIiqnAj3pleOAJHX6PMRGVI/sdoGiZK43HmGz6NeX+EbRKPmP6lMkhU+4CgwpOAdXpDoEe2MuGqA7vEP31x81b7ERAOnq3GSVEkK4crhTMj/EcA13CGmm5bFlDqDO2IaeEtWqSUyPpPhUF0pSkDdVIaxDy5yZiXWUuEzqtdxC0ZQeV90fjhvE09o18uB71WuRiDpEp1CWTaO5ORRo0+1A/+3MAruV7UBPGCU64hmLYs4caL6GoZW5zmwXcf5wYZzuLQQUlE6nR4c1b3ALE6Uw7Kcxst+kguUpZP7yIdRlQuXHNzBZl5qjuIq1k/CQEEgTxxSrvuGF6ZMrqW9J6d2MDNU8WFPo+GdilG/+1GQiXYq5RazDl1GADeXnOu5CvqhtzGqP2j4mprT9CVwXHN6XCHaWk1ZJ5loMOYLdjNLjVuWoYijb6nvq82O7l59TXT3Q+MII40zQrO+1dmCfMg/kK/jF4jMi27TDh1W2zpYc1JEOsHEAuPcZDrfAJ6FaVGYC9of6upaAfEbfh2x9YAg70NpkBUnH6pAjbhSpQFmXX0lQ5phqLIOrrkp16UFaLg8CvKnPqkFhK1avnN8sb3n52GB3aSLrB40kKIuEQeeoagbWdZN0xbdeZYg3rfGoLpbhQU6nfsLtoQB+lvZyWluA7bww8f3rmW0CQrQFqAJU70AgFVauJkLBwegmXcIdl9S+aSU16LqRmboyTTUr9l8NSckFSFQjT/m8q9Ay7mGMzriIRQRN/f1RfY0Ueoe367l692kFZR68iwAg3cBdL0ZFhqiiWyiDC3m94xDShZt2OVatRsN8xLy32S1DktH6+LUXc6TU/C4buvmUpFyxUEZmkv9S2upcdqSu86O9rdtZvOja76j6//KQYdUql1c0hV8YMqUr2qzMtERufP0g X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2024 09:10:03.7512 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e70fa6bb-7ffa-4443-7b82-08dcd954037a 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: DS3PEPF000099D4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9140 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 | 15 ++++++++++++--- 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, 25 insertions(+), 16 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 690676cab022..7f852029d6e1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2357,10 +2357,21 @@ 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; + strscpy(vm->task_info->process_desc, process_name, desc_len + 1); + kref_init(&vm->task_info->refcount); return 0; } @@ -2375,8 +2386,6 @@ void amdgpu_vm_set_task_info(struct amdgpu_vm *vm) if (!vm->task_info) { if (amdgpu_vm_create_task_info(vm)) return; - - get_task_comm(vm->task_info->process_name, current->group_leader); } if (vm->task_info->pid == current->pid) 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 20 09:06:48 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: 13808401 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 E009FCF58F4 for ; Fri, 20 Sep 2024 09:10:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 66ECF10E7F5; Fri, 20 Sep 2024 09:10:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="z5vW1CtY"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8CD4810E7F2; Fri, 20 Sep 2024 09:10:09 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yeVkYcn7brmBw2wjUltWV7dH7MlrblRqCGm35s+tpvh+qfOeTUxgnTDkO5JyaTfAOMk6SJRRgs0aOeIwHs5hPtM/tc+eHWwQnOiT+WrUkFWKsKbEzAHF71LprGSDnhli0CCDOJynC420nOkEpWWvCOqjNB9Y89xj5IdCjbdfjAn7/T+hXH1F8wYhSYSuvE8inJPqZ0bn5dSbK0ME2u265QEczERSIcQBmZby2BKS9BynKOJE3iRvp59fSjx9WlRSKkNpj56O8ndACgK16ZDWEQXWNh7BOqNDNJQrnYpjrRscgKBVFZRRxvKwH9XLsUjXpa5U2ElLzkCNa/dJwRPV6w== 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=Hq6yZZotLfHWb+83Pw0AhKPXvnCBuuddgKSNSPQ9/QY=; b=Eyr15BNzxGZQAFFo8obeC5Dp4scFaQG+CDUUIEjT/NjIb0uxLjgh6HIcp708d3EWAEpnOzX9+9DwMlG2EVw3n7h9b2x6MhVhQF0d2c8DX/JcnPD61+lO94je/i5tvLdbMhwO8XJSJcyZiFQk9/lqORxJNP0if/nZQYIsc0Jjhip3hjWVUSuS7LHKOsJex6eKLuDZ2sNhPo/18RgfMavebCEjKdDlIAvu7dM3b9I+n6uik4g48diAVvS39oxKKWrtC34r6E9uOvQJtRq+Cr+OIpyBCDMC2JTiqRclibEHTqDRDvU6B1P9SQe6WXOkWYlSxhRznk8yqQPDTKH1QbPfNQ== 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=Hq6yZZotLfHWb+83Pw0AhKPXvnCBuuddgKSNSPQ9/QY=; b=z5vW1CtY9sJc2XAgj8vRAxRU4VvzOLBM0RHasXwTAApcwk9O63A2WwW2I/k5yVPMODJ+h6myH7WNNwH7nJ/QpXc0gPDo9OVvetdJKJUuf3UxHhTnhbWXeeY43W8sw5Z8iG8vrGE7oV2+z7QUoUXT6PeUIvXvzeIr3S89+Wn/6pI= Received: from CH0PR13CA0052.namprd13.prod.outlook.com (2603:10b6:610:b2::27) by CH3PR12MB8852.namprd12.prod.outlook.com (2603:10b6:610:17d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.22; Fri, 20 Sep 2024 09:10:05 +0000 Received: from DS3PEPF000099D4.namprd04.prod.outlook.com (2603:10b6:610:b2:cafe::76) by CH0PR13CA0052.outlook.office365.com (2603:10b6:610:b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.16 via Frontend Transport; Fri, 20 Sep 2024 09:10:05 +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 DS3PEPF000099D4.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 20 Sep 2024 09:10:05 +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, 20 Sep 2024 04:10:03 -0500 From: Pierre-Eric Pelloux-Prayer To: , , , , , , CC: Pierre-Eric Pelloux-Prayer Subject: [PATCH v3 6/6] drm/amdgpu: use drm_file::name in task_info::process_desc Date: Fri, 20 Sep 2024 11:06:48 +0200 Message-ID: <20240920090920.1342694-7-pierre-eric.pelloux-prayer@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240920090920.1342694-1-pierre-eric.pelloux-prayer@amd.com> References: <20240920090920.1342694-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: DS3PEPF000099D4:EE_|CH3PR12MB8852:EE_ X-MS-Office365-Filtering-Correlation-Id: a617ce2f-0f7e-445a-6f15-08dcd9540491 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: f1Mm0zvSfZcXWW49sLjkHJzOSBjoGVwRcdudp9g/wSn+PBVhAxK+53vAvJQzgmizgd8e8NLj9IRK3CGBMagYVQqfHalGeisCcHIu60LU2oPu3r4WFhy5YMCWpLNIM7VZGCvh5MefzXFM5LI+KJZgEjX26Fb6APyoJPsx0OG/vX5k5yZG1C9NW9BgUqKedB1v/L+ys+QLeEQr5d1DS8tDrqKSn3w1JlfLDKBzK0BRiBf0HSwd/UosPgDVZajDbiygf9QPTDPRASc3NVfV1pG7FBKkFsTrZJJKdzoeY7k0vZhHCfMlxX8Xzg/jI2jTijQeI1fAveEPviF8DtiVMcWGoyVv8F7RkgVFcyI6upilUi7UmHjd5QYddc526gJCUSMZRUnN9xuKjBk887GLTSjKJs4ZnFN2aJB1fPLcruPLR6qfHGQvM7fdKNnUYIKaeKyMiiJrEsuIvEG49NzGK5t4ski1p4WIUl/YrPjC47m7DM7xH0zYGAewqujyXtK/vmXqt+N8eTRHM6pGnd2Dqplnet2Is0Lyhqb6uayppgq71dSWmqf25YcGlPJF08TsR0q05/AeeskAKgsdB11ybb+zpDjAC2q5V6oNmNXHiAPI29ufeGTRqUBFVcRoeOTYhinMHyMUJ+4fxGgMpbsLQ2HMCRNAkv22+ZyycUSbA542KFsUBUxoY8vDGQhWy66P9VBayMcaSmD/PYtcNDvbOIoF1IxhFYD9Ul3qa8LT3E2mX2hGIyLJ80ByGkk3hYp+0xJR1R4dqugea4QCOrpsk5bDs4l+325+T9Yo7pjxwpN08S2Ba03+D7UI5xg6Y5+8qMTo9tWtRghqQiA2/MegIZlhJKrbudUSAjCvR7FeBYhvz4cqJdywDi+pxvo0DRTCPEQrRbF+xgwtX+gc632/U1VXN/HfStFXELpZHt+Vx78Y6EeBiLJqX2Qocy6VSNXXVk8m9XZmkMFow6ZlHq1t+jheUCZkumf6YKaetaPtlk45U6hshH6QUF+70g3D3gB+Cd53l6OQYTQkASioxNxHfQtHCQ5s3E6Grx+gAgnHVlz4Uil351I5D3tqRvNj/B6EJnxg4/hu2dGr71wjQ59CCd3MijRunTJVQkKx0VBmGVo5ixCZm2qxfB5dTyL6qTokk+MlYHu40PK7LVfNtJ7Tlwe5cfivASyOGwIQnwm68OU+vCmjQE2qnYuKcCcM5c3b3Dc/hPgqi08Rar+ZUWR0nnYWkNcLWEPGGV1EWuHIjXA+2Oss/D41cSLT3+pL7T9olOlMQEKE2im9115d+QNYIxhH8JgrAGUARQROf6ovNkjSWDLRwjnPQytxfIiX+/Y7qRwJoRpWQVmDYdgS9aBhm5eF48sDNfj4MTw4Ewp82Jml/gUpqRO0BeHt8OiolobIyU9M7mSva4qGvX6v3tw2Vr+RwjXAvT8ppCSfyO3dGA8JX090zBfxdnIXiACofJAz7RW/ 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)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2024 09:10:05.5638 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a617ce2f-0f7e-445a-6f15-08dcd9540491 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: DS3PEPF000099D4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8852 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, 30 insertions(+), 7 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 7f852029d6e1..a2b12f0c3253 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2355,14 +2355,20 @@ 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); + if (filp) { + mutex_lock(&filp->name_lock); + if (filp->name) + desc_len += 1 + strlen(filp->name); + } + vm->task_info = kzalloc( struct_size(vm->task_info, process_desc, desc_len + 1), GFP_KERNEL); @@ -2371,6 +2377,17 @@ static int amdgpu_vm_create_task_info(struct amdgpu_vm *vm) return -ENOMEM; strscpy(vm->task_info->process_desc, process_name, desc_len + 1); + if (filp) { + if (filp->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->name, (desc_len + 1) - (p_len + 1)); + } + mutex_unlock(&filp->name_lock); + } + kref_init(&vm->task_info->refcount); return 0; @@ -2380,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; } 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) {