From patchwork Sat Nov 16 04:44:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13877490 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 6DBCAD68BE4 for ; Sat, 16 Nov 2024 04:45:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CDA0510E037; Sat, 16 Nov 2024 04:45:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Se7XBrct"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2060.outbound.protection.outlook.com [40.107.223.60]) by gabe.freedesktop.org (Postfix) with ESMTPS id ECB6110E037; Sat, 16 Nov 2024 04:45:16 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oCLC3CtvZ8g5SgQWGiThv5rr11lQAvV8f+IDqZt90Uw0HD+u9jJkUUkYHU+zxeyO7Sn1JISAqItE5+menD66f/fuxwLg2AhDKjnSEHUVTvbgZunTJ2fKtLgphbAGX7IxhvFBEfyEMsmeQwIq69p7bFET/2tC6Z5Dv/8Q5hQkvAS/Ea2GfytSqNVPavS76CSjhzWW2QCJuGIb6ZRRGn3SY222rDoYTUHNO1/lP5aXElObeVp7KpchyF+cLbmqpVjRMUt01xIovZ60T72jpD5lpvuFFL2aYo0T62i5wEk0aS9nAN0HJCIgrY+xtqfR6FToIMUSonbT2FSsFo8TOEtWTg== 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=J5JSJ5sJgfoK0X9unfL8geNk1kgOH9scMSIgCDRQFnduT4awwz4q49lqMTeETEAkF6NIFisyWhE5AtiBtXdtZoKIqxoQ0RoByY97tqeX2zcLlanf/C2Rrqc9wA7rHjIJQ+huSJBX5cWmC+cnhCB8Xk0UVuzIht9o/0WCoE0o7V8lOmeJusSDq0RoK0TKoz2+0q6BnpsMt5IZ4AgYJIxaagH5gh2sY2k3XHu3q69ifOUJwoCvt/cKSb8pm4Je905bwCV5baHlm4D+G3ddR7F0OUPh8tWejDRL9swYkipIm5flZbT5KOeUfQz9sbCDieASaAon0KTWKJKJ1I256m7azQ== 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=Se7XBrct0lpwAlEfaMkT1yDVBDDfx7+25Yr4ojzrdAkZdYx5QrmOXJtNv4use5Tg+DqV92HVH0HLNhgbN3CD9L2OJc8lKleqd8M4P5YmTsBSk4hG5IYn5BzoVO63R6/8Xi6/FUPvqtWORyOcUbENl1vboSBn/aB8OwGevbyzYTg= Received: from MW4PR03CA0150.namprd03.prod.outlook.com (2603:10b6:303:8c::35) by DS7PR12MB6286.namprd12.prod.outlook.com (2603:10b6:8:95::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.19; Sat, 16 Nov 2024 04:45:14 +0000 Received: from SJ5PEPF000001F7.namprd05.prod.outlook.com (2603:10b6:303:8c:cafe::9b) by MW4PR03CA0150.outlook.office365.com (2603:10b6:303:8c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.18 via Frontend Transport; Sat, 16 Nov 2024 04:45:14 +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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by SJ5PEPF000001F7.mail.protection.outlook.com (10.167.242.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Sat, 16 Nov 2024 04:45:13 +0000 Received: from MKM-L10-YUNXIA9.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 15 Nov 2024 22:45:11 -0600 From: Yunxiang Li To: , , CC: , Yunxiang Li , Subject: [PATCH v8 1/5] drm: add drm_memory_stats_is_zero Date: Fri, 15 Nov 2024 23:44:48 -0500 Message-ID: <20241116044452.5925-2-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241116044452.5925-1-Yunxiang.Li@amd.com> References: <20241116044452.5925-1-Yunxiang.Li@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB03.amd.com (10.181.40.144) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001F7:EE_|DS7PR12MB6286:EE_ X-MS-Office365-Filtering-Correlation-Id: f55f8679-6d32-413e-d9f5-08dd05f975f8 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: =?utf-8?q?KD608meUEiXlTrsK4MmwYmEUsQmgmtY?= =?utf-8?q?wHwlHCkao56TeM+uolgipuqCxvsRtW8rgNxay63sJLZukioVLLO1L0mbh52sOSs2Y?= =?utf-8?q?p2Sd76bg2YRxwDjyl+eMv80czaL6K3f6fDdYq/5nWxWvFqB18tbAjadEZUGMSjK7n?= =?utf-8?q?UQoUqO6lYq0S/KeE867+mjpx4mvcc+89AD9HfUtjznr7mT7irPmNA2x4doqZ3hkZe?= =?utf-8?q?raNNiQ62MCvIOtAN+h3Xu8lT3WHR/sw/XfFd8QsagFtsuoyn1l6Aadb6eSTvtNbDH?= =?utf-8?q?ZOSCrVRQkvLWt8bnhTOFDemInQxKdg79xG9h5qir15PBK7hbFaT5XHHx9ha3rRXvN?= =?utf-8?q?OXhwjmiyzOO+9nmvhRl0sKfZaT78BVIo7/qoE7XECi7FI+6O8fLgLDoJA/2k2Uy9W?= =?utf-8?q?tzip6gSPlFvEAe/quEknQaAUxkHbOEHN9wyBTk5ZfExwnPBk+ZVDdiNCDeMiCWhJ9?= =?utf-8?q?V/tDBjEJicA2fU5h6xd+Zb+OSiZzSg8TWfz4YqTe6IuNV0ZLDy6PwWsuA5eN3Kw2x?= =?utf-8?q?e3bX3jxYvzEJRJIn1u3du1rwUCsga/+AKH1j2civbBwIAiPOKkddLxGD6LLkFm0aQ?= =?utf-8?q?Telw1XETMfJA9Da+DGM1d2kUYTrzUe20niYGA+Zu9VU2d4tnSfOygOLqIhU7LWwpx?= =?utf-8?q?BXR/QQ1I9PYzUgZZtLdCk1Wct8xw8SdTzkK3SanWnyRLErl42OPU98CWihKVrs70X?= =?utf-8?q?3ZCm5WeYTvWAJnadTJkzqrDUK5sB1l1qSwMY6N+H1Iyi4bAR0NMltL2EiBzXNS0L6?= =?utf-8?q?V1WWLZKrqSRhBzzVNqUZ8TcFdLjpWwx9SnJkWgCZ+84U5Qww0RWdERN+W1alXc+j9?= =?utf-8?q?b0wy3g/ABr/2kH5qy21VCnv97XNLSgPxLtH6c+9uiR5KFcXf4xhuhG25I4Zy0w+cM?= =?utf-8?q?ilIfemzfnwcWw/WBFp5we2jVEKQnLsjjjfAGMFwaw4xC8yN1EA/z61b3Of4fyz84k?= =?utf-8?q?lcc657Dltnn+SD3T/kWGtdS0Xjo8tLwrPDGlSm8uRBKNu0V6pgu7iA8l+N4jB9U6W?= =?utf-8?q?nrw3uqUtYxo0NIzXGmDdeszMeg50RCBSvKakGvQrytNkdawUFYsS4kZPDaMBSJPal?= =?utf-8?q?8e3Zzlu1OL3VtRkSOkbNpvjvfgs2Qvk/XG9rfEoq8QaXE7ZnttwTOTdbh0jgYBq81?= =?utf-8?q?PMKkN9XHdfrur9+G9Gq6+aWK4DpyFr0HXwj/Iop1k5lJDuYxlttFE+2FBbqbNCH6S?= =?utf-8?q?KDrXndD00B67HoWMAV+ved7FQg5Av0sfvyxWNHeur6rCSufE2AJ4rUmJyS0WIhyUs?= =?utf-8?q?NZTDk1+SuGzeU6sDvGm2qmCdEgnXH6vFrRR3fs4GIWfa5cGd5r2PtFUizguNbjEd/?= =?utf-8?q?WrHdA3hTHrgWDFyID5NCBMlIv/URUIgFIw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.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: 16 Nov 2024 04:45:13.9310 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f55f8679-6d32-413e-d9f5-08dd05f975f8 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001F7.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6286 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,