From patchwork Sun Nov 10 15:41:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13869959 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 4D00FD12D46 for ; Sun, 10 Nov 2024 15:42:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 254D010E035; Sun, 10 Nov 2024 15:42:32 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="F8YOd9SG"; dkim-atps=neutral Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2086.outbound.protection.outlook.com [40.107.94.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8DD2710E035; Sun, 10 Nov 2024 15:42:30 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=R6/GjtYz+tMjdHB12nFcfWmgtwzPiKZ0FqwMhJ44EJLn6XuBuKpdu+RxlEt2XwNRe6oJZCCXWYlsLgsf1yGikFmVXT8bbGE3lOK/H/7pGthJlYbhHCf8BBa7cpSxIkl7PgRETERks1KFIO4ssKCp9m6/nmXAA7/gJldH3Gojrvx/E9PWgRgP3yP3icFFxxQCwjs+Fp1I6j4B7AkA5H6g/Ye+EL2QuIjeUTyPZrhRKhPw5r2yJs1sP5YSEuIFsJY0Zf4/pBSl217PkpSD+E/mf6u8GY2QE0MPX7LB75TBmVtgjnwqACbEcmwTDLkfcHBV17W0U4IA3uZtma6W8+ocGA== 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=xSWAjmpW0RzYA3fPKkCKeVEDXtQcv56hW8REsGhZQAw=; b=LJKlzs1V/Ixei+3vgYbQqY3sNk2fnvg0AiAeQLq4BrbsfKlIUjzpj96hq+/Ek4VPna9rTO68Zy0TZSSvHt203VlKtevvhsqzTlnlsu9Asr5D+KwsfWjFEEJ2EpA+ZSWeMSuib8xPdiyIFht9V5yzYbEkNYGQoD7EAD3ei/D1l55ueUeANN1EnZ2VvP3euQaPwiqQkzbJi14IzEqj49QmPIHDxCewQvC5PNpKEm4X2iz6pONDy+avHSN9RK+MorSjh7zacDt4lYu822avjQW/7bGitUJwBUHo+SAa065nv68488vsSFxQFsdphBIbKexSHWavemmAErjhquIwP5LgXQ== 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=xSWAjmpW0RzYA3fPKkCKeVEDXtQcv56hW8REsGhZQAw=; b=F8YOd9SGltcht+Jn2C2o7j4/yrNNZcVy47SwKc8dfBTmewFcHZr0tkb7U9BIhnA1TMk5uXRGhpXZ0GeG+olm6v/48OTropIjoD7mhL253qXIicuIbbtGeWX8TXZbSEFOcJ2SfMzPCotlGtYzT3Z7mPMKxNsaMKXoyvZyJ8iLN7w= Received: from CH2PR14CA0014.namprd14.prod.outlook.com (2603:10b6:610:60::24) by MN6PR12MB8567.namprd12.prod.outlook.com (2603:10b6:208:478::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27; Sun, 10 Nov 2024 15:42:25 +0000 Received: from CH1PEPF0000AD75.namprd04.prod.outlook.com (2603:10b6:610:60:cafe::28) by CH2PR14CA0014.outlook.office365.com (2603:10b6:610:60::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27 via Frontend Transport; Sun, 10 Nov 2024 15:42:25 +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 CH1PEPF0000AD75.mail.protection.outlook.com (10.167.244.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Sun, 10 Nov 2024 15:42:25 +0000 Received: from MKM-L10-YUNXIA9.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; Sun, 10 Nov 2024 09:42:24 -0600 From: Yunxiang Li To: , , CC: , Yunxiang Li , Subject: [PATCH v7 1/4] drm: add drm_memory_stats_is_zero Date: Sun, 10 Nov 2024 10:41:49 -0500 Message-ID: <20241110154152.592-2-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241110154152.592-1-Yunxiang.Li@amd.com> References: <20241110154152.592-1-Yunxiang.Li@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD75:EE_|MN6PR12MB8567:EE_ X-MS-Office365-Filtering-Correlation-Id: e46556b4-16dc-4998-1c6e-08dd019e468b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?HnQPrKvQ36VIo3ZmRb7WFNTEjBqsXJl?= =?utf-8?q?I9VU1PtetZNAIUIuEtdHo3oyaFg55aX+IO4YvBczvMq5ibgFtoRincKdZvIsRBS2V?= =?utf-8?q?OvuXq9wZ6mcMRC59K7M+/atU7m9u9rKisZMdBRvbHVHHjXR5JcnR54iXgWZ2TTQLe?= =?utf-8?q?qZq5u1+GPR9ACwroLw9yPDK97hVrzeX1mpqvLs4R3tG7US09rKFZ/xgxI6Fm0I6Sw?= =?utf-8?q?lpfeNTl/Tlo6ll2za8D9O5Cr4gyt+jJNoNi4onpotI6h4M+5w4vRczyFT9hu/9zGG?= =?utf-8?q?zmzDA5qd5U2MPknTdN9qM/ZyXzULqkYVRd/1FPWQcwCy84R2T6hK/rFJBd1Im4+vJ?= =?utf-8?q?Ij3qjRsPtfJlmVG9rcUdjf0wpDOjVcB/jSNailkQPyii/Iq4iQ9e2q0ITYUP8Ex1s?= =?utf-8?q?3045UYXPIjVYUIjxfm9709DnS6j0+OSsq2xEULd+UWn9KoYQgDkLtwtbODFiBdv6u?= =?utf-8?q?GJxlnN7Pe7WHhXHDgk2ib8LFrtw9xcj2JEsJTWVYlL7/1SrvLKoFSlZsl5CeS2WZc?= =?utf-8?q?37r9hYt1jHdor8S2d0j8w07Wx9B5+Y60JR4QTztBWcGUifGrDbC7oTXRAP/uq/Eu5?= =?utf-8?q?g79w1bzwtqWIqlDdX2MXoELdavhPKqu6Uei2/W53GWE6Rny8J2QCfOnhfTNL1/J1v?= =?utf-8?q?jZPwz90mDT5p8xq068+Nhrf3KCN7E9h8UDdFOkPUqnr7KGdhodGGtq5ualNGN5TD0?= =?utf-8?q?l8fX+wRklX/shzX+QE6MOU5nPSRyHFzM9cHtsNG5zBxOLZlZhJijA3oxEmJBMrikS?= =?utf-8?q?yvZnnp19KfN4m3TbrxC91q1UOWTd+ZguIPXWycHhTRmSD9KTsuXCVE5HdhHMS2oxV?= =?utf-8?q?G+fr/iHOZ1U5iZivPJZNJ0uI/TDP5OaeDDbmBxuaEKfgW/rEkD2ESuFLu25H6VWS3?= =?utf-8?q?o+hOnDPiavfPuSKYjCT1GLjmyBYPFW8E+MBlAuiLMjsZD1LeWCzyqfL+wwjd7ahB5?= =?utf-8?q?+USObbvFVTAHY/+QdaJAoO+xmA07MO+UvhwaW+OZKRNBxWO+AXFHLY7JvxAP0klkx?= =?utf-8?q?OQK5WETWz6vhP0/AkwBfF2Jf73iQDmfA83zClnG94Dd/bnbd3JPr4k4wYa5/o8nK2?= =?utf-8?q?EGKQaFllIUdyxdUSoEyGxLUXuhkbvA6uOsb05pO5nN57SA6dQ+x8CPHvB4PluDTGd?= =?utf-8?q?ywaTNoL0KZdC22gvf8PWPQCLaXSplSXM8TCbU0Uj2fCT+aMU36OrT5PFKHV1Q1UO2?= =?utf-8?q?Cl8K1joG7ZWCQtdfQeZyqlNwXJOvuK6JejLdnHAYhWFmxjY2UyIVkh7vuihvqAZ0r?= =?utf-8?q?dFET0x04H7jD3+lbUC4CEYQudC+WQUCA3K9F1eq1L5WD/scrU+YqF1SJMZaDyPcUy?= =?utf-8?q?I7lHXs8l/MP36hUz/zb8ZqUlCtJh2vYDVg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2024 15:42:25.5523 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e46556b4-16dc-4998-1c6e-08dd019e468b 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: CH1PEPF0000AD75.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8567 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 a helper to check if the memory stats is zero, this will be used to check for memory accounting errors. Signed-off-by: Yunxiang Li Reviewed-by: Christian König CC: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_file.c | 10 ++++++++++ include/drm/drm_file.h | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 714e42b051080..e285fcc28c59c 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -859,6 +859,16 @@ static void print_size(struct drm_printer *p, const char *stat, drm_printf(p, "drm-%s-%s:\t%llu%s\n", stat, region, sz, units[u]); } +int drm_memory_stats_is_zero(const struct drm_memory_stats *stats) +{ + return (stats->shared == 0 && + stats->private == 0 && + stats->resident == 0 && + stats->purgeable == 0 && + stats->active == 0); +} +EXPORT_SYMBOL(drm_memory_stats_is_zero); + /** * drm_print_memory_stats - A helper to print memory stats * @p: The printer to print output to diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index ab230d3af138d..7f91e35d027d9 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -477,6 +477,7 @@ struct drm_memory_stats { enum drm_gem_object_status; +int drm_memory_stats_is_zero(const struct drm_memory_stats *stats); void drm_print_memory_stats(struct drm_printer *p, const struct drm_memory_stats *stats, enum drm_gem_object_status supported_status, From patchwork Sun Nov 10 15:41:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13869960 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 9929AD12D47 for ; Sun, 10 Nov 2024 15:42:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0559310E2D3; Sun, 10 Nov 2024 15:42:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="YzNKiAGp"; dkim-atps=neutral Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2077.outbound.protection.outlook.com [40.107.93.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id D9A8B10E035; Sun, 10 Nov 2024 15:42:31 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dYRSaNohzRP1WT7EdhHgaTBDNMz/RkeeHjnA/uFufEP0/7TS+IPWqsAoOqMLXIvoDO1ruBfc9zJUAOP0RiLYUyjEDUG9e6yh7LAgIf5UMo3rfeITmEm1GQ8c9FaOpsLJBe3nK0z2oSl5Meb0NWrSbmPum7qQ3y+1kb0+ZDAIwGRHIBdLewYj5FEAWuOQEHHD9mHn7jw7lVnmOGqqCYCX7R7AAS/N7PL3POpitq/WfjxL3aQeP+epYq7/CJ++AadhwiKWDnscVIYkAXVJ8DmgEJm3UmPKMbd0Y278L4jMqKMphRKXhGb+u0gdRYsYSxVIneUG9qtt380o/g06ORY4sA== 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=pWtVQR2CQxI+5TDmYGp+d550I0tB0nOMSy+Q9yX0Jkg=; b=yvQxhllODdjvlIVhqkG+DVgFgDfjOkFTI4JMnK+fgnH0c81eCggLdhIAXMTmZdP2xrkhj0OSSb0k16kKZ+uesvHhwu0qwA4tODVdVDojBSj8c0YU0ywboB89i4bFzmWf3dh5c7+4mrWE+w/tsH6OdMW98ZnAR8GGuvhZ2tFBqEraJTfyl4m5WVFtBVSCmDxNadpp+7TVawrvwHBRGTYFfj6CuWtRXJ+OGmJX0u9LhNm+ltSZKyStqHUhvReS8eZp0tvIWfcwR4DjYQ/5j7h8tv4iy0x+4+e4qv/8nFjOmXd3NCX37SgDqQ79j1BGKa2K+ZCT8XKkB8cCMjX3ieyq1g== 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=pWtVQR2CQxI+5TDmYGp+d550I0tB0nOMSy+Q9yX0Jkg=; b=YzNKiAGpjj+5QtUyicrCePfQoaK6IpEfl2302He2plXLf8LznZotyeGDMvm0hDKYHqKFbxTDbLe0y5xzFNdwIQ+JabBC1mh+plZij1pWfVFQdczkwP/j7yw7n/lGUzeV5beRCrZwaHT4aAJZBJNEfBv1gVhBCHXz6WANY4RmEFM= Received: from CH2PR14CA0002.namprd14.prod.outlook.com (2603:10b6:610:60::12) by MW5PR12MB5621.namprd12.prod.outlook.com (2603:10b6:303:193::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Sun, 10 Nov 2024 15:42:26 +0000 Received: from CH1PEPF0000AD75.namprd04.prod.outlook.com (2603:10b6:610:60:cafe::39) by CH2PR14CA0002.outlook.office365.com (2603:10b6:610:60::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27 via Frontend Transport; Sun, 10 Nov 2024 15:42:26 +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 CH1PEPF0000AD75.mail.protection.outlook.com (10.167.244.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Sun, 10 Nov 2024 15:42:26 +0000 Received: from MKM-L10-YUNXIA9.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; Sun, 10 Nov 2024 09:42:25 -0600 From: Yunxiang Li To: , , CC: , Yunxiang Li , , Subject: [PATCH v7 2/4] drm: make drm-active- stats optional Date: Sun, 10 Nov 2024 10:41:50 -0500 Message-ID: <20241110154152.592-3-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241110154152.592-1-Yunxiang.Li@amd.com> References: <20241110154152.592-1-Yunxiang.Li@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD75:EE_|MW5PR12MB5621:EE_ X-MS-Office365-Filtering-Correlation-Id: 92315389-71f3-4302-407d-08dd019e46d0 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: jJnQ6CLvyTrhhehwW54xkA/pdctIV79C3VEApPDVBUdbTy/O7kcWTZV+0TaD34gMjMi3ulVWtiOIf8Hq9+KWglAT5jw3lkxOK5/3aZyL2FoYxg9vkLBsny13rQB3CvsXz20qyMFBfzjJjL5lvGqpzMitN1j/wdLghdQEzLlE3IDrZgSDK+crwEhimAFBePPT05RIG16CtxI17WmEmfLtEdrdjx19q0+SE+r+eHhoFguYZorhfw1f+8I6z6FGoS1/zI1+Ug5KPllBf5EYyvQLsrl0m/ITa6/gnbxVxTB0yM8XjKf9elxXpaRey/hEmrpltrOC6++o24bFg35KQkh++uyqmS51ggfaDsaE0vElpr3lRtcCcytwLez3ykDKvIiozo9Cwj4me+RUAJ8mV511SjCTtVCvCCgoUHZTERB2mHxSf+Pni9g4qJTnkQmAvKCTUsqe1WkkDXQh8r9s07QpK3HFypnUvghOBc946KEghqHkNwYabsPw+5LdKL9l4glQD7/ct+t5iQUi+xLOFzwAPbPM+dMQCpviLOcPQpzX49KqcOXcyxZ7GOJ7dakVk+msAOVDhBieNhC09oH0aJCi+VpLgOxqOG7+X2PUD0JYViJsII6dR9PvGoTo/tVpHMnSRW+xI1mVkdF7hZ0tTczs06k17wOGb/uURvwB3qSjl/nBiTLN+hEGIgkUPwbDIJ0XRGPkJokfjcjZ2dq3ST2Cg2FRl2/qmTDXONuUuIMOvzjPP55hF5I1CvTIXd7hLa1+NKaCMH4YAQZVpO3Q8y9eqAjD5fPJp4oTs1vbFw4stuhB6muXK5zD5gF2djN9heJA+LycwDJAOOYsw11kzo6Xqb6GRZJ6jFCNCJ1WdaGUNYn29+Qu869jR1clNcsAb08emt2fcTvzp2njh8Piix/paFsmeodfDvkqgp9LkQrN0ij6IDkLqHeHNw/h20ZODxQqQfvwvmS3zoDcrvomwlpfUWsZKkkT3rjD4J8YJXC7HikXcihzXscr6lMUOzos9whv7fv1/0z4N0Zpja9J6wLyvabV1PPfFLx6z1qpDRnfroyTenLgc4qoF/ppN7YE1retNGX/o4Ri1XhfJDIjHks/dgpMordaJMAJ+qlKj6upC/ISXR7THxJOfSI9wYkiOCwFxEU/P2QiK1gUnNTqDlV7OJ3ctmp5ejXfsZx01hnXkEn8DDQZNC/RYSSDfmfGkQugfDHQ2W5UNUdwTvV0mDwX+GwMiLaJm54uSVunqqhVmMW5hhWF60ZEJAPQ/KoQfuGJYZaEqWjmCbEbUbHaQnvo67k1uQ6xPj71OGWmPGftM+mxWaT19BPQ4eZ34bWqJwrTWtRctFQ/tzFTBqO3/1SfdtlLsKiVKjoaR0vJkPa5ZcB3djaWqmstM8rDVpXuG9eGxCqZVxj84xZakU8nRdF6LQ== 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: 10 Nov 2024 15:42:26.0210 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 92315389-71f3-4302-407d-08dd019e46d0 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: CH1PEPF0000AD75.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5621 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" Make drm-active- optional just like drm-resident- and drm-purgeable-. Signed-off-by: Yunxiang Li CC: dri-devel@lists.freedesktop.org CC: intel-gfx@lists.freedesktop.org CC: amd-gfx@lists.freedesktop.org --- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 1 + drivers/gpu/drm/drm_file.c | 13 +++++++------ drivers/gpu/drm/i915/i915_drm_client.c | 1 + drivers/gpu/drm/xe/xe_drm_client.c | 1 + include/drm/drm_gem.h | 14 ++++++++------ 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c index df2cf5c339255..7717e3e4f05b5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c @@ -97,6 +97,7 @@ void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file) drm_print_memory_stats(p, &stats[i].drm, + DRM_GEM_OBJECT_ACTIVE | DRM_GEM_OBJECT_RESIDENT | DRM_GEM_OBJECT_PURGEABLE, pl_name[i]); diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index e285fcc28c59c..fd06671054723 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -884,7 +884,9 @@ void drm_print_memory_stats(struct drm_printer *p, { print_size(p, "total", region, stats->private + stats->shared); print_size(p, "shared", region, stats->shared); - print_size(p, "active", region, stats->active); + + if (supported_status & DRM_GEM_OBJECT_ACTIVE) + print_size(p, "active", region, stats->active); if (supported_status & DRM_GEM_OBJECT_RESIDENT) print_size(p, "resident", region, stats->resident); @@ -917,15 +919,13 @@ void drm_show_memory_stats(struct drm_printer *p, struct drm_file *file) if (obj->funcs && obj->funcs->status) { s = obj->funcs->status(obj); - supported_status = DRM_GEM_OBJECT_RESIDENT | - DRM_GEM_OBJECT_PURGEABLE; + supported_status |= s; } - if (drm_gem_object_is_shared_for_memory_stats(obj)) { + if (drm_gem_object_is_shared_for_memory_stats(obj)) status.shared += obj->size; - } else { + else status.private += obj->size; - } if (s & DRM_GEM_OBJECT_RESIDENT) { status.resident += add_size; @@ -938,6 +938,7 @@ void drm_show_memory_stats(struct drm_printer *p, struct drm_file *file) if (!dma_resv_test_signaled(obj->resv, dma_resv_usage_rw(true))) { status.active += add_size; + supported_status |= DRM_GEM_OBJECT_ACTIVE; /* If still active, don't count as purgeable: */ s &= ~DRM_GEM_OBJECT_PURGEABLE; diff --git a/drivers/gpu/drm/i915/i915_drm_client.c b/drivers/gpu/drm/i915/i915_drm_client.c index f586825054918..168d7375304bc 100644 --- a/drivers/gpu/drm/i915/i915_drm_client.c +++ b/drivers/gpu/drm/i915/i915_drm_client.c @@ -102,6 +102,7 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file) for_each_memory_region(mr, i915, id) drm_print_memory_stats(p, &stats[id], + DRM_GEM_OBJECT_ACTIVE | DRM_GEM_OBJECT_RESIDENT | DRM_GEM_OBJECT_PURGEABLE, mr->uabi_name); diff --git a/drivers/gpu/drm/xe/xe_drm_client.c b/drivers/gpu/drm/xe/xe_drm_client.c index 6a26923fa10e0..54941b4e850c4 100644 --- a/drivers/gpu/drm/xe/xe_drm_client.c +++ b/drivers/gpu/drm/xe/xe_drm_client.c @@ -229,6 +229,7 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file) if (man) { drm_print_memory_stats(p, &stats[mem_type], + DRM_GEM_OBJECT_ACTIVE | DRM_GEM_OBJECT_RESIDENT | (mem_type != XE_PL_SYSTEM ? 0 : DRM_GEM_OBJECT_PURGEABLE), diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index bae4865b2101a..584ffdf5c2542 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h @@ -48,19 +48,21 @@ struct drm_gem_object; * enum drm_gem_object_status - bitmask of object state for fdinfo reporting * @DRM_GEM_OBJECT_RESIDENT: object is resident in memory (ie. not unpinned) * @DRM_GEM_OBJECT_PURGEABLE: object marked as purgeable by userspace + * @DRM_GEM_OBJECT_ACTIVE: object is currently used by an active submission * * Bitmask of status used for fdinfo memory stats, see &drm_gem_object_funcs.status - * and drm_show_fdinfo(). Note that an object can DRM_GEM_OBJECT_PURGEABLE if - * it still active or not resident, in which case drm_show_fdinfo() will not + * and drm_show_fdinfo(). Note that an object can report DRM_GEM_OBJECT_PURGEABLE + * and be active or not resident, in which case drm_show_fdinfo() will not * account for it as purgeable. So drivers do not need to check if the buffer - * is idle and resident to return this bit. (Ie. userspace can mark a buffer - * as purgeable even while it is still busy on the GPU.. it does not _actually_ - * become puregeable until it becomes idle. The status gem object func does - * not need to consider this.) + * is idle and resident to return this bit, i.e. userspace can mark a buffer as + * purgeable even while it is still busy on the GPU. It whill not get reported + * in the puregeable stats until it becomes idle. The status gem object func + * does not need to consider this. */ enum drm_gem_object_status { DRM_GEM_OBJECT_RESIDENT = BIT(0), DRM_GEM_OBJECT_PURGEABLE = BIT(1), + DRM_GEM_OBJECT_ACTIVE = BIT(2), }; /**