From patchwork Fri Oct 18 13:33:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13841812 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 1D5E6D3000E for ; Fri, 18 Oct 2024 13:33:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 49D9910E92A; Fri, 18 Oct 2024 13:33:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="qpo0ZZGo"; dkim-atps=neutral Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2050.outbound.protection.outlook.com [40.107.223.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69E6410E91F; Fri, 18 Oct 2024 13:33:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=myhDT02EqLix7cOzb5WnC+fIImYCSWfI8VJ1byWGq9oWlJt+cFqObzV7n/yCaFr73/X0uqOhWUHdCYEXaU4WCO+HmwaTltmpJe9IeXco44EceHscLpAnMwMsGlSkoz5mykguqCihekUD5/EuTWcn0SN+uohsXcQB408VmSchu+vQlBNQFU/W5kbbPd6FIkcX6wBlacDUif1ZIuoFpIXWRfUgjFIHCUllr/Yti3TENDP74Hx6UeplCs/iMEjlZYG+BWQw3zYzQ4bitSdn8OJxMWPdHJEPYaoRCIrcUit+aVsRR9Wh2pLfCJ+f1c62hMN54ucoFJSLseS5wv8fA/wQjA== 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=YYQfiYsJokk/wseiXPmgk37Drvu6aycOxZZZZwY6J5c=; b=OHwnVxya6qMLLj3frkffSnFxltF73UjEcwpOtSIJfYavjM/N2gYAjLp4diZ+IfvbXRtQjCOTY+QsfNx1hTmd+qhFGoH5qohQtrD8dvYyNL6Aq2RKJyfpsmBEW3FUax3D0uIrYXQs5nzDDdoc0Oc/o9GTk4yMpQUnNLe7vqS8T3s3at7mIidUELzmw3DzSIBEtbxqZHDu6Z84vvSuk+/vrZR2c5PlaMO/Ww6gru1123RfS4VIMXhSHgOv0+6l6EAtiUTk/07xMbgGyJ+mZZmOpCL7WewvKFLyc8qlFfANBDCrhNUMzE861u2m1kWeJQEFNgsesHQ31f8lj633IZb/iQ== 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=YYQfiYsJokk/wseiXPmgk37Drvu6aycOxZZZZwY6J5c=; b=qpo0ZZGofHoDHRQNmQ/Uo1nPb/hFeIC4Yh03KhZEDoyU7kgc5g/7+whYvE1mYMIrlb5JMuVQLGkL2922WVRKLvGkeeFIz0HW4KwFpwTlLW3VquD54Tu4AWvOPVDYbEQjBPfBM6fyJ+xkScV4pd03z7qFzj/5X4mWdzt73V5eEMQ= Received: from MN2PR22CA0010.namprd22.prod.outlook.com (2603:10b6:208:238::15) by CH0PR12MB8464.namprd12.prod.outlook.com (2603:10b6:610:184::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Fri, 18 Oct 2024 13:33:49 +0000 Received: from BN3PEPF0000B076.namprd04.prod.outlook.com (2603:10b6:208:238:cafe::cc) by MN2PR22CA0010.outlook.office365.com (2603:10b6:208:238::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.23 via Frontend Transport; Fri, 18 Oct 2024 13:33:49 +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 BN3PEPF0000B076.mail.protection.outlook.com (10.167.243.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Fri, 18 Oct 2024 13:33: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, 18 Oct 2024 08:33:47 -0500 From: Yunxiang Li To: , CC: , , , Yunxiang Li Subject: [PATCH v5 1/4] drm/amdgpu: remove unused function parameter Date: Fri, 18 Oct 2024 09:33:05 -0400 Message-ID: <20241018133308.889-2-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241018133308.889-1-Yunxiang.Li@amd.com> References: <20241018133308.889-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: BN3PEPF0000B076:EE_|CH0PR12MB8464:EE_ X-MS-Office365-Filtering-Correlation-Id: 56e8ffbd-269a-46ca-5ffe-08dcef797f6e 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: x5JgGrOVje3iAyyYaF4PVVpw4bmOIbbGruaj13Ma1FjbfKYTSy6bfiFYsQuCh/s9DjElVe2VbMgKLeagJ/zb1PcKigsL6iLGq6Sjj37+KL7SkucsKqDLu2GrOX7Z0p/qlMAjV/r8gwoJdiYCRnINR6IORxSLhidIkC+RjLbIz7wTymjxtu2sstNt07Ok9tHeFwc0BCLWxkWZmXBbSKnKoEoXY83TnGjJhb1gYyZP2GRSO4O+N81SSCp+2hWhZRWOLYbRMRUaonALCWYps2kbaQVdbHNDiWr4j7rqYwM71W3cNCbNvr8/FQhbkjaS75QH8ezcLC0j92n5lJglb8+Q1REPcAtvsvUNUnq1Qh1vOkG8ar2hase58KoY21EVWWPN2lerHZdzlv2B79T7LRhKC5zY+y/iFxTlLt59NnOa51ZiSZVlz4vt8IuZx/VwH9qo7U3DCfJ8s8IwaBeKZVFxs3FAPTTUYGYSlbF3DWBXB4tfyfO9uW9Pvs8LhHBq8TYFtadrgarOn53qXcc3kNHqJHIxsEhynu9NwKlqXetSzZuiNpsZk5bSMRMQ9bHtW6QWZ/MGKwye8xUAIT+SArKR2C1QjyB3KsaWX/BUHQL3iiy96o1DL7FnTZ0RASg9i4iAxPFQ+YSDHo8ppKSYq+u869gKwh7WREl/EFIn2aKc3MMf6NQZq2YJUZs0G6+ImSxaitgiP3+ze2VLbhH0+wQVBaGvFseduMvirnmlCLpBNKMUqL7w+yUT4p5XvOGcY/on5CJ6YxJdFym4+ndapUD+9shtRd5/VScda/YVmqAMIOE3xvnGUtYdkIpa4rKSl+OUJqaHO9a217Wf0LIgYK0ucET1P4lK7TeQGU3+AmDXOSPcDKVKxI6+DT78VHmWAYXOhZzdKKgXBqbMbsJoqsaeGGs2hgcd5tdxsCCr/6UBV3z73vIE+csq/Uib2PAgtjKdMZSk5uPBmek7rOZsn+3omvjDnLj4u7SD+BMuoCQxZadBdElWoSftsXZnN2aFcUoLCTqrog66IUH0zrcf8VkKSewBCjKaPOed6SZPDZ+ojWl0/LsEPkAWdSmMohVj9DWCQGK4uCEtGIHul04UoPxCM38OpCKrzfdEvf/hPXKb4Wq/8ozJwt6I/YcwsmGbAPgf7EKikbkdIhe1CaNPnxXSsbwRnJ6I+/uL5Hb30L5dsMrJBcm9ing1r2a5OlYoKHyzkQdf6qsx2dkXGBF9KuAxw2lWX3TO6oAq0R06AsOEiw9diNfIUjY6LPAmL9S1/oTMPuV2B77/iHpicAuGPdYwmyQrI5FHQ9Sk/jd0UcS+V1Yvau+0mN3p00o4kAkfVVYgOyuwf7AgB4uEeh6xZFIYfnnchS/z29EonA1+rDmgXRtyS9QXfxNg/u8YYoP2vkRKfDkoUTTfwPw93uTcnHXbRA== 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: 18 Oct 2024 13:33:48.7164 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 56e8ffbd-269a-46ca-5ffe-08dcef797f6e 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: BN3PEPF0000B076.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8464 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 18 13:33:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13841811 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 C61BED3000D for ; Fri, 18 Oct 2024 13:33:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E87C10E92C; Fri, 18 Oct 2024 13:33:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="NKj+3305"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2085.outbound.protection.outlook.com [40.107.237.85]) by gabe.freedesktop.org (Postfix) with ESMTPS id F09A910E91D; Fri, 18 Oct 2024 13:33:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yhrRYxq7A09bm7SGnQ7s6qlJnn5WdQW2qxj1/mqHjU+ae7B3FKRW1aCNgyaKXire9uGjkYFwx/HkZ3obqlMix+cq4yw5PAVR4Oo244N18FwNFwSKMgEq2CZTgtBWgUE1c6SweY/LkBkMaAFhN3a5hjHUwywyP/EAZypWRS6FLG+fvd7qQD9nGEb+sdz1T+pSYgaRkw8b9/3nF8cw9I2noJ1yKxBFudox8dHTrJu5B6VMn1eRUrKszfHf5LZ3v0h0eq9goV4bExwf1H5Nf9A/qXjZRE9aXtT9ns3nkpUOt2AGZKznWzPxmY3hG2Y3SaXp+pcHLqOZJiNQRVPrcIly8Q== 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=6ekkHb51M+zTWLb7MQ36UCtqa0BX/ZSr7+X480rFhLM=; b=DPbtQlfFmB+VjJt1TM2YQ/d1x5So9gkRNU4NQczoMDMJhjB8WPzyBq0GB6i+KEDAEEec59xi3NuiMoiqTqcmqiKbTBg3K2SsyJBzo9r8Av1wzAQkG/Ms80iWsd1J5wj3jBvB9tbEz/XG1stMAzAu9xRFxW8JdKTFdJGOkLZGOqRjNlSF3mDJL8jfhrgfNQQP9qBNpfVIRDvNb4lxOc012nGescLKVazVTkEpQ9Z5TnmLlUKf8BW49PVF7swybWVF6/0OJKlndXr241UISFfj7XEc8J3TRmHUCPXypE7tdP8R8S5jWzSQtCkSzrd5t2kfA2giyVPPfzSEL1mgx3eH1g== 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=6ekkHb51M+zTWLb7MQ36UCtqa0BX/ZSr7+X480rFhLM=; b=NKj+33051tKNdfiB7YXI/gikv08d5ePuTy9721BhCi7E8x1RzTuvvnbBwpM7OZoJbfSv/DGS5hjuX7AIdImnVjyeXmZhlOPe2w2v7nbrQSYcFiPEl3cT0ZLosNmdAXmE1fWOZi+wvzkeo4KBRGuUKyi+3XvNbH7TI9K7U0uIy1c= Received: from BLAPR05CA0041.namprd05.prod.outlook.com (2603:10b6:208:335::24) by SJ2PR12MB8926.namprd12.prod.outlook.com (2603:10b6:a03:53b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Fri, 18 Oct 2024 13:33:51 +0000 Received: from BN3PEPF0000B077.namprd04.prod.outlook.com (2603:10b6:208:335:cafe::21) by BLAPR05CA0041.outlook.office365.com (2603:10b6:208:335::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.10 via Frontend Transport; Fri, 18 Oct 2024 13:33:51 +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 BN3PEPF0000B077.mail.protection.outlook.com (10.167.243.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Fri, 18 Oct 2024 13:33:50 +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, 18 Oct 2024 08:33:48 -0500 From: Yunxiang Li To: , CC: , , , Yunxiang Li Subject: [PATCH v5 2/4] drm/amdgpu: make drm-memory-* report resident memory Date: Fri, 18 Oct 2024 09:33:06 -0400 Message-ID: <20241018133308.889-3-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241018133308.889-1-Yunxiang.Li@amd.com> References: <20241018133308.889-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: BN3PEPF0000B077:EE_|SJ2PR12MB8926:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c0d4b0a-8c56-46d0-5169-08dcef79809d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: ih7I1pwL4L+su5sAOanzZMmJimu/+olwaswNjm5F0NQtTc9QdJrplpU1izYRKXbJ1X/LJrThLwuWWuMj0qP86Zhsv7RnbfxuM/kEAQFCB5X5bAmlNFaLHfpXE9l+Z9hvktpcRDaC7zdYYQYMFwTHd2lYSBCDPNTw4c91/EIN2OgLeiU33Uuzp+W54aWGNccGCkzOZtnUa5bt0xxxbV1OUqN6XY7QbVOnqZQ5jSj61tXIwatMGtIJ7qzOIm+LXuGOqcEn+yYGpZYLQRrJFdpvNeb9Iqo0Zod0UPo41kB8er55ckypOSIvJG7b1XAkefPzokovJbjaBkvpwHpDMYZm3V042ahUXhYC62B8wU3m3WrHpwkAFnIDzvNVub3W0nTefmj+4UxXbYW+CeecIqrJ1UO86e7P14pf1nNMWdJHIjvT9uJ639f4m9QJ2bVkZleR9/dG9XJjYnwF9epl7CzTNuno1LXIftB9jzXZJ+fA0m3wUuQphCnJl/35Q1SbBg4gcjt/9EoAwvZkZVun39EOd7+uroOPHP0txo9EMOkDjI7BCE83lrCSsEscwyX4HecY42JPw4pqqJtIfnuRIMgb0vF2aZ/9BJO8Hs0SUSoLbX9oM1arQI+GvVmgOxi8jPOz93cVeluAUh4GHzBn05bSrMuuQebPHw0JFqiZfoKSY5Y0MITKrTF+J5upWvwxJ2D9d4PCrxrizqr1Jd70YNVFagKAoizuJZt2k98tbOE77ldhjl5C4w7URgKB+4xvUaF72PfeSuO3gfg/emubRNvolBrBrnEdKJb+EO6nMIdnVHe5cuEZE0xNijsu9EbtV6oRPYe2XeSajPAHVlzSEGQh49aR2L9+YOsF+4FDLtbGkyMs93NPkrrGK/lc+ZvOkrXrpArv3+2QLtAL6ZMdon+Xo6mErknbXhGB58g7+vrVpL0Gu7qmgTZORdfudddFJZmjWyV3JCV2YCTg8o5wQOSWc9wfKxaFE9pHAu+ljTNCifQb9hEhjZi9ZCrUbT0ZQfsW/6knoF+QnZsIki0+iCeWYsFuM6WweHw8e3c2yOW60ezwuspBaCb1U86KDIZDngyj8GZI0iQGlr+yoI+OEMlcdRqrfBfv4tt/CW7VRJHuJ9DeDplceh0rZFO97DFufLuegiBpbQb79B4nCtUr1q+vgbB98E9y0+9u67eeZfbf9BnF6gHb12XmX772pJlBhFu/u/jzW1gHwHdQRWhjDXU6tAsf44Tscw4U3hXmn9Wt4VC16x/MbPNGn1z5Ywwda55LOyik/Xam0hfjJHT+VpU0oGOoQTjuHAlFI4etq7+Kl8vsRAcTkoeCY1hQPRaKKODbkpesc+tEfzX/KCNo366+vYTot16oC6j5JUuGWvB/bpO+ZIokl7T2Bge4w0uWQw3ZJLxSidC9o2TqLEAyqQ5JVQ== 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)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2024 13:33:50.7017 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c0d4b0a-8c56-46d0-5169-08dcef79809d 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: BN3PEPF0000B077.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8926 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 18 13:33:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13841813 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 AA1B6D3000C for ; Fri, 18 Oct 2024 13:34:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C1BB10E92B; Fri, 18 Oct 2024 13:33:59 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="ZIAGzOF0"; dkim-atps=neutral Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2074.outbound.protection.outlook.com [40.107.243.74]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A2DB10E92B; Fri, 18 Oct 2024 13:33:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A2/e3uozGcpE06NkyXmIr9a1/iof1cXqNsEbgYDZxVEA9d+wtl4RX0Vib07t2pVP3IQLw3qMD+d3Jw1dyI3W8Mpm1H0YveasjzKlq/YmuCxCazYPtlg1oJAoeKBuFwoQouLo34Ry0AqHDUCmTcXxQiwQfEKQIfnOXuSePYANGedMY53XLoISSO+h6HZACBUprhWRU1XXWWgk/x1Kk9tFmSjVT53iCde0NujQznuiwckv1HPY4PYOc7oEj9H1NKrJNHLTP6rXFEcMcnCfshPKDBCFtQqYYL3IBjL98bTgFzqhgL6O/2lRwuxSXvSpPYIuzQXWvqck8gomK32nh1z/4Q== 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=XO+7dCLe9uTh2aOMnLC2eLAtbafJaF+b4dRzmUMlYMo=; b=weggGrTyiHAGsVRww2qROEtOXC8EGlpv13i0P0lAAlEasLqaJz1cmJDnd82IJhYAPhz29wpBQ9wdhzBBtPR6SJxGhVPuZ1XPDAMQHrTZ6yan4f9Rzg0E5/RwubnPbGCd4gJXmIwk4CPG7tK/t+uDgj6fz0pCPq6lUFCbhQ/FUa6Rgthtzp1tXxkIrpA7nI/iU8iomLfuOUUzu8Me5UYnQK6khZta6/oglqVF7NWokR4eTT3AlfJE1uxTGcxBmCNClOCrsyKOYKmJysbm+7yFKmJmaQEPxi7P9GjorQEmMbztC6LribMvagPTj42pzRQjYs5QxUf8yvt1YzmG52I6+g== 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=XO+7dCLe9uTh2aOMnLC2eLAtbafJaF+b4dRzmUMlYMo=; b=ZIAGzOF069UVz4xCFNV3rbnQKXm20px4qUanyCz5eQZ3djpdNYsyziIpUwXInlKsmqh9s/DkyunysMUdMsu7u/lG/yVUoRqVyxKydxBZ4LZwssotlJFEZeB6dVGmCUdBpIBFD06t2KP0ddKvbVjachNKiK/Sr9/HqEWKzbNMhP8= Received: from BLAPR05CA0027.namprd05.prod.outlook.com (2603:10b6:208:335::7) by MW3PR12MB4425.namprd12.prod.outlook.com (2603:10b6:303:5e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.24; Fri, 18 Oct 2024 13:33:52 +0000 Received: from BN3PEPF0000B077.namprd04.prod.outlook.com (2603:10b6:208:335:cafe::42) by BLAPR05CA0027.outlook.office365.com (2603:10b6:208:335::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.10 via Frontend Transport; Fri, 18 Oct 2024 13:33:52 +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 BN3PEPF0000B077.mail.protection.outlook.com (10.167.243.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Fri, 18 Oct 2024 13:33:52 +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, 18 Oct 2024 08:33:49 -0500 From: Yunxiang Li To: , CC: , , , Yunxiang Li Subject: [PATCH v5 3/4] drm/amdgpu: stop tracking visible memory stats Date: Fri, 18 Oct 2024 09:33:07 -0400 Message-ID: <20241018133308.889-4-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241018133308.889-1-Yunxiang.Li@amd.com> References: <20241018133308.889-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: BN3PEPF0000B077:EE_|MW3PR12MB4425:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b8e4708-9f2c-4c23-477e-08dcef798176 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: YGf14MpANixQty3E7pXrgcye2ayjBbUFJ6l3XiLBmicycvE6e/QPxBB6/12geGiwio2/Xzj+pSWE5yAjEI3/dF6s9e0Z4s4CrP0B2y0on0d8qvrZY9c7NtA9nHCe8onAQ2Khj90IHyH4rlhGoG24lOhUZMrh3VUUIaqjTtLfJPi1mAdN7Q7AqQIGKxEU8AsAfhkuYp8sBrfKHPhsaFCsApRY3f05NPJQ4Qj2lCpzFSlDTJCinHGnLhrvNy0c+R3lkP+WyZ2ik98SXr4sqx/T4XQRUYLOM55J0BXjsavRlH7pRZeKpbzD4JaW3r+p6utB5MS/0Hty4iR4aptheOcJzBQJiSVuFSx1oYQ4xv/Z1Rz94QkW/+4uA4ItX2++rMYdBcVUGt9tqssvp/6IEL0ADGKkAOHRPz4BJ1NiHjN8pH+7TFbcjXyTIQibz6VTohKmOIqq/xwGTgTiHyt2ABf+/aHmf7yuLMYIZUVw/xGLEJfwyBfPB3xHhgNZeucv1juJ4FAujLhN0nKKrJg+f+kw1WerxYST6jReYM1H1G1QazDURLwosXHhq4ZB1V8z8Tf0kPPI+c/0mab5j6IAeGWSUNMtCXoRLSdrV0Fc1dkIqfQBofdANmU+sFe022YsC06kyUMNhgP41LYmrcY9hg8jEeNeENDG0C+81ahVFA1PdfYry//z6ektsUBtTwDyVWCioJrtpeqHN86ZStjcbXbraXl78ZHaOVCT0Qqw7/eQyvAfdaUyYTucrc8GLQXqz5+KzzoG9AY8W/lAJ5rilAbdSznXsX7J0ngXsZGQBR2lefg9r6RXg7TH9oD/lkEJQsCViWqnKrEu622MraOuyMwoiuir3y3AoDaxfDMhdIOpdECWR+ihfMHkZzsxLTYi3okAu2XZou06fHjMsjxR1jHSHn+oDbNhb6oMh/1BsUWvYn9n1UE3gFTuV9UM+am4IYjCDxW/R1bCgSl4UBJ3lbqCPcszbwooGCQC3yhaO8X9pWjTFMl+EguVX8E5ffyN5KF1zVnPnEP4jQxhsAxwEdZKn48rORGgj2Hm+SNI0UsDu76B7gibbRkAU6NIZHBDFo87HMpxrsozTepYNfmtdRQPrNd0+QzBC2j0nwhK/TIEBqpQ7MpVAcHI9RCoNiSIr+yoNBU7LAZb8KZ9bes/dW73mS4tDvn/0Pfnm6Mnwjnm4bpeX4/B6U2hcn0caNZcUdYlwKgW2eT8jnCpMhXz8fDl0QSlFDmmtNkyCvtvtUVRmv08JnHth3CC6/M54z2k+qGdWmTMG62/rCeyZb1ow/Smif31b9abRblAAJpX1e4Yaixv20JxITgsCOXvQ/Pq1g4DOQbvPZqJ9H+E5LbOxGByGyhNXc0rnCNxpCIhwQ92EvDsU+q7JZtjatHvlxvpzc0LN45tZCJ7qTPf4bnXBQsEtg== 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)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2024 13:33:52.1236 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b8e4708-9f2c-4c23-477e-08dcef798176 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: BN3PEPF0000B077.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4425 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, or just report all the BOs as visible. 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 18 13:33:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunxiang Li X-Patchwork-Id: 13841814 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 2288CD3000A for ; Fri, 18 Oct 2024 13:34:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8B96F10E92F; Fri, 18 Oct 2024 13:34:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="siWXveam"; dkim-atps=neutral Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2078.outbound.protection.outlook.com [40.107.95.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0357610E92A; Fri, 18 Oct 2024 13:33:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XkY1L3PbCiYwAkzcSioJE769TDkj/j5zzOU3o04AqpTuGYFfgfBU1LAzVOI6ypjCEE6GNQ81H6UfHP7iy0rDRdCLmLFdyuSP8fNX6pSJjkCUJ3/rdhaIO7C5nD0/dXNM0hKCQFSb4CTQxsE6RE+6zm62iyIdxBVDsT9obIa1q17Q9JpMeQ7wuciTtHwIqQ97AU20YH+BHsQ0WnfAECXYazDN1wT0Y/QgEDtYlzj5J545rIaOSjmD71chgmLndcyeiVJqWPrB6V/gZRvOsmwXQ76sioKZKlbXHhFLyvLPszHCEFgYuUL2su9NdKhMFk4IV5XEFC37yy/xuoOMF/RIgw== 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=ocnrLIJwQAsrYWLC+Ze8UUzKOmziHXcx3NebWdzj04w=; b=nhCFp0P6IxJHZ0JgwuruVvLnPKoylxYAWygjvMjSzeJODckA45j3xp6yQVG3G+lMVi0+3EVzf7mPR/fuLtq/z/nKva0KwhnB9E2G9KtYhg4h2JCq9UDGEcdTtVjWt+33l9lHASlTpmF2mxIbtd7z+mGKW07xcqO3Kw7uhjCKom8KZjdPTvq5BbbmatCc+EMh2GaAtBoEw3auvyYzRlU1FojIB99N/2RlRjA12doGS/y3zPjAToEInFNcw0859cQ/z79cr4IOov52adp1rGDqEeqOSic1HRTn3wKIwcEXVXGE0+8FxaWyEGSDHemZ78/xI9BceHSd7kcJ/EUsnAHOkw== 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=ocnrLIJwQAsrYWLC+Ze8UUzKOmziHXcx3NebWdzj04w=; b=siWXveamWjk2vcqpuxtcF1RVwfI0Ius94z6/IvArd7rWHITBL/oRy5p2z0bkRfk0KPvQk+TJyCjxw5B/rCJmHfZ75KodjDfiLi0KtBsC9cJpGa44Fcbj4oev+YnYv0SSL0gZ/+NMl27jJVF3xSk0AqYDSn+H4rik69F20EFLFmQ= Received: from BLAPR05CA0041.namprd05.prod.outlook.com (2603:10b6:208:335::24) by CY8PR12MB7266.namprd12.prod.outlook.com (2603:10b6:930:56::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Fri, 18 Oct 2024 13:33:54 +0000 Received: from BN3PEPF0000B077.namprd04.prod.outlook.com (2603:10b6:208:335:cafe::34) by BLAPR05CA0041.outlook.office365.com (2603:10b6:208:335::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.10 via Frontend Transport; Fri, 18 Oct 2024 13:33:53 +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 BN3PEPF0000B077.mail.protection.outlook.com (10.167.243.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8069.17 via Frontend Transport; Fri, 18 Oct 2024 13:33:53 +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, 18 Oct 2024 08:33:51 -0500 From: Yunxiang Li To: , CC: , , , Yunxiang Li Subject: [PATCH v5 4/4] drm/amdgpu: track bo memory stats at runtime Date: Fri, 18 Oct 2024 09:33:08 -0400 Message-ID: <20241018133308.889-5-Yunxiang.Li@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241018133308.889-1-Yunxiang.Li@amd.com> References: <20241018133308.889-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: BN3PEPF0000B077:EE_|CY8PR12MB7266:EE_ X-MS-Office365-Filtering-Correlation-Id: 77b279fd-8686-4423-62bd-08dcef798275 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: MEyZMA62jGhytLPaqkpXTuakcG3M6vqrp5luzPG84dilseJJ+DV9WImXWetDSCgjMlVwHFxDQDd/GOVeyQ3zW69SW0xVTV1SBje/1ptsY/GcA6nv24it/oa8wvucD2J0BcZt4YUiIYw5iLS9bVF7AwGNdmCVBnN+hQzHquy09pDytNbXOihZJJg86kF1qo2C4Fazp5P5lwJH+v0VP8zorWFjljYeHau2i7cyCr6YoqhZEgQO2ALxUSb5lsR6tZobmZkEoxrCQw8nIEwEpOVD8hrGcFAS2wi5vdKYHoqBDyeKF44eTmJr2STh8Y/tAiSwBx5oDmWm4vpyad9R7i2PjZM7LhvrorNsO9xKYLPO9QugvmHOANkQvkC7s5HqG8s04mAKS9ZprLeg7C/omrI6JFGODHzSB/r5uCMtsil8DN5d7RKp6yDzCa7nZgCXOynCSI0CI4pJYwko46R5ABAVd/fMrUrnQqAvtkGnZDWSY6esOoBkbDaJsJO6/h//6fnKvPpSBXHL+N2r4gr+zVA/fbs+boLIYpiPpAXFTPbgpulQydjWTEK/Bd3FiVcTBxTVcKe6U75NMXA3R1EqXQyofrHDamjZ9v6eEnuiBk/hIyMz33HdiP4z4bHrMutysaMzOtE2OamGvLODE6YOyUgNTcU+6XSl8uq0xx5veGmtP30+kaiD+cUrNOFiti9xzQgFWyg3fMIM+rsYetmwJ0hou4/HWToV5QGC61rJX5JLgZHS4TBAEi/sDwNmb6y5C51hFjubB2lQ/uMgnyY9gWqBjoOuJK7mJx1WBWSNaVIYlp7X0WQ9t0LrzzUR4F1+AoaIHMSgkBoKB+IIYBUmjW78CFxdMfjppDkPFI1wN97Jgg8Gk/RGZRrJF/7+2djx9QH+YwTiehYT/eGki/pAbAdw8HP/ruSRkvz27ytKjsFRD/sfH370pVneoXPYdE16hTLZT5TwM6DcryJljqwaFiKX9HWct9kIFpng71E0NPzYsGiQ/Oc1N1uwt739S8I1bnpDAIkgbQHL0w8Nku57c24IW9CxBVfjsDIiOmQD99E5Qw2B25EWWU/2f89a6U6yX3dlKo0SliBaVcj5y8u9ErmTmDT+mXn/VPyQ9pv+AZNIVCfuXfUZ/rXVz8BLDzfIrJIljOe86Z4DIznKc44qfHl4IaaL5xb07H+kbXgvpB369pimb5VSHNeWDqq353KQ0MQ9smfquc3THUx3WU0XdJ+5uxaxiA7wgYkRlMbDdAO49BJEUrXVG/a8f3jrpsEf7q4WHZuewIziVzNDjy7r76Q00FIUgDrXyrHnp2goTw77v/EgHpMDqOu7X2ybGPyWhrqoWVJPValhx1DzgfREl/4xMwdrBTUPRWpxaDgQKMeicc2ODLvueNdFBdS319ehBPhTrv8cTD3HtuQVOWQynxijcg== 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)(82310400026)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2024 13:33:53.7955 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 77b279fd-8686-4423-62bd-08dcef798275 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: BN3PEPF0000B077.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7266 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 | 11 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 82 +------- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 3 - drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 204 ++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 13 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 1 + drivers/gpu/drm/drm_file.c | 8 + include/drm/drm_file.h | 1 + 9 files changed, 220 insertions(+), 117 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..ceedfc3665c18 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c @@ -40,6 +40,7 @@ #include "amdgpu_gem.h" #include "amdgpu_ctx.h" #include "amdgpu_fdinfo.h" +#include "amdgpu_ttm.h" static const char *amdgpu_ip_name[AMDGPU_HW_IP_NUM] = { @@ -60,7 +61,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 +71,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..5ff147881da6d 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 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index be6769852ece4..ebad4f96775d9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -300,9 +300,6 @@ 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_domain(struct amdgpu_device *adev, uint32_t domain); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 9fab64edd0530..a802cea67a4d7 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,134 @@ static void amdgpu_vm_bo_reset_state_machine(struct amdgpu_vm *vm) spin_unlock(&vm->status_lock); } +static uint32_t fold_memtype(uint32_t memtype) { + /* Squash private placements into 'cpu' to keep the legacy userspace view. */ + switch (mem_type) { + case TTM_PL_VRAM: + case TTM_PL_TT: + return memtype + default: + return TTM_PL_SYSTEM; + } +} + +static uint32_t bo_get_memtype(struct amdgpu_bo *bo) { + struct ttm_resource *res = bo->tbo.resource; + const uint32_t 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, + }; + uint32_t domain; + + if (res) + return fold_memtype(res->mem_type); + + /* + * 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); + domain = fls(bo->preferred_domains & AMDGPU_GEM_DOMAIN_MASK); + if (drm_WARN_ON_ONCE(&adev->ddev, + domain == 0 || --domain >= ARRAY_SIZE(domain_to_pl))) + return 0; + return fold_memtype(domain_to_pl[domain]) +} + +/** + * 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) the memory 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; + int64_t size; + int type; + + if (!vm || !bo || !(sign == +1 || sign == -1)) + return; + + spin_lock(&vm->status_lock); + size = sign * amdgpu_bo_size(bo); + type = bo_get_memtype(bo); + 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_mem: the new placement of the BO if any (e.g. NULL when BO is deleted) + * @old_mem: the old placement of the BO if any (e.g. NULL when BO is created) + * + * 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_mem, + struct ttm_resource *old_mem) +{ + struct amdgpu_vm *vm = base->vm; + struct amdgpu_bo *bo = base->bo; + uint64_t size; + int type; + bool shared; + + if (!vm || !bo || (!new_mem && !old_mem)) + return; + + spin_lock(&vm->status_lock); + + size = amdgpu_bo_size(bo); + shared = drm_gem_object_is_shared_for_memory_stats(&bo->tbo.base); + + if (old_mem) { + type = fold_memtype(old_mem->mem_type); + if (shared) + vm->stats[i].drm.shared -= size; + else + vm->stats[i].drm.private -= size; + } + if (new_mem) { + type = fold_memtype(new_mem->mem_type); + if (shared) + vm->stats[i].drm.shared += size; + else + vm->stats[i].drm.private += size; + } + if (bo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM) { + if (!old_mem) + vm->stats[TTM_PL_VRAM].requested += size; + else if (old_mem->mem_type != TTM_PL_VRAM) + vm->stats[TTM_PL_VRAM].evicted -= size; + if (!new_mem) + vm->stats[TTM_PL_VRAM].requested -= size; + else if (new_mem->mem_type != TTM_PL_VRAM) + vm->stats[TTM_PL_VRAM].evicted += size; + } else if (bo->preferred_domains & AMDGPU_GEM_DOMAIN_GTT) { + if (!old_mem) + vm->stats[TTM_PL_TT].requested += size; + if (!new_mem) + 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 +461,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, bo->tbo.resource, NULL); if (!amdgpu_vm_is_bo_always_valid(vm, bo)) return; @@ -1106,29 +1236,10 @@ static void amdgpu_vm_bo_get_memory(struct amdgpu_bo_va *bo_va, } 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 +2182,7 @@ void amdgpu_vm_bo_del(struct amdgpu_device *adev, if (*base != &bo_va->base) continue; + amdgpu_vm_update_stats(*base, NULL, bo->tbo.resource); *base = bo_va->base.next; break; } @@ -2136,6 +2248,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 +2297,26 @@ 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, new_mem, bo->tbo.resource); + + amdgpu_vm_bo_invalidate(bo, evicted); +} + /** * amdgpu_vm_get_block_size - calculate VM page table size as power of two * @@ -2585,6 +2733,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) { + if (!(is_zero = is_zero && + drm_memory_stats_is_zero(&vm->stats[i].drm) && + stats->evicted == 0 && stats->requested == 0)) + break; + } + return is_zero; +} + /** * amdgpu_vm_fini - tear down a vm instance * @@ -2656,6 +2816,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..7b3cd6367969d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h @@ -24,6 +24,7 @@ #ifndef __AMDGPU_VM_H__ #define __AMDGPU_VM_H__ +#include "amdgpu_ttm.h" #include #include #include @@ -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,12 @@ 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_mem, + struct ttm_resource *old_mem); +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 +585,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..bd57ced911e32 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, entry->bo->tbo.resource); entry->bo->vm_bo = NULL; ttm_bo_set_bulk_move(&entry->bo->tbo, NULL); diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 714e42b051080..39e36fa1e89cd 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -859,6 +859,14 @@ 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); +} + /** * 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,