From patchwork Wed Nov 22 11:44:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10070317 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 BDACD601D5 for ; Wed, 22 Nov 2017 11:44:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC9E2287D6 for ; Wed, 22 Nov 2017 11:44:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EC1629B62; Wed, 22 Nov 2017 11:44:53 +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 BDC5C287D6 for ; Wed, 22 Nov 2017 11:44:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 52F2F6E63A; Wed, 22 Nov 2017 11:44:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0073.outbound.protection.outlook.com [104.47.40.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 94BB86E63A; Wed, 22 Nov 2017 11:44:50 +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=suwKNwOZpgOYINzy5sqVb82PEL8VDAbZJo8QT0D2+sU=; b=QDnhua+sMIZv+Hy5BQym2WqUXMJf+pzt6N5/yjKhgwFY8CCgwz7LJAyb+JVAvS/hKMUJLxHnkiXMzDLfAXBKtVP7zyjMggoysqTJ6n5gorX74tev0SaXy0o0MuieUgLpLCzcebBAQRZ9Fs0wv5m47mMu44sBekcb/loay5uWj+U= Received: from MWHPR12CA0062.namprd12.prod.outlook.com (10.175.47.152) by CY4PR12MB1448.namprd12.prod.outlook.com (10.172.71.140) 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 11:44:48 +0000 Received: from CO1NAM03FT032.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::203) by MWHPR12CA0062.outlook.office365.com (2603:10b6:300:103::24) 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 11:44:48 +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 CO1NAM03FT032.mail.protection.outlook.com (10.152.80.173) 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 11:44:48 +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 05:44:46 -0600 From: Roger He To: , Subject: [PATCH 3/3] drm/ttm: roundup the shrink request to prevent skip huge pool Date: Wed, 22 Nov 2017 19:44:29 +0800 Message-ID: <1511351069-4757-3-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511351069-4757-1-git-send-email-Hongbo.He@amd.com> References: <1511351069-4757-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)(346002)(376002)(39860400002)(2980300002)(428002)(189002)(199003)(316002)(8936002)(47776003)(101416001)(50226002)(68736007)(97736004)(5660300001)(16586007)(110136005)(106466001)(53416004)(53936002)(77096006)(450100002)(189998001)(575784001)(86362001)(4326008)(50466002)(105586002)(48376002)(5003940100001)(356003)(50986999)(2906002)(305945005)(6666003)(2950100002)(76176999)(8676002)(72206003)(478600001)(36756003)(104016004)(81156014)(81166006)(14583001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1448; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT032; 1:0iP9Em26HS90zYnZAqPkwhPrYfTQNHgY9vrnlLScp5tWCRaIZZyQ9jEV4Pvk9AYBy+PAF6htDTmcgC3TwS7AfR1YUwIT8L7jaj7TD7Euuz02MOa75IZmWxhws3g1Xg0a X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0dc1f05e-3f7e-4456-25fd-08d5319e6f3e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:CY4PR12MB1448; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1448; 3:zIW/MrUNdEtGZ6Sx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LIwCS+MpjRp3+e8ONymuxOVtNNohwBIC7c0eRA1GRzCOXV7eJClrXnEh7YjPQ6ozknCbAjYkz0fLEP9Tx/fgwyuHVl86kVaTqISLTAoSrfV6EurFiO+yXOMMxpmupImzygoR8+zhy3W/A0CuImIRocRsDiNu8FMYQ1rw9g3L+G7f/2XwJWEvgpeUnXJaym8K4KLdPsNbkne5inBLw7pVsyOlV/AdNZsy+XJ8bN9ojznln8gy298aj1swn+L5R+i9ZwcanyjA8H0gQ7fHQz2m5sd30rr80hv6GVkiiQhmeETM0ghF+UNFzterB5vsKOR+4TuH3Wi9E9WyFIgll65ABcEHqwdkv2TWFQVYkQ7thMeeDMbzRpKknPgtpW8MolUmTIIinpKzkDs2uSC0IHqTCMb2kUcPjSYfTSFnascu1oEVOInLtrcw89wMST/pkPQN7dZv5iqSUn4Hm7qupEWupajbKbH 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)(3231022)(93006095)(93003095)(10201501046)(3002001)(100000703101)(100105400095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(20161123558100)(20161123560025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR12MB1448; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR12MB1448; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1448; 4:Wp+Zjac691tIErM0Tc0O0NZ1kuhUNDKVB9v+yucFsBU3fYgByN4NDTQBr8Ha7Tbfz73SbHIMyIYLM1zaAKmGqz2bMOXuossVCDtleAMFq0HE7vaECL5usaBaLbtuO6nUjeaUyg/EBYiwrF6Wm1w242hGuM9maBoPKsOLJwpZGY7mS5iKqwsKqDe4kE5B4gujBG+WTOhAAiNQzQCOjnCkexUE4pSr2ElvosEEWYQIe1EtjTWC5t1HGCH5f033H7+1NUy1WFiufAjduJf6fjHkdgy9THJOTJMDlGpdTghMC0ZpvOIuvVWR4MKRHZq3l/7z X-Forefront-PRVS: 0499DAF22A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR12MB1448; 23:OiO2mwJI48EW179H4SojMjgwrbgAWGwzQ06REB3FH?= =?us-ascii?Q?Oq1Dalg/EJ1dqukyC8C3DSqGnUvmlwU4qlquvoOYR5QkvYCVc6RYMA70nhXj?= =?us-ascii?Q?vEhIPZ2xwWgk8QfLztanXtLNhebjUUN1HE57TfakL2phUQNQl0kpmRCEiWc7?= =?us-ascii?Q?yK1jntCrNc+hng10zg9JtEsnOc7U9ah0xqjV8H/XeaQ3LWLYRU9DBpYyjVmZ?= =?us-ascii?Q?80SK/0iN3o4LsRYYfhqK6XVuI+05NklCW3dhXfmfbZOPJkswmKQia8hZYoq2?= =?us-ascii?Q?5R/Vakwnr7NuLkrd2FjASC1FOhjJ1Dtca4DQqoARjfBHPVHysMZHRntKMI3m?= =?us-ascii?Q?fVSEpej+XPfSyJCUg9TLArmH2rdil0eacLxb9fjdon6ptoTlhgAH+aiKAEpP?= =?us-ascii?Q?++R19TrmACm7NhAv4tiyc2a5SmYXCLKi9qicytFA5egsoFtgLOsUX9neNX9Y?= =?us-ascii?Q?6r9mH5hSmT85AnK5wQodIMS8k4KpBvtf4fQIAwLbdbPB9K9iX+ANjRIxQgK8?= =?us-ascii?Q?psG4cXkHbRxKNG57pyxAtC78lJFqK0G7zOXk1PJGioVDRoWiFOx64zSPEXOj?= =?us-ascii?Q?EzfgrDO2Qexm7sayX/JADOg8ZWwF6QMNXpFU9c3v06fUcFYkUGNUhKZyTKFd?= =?us-ascii?Q?/fqVikC+em1lTX1zacYPSy7BcBtauARxnx8nkXT10JiNDHr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YXgnOQvzIbGMs4UQJM7ChGLzcw=; 24:Z/6BX/HvSHFrt4Pybj+iZq383yZY15OaqHBHZEay4pxsy8RyPzBUr2DtMBh6lidfrQNQLsRSM6dCWBCoNL7tTYqG3FO5fBVkqFBuJdvSn7M=; 7:YNjI6VXAq+urnCWows9bjod+/u1Mwr2XbbsUXRDK7HvtHn3OVxlBco7ovaC+32YWxXAzgGdSKPcrhwLgDJb4gtcuI/QYUvfxTs/HPJ9acV7ouOUkVFb/Yh1xQKMCg4OU9GBCRU0SnFFC24ZsIXrJxKyWlnaj6tCnoHXY04JE6VXXxzqoqAAph9mwxfQPXjn3soFXX9tdJJcCA0yX2hU0lSeW18RtxwdbpAjr95Nqd2V4+10BT461By64lPsoSpPP SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1448; 20:nPfqc/9KGlhwcMMPl04X5bCVdiVzHHgVum4upTZOC2jFXRaA9Xc4f2mDwCVQxXfFcVDSXd4AZO0Bf28BSPtIOVBJfkXgRxHjSDDcoGJy8g3A1Jogk75p1AVh2K29pHjnUeMlD1L7y8Vp10FHN+A9Jq/MlorhLkMSqgqBcQhUEfmNUEjhY5uqC4NSTU44KPIHRcLyX4fjWlrKG5/76arft968WWUREsKQkHS7ltxcHfFliqOark+kok7+37dihsaV X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2017 11:44:48.1855 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0dc1f05e-3f7e-4456-25fd-08d5319e6f3e 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: CY4PR12MB1448 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 25b0fa5..1543532 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -442,17 +442,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;