From patchwork Wed Nov 22 05:36:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10069811 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 1615B60353 for ; Wed, 22 Nov 2017 05:52:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F8B929B45 for ; Wed, 22 Nov 2017 05:52:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02BF329B49; Wed, 22 Nov 2017 05:52: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=-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 7C60D29B45 for ; Wed, 22 Nov 2017 05:52:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C70616E5DB; Wed, 22 Nov 2017 05:52:56 +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-co1nam03on0081.outbound.protection.outlook.com [104.47.40.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F4B86E5DB for ; Wed, 22 Nov 2017 05:52:56 +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=f2piKySjU2r1rPWj4Kd32OYLP47LHKGuSBDUimw1c6I=; b=uwb/90OcND6HT1u+yOMVk9ApGQs0xpxtag9nIGrM2Ei9ElAmMcWJJ2fugLrF7ed0pQqBASwM7wQjhZ4Hoczhc516yzH2Bz+m9NICSMunN0dDRqAjvVf5JgV8+/iWpjICEhVmFF5ZaY6vgaLqU/rh8BpsFDnFK/p4MiY2KmHeonE= Received: from BN4PR12CA0013.namprd12.prod.outlook.com (10.164.241.23) by BN6PR1201MB0051.namprd12.prod.outlook.com (10.174.114.13) 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 05:37:03 +0000 Received: from CO1NAM03FT003.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::207) by BN4PR12CA0013.outlook.office365.com (2603:10b6:403:2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.218.12 via Frontend Transport; Wed, 22 Nov 2017 05:37:03 +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 SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT003.mail.protection.outlook.com (10.152.80.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.178.5 via Frontend Transport; Wed, 22 Nov 2017 05:37:03 +0000 Received: from roger-build-server.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.361.1; Tue, 21 Nov 2017 23:37:01 -0600 From: Roger He To: , Subject: [PATCH 1/4] drm/ttm: add page order in page pool Date: Wed, 22 Nov 2017 13:36:53 +0800 Message-ID: <1511329016-552-1-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(39860400002)(2980300002)(428002)(199003)(189002)(36756003)(104016004)(450100002)(316002)(5660300001)(5003940100001)(478600001)(4326008)(110136005)(54906003)(16586007)(72206003)(53416004)(77096006)(8676002)(48376002)(6666003)(189998001)(8936002)(356003)(81166006)(86362001)(575784001)(81156014)(47776003)(53936002)(50986999)(2906002)(68736007)(97736004)(305945005)(50226002)(50466002)(106466001)(101416001)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR1201MB0051; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT003; 1:e3oO5qVhhoTLH67Vp2XlWDNRPHPvwbeQoh3nKK/jKQpN3wmF1MlshUQiC706hcBwz21+EQN0SxZigkyPNxx6lK9CzzTW4i8EXFCGVjOODBMauccKkxdfcljY5tHAVJq7 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 38858ba5-85dc-42ea-f242-08d5316b0f67 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:BN6PR1201MB0051; X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB0051; 3:EA/vcGR55l28S9yCg1cuZXnH40OlIsyLmrkZgi4gO3kpBcSy8AcHSa7r1YyAEWlGQ3yYgQZFR/hnkiuFFynh7tSmXOblGhFc4nmmeEEft6HA5DXGviEzO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ajb1puf+hmxXyfrl0w2+xotZteJCADmLnSwx+Te1hEpqVPu01R7ePSLtqmZQOJmOkfacB8GNAlumjrbSJ5bKOxyccIDhxgUWeX8RoFsOeNzTU0tbj5iUWmAIo9WSOle8wTpBmrgc0xjiM5OhdYE19aBT3dQH9yJxz1H5fDJfAylfsdI4/CbR1AknTHpFTJqntdc13NuqO7M0X0+wYPdVBk7VotqUGs5Clf88JCmEUzVNdqY/p1vpXh69Fl55Zx9vHcVrFUqLdx1QAklqu1P0M50KQ87HVBE1eyBBoBqvmgKMJuC21/GFNWmYeKQdK4Sln9oclqeppmr/Q0 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)(5005006)(8121501046)(3231022)(10201501046)(93006095)(93003095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123564025)(20161123562025)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR1201MB0051; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR1201MB0051; X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB0051; 4:rAnT+FudRVwaRNRz8aCXj115LdN9A5+8K0DrfgEKrwe1Iu7LCtKkHBQJsi/nkPs7MNFKt32toeVALb9W3dx+L3yJhjiyQd2s27aEN/62KPpeb71FBwkpvT28tB5kAuwe5cdblVgqxiUCb9wCT4o4D7h6sdkPS0UhqsDw0hxg/h3NXjzOdyWrxveLrAkqF5oaOnKfM+BbLmh/PG5LpF+0AqaDB7+m4uMwcijnBji7/qwM7+H6q7TzabIm7k79vwZqZdp6r/1IYETDF+NpsQY3rdSrH4A5TSAXV2Cj4bKgeHNl0fDbWtWkYf6UpySR8Rmk X-Forefront-PRVS: 0499DAF22A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR1201MB0051; 23:PW6hAKsywlsb3QE7VxLB7eEB7GWdZ0+xJSvX+FE?= =?us-ascii?Q?tCA0srqc7nTRb8Rhe49zC6m72rCmZH0uTG/Qh0fncaWVeKEcvBFhaCixSMMb?= =?us-ascii?Q?OkcdzacqLNbttZoFbenlVZYSkgbIXmD0XXESwS/71nh41DooCkE/+3hcv35W?= =?us-ascii?Q?klF2RoL6ccmZ6T/jWWvOk4vHdw924tSh0opO/6Zhvj2KratQjqezr5+TddNu?= =?us-ascii?Q?xeIZctFrXQ0WOG65XFDVtKAgnYrKidFxAhdIVy6QfV/5r+umbq6zgpxRpDi6?= =?us-ascii?Q?UQtM97b3Jb0LabHMGCbJi+TJPXTEXYI8peyFJdIHW+gehSUIy5tpkGwrP4NG?= =?us-ascii?Q?n+rizVa95iwBWRJm7jGJMtiFKVjV6957/JLOIU7y+RPUWs3MfCQaS/KgVDTu?= =?us-ascii?Q?vTLfklTPQFfeQZr03Q0y09WjWpEmPrrwUAjeLci/KrwnvG8pGzFrWkzloxkA?= =?us-ascii?Q?mJwybYxZvtrgohF7YtNl8U3Zq2LdELmZjjKGwllAus+rvk9I0ZQbdXq48Tp4?= =?us-ascii?Q?ZSZPYp2Rho6iMqaU6Du4LZZUnv3uCM/utQF29FUxNNvRqbdWhO367xb0A0Zc?= =?us-ascii?Q?hzR3CWfwgE/oV3mm2LfBhXmVNsElz17fo/bFwMatBG/rvI2njS+kJhD/1VPD?= =?us-ascii?Q?kuBx60L2OU8M1+OPeAsnFNqkF9gGEFNlpxdYDswG6+6v0A/vtdePVepKAqnI?= =?us-ascii?Q?/uAZWCKnWeTOG679AaRg4Me9l2XQNcZgck3NfiA4+1WTR/YkAPLKyVdpzAG5?= =?us-ascii?Q?LqIo73ZrpoQYD+Ztz3JL/Xt4h5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4KO2ZkoHgAWJRCEiv15uBXOhQVFK0JEYy036M1kI/Cjgh2utPy8n+r6HXvqV0V8m9fPwGm7Sj8Cv6ZKQcjYjsd+mSKUfTtxhhubCujykV4orDl+VAT99t9B8F7mQLrK5m2Wa6/UMK+/5e5HLrjCj5Wnk4azENO2W0FsKLKFC9GqRwGZx792H2qg6x5nDlbeZMF066gN8wds1UpdAwF/792Wv6L SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB0051; 20:I2p07gyweyEARUn1OMrywEG+ENvC3vC0jG8uTr0iXtateixEu1bbp5qEi/ZpsD+KcPBdrCGMqnoCEwyI8p76yxm8zDKXAAtVTQ82B9fspggoeWc5DfPRoZ5ksa4iuM8kDyrDj4FubjqiCwP0aFuy8kWobFtfs/U6JKg+sNccNxImKanFmZIjaqx9dGtgiIXBSReAA9mhTkNB6+KhXgGNmMT06ktfBH7vyKVABVIyhfKq8VzxGUCZJjuKog+Gelj7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2017 05:37:03.0494 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38858ba5-85dc-42ea-f242-08d5316b0f67 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: BN6PR1201MB0051 Cc: Roger He , Christian.Koenig@amd.com 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 | 42 ++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 72ea037..0a0c653 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; } @@ -932,7 +942,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; @@ -940,8 +950,18 @@ 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; } +/** + * Actually if TRANSPARENT_HUGEPAGE not enabled, we will not use + * wc_pool_huge and uc_pool_huge, so no matter whatever the page + * order are for those two pools + */ +#ifndef CONFIG_TRANSPARENT_HUGEPAGE +#define HPAGE_PMD_ORDER 9 +#endif + int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages) { int ret; @@ -952,23 +972,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;