From patchwork Wed Nov 22 09:17:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10069963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5EB66601D5 for ; Wed, 22 Nov 2017 09:18:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53FCA29BF6 for ; Wed, 22 Nov 2017 09:18:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47C4729C20; Wed, 22 Nov 2017 09:18:46 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 CD3AC29BF6 for ; Wed, 22 Nov 2017 09:18:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 198896E607; Wed, 22 Nov 2017 09:18:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0071.outbound.protection.outlook.com [104.47.37.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2D9976E607; Wed, 22 Nov 2017 09:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ZiVrPObvGQdv00j68kNJ6nSh3iJ3R+QwmeVgOW2B6lc=; b=UlK9wZOGyoWbvbzm1i92IGjlOks0AJt3h3jnqmr81+wN/AtOevmUWlHaUeHg9EuIRYoJIA6PZIKFPGAh2FcxfXoH3vdPzkGFPKcVU7Kc5AqsOrbpSvgrLYa8a9WlnjHck1nC/euaTarWHTkz4Uvx5PKjb8zorUeWoFrG+yyN2b8= Received: from BN6PR1201CA0024.namprd12.prod.outlook.com (10.174.238.34) by BN6PR1201MB0049.namprd12.prod.outlook.com (10.174.114.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.260.4; Wed, 22 Nov 2017 09:18:42 +0000 Received: from CO1NAM03FT017.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::203) by BN6PR1201CA0024.outlook.office365.com (2603:10b6:405:4c::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.260.4 via Frontend Transport; Wed, 22 Nov 2017 09:18:42 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by CO1NAM03FT017.mail.protection.outlook.com (10.152.80.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.239.4 via Frontend Transport; Wed, 22 Nov 2017 09:18:40 +0000 Received: from roger-build-server.amd.com (10.34.1.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.361.1; Wed, 22 Nov 2017 03:18:39 -0600 From: Roger He To: , Subject: [PATCH 4/5] drm/ttm: roundup the shrink request to prevent skip huge pool Date: Wed, 22 Nov 2017 17:17:13 +0800 Message-ID: <1511342234-18570-4-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511342234-18570-1-git-send-email-Hongbo.He@amd.com> References: <1511342234-18570-1-git-send-email-Hongbo.He@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)(6009001)(39860400002)(376002)(346002)(2980300002)(428002)(189002)(199003)(47776003)(478600001)(50466002)(97736004)(77096006)(48376002)(450100002)(81166006)(81156014)(68736007)(72206003)(8676002)(105586002)(106466001)(4326008)(53416004)(36756003)(5660300001)(16586007)(305945005)(101416001)(2906002)(104016004)(86362001)(76176999)(53936002)(50986999)(5003940100001)(316002)(189998001)(6666003)(2950100002)(50226002)(356003)(8936002)(110136005)(14583001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR1201MB0049; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT017; 1:MbanK0NwGlZXayB5ZPyANlNVLYpCjfUfFCeyrn7P4q23zWkspW/30i4pxE8UpQzD6Osl8TZkUTYt43jLhskMQaK7RKtsOOQ/MeWCqodmJ/5f5XbeIjMTMDlSbCuWMwjX X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76ca0606-b16b-4f6c-61fc-08d5318a0543 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600022)(4604075)(2017052603258); SRVR:BN6PR1201MB0049; X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB0049; 3:uXi8fazvuIm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5F2LjXjDWiFjOl86s8VfGhNh1dO2qwA4e0UaqbOO/cdwJVMH4GAncqA/Kql9uRTwQpjF8vZ9hyIkTbPA0oc6BsF8mZujYDBglmGs9VC/MAA513D7kWf0MSdZtRYLoNhQ+MX/ZVATYk0PscJjvwqJfPDdJNuLP3n042DtFXO8PL1dd8yrChWToDr55KvqAz4IID5mRmNAtZ8DeYsHJpeGIkJtQbdq4owqOQzfli160UK01iz5g+9JrI8jzIWKJfxp3a4d36tg6qUUNiX5EPUqvDOcBTRogjCapNw2ku1N12WFd2o/QzG84LaHfm/Uf1GRYpaFC3doCptWkHIsIopZcZvTpo37D43eWc3shBHeeFgpetdbxmsQLXs1rqOnQveundBIkXz8yfGEvsPttEv7hY0e0SYLiRgfl8BSYW/hi0eCcy7xt4KCj5oNur5FH X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(10201501046)(100000703101)(100105400095)(93006095)(93003095)(3002001)(3231022)(6055026)(6041248)(20161123555025)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR1201MB0049; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR1201MB0049; X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB0049; 4:wJnv96fY8dZJrJxMY+qzyYzaQnHlU3P1AZaAaBNo7NYwYemqPFMAkkiWbuIbm9vJKjbLzl9KgmhxrXdxaB4ntfibU7FTxUJH6fxYe/wK8dr7J0GV+uZuW4nzUExHoOsokZjbfkXHKOLBb+aF9O2SdFxTZRSw6BjVNHsA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w=; 24:NGnU+eOUzr3weWleg8p4MUMhT7sDvNlnwlJGqQQ0ANayxsbth38tmkKkTew+yzKo/PYZN0ND0LicJiEzP2k+J1Jtnu18Ta+f4EdzNRVy8iU=; 7:0z6CTN9HXbRgTzHy5K9M0L0A/jVL5QxpDAVqWoI6ioYGJVRErlnAHJmnj4hrZ1DCzSDrPMhVH7CFErE3M45Z/Kyuf1UUVBMdtVtSqZRBfZ2r6+rGjoOpX4jdt3UT4ftYmw8ln5/Y0cdp2Ub2/PKdJxIG/ZjscOqoPvcvmc0yC+ElcKf+0hWlLo7cCigWKKLeLu4agAI9xxubxj/6ob6M59CVZTMX6IJfKt0gPW4FnS9Ut4N7zbITXjF+H/rAqP6y SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB0049; 20:8iAyonSzcm0fcg3hF5s1TPw+2rl77+R0gik4Rj07oiqcAs/WhaommFbJF/jZlXHt/s8S/g2/WBsdfL6yd/FZu5oeOfxr4uay/AOojPzChkxbIYyx3FCAJCFvSWZ+2nCnLAdWcMv7t03U2PzFgC7HoGju8C+tKgNplkPVSEH+yCWYTva4pfWU+N2mPOOdzgOumNDXbCUuYYpvbn0M8qScuj8o7RyZdQgLz4hIg0xYVifY0Q4VtoUgwlWyEKn7MZYq X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2017 09:18:40.4311 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76ca0606-b16b-4f6c-61fc-08d5318a0543 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=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1201MB0049 Cc: Roger He X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP e.g. shrink reqeust is less than 512, the logic will skip huge pool Change-Id: Id8bd4d1ecff9f3ab14355e2dbd1c59b9fe824e01 Signed-off-by: Roger He --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 2dc83c0..a710d9e 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -438,17 +438,19 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) /* select start pool in round robin fashion */ for (i = 0; i < NUM_POOLS; ++i) { unsigned nr_free = shrink_pages; + unsigned page_nr; + if (shrink_pages == 0) break; pool = &_manager->pools[(i + pool_offset)%NUM_POOLS]; + page_nr = (1 << pool->order); /* OK to use static buffer since global mutex is held. */ - nr_free_pool = (nr_free >> pool->order); - if (nr_free_pool == 0) - continue; - + nr_free_pool = roundup(nr_free, page_nr) >> pool->order; shrink_pages = ttm_page_pool_free(pool, nr_free_pool, true); - freed += ((nr_free_pool - shrink_pages) << pool->order); + freed += (nr_free_pool - shrink_pages) << pool->order; + if (freed >= sc->nr_to_scan) + break; } mutex_unlock(&lock); return freed;