From patchwork Mon Dec 4 11:42:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 10090023 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 893676056E for ; Mon, 4 Dec 2017 11:42:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D93A28F31 for ; Mon, 4 Dec 2017 11:42:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7236A2911C; Mon, 4 Dec 2017 11:42:34 +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=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 3EA2A28F31 for ; Mon, 4 Dec 2017 11:42:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E596989DC5; Mon, 4 Dec 2017 11:42:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id DEE2D89228; Mon, 4 Dec 2017 11:42:29 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id r78so5224633wme.5; Mon, 04 Dec 2017 03:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Bk3AmzUr/38BYYsPaR8a7Hb7+7AyAU4jj+DNf6Ft7N0=; b=PsXwZcInCtJX115PQoIZL44KJJmuCU2R1UH6VQKBFXnjhcfKeL7wbll1GduqFNId8e rcoZYiixYxB6nu4PNC6naNrR8HvIJ2ev+Qiraqq/t4H3Z2u3ZDSvkgcr0TmqM+miBnXm yR6HVUO4P6b+/t3Rw2Z0xXCRKyYK/iuKc4BaSJHginLYqwEf7YiURvbfUWLOys07KWjt 0ooXlfulst2rfPfsZrxmsih/lT0GdQYedhfcypH9zMdn/vJKa51DQ92SLxpOQl0rV7eK nn46xCjvqddhrH09r7CtFhNmi9/01LNFE542deVaFwQe+e0OI71RTXSw9D477qcW2xxO iBgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bk3AmzUr/38BYYsPaR8a7Hb7+7AyAU4jj+DNf6Ft7N0=; b=PDkSWU5KN8UKYMlliBv2aoNdIv/rrckIv8oOVlzf706Urr34nW3JSAOwz5RSLmdAhj XXDMte10imlubGDVQHx3fXzxgWlfatMiZo8MyAaIWpdhxAZ0f7WQCFkVafX0VkkLHXeD 3torygJ6AysIQy4DZZaOiGaUz6CTbfGDF9RRzgjmFD5ttDU7Mzqd2kqcx5G/G/vAcb2y 8sJ6+caSCPKhJKCbcMZHBqheBr1AkGdWI6CfJJdeHqcs32mO8tZdEyXAIXwZ6fmqx74D dXBYXK90ODqO4X1OZz2yLg9Nvh07UAFtatDM1wcX6wfcjCAwyy/Twpf0CDzRyAzv1ghJ Z0Yw== X-Gm-Message-State: AKGB3mIV+tOelodf/KEbiQoBL4tWmv8BJBmERnrXr5UZKcFMHcZ0lDpw EAI7QD+3eDEUrgC2vrultj2qNg== X-Google-Smtp-Source: AGs4zMbyuiM2PQgUFnp/88oWq1IRKEi8tu5rCV8MCTbyxXWdh4MMe4m5nT0M6jyiFz0QkpWdI5xddA== X-Received: by 10.28.24.132 with SMTP id 126mr2914972wmy.34.1512387748357; Mon, 04 Dec 2017 03:42:28 -0800 (PST) Received: from localhost.localdomain ([2a02:908:1251:7981:dd5a:a87c:8925:b9a5]) by smtp.gmail.com with ESMTPSA id v23sm667088wmh.30.2017.12.04.03.42.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Dec 2017 03:42:27 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Hongbo.He@amd.com Subject: [PATCH 2/2] drm/ttm: swap consecutive allocated pooled pages Date: Mon, 4 Dec 2017 12:42:24 +0100 Message-Id: <20171204114224.27712-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171204114224.27712-1-christian.koenig@amd.com> References: <20171204114224.27712-1-christian.koenig@amd.com> MIME-Version: 1.0 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 When we detect consecutive allocation of pages swap them to avoid accidentally freeing them as huge page. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 60401350a01a..909028fd663d 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -957,8 +957,16 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags, r = ttm_page_pool_get_pages(pool, &plist, flags, cstate, npages - count, 0); - list_for_each_entry(p, &plist, lru) + list_for_each_entry(p, &plist, lru) { + /* Swap the pages if we detect consecutive order */ + if (count && pages[count - 1] == p - 1) { + struct page *tmp = p; + + p = pages[count - 1]; + pages[count - 1] = tmp; + } pages[count++] = p; + } if (r) { /* If there is any pages in the list put them back to