From patchwork Fri Aug 10 11:55:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 10562639 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 D41671804 for ; Fri, 10 Aug 2018 11:56:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2DC52B9BC for ; Fri, 10 Aug 2018 11:56:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5D8F2B9C5; Fri, 10 Aug 2018 11:56:13 +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 6F05A2B9BC for ; Fri, 10 Aug 2018 11:56:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C11C86E8D1; Fri, 10 Aug 2018 11:56:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0060.outbound.protection.outlook.com [104.47.34.60]) by gabe.freedesktop.org (Postfix) with ESMTPS id 460E06E8CA; Fri, 10 Aug 2018 11:56:09 +0000 (UTC) Received: from CY4PR1201CA0015.namprd12.prod.outlook.com (2603:10b6:910:16::25) by DM5PR1201MB0121.namprd12.prod.outlook.com (2603:10b6:4:55::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Fri, 10 Aug 2018 11:56:07 +0000 Received: from DM3NAM03FT030.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::201) by CY4PR1201CA0015.outlook.office365.com (2603:10b6:910:16::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1038.19 via Frontend Transport; Fri, 10 Aug 2018 11:56:06 +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 DM3NAM03FT030.mail.protection.outlook.com (10.152.82.203) 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; Fri, 10 Aug 2018 11:56:05 +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, 10 Aug 2018 06:56:04 -0500 From: Huang Rui To: , Subject: [PATCH v2 0/5] drm/ttm,amdgpu: Introduce LRU bulk move functionality Date: Fri, 10 Aug 2018 19:55:54 +0800 Message-ID: <1533902159-14232-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)(136003)(376002)(39860400002)(396003)(2980300002)(428003)(189003)(199004)(97736004)(36756003)(561944003)(8676002)(72206003)(68736007)(105586002)(53416004)(106466001)(356003)(81166006)(81156014)(47776003)(450100002)(4326008)(8936002)(316002)(5820100001)(305945005)(110136005)(6666003)(50466002)(5660300001)(104016004)(50226002)(26005)(426003)(53936002)(2906002)(478600001)(2616005)(2870700001)(476003)(126002)(336012)(86362001)(486006)(77096007)(14444005)(7696005)(23676004)(186003)(142933001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0121; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT030; 1:TQcIFr7G3IzaKoH/CoQnVVsqWcV2+9mGQvcBzI4vfalDCICm2pipnffDUF2L23zMlKfxbo58cI5pJEwD79UB6eMiqF5MwjsYEqW3wVSgWuRjdEnzuZnXz9rUB2aTHhTz X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b3d18c7-fc13-4c3f-70f4-08d5feb8414d X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060); SRVR:DM5PR1201MB0121; X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0121; 3:gIfwme4UWbJdenazCksptGgzHHM4XGRbD43RDG8yZuNQkCjJp/Fe8kOwOHS+iKUITTOUOZUIeRKK7pSgM5DCitIgRqBfKXnWfmQLQzeSgjKA72pLm2rB6JP8H6HzFo1l5u87x4BkwNCGNywfT2ANkYiaI2ewxankzAn3/+XfVcqAZlG26N99odmoRZ6c7WXjupXAkpOz2so3ZBcPtjzJ4Zlas/BrwTrg27shvdlbj1NEqpPKcnCJ8fupZJQ8Uatc+sJNOmnN2XkTN4mk6a+1bxJxAr3QV+xEKM8zimxkTIa4lbn3dNb9A/PVUU+GDOn217bkugjzrUfuV9k5D9N7mpsi0yOWx9E4gWUvUmzAujw=; 25:1ITekUqLeedLI2tCIBIdEaufOaT6fM/a3SLNrpCIOHtwC0ifvTM82w0nem3GRWg9bWyKmYXBTzx/72p/zJtW7RnS0FPE9ExBth4HI956a17vM0HStmShGhfU5Zna8ngu/l0+abCmdkGyX95mcc/nedOjpuF4PJvTDdxAoOc2Upo9G+4f9z9FRleI02q62WRI5Vr/4YvZiV3Es750nskZ6erxe8QPsKt7KTVlOHY6QM34hNWij9thTFZre7cWHUrOSla6pYd2tS1ake0gY7lOFyJl2K+TBqOlUa3x8SKVrS9HQICfeajWfaF5LHIvdItiiGcTcqHZ8qrO0priiBBQCQ== X-MS-TrafficTypeDiagnostic: DM5PR1201MB0121: X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0121; 31:tYMCTtejcipZZPPe+T+6m+T1wVoZGPGy+8dvpz2iBKdag8JWn3/6JrHaW4nPrLu9bWlc1KZFGdRTnRbDlwlmyflPBFNiBqNRIXKHr9OkDCVVz6AamZ1UNZgqLDdNFE4/aJRlEx460Rlaszj1d4V5EhUkiqr7VIBFFMe3L0D/L59O0uSyCnBXyf2MIwpDNPv9uJsCdU9SrbboUO8JWtYSznf1Z2hWlErmqaXpaArGsxo=; 20:KsaDf2pAnIJIe5vGqy/Fs4vRSG3vAtwj0C4NgATQcPgcwMb4jGOmBF4FxhAFZTX79bZvO+ZDznrLXBGefjF0aj02iKf6bRakXtdIEiT5AdSfCO0FvYW7hvoF2WUyRgyfDDBLG/icOfsuskR2TXNfRZV20jwLgfzA51s2Nk73rVWgn11eGQkb4X9SZ0D+Ixt8UEyWOtBuukmIqbuX8ZSAFhVRC2m5L4q3RfD5D+ev5/UR6qPm1cV9GC9nneEmt/1tKRKHeHjgZP+m/HncWlFUMASBJwlYocysx7cBnXbzLuDUHCJo8b+tsuTwDbS1wJFELWq3u0fBYg9OmzdL443Y15sk9r5+dhIbJ42Kjv21oetXg9PO6uHC2QAjJ15XjbI651gepZGdKSvs+FCstMY4o+g8ZnMDcLC5gfM10dj5clTLaym4GisrzVlDgiM28JytY95zW3d2EzBV6vALH33vB51z7Njdn38BXvWXUa+hMzGZqBMJNW1moXmefRFkHwVP 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)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:DM5PR1201MB0121; BCL:0; PCL:0; RULEID:; SRVR:DM5PR1201MB0121; X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0121; 4:I+bQuqSsOS/f3PuO+KP7Cm7Ujh2TakQUCBA5NyUFL1YkpPHp6PS7BblajUqa9N4zeU14Md8IQmpcmkYZsLA5Wwlcq3IBVPaZNsvxyi8ZLcKbwQgT+b6xYB0FlRdgbG7DeZ4gvIjukhfxL09m43m1vrfcdYaDHNM28r5tbZsT0klZeaXpZkANjWuUSth4I9inIf/jIXfHOhGXoQTrJFNU3SvvLhGDxpQotGFFw4pt9HJqNAmVHGEGeM4kmSIZPhYhjfCzO3mxLKf+4WIn6A9FcA== X-Forefront-PRVS: 07607ED19A X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BDM5PR1201MB0121=3B23=3A+8JIR?= =?utf-8?q?WEyOGH3nwmQvs9ymSi+PO5Kff1z3QmjOquYTfJ759xXpDyXawKt5llLJXiMTrH/P3?= =?utf-8?q?TZrZQ7z+Mtw9VPPDJkJIlQQQlXcvrxovIJCCCerjs/715R96bpSqQmL0mXLM/2Cux?= =?utf-8?q?QWBAIvAZ9OIF+smU8rfJI8LD15pVq3ZOe1bZqKA1BXDd0821Yw8k3J4NbuC2Gxged?= =?utf-8?q?Beh3Xw59BZcCmVyhGd9F/ikyIXhrCoGwZMBpMVTacmZIB71UrA+rwOI7vQjCT6bi9?= =?utf-8?q?saNkpVvqHMAswDyos+A1VXCKfL5TRsVZ0pmPm0ym3ukGAm1kXLbtAgV30XnL4hWsB?= =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lRneI1iG7L9ncZRGiTG01LLj1EE4yBwdVz3bMmIOCOHGUQ6xjRmxnfPhUgsQp2uKgXcYJjW5GBPsHO2Q5Pqv5ryFAkdJLz8Sb/OdALieC4ukccFLKIEILByh5/AEOl9cb4n37hUGNDszjswxsdHUhHthCcnkg9gE6xv4oBK3S73BTHuu4BwLssI/MJh4e+uTuSPmM0FJBlGIuYBY SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB0121; 20:rxJ0LyDOwFIfPkfPNerQ94vzlO9d8vRAy4hosF1KH6ufvvA/ih1ZHyzlLsMAd1CGBVUvy2rRyvPCJBDePTzuz9ihAvfa2mhzY0EcW4cRnLfLDlfdrCywRwGndmi1ed8ezT8/diVegyVaVsCQSRCBoxqCDDeB8eI9W2Ezdm+G8NQZAdVReZM+ZTYwYpjs87qnEkiH6NT1Sz27NvWJS14p6vdA9MwmqQH87FzFZAdfgAsm2pk4ZWLWUSyHNQmzzHpa X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2018 11:56:05.8012 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b3d18c7-fc13-4c3f-70f4-08d5feb8414d 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: DM5PR1201MB0121 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. 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 (v2) drm/amdgpu: move PD/PT bos on LRU again drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 77 +++++++++++++++++++++++++-------- 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, 184 insertions(+), 19 deletions(-) Tested-by: Mike Lothian