From patchwork Mon Dec 4 12:12:32 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: 10090033 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 8EECF60327 for ; Mon, 4 Dec 2017 12:12:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BCB829163 for ; Mon, 4 Dec 2017 12:12:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FCCD2916F; Mon, 4 Dec 2017 12:12:41 +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 CC18B29163 for ; Mon, 4 Dec 2017 12:12:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C7B626E333; Mon, 4 Dec 2017 12:12:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id A1C836E331; Mon, 4 Dec 2017 12:12:38 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id f206so7639096wmf.5; Mon, 04 Dec 2017 04:12:38 -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=Ux0StEE44jjGpSjYB1BWHcoJEHq7tj791aTWf9sE8uU=; b=XQip2iInbFH/o5USMh9KrHEp5A+8pwKzlTZ1/iSPzK4Gl3qUNo6wWD76Z29NPXtH7u NypN6s3JV9pn7F102ZZtYaEsg2gtCoGx2Rt9sZoPwwegsCDCL17tXeYo9CnicYkFJs6M L9JtaNNDm3/NM+bpFm8dK8o7yzwTv1j2Ry/E1JnlA5cu+aPhltoFz0CZxu4yA43bQyg3 cyg7T3JqaAY1vOZRhhj3VLynL6Tatr+FvKuz7oZ8dBYNqkftEs31HoJ/c1FhFHUgHLax uAlTfjkdX07dSG6WEio9pMJSmEtV+5dcds2a2DFnpAPA4lOsfT8eL5K+Z6LRj5EMPuzw SsAA== 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=Ux0StEE44jjGpSjYB1BWHcoJEHq7tj791aTWf9sE8uU=; b=Arkh5kovAg9kSYHTM1mjOMMqmEvF0aXH+AecEVTzw4o4IAQbNHlQJQCLjyh/CYyCvG 8mIlhIS8yjOytx8hpwVW+10qQBA3dkCQ4mjs+NiIDUcMbh4PD9lhAyGIbdICuPwassbu HqLp27BFYHR4v53FySLv2fh/bpiRKIldGd5EQrdfqvhsbsa8KPTBy4DzT39/+BSYZFEk /35pmdpke2T5SXXpyFH7NKY4T/3qp653I5UEV7pQZf2zqojvFEPzoVP98EQNsz9FJZ/o sD7IFXID4rLTELzmBVrQD8Ly7dpWmK9u6eaIFdJ5qIIOTmjlAL5jDZPMei3lfnA+5FlQ YNyg== X-Gm-Message-State: AKGB3mLJalGeb1psFrh95NsSKKfmRcEmdn/WZUVuUYH92D7qi5P60G6S nxKRR2JLMvGUwEa+mOnZInOvuQ== X-Google-Smtp-Source: AGs4zMZ31yXmzeZKTKBC8d9AIeKpibax9oDtXxCXPSgvGODBH0iyVc3ezfduJbyK4cMAAIBqOIYVjA== X-Received: by 10.28.226.214 with SMTP id z205mr7383652wmg.149.1512389557104; 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.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Dec 2017 04:12:36 -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 1/2] drm/ttm: swap consecutive allocated cached pages v2 Date: Mon, 4 Dec 2017 13:12:32 +0100 Message-Id: <20171204121233.9164-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. v2: use swap Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index c82d94cbbabc..b6c5148607e9 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -921,6 +921,10 @@ 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) + swap(p, pages[i - 1]); + pages[i++] = p; --npages; }