From patchwork Thu Nov 28 18:54:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13888282 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 36DE5D70DEB for ; Thu, 28 Nov 2024 18:54:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 83B2010E6C7; Thu, 28 Nov 2024 18:54:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="huMBTn3y"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2061.outbound.protection.outlook.com [40.107.223.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F48A10E6C7; Thu, 28 Nov 2024 18:54:32 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ch9rpCtpKQM9CLlFIWTDgYOMBesJ23NZJ8e8+KYX0FF/i97TAmnApjYsbSNrGjuYPEG4F0Ps4K+u5nAHSJRxNEuRACanqDCSZQvPh3maYI5JLTTK1JoEatK5eZ6eeAkrx5tmb+dWK0T9lgD+VK/dnrkWLnsOY5UeLDlM/O4AkwTXGYv2+OmyiU8LWrMkMQWBOezeo61q+ylwVtbX6gWP+GqkHIusvuj9jQeur61B3/gUEygVid7rRkGHiX3cvHWUC2YZb/8Lk74Ni6LCrngcQgZ4mi5SUm4RKAqG6RQ0CZQv3AKMUt2Ooi1P+Jzlo3cV0+7mba7lkSoiYKBGRMP1Nw== 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=jsiRFxnwD9MAzsvO8nNXPttllKcEPI8rPAMEOIfSuca7UJvD+TmoIZtUlK+0ywD+GeV3pZ6sZNdAj+RSGlfYk0kkilJGHbIudtIAwmevyXblkHSaiqzHSXJW6Skb8nCcU3fwsU8m3U2zUKGQ4JXrsvbPOdwt4hcfecMIuiW1gl63cGI4b7hS+47lFiWMoXEfpsyTMIPNVAnL29FTTgA/ghS3ZYS9WhyChjmRd5p3B/cE4brxZlOYQutfBgSkyzGAKvrFFUHx0O/RoHopP6NjbiqZpt+nardaC6VLTIUfGwGBqmQXFnfpDaGmF0AQGAlCa2HCboN2s3SkHjpXhpUbwg== 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=huMBTn3yOcPLBzeHli7RuCKORxmhx12/IJQK3VmsZP0+DOarQx8rvZhITzdgNGdIWfmglejx4Oo8685psx6dXsuewt1RBP6xz3QraILKEW7mJpbZhCaP6EEW+ljCe0eG57WIj99tqq7Kzt/n/4C2I+Rt0y364v0Rf8j4ixiwkH8= Received: from MN2PR02CA0034.namprd02.prod.outlook.com (2603:10b6:208:fc::47) by CYYPR12MB8701.namprd12.prod.outlook.com (2603:10b6:930:bf::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.20; Thu, 28 Nov 2024 18:54:26 +0000 Received: from MN1PEPF0000ECD9.namprd02.prod.outlook.com (2603:10b6:208:fc:cafe::6a) by MN2PR02CA0034.outlook.office365.com (2603:10b6:208:fc::47) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.14 via Frontend Transport; Thu, 28 Nov 2024 18:54: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 MN1PEPF0000ECD9.mail.protection.outlook.com (10.167.242.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8207.12 via Frontend Transport; Thu, 28 Nov 2024 18:54: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; Thu, 28 Nov 2024 12:54:24 -0600 From: Yunxiang Li To: , , CC: , Yunxiang Li , Subject: [PATCH v9 1/5] drm: add drm_memory_stats_is_zero Date: Thu, 28 Nov 2024 13:54:00 -0500 Message-ID: <20241128185404.2672-2-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241128185404.2672-1-Yunxiang.Li@amd.com> References: <20241128185404.2672-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 SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD9:EE_|CYYPR12MB8701:EE_ X-MS-Office365-Filtering-Correlation-Id: 9158c3f8-b0e1-473d-503e-08dd0fde14ab 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?0X72ipArl0uLJffdwGmzzUM1Fkn+cBi?= =?utf-8?q?uKspgZ5FHSw8z1aNmGeVeceZ+PM5BznlAkAxWbBA2+ooSH/0R0Q0suj3oT7k1YSwd?= =?utf-8?q?1e3CBQZk1NXI040/rNElyV58U/8bkxpbaKrCdd+RR5FZZVXAfL6wz2cvkNfioKD7S?= =?utf-8?q?Kx50fUfTCdv8saIS3uXMeiAUgJ9Y/BlEFe0HLJqSHB/Cjzz5NNYSEC5CeogL2rXZt?= =?utf-8?q?Ood/IFsExZClFyNULCK+DFu+i/cbc71fCAEBd1JNM8u6Ixq2LdtyTB8xOHm6RwH87?= =?utf-8?q?L/BaZFFeGZ1b0dKpTsHdn0JkLm4sn9wxn4Mz/J8ZaAXmnbNCvy7JEXf8jVN8S3es6?= =?utf-8?q?vIsoAWL1smPUFfTZC5zkPs4xnim3WbPDAIq5dA1V5AAi7y3GGGDBQ2fUaPUinrZd1?= =?utf-8?q?tMlBJsIvNC8xv5KLaOtyoQ/lMztZdbZi3QL3AkPwg18AVK89AL7wrAKv2g9Z9V271?= =?utf-8?q?SX9Th1UDaL6ialv3oEdM4AxuwW71d14kKHn4pgA/bo1KXJvKOv/G4ZwhbDbRfHBpS?= =?utf-8?q?SfC3dhwLqzBU9wXfkNcIzXLRB7id2/1YMN69OFaRp2z0vaYMvP+KEgm8tlc9NbIxs?= =?utf-8?q?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V: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: 28 Nov 2024 18:54:25.9781 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9158c3f8-b0e1-473d-503e-08dd0fde14ab 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: MN1PEPF0000ECD9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8701 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,