From patchwork Fri Oct 25 17:41:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13851246 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 4B01FD149DD for ; Fri, 25 Oct 2024 17:42:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6DA5810EB5D; Fri, 25 Oct 2024 17:41:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="WayHzUTr"; dkim-atps=neutral Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2052.outbound.protection.outlook.com [40.107.100.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7625110EB5A; Fri, 25 Oct 2024 17:41:54 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F4gqpTZxd6avzlp++ZvE6tLdhNRMAgCcYmb+xsskvFkE39PQxP3rThVGEqwbVVhvcFufmZCCTutbCYnDytw17diqKOJ8beQVYYw1/L7OXcynVlV1rW7nST1DpTsXIxLEZNEWClfSbK49ZwnGpfwCap3B96bv9wVJRn/UgAonSnFjGhTd+e0gBvY3DmG5pyCJ9QoJWIslXqjTZK1c56z24VYzgmdM1dzQ1brBt8WBstRvD/BS7KEoYy3yNg9rmGO0BhSMfZwqZQQggAUsN5s48ErmFMAoPzMP9KsOLbPgdQIrkYu66YtlX+UepkgA1CoL6gCGzJsrL0tEDoxjnPQm+w== 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=kgm7SYWvSne0CYCzpWhnAq8+2UVMQSeTOmWLgZO5dbI=; b=WTqJldJMKyfSzDjQd01R8qPWyyqBQGAiKWFV6lFR1ExjrBF0Zk9ncyjEnWZjHL73RaaEZytahXjxmMquw22Isi3uG8MLS15kXlP8CKJvDGIS/yjOIbNn3Cl/aUYkBqvAzkY6nRg6k7h89fzib0wYOQRCfOMk3VgWJGl2iNpF/QeGTuwKnszy+k1InXb3rmz9/RXyGl187+cFQrNAgcIYL7hLmGyKpueLNoqNopZjtXlZQElStUzxUk1BNLF9WyWInre40Tyu+M8rCKkyXrpUrGvLBmzJg0bBKU261PCld85w781Fd0cB6c3iJEwZjG+vis38bRN6WqOh+98VJ3XsLg== 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=kgm7SYWvSne0CYCzpWhnAq8+2UVMQSeTOmWLgZO5dbI=; b=WayHzUTria175065zk8fVaqV0CQGeZcbu4LNpKDyqY0ptZNAk8JcjBLm/nIdM5d1XzHfC/JmWY182chzJXhEMeByPNU+nXQA5ymuOJb+S42vzCb4FtYntsI2Uu2zPLAqdcWRjb9gcggu0fUeZfLuBVENW0Es2r5OqsLGM3E3s60= Received: from SA9PR13CA0070.namprd13.prod.outlook.com (2603:10b6:806:23::15) by SJ0PR12MB6782.namprd12.prod.outlook.com (2603:10b6:a03:44d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20; Fri, 25 Oct 2024 17:41:45 +0000 Received: from SA2PEPF00003AE6.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::a0) by SA9PR13CA0070.outlook.office365.com (2603:10b6:806:23::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.8 via Frontend Transport; Fri, 25 Oct 2024 17:41:45 +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 SA2PEPF00003AE6.mail.protection.outlook.com (10.167.248.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 17:41:45 +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; Fri, 25 Oct 2024 12:41:43 -0500 From: Yunxiang Li To: , , , CC: , Yunxiang Li Subject: [PATCH v6 1/5] drm/amdgpu: remove unused function parameter Date: Fri, 25 Oct 2024 13:41:09 -0400 Message-ID: <20241025174113.554-2-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025174113.554-1-Yunxiang.Li@amd.com> References: <20241025174113.554-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: SA2PEPF00003AE6:EE_|SJ0PR12MB6782:EE_ X-MS-Office365-Filtering-Correlation-Id: 4cc00c76-2123-46c3-bf5c-08dcf51c4b79 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?TnSajhlQ3GBQt1xFwt3R3myOU1O48Fg?= =?utf-8?q?LW4ilQdDGvQAJfOwboubkJcAPA7R4x95g8iafc1SqMOguvGBWXAJuQThGqMbViAa4?= =?utf-8?q?Grsi+BdN+Si+XS5ZFPo4+M7ZDvKz9R4cUpI7UIEXma3qOE55HIy/C3MuPGsACS19U?= =?utf-8?q?lvaH2zf6hJsFcSAufBRTFKu1U2e9v/o7dAzHpD/W/HqKGI4D2HBWBIL5H6IVaDYrD?= =?utf-8?q?E+6QIwV2DgpIgEQ+uGbuZ2GP2Jft0e9Cehl2OOgwcQmMqSJKoCNbS+5c6OOITQXm9?= =?utf-8?q?kd+HJgS0Mmkhec+g/Qw2dBM2b2rszpERTUOylISv4QLp7ehfK+fEc5NkNZ/MPuPEd?= =?utf-8?q?pCKIyfaHLtDlOFh23MC0SFaKGpl4I488HIdyOVjw2DvWcHiemLftABt8nXsY+GAqm?= =?utf-8?q?75Ui2q6+/O8OU+lQfI2cqeHn4BKMZsEZsyH1LC+6QK0qw+o3r8qBmEffC1tI/A/AV?= =?utf-8?q?qgx7o+mhYKH8SJ1BPKmAdOmN9f6ZBZXTcTx9oRpuPV+0OMfaBCLyrzezKncFYQbHF?= =?utf-8?q?druDYkCf9UEYNEyts7VhHl/JJdVQ/kLDfNALj81MrPZFE1paUjJWpj9iJXi4FKdBR?= =?utf-8?q?5zjIgL/cvo1xRgQieXYed/Q24LXNcNB3vJPVvaFAklvBWmMW3E9cXF+aCC96NGtu7?= =?utf-8?q?Q1NyLMxdsJ6QIPgGoXy3sKEAvuWd4LPHP07A7qSCMvykHbhqsm8TmkBQRxos9dCUa?= =?utf-8?q?rNZBNO8maqDmgHRTrTVXrCms1yIkZLYtk4DDXtYtqqZWdSOrrccJBWeHN+QC6k2HE?= =?utf-8?q?lZbCzyK8a5RTxr1n7OHSvs1lDaDDP+IgCJZAz0+20LuFbdza+e1k8RRh0sPzt0iwQ?= =?utf-8?q?C+gyXwrLbSQe/OKmsblMmK+D30CD6F/LoaxOPQCcCI+62+cuhofwpyQSUDqQQLRf3?= =?utf-8?q?Ud0e1c7zgJ719Xq1n1AlN2LTke2W3+felCrq0TMMEmv1jt7Gk34OWghTqRTV+b7fL?= =?utf-8?q?a59c+My4F9By5vfGdwCva7lXoPSlTree1UwyHOCXi1pCZ89o7jSR0iWc6EyphZlPb?= =?utf-8?q?Ud7Y78ZMISYg+c38QiiHazuKECSefCo7UypX0X3qrnAUXgBGHk6O/Xt8+GkmIvd7B?= =?utf-8?q?c1MhnrRJz3lDBCbaVZ6QvBg6q/In2W2dv8XZOVslxYQ7L30zFJy3HhdpiLrLaZ9MN?= =?utf-8?q?MAjsZIVI/n/JeEbFxBerUfkoLqzxKfcdAYc0+zTV5KON6PaR5D8g5eCJvxvyjIHIB?= =?utf-8?q?9ekInCM1yCWyX3V9hqGm4akuxTbclPBkQ6YQ2yx2K6EvZlfHEDvgAV9U/yhwQgGbm?= =?utf-8?q?i4ziIy9lUeooY3m91ZqXKWpYIydjbKs5gqoqpWWogxbeibqFTAN3GRaPti8WLZqt+?= =?utf-8?q?B2McC9K/Hd+KmVkPYaFnCIkQeJu4eLn54A=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)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 17:41:45.3146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4cc00c76-2123-46c3-bf5c-08dcf51c4b79 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: SA2PEPF00003AE6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6782 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" amdgpu_vm_bo_invalidate doesn't use the adev parameter and not all callers have a reference to adev handy, so remove it for cleanliness. Signed-off-by: Yunxiang Li Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 +-- 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index d891ab779ca7f..471f3dc81e8db 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -1105,7 +1105,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p) * We can't use gang submit on with reserved VMIDs when the VM changes * can't be invalidated by more than one engine at the same time. */ - if (p->gang_size > 1 && !p->adev->vm_manager.concurrent_flush) { + if (p->gang_size > 1 && !adev->vm_manager.concurrent_flush) { for (i = 0; i < p->gang_size; ++i) { struct drm_sched_entity *entity = p->entities[i]; struct drm_gpu_scheduler *sched = entity->rq->sched; @@ -1189,7 +1189,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p) if (!bo) continue; - amdgpu_vm_bo_invalidate(adev, bo, false); + amdgpu_vm_bo_invalidate(bo, false); } } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c index 8e81a83d37d84..b144404902255 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c @@ -345,7 +345,7 @@ amdgpu_dma_buf_move_notify(struct dma_buf_attachment *attach) /* FIXME: This should be after the "if", but needs a fix to make sure * DMABuf imports are initialized in the right VM list. */ - amdgpu_vm_bo_invalidate(adev, bo, false); + amdgpu_vm_bo_invalidate(bo, false); if (!bo->tbo.resource || bo->tbo.resource->mem_type == TTM_PL_SYSTEM) return; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 1a5df8b946616..bc1ad6cdf0364 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -839,7 +839,6 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) { - struct amdgpu_device *adev = drm_to_adev(dev); struct drm_amdgpu_gem_op *args = data; struct drm_gem_object *gobj; struct amdgpu_vm_bo_base *base; @@ -899,7 +898,7 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, robj->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT; if (robj->flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) - amdgpu_vm_bo_invalidate(adev, robj, true); + amdgpu_vm_bo_invalidate(robj, true); amdgpu_bo_unreserve(robj); break; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 1e6a044e3143b..045222b6bd049 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -1148,7 +1148,6 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, bool evict, struct ttm_resource *new_mem) { - struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); struct ttm_resource *old_mem = bo->resource; struct amdgpu_bo *abo; @@ -1156,7 +1155,7 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, return; abo = ttm_to_amdgpu_bo(bo); - amdgpu_vm_bo_invalidate(adev, abo, evict); + amdgpu_vm_bo_invalidate(abo, evict); amdgpu_bo_kunmap(abo); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 9d6ffe38b48ad..9fab64edd0530 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -2139,14 +2139,12 @@ bool amdgpu_vm_evictable(struct amdgpu_bo *bo) /** * amdgpu_vm_bo_invalidate - mark the bo as invalid * - * @adev: amdgpu_device pointer * @bo: amdgpu buffer object * @evicted: is the BO evicted * * Mark @bo as invalid. */ -void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev, - struct amdgpu_bo *bo, bool evicted) +void amdgpu_vm_bo_invalidate(struct amdgpu_bo *bo, bool evicted) { struct amdgpu_vm_bo_base *bo_base; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index c5b41e3ed14f2..428f7379bd759 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h @@ -515,8 +515,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va, bool clear); bool amdgpu_vm_evictable(struct amdgpu_bo *bo); -void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev, - struct amdgpu_bo *bo, bool evicted); +void amdgpu_vm_bo_invalidate(struct amdgpu_bo *bo, bool evicted); uint64_t amdgpu_vm_map_gart(const dma_addr_t *pages_addr, uint64_t addr); struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm, struct amdgpu_bo *bo); From patchwork Fri Oct 25 17:41:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13851243 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 AE0C3D149DA for ; Fri, 25 Oct 2024 17:41:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 838E510EB23; Fri, 25 Oct 2024 17:41:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="3RroGwoo"; dkim-atps=neutral Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2070.outbound.protection.outlook.com [40.107.92.70]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3C01D10EB23; Fri, 25 Oct 2024 17:41:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p715fKSpjc/ec8DvQHD+O12eZfyrnef9YllVoH3cZy3Yop/nbL0OmyXBRgBDcsiRgL+um0Qy6kXNlUnxdlQpyEa3OBLgLcamypLrcVkf1LmXHKbjunuRu/WQE/zeFunlvO9q4EUbW+7GAIwYxRMQzo9UMir0Yk2objmfRdSP7gQRGO3dkX+LuCy5SR/x3afHVcLYmhB+J17U/drSD/7HvESnhQMGp2w14r/+br2X1yeYKUdBjm/w+WrdNqpdpcWHiBFOmY8nfnFVn13lkOsp+U57ZQCiu2B/yd+E6oKsfmNGdjGwKmPIHWND7y4tfeecNDgSmc5R3g/2SdNWQY2Vmg== 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=BeiJOZFwwP4FJILpSKu9b1qILvtjAOavn2Gdc6tL9B8=; b=HWG4fcsVAQ8NFP5/VxwPdhcLXpp7r/q9Ez/IRG/UMYJrgbLKBrhvgH81DklmQlM5XsHDI9Zo9Gdy+cLzqwKQeeLsDF826jiliwYBRzQaak4lEfiI9FlYjnOMVq0IGbreE/nOuJBJoJPxA+nnxTkidjg31iVqe2zrEfAuxt5TxApAAvrhvRJ7eEyHcLHvb+UbqVs7OE/jXSiVvXyeU+Lk9atEVBNSJtpY3qUwPjRFSB+EUjyWL/twOlFgvM7Do7mfhZYtWUu88dG97C9OxrnFXCSNHulCIzhFwPP9YsB0K1/biq7bcOh6/Y01jJhva6INe2RumtyMMRjGzDvfGbblkg== 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=BeiJOZFwwP4FJILpSKu9b1qILvtjAOavn2Gdc6tL9B8=; b=3RroGwooDG1RhR9LZlZnqhYi/Zw2yzo0AUO/8rSIRj/NGm28TbIRY+p+Ttl4MEEyJTg9vKW8pXoF9iY+gsrhf/MGV9rl3wHef1RSWwMXIXuBMpI5W2sxow7yjBw703KgC5faZRFXBOW6H3vQyNnzOQv9M9S46BVMaQDWeO4UVC8= Received: from SA9PR13CA0072.namprd13.prod.outlook.com (2603:10b6:806:23::17) by CH2PR12MB4104.namprd12.prod.outlook.com (2603:10b6:610:a4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Fri, 25 Oct 2024 17:41:46 +0000 Received: from SA2PEPF00003AE6.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::ae) by SA9PR13CA0072.outlook.office365.com (2603:10b6:806:23::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.7 via Frontend Transport; Fri, 25 Oct 2024 17:41:46 +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 SA2PEPF00003AE6.mail.protection.outlook.com (10.167.248.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 17:41:46 +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; Fri, 25 Oct 2024 12:41:44 -0500 From: Yunxiang Li To: , , , CC: , Yunxiang Li Subject: [PATCH v6 2/5] drm/amdgpu: make drm-memory-* report resident memory Date: Fri, 25 Oct 2024 13:41:10 -0400 Message-ID: <20241025174113.554-3-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025174113.554-1-Yunxiang.Li@amd.com> References: <20241025174113.554-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: SA2PEPF00003AE6:EE_|CH2PR12MB4104:EE_ X-MS-Office365-Filtering-Correlation-Id: 35edf74d-d83d-45a3-6b7a-08dcf51c4be7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?lOd5YKV/qA/sS5zyA30w22jiI9n+en8?= =?utf-8?q?gVbM6Mk20ek/qxHTnMVNX9+1rxG/jDeF5FWYE8QK5zRHDjC9HWA+INKToRD7ICW2M?= =?utf-8?q?SkGX+M+rPFC1MfAkfzVt1/MJR3lu8iHysTHBOny4BjE5zs9oXPLWfj/seTjY7S4Gq?= =?utf-8?q?6SCpsovu6k6DHNk7UGFBIo+muD/iUCceKr0NiHGgeVBTzj3Jtih7XhXogvRsLAYCF?= =?utf-8?q?SS6EVarD2ZdhW0t1506vgaHFh9u9ExrApiSPblFTwVtluFSJFD06Ei3ri3+TKdH8T?= =?utf-8?q?i/LxiW99a10E9sX796CzzHn1tWGPFtIPkIfGVpH9Ybzq8m9pA6Mh9L17rPCqOCqIK?= =?utf-8?q?ZOU9mOdZs2VmrFRHb0OaVZU0bJNn4x8j8OI9AyPXWAAqdQkFd1NvOQN4ObCZKfUYZ?= =?utf-8?q?nCLBRtdxkNC0nKca62dzHH0y/Jn03Rlebp4fh29BYkpasbT+3bE2sPEQ3E2rBrSrO?= =?utf-8?q?QMCKxIhgOhytmlrP98dUis+XE32UoZUOIoQDdTaCrMsESA93s1nOcN6trr0oQDPX2?= =?utf-8?q?HqzjznUgYEAZbxjJjPHm2taFdM0DTELAVCVarGqhbM5gVLEs1j9qxVOlLCXxFtNKc?= =?utf-8?q?KGKYwI/Ikc8FwEKQciM+rdZoPWWX8oMPJirquI7Q5cMOX28iglHc3VggHJ1iPz2M9?= =?utf-8?q?6czZ0gWse/0vA+oqVm/Rd4+1s6M4agTRYjS/LzXt0YZqNpQ2XIACSUKylRSqDcKuU?= =?utf-8?q?UqjACMOzMiZwUuDGnJDzY2x+mtif+ft2Dm3DN2WkPfe9SSwX83g2roEspUouq3s+q?= =?utf-8?q?ynCoIqrt3kZ2TEtwJQsB38tr3YIT8TPbQ2t39u5I8buE0tT7BLf7+qAhpnV2wvMKu?= =?utf-8?q?Yq26s1sOtcZIXMkEzlgQ452RJS+cdMLb+JQ7VjXkramnndAmoIB9O/z1Cf5jA1OOZ?= =?utf-8?q?kshUpC8nAOWA+kyNSQIDnkSIfEJBGyB6vGn4W20CHGD00Xj1ZXaoGU0tVqv5gUH7f?= =?utf-8?q?Ell2TCjbApe/sdOhTVnm/Q3MNY/qpowqpuvN4OCct+7Xiv6wSuPeaN6EY6WIEJ+PA?= =?utf-8?q?K0H50KzqrgWPs40BlVlNhC/Myh1PJAK3I7UfON3Iahj1Xu2rX62WToMSBTuVBqoWy?= =?utf-8?q?QFhz/xiJTVgqmOIyeDbAGcDGTrNXh/Or2qRbI/dIc++udmhmcjC0Sd5K28NnUuew7?= =?utf-8?q?C7zRtbcBTFFlu53EBwkb4n5uIfvHILgxIQqCm9dKclyIA5hPnK02Jeu6fUbkXc4B1?= =?utf-8?q?9sJuBGOaVOYf83kftzvlFd697k3xEf1LxlEO9yvQh18nWoceaKom0PIAmatxreXS3?= =?utf-8?q?ZKmbXNa7dSuRZKJYGlFes6eljvwV5lsm8GQCUKL2NdSAAW4fUiEliDU6rJS3Rm2+b?= =?utf-8?q?hSJgFj6sVooDki0bpDKVER0k2cQeu6sluw=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)(36860700013)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 17:41:46.0333 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35edf74d-d83d-45a3-6b7a-08dcf51c4be7 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: SA2PEPF00003AE6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4104 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" The old behavior reports the resident memory usage for this key and the documentation say so as well. However this was accidentally changed to include buffers that was evicted. Fixes: a2529f67e2ed ("drm/amdgpu: Use drm_print_memory_stats helper from fdinfo") Signed-off-by: Yunxiang Li Reviewed-by: Tvrtko Ursulin Acked-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 7 ++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c index 00a4ab082459f..8281dd45faaa0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "amdgpu.h" #include "amdgpu_vm.h" @@ -95,11 +96,11 @@ void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file) /* Legacy amdgpu keys, alias to drm-resident-memory-: */ drm_printf(p, "drm-memory-vram:\t%llu KiB\n", - stats[TTM_PL_VRAM].total/1024UL); + stats[TTM_PL_VRAM].drm.resident/1024UL); drm_printf(p, "drm-memory-gtt: \t%llu KiB\n", - stats[TTM_PL_TT].total/1024UL); + stats[TTM_PL_TT].drm.resident/1024UL); drm_printf(p, "drm-memory-cpu: \t%llu KiB\n", - stats[TTM_PL_SYSTEM].total/1024UL); + stats[TTM_PL_SYSTEM].drm.resident/1024UL); /* Amdgpu specific memory accounting keys: */ drm_printf(p, "amd-memory-visible-vram:\t%llu KiB\n", diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 045222b6bd049..2a53e72f3964f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -1223,7 +1223,6 @@ void amdgpu_bo_get_memory(struct amdgpu_bo *bo, /* DRM stats common fields: */ - stats[type].total += size; if (drm_gem_object_is_shared_for_memory_stats(obj)) stats[type].drm.shared += size; else diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index 7260349917ef0..a5653f474f85c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -142,7 +142,6 @@ struct amdgpu_bo_vm { struct amdgpu_mem_stats { struct drm_memory_stats drm; - uint64_t total; uint64_t visible; uint64_t evicted; uint64_t evicted_visible; From patchwork Fri Oct 25 17:41:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13851244 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 F3E92D149D9 for ; Fri, 25 Oct 2024 17:41:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 57A7A10EB54; Fri, 25 Oct 2024 17:41:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="O7AaimC4"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2054.outbound.protection.outlook.com [40.107.220.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2022810EB23; Fri, 25 Oct 2024 17:41:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZDfIeO+34A9an+jN5VvbyShlfFg1nzOS37WSmcgqragXzNuXHnkKj9BdmtHpmUrjmNCCOSWi4B24taBJ+ADJ3BjSmoQS2bNgNzm+2LVOqlomYhh7CBdCq0am0EBTBxSFl2iOmftS26ACphRAhKpXXNYdvCJb7zBmpl+F7NutsoQ+HefuCgnuog0N1zmLfM55Gp2Z4Hma1MXx3GaejPb+AyVmSqZLnEPOn0CQHXm9kSApmAqjl+VfUUht+DIBDT88CmnhnsCkayxMNHNmYENL5EE1W/b7j9FJqNtwUg20BlyPkeXFfNQKDXK+8mEhF0QDiSKdVWZDNbfw5J2gBmFfzw== 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=/gKl9nP6ACrxTQ4vYZkwmjQG1BpaKQ7tKT6RQDOa/PQ=; b=QZVdG/L+kXjF3Q7IG82CO7DjE54JrE3LXmHcNBC7KCRCVRH4nqRpTP6/NS9Wm/1+FbcJJqVuDygfh7JSjmSHGNrk+aim8CUE/IHOACYTJ4D+0hRlgghxCH7/BIN5yVXKBqYikmuoyiiZxNYSXIFD9IyM1ZkAXJdE2BRzZ/KQPYhaV4JxRbxJP9wZ0+epvI8Mxx1lWuQ7vDgOHEcGoT1fTvJKdN4tTw+YntVy24jfOU4mNwSVhupODayFXrpuix7ULooMTqh+FTb/+PtkNJYhCq1gAX094gLYnUHNoVZxXupFmu3+ZaRNO6E/lTOXe2yMT74fKm6ND8u5mcrHe4u5TQ== 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=/gKl9nP6ACrxTQ4vYZkwmjQG1BpaKQ7tKT6RQDOa/PQ=; b=O7AaimC4KaQGAQ9CkSJElVdSLJRaxS4k8SSS52Vps9YpUnyy+eXa3kvFEj6nO7B/M5vdXn3K3FFyFax38Gg+Hy7q9daoGgUw7gtjh4kMGx9oIrdZgUEvGzp+AoK/OJEpQLlJbFPUYLKkaTok7LAzYKKVBFIF/vrv+A6BR/oPGlU= Received: from SA9PR13CA0075.namprd13.prod.outlook.com (2603:10b6:806:23::20) by CH3PR12MB7620.namprd12.prod.outlook.com (2603:10b6:610:150::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21; Fri, 25 Oct 2024 17:41:47 +0000 Received: from SA2PEPF00003AE6.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::fc) by SA9PR13CA0075.outlook.office365.com (2603:10b6:806:23::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Fri, 25 Oct 2024 17:41:46 +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 SA2PEPF00003AE6.mail.protection.outlook.com (10.167.248.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 17:41:46 +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; Fri, 25 Oct 2024 12:41:45 -0500 From: Yunxiang Li To: , , , CC: , Yunxiang Li Subject: [PATCH v6 3/5] drm/amdgpu: stop tracking visible memory stats Date: Fri, 25 Oct 2024 13:41:11 -0400 Message-ID: <20241025174113.554-4-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025174113.554-1-Yunxiang.Li@amd.com> References: <20241025174113.554-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: SA2PEPF00003AE6:EE_|CH3PR12MB7620:EE_ X-MS-Office365-Filtering-Correlation-Id: 435ab7b0-ad1d-4438-ddcf-08dcf51c4c3a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?CGr9lJ1dcvWXT+by27yWeuqt0vAb1Nl?= =?utf-8?q?1MGU6Y15d7UI+mgUoFvjbvMz79JR8z5YBVYVY205xBlydXT18UeIwJpK6Ya3RTbFA?= =?utf-8?q?deBvnLe5JmvgT0HWmExSTHpoiGNWp6pX1L0A0/l/j+3tGr3EDTmtQ7DbmvhaRgLsG?= =?utf-8?q?KUz4BOFwIWhEHUpk2PP/UpzMzrcJQNQ9LsCkkMIXmDmzvfKhF2nNqhrrQNTeUV1Rg?= =?utf-8?q?/GJ+OVwvYTmHeAwYE+3C96I/qHm0byEkJNSana8XWfBhMj91esp4WIJ2fE6dEVE04?= =?utf-8?q?xJjCe14pX5oN2NltrTSRyvrpmZAqvGKiE/b+kJP16PeO3GPXv6vpGCrxmeUSOLiu9?= =?utf-8?q?L8p2h6H41sok+yR1lkw1WzY3bPirlW9ghlu1tOrbwu9x+iDLlwBe4OniXrLN+mfah?= =?utf-8?q?4w+EB7nEbv/ADDGiy+HG9zP5Sm6PfPwytEqmBiB/Wtd9irOeVvzWVgPHmFC4xHcH3?= =?utf-8?q?6bzIYOKOT/lqsU2grJ+7Vm5ZCYgao+GsILpVX8wKScBoeSm5Xr2+RO8IlThZ7h+7h?= =?utf-8?q?o5cc9VAlXbTlS95GIemwxwyRYRr0hIpq9GOTDzPvT6oCn14XhEDXg+CgoH6JnWedd?= =?utf-8?q?QXHb0CzZzey8FFs9ooCao2tsKGxa05uZ9Cgp9B5BNphhJO0qIQJZw5MDD0Hu5yteW?= =?utf-8?q?e2XIJ6GrPE6xkJqsR3EZmHqE8gEbmgWDobFs1wD3wEmq+NBu6TrZMLcuxczepP7zC?= =?utf-8?q?IEVZ6SyFHF+hpAFTM42jeIjf8LnOdGKwF0E/dDDZqK0oZGLX8B6tHnZ68ODhQVabJ?= =?utf-8?q?F1vv3oe67n1xbqmIBKAgWIMTZCatDghM9/IbktiJlXrWvXUVF/r5XTzdm6iWddwyv?= =?utf-8?q?nZuyehyFeMZGznuXVFpga/avWXvlxK5viNekOo1wENjV/umDLL/mePDBhTYHlCgrJ?= =?utf-8?q?GN5aaSlsz6A76G8S54olCRMgtLScu35dFFk8iIHKPcDsxtYnHuJRfQNCVn8DlIA1V?= =?utf-8?q?LNp1nGr571qycAiwni0J8EIWXU0s9XqVD4KZKY4j5WtMbTvJFYFbm9oiBBo1TC8Oq?= =?utf-8?q?fsWxctENaKB5sPgzlaszsJBb72zz19k4NiLaLvCghQUF3uRMJv8ypJcevrqsx3Kwq?= =?utf-8?q?JF13Tk6W1u5w0mmZ2WoOL19AMNxF5edEZMeZ+d6WyvhGG8almWjn/VJjcLkcR+5xH?= =?utf-8?q?wdp9AWY3cBWXUop3EtIJKGY5IpY5vUovrVNCfuhDGZCgYcX1DRDUZoUgS1t7Yjp9N?= =?utf-8?q?O16BgOXm86djB7B1CEFQWK8SWMcjqsC47HQiFQsHfqHYVTj//wYqYDs867NT8sDqj?= =?utf-8?q?yMNhm0fINvk8xXx2FJ/LE7kVZCsFSKgVQq2C2i9O4ScIlDX7I+piMThQaOS10NLim?= =?utf-8?q?K8Y/ueBWiv7Qe2W7mZjHXHeFNPHivZcpeg=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)(82310400026)(1800799024)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 17:41:46.5802 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 435ab7b0-ad1d-4438-ddcf-08dcf51c4c3a 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: SA2PEPF00003AE6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7620 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" Since on modern systems all of vram can be made visible anyways, to simplify the new implementation, drops tracking how much memory is visible for now. If this is really needed we can add it back on top of the new implementation. Signed-off-by: Yunxiang Li Reviewed-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 6 ------ drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 ++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 10 ---------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 11 ++++++++++- 4 files changed, 12 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c index 8281dd45faaa0..7a9573958d87c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c @@ -103,16 +103,10 @@ void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file) stats[TTM_PL_SYSTEM].drm.resident/1024UL); /* Amdgpu specific memory accounting keys: */ - drm_printf(p, "amd-memory-visible-vram:\t%llu KiB\n", - stats[TTM_PL_VRAM].visible/1024UL); drm_printf(p, "amd-evicted-vram:\t%llu KiB\n", stats[TTM_PL_VRAM].evicted/1024UL); - drm_printf(p, "amd-evicted-visible-vram:\t%llu KiB\n", - stats[TTM_PL_VRAM].evicted_visible/1024UL); drm_printf(p, "amd-requested-vram:\t%llu KiB\n", stats[TTM_PL_VRAM].requested/1024UL); - drm_printf(p, "amd-requested-visible-vram:\t%llu KiB\n", - stats[TTM_PL_VRAM].requested_visible/1024UL); drm_printf(p, "amd-requested-gtt:\t%llu KiB\n", stats[TTM_PL_TT].requested/1024UL); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 2a53e72f3964f..2436b7c9ad12b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -40,6 +40,7 @@ #include "amdgpu_trace.h" #include "amdgpu_amdkfd.h" #include "amdgpu_vram_mgr.h" +#include "amdgpu_vm.h" /** * DOC: amdgpu_object @@ -1235,23 +1236,14 @@ void amdgpu_bo_get_memory(struct amdgpu_bo *bo, stats[type].drm.active += size; else if (bo->flags & AMDGPU_GEM_CREATE_DISCARDABLE) stats[type].drm.purgeable += size; - - if (type == TTM_PL_VRAM && amdgpu_res_cpu_visible(adev, res)) - stats[type].visible += size; } /* amdgpu specific stats: */ if (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) { stats[TTM_PL_VRAM].requested += size; - if (bo->flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) - stats[TTM_PL_VRAM].requested_visible += size; - - if (type != TTM_PL_VRAM) { + if (type != TTM_PL_VRAM) stats[TTM_PL_VRAM].evicted += size; - if (bo->flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) - stats[TTM_PL_VRAM].evicted_visible += size; - } } else if (bo->preferred_domains & AMDGPU_GEM_DOMAIN_GTT) { stats[TTM_PL_TT].requested += size; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index a5653f474f85c..be6769852ece4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -139,16 +139,6 @@ struct amdgpu_bo_vm { struct amdgpu_vm_bo_base entries[]; }; -struct amdgpu_mem_stats { - struct drm_memory_stats drm; - - uint64_t visible; - uint64_t evicted; - uint64_t evicted_visible; - uint64_t requested; - uint64_t requested_visible; -}; - static inline struct amdgpu_bo *ttm_to_amdgpu_bo(struct ttm_buffer_object *tbo) { return container_of(tbo, struct amdgpu_bo, tbo); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index 428f7379bd759..6a1b344e15e1b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h @@ -42,7 +42,6 @@ struct amdgpu_bo_va; struct amdgpu_job; struct amdgpu_bo_list_entry; struct amdgpu_bo_vm; -struct amdgpu_mem_stats; /* * GPUVM handling @@ -322,6 +321,16 @@ struct amdgpu_vm_fault_info { unsigned int vmhub; }; +struct amdgpu_mem_stats { + struct drm_memory_stats drm; + + /* buffers that requested this placement */ + uint64_t requested; + /* buffers that requested this placement + * but are currently evicted */ + uint64_t evicted; +}; + struct amdgpu_vm { /* tree of virtual addresses mapped */ struct rb_root_cached va; From patchwork Fri Oct 25 17:41:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13851247 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 32382D149D9 for ; Fri, 25 Oct 2024 17:42:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6452E10EB57; Fri, 25 Oct 2024 17:42:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Is+dlTa3"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2072.outbound.protection.outlook.com [40.107.236.72]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6427E10EB56; Fri, 25 Oct 2024 17:41:51 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zNuf1RrsWj0TrvCskwKa9dU6dLrrWge7lxvf6x543q7ptknMQ8g+mW1b1VHtHx8Qgcbg0Pvv2oX7dNA9rz9oB0DsNuS2suqYCY4one149gfPURGhSttrRKeLGK3he6sawa2Afiv7BtDUDCQentShH1ZG0OyXSzgZlUzbEAVGa55Kuy69U3vYNSdS6s9S5YQYZNbKtxuPGSzZ9fws+t72TBpkn3gGE3naSdVB9kAuDx+3t4Mn1kU/q4wPbkEWWzirYps5gqwJ0hqt85JKvMXGhCNTOcGwM4SHm91m08aBOXH3KP5hLoOj5s2YmrgufR3UVsnOmHrsELec4dlmlZe9oA== 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=5V31yZqs6mUZSS/Bgqj965Klzs50w3i1AcjYXBXaQSc=; b=eEGFqMsEBfliu9AUb/SLXG6weAxrZTR3bOAllYJa3PDzgZfV4mrbCErvkBawNy5pHirfTyESwlUKi6pk5yReJSlwas922mwXiwM9sfBkiCfH/NZtpJY8kRdswTaV1VFA12I5511la1961eRMWoyo0EXL41A+BkOiBnhTjpBIP1s/uXL+/7bZOX3/hgR60hVNqmx0Trph8tgb+KJdksn5n/TuqelYFitCDl2rUD+jzAOFLbzRooSm3foRTzkRXNMvtmEuucrMXWuTizQUIERie4n53Cfl8ZPORGPol5DnCVsr9ICSuA7scHwVFYfXqBPe6a2KEqaZx0Mc94tnIiO0zA== 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=5V31yZqs6mUZSS/Bgqj965Klzs50w3i1AcjYXBXaQSc=; b=Is+dlTa3OPsEiqrYvwQNf/sqI0mEEHPb/OCe6ZTHrJk7w3sooRLM4lTCD4WPDUCbLKPLwcCDwEqKmzHOzsklm+c/HUuf1JaV821F0HQuoX7VhnM6NRGQifg4v3cM2Cb5CHLw0jiZacw4AUW63ogAU2GQKrPv1BBRR3IjM9eCDL0= Received: from SA9PR13CA0080.namprd13.prod.outlook.com (2603:10b6:806:23::25) by DM4PR12MB6064.namprd12.prod.outlook.com (2603:10b6:8:af::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Fri, 25 Oct 2024 17:41:47 +0000 Received: from SA2PEPF00003AE6.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::24) by SA9PR13CA0080.outlook.office365.com (2603:10b6:806:23::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.7 via Frontend Transport; Fri, 25 Oct 2024 17:41:47 +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 SA2PEPF00003AE6.mail.protection.outlook.com (10.167.248.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 17:41:47 +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; Fri, 25 Oct 2024 12:41:46 -0500 From: Yunxiang Li To: , , , CC: , Yunxiang Li Subject: [PATCH v6 4/5] drm: add drm_memory_stats_is_zero Date: Fri, 25 Oct 2024 13:41:12 -0400 Message-ID: <20241025174113.554-5-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025174113.554-1-Yunxiang.Li@amd.com> References: <20241025174113.554-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: SA2PEPF00003AE6:EE_|DM4PR12MB6064:EE_ X-MS-Office365-Filtering-Correlation-Id: 0dc45406-a8d2-42e2-75c1-08dcf51c4cb4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: XzpX5zlt7qpc5fX1j3KuIijS9ODDeLi9KHfDsYR+W/X2TyyXj2zQqGkciAq96dDmAmWIw6YK3IjCDLRmxTNOhThv/weYuMtMInIkFZohx3OSibKAK9kHr8cHzDDT2oduNykVEaElq+fd5LIxO4PbzdEc+4c2cOTjdKdClNs5fwRsUvlX10tPBXdJMs1Q9T7EB/UBckAbcX5sFQzmf85GSRNsUaI9+jEdFz/dfN5ft2VhMFKxC8FwSfw4PBT30JLbvC7srAEW1EKCppTQlcefrydtCBF+FVhWuW7KF9ZMYScpaVtmnP8rDRodaV+GIu6vvQ/0STQxGw/8/O5mTxHZxjRcYFNodbw7sDyR/5wkO5BB+8ufWHnIY2aiZMnKSThoOKBGyG3pOIvyqo1z7RTIkaskACI7goFO9ncuSfCTafqiX1AsHd1/1GuDcFIEQ2mY6mKUwCkClh7Esq5YRyNl9DEGCBanjFCIaRkvk/ZoVAwcurf1iKEx+p7UHb2F3+cqCulbyt+ipVeYXf5ctMipEWa70x+/0c2BLApXBGLbLiipEGTUclw9f3x3Uid9OMuaeQiJ5EesAZctjk9s4Lne4M33wNUKWHGXZkRPsfhXX/Y1GU+zgq1djgpMGGOzdlWGyfmkVAuJ8icrU5kivKeoybhMhtmMM3Qu66/mJ4a7kzz1ejFzzxVwlNLLrSOzXMPmmCvTR3F6KhPribG+dzakyLd2xNCaN0P4Winz+EZI6kiTutUsiAOlI6DvEAyo0H1yAMXupS+FMiWUR+xVuRwc0KWXB3h9Co6bSE5zCP5GtUaAUC8pvqlbmnfse1DdxITC3brBlXnzMzyl7JEH4U73OVyyk4hzl25yx9FDN3SqtEy/VE9r+DeiSDnr2hm7xzTKuA3zCES32IJh0qR8MZcPbFZZYYAgoKtQv8bxXqod4Fxa6HasmQZBf/CvQmg9ysfX86Cwy7htupBo2vPl/U2hIDtQmZkzzYSEfmdvTbRC1WVyducs+TbdUB58wB5jEJuyqsXUMR8p63XSO7Uz/RdDdrzfS9fgQYkJuhjSsPHvoBaemQO7fPWd3ISU3uOEXt5x1vFsId/oopp7fkkQrP1eVMsikFAZp8YvTAOauIt1r446BHuMmSlY4z1OHgkNe3KmA6Kp1GyewXbFqB/OJH5iKDhxNurVFob45ZZ8ElEIpqgbTIXfB7AIbGBJHyhQYlzQuOq9z2dwun3HutFMKSHrVAUzHoyC2MbECdNhMGc2Bw8S1yhebxNBOSd2D/qdSoapKYCNXl5MxGxghdtLCcCxdTDpc2/ZBA7OE5X+t5EDnJt/3hUcs0OPMIDRBeP67HwtDOldVtuO8tn4tTyRDhhjbic//ALEoYCqzbDMl5uO8E8tyktQ7BV5z4eSff0rmONGNjfrM9rPpjJDfewkUjbIaQ== 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)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 17:41:47.3771 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0dc45406-a8d2-42e2-75c1-08dcf51c4cb4 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: SA2PEPF00003AE6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6064 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 --- drivers/gpu/drm/drm_file.c | 9 +++++++++ include/drm/drm_file.h | 1 + 2 files changed, 10 insertions(+) diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 714e42b051080..75ed701d80f74 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -859,6 +859,15 @@ 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 Fri Oct 25 17:41:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13851248 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 CB832D149CD for ; Fri, 25 Oct 2024 17:42:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CB94510EB60; Fri, 25 Oct 2024 17:42:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="U4ljD2cw"; dkim-atps=neutral Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2063.outbound.protection.outlook.com [40.107.100.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id EBDD110EB5A; Fri, 25 Oct 2024 17:41:54 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VHVD1vu2jUY4un+75wzHh9ruFkByz/2FVwIyFmvexdsrtMZvbejx155uGy6KubFiS0SVlpZPiT7ZMqJCDFO+FhGTwQ4BkVo18Zlu8uWdX4TwoRDpK4/aAx3eibK9jhs/5LgneDhMGMNJVTx8J9RW6odLyQdI3tpSVAaemigf5PpcgdeDOHhA61P5WjnS/muvkqbyaeqYSyNRvQbu51FpQbj9qLcJBOKJs+hEdRZRFsYixptDJnl/QokaZAyCft0KCHVs/4V39VMWOc3aQ/gjK0dnhG8e2cM+vTozi6WkPfTOPlb6uYNcAE0iy+KJA9IPmxm9SMNGTChO1WaGQYPzag== 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=3zklkeAufDV7XkmMc3VNME2yDXUhFAasa4JZeFr8x7k=; b=tTIUDClkm24Np9lf413j2NQLDjDI95yMijBEuf1TDazNOrl3ZX6dgC2PbPbf+sHi6zzzo2T/DpACGnbN+HGSk+ou5m7ZtWtIj6PW+P6VkzK5LjzyLcl9sSvC3W6+GjrQ44scUkPjbdPumvUnUmsZOilKMfZ4UhXIHx3a4mdCHL7FH2lmE5zEAM2+Cw1Sr7KmKgOUOpedjYpDGDr/a0gB7tC1Qlqs+OiiGpZv/ICZ/DIJWtUwPQc32MT2Ee00On4qFkxrUnkAtLwwqtQ8YLX6se4CzeLYRj7HbuAfm/bgGIfKTHDqy2jUQ/8htFvenCC+Y1EM1NFbIY7zRLsbxgAEnQ== 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=3zklkeAufDV7XkmMc3VNME2yDXUhFAasa4JZeFr8x7k=; b=U4ljD2cwV1bayleXHn4VELopIeT4PvOJ9lbsUyHwFnpNYXVNqxtHnuRsvK2c6YcKwRKsNfvklsfChC6Ks/si4CBE5pxdBdshWlDPJJNZy/K8IUCVKpTSyLe/UybXHetcAI9XUqIezx6rh925Wv7nrXK9TJo3EqIQ7srsCycmOTQ= Received: from SA9PR13CA0079.namprd13.prod.outlook.com (2603:10b6:806:23::24) by MN0PR12MB6271.namprd12.prod.outlook.com (2603:10b6:208:3c1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20; Fri, 25 Oct 2024 17:41:48 +0000 Received: from SA2PEPF00003AE6.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::5b) by SA9PR13CA0079.outlook.office365.com (2603:10b6:806:23::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17 via Frontend Transport; Fri, 25 Oct 2024 17:41:48 +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 SA2PEPF00003AE6.mail.protection.outlook.com (10.167.248.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 17:41:48 +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; Fri, 25 Oct 2024 12:41:46 -0500 From: Yunxiang Li To: , , , CC: , Yunxiang Li Subject: [PATCH v6 5/5] drm/amdgpu: track bo memory stats at runtime Date: Fri, 25 Oct 2024 13:41:13 -0400 Message-ID: <20241025174113.554-6-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241025174113.554-1-Yunxiang.Li@amd.com> References: <20241025174113.554-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: SA2PEPF00003AE6:EE_|MN0PR12MB6271:EE_ X-MS-Office365-Filtering-Correlation-Id: c2a03554-88db-4b7a-e69a-08dcf51c4d26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: 1tzYDyq/5gLkVkdykaH4IvrrTaa26sss6Cw/lHaMcTj2u61ccCWZ5MxlwQIUaNWlIqNAwrBNrFczb1T8ZysRsfMwsFJfwW5pdpAwWsVyvScViwpbh0iJu/wMFkzcsHwt97In6y8miv50Xvdux9jEqecYFLclgnu4+SLDtkz3vZd15fMZ8v54HffnuHHCHWVvBRNsi9iWeTuLKjvNpP9jP0vu3zY2kPFEWtVvwDPdm5+oRPfXm9vtsJGRVSqguDLmaRkCjjlx7EEMpLP0OPt0lAUl7/d+t1yslJN1AUSiSnvTHvh8PLP2gvNmkvk7p0rYntZ24nVeFPZhfpZAdoSw/HjzmYoLZkuIQylIdgFNrCIdueciOrKdu/oFawA2ZnG6RjbsUB/zEbkrCOyIPecN3R5YTCKhnq3FMN33EPbuAIgwYnblPBd/EJtUQfQ9X25A9uYiROIbj7Wp21Y658HaiXlAxJbh2Q+obYrdCLwV43Mo8QJc0RTIAIzCMcxSkAaPg/eH9tTcRNUTsftoesGWY/Q4/Xh+XK5e5QbmxyeiTR4qBT++io5JCBK5Pvt6X4V9M5hCDfWNhXEBj5+JYhmYokEnKPJchKd1P3Hza3qmpbqN/AItyaS3VMQERoiTr78rPCifFEsoCEJQUPtrpkG57ijPNnoLJ4hqCEn3SQkpArcVi5qu1iIatpxjm/KzEOiFqyKGGo4XYLZIQi1mYcBW95OXu5hMMdUHo4T0pznvJFKrc+ceO9+/KEn3aDJ+7bFdVdCMPYG32EsO3FLXbnZM6aBWW4HGmEzXpK5LjtlueNoVjAEzHCL+J/4EtlsPTSKftRFZEb0W1bjmhAuZISXJ81vLJfQQbB0BOKX8KUDlv3iUDsu4lUmIfBjRvYp9sQ3zv6lO2Yyokg0xebYcIFP2EY1q0NUlZoOcCwzGZzRgD5uopZXnU7sNj1w4tH+jVFU+7wW4Fb5WdsY8mxwFM4oh7V1xXUZ0RDe/Huha6VV7ubhbViNb1HwILj9Z6UB29j/w5wFpQPCioLD6gnUKRUC42Rp4AKOb4jvYpHbGwbADmqjh55OxVEsooy4HqQyJKaTzEgcsJ5QlVnpz9Lx7r8VoL6vdsCWMmRXCz6Gr5Ot2gRO69T0XP4fi5d5PSgB4+Klyt2wb4hgM3iegiWC2iJYfA5rvIjW2o8wYIGTvmOE/CJcQ1ifuV8bGGXAvi3mEswSroRkPXChzDx6zYahLVcXTWZaQ9eJL0/Gjh4aO5r0bPAjcxBT26nJpIWipA0G0aiCkziqXusVo+AhVIfnaJMfOXX8V2SVVoigsvw/973WdhcKbiVNUtb+skdKHgbghkHmwmX7MQOjxFObm+r20frPQRbkv9qizeQm/BymfhwwY5pMmV45qpnVXrtitMmwkGY6OTFXqKaANj2VOYk12e0wRUw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 17:41:48.1271 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2a03554-88db-4b7a-e69a-08dcf51c4d26 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: SA2PEPF00003AE6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6271 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" Before, every time fdinfo is queried we try to lock all the BOs in the VM and calculate memory usage from scratch. This works okay if the fdinfo is rarely read and the VMs don't have a ton of BOs. If either of these conditions is not true, we get a massive performance hit. In this new revision, we track the BOs as they change states. This way when the fdinfo is queried we only need to take the status lock and copy out the usage stats with minimal impact to the runtime performance. Signed-off-by: Yunxiang Li --- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 14 +- drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 10 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 107 +++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 189 +++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 12 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 1 + 8 files changed, 199 insertions(+), 141 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c index b144404902255..1d8a0ff3c8604 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c @@ -36,6 +36,7 @@ #include "amdgpu_gem.h" #include "amdgpu_dma_buf.h" #include "amdgpu_xgmi.h" +#include "amdgpu_vm.h" #include #include #include @@ -190,6 +191,13 @@ static void amdgpu_dma_buf_unmap(struct dma_buf_attachment *attach, } } +static void amdgpu_dma_buf_release(struct dma_buf *buf) +{ + struct amdgpu_bo *bo = gem_to_amdgpu_bo(buf->priv); + amdgpu_vm_bo_update_shared(bo, -1); + drm_gem_dmabuf_release(buf); +} + /** * amdgpu_dma_buf_begin_cpu_access - &dma_buf_ops.begin_cpu_access implementation * @dma_buf: Shared DMA buffer @@ -237,7 +245,7 @@ const struct dma_buf_ops amdgpu_dmabuf_ops = { .unpin = amdgpu_dma_buf_unpin, .map_dma_buf = amdgpu_dma_buf_map, .unmap_dma_buf = amdgpu_dma_buf_unmap, - .release = drm_gem_dmabuf_release, + .release = amdgpu_dma_buf_release, .begin_cpu_access = amdgpu_dma_buf_begin_cpu_access, .mmap = drm_gem_dmabuf_mmap, .vmap = drm_gem_dmabuf_vmap, @@ -265,8 +273,10 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_gem_object *gobj, return ERR_PTR(-EPERM); buf = drm_gem_prime_export(gobj, flags); - if (!IS_ERR(buf)) + if (!IS_ERR(buf)) { buf->ops = &amdgpu_dmabuf_ops; + amdgpu_vm_bo_update_shared(bo, +1); + } return buf; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c index 7a9573958d87c..e0e09f7b39d10 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c @@ -60,7 +60,7 @@ void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file) struct amdgpu_fpriv *fpriv = file->driver_priv; struct amdgpu_vm *vm = &fpriv->vm; - struct amdgpu_mem_stats stats[__AMDGPU_PL_LAST + 1] = { }; + struct amdgpu_mem_stats stats[__AMDGPU_PL_LAST] = { }; ktime_t usage[AMDGPU_HW_IP_NUM]; const char *pl_name[] = { [TTM_PL_VRAM] = "vram", @@ -70,13 +70,7 @@ void amdgpu_show_fdinfo(struct drm_printer *p, struct drm_file *file) unsigned int hw_ip, i; int ret; - ret = amdgpu_bo_reserve(vm->root.bo, false); - if (ret) - return; - - amdgpu_vm_get_memory(vm, stats, ARRAY_SIZE(stats)); - amdgpu_bo_unreserve(vm->root.bo); - + amdgpu_vm_get_memory(vm, stats); amdgpu_ctx_mgr_usage(&fpriv->ctx_mgr, usage); /* diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 2436b7c9ad12b..98563124ff99c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -1156,7 +1156,7 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, return; abo = ttm_to_amdgpu_bo(bo); - amdgpu_vm_bo_invalidate(abo, evict); + amdgpu_vm_bo_move(abo, new_mem, evict); amdgpu_bo_kunmap(abo); @@ -1169,86 +1169,6 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, old_mem ? old_mem->mem_type : -1); } -void amdgpu_bo_get_memory(struct amdgpu_bo *bo, - struct amdgpu_mem_stats *stats, - unsigned int sz) -{ - const unsigned int domain_to_pl[] = { - [ilog2(AMDGPU_GEM_DOMAIN_CPU)] = TTM_PL_SYSTEM, - [ilog2(AMDGPU_GEM_DOMAIN_GTT)] = TTM_PL_TT, - [ilog2(AMDGPU_GEM_DOMAIN_VRAM)] = TTM_PL_VRAM, - [ilog2(AMDGPU_GEM_DOMAIN_GDS)] = AMDGPU_PL_GDS, - [ilog2(AMDGPU_GEM_DOMAIN_GWS)] = AMDGPU_PL_GWS, - [ilog2(AMDGPU_GEM_DOMAIN_OA)] = AMDGPU_PL_OA, - [ilog2(AMDGPU_GEM_DOMAIN_DOORBELL)] = AMDGPU_PL_DOORBELL, - }; - struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); - struct ttm_resource *res = bo->tbo.resource; - struct drm_gem_object *obj = &bo->tbo.base; - uint64_t size = amdgpu_bo_size(bo); - unsigned int type; - - if (!res) { - /* - * If no backing store use one of the preferred domain for basic - * stats. We take the MSB since that should give a reasonable - * view. - */ - BUILD_BUG_ON(TTM_PL_VRAM < TTM_PL_TT || - TTM_PL_VRAM < TTM_PL_SYSTEM); - type = fls(bo->preferred_domains & AMDGPU_GEM_DOMAIN_MASK); - if (!type) - return; - type--; - if (drm_WARN_ON_ONCE(&adev->ddev, - type >= ARRAY_SIZE(domain_to_pl))) - return; - type = domain_to_pl[type]; - } else { - type = res->mem_type; - } - - /* Squash some into 'cpu' to keep the legacy userspace view. */ - switch (type) { - case TTM_PL_VRAM: - case TTM_PL_TT: - case TTM_PL_SYSTEM: - break; - default: - type = TTM_PL_SYSTEM; - break; - } - - if (drm_WARN_ON_ONCE(&adev->ddev, type >= sz)) - return; - - /* DRM stats common fields: */ - - if (drm_gem_object_is_shared_for_memory_stats(obj)) - stats[type].drm.shared += size; - else - stats[type].drm.private += size; - - if (res) { - stats[type].drm.resident += size; - - if (!dma_resv_test_signaled(obj->resv, DMA_RESV_USAGE_BOOKKEEP)) - stats[type].drm.active += size; - else if (bo->flags & AMDGPU_GEM_CREATE_DISCARDABLE) - stats[type].drm.purgeable += size; - } - - /* amdgpu specific stats: */ - - if (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) { - stats[TTM_PL_VRAM].requested += size; - if (type != TTM_PL_VRAM) - stats[TTM_PL_VRAM].evicted += size; - } else if (bo->preferred_domains & AMDGPU_GEM_DOMAIN_GTT) { - stats[TTM_PL_TT].requested += size; - } -} - /** * amdgpu_bo_release_notify - notification about a BO being released * @bo: pointer to a buffer object @@ -1463,6 +1383,31 @@ u64 amdgpu_bo_gpu_offset_no_check(struct amdgpu_bo *bo) return amdgpu_gmc_sign_extend(offset); } +uint32_t amdgpu_bo_get_preferred_placement(struct amdgpu_bo *bo) { + uint32_t domain = bo->preferred_domains & AMDGPU_GEM_DOMAIN_MASK; + if (!domain) + return TTM_PL_SYSTEM; + + switch (ilog2(domain)) { + case AMDGPU_GEM_DOMAIN_CPU: + return TTM_PL_SYSTEM; + case AMDGPU_GEM_DOMAIN_GTT: + return TTM_PL_TT; + case AMDGPU_GEM_DOMAIN_VRAM: + return TTM_PL_VRAM; + case AMDGPU_GEM_DOMAIN_GDS: + return AMDGPU_PL_GDS; + case AMDGPU_GEM_DOMAIN_GWS: + return AMDGPU_PL_GWS; + case AMDGPU_GEM_DOMAIN_OA: + return AMDGPU_PL_OA; + case AMDGPU_GEM_DOMAIN_DOORBELL: + return AMDGPU_PL_DOORBELL; + default: + return TTM_PL_SYSTEM; + } +} + /** * amdgpu_bo_get_preferred_domain - get preferred domain * @adev: amdgpu device object diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index be6769852ece4..bd58a8b0ece66 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -30,6 +30,7 @@ #include #include "amdgpu.h" +#include "amdgpu_ttm.h" #include "amdgpu_res_cursor.h" #ifdef CONFIG_MMU_NOTIFIER @@ -300,9 +301,7 @@ int amdgpu_bo_sync_wait_resv(struct amdgpu_device *adev, struct dma_resv *resv, int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr); u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo); u64 amdgpu_bo_gpu_offset_no_check(struct amdgpu_bo *bo); -void amdgpu_bo_get_memory(struct amdgpu_bo *bo, - struct amdgpu_mem_stats *stats, - unsigned int size); +uint32_t amdgpu_bo_get_preferred_placement(struct amdgpu_bo *bo); uint32_t amdgpu_bo_get_preferred_domain(struct amdgpu_device *adev, uint32_t domain); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index 2852a6064c9ac..a9088e864fde4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h @@ -26,8 +26,8 @@ #include #include +#include #include "amdgpu_vram_mgr.h" -#include "amdgpu.h" #define AMDGPU_PL_GDS (TTM_PL_PRIV + 0) #define AMDGPU_PL_GWS (TTM_PL_PRIV + 1) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 9fab64edd0530..abd35c18ddaa8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -36,6 +36,7 @@ #include #include #include "amdgpu.h" +#include "amdgpu_vm.h" #include "amdgpu_trace.h" #include "amdgpu_amdkfd.h" #include "amdgpu_gmc.h" @@ -310,6 +311,94 @@ static void amdgpu_vm_bo_reset_state_machine(struct amdgpu_vm *vm) spin_unlock(&vm->status_lock); } +/** + * amdgpu_vm_update_shared - helper to update shared memory stat + * @base: base structure for tracking BO usage in a VM + * @sign: if we should add (+1) or subtract (-1) from the shared stat + * + * Takes the vm status_lock and updates the shared memory stat. If the basic + * stat changed (e.g. buffer was moved) amdgpu_vm_update_stats need to be called + * as well. + */ +static void amdgpu_vm_update_shared(struct amdgpu_vm_bo_base *base, int sign) +{ + struct amdgpu_vm *vm = base->vm; + struct amdgpu_bo *bo = base->bo; + struct ttm_resource *res; + int64_t size; + uint32_t type; + + if (!vm || !bo) + return; + + size = sign * amdgpu_bo_size(bo); + if ((res = bo->tbo.resource)) + type = res->mem_type; + else + type = amdgpu_bo_get_preferred_placement(bo); + if (type >= __AMDGPU_PL_LAST) + return; + + spin_lock(&vm->status_lock); + vm->stats[type].drm.shared += size; + vm->stats[type].drm.private -= size; + spin_unlock(&vm->status_lock); +} + +/** + * amdgpu_vm_update_stats - helper to update normal memory stat + * @base: base structure for tracking BO usage in a VM + * @new_res: if not NULL, the ttm_resource to use for the purpose of accounting + * (i.e. ignore the one in the BO) + * @sign: if we should add (+1) or subtract (-1) from the stat + * + * Takes the vm status_lock and updates the basic memory stat. If the shared + * stat changed (e.g. buffer was exported) amdgpu_vm_update_shared need to be + * called as well. + */ +void amdgpu_vm_update_stats(struct amdgpu_vm_bo_base *base, + struct ttm_resource *new_res, int sign) +{ + struct amdgpu_vm *vm = base->vm; + struct amdgpu_bo *bo = base->bo; + struct ttm_resource *res; + int64_t size; + uint32_t type; + bool shared; + + if (!vm || !bo) + return; + + size = sign * amdgpu_bo_size(bo); + res = new_res ? new_res : bo->tbo.resource; + type = res ? res->mem_type : amdgpu_bo_get_preferred_placement(bo); + shared = drm_gem_object_is_shared_for_memory_stats(&bo->tbo.base); + + if (type >= __AMDGPU_PL_LAST) + return; + + spin_lock(&vm->status_lock); + + if (shared) + vm->stats[type].drm.shared += size; + else + vm->stats[type].drm.private += size; + if (res) + vm->stats[type].drm.resident += size; + if (bo->flags & AMDGPU_GEM_CREATE_DISCARDABLE) + vm->stats[type].drm.purgeable += size; + + if (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) { + vm->stats[TTM_PL_VRAM].requested += size; + if (type != TTM_PL_VRAM) + vm->stats[TTM_PL_VRAM].evicted += size; + } else if (bo->preferred_domains & AMDGPU_GEM_DOMAIN_GTT) { + vm->stats[TTM_PL_TT].requested += size; + } + + spin_unlock(&vm->status_lock); +} + /** * amdgpu_vm_bo_base_init - Adds bo to the list of bos associated with the vm * @@ -332,6 +421,7 @@ void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base, return; base->next = bo->vm_bo; bo->vm_bo = base; + amdgpu_vm_update_stats(base, NULL, +1); if (!amdgpu_vm_is_bo_always_valid(vm, bo)) return; @@ -1082,53 +1172,11 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, return r; } -static void amdgpu_vm_bo_get_memory(struct amdgpu_bo_va *bo_va, - struct amdgpu_mem_stats *stats, - unsigned int size) -{ - struct amdgpu_vm *vm = bo_va->base.vm; - struct amdgpu_bo *bo = bo_va->base.bo; - - if (!bo) - return; - - /* - * For now ignore BOs which are currently locked and potentially - * changing their location. - */ - if (!amdgpu_vm_is_bo_always_valid(vm, bo) && - !dma_resv_trylock(bo->tbo.base.resv)) - return; - - amdgpu_bo_get_memory(bo, stats, size); - if (!amdgpu_vm_is_bo_always_valid(vm, bo)) - dma_resv_unlock(bo->tbo.base.resv); -} - void amdgpu_vm_get_memory(struct amdgpu_vm *vm, - struct amdgpu_mem_stats *stats, - unsigned int size) + struct amdgpu_mem_stats stats[__AMDGPU_PL_LAST]) { - struct amdgpu_bo_va *bo_va, *tmp; - spin_lock(&vm->status_lock); - list_for_each_entry_safe(bo_va, tmp, &vm->idle, base.vm_status) - amdgpu_vm_bo_get_memory(bo_va, stats, size); - - list_for_each_entry_safe(bo_va, tmp, &vm->evicted, base.vm_status) - amdgpu_vm_bo_get_memory(bo_va, stats, size); - - list_for_each_entry_safe(bo_va, tmp, &vm->relocated, base.vm_status) - amdgpu_vm_bo_get_memory(bo_va, stats, size); - - list_for_each_entry_safe(bo_va, tmp, &vm->moved, base.vm_status) - amdgpu_vm_bo_get_memory(bo_va, stats, size); - - list_for_each_entry_safe(bo_va, tmp, &vm->invalidated, base.vm_status) - amdgpu_vm_bo_get_memory(bo_va, stats, size); - - list_for_each_entry_safe(bo_va, tmp, &vm->done, base.vm_status) - amdgpu_vm_bo_get_memory(bo_va, stats, size); + memcpy(stats, vm->stats, sizeof(*stats) * __AMDGPU_PL_LAST); spin_unlock(&vm->status_lock); } @@ -2071,6 +2119,7 @@ void amdgpu_vm_bo_del(struct amdgpu_device *adev, if (*base != &bo_va->base) continue; + amdgpu_vm_update_stats(*base, NULL, -1); *base = bo_va->base.next; break; } @@ -2136,6 +2185,22 @@ bool amdgpu_vm_evictable(struct amdgpu_bo *bo) return true; } +/** + * amdgpu_vm_bo_update_shared - called when bo gets shared/unshared + * + * @bo: amdgpu buffer object + * @sign: if we should add (+1) or subtract (-1) the memory stat + * + * Update the per VM stats for all the vm + */ +void amdgpu_vm_bo_update_shared(struct amdgpu_bo *bo, int sign) +{ + struct amdgpu_vm_bo_base *bo_base; + + for (bo_base = bo->vm_bo; bo_base; bo_base = bo_base->next) + amdgpu_vm_update_shared(bo_base, sign); +} + /** * amdgpu_vm_bo_invalidate - mark the bo as invalid * @@ -2169,6 +2234,28 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_bo *bo, bool evicted) } } +/** + * amdgpu_vm_bo_move - handle BO move + * + * @bo: amdgpu buffer object + * @new_mem: the new placement of the BO move + * @evicted: is the BO evicted + * + * Update the memory stats for the new placement and mark @bo as invalid. + */ +void amdgpu_vm_bo_move(struct amdgpu_bo *bo, struct ttm_resource *new_mem, + bool evicted) +{ + struct amdgpu_vm_bo_base *bo_base; + + for (bo_base = bo->vm_bo; bo_base; bo_base = bo_base->next) { + amdgpu_vm_update_stats(bo_base, bo->tbo.resource, -1); + amdgpu_vm_update_stats(bo_base, new_mem, +1); + } + + amdgpu_vm_bo_invalidate(bo, evicted); +} + /** * amdgpu_vm_get_block_size - calculate VM page table size as power of two * @@ -2585,6 +2672,18 @@ void amdgpu_vm_release_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm) vm->is_compute_context = false; } +static int amdgpu_vm_stats_is_zero(struct amdgpu_vm *vm) +{ + int is_zero = 1; + for (int i = 0; i < __AMDGPU_PL_LAST; ++i) { + is_zero = drm_memory_stats_is_zero(&vm->stats[i].drm) && + vm->stats->evicted == 0 && vm->stats->requested == 0; + if (!is_zero) + break; + } + return is_zero; +} + /** * amdgpu_vm_fini - tear down a vm instance * @@ -2656,6 +2755,8 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) } } + if (!amdgpu_vm_stats_is_zero(vm)) + dev_err(adev->dev, "VM memory stats is non-zero when fini\n"); } /** diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index 6a1b344e15e1b..03589559641c4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h @@ -35,6 +35,7 @@ #include "amdgpu_sync.h" #include "amdgpu_ring.h" #include "amdgpu_ids.h" +#include "amdgpu_ttm.h" struct drm_exec; @@ -345,6 +346,9 @@ struct amdgpu_vm { /* Lock to protect vm_bo add/del/move on all lists of vm */ spinlock_t status_lock; + /* Memory statistics for this vm, protected by the status_lock */ + struct amdgpu_mem_stats stats[__AMDGPU_PL_LAST]; + /* Per-VM and PT BOs who needs a validation */ struct list_head evicted; @@ -525,6 +529,11 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, bool clear); bool amdgpu_vm_evictable(struct amdgpu_bo *bo); void amdgpu_vm_bo_invalidate(struct amdgpu_bo *bo, bool evicted); +void amdgpu_vm_update_stats(struct amdgpu_vm_bo_base *base, + struct ttm_resource *new_res, int sign); +void amdgpu_vm_bo_update_shared(struct amdgpu_bo *bo, int sign); +void amdgpu_vm_bo_move(struct amdgpu_bo *bo, struct ttm_resource *new_mem, + bool evicted); uint64_t amdgpu_vm_map_gart(const dma_addr_t *pages_addr, uint64_t addr); struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm, struct amdgpu_bo *bo); @@ -575,8 +584,7 @@ void amdgpu_vm_set_task_info(struct amdgpu_vm *vm); void amdgpu_vm_move_to_lru_tail(struct amdgpu_device *adev, struct amdgpu_vm *vm); void amdgpu_vm_get_memory(struct amdgpu_vm *vm, - struct amdgpu_mem_stats *stats, - unsigned int size); + struct amdgpu_mem_stats stats[__AMDGPU_PL_LAST]); int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm, struct amdgpu_bo_vm *vmbo, bool immediate); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c index f78a0434a48fa..384526d10a3bc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c @@ -537,6 +537,7 @@ static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base *entry) if (!entry->bo) return; + amdgpu_vm_update_stats(entry, NULL, -1); entry->bo->vm_bo = NULL; ttm_bo_set_bulk_move(&entry->bo->tbo, NULL);