From patchwork Fri Aug 17 10:07:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 10568565 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 76CB714BD for ; Fri, 17 Aug 2018 10:08:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 635FF2AD5A for ; Fri, 17 Aug 2018 10:08:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 569E52ADD8; Fri, 17 Aug 2018 10:08:15 +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 EB5172AD5A for ; Fri, 17 Aug 2018 10:08:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 962836E5DD; Fri, 17 Aug 2018 10:08:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-BY2-obe.outbound.protection.outlook.com (mail-eopbgr710073.outbound.protection.outlook.com [40.107.71.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 13E3C6E04D; Fri, 17 Aug 2018 10:08:11 +0000 (UTC) Received: from DM5PR12CA0002.namprd12.prod.outlook.com (2603:10b6:4:1::12) 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; Fri, 17 Aug 2018 10:08:09 +0000 Received: from DM3NAM03FT065.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::202) by DM5PR12CA0002.outlook.office365.com (2603:10b6:4:1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1059.19 via Frontend Transport; Fri, 17 Aug 2018 10:08:08 +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 DM3NAM03FT065.mail.protection.outlook.com (10.152.82.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.1059.14 via Frontend Transport; Fri, 17 Aug 2018 10:08:08 +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; Fri, 17 Aug 2018 05:08:07 -0500 From: Huang Rui To: , Subject: [PATCH v4 0/5] drm/ttm,amdgpu: Introduce LRU bulk move functionality Date: Fri, 17 Aug 2018 18:07:56 +0800 Message-ID: <1534500481-15123-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)(376002)(39860400002)(136003)(396003)(2980300002)(428003)(189003)(199004)(23676004)(106466001)(53416004)(105586002)(126002)(7696005)(316002)(86362001)(486006)(476003)(186003)(77096007)(26005)(97736004)(110136005)(561944003)(356003)(2616005)(305945005)(50226002)(6666003)(4326008)(14444005)(450100002)(68736007)(50466002)(8936002)(2870700001)(426003)(2906002)(478600001)(53936002)(81156014)(5820100001)(81166006)(8676002)(47776003)(72206003)(336012)(5660300001)(104016004)(36756003)(142933001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0241; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT065; 1:ky+7SN03LJJij9ZkGNzziFUsnH/hmJLuk50RAbgLBEqZn7dG6wFOI4xezrbkh+YqMbDIaSXEOFWEIU8fRlhyHo2MJMoz4hcZdj7ViTdZXpbYwXa1CdU9cuo6ceEIKG5d X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ad00ecf1-7ce0-4413-1886-08d60429551a X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060); SRVR:BY2PR12MB0241; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0241; 3:iMbkcQTws6aRu2OC10531JxNItlja6y4ANI0tIhfh7BadDtFzxDqoRwSQS0SBk+dKWbZaypI/HCnz+LVk1CHFcXXjPQNlgB10lltbWHa9Emd2iBkXtSQ1heq4AgtVwZk6Y/B2NdAKzy5aHf17pXX9BmrhPPXM0O3a40fD54bMeSJ1uCek2waAzVhSwQisjqdvBHURp7ukgj3WRgZfxniDIYee7Wh/iO4oq0uOquTJrL987Z4NS3HE6R1PJcqbLwB1Vg1ZmLXmSeTZKTrPc10dIxz39An/r7CmgKYiQXo7T26z/1GeNEZvD3mDuZYZeNinwFUiz0n7ShzVxw+6kxWRMJiciQEfrhlVp5V9peMZLs=; 25:LjE05Vvo/kirNcFC7ETozI3LFa2ZvHe6V9yOkHWwx3dK7lc5PpMlds1uS/hTFo/OekvAz4lj8lW9h8N2PHJBwvFQfKoKB6u7GNRBfXu0IpwOOqCo9b3A5vLfqu5AGJMlq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RVS: 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)(3231311)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699016); SRVR:BY2PR12MB0241; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0241; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0241; 4:+cW0SbQhISUKOa1ToLyFMhID+FqLBhNCTXEyy6jw95hpDRoQ52qhR8Y7b+nhlBeREYCbEJnt4UQ7YlTDOYg9jqPCwFNIuHXbW7g4+Rts0EjzGX89e2F+4WJKhh0+nmveWxWYgi/eND72uY6OFwHXJlhxQ3C04V3d8tT5cLhPdGXUpovQoFNL/UBFSHDR9C3twLIPTDt5ogAIit4geqwjCoBaydgXqwGFkBmht3G1Ca6U7hY4ivGfBTigOPXDHr8Y1QZRzC6lq76o3VbR/ViUbg== X-Forefront-PRVS: 076777155F X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBY2PR12MB0241=3B23=3AtgSqhHZ?= =?utf-8?q?al5CeP73NQz1hujslxyPzcvfK0pz077cIsuHqyq2wx4FYlQwte9ha7va+yx21FHXh?= =?utf-8?q?IxxvgcYlb1Et0JvfhUyXVpFtLDqKr/kSjfT4vUwseoEOpJKYHVdEJ1GkvFhoW8o2a?= =?utf-8?q?wqZvxPHPkR5ZQiXQ7/rNro7GHthLsYmpWAPn0g81vcPY0rgVWO3yNVNZnNhR87VY8?= =?utf-8?q?C1F31q8DHvEFNTWl/tY3b6xiPyQLNs2kqafWG/VUdZfYrxN6pDLHUWnd5hRWArJvv?= =?utf-8?q?Q/l38pSFSxPrZG524GuNVlx0RJ4G5q2GxEp4Q8JLTjv44C/gyn7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h/GFyIheQ8/xUTTAfyI6YtRz9fd1orfBy57Sh7BTFj6bMUpFSrt/VjAWujyLiu8L9Xxqm7Rk4vHLDPrnbctjmyFj0VqNrD6+vD32P8OwZxfNGalMp+5OIJJWoKZSjjMZbsNPTQ0D82SIIU9ZwoQMnPNugGAaePwkJYFutvEmoceAjB9lBu6AI7pRDuyiAuhrKcHZec7cEG8J6k0IdiiE SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0241; 20:M5IdmkxWS6hGLz1KOBmVZJTel2YeYFZ1RBvE9eP3N0v04s5l2i+c/0Kh+P9Sgh7S+kC02Kgy/xRtrrL5Vl4dkUDdIm/Gcoo6URklbe8sSfIPhDCjbiMg3crB9HukAkdWVizP3MFiK4jToWHa5ZHMt9g4mnRyE5Y2H1X+LwOuOF3Cu7ZM3AgCmGXAEXb4RYjtHgrAORMtkk12Goh8vPyBmhFjdwRGPJ4Lelc3gI+Jk2xNvlrF1hWj3dgF1X0jYJP7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2018 10:08:08.5728 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad00ecf1-7ce0-4413-1886-08d60429551a 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: "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. 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. 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 (v4) drm/amdgpu: move PD/PT bos on LRU again drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 11 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 73 +++++++++++++++++++++++-------- 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, 196 insertions(+), 21 deletions(-)