From patchwork Wed Aug 22 07:52:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 10572655 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 5945413B8 for ; Wed, 22 Aug 2018 07:53:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44E2B2A28F for ; Wed, 22 Aug 2018 07:53:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38B7F2AB4F; Wed, 22 Aug 2018 07:53:28 +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 B7D812A28F for ; Wed, 22 Aug 2018 07:53:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 16ED889FE8; Wed, 22 Aug 2018 07:53:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0050.outbound.protection.outlook.com [104.47.38.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id 35C0D89FE8; Wed, 22 Aug 2018 07:53:24 +0000 (UTC) Received: from SN1PR12CA0076.namprd12.prod.outlook.com (2603:10b6:802:20::47) by BY2PR12MB0241.namprd12.prod.outlook.com (2a01:111:e400:585d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.21; Wed, 22 Aug 2018 07:53:19 +0000 Received: from DM3NAM03FT022.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::200) by SN1PR12CA0076.outlook.office365.com (2603:10b6:802:20::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1059.19 via Frontend Transport; Wed, 22 Aug 2018 07:53:19 +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 DM3NAM03FT022.mail.protection.outlook.com (10.152.82.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.1080.9 via Frontend Transport; Wed, 22 Aug 2018 07:53:18 +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, 22 Aug 2018 02:53:17 -0500 From: Huang Rui To: , Subject: [PATCH v5 0/5] drm/ttm,amdgpu: Introduce LRU bulk move functionality Date: Wed, 22 Aug 2018 15:52:50 +0800 Message-ID: <1534924375-5837-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)(396003)(346002)(136003)(39860400002)(376002)(2980300002)(428003)(199004)(189003)(478600001)(316002)(426003)(68736007)(2870700001)(561944003)(8936002)(5660300001)(104016004)(336012)(86362001)(110136005)(106466001)(2906002)(2616005)(4326008)(5820100001)(53416004)(450100002)(305945005)(105586002)(476003)(23676004)(47776003)(97736004)(486006)(7696005)(126002)(36756003)(6666003)(53936002)(81156014)(81166006)(356003)(50226002)(14444005)(50466002)(72206003)(77096007)(8676002)(26005)(186003)(142933001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0241; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT022; 1:LX5OsQFl9OIyghG9BCUIaUyzlJTD/d3aSYR5pIz1SYKwyze7IEKVd/SXJDtICP61bY8TTW58UIqkWuebdPuswO25U/uNj/e3caz/Aw1pIMvHAx1930gtBRQ/azdoF5rf X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 146ea430-fda8-49a4-1942-08d60804533b X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060); SRVR:BY2PR12MB0241; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0241; 3:6d89MP6iacTbOR1t7TE0fu5dWn/pbNj8hzp/MxDf/S+VryjJ0nzE1G2/Gt0ozQ++EroZbl7AQZ9O56bpOJEe6F4pVKLzRQuGj/R4DB/OUgrZs+9JZjQ47HBC9h22zTr4x/rYlnyqEKYQUi6zoRFJSKuFZ0EAfWvXc89VB8RWX3PLwqMiBm+pqRmsFi0WEYxdAGSVliusa5kYHidlJE4ADjK+VDHAiai3bmg6e9U0MNXBYbXCcuDyN0FzlztKok91H8wrx87+JnvWSqRwZQjTzIQZ69C5B39Jq0KeHOepnD027lsRLl59FFh21sIo2WoYs8+Fe8oKl0EIshOgbshJcHKHb5bE1C0Qcz8AYPncxmc=; 25:yOYVTV2sE5RN6Vof91FTulLS2OqTSSt7Ir5NBjPWV7xIDMUZ10FtSuSed3t//lUiK9KPeoGInbaruKsoCJcUEX7JnXfYStJ7Ou1ED2/QfweyucPONoT+yJle+tJhjP9rHyH8z0Z0OPQrGGSOIXrSIHxEpBG38lvRsT4Dpz6Ln0v7yeB+4pPRXdnKRLpOc2t+z5w41oMQMRWfkedkkRtItbLCT/SRwuT9Mwu57WqS3jdx+o92vm+0e32cOlZz3TlUjmwQg5uYjW8L8SWmHsigH7QK7Q1+VvvqgGDYnFRlgbwuIsWbOX2LF1sphDrAfz0DC8Gv8Q8ItyzMOSekUnYqlw== X-MS-TrafficTypeDiagnostic: BY2PR12MB0241: X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0241; 31:a4pDHhKNENZurIQhMVHFnhr+GIs/xZIe56k0TpNNObdZpIKtFLc91zksuHypDInMABMpEUEjTqYFqPyz4T/sG85eWzJ9zRkueCvJap+HJgleswrkIpoXinR0wXdkE2w32/3+5z1PMjcWtdEAMphCcZQSq7JuJUWWDSUifdfoTp2M0pMTIxcm5Xmg6RgqsQIH63BE9JWnbHcSgIbbK/LypcnopYv436B/6CxTi5iJcko=; 20:nzHCt+kLaybBwR/XdI+SCX9Xr+jVNqCzNLKrP74sGDjybiVwU0vgfjMFu0lQMlkLWvJSP9Z8mhvlItdVS6R1cWQKk8PcWHb9zqNtLVgHgEhC7sEB4gvsiBIEKKCD7EgCkALM8kCqQWZDOA/zie0dc15XYnbL4QpmX0n35b3IkAQ8GZC/gaTKQJIFmzTaZfF1j1V2eppX5RvkH11scttRhdo4R22Ya2CJSy+idb/DNpiEwLel0EoCdCOAJ/Z5unLGZnfwgZ3aLFMxuHLyS7cQGCdgCNVrvX1FCawpEh10X3tGab8a33wbLElvHIcopIO4CG9xYDbGV6VoPUb5PgRDGOn+fYrD8fQriqe80/YShD9IGaa8qIg8V/Bl3nDIStLC6LjeW2OEv+uOitSUvpD/tnbUPXxYtCon6Z7p+KNG42w8yw3TE5zs4vvREm2sL8gyC90wBE1lpxi1tLj0LmGro1fE7Ei8g6t9ARjTru+lyPKDCHvXNMRxmoxRTOyzI8ve 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(93006095)(93003095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016); SRVR:BY2PR12MB0241; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0241; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0241; 4:dIXeViP6kKn+76zqKXeBYzwfS6NFfwLLIFQ17JZfmRZIT/SbM6thCIw+hoIu5LbCM0E5jNBO0zfERRtOnSt0hEgLcV4BSaRWTQm9AdcJ6GGBuuuHX9TS5kNkAgDbzIr1WUEgFp3gNijEtEpyZDhzG1GoFCiNGKfK4Jr8/hzNLX/8/DQ+TrSKBxUG7hK6X7mBeBfH8rmPLUpCj9xDD+WS4cS+hCBPftz31D9OAAFAzw4YWkTYyuFrhTUjtU+UCEGuoZ4pKKykww38GWC8gYCWng== X-Forefront-PRVS: 0772E5DAD5 X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBY2PR12MB0241=3B23=3APPZMWtt?= =?utf-8?q?i8LLrmSY2bZTjfO+HPAoBr5XaeW+LMXaOEIJGJe9hOyPSbJsBdlZ23CCRHIJc8Nwa?= =?utf-8?q?KiqQrK4HQVtLp+kNHOA+iwm73C+HAOHJDrI3dwEzSl7WnO9w/NLLAo5KSpHsRv3bu?= =?utf-8?q?7bMNXbTzEACa+7EvKeOQN3g5RpXPE5P32W1q+KT/qFVjC20o2qXDJuYqe79X5U2RQ?= =?utf-8?q?2NOlWVvMaJFVA84/ejFtdKDlAsrzCTwrnrv6tUNQxsquvzkxC784X48ZXvuFfWhzd?= =?utf-8?q?xsTNp4T2hOAsaCQoqg32UdclNpYs1Vq0HqWsQhP7XVic9EuvdzEkBr4ywQv4MWt0f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+LPiVczO9ajvZEUxQz/Yx3MLhLmG0VMeJhamHPzrJOOYASNrN+0/e5rug8GkU6W1n1VPzHfVBipxtbdPD/S+6fNNQbPoYWEOAnX4OKx2/ige3P9R6Xwet19cs7BgzGk3IlFPYAhzktL9oTg98FJrGDuEJZfpbU/dGKakWU2oTKCNZYAWKkumHjAU+KOBcqqvDPLIUBSLVaskR/ezDPcj9kylBXYbC/ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0241; 20:iHknAMSnLqQKyKlc0HPTpwxB2wgDcCUOQQkEK345535wYAAp541UcpXYIm1MzclO2l1aaScn0ctY2v7awg5oP5fiaoJMcewijZhCi9UkKUjaCJ2uXgvl/qyfKBBMjkV7FJxYUVZvVGyE0b2DIwUGoHJ2mXvhSy7+OqW/BASfYxViPPq0EjELI3cJG5SnrOmlXINPjaj9j165boBrlbHOupne8eq+Dkigj++MQWDiKZ7ZJmV88oIyQu2OD382YB0c X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2018 07:53:18.7058 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 146ea430-fda8-49a4-1942-08d60804533b 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: BY2PR12MB0241 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: Commit 0bbf32026cf5ba41e9922b30e26e1bed1ecd38ae ("drm/amdgpu: band aid validating VM PTs") 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. Changes from V1 -> V2: - Fix to missed the BOs in relocated/moved that should be also moved to the end of LRU. Changes from V2 -> V3: - Remove unused parameter and use list_for_each_entry instead of the one with save entry. Changes from V3 -> V4: - Move the amdgpu_vm_move_to_lru_tail after command submission, at that time, all bo will be back on idle list. Changes from V4 -> V5: - Remove amdgpu_vm_move_to_lru_tail_by_list(), use bulk_moveable instread of validated, and move ttm_bo_bulk_move_lru_tail() also into amdgpu_vm_move_to_lru_tail(). Thanks, Ray 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 (v5) drm/amdgpu: move PD/PT bos on LRU again drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 10 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 68 +++++++++++++++++++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 11 ++++- drivers/gpu/drm/ttm/ttm_bo.c | 78 +++++++++++++++++++++++++++++++++- include/drm/ttm/ttm_bo_api.h | 16 ++++++- include/drm/ttm/ttm_bo_driver.h | 28 ++++++++++++ 6 files changed, 186 insertions(+), 25 deletions(-)