From patchwork Thu Oct 12 17:30:28 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: 10002423 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 355CB602BF for ; Thu, 12 Oct 2017 17:30:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C85F28E5B for ; Thu, 12 Oct 2017 17:30:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A5B928E68; Thu, 12 Oct 2017 17:30:36 +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 6D0D728E6F for ; Thu, 12 Oct 2017 17:30:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5AF086E8C8; Thu, 12 Oct 2017 17:30:34 +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 413646E8C6; Thu, 12 Oct 2017 17:30:33 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id l10so4371217wmg.1; Thu, 12 Oct 2017 10:30:33 -0700 (PDT) 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=GYobCCMuSbhjr4Km2xAK8hDEmHEGlqW7/Xu0wfejwp4=; b=sLuO6LbDrNfVUDv1WIlSorBYD7qI8i+Jjz9rPCQu6twzR4tD4Ni6SpcWnxd3FYsVVa 5b68JU0KxfLrArqzzDXBfckSGaiJIiG3LbKtiPSzXPoERchtGrKgzW3LTYvvCEVAkQgZ IUWdfjEihw0l/NYholo0tIMTfi7O7SsOFbls9gecyhA1cv2Qtmfso3eeyjt5cNMc5U/y 8FRQsxXgPF7H7v7MVLrw9FBHu9IVitwHV+p+6kxTtz0FNfgwCofWyLktP+MHD81ePhZR mZg0oU2zuLSvWHf5tJKmfa2SgdBnC4uzFQF8o+2ENYGOiICKFzUl//9AvtCh6mTIvHQ0 r8Ww== 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=GYobCCMuSbhjr4Km2xAK8hDEmHEGlqW7/Xu0wfejwp4=; b=eYuoQjeCICX2k50etH0F0jgXTIg82RYJw7GrIhBxD+wzeVL7uhnNqWyffU803r+ORP zQG+AAzu8jTfoR0hE59sYwnsDl7YLHLG0eJXjsb3HUxZXK0EsXNRHoR1IWOQOAaXpWp/ 5NOxuNyjUzDgLPw9GPQ+sY7PqbgFnx6KWvytBx3vjjoXPPzY+4EIJlD1vp1ucHbaxU5h huHsLxgCuJCq+6EeDwQ0qtl3opCO8qikWM7uov4nZKV0D2uGfmqR0Zz0bF6/MtulZCpk 9t4gYBDukxxBKPjzAfz2mpS1FwM8XjW9WXN6bJrGi3ir9d7zb+W87R9GQg064aYEDMnM hcCg== X-Gm-Message-State: AMCzsaUje+zi1rvmz+ru1MwKS42qYoONJ0n60nPaumfyuZ7KqE2PdYXT M3hNd+5ti31Tc0ETf/OqsQWgf9IP X-Google-Smtp-Source: AOwi7QDGJ+uaibpZOxUxJP+zB6fWp+tVacB836at3v8ZUWnSOlt/ZV8OjHqSt1exZNw8U0FYILDR9g== X-Received: by 10.223.142.244 with SMTP id q107mr2624714wrb.208.1507829431430; Thu, 12 Oct 2017 10:30:31 -0700 (PDT) Received: from localhost.localdomain ([2a02:908:1251:7981:242f:b18b:828c:70d0]) by smtp.gmail.com with ESMTPSA id 61sm12321345wrg.58.2017.10.12.10.30.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 10:30:30 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, michel@daenzer.net Subject: [PATCH] drm/ttm: fix the fix for huge compound pages Date: Thu, 12 Oct 2017 19:30:28 +0200 Message-Id: <20171012173028.1505-1-deathsimple@vodafone.de> 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 From: Christian König We don't use compound pages at the moment. Take this into account when freeing them. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index b6f16e7ffff3..c3be50f41461 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -731,22 +731,33 @@ static void ttm_put_pages(struct page **pages, unsigned npages, int flags, /* No pool for this memory type so free the pages */ i = 0; while (i < npages) { - unsigned order; +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + struct page *p = pages[i]; +#endif + unsigned order = 0, j; if (!pages[i]) { ++i; continue; } +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + for (j = 0; j < HPAGE_PMD_NR; ++j) + if (p++ != pages[i + j]) + break; + + if (j == HPAGE_PMD_NR) + order = HPAGE_PMD_ORDER; +#endif + if (page_count(pages[i]) != 1) pr_err("Erroneous page count. Leaking pages.\n"); - order = compound_order(pages[i]); __free_pages(pages[i], order); - order = 1 << order; - while (order) { + j = 1 << order; + while (j) { pages[i++] = NULL; - --order; + --j; } } return;