From patchwork Wed Aug 22 07:52:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 10572657 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 8B241921 for ; Wed, 22 Aug 2018 07:53:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EBE72A52C for ; Wed, 22 Aug 2018 07:53:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 701D92A28F; Wed, 22 Aug 2018 07:53:58 +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 08AD62A28F for ; Wed, 22 Aug 2018 07:53:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3950899B5; Wed, 22 Aug 2018 07:53:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680040.outbound.protection.outlook.com [40.107.68.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 05E2C899B5; Wed, 22 Aug 2018 07:53:56 +0000 (UTC) Received: from DM3PR12CA0085.namprd12.prod.outlook.com (2603:10b6:0:57::29) by DM5PR1201MB2505.namprd12.prod.outlook.com (2603:10b6:3:e9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.14; Wed, 22 Aug 2018 07:53:54 +0000 Received: from DM3NAM03FT065.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::203) by DM3PR12CA0085.outlook.office365.com (2603:10b6:0:57::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1080.14 via Frontend Transport; Wed, 22 Aug 2018 07:53:53 +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_P384) id 15.20.1080.9 via Frontend Transport; Wed, 22 Aug 2018 07:53:53 +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:52 -0500 From: Huang Rui To: , Subject: [PATCH v5 1/5] drm/ttm: add helper structures for bulk moves on lru list Date: Wed, 22 Aug 2018 15:52:51 +0800 Message-ID: <1534924375-5837-2-git-send-email-ray.huang@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534924375-5837-1-git-send-email-ray.huang@amd.com> References: <1534924375-5837-1-git-send-email-ray.huang@amd.com> 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)(376002)(136003)(396003)(39860400002)(346002)(2980300002)(428003)(189003)(199004)(72206003)(104016004)(450100002)(97736004)(36756003)(4326008)(50466002)(77096007)(186003)(2906002)(426003)(126002)(336012)(446003)(11346002)(68736007)(476003)(2616005)(486006)(478600001)(5820100001)(50226002)(2870700001)(106466001)(105586002)(26005)(53416004)(81166006)(8936002)(47776003)(7696005)(8676002)(54906003)(81156014)(76176011)(316002)(53936002)(86362001)(356003)(305945005)(5660300001)(23676004)(110136005); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB2505; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT065; 1:JRBWN6K64GlO/pT0zgMmVxHVsaam/3fuEGWMuPlAWBsQMEqQk14CLJI65OYOwTZokvAEHA+j0miiC2rR+R8QDqjckfAD1fbfy4tfBHp6MToGNxB6OXfe4BwgzTXchtVD X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e92e6786-b098-4a8a-7185-08d608046810 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060); SRVR:DM5PR1201MB2505; X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB2505; 3:MwHBBdlCB//MhZCBo1DFYPKaynZDepcDA0pCvbAYhdgm8bg5fkEc6rcoqrEJI8VQ4ZtwVMPmUpBuA6JwYpcNpPWJ9EWd8L4/zg1Qu+ITNzwGMTQImQSPawzRgybnt/yOzZuBmIdUdtYFXguKHuC+FR4E2uVIYVGz8jheQVML8bfog28ZICPSgM0Iw4r85dezTJxBfI3v1+zkmP8L11h+FnHK3z8qBv3jEjJ0bY8YyVkmPAlqqUe+7GnohUQ3DO5IMNjfJrCbAeRFpIs/HaMvdUHEUYg7A/VC5twVRmdK7wCaA7PsOPaMmawHXa2risK9HCnpOcLi0t4+PJ3UIa/tvtqFUQZbGmm7YLVvo4GNIbk=; 25:hex9RFNr1iV/8m53FZvpiADus0Im68MRpxX/GorfGR6ontM5KYmedo5IFkN4XkGUFGUiQ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LVVMkzF1KEtmsStLP94H X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93003095)(3002001)(10201501046)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016); SRVR:DM5PR1201MB2505; BCL:0; PCL:0; RULEID:; SRVR:DM5PR1201MB2505; X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB2505; 4:ofVv5N+qfYN0NzHG1pD8D4/De3bxkY2vBWSdIKJkq5yK9umknXAQ6CKOg4EN7k7xSVwk5tbrU14qxpAiPVPWInfF4NgdKybQUq1sg0IgYBl5zQwobnLCLVx/Fo66JRxCOu5ZZ8FuJn/owylEVqjkDzEb9EZFIZvbVEYDY2T0O5HbfdKNczwDsBCLEySP3cb0kTcbnjb/OFw6O3PAs13JsYcaebkVAV+X2TC3qE334h6nclFQUcUMTpQDWnQB7avYGBsFCWfEzgPaBzW5TCmzMR5NeMkd4m7gzb0ZxVWmmgYktG6VtZwDFm5jOXcMM4Q4 X-Forefront-PRVS: 0772E5DAD5 X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BDM5PR1201MB2505=3B23=3AeN12l?= =?utf-8?q?w9IY1M2kCjL0EOiVOsbozQxnPiBPQz7Jrvjv+hpHQUMzH1Gipw6yA8K0P1dT+qX/9?= =?utf-8?q?xviKZ/iKGK07i4NnQZ3fpEOOn7olouEryjNuRRv629rIWSR1AvtRIz9rc760Z72xJ?= =?utf-8?q?We2UuPFLFKON+YGrbJmBT26C+IbglsbZYhQQaNbtEqgi/HejKg3K+zhkJjbgd5xRk?= =?utf-8?q?gqMmS6wIK7mNtt6LiMLXLT6LuyU30NPcjQgOB6DDp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ngIVGfzBUMfaDSrHXQX2J1CDW62kYGjM=; 7:Shh9+7h7dje6500RxGHhdx0vnuhLTA1MftOS/FCEItb1klmSHbGLtadyYMmbP12WfdUlrWrtWsWLsQp18A1hEb1i9hXZfkBM/egkhw0pUq5pil2FjTreTcEsl/kfJlWnDMYQMLVHwg4ZAMBgZq4hnX2cD9iBdiozkd/AhGh3fWIYGk2PfI+5g6Tdazjr3NCYTSCrdarJV9vxLaqjOl2oWE58uiD0eug9y7vYnJuxyDsJJBPBmBEpNOEJoj4U9Bbl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR1201MB2505; 20:yph6uVTyX7T9gNQ8Nyo/8snfdjihSAxKBiSuK0zI7pTHt6HCSbpURgwjQazP4m+Ian3BGewD+4yYEHvexYiS3Yko+CjkwxMrfSjDhBjYVolPTQ9ObCSrDqz7sc89JuNHMvn+iNV9U9twNzG/K9tXdifTIWOkbeqljlFMIYJoxqpfDFyfGsjJKW/D61hRLH5CDnpUDQ79ihuL6EZgVTdFwJDkInB4nPXOwi4GpMbNm5HRaQLRPcYwqcMP2alwWsfb X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2018 07:53:53.6584 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e92e6786-b098-4a8a-7185-08d608046810 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: DM5PR1201MB2505 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 , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Christian König Add bulk move pos to store the pointer of first and last buffer object. The list in between will be bulk moved on lru list. Signed-off-by: Christian König Signed-off-by: Huang Rui Tested-by: Mike Lothian Tested-by: Dieter Nützel Acked-by: Chunming Zhou Reviewed-by: Junwei Zhang --- include/drm/ttm/ttm_bo_driver.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 3234cc3..e4fee8e 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -491,6 +491,34 @@ struct ttm_bo_device { }; /** + * struct ttm_lru_bulk_move_pos + * + * @first: first BO in the bulk move range + * @last: last BO in the bulk move range + * + * Positions for a lru bulk move. + */ +struct ttm_lru_bulk_move_pos { + struct ttm_buffer_object *first; + struct ttm_buffer_object *last; +}; + +/** + * struct ttm_lru_bulk_move + * + * @tt: first/last lru entry for BOs in the TT domain + * @vram: first/last lru entry for BOs in the VRAM domain + * @swap: first/last lru entry for BOs on the swap list + * + * Helper structure for bulk moves on the LRU list. + */ +struct ttm_lru_bulk_move { + struct ttm_lru_bulk_move_pos tt[TTM_MAX_BO_PRIORITY]; + struct ttm_lru_bulk_move_pos vram[TTM_MAX_BO_PRIORITY]; + struct ttm_lru_bulk_move_pos swap[TTM_MAX_BO_PRIORITY]; +}; + +/** * ttm_flag_masked * * @old: Pointer to the result and original value. From patchwork Wed Aug 22 07:52:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 10572659 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 E101313B8 for ; Wed, 22 Aug 2018 07:54:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7DB12ABB5 for ; Wed, 22 Aug 2018 07:54:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA3682AD5F; Wed, 22 Aug 2018 07:54:23 +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 1E2572ABB5 for ; Wed, 22 Aug 2018 07:54:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CBB526E035; Wed, 22 Aug 2018 07:54:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680055.outbound.protection.outlook.com [40.107.68.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id 436596E035; Wed, 22 Aug 2018 07:54:21 +0000 (UTC) Received: from SN1PR12CA0080.namprd12.prod.outlook.com (2603:10b6:802:21::15) by DM2PR12MB0252.namprd12.prod.outlook.com (2a01:111:e400:50d1::21) 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:54:18 +0000 Received: from DM3NAM03FT027.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::207) by SN1PR12CA0080.outlook.office365.com (2603:10b6:802:21::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1080.13 via Frontend Transport; Wed, 22 Aug 2018 07:54:18 +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 DM3NAM03FT027.mail.protection.outlook.com (10.152.82.190) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.1080.9 via Frontend Transport; Wed, 22 Aug 2018 07:54:17 +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:54:16 -0500 From: Huang Rui To: , Subject: [PATCH v5 2/5] drm/ttm: revise ttm_bo_move_to_lru_tail to support bulk moves Date: Wed, 22 Aug 2018 15:52:52 +0800 Message-ID: <1534924375-5837-3-git-send-email-ray.huang@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534924375-5837-1-git-send-email-ray.huang@amd.com> References: <1534924375-5837-1-git-send-email-ray.huang@amd.com> 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)(136003)(376002)(346002)(39860400002)(2980300002)(428003)(199004)(189003)(106466001)(6666003)(426003)(104016004)(2906002)(23676004)(54906003)(336012)(5660300001)(110136005)(4326008)(7696005)(76176011)(97736004)(476003)(446003)(50466002)(11346002)(105586002)(450100002)(486006)(2616005)(53416004)(126002)(5820100001)(68736007)(356003)(72206003)(8936002)(77096007)(26005)(86362001)(186003)(478600001)(2870700001)(14444005)(53936002)(36756003)(316002)(50226002)(47776003)(81156014)(81166006)(8676002)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0252; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT027; 1:pZpPk41BGfWaQEZbmQpW3Tl2OHR9Lyqtl45i7m5lb1bflBgA0mEp/w3yvrimKaBpTDRf0RWVG+hz7XnaHD+LGslSQiRfl/7qTTHyxex2eW2hXCWASYgrYQ4FtuT/pQ+U X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d000db24-ea1e-44da-9027-08d60804767f X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060); SRVR:DM2PR12MB0252; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0252; 3:hVfsmac2xeTfp+kb2b5TEKZsEHk1qJFXg7Fz/xm/ZNP8FkUoYRI9IK1ZCRAxYFs5ccMRMQLPNWHRUOhwaToJMJTIhltWI9AZ+Jr5juLKRr2nlTPW9ZdyWZTmTXzCnoI3AaubC7RzScCA/vtjfr+oGHsDIIV8m+LQK7Z3lFk/eNJ7cFr8toEM/1fRMWbs+NlEaM3dKKIug5Rkx3gfV1cDsul0/mkFz1tirAVCga1YoBG5xM4xNLveq0tjzwJ6P0bjlwwgE7ijPdva6u505SSfXLX76EFQYS6bNZEKZ9aOnwsrgAUM93qBPIyF2SqsOlrMOgLmZFqj9g+KOFUXPy9XR2GeR9wEpTIhXdWpvLDIptI=; 25:tg5DPT3nsS0lB52wDOtNrEdiUzYyMBJKL6keRTPel90Ir20E9bh9WhfMYKvExiRA1cVPpwf8BPWjRuKPZfkqzHLNVKv6mZdkiB104vCLXO0EcEvvpHOjP1hcMYUlQPHMxmokIFm/ZrUwkbWLy5ZHWgJCmMAS7+keYduYOGZOSzRi97kN1QwAjivewXk7Kpye0szFVm1e28r3C5u41MGbsyIglCsAQhqbLOKHOO2/9GMdKt6A/KLfMp1KsyjYnKS81aboQ0V2BwxifvE88mUe2bOBeo5W+mU3U+UuL0ECqW1K7Y2lGBVBuizv2HXZydITtJHpz8xBRVRyjUSdmFruSQ== X-MS-TrafficTypeDiagnostic: DM2PR12MB0252: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0252; 31:USg3CKNKYIwz4L2DirEVZLFjXSrhxu/635FoTt/uAXEnFoAdp+sQ7GOBaYhBEPqJPIEOUAsBjQQAZU4UG1VHEmC5GSnsrw74QN9pHhhc7gVSSO4C68/s3/odxEQ23TawIYEljkXsvkxXrxDAdMkLvrVJ7dYPitryC4m+xSCRrNyitp6ptY/183O+ur2fQ4eSSEa/HuEXS261gxZcsjGeotXacctS5mj+zGL0kz0fZag=; 20:MCWuwP7v7uW7ERVytO8gaJQXjRjmpEj0wJ+zXiBujN/v580R6RRC5bk05m8EAwRXJpvI6EhnE5r5b2PIdgxIzXzA0sDfuGijD/bBLIL+cFVPkDkcUD34EJaE2RtYxm6QEd4ZdJCF85I1fTeHCjNZC4eB4M0z19qd5tm9KHonIro+alO6/Y01ZfoTuX88YcG/LehXWfn2UgupJc+nhnEdedp+W59sNInXDIa0rTWMmIs7eGkI8cpQXbw4zLU4AhfdbU30wG3XxqLMLr/d4XYqY0/rfVQICJTLH3d+rZv2sr+eqPXKoIuMdXN/TIi2daUg0mDB630p97jps62C6/2ZKwMLIbILE0lh1bI1xr/sfRpMaYUVtGP9wHLsVxxhOKGxq2Kcexk7QoumoPkeWezobpWZCnGqDlvqAfWHXsMHuXLg7NwnOT21eiqcKrzEh/TVjT8ExryU3g/yrc6Xdzkr11KOqEudDqY+a/VIv11MNwzXlZmGvjMKzgHDwX9HQSn8 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93003095)(3231311)(944501410)(52105095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699016); SRVR:DM2PR12MB0252; BCL:0; PCL:0; RULEID:; SRVR:DM2PR12MB0252; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0252; 4:scid+p+WaapNrlGQCv6zb8wp6i7wdHKxpB9Z2O0CpWg7pMtIb7AApAkrrGZ1Q6m+whRZZFRjWNidzH1xgG9K0gjcYZjTTUtgsdAp6tDttqByZmyI1+OnsWV/eZUoPoco57WITko6eTB3DBKu+VPuyci//ZYIBZ8hzl9KqR5Ewg8OV/2m9unEjmv0khu650pdjarvlmRJXbG2L9BxHiKkXKmCl2P1xsTae9fbg42wlwvaWxTgWsAh4GNSNG/CdbLpnjgwaKTlQzbkUWK83K9YipNABq3KTC5Akclxl5gft8JsqVZIZIveD+AVtLq1lgFl X-Forefront-PRVS: 0772E5DAD5 X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BDM2PR12MB0252=3B23=3A7vn38wJ?= =?utf-8?q?WOWELrId65+IRh42QbiGvcXGJEmBW6m71Hq2W7Sfcnz6FJ/ICysnMnacbJjaX8QCM?= =?utf-8?q?hyhq4Y8Jxvbj/ur4jEWHCO9KyFelNDB0u70M9vwbNSp8Ls0FVoY60T0HohYlZMwoN?= =?utf-8?q?ZLo4+n5Nm9MiiJYYUU5ZPWZLWTOC8urx2rK5h8VTYxqtk5kbG9oFWzfr70LdTNs0K?= =?utf-8?q?f+/IqWzdhsjgF8tQt7uqBMAMhzW/+1rc34wTgPQ8g+F0vhJ10i9Co0rZ91gwAu8yW?= =?utf-8?q?zxxRwvAWxZdV3okNqwcXpWSxEKt1HpNUvbveZaG4TXknVCBsjhFWCVQYJklj/Eodb?= =?utf-8?q?MDwCH1oOnrdI5bdDK+gxI5yg8PYTaTkfb4DfjlwcEk07+2Syygrj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FEfTFXhSUZU0sgZNikInYWuVq69es5V17bF5N529xq1ez3wnK8CzcsJUQB9ya9a0YYgdurMWEIm8ZqOexhVBVqOERdEVNsk4t1oSGDVf3y8hIttNS83b03Y9FkoiF1SaKSDbK81JUyprvbOIBaIMb SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0252; 20:7jz3e0sFjN0axRhcSngdft9cTtlnzHM+N8OmaDtfbRz7KjF+X4t+f/HMfO9vxWZTMcgYybjydT+5Hrur9ZXJFuypAkN+nBmG0pKQ7iB/rphcAk/gFHWo//FeIZN0H+KriSGmWlqK4rBu0HDBZUh2fdF2TqT4hBit97f/ydJzABSFu08xfQbgPKS+mUb2R+h1breTNn9yOVhn9Kanx+GjhfAVDGEkIHzaCzGkmNT3kkGAnefeOfnJIVpf6NoiXeyk X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2018 07:54:17.8279 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d000db24-ea1e-44da-9027-08d60804767f 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: DM2PR12MB0252 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 , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Christian König When move a BO to the end of LRU, it need remember the BO positions. Make sure all moved bo in between "first" and "last". And they will be bulk moving together. Signed-off-by: Christian König Signed-off-by: Huang Rui Tested-by: Mike Lothian Tested-by: Dieter Nützel Acked-by: Chunming Zhou Reviewed-by: Junwei Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++++---- drivers/gpu/drm/ttm/ttm_bo.c | 26 +++++++++++++++++++++++++- include/drm/ttm/ttm_bo_api.h | 6 +++++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 015613b..9c84770 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -297,9 +297,9 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, break; spin_lock(&glob->lru_lock); - ttm_bo_move_to_lru_tail(&bo->tbo); + ttm_bo_move_to_lru_tail(&bo->tbo, NULL); if (bo->shadow) - ttm_bo_move_to_lru_tail(&bo->shadow->tbo); + ttm_bo_move_to_lru_tail(&bo->shadow->tbo, NULL); spin_unlock(&glob->lru_lock); } @@ -319,9 +319,9 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, if (!bo->parent) continue; - ttm_bo_move_to_lru_tail(&bo->tbo); + ttm_bo_move_to_lru_tail(&bo->tbo, NULL); if (bo->shadow) - ttm_bo_move_to_lru_tail(&bo->shadow->tbo); + ttm_bo_move_to_lru_tail(&bo->shadow->tbo, NULL); } spin_unlock(&glob->lru_lock); diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 7c48472..7117b6b 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -214,12 +214,36 @@ void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo) } EXPORT_SYMBOL(ttm_bo_del_sub_from_lru); -void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) +static void ttm_bo_bulk_move_set_pos(struct ttm_lru_bulk_move_pos *pos, + struct ttm_buffer_object *bo) +{ + if (!pos->first) + pos->first = bo; + pos->last = bo; +} + +void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, + struct ttm_lru_bulk_move *bulk) { reservation_object_assert_held(bo->resv); ttm_bo_del_from_lru(bo); ttm_bo_add_to_lru(bo); + + if (bulk && !(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) { + switch (bo->mem.mem_type) { + case TTM_PL_TT: + ttm_bo_bulk_move_set_pos(&bulk->tt[bo->priority], bo); + break; + + case TTM_PL_VRAM: + ttm_bo_bulk_move_set_pos(&bulk->vram[bo->priority], bo); + break; + } + if (bo->ttm && !(bo->ttm->page_flags & + (TTM_PAGE_FLAG_SG | TTM_PAGE_FLAG_SWAPPED))) + ttm_bo_bulk_move_set_pos(&bulk->swap[bo->priority], bo); + } } EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index a01ba20..0d4eb81 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -51,6 +51,8 @@ struct ttm_placement; struct ttm_place; +struct ttm_lru_bulk_move; + /** * struct ttm_bus_placement * @@ -405,12 +407,14 @@ void ttm_bo_del_from_lru(struct ttm_buffer_object *bo); * ttm_bo_move_to_lru_tail * * @bo: The buffer object. + * @bulk: optional bulk move structure to remember BO positions * * Move this BO to the tail of all lru lists used to lookup and reserve an * object. This function must be called with struct ttm_bo_global::lru_lock * held, and is used to make a BO less likely to be considered for eviction. */ -void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo); +void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, + struct ttm_lru_bulk_move *bulk); /** * ttm_bo_lock_delayed_workqueue From patchwork Wed Aug 22 07:52:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 10572661 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 01836921 for ; Wed, 22 Aug 2018 07:54:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7EED2AD5F for ; Wed, 22 Aug 2018 07:54:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB8A12AE9B; Wed, 22 Aug 2018 07:54:49 +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 CEDB72AD5F for ; Wed, 22 Aug 2018 07:54:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C50A16E0F0; Wed, 22 Aug 2018 07:54:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0083.outbound.protection.outlook.com [104.47.33.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5471C6E0C9; Wed, 22 Aug 2018 07:54:46 +0000 (UTC) Received: from DM5PR12CA0002.namprd12.prod.outlook.com (2603:10b6:4:1::12) by BY2PR12MB0243.namprd12.prod.outlook.com (2a01:111:e400:585c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.24; Wed, 22 Aug 2018 07:54:43 +0000 Received: from DM3NAM03FT020.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::203) 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.1080.13 via Frontend Transport; Wed, 22 Aug 2018 07:54:37 +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 DM3NAM03FT020.mail.protection.outlook.com (10.152.82.193) 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:54:36 +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:54:35 -0500 From: Huang Rui To: , Subject: [PATCH v5 3/5] drm/ttm: add bulk move function on LRU Date: Wed, 22 Aug 2018 15:52:53 +0800 Message-ID: <1534924375-5837-4-git-send-email-ray.huang@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534924375-5837-1-git-send-email-ray.huang@amd.com> References: <1534924375-5837-1-git-send-email-ray.huang@amd.com> 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)(39860400002)(396003)(346002)(136003)(376002)(2980300002)(428003)(189003)(199004)(81156014)(26005)(14444005)(2870700001)(97736004)(336012)(126002)(305945005)(105586002)(426003)(186003)(53416004)(110136005)(5660300001)(356003)(6666003)(2906002)(104016004)(53936002)(106466001)(81166006)(8676002)(486006)(77096007)(11346002)(2616005)(476003)(450100002)(446003)(4326008)(316002)(23676004)(7696005)(36756003)(76176011)(86362001)(72206003)(50466002)(50226002)(478600001)(47776003)(68736007)(8936002)(5820100001)(54906003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0243; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT020; 1:8LO29lVSY7sj3liUEQcpowotN6IiE8TvUzl3vOkU14VbvubiwW3oGLFFQmmi9Lc6ggxmKsmDaec5RBaLs1eqYRRjsi/6EPU2RvUjmqcPdsQkH4OK+aONUrmtcPBDI9LX X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7c235c04-d6a6-4c82-26a8-08d6080481ce X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060); SRVR:BY2PR12MB0243; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0243; 3:dNgM9D9sQ3rCBz5gIqrdWQr0DzngpvqVnA8vj4MlqZAuQO4nRWRN3bSmqaqgvEo5hnKS6pcUnoX7ZBrpALV/+l7kiQAmIxYyYGl6oIXcz440p9OL3T0h0mI5T2SWXsrl4yLGokUJCU+0Kl5fNX87ISIabB3QRLxSf+wAtaOsnIa6W44VmXf45UXrNVc95Frea6GmILjPgBe7EMhjhKQ1iNdhYDH+5P08Fh3Kyng9tdfOSK3xjShM03KTtBDTFXvQhkPFM3/JTDchFGCJxwHOkjvmqa8e8swD31eu4g7wjw4dC2T4NqYWI/TSFU04ad4dU8PgErAeRJAi/TnF8RuvILLnEBq873ApJCp/ePmy8Q0=; 25:DIcN1gd7qNtDney6UyV3ZQ6mRw91ZhrustasQKqA+3526fMHO2WkPYSUwTeEum6rE1wKw/ptKj/VwUc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/08FZm2WaIXdoEzoeb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); 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)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699016); SRVR:BY2PR12MB0243; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0243; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0243; 4:Bi7Sjwp3wB+4BJUsHlG5TvXIdsaPLEK+8phe/z++dInmvaJe/ipa5r8Tqi3eePeNYpumGC18JT9s964YkW0XqkE1cqN4WHkvPx1HeVfVmwFbMTn5GLk0HfPUFm3norljGqIfYpu+GEXZ7Xeu17d4N1rv/INlhEZ7sgFoklFTz7qtk4+4yAY24gAkCuWxJjmaMBKlbTJlfykIZTeTtbJnb/c1awamJEhuxsXXwMGXvibLxFPaP3QrIcwUPt20tUtlu6N4wLn/Zo0ecHhX1Pgq1uSg1HltUtHBEkofpxx0YVJoCfbtgWbkL7EF8ctNdKAy X-Forefront-PRVS: 0772E5DAD5 X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBY2PR12MB0243=3B23=3ApF4MSS/?= =?utf-8?q?Ts7KjOeTfSsxElvlq6JPX3wuTRAKqmkFb8FVmBHtylfqiA9SlTR9PeNnYVzl79+jm?= =?utf-8?q?/knSA1FLmtlIk0YSjMuZoJhJJasWNmNuJuFQxwSRndNysfAiYzHKg0TltgBtNfbGD?= =?utf-8?q?o9NtmGNFQxTK6HHXDgg1ygx3HAgrgzkcx05SIU4MHRyC+3BY1lGK33Y7h9f0lzLVP?= =?utf-8?q?XVsmtyGRhtcACpBVIR9s2dU30qE4SlyHKHL/BO39+Rh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DpBo5ESgThXLGBI11R+OdNitlFy5k3j5tuqyiTiLAVStGgcuYtnI/2Y=; 7:cfmVA82E+lrivm8kNI0FXCF51KoFwR2ISXTDYwVDiklf9aa1GbRquAqdl+vIwfKGzxOldtpU9PNkdIrKFFMVVF+Iv592jtUjJE8pKZWkhzvtAQFw5nJP68MfLl0235jg/QK+HgfpiyOG+nyWtQUqXuyEMiXVUKA4zISsyln+XS7b80m1J7RPCpOFpffHOvmFTb2CY1R0g0DjiA4V4lhrDf8Bu5tY0WSlHreiSWas1L8m3IhcF9or6r+VnA79NroQ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0243; 20:+vI1ptmlhIEwcVLhqS/dYQOBQW7vF3JUzc+PhoRILfcvX41b/9w+Kd1IbBTMQzw95u2AXxbdd4sl8UyiwbYsIRav0HVhxF+3R7iacnrY2R0d9w4vi+qYzrzZkuSphpKX1zbCAyKTh126sKqNzL2kVtC5VZaiDuOfbZzlalkHaDPSg/LUIr7mtrPuyJGrbACaMiGzPGyEqbJyjYlE1Y2cMPL7JamvzrKconYL1rMZpJQOUNNPrwYXnk1uJlYT8+sP X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2018 07:54:36.8447 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c235c04-d6a6-4c82-26a8-08d6080481ce 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: BY2PR12MB0243 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 , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This function allow us to bulk move a group of BOs to the tail of their LRU. The positions of group of BOs are stored on the (first, last) bulk_move_pos structure. Signed-off-by: Christian König Signed-off-by: Huang Rui Tested-by: Mike Lothian Tested-by: Dieter Nützel Acked-by: Chunming Zhou Reviewed-by: Junwei Zhang --- drivers/gpu/drm/ttm/ttm_bo.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/ttm/ttm_bo_api.h | 10 +++++++++ 2 files changed, 62 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 7117b6b..39d9d55 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -247,6 +247,58 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, } EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); +static void ttm_bo_bulk_move_helper(struct ttm_lru_bulk_move_pos *pos, + struct list_head *lru, bool is_swap) +{ + struct list_head entries, before; + struct list_head *list1, *list2; + + list1 = is_swap ? &pos->last->swap : &pos->last->lru; + list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; + + list_cut_position(&entries, lru, list1); + list_cut_position(&before, &entries, list2); + list_splice(&before, lru); + list_splice_tail(&entries, lru); +} + +void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) +{ + unsigned i; + + for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { + struct ttm_mem_type_manager *man; + + if (!bulk->tt[i].first) + continue; + + man = &bulk->tt[i].first->bdev->man[TTM_PL_TT]; + ttm_bo_bulk_move_helper(&bulk->tt[i], &man->lru[i], false); + } + + for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { + struct ttm_mem_type_manager *man; + + if (!bulk->vram[i].first) + continue; + + man = &bulk->vram[i].first->bdev->man[TTM_PL_VRAM]; + ttm_bo_bulk_move_helper(&bulk->vram[i], &man->lru[i], false); + } + + for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { + struct ttm_lru_bulk_move_pos *pos = &bulk->swap[i]; + struct list_head *lru; + + if (!pos->first) + continue; + + lru = &pos->first->bdev->glob->swap_lru[i]; + ttm_bo_bulk_move_helper(&bulk->swap[i], lru, true); + } +} +EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail); + static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem, bool evict, struct ttm_operation_ctx *ctx) diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 0d4eb81..8c19470 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -417,6 +417,16 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, struct ttm_lru_bulk_move *bulk); /** + * ttm_bo_bulk_move_lru_tail + * + * @bulk: bulk move structure + * + * Bulk move BOs to the LRU tail, only valid to use when driver makes sure that + * BO order never changes. Should be called with ttm_bo_global::lru_lock held. + */ +void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk); + +/** * ttm_bo_lock_delayed_workqueue * * Prevent the delayed workqueue from running. From patchwork Wed Aug 22 07:52: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: 10572663 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 DC71C921 for ; Wed, 22 Aug 2018 07:55:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3B702AD5F for ; Wed, 22 Aug 2018 07:55:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6AE82AE9B; Wed, 22 Aug 2018 07:55:02 +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 884022AD5F for ; Wed, 22 Aug 2018 07:55:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 609676E10E; Wed, 22 Aug 2018 07:55:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-SN1-obe.outbound.protection.outlook.com (mail-eopbgr700080.outbound.protection.outlook.com [40.107.70.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5A77D6E10E; Wed, 22 Aug 2018 07:54:59 +0000 (UTC) Received: from DM5PR12CA0002.namprd12.prod.outlook.com (2603:10b6:4:1::12) by SN1PR12MB0255.namprd12.prod.outlook.com (2a01:111:e400:5143::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.23; Wed, 22 Aug 2018 07:54:56 +0000 Received: from DM3NAM03FT020.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::203) 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.1080.13 via Frontend Transport; Wed, 22 Aug 2018 07:54:56 +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 DM3NAM03FT020.mail.protection.outlook.com (10.152.82.193) 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:54:56 +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:54:55 -0500 From: Huang Rui To: , Subject: [PATCH v5 4/5] drm/amdgpu: use bulk moves for efficient VM LRU handling (v5) Date: Wed, 22 Aug 2018 15:52:54 +0800 Message-ID: <1534924375-5837-5-git-send-email-ray.huang@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534924375-5837-1-git-send-email-ray.huang@amd.com> References: <1534924375-5837-1-git-send-email-ray.huang@amd.com> 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)(376002)(39860400002)(396003)(136003)(346002)(2980300002)(428003)(189003)(199004)(2870700001)(53936002)(86362001)(50226002)(8676002)(104016004)(76176011)(36756003)(23676004)(106466001)(47776003)(81166006)(305945005)(81156014)(561944003)(8936002)(105586002)(53416004)(54906003)(68736007)(186003)(97736004)(14444005)(336012)(356003)(11346002)(26005)(5660300001)(450100002)(486006)(72206003)(50466002)(126002)(446003)(5820100001)(2616005)(110136005)(476003)(4326008)(316002)(478600001)(2906002)(7696005)(77096007)(426003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0255; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT020; 1:JVaJRWYCpXO9KG3xMyE4N6qoOI1U9RwSGzIU4p7taEOHPfMeUW7dVMAJ5RH9YG4OMKtqWl2e0IT89AhMT3zcEkU8CfrHzf6FOeStH4Lg8ZcCk7rAJeyONM9lvjXvU/sN X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8eee60cd-a7d7-4ea9-87d5-08d608048d81 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060); SRVR:SN1PR12MB0255; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0255; 3:C/dvWPNAHh23msmaY0jmJcYQ8IZROSCoR82TWgeEZY3tT1ZyQic5GpOVv9tOBjjCLHeLWkZChDYueBdn1TBfV2GOHNJ7SSNZoVakQWVdz0DvOzYTdinM/sYgfzg2a+RXc9l/4D/ykroaEU9fRuRdp+PosyApksiiV9VptwZzWt0lHBGNEzd+9M/YjU+VlhzKWUCtwt9w8Rg0SwqiWzK5/a/dVBnuK5SOeY4IRXmf1a0rt9TCnY5o1TUxg4FaYkc07Q9v32KrsVLUDkOWJOS6Pf6qhjm9fbff08AUErKO02tVZTHGAWAPSXlmZFmhAl3ah4FT7roXN0ji1T4ZdeGZ2c5D2WxTttnNMv+KwNhm3ho=; 25:Zpq3W8ANoJ2f/YzEvg3diIFD78eyZHzLSk0IGZKNHiWA/Kaqx05WyowuUZFIXRAlP1AjOj0o3/c0Hwd0bGMP+z8Xzn5dMNnWrxwG3QwTnPAEpk8w2zYy6tlb0/kIbj69cc6KEaspghuoHXVsIjcsBuOR6SvthC0hsioYv0gRNtnCvjQHLCCdDwhlLwKZiyBd80SVTmhTK8s6rFk6HYdZfOHyjT5koNk0eadyBtwH10zcfCmZuAMndiNfslRRzDuLs74F7RaxsXPfhJmCd8yZVe8ZQf7+yj4sVKKcNbUpjwGKxBAFAPdJuQaNfr6NuWnY7UTJzA33mPUn6veu8ghalQ== X-MS-TrafficTypeDiagnostic: SN1PR12MB0255: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0255; 31:lPI2GVZIO9rMm+cVbCkfWmHW6icd8JOL9A9eXmnN2ikkxWc94FyJCpiHNnpNS0OoGFZ8RdeA6+hOFCp0WNuwhwBMb5Lqqnvwa31pgRe/kVhq6G+wR5wwe9Hi6lZT+T8jxbrhknhdWR/u/iL8qW8WmPbqgmAZgXI2jAQo4Z9VggroGhgbQaHEdqY6lycwI+LeWATR0NtaHvmTqB6KaIUBgZ3RaiiKq1R0qgQj8P0is2A=; 20:KAKeqhL0Lx7uRHzEilAP9CaEpOFVgu1wFoQDcuhjbRn3Gk1tl+wfpfZm6IvcB31yv827vVd+XfmlyVOa8hEducdgn16IoqD0keIQwT9lp4Fc3leaihwwe74Rj+XwjETIgsi5+STIhKezOVFf+/DS3GyYoaZFvzIbeC+P7ijuihdbUVvYOfTsrIzCDEGvA/yRgqQ5WNaBZHoySUwZlNZs3YVqVq8UHUZxbR9QvWQWPc++/L95E2vqaKg5Aj5f2vahx8wVIUbiNT1dC5/5wrqWQlZ0MzPUmifkPizvK3MQngbme5fVdPMdKiPEv9j3vjSiR3dbM9zGMcQptDuKxvLJQwV7BgJE+SavFFa8HAz+OezHse+VMaT6KnpyZBnQFtFCZVbseUhAz9I3PpIJ+WudAwARPuOazC3g4M+uL9dZxgFkpM5PhGQcVSs8rTA+3TUmZ7hE1z2kDrMrTKEJl5gkH+oiYPuJZO2IN7MkDC2ne0DJr330NMSKX0IomcNb071R X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); 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)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699016); SRVR:SN1PR12MB0255; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0255; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0255; 4:ZoSPbjVA20XBvTPZZdcnM2SRABwFsyhYgFcDmigTArSGai+T6AmzyuPsdZQZ/D21nykDDakT4MtVx+lrkBeBV6B/OOUNehEVUObiCkOFNfwkeVgMoP9Ysi/NvoqYzqnXJEA6IqBs2wWJvL4t1iAq6EGk2tB4HLoalGGSD8OceWx9pjVCJdKXOCLMzSs2dMITT9R3qJ8o92oJC3Un8TsdolWkKmJ5Q5O0AOiWlD4YtwszXm7HuibHOEum5nR1utVM2dDa6oHMlgS+scbooIwG3tLHO5u+QldKaWmAs8pZXmfl/cV0scEakVkPpJH8elOX X-Forefront-PRVS: 0772E5DAD5 X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BSN1PR12MB0255=3B23=3Aq2Cdqyl?= =?utf-8?q?Mk1qF9vwzBrS3dtxkngzSw8eB4QC58//OyplXdGTcLPkK5aweYD3UFUVgs9h7T4cW?= =?utf-8?q?JIO43+YA+mgIYs1o+8wVfyMDMPFdeSlq1xnExyQZiUKsGBg4NRPrer1kc8Z9MoqOI?= =?utf-8?q?2U443PuJBGRvuGy/PCAEVabqpjS6lwKYOQzdzm8HsqOvMsa2Uy2UktNXWQsKKxMa+?= =?utf-8?q?G5f5rcNWaXY6gAum3iCQPYCswIhw8r8GFIXLEr1UcIX8elezBBwOdIEfQ8yXTa8Sv?= =?utf-8?q?Ddklqr1Bkh46rdsl/Y6tSqGVWX6J+y36cZ8vxPmOYF6y4Pa69iX7tuz9/hLAShQO7?= =?utf-8?q?ILxguQ0+y50oVdBDtzNj5NLbr45bCx/X8RlWImFHX0vPPqp8cBZSczM06Hg6FljLo?= =?utf-8?q?oOs4Da3uTdlYp2xNIi9L3m/1llG1km6oJsYVDR8NzAg5zc/S1QgiDV8+T0s4n2qab?= =?utf-8?q?clK0sLs0jowhW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8OgTxQwlyeE7rCt72qconTk1ab/HNx6jAn3fT SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0255; 20:lmcR4h53Z8uYXxd3HGemAfl6KeHQ3DWjXcng8PsYd1hco9d9BVCEBWZ76374rpNov0a2U80wwCJrRAc77cqNzrFAbI2cVuLPBFX3ELA1vWpV6bsJlOFAjG8vSrcpGxestX50ILP03V8x9IJ+jGsAsP80vsfeWkIB/wLcDpMouAkdR9AeNfjUgIZ2RYwuKs1HU0yxfVcsajC6zeF05ZkYjncunl5Uai8v7aHGdBHCKqQFFWm/pXmgUl6i9DVExc8l X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2018 07:54:56.4284 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8eee60cd-a7d7-4ea9-87d5-08d608048d81 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: SN1PR12MB0255 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 , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP I continue to work for bulk moving that based on the proposal by Christian. 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. v2: move all BOs include idle, relocated, and moved list to the end of LRU and put them together. v3: remove unused parameter and use list_for_each_entry instead of the one with save entry. v4: move the amdgpu_vm_move_to_lru_tail after command submission, at that time, all bo will be back on idle list. 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(). Signed-off-by: Christian König Signed-off-by: Huang Rui Tested-by: Mike Lothian Tested-by: Dieter Nützel Acked-by: Chunming Zhou --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 10 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 66 +++++++++++++++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 11 +++++- 3 files changed, 65 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 502b94f..4efdbd2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -1260,6 +1260,15 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, return 0; } +static void amdgpu_cs_vm_move_on_lru(struct amdgpu_device *adev, + struct amdgpu_cs_parser *p) +{ + struct amdgpu_fpriv *fpriv = p->filp->driver_priv; + struct amdgpu_vm *vm = &fpriv->vm; + + amdgpu_vm_move_to_lru_tail(adev, vm); +} + int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) { struct amdgpu_device *adev = dev->dev_private; @@ -1310,6 +1319,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) r = amdgpu_cs_submit(&parser, cs); + amdgpu_cs_vm_move_on_lru(adev, &parser); out: amdgpu_cs_parser_fini(&parser, r, reserved_buffers); return r; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 9c84770..db1f28a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -268,6 +268,47 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, } /** + * amdgpu_vm_move_to_lru_tail - move all BOs to the end of LRU + * + * @adev: amdgpu device pointer + * @vm: vm providing the BOs + * + * Move all BOs to the end of LRU and remember their positions to put them + * together. + */ +void amdgpu_vm_move_to_lru_tail(struct amdgpu_device *adev, + struct amdgpu_vm *vm) +{ + struct ttm_bo_global *glob = adev->mman.bdev.glob; + struct amdgpu_vm_bo_base *bo_base; + + if (vm->bulk_moveable) { + spin_lock(&glob->lru_lock); + ttm_bo_bulk_move_lru_tail(&vm->lru_bulk_move); + spin_unlock(&glob->lru_lock); + return; + } + + memset(&vm->lru_bulk_move, 0, sizeof(vm->lru_bulk_move)); + + spin_lock(&glob->lru_lock); + list_for_each_entry(bo_base, &vm->idle, vm_status) { + struct amdgpu_bo *bo = bo_base->bo; + + if (!bo->parent) + continue; + + ttm_bo_move_to_lru_tail(&bo->tbo, &vm->lru_bulk_move); + if (bo->shadow) + ttm_bo_move_to_lru_tail(&bo->shadow->tbo, + &vm->lru_bulk_move); + } + spin_unlock(&glob->lru_lock); + + vm->bulk_moveable = true; +} + +/** * amdgpu_vm_validate_pt_bos - validate the page table BOs * * @adev: amdgpu device pointer @@ -284,10 +325,11 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, int (*validate)(void *p, struct amdgpu_bo *bo), void *param) { - struct ttm_bo_global *glob = adev->mman.bdev.glob; struct amdgpu_vm_bo_base *bo_base, *tmp; int r = 0; + vm->bulk_moveable &= list_empty(&vm->evicted); + list_for_each_entry_safe(bo_base, tmp, &vm->evicted, vm_status) { struct amdgpu_bo *bo = bo_base->bo; @@ -295,12 +337,6 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, r = validate(param, bo); if (r) break; - - spin_lock(&glob->lru_lock); - ttm_bo_move_to_lru_tail(&bo->tbo, NULL); - if (bo->shadow) - ttm_bo_move_to_lru_tail(&bo->shadow->tbo, NULL); - spin_unlock(&glob->lru_lock); } if (bo->tbo.type != ttm_bo_type_kernel) { @@ -312,20 +348,7 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, } } - spin_lock(&glob->lru_lock); - list_for_each_entry(bo_base, &vm->idle, vm_status) { - struct amdgpu_bo *bo = bo_base->bo; - - if (!bo->parent) - continue; - - ttm_bo_move_to_lru_tail(&bo->tbo, NULL); - if (bo->shadow) - ttm_bo_move_to_lru_tail(&bo->shadow->tbo, NULL); - } - spin_unlock(&glob->lru_lock); - - return r; + return 0; } /** @@ -2596,6 +2619,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, return r; vm->pte_support_ats = false; + vm->bulk_moveable = true; if (vm_context == AMDGPU_VM_CONTEXT_COMPUTE) { vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode & diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index 67a15d4..bbdde40 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h @@ -29,6 +29,7 @@ #include #include #include +#include #include "amdgpu_sync.h" #include "amdgpu_ring.h" @@ -226,6 +227,11 @@ struct amdgpu_vm { /* Some basic info about the task */ struct amdgpu_task_info task_info; + + /* Store positions of group of BOs */ + struct ttm_lru_bulk_move lru_bulk_move; + /* mark whether can do the bulk move */ + bool bulk_moveable; }; struct amdgpu_vm_manager { @@ -330,8 +336,11 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring, void amdgpu_vm_check_compute_bug(struct amdgpu_device *adev); void amdgpu_vm_get_task_info(struct amdgpu_device *adev, unsigned int pasid, - struct amdgpu_task_info *task_info); + struct amdgpu_task_info *task_info); 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); + #endif From patchwork Wed Aug 22 07:52:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 10572665 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 B700C921 for ; Wed, 22 Aug 2018 07:55:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE5652AE69 for ; Wed, 22 Aug 2018 07:55:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2E232AE9B; Wed, 22 Aug 2018 07:55:19 +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 4E6AF2AD5F for ; Wed, 22 Aug 2018 07:55:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3FEC06E1AB; Wed, 22 Aug 2018 07:55:18 +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-by2nam01on0080.outbound.protection.outlook.com [104.47.34.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 30E2D6E1AC; Wed, 22 Aug 2018 07:55:16 +0000 (UTC) Received: from CY4PR1201CA0009.namprd12.prod.outlook.com (2603:10b6:910:16::19) by BN6PR1201MB2498.namprd12.prod.outlook.com (2603:10b6:404:a9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.20; Wed, 22 Aug 2018 07:55:14 +0000 Received: from DM3NAM03FT056.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::200) by CY4PR1201CA0009.outlook.office365.com (2603:10b6:910:16::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1080.14 via Frontend Transport; Wed, 22 Aug 2018 07:55:14 +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 DM3NAM03FT056.mail.protection.outlook.com (10.152.83.158) 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:55:14 +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:55:12 -0500 From: Huang Rui To: , Subject: [PATCH v5 5/5] drm/amdgpu: move PD/PT bos on LRU again Date: Wed, 22 Aug 2018 15:52:55 +0800 Message-ID: <1534924375-5837-6-git-send-email-ray.huang@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534924375-5837-1-git-send-email-ray.huang@amd.com> References: <1534924375-5837-1-git-send-email-ray.huang@amd.com> 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)(376002)(346002)(39860400002)(136003)(2980300002)(428003)(189003)(199004)(426003)(476003)(4326008)(450100002)(97736004)(81166006)(81156014)(106466001)(14444005)(8676002)(446003)(11346002)(6666003)(72206003)(5660300001)(356003)(53416004)(2616005)(126002)(86362001)(486006)(50466002)(305945005)(105586002)(478600001)(26005)(186003)(77096007)(36756003)(8936002)(47776003)(50226002)(104016004)(68736007)(2906002)(53936002)(5820100001)(76176011)(7696005)(336012)(23676004)(316002)(2870700001)(110136005); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR1201MB2498; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT056; 1:B86bJ2VcFiOkfwai2vOZsjmoa/f7RiM6W95m281zXM+Y8+/7u/jG/OlrdzLIB0fqR1j2whUIdnnyVfRyURLGHfhqUmCMa6XBTelGuujEcOItoH5GZLzRLnmOkJbhXR3m X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c7cb948-b7e2-4c48-0bb0-08d6080497fb X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060); SRVR:BN6PR1201MB2498; X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB2498; 3:HFNCxwM4rJPa44T0ly7SJeiVRsW8oIohaK1SC/ne03DckUKWXHGTlW2OQS2iI0h7wEGRO/9U98fXI2/dgiaILA9GoifXcEoY79XqwIAs7waoEMuBDSh+/Qta3p10A7ENl9zgx016YU4CoCzVulFczaSClRs1/AMXdxLzZopI7yuOJ+wzG2sXQBxdw7wt35g2wzFJM+Oe6iQR83gZmx/OsB7dxlPgp4qwZ/JjYiIWpfsH1kq66Y7cadnfBrDt5Odx1OQhbxdhoOMw5JHcaW1j419a6GjrgF9QqyeBYRHejWoMM5S4gm05nkSX8S4c8PUZPhIcDOxQZfoUxo0ygqwZ8hmsn594FXu9Wko6HRzAA9A=; 25:RO5Xp8lA9bMWtX66yjCE1W3+kyLsTVy6sz8gI2KwS7LGBU8qI3S8iLA3PBE25wWY8aBP5z9Smu+fMTDMeHQMheRnIwY06BGUYBW27v3DFuTu3sIvUTyeYYuP3MuY5K4cYp4XzTJpyGycz7feK8tzujyXCDq9kA/4hfT8eUh84No63Vk3j32AilvsnILyD1GwgtjKHzEyOptkWatVxcz7Lk31kFt3eiJO9SEGGDEJpgX4UrlHIF8nN8Dvq6Wl5gDIvbhwmDtDYHLOgnKv+ibqe7poN4VD3szmKD78FXragffz0HVGXCBXHE4tQNK/IiDdmtKzS0prAnZ23fOZJYCJ2w== X-MS-TrafficTypeDiagnostic: BN6PR1201MB2498: X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB2498; 31:Ly8CH+AdOmP8fYhQzwTF3p+/oqVaaIO3bFc0inYGa68e87ozB+ewLC/3qbaVp+KrJXrwCsfQPjcLc20Ot5NRRH3W2h6cLhE/40SWJWgKIE9pa9sciFLGL/mcvrduTXRr7omciiEJyxgIIfmDWv/JoXDhVv/Agaojh4R96FrIF+C4YcRZZZTLTUmI6eL4rsSlCCZU89FpfHo2VjFFyl2HF5q8hTqqYUNOPnWNc4sP9+8=; 20:+094Bc21BDN/9KlYi4XvGTZjrIOJBX8QAQrAJd3adPC5DF3YMxhdp78HFdkV8Ok8HLajL4rgsoGbw6PtMiGFg1hrnWV/3jFxzc20bfmuYpcdOA2RVIGt1edTieNmfPXIinzWt3diptx0yJKxcUnJrOHxTGfJV0/+XEZNSoCUlXfNYVqJ5Z+fuOgfDBe2EBr9yrHOh57/YJYccdS2lMW9k38wDS/TKcmfvUUj0A5rm7jhhQnTJjeOEh22Y2jgU95tjUdhlPF3VgktBhw6QL6LAXEueS2WjaYfLn2XyVeuD53pUskXjhv3iSGqDom3D3gY1xjTIl6jZCGHR+4CcMXcyETLqiCP+dcfsIM5ls1tQm/je/IRECEldd+a124FBoVfpkzUoEMevvO+bBmIeB8y0xVLXBSqkUupfMh/IXUF73PkL6e0qcPsLDviroXzJ6wBhTGgGTGy09/6OSUvVmH5bjiMuU6ZHyiO5IMrsMHcXImJI1N2gD0Kc0rqCNAUkZSP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); 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:BN6PR1201MB2498; BCL:0; PCL:0; RULEID:; SRVR:BN6PR1201MB2498; X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB2498; 4:GbuKblFC9/kVQGIK/fLLBxUDJLeO90KcQ+lKJTcCg1FJPi0aiO6Dlz+1BsbBz3N/c4f4xYINhgZXj8LflLS9wgwzmBI0TiuikDlFHCOKDjgNb6NgJNZ89/Cg8Rb2wz3Tm3b0MSK5JzxnIbNCNgdLBJjzXlCjfDF/t9VqlAv11kpmx2BJbyNVhqBt9mAU3DLEESmgVFyt3ySP35wxtQCwEfsOM1X0Tut0fLWezji3WnAWycHOaF9zxqEa7bXVirg+eoDPJzNywZqnJve78+zKQ225Udn8BJhk7IhR9jZrWvZhxb59hDzCkb+D6X1YDCBe X-Forefront-PRVS: 0772E5DAD5 X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBN6PR1201MB2498=3B23=3AR83Bw?= =?utf-8?q?aQQ1BvnpqvsxyxnwXRkdvJDg7IJpeIDsTQ1hS9Y/YuVArfQgfb5a115pfzLlk31Jr?= =?utf-8?q?I20pfg87X0rVLNZLuTb3Y+FLTVg9aPm03C7jvbYwsfBgGGZtjybLcB15a8aMP8/Xk?= =?utf-8?q?2GFfeKkoRrF2IVM7hjz9XjJu93HZ99I9EBD5t9VB3j3QMbdPuJ1eCSIwEzltLYWOH?= =?utf-8?q?SZCgo33mmA8N83v8qrhPBPBTjEmjnCnSB0MJ2kNrWSQrA5ouZsp2pBfGs+fQRbcKs?= =?utf-8?q?lHhBnP7zhieYSPCabaHIP65N3Oudi3ROftVwDEs6WQ7ii+MM2XRib9JIMZHCQRiJ6?= =?utf-8?q?5s1KiOJGuZjDGEonPhk4ext2Fz/zzNHvbv42QSJr1q2gS7+81jtrJSaavGbRt4gS9?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izQ6zFJcHCi7MyHudqKduTdqlyGr80qTV4kPvkl9L6vR2rA+pLM8y+en48wHRUxw6rpe+Gvr3P8PMC8yiiCQ0YgH80mBgo+I8jwllmcpOWmMX1EIKKr4rbW1lcj SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB2498; 20:DgqN1vbjVtZcSizDuSVeg5+fo7r2DZRrcogNUBw7QZnpPeZhFgNv1zisR+PfoGFs1sQRSGSCg6B7PyOjy0qwtPX3/CxrQHrnbf92/bAl1l/LWDdTw5oB/Coabca1577gacAZ+JM/SUd5cekDeNEf9TM4wnNSSddAZEEJJp5MgY1i9vbkSapju/nTMXUx++wgb1O/6h88qIRQHioxk9hlK9EfPNmyjNvrhMK824JnW4n51ljxPYnbZt71nmMXmMC2 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2018 07:55:14.0332 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c7cb948-b7e2-4c48-0bb0-08d6080497fb 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: BN6PR1201MB2498 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 new bulk moving functionality is ready, the overhead of moving PD/PT bos to LRU is fixed. So move them on LRU again. Signed-off-by: Huang Rui Tested-by: Mike Lothian Tested-by: Dieter Nützel Acked-by: Chunming Zhou Reviewed-by: Junwei Zhang --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index db1f28a..d195a3d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -1107,7 +1107,7 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev, struct amdgpu_vm_bo_base, vm_status); bo_base->moved = false; - list_del_init(&bo_base->vm_status); + list_move(&bo_base->vm_status, &vm->idle); bo = bo_base->bo->parent; if (!bo)