From patchwork Mon Dec 4 11:42:23 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: 10090021 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 6157E6056E for ; Mon, 4 Dec 2017 11:42:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53D2E28F31 for ; Mon, 4 Dec 2017 11:42:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46AEB2911C; Mon, 4 Dec 2017 11:42:31 +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 CD27528F31 for ; Mon, 4 Dec 2017 11:42:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 51EDE89CD5; Mon, 4 Dec 2017 11:42:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4478389228; Mon, 4 Dec 2017 11:42:29 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id q9so16906501wre.7; 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:mime-version :content-transfer-encoding; bh=XrCNf31+7t8Gal5F+XWWUCMwO3jPzwrRSGaeuoBJO8Q=; b=n+BQNiXGbTUYUVA75zmfFzohgpT/ANotnpoYZyk4losNhkdJRsZncAz1Ix5oEz1WLg q3Qh9m538HA3jHROTtYMQjm2wOhXOCFAwu+RR4va7RlE+VgDBvGJCd8K1eBO/ZyanFiE csZtKJhyjo7UQqqhrm3dLjqWb4jEhpL7Vy81+fVzbK4OTywveQhFWdmJ2Ca5RNy+DUkZ xphhBnkxMrAXDn9ld6VDJcyEFaAqksq5r3VnPx4eagFfa8iH0rW3q3lbAXnOJsbstOs7 fKaRP/M2KTsUDZj1Vmr4haoNVQnTpIMV3pRHJjRQvs396rnwIVJh7H3LuFDIjiDeGk7P BBNg== 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:mime-version :content-transfer-encoding; bh=XrCNf31+7t8Gal5F+XWWUCMwO3jPzwrRSGaeuoBJO8Q=; b=s6GRtxffzpZeDmWBUtEeLVsJgpVBliENw78ewWew6lebRxlQgK1mae4DvhwIOe991r 3mT1bR35SdB37vhoHCihOeGEVVgE0+q0DrIMErYfOQzRg8B8wesHLmey7T3WcDOS3jMp q98MsKV+4MA/Xwu6E99bSRE5/GlObZl43TYpEsd4+4Wg40p83LNty71se8EVfDP8QYTO Mlaz26+V/uCN1KE1i0N3oQW7Pb9Z6iKqz706nrNa0iPPgw8zx2jC6epzEXC4ilUaq2xq 0XU77UyXwa18Lnzd5eZk1bhAHy3vLeJTHC9a0LBnuJrDLEq8jddPyta2xJtHG0/wnaHz UaiA== X-Gm-Message-State: AJaThX7xzfVHlRmJ3X9x7+JLm/ma0kfHT/1K92+8mIJ9V1WY3Ly1FpCy 9A+XGiPRI6QvERilx410hrDPww== X-Google-Smtp-Source: AGs4zMZS/+RwPZDXJn8UekOfhkiW+lQiIICc7r5kmE7eaVe65CJph31XNJdDZ5376V85R29lA4xS+g== X-Received: by 10.223.180.69 with SMTP id v5mr12210361wrd.193.1512387747597; Mon, 04 Dec 2017 03:42:27 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Dec 2017 03:42:26 -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 1/2] drm/ttm: swap consecutive allocated cached pages Date: Mon, 4 Dec 2017 12:42:23 +0100 Message-Id: <20171204114224.27712-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.11.0 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index c82d94cbbabc..60401350a01a 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -921,6 +921,14 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags, return -ENOMEM; } + /* Swap the pages if we detect consecutive order */ + if (i && pages[i - 1] == p - 1) { + struct page *tmp = p; + + p = pages[i - 1]; + pages[i - 1] = tmp; + } + pages[i++] = p; --npages; }