From patchwork Wed Nov 22 05:36:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10069723 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 6E3A26038F for ; Wed, 22 Nov 2017 05:38:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67965286A8 for ; Wed, 22 Nov 2017 05:38:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C19C296C4; Wed, 22 Nov 2017 05:38:01 +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 3F7EE286A8 for ; Wed, 22 Nov 2017 05:38:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B08B16E5D6; Wed, 22 Nov 2017 05:37:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 72224 seconds by postgrey-1.35 at gabe; Wed, 22 Nov 2017 05:37:58 UTC Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0045.outbound.protection.outlook.com [104.47.40.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2EF156E02A; Wed, 22 Nov 2017 05:37:58 +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=24Jw4bDnFWMIF5maSl4YHZOt69AiP5u1ylDQgrdqReU=; b=Jzy0IbLSKdC/S4LjDChpBfzmgssP3OM+N5S/zvJ095gdW3dMpKHpCH9JpYKm+StCetsAEhj1OLxv6h1Sj1v3uc1+MgCihGiYWeFYS0zC58Zs73V9GPkSWiNzz0f9pYsRY/eA6ujPeV6NOBtg6rofTJP8Qz3XsVHbGYmn/D6aHiA= Received: from CY4PR12CA0028.namprd12.prod.outlook.com (10.175.82.142) 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 05:37:56 +0000 Received: from CO1NAM03FT054.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::204) by CY4PR12CA0028.outlook.office365.com (2603:10b6:903:129::14) 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 05:37:56 +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 CO1NAM03FT054.mail.protection.outlook.com (10.152.81.181) 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 05:37:56 +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:54 -0600 From: Roger He To: , Subject: [PATCH 3/4] drm/ttm: add static buffer for ttm_pages_put to support pool shrink Date: Wed, 22 Nov 2017 13:36:55 +0800 Message-ID: <1511329016-552-3-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511329016-552-1-git-send-email-Hongbo.He@amd.com> References: <1511329016-552-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)(316002)(8936002)(47776003)(101416001)(16586007)(54906003)(50226002)(68736007)(5660300001)(97736004)(110136005)(106466001)(53416004)(53936002)(77096006)(450100002)(86362001)(105586002)(4326008)(50466002)(48376002)(5003940100001)(189998001)(356003)(50986999)(2906002)(305945005)(2950100002)(8676002)(76176999)(72206003)(81166006)(478600001)(81156014)(104016004)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1448; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT054; 1:ocel7w8dXZ+ZPwoLQZRhv/jNYBcbsVabRasblSEc/11qVFkzK95erjkHOmpOW/rc2HoQXiwhLNejA1NXO66XLpsjre/TgvLd5BBp1qFdNnj7EziB5cO70/Ufn8ZzUm/m X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 72c5e304-a1c0-47a4-d6ca-08d5316b2f1f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:CY4PR12MB1448; X-Microsoft-Exch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vAlr3VV0RakVCOJgzngZlMheBuepTcAG+KPJ+m5Amr0FDcM3dOq0Zg/sLbm8wxK2dmtC5H8PWHKK+DfiZzRSFDkMl4BjTbs10K6PPVmggk5MyrRUKGrCPEG5BbqmHpVQ3Al9in40VuMICilF++5TO/h7+lAZP21vJufSMKfvhZ8LIKvB8qP5GBcaxd4maDiM6KyrTzXwrepnTpyqcN2F4OdvTwBdOEVQ4Ef/4tU87R/WTd+y7KBYXg4SPdbA3ngLtoLY3MwH5YQye/4M9JcMv5ec7niC6WlKCKDzZan9U0PsggPC/0a/L/Za6hXdCwl36gcdTsnsiOp/6pTa481kzX6Jh9cwDI7tiSQNm6RBgxgNMu8bl3TM6gR8+ieuzs6SrSfocDpWELd9ji5RLQ68WVddKmNgnM4QVq7wIfYYNTxqqET8r/ugScxE3uL3jpHbQGquX+rfrMWaZVqAU2UuV1pmidup6oK9qkVvN+trdI3 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)(10201501046)(3231022)(93006095)(93003095)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123562025)(20161123560025)(20161123555025)(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:I9NqrqFIoFaLGIzig/rk1If6i/iXY+dcV/RSlNEKchhp+/9PuvFV8OTYmM45KS1Ei8oK7RgIsSrAjCg/7q3CaeU232HBxkQvSbO1SieAoW/bYcFRgC/fvu4/VR08r7QildVtp4OfqvafLwMpuf5DJR2d7uu49MRwhHbic3hQoiaOff2m/cZZxSJjwaXDsw/rrXUejfSnb9POn+lUYEWLn3smMXD/GniVn5oGydaeCXixZksUcIE7pbg10L6vOfzccIYLBdLhyZ+tZVhUvDQBhgfwWMTdAMkkMfH8m6hRcAqdKVi3KrwBrsj/e/Kr4vwS X-Forefront-PRVS: 0499DAF22A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR12MB1448; 23:A4d8HusOhd6G0qFQ9rxst69JDZe+1h1xXnQmS4+rj?= =?us-ascii?Q?Y7kHlCQ4z1B5QvHd3f7cmFknJ40ti9dpgCtqagyc4WJomt3BOejTc2um3Xt6?= =?us-ascii?Q?1LX1TMA3jBqP5OeDABGWbNkqldp/LmJzs/D5tviv5bPponJ0+8toSaSAZdqv?= =?us-ascii?Q?nCPdoTx0FevbTjwQmBjGe3sRH6bVoKj3f3QsEgnPDEMNYTVBSbp97pmwxTcR?= =?us-ascii?Q?dx1w/4wOAPeMfI0qXj0VOAD4sdRAWBELSzbWzq7YrBwtPyYRCULMVPBnELIu?= =?us-ascii?Q?Urw0guk4H9kIXb/UMhkzIE8uZNUTCJyEt3TgLJX1mP6/Vt4QSKxSIpSo0jXC?= =?us-ascii?Q?dxc45pyDC/JWTvSf0AQjn2olkeRlXXpWnoVUi/JpvvoXH2aCxXIhpYaacw7C?= =?us-ascii?Q?96+axstaNeXzYV1ToLmhtgzuLAWyk4O0i/fvWmnA0EJcoL8dmSZQouXg6YB7?= =?us-ascii?Q?0uIqdR/SZMUU8K4OKiliGWx15vIOAtmyL7r9sy8uwVd9X31ra9ph+0MLZfza?= =?us-ascii?Q?Nt1JiwAj45HeVi28Z27aulL1hPwcqr6qUkXx8IwOHqK0TRpKNcP/KZvTUYT8?= =?us-ascii?Q?hjKiU1dn8r0KzhHLhzu3RMR3aw401c89SyZXfrmk9RY6yEEmu0z1kbxH1YIj?= =?us-ascii?Q?HramEV1+5m4aFx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sQT8I=; 24:F1LFK/NV06c5RiewmE1f9u4slqzVx8+ZEPhFkVzaFG5GMglBkwU4MmlSikJ76HSPOm5s2sYfh3alGuNHPhuoZzK0NdmRM/jVbVARfteaVgY=; 7:3rReRoob/Z1WXECaorIcdofrESrYOi1kZe6islegYwyh/PpyXcfMjeqPHpiC1sY+6b1bNtM38oDx6E7WmMz7FOTQaEbnHum5qkpsODBU8JuyZdQOfgOoWMZs6NhY64g4/d98RnE7sHSzdETzEMfN5YYlxR0V2Zy0Kvj6VXl+h+oQhaw0Ul4GzXZGhzJBEQoYGXco9pn0RXo4QHVWmABwWgthj7mcQ4BSo3ZNP9MKlRktPgmoohybVxcSInSYpd94 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1448; 20:c0JiRfhqmQKdEtjKCmhSH0dAuk2F7q5QbtsAxSsaI/8kBb06yBnrl4oMI2/XlZiWr+rQJMuq+b/BZgjY1EZiFUvxBfmZQfopO/uJ1w2wXmJb8sN/WO/kkFnJTsIqam1yvQVwE5y+jze175eTG8FsLXvO0i6b0go35Nz1G2eXk1oq9j6AvBp4zl7MaVeIQACCZ7u0OysK5zxP5hxKfntyBB9Uzhzl4Wv55oKd5XAmjdmCGM1J/dganrHT+42OfvRT X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2017 05:37:56.2795 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 72c5e304-a1c0-47a4-d6ca-08d5316b2f1f 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: CY4PR12MB1448 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 Change-Id: Ic20c016eb3043d7cfedc2e3648790a017168da6c Signed-off-by: Roger He --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index de64209..37c2f2f 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -285,20 +285,27 @@ static struct ttm_page_pool *ttm_get_pool(int flags, bool huge, } /* set memory back to wb and free the pages. */ +#define STATIC_BUF_PUT_SIZE 512 static void ttm_pages_put(struct page *pages[], unsigned npages, - unsigned int order) + unsigned int order, bool use_static) { + static struct page *static_buf_put[STATIC_BUF_PUT_SIZE]; struct page **pages_to_free = NULL; struct page **pages_array; struct page *p; unsigned int i, j, pages_nr = (1 << order); + BUG_ON(use_static && pages_nr > STATIC_BUF_PUT_SIZE); if (order > 0) { - pages_to_free = kmalloc_array(pages_nr, sizeof(struct page *), - GFP_KERNEL); - if (!pages_to_free) { - pr_err("Failed to allocate memory for ttm pages put operation\n"); - return; + if (use_static) + pages_to_free = static_buf_put; + else { + pages_to_free = kmalloc_array(pages_nr, + sizeof(struct page *), GFP_KERNEL); + if (!pages_to_free) { + pr_err("Failed to allocate memory for ttm pages put operation\n"); + return; + } } } @@ -317,7 +324,8 @@ static void ttm_pages_put(struct page *pages[], unsigned npages, __free_pages(pages[i], order); } - kfree(pages_to_free); + if (!use_static) + kfree(pages_to_free); } static void ttm_pool_update_free_locked(struct ttm_page_pool *pool, @@ -380,7 +388,8 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free, */ spin_unlock_irqrestore(&pool->lock, irq_flags); - ttm_pages_put(pages_to_free, freed_pages, pool->order); + ttm_pages_put(pages_to_free, freed_pages, pool->order, + use_static); if (likely(nr_free != FREE_ALL_PAGES)) nr_free -= freed_pages; @@ -415,7 +424,8 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free, spin_unlock_irqrestore(&pool->lock, irq_flags); if (freed_pages) - ttm_pages_put(pages_to_free, freed_pages, pool->order); + ttm_pages_put(pages_to_free, freed_pages, pool->order, + use_static); out: if (pages_to_free != static_buf) kfree(pages_to_free);