From patchwork Wed Nov 22 09:17:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10069959 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 C3E36601D5 for ; Wed, 22 Nov 2017 09:17:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD73E29BF6 for ; Wed, 22 Nov 2017 09:17:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F4B829C20; Wed, 22 Nov 2017 09:17:28 +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 ECA9529BF6 for ; Wed, 22 Nov 2017 09:17:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63FE689CA4; Wed, 22 Nov 2017 09:17:25 +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-by2nam01on0087.outbound.protection.outlook.com [104.47.34.87]) by gabe.freedesktop.org (Postfix) with ESMTPS id BA92D6E5F3; Wed, 22 Nov 2017 09:17:23 +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=sWbXHO9Cp9D8HWcSFKIOluFkB6TngmZgTVpL3BP54bM=; b=IJW5cflVKlfb9Wezs7B89cwFR3KTQKCZtCkaV/XS7/t3rt+xbAy58QnkUuIeaUCpWYZeEHRiBAU/mSAnVlTfRdvqhgIJyiZm7vnhXvntgUIgU24A9qggKazIF2a8m3qoO+VrB3/nmzciIi4CHbZwo9VdWv8tgB1QJtEgH1+3gf4= Received: from SN1PR12CA0011.namprd12.prod.outlook.com (10.162.96.149) by MWHPR1201MB0064.namprd12.prod.outlook.com (10.174.98.15) 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:17:21 +0000 Received: from CO1NAM03FT004.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::203) by SN1PR12CA0011.outlook.office365.com (2a01:111:e400:5174::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.239.5 via Frontend Transport; Wed, 22 Nov 2017 09:17:21 +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 CO1NAM03FT004.mail.protection.outlook.com (10.152.80.154) 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 09:17:20 +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:17:19 -0600 From: Roger He To: , Subject: [PATCH 1/5] drm/ttm: add page order in page pool Date: Wed, 22 Nov 2017 17:17:10 +0800 Message-ID: <1511342234-18570-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)(39860400002)(376002)(2980300002)(428002)(189002)(199003)(47776003)(101416001)(53416004)(105586002)(189998001)(68736007)(106466001)(8936002)(50226002)(50466002)(81156014)(5003940100001)(81166006)(8676002)(53936002)(48376002)(4326008)(36756003)(2906002)(478600001)(72206003)(450100002)(77096006)(104016004)(50986999)(86362001)(356003)(305945005)(6666003)(5660300001)(97736004)(16586007)(316002)(110136005); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0064; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT004; 1:N8LRyQfGEFcI9SQ8ZjBjlQJdBMRkQdsvkpmyIM6CiDEqXwuR/J+VPvBhAe2Zv8bDh8HPgJA59DwdJIxVwghqIWYIeZpatpE7VpmW2epwAlQaxOaiKwQLRMwWekk91zV9 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f9f49d6f-f16d-40e1-8e20-08d53189d5bd X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:MWHPR1201MB0064; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0064; 3:o4XXsC1rS+VKIcUtCFTOQEE0UPpUA5xuO6e1nKsDkJErdpn/Ar73CpYLm1oYfu3tK5YzbumOp+9mBSnVnE4kVuvj6kLRKaAEAVSQlvB+qXyAXgPdA3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jBeLnzGK5p20U+cym5+X1w9cyw9vM6NSuia7OTrRksM4bN/uKSZIXq8wDbPT0dd/JkVdwF66CdrGGpQ2RoHg4fMWB1hJ2FRxA6/QnehPuD5zJIo2+ydT5IDrSXoGrMhK3D0LiR1Wdho9j0PMNeuk1+AA5YCsmBvu/2KCSwsQYfqpAmMb2T51u2yvf4DYf3CjLDS3ORXugvnlsGD4iccWGe1YEBW1pYzP5f8Zo9Orksf4vFvuQ6mHdkpDviwg565NW8eTkjJBxHu9du3xxy5zYVvQZ29byFYe85z1ugga3ezUWnmS6mxrsEmtQNp5sDW3oKAURNbQjFXkGMu8on6Yko 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)(100000703101)(100105400095)(3002001)(10201501046)(3231022)(93006095)(93003095)(6055026)(6041248)(20161123555025)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR1201MB0064; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR1201MB0064; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0064; 4:PvgszEoqfpNRSPw17iK2NnBT0XRusXHMXe0Bb/Cuei/qOnWLBNLYdgi3yc7bD9nl04M4yodrBWODSa3PNIUyCr8rjrdxqrzcLPfwNDppTzJuLmdGd1IDCKGxxH3xNV/d5B+lLpBCCpRuE40lMCmXUBxC5vHr2TE1+n1j+dQrT6YVVpdqCRRf8+S29vfLF6rmhEGCicvDu98K8hnbkgj3argpikHUsZ/q/Y8s6bD1vecuIGBq9KW+oiVP3ALsogYaewtyWCZN5Qk+9iA7MIjk26rGkm0xyx0kc6Z69hA24smCUR1rSfjl9EJsX+Ya9ab9 X-Forefront-PRVS: 0499DAF22A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR1201MB0064; 23:hndgump2si/hkUa1kkany5dm4W6CGX4P79bg/O2?= =?us-ascii?Q?i7ESggWQbMKpiDzf7dNu9Z+an3uj5EcOI9+ZxaQXAABdN7eiaj2VWkk9AyuL?= =?us-ascii?Q?4OOiwZnVWaPBjkdNu61DveoBpp/edOIxFxrMEZZx0Fhxd8UY5G3Js5DeZ233?= =?us-ascii?Q?qUEyrFf69L3kKYku7HfHbyfVDvGu97FFxaGFtDdvjx0T74i5WF7MtVK+V7FE?= =?us-ascii?Q?hsAvmI57c8I2yQruBOySYwXUPgQpP6nWcrukL/2sApRLlryCseagN0Z+AMdb?= =?us-ascii?Q?JV+W0+O2WeVmY8zFUVDZmt5GrCLe7lzX5FOL6LVoDuF998EqFjE0p+KFaatW?= =?us-ascii?Q?O+/PzTfYwt7/uH9j/eVssj0OAPaOjcqE+Pk11tTpGiSCdVK10Vd/j6Y6O65i?= =?us-ascii?Q?yymczybNRxulTAs/zdq4XMiDvE4kllus4/GGqdd1AKU5ryP7/tnPbUb62ik1?= =?us-ascii?Q?1tZgOFyhP+9ELZpyrnK46Q+JZpXvGY4YNYX377fguDCrNu3HRS0O/FXQbAsq?= =?us-ascii?Q?IS0bTbPGLyrAKPIjXVVM8YuBjdlCVYoazU4abtXrb3DD3gnBJkJrmVJYLbcu?= =?us-ascii?Q?PckiuJ/TGXnOaVDK7GbBYYsAu2yPE4xSxwE8JodV9gzcOfRINlfcesHyK1kH?= =?us-ascii?Q?RculrvlRlNAJafAfdPw4tlPSZ/vHgrq/5582PmMEDCi4p/8tKu5NqsdibAMv?= =?us-ascii?Q?4VOgA2eDjdv1hSKk8kXVN6Olz7gPffHtKPVnPbhGBlnAb/QFf05QvCT4LhWi?= =?us-ascii?Q?j8nSrgTyrD2MtJnu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DvwzXUpoeH9FJXvfi1Gtx1SYnN8K74kD/YCXwYt3Q2xXJV+1YqJVWtuo3Q+PJxiutTUtbwxz6do5yULDzqE21DgrhyQP2mKIhSUkO2T18gW/Sxg+QQHmyERHMZsaffKbyofaoO4rTrh4ftlK0qrmgX0qt6BOsREIVDL70kgnPjytPL+fauyp SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0064; 20:pqIeJ0RTwWoKlGvY/XGIehLGePdwWihu8ambzYS9A2qFXrvFh81J3MfJEAt410AAW2+3hVD/nERWacIqYSP6NBUR1SSUhHIFnlS7WFjAAIHTeE6H9bewtulPuwXi9GAIa8wqE2/DLtOBMl/Rxhm5EieeqI1tqEQE+6NpHUVgKA3avJyolzwqbAN3aju/oNVr8KL6vwzBdU81Y9NWMMeQE/Z8KuCTvH3QEbF984VAFalEp8BXzdcoUKBlM5osg/+m X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2017 09:17:20.7168 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9f49d6f-f16d-40e1-8e20-08d53189d5bd 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: MWHPR1201MB0064 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 Reviewed-by: Christian König for this one. --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 38 +++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 7385785..a02bd65 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -84,6 +84,7 @@ struct ttm_page_pool { char *name; unsigned long nfrees; unsigned long nrefills; + unsigned int order; }; /** @@ -415,6 +416,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; @@ -424,10 +426,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; @@ -439,9 +446,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; } @@ -935,7 +945,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; @@ -943,11 +953,17 @@ 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) { int ret; +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + unsigned order = HPAGE_PMD_ORDER; +#else + unsigned order = 0; +#endif WARN_ON(_manager); @@ -955,23 +971,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", order); ttm_page_pool_init_locked(&_manager->uc_pool_huge, GFP_TRANSHUGE & ~(__GFP_MOVABLE | __GFP_COMP) - , "uc huge"); + , "uc huge", order); _manager->options.max_size = max_pages; _manager->options.small = SMALL_ALLOCATION;