From patchwork Wed Aug 8 09:59:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 10559709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D31641390 for ; Wed, 8 Aug 2018 09:59:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEF112A903 for ; Wed, 8 Aug 2018 09:59:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2CBC2A95A; Wed, 8 Aug 2018 09:59:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B38332A903 for ; Wed, 8 Aug 2018 09:59:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D055E6E2B3; Wed, 8 Aug 2018 09:59:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0042.outbound.protection.outlook.com [104.47.37.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id BBF0E6E2B3; Wed, 8 Aug 2018 09:59:46 +0000 (UTC) Received: from SN1PR12CA0033.namprd12.prod.outlook.com (2a01:111:e400:5174::43) by CY4PR1201MB2500.namprd12.prod.outlook.com (2603:10b6:903:d0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Wed, 8 Aug 2018 09:59:44 +0000 Received: from CO1NAM03FT061.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::201) by SN1PR12CA0033.outlook.office365.com (2a01:111:e400:5174::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1038.20 via Frontend Transport; Wed, 8 Aug 2018 09:59:44 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT061.mail.protection.outlook.com (10.152.81.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.1038.3 via Frontend Transport; Wed, 8 Aug 2018 09:59:44 +0000 Received: from hr-intel.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Wed, 8 Aug 2018 04:59:42 -0500 From: Huang Rui To: , Subject: [PATCH 0/5] drm/ttm,amdgpu: Introduce LRU bulk move functionality Date: Wed, 8 Aug 2018 17:59:32 +0800 Message-ID: <1533722377-27020-1-git-send-email-ray.huang@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(396003)(39860400002)(376002)(136003)(2980300002)(428003)(189003)(199004)(68736007)(7696005)(5820100001)(8936002)(77096007)(2906002)(81156014)(8676002)(356003)(104016004)(53936002)(81166006)(26005)(478600001)(305945005)(2870700001)(23676004)(72206003)(86362001)(14444005)(53416004)(426003)(105586002)(476003)(50226002)(486006)(2616005)(561944003)(126002)(4326008)(106466001)(336012)(450100002)(186003)(47776003)(6666003)(5660300001)(50466002)(36756003)(316002)(110136005)(97736004)(142933001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR1201MB2500; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT061; 1:KcBqUypvF9PoTDaL+v34hkDQGhy84cgbz4+z1k7nrJqXRu99KcNVNDjUBlRe7P8n2FEXlH7YyPOyshfafzrrb85AKI2A6KShil4ba7UdHbkBod+YOqdJRGqafJL9UCh5 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b4fa26cb-a152-4e61-5aeb-08d5fd15aace X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060); SRVR:CY4PR1201MB2500; X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB2500; 3:FeigrvLutKBJ9QlTNv0EQOGA8wDCTg2drpJ1CRYCN8yCnj9XJTm7q2F1UQE97Gehet7JZSozvaQsnRcC/n5ESrydvM1L66kadfS7lknhuVz3kWJM0umrluPC8l2o6NyFnlsffuD1Tmc7+FgekrFCuZYDCO881HF5Op2idaM50RsgKRakIrPTsep4QpS+v8fMpoAnuc62nnErYVwFqumH/ui0gfbbQXDokGPBQqeRRZYWOy7aev7YuTFlOfJaFBgPgUk1a/giXf51gH6Ko3m9SPJ4rkBe1gPGgm1U0eo0VTnRYJ0Wh8dRYglp9uRdHg1J+iRTP2QX4FZ6IL3Y92gqJdoGy6XIr/X8I/tSdQ0VprA=; 25:FtcmtpXjxbLvcbAViM+hzI/X1NlVIllKmIi3ZrAOBm4QYI9sds9TX9OoKn9hcdhcT9hwiQ1CGeCCmIGEAahJqBTJitZSN+RHq1kT895nvS006IfeONUTm6YRxnibCCjgLyvSJaY460YsV+q3hRwbXlUGDEdoO2VOh85uG2u0DGEBhyY9Xuq5iRUWzRxbatirx6tNnYwwPKTvIdudSDJNjza6oDJ76qcxYCLIyifYm/A+uV6ZdR88MzYBEeoeg+L3dyzgwaLLEPOUBNXJAB3O3Ky433JTQ7ak9rttnPkwExDN+FQZdAzmCs2z3BLqzobchlCSM3PR84pcHKkaVQJh8g== X-MS-TrafficTypeDiagnostic: CY4PR1201MB2500: X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB2500; 31:y4wrL2D71sSOt4S8AI1W1jLS7JzGOZbmeS6absxU0q1pgNO3HX0SVMM5l9Miwq3Vq0sVtIFY3fhlLwZlnkcrRaVdoZBjakDJN0vaRwYtNdoivBqhU6+udBiYbAw03fDFu21oEQ9+IhGutuS4PmaAcoRNZEF/98vL83dyYc6haeksLWhYY8z5d3YTI89ni990OJ/Jm/HTuNlzl73r8O3eKeAm/0EcNQFqeJRZF9GaB5c=; 20:rRnibFtdv2uwNQIY7kIR2+1/9NJXNZo+jki8ei4UB7jKRnqIyon6TVq7BAME4njb62G8VOaU+u1DMNpOZXGmZSRKwglTA5pAg29qyciV5a0HbPbtkVsbwSQSwVuN5oW2AI7LFfS4ubV20H2wUKktN3V7ezCEk56nhJwekmu7KU9+KmjU6ANIRTiTMSuYoEkJU8DvZ33d1xsZ1dRH3t7fSicejmMziFlCdah1PVwQgNLTs4eYUDzqzCt2Cv7BeAppvB950iJYJX+5KSr0gStN5fbluee5gN+pF2clA/39HbWz0QXfSYSvZ2F8wGouZYTsV9ZnFviKeGwv9BS7fYud+YWNVFZiL6nmL1z10bageWF3fgEllFCV/D3BQ7xkv1i+sXmAyBzs1wX+BJIJJdPEpEMSA2aP2gET35LqY5njcIueXm04ig7QU/KXqIiA4yEUiSrNhMWTnhnuc1mlepPSK1BEK6TY2Ffn/bcCSbjeghycCmNI/ULIfSwiU8fA2BZQ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93003095)(10201501046)(3002001)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:CY4PR1201MB2500; BCL:0; PCL:0; RULEID:; SRVR:CY4PR1201MB2500; X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB2500; 4:nqlPaPzCFj9bai6XHTHmIaOocDC+7dS7fC9Bgj4ezqbNrvnG8GGPtBPeUjpbSrfJLwuSvgfk3+vxOQY2AiuA1NOoDoNOGWbKh2nazYfEwx7n70eGlYs9oUUKhijS/Ozt3/O7Ce3KUsPGdJjYgj6Y72SuR1/NxlyO8vRjVMmKT6n/12cS3Xg9p/+yLWy+Yc4tWUCrinwf9BA25PkdMOiN21WhI2HWoX4UMYX/CIUHYeDFTpOpC09YjX3wdThaicUedQeatuO2E5Z+h/Vk6z8TXA== X-Forefront-PRVS: 07584EDBCD X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BCY4PR1201MB2500=3B23=3AhAdA8?= =?utf-8?q?48WzqnFcF7eV0WIIBGPbEU91THuvAwiZG8Ut/oWTo+jWwIRv0pdzNXvd9HgQnO/Gt?= =?utf-8?q?Kv8nWG4LmrUGnnhtj5yex3L/rLr2oQy4k2/CHunfVsA5UGZKkgRxA39RcWv05erD3?= =?utf-8?q?nkC34xwjLAnP+YaTQVfyNn97dUGi43Qfutz9qThjp0iVJAP1Zd1j9sLr/QYa7SWuk?= =?utf-8?q?l5M1sNeICbrjV7s5m6WS47KSNxPQ+am+MIdrxddKHJf4JsthbCGS+HVcF9Keq4L5p?= =?utf-8?q?AXo+5AErDEdo36+eFv3k6nVNaYXE66pplL9juS48WY8jk9C5tGdkVyUvM3VA0Hjcx?= =?utf-8?q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dvw8h6UpX8vTpghuYsrKUqUj/N9uFxHCnfvzTN3LHI7s0kf8+Fr15ZkAAsemtFKpUhTT9n99HQ5Y3UGDkhjuke1wAMIvs0kVbVKmbS6crp/CqWEC8MJZ2UZEcQORTVb/c45MQ33Dx49JIeZ2/2GgvzYi+lFn1oHqp2lY0DfFoXOuE2FwpJkNf3ARr/QqZ3YdmUgKf+Pqim0TG9VymrU/4OUSQKqxM8uX/uJluIRtxUtP SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR1201MB2500; 20:0b3i6nhhhcuIjEpIFM/pnjFfVedQnp9mihMk1zu9ha9Kbac7mZfxwhHCahioEFNWdyaBS+E/freq0xmrXQCPnWobhTWoHLRAy15h77JLzn7ChNe8JhHGAR3iVEjO6/ELakHTz4lf6q1YZr12gwse98aTqlGlclj8Po3wcm26v83qkAhsaCv6qTwBtNj2N2gtTixgjihu3ka9fGpUxFcVVNVtI3l9kpiZ1d6ueAGe+UQNr2eMicEUZOlQW4N0kESd X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2018 09:59:44.1459 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4fa26cb-a152-4e61-5aeb-08d5fd15aace 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB2500 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huang Rui Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The idea and proposal is originally from Christian, and I continue to work to deliver it. Background: amdgpu driver will move all PD/PT and PerVM BOs into idle list. Then move all of them on the end of LRU list one by one. Thus, that cause so many BOs moved to the end of the LRU, and impact performance seriously. Then Christian provided a workaround to not move PD/PT BOs on LRU with below patch: "drm/amdgpu: band aid validating VM PTs" Commit 0bbf32026cf5ba41e9922b30e26e1bed1ecd38ae However, the final solution should bulk move all PD/PT and PerVM BOs on the LRU instead of one by one. Whenever amdgpu_vm_validate_pt_bos() is called and we have BOs which need to be validated we move all BOs together to the end of the LRU without dropping the lock for the LRU. While doing so we note the beginning and end of this block in the LRU list. Now when amdgpu_vm_validate_pt_bos() is called and we don't have anything to do, we don't move every BO one by one, but instead cut the LRU list into pieces so that we bulk move everything to the end in just one operation. Test data: +--------------+-----------------+-----------+---------------------------------------+ | |The Talos |Clpeak(OCL)|BusSpeedReadback(OCL) | | |Principle(Vulkan)| | | +------------------------------------------------------------------------------------+ | | | |0.319 ms(1k) 0.314 ms(2K) 0.308 ms(4K) | | Original | 147.7 FPS | 76.86 us |0.307 ms(8K) 0.310 ms(16K) | +------------------------------------------------------------------------------------+ | Orignial + WA| | |0.254 ms(1K) 0.241 ms(2K) | |(don't move | 162.1 FPS | 42.15 us |0.230 ms(4K) 0.223 ms(8K) 0.204 ms(16K)| |PT BOs on LRU)| | | | +------------------------------------------------------------------------------------+ | Bulk move | 163.1 FPS | 40.52 us |0.244 ms(1K) 0.252 ms(2K) 0.213 ms(4K) | | | | |0.214 ms(8K) 0.225 ms(16K) | +--------------+-----------------+-----------+---------------------------------------+ After test them with above three benchmarks include vulkan and opencl. We can see the visible improvement than original, and even better than original with workaround. Thanks, Rui Christian König (2): drm/ttm: add helper structures for bulk moves on lru list drm/ttm: revise ttm_bo_move_to_lru_tail to support bulk moves Huang Rui (3): drm/ttm: add bulk move function on LRU drm/amdgpu: use bulk moves for efficient VM LRU handling drm/amdgpu: move PD/PT bos on LRU again drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 24 +++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 ++ drivers/gpu/drm/ttm/ttm_bo.c | 78 +++++++++++++++++++++++++++++++++- include/drm/ttm/ttm_bo_api.h | 16 ++++++- include/drm/ttm/ttm_bo_driver.h | 28 ++++++++++++ 5 files changed, 139 insertions(+), 11 deletions(-)