From patchwork Tue Nov 21 09:32:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10067847 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 B87D3602B7 for ; Tue, 21 Nov 2017 09:33:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9FC028C55 for ; Tue, 21 Nov 2017 09:33:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E14928C86; Tue, 21 Nov 2017 09:33:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 12DAC28C55 for ; Tue, 21 Nov 2017 09:33:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 554986E38B; Tue, 21 Nov 2017 09:33:14 +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-cys01nam02on0063.outbound.protection.outlook.com [104.47.37.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5DB266E38B; Tue, 21 Nov 2017 09:33:13 +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=eEvB/JjCrXu+VNhIQ+k7HH2p9vaLAcjambJtI2DU4hM=; b=TIdj1njLI3jw8ot72TE0Kvcl/mso53+ZM7Uz4iw6sz/geIbsVpjvNXKGT/JtlgF2QlXh6To/LB8RCYFeaGibN45/Wdw/X2nDFuKd8c5z5qlPstOY9A153wabnLSqYlsGf+3OA2F5+C6xQx+fsCHdYjL2oAgLmdsQQD8ys6eWGfE= Received: from SN1PR12CA0001.namprd12.prod.outlook.com (10.162.96.139) by DM5PR12MB1273.namprd12.prod.outlook.com (10.168.237.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.239.5; Tue, 21 Nov 2017 09:33:11 +0000 Received: from CO1NAM03FT044.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::207) by SN1PR12CA0001.outlook.office365.com (2a01:111:e400:5174::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.239.5 via Frontend Transport; Tue, 21 Nov 2017 09:33:05 +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 CO1NAM03FT044.mail.protection.outlook.com (10.152.81.108) 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; Tue, 21 Nov 2017 09:33:05 +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; Tue, 21 Nov 2017 03:32:58 -0600 From: Roger He To: , Subject: [PATCH 1/4] drm/ttm: add page order in page pool Date: Tue, 21 Nov 2017 17:32:19 +0800 Message-ID: <1511256742-5601-2-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511256742-5601-1-git-send-email-Hongbo.He@amd.com> References: <1511256742-5601-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)(39860400002)(376002)(2980300002)(428002)(189002)(199003)(478600001)(97736004)(68736007)(356003)(86362001)(48376002)(8936002)(5003940100001)(305945005)(77096006)(6666003)(2950100002)(16586007)(2906002)(316002)(5660300001)(450100002)(189998001)(81156014)(72206003)(81166006)(53936002)(8676002)(50226002)(110136005)(50986999)(76176999)(47776003)(104016004)(105586002)(36756003)(50466002)(4326008)(101416001)(53416004)(106466001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1273; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT044; 1:LVsbsvHgy+BiLffBSOWEUhyNXaLVOtx6y6STvkTpV/fRtomRoIBMjv/HjQ7rJKVOCNwK2eygL9SFWmlkVNUlRbabY2yVD+Scz8VuT0pRtPg6cpkm1DQBjbF6y3ilSr0+ X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5cec9c34-aab2-4ea8-a879-08d530c2de55 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603258); SRVR:DM5PR12MB1273; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1273; 3:agHn6cQEa75s2JJao1ZZkuSANEStFHzJblidAwyfwyNWBut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8ACThqqhkh/r6wfg2z3crN74efx0Tt5qRqzaMKHBRHe48XGJ1TS4Efqmz8Vy47Nr0UbVzh4qdrQ2P6ZYF+K1K7BsYbesb+WDXgZUJ5ut3DNmbnvGYtliPvNIWlORFuwjZY1ZlTBt2IpTuShKkn/BLKVcIqEh0T66SZEt9Zp5d6SA293DkFXoOWDMypbU3zTGW16JQTorUHy7w/8aO7LUO1Rh1OZrNavm2LpUxtaRUK4OFcB2Oi1nHfyDu/P8nauIn5yYgOMbg3sg4tL4oP6Y7L2guWSof6Zhk9qT3Xwp4I7srvzG6kl+9BYMSIMuJ0ENnbvIjrzu/vt9xuioFOU8NU0k7DsFPMF5tYOkTtRSP7okyUpvm0cTM9mbCyRRTO2SaLFwPl6Cw1b/kAGG09C8/W1f8wbaxNJgC6aZEhZpBJY+l 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)(93006095)(93003095)(10201501046)(3231022)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123558100)(20161123560025)(20161123562025)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR12MB1273; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR12MB1273; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1273; 4:+erEmbu2zOheHe/c6zVg2SSwfYifXyxwuFEYufjyMXoikyJL+P5LDmuKHVTUGJStGLGQMWE9S6w71mUk287uVG45PKC8fXwEuvA/qMth2wj95qkugaJWpyPfhwzevxNQ/p90OirHXNhFBJhWaWuChjNQ+0fAyjWs9rLdn7GeFJSdkKGMVsmKwtMrQK3IuKChol/n0FVw3fA3Moo1jDyv+S2N0q7v1Uei2S5bKQqCqvBunRbrsOT2LCEm4FmfnDWsArJth2l+imyx8FySSrSyUorzQUhQ+zo27Odn4ekuvxujd9A9Q4RGbxwKK3hSQMZl X-Forefront-PRVS: 049897979A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR12MB1273; 23:0qU2DbrFN0UQzKq19HkpXkDc5QFm1HRMcCZu4Poku?= =?us-ascii?Q?wll32vv3Bc0HrnYKrkDZ6UuGE2snx3ew/JRE9QWAXOl0wc3DoZZn3AdTaGjc?= =?us-ascii?Q?1lriEhzWehp3+4XH6bzA8/t2EyUi7XA7ucDp9MYxwGlTiPxsOFIWmEsIwiKI?= =?us-ascii?Q?hC7F8KMMJMuk55YipNhwWM/91L9iVDlKMWD5kbQpUONEJctJx/EoShU49qjv?= =?us-ascii?Q?YQ6POV0WAa8LBysB2kz64jdQiGNVYwdR14AtYb9kxpkGsKApTjgiKuXVnLNc?= =?us-ascii?Q?tHO4wuNdL9y1WMU9dq6RLjJtbeDuihMFpDJ8mTUtA/gpyymaUkYXrj6znHpR?= =?us-ascii?Q?UJAYt/XAonlwUrwDUDb+uXc5vxHU+bJM7ee89jjt9Ss3WASWzyaPNA5d2j8i?= =?us-ascii?Q?VFusXpFOD/FobjE40+GlAoPZqKjqzRieEyLp4zPDCD19yn+LjwYHtuGaj7tA?= =?us-ascii?Q?aUCdfMIuuoQ6lbtcrzPHQXePLSoTKjrX9A0gvQ0KfSMTDilFkR4HEB8aB/rR?= =?us-ascii?Q?X857ETcQhRO7d402dFQ0B6dgaSYexbknjlIxXbF0oH8vqJF6At8vNjirPmtN?= =?us-ascii?Q?pF+dRVqI08nB0tnC6Et7dgvYAcnM6Hnr81Lrc5q7vy8FMp01TJtbLicu/6ta?= =?us-ascii?Q?yTTl8D1nhxWOOaaaXL8g9F00LC6YpptWojEI9kPqwZgAIaGSHBM8Yf+4Y1qS?= =?us-ascii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8jwvS1qD5gkZSI+xw+XJuYKGKkbUIUvl1bmx53Gn//SeQhgaLwdcdd4bsogovOir5DFzTbu0=; 7:VtFxA2hSWgKmbI8nXaUGgktjObGp80aROWVdft2jAEK/ZnX+pz8rCSQIM9Su85euj6LsPx+O0/ecKnojCLqvBq1PuVNRNDCTp6rmCP1Y9pZmHU6Rez+EkoWy3WAVyq8ZU3RMPDix5reRT1oKBY9PuWU+nlq+ZKHACEOAdmprZ4uzdt+ta/ndVoCfGFBR8dnoCYUzmvYsaBMQZK8Mo9a9YQpyScpCybnlL+DaS48utRCQKv4rIEtJkXgVG+xMmkST SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1273; 20:ZtawZjCNrv5c+Yp6Eg8uFaqJAfpc2ya41J3+10S1s3L8iCORkpjxalSstjmBDeIsR3DYxQ46OxkfYPF1dFouEg14BjuGhnxVuhgnzc0V0OviGkyzukjk+HVma9uit0xXZxRGQwZBP4pjz3h0E2dJEWBD/R+6c7lKmmqdRXXTOLYGu1ZfbG6WjmVFBy3bp0bYc8Kwr+DrSMY0MYukXApczLGMTaTXhI28VnkY6RHWhyu7F3XD6eY1idgStOUWijiq X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2017 09:33:05.2832 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5cec9c34-aab2-4ea8-a879-08d530c2de55 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: DM5PR12MB1273 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 to indicate page order for each element in the pool Change-Id: Ic609925ca5d2a5d4ad49d6becf505388ce3624cf Signed-off-by: Roger He --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 316f831..2b83c52 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -81,6 +81,7 @@ struct ttm_page_pool { char *name; unsigned long nfrees; unsigned long nrefills; + unsigned int order; }; /** @@ -412,6 +413,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) struct ttm_page_pool *pool; int shrink_pages = sc->nr_to_scan; unsigned long freed = 0; + unsigned int nr_free_pool; if (!mutex_trylock(&lock)) return SHRINK_STOP; @@ -421,10 +423,15 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) unsigned nr_free = shrink_pages; if (shrink_pages == 0) break; + pool = &_manager->pools[(i + pool_offset)%NUM_POOLS]; /* OK to use static buffer since global mutex is held. */ - shrink_pages = ttm_page_pool_free(pool, nr_free, true); - freed += nr_free - shrink_pages; + nr_free_pool = (nr_free >> pool->order); + if (nr_free_pool == 0) + continue; + + shrink_pages = ttm_page_pool_free(pool, nr_free_pool, true); + freed += ((nr_free_pool - shrink_pages) << pool->order); } mutex_unlock(&lock); return freed; @@ -436,9 +443,12 @@ ttm_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc) { unsigned i; unsigned long count = 0; + struct ttm_page_pool *pool; - for (i = 0; i < NUM_POOLS; ++i) - count += _manager->pools[i].npages; + for (i = 0; i < NUM_POOLS; ++i) { + pool = &_manager->pools[i]; + count += (pool->npages << pool->order); + } return count; } @@ -933,7 +943,7 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags, } static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, gfp_t flags, - char *name) + char *name, unsigned int order) { spin_lock_init(&pool->lock); pool->fill_lock = false; @@ -941,6 +951,7 @@ static void ttm_page_pool_init_locked(struct ttm_page_pool *pool, gfp_t flags, pool->npages = pool->nfrees = 0; pool->gfp_flags = flags; pool->name = name; + pool->order = order; } int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) @@ -953,23 +964,23 @@ int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) _manager = kzalloc(sizeof(*_manager), GFP_KERNEL); - ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc"); + ttm_page_pool_init_locked(&_manager->wc_pool, GFP_HIGHUSER, "wc", 0); - ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc"); + ttm_page_pool_init_locked(&_manager->uc_pool, GFP_HIGHUSER, "uc", 0); ttm_page_pool_init_locked(&_manager->wc_pool_dma32, - GFP_USER | GFP_DMA32, "wc dma"); + GFP_USER | GFP_DMA32, "wc dma", 0); ttm_page_pool_init_locked(&_manager->uc_pool_dma32, - GFP_USER | GFP_DMA32, "uc dma"); + GFP_USER | GFP_DMA32, "uc dma", 0); ttm_page_pool_init_locked(&_manager->wc_pool_huge, GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP), - "wc huge"); + "wc huge", HPAGE_PMD_ORDER); ttm_page_pool_init_locked(&_manager->uc_pool_huge, GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP) - , "uc huge"); + , "uc huge", HPAGE_PMD_ORDER); _manager->options.max_size = max_pages; _manager->options.small = SMALL_ALLOCATION;