From patchwork Mon Dec 4 12:12:33 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: 10090035 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 1C1BC60327 for ; Mon, 4 Dec 2017 12:12:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E010F29163 for ; Mon, 4 Dec 2017 12:12:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D50452916F; Mon, 4 Dec 2017 12:12:42 +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 A081A29163 for ; Mon, 4 Dec 2017 12:12:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 784236E337; Mon, 4 Dec 2017 12:12:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 841A26E331; Mon, 4 Dec 2017 12:12:39 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id v22so17016893wrb.0; Mon, 04 Dec 2017 04:12:39 -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=yI7r2q1inzqeRIRLv61hjWlxoQzT8IZ7LwVL343lQL0=; b=qG3Mxz6uk/QzPQ7VzH1FIP4Ee9qMy9jGXCyvxEwZFuocJdkZ90d+ob3mb24RVdeaY4 ubVadCqjA+rM3O0RcAFZ/JqHL9UopQVhXckpn7Ir3SEVjtqa6rMy442SlSe5QiGjrM5B fXOtNQXbUsKzwIWBirbxYOj9qXR5kaS7p5es5qWMoDbyXe7hI25reatcVpBMpzX1JISZ IEcNUDEI4y9iYc6JcZFaQCdGMUVpriJNw6CA+ZPFSv6FATULazRHTYCrA2WtZ6nljTl8 TQ/GKRDHTbqLZbPq5Z622FquRS+A+Ky51/HmtSw7owUjAPrhQIQr4/Zyq7Ot2sIzQLOJ aCVw== 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=yI7r2q1inzqeRIRLv61hjWlxoQzT8IZ7LwVL343lQL0=; b=Jagy1pbWUHWWM21NUB+UEsrVO7ELYRxD8mq3QsvbV9sLfelN4xOkl+5wZxQGWN5jq2 iB/WtGRh/6ay9KCGy2Hw/yL8M4wZ29WvDxK0dTGVh4aknKGhzw9tNhyUZj5cJHFjr+aK vEDcDzetem/S1dJx0Ci+PXGZFOvqYGjWvOb7Mn0YSnhtOmNPZaOQQxvrfMn1OPKfnlz7 KCPQysDAMG/g0v8n/JMHw1cCegNJrkCjCtZyeS8Ut//TLt3dBKs0Fmyl+vC8EIED5FEa wuCPBy4/mLKQMKIpFaH9mip/ZJUh/LKyYv8O+rV8DI3XSqZ4WVtpqoB/Iw+lyW+d+Pfv Qrvw== X-Gm-Message-State: AJaThX65/3wUa0ueIhn+PDYbVoPreY7KMs6R6xYcFJqgbVHDXAWPABoa vzu9IrId0RiUOUfFMAN84e8Dzw== X-Google-Smtp-Source: AGs4zMa0XZKC65MPmJVTNiAL2yBfvds4P1osMqDF++wAZSfBdHpfEDZ7gRiFZSR7eTqTqqYjYvtuTw== X-Received: by 10.223.160.61 with SMTP id k58mr12194214wrk.252.1512389557993; Mon, 04 Dec 2017 04:12:37 -0800 (PST) Received: from localhost.localdomain ([2a02:908:1251:7981:c5f1:d194:ba71:cd9d]) by smtp.gmail.com with ESMTPSA id d10sm3844150wmh.15.2017.12.04.04.12.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Dec 2017 04:12:37 -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, ckoenig.leichtzumerken@gmail.com Subject: [PATCH 2/2] drm/ttm: swap consecutive allocated pooled pages v2 Date: Mon, 4 Dec 2017 13:12:33 +0100 Message-Id: <20171204121233.9164-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171204121233.9164-1-christian.koenig@amd.com> References: <20171204121233.9164-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. v2: use swap Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index b6c5148607e9..29652b2615a8 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -953,8 +953,12 @@ 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) + swap(p, pages[count - 1]); pages[count++] = p; + } if (r) { /* If there is any pages in the list put them back to