From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0700CCF9E3 for ; Mon, 10 Nov 2025 14:27:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 118A710E074; Mon, 10 Nov 2025 14:27:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="Cg+ZW5Um"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id D1D2E10E074; Mon, 10 Nov 2025 14:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1762784871; bh=I3hDlgnUiFEeHYO7l/Z1ZTVOyh5tZR91I5wEgfYLxhA=; h=From:To:Cc:Subject:Date:From; b=Cg+ZW5UmcV+OPWWiVEIBEa71YhgKHcLsSHBua7s+xkI6A6fo9dVDIF0jxdDR9/4wv MjA1rjz8N0cDT6mEz+IEMwv3O+R84lHlS+D/t5vLSb0p88yV8ct1kCcqxhlXR292s5 n9Um2Vwfx9ZpZBL8HAEmAVSyhGDdJfur9x2h+3L9zpKghOdQBRumTmSI/i5AZuTiqt Sbs1UnPBOMo5g3+xvmhQ+KDbkoNeTRQpOdQ9u7k+3JNGxgcLxf/IX2EWQB6Sm7j7BS YVprWLa9yJWr0bZWJGAIx5IKQNEviK/rAqlW/sLKIUoJF+rFkUUAxJcx4RKj+l7NNO klylxUGZLn0Qg== Received: from debian-rockchip-rock5b-rk3588.. (unknown [IPv6:2a01:e0a:5e3:6100:2e0:4cff:fe03:d8c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: loicmolinari) by bali.collaboradmins.com (Postfix) with ESMTPSA id 5A6DF17E1313; Mon, 10 Nov 2025 15:27:50 +0100 (CET) From: =?UTF-8?q?Lo=C3=AFc=20Molinari?= To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Boris Brezillon , Rob Herring , Steven Price , Liviu Dudau , Melissa Wen , =?UTF-8?q?Ma=C3=ADra=20Canal?= , Hugh Dickins , Baolin Wang , Andrew Morton , =?UTF-8?q?Lo=C3=AFc=20Molinari?= , Al Viro , =?UTF-8?q?Miko=C5=82aj=20Wasiak?= , Christian Brauner , Nitin Gote , Andi Shyti , Jonathan Corbet , Christopher Healy , Matthew Wilcox , Bagas Sanjaya Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, kernel@collabora.com Subject: [PATCH v6 00/11] drm: Reduce page tables overhead with THP Date: Mon, 10 Nov 2025 15:27:35 +0100 Message-ID: <20251110142746.3490-1-loic.molinari@collabora.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This series aims to reduce the page tables overhead of DRM drivers for builds with CONFIG_TRANSPARENT_HUGEPAGE enabled and either the sysfs knob '/sys/kernel/mm/transparent_hugepage/shmem_enabled' appropriately set or drivers using a dedicated huge tmpfs mount point. It starts by checking whether a faulty address in the page fault handler is part of a huge page in order to attempt a PMD sized PFN insertion into the VMA. It then introduces a dedicated get_unmapped_area file operation on the DRM file descriptor for GEM objects to get the best virtual address alignment for the underlying shmem buffers. The remaining commits propose shmem helpers to create and release huge tmpfs mount points and adapt the i915 and V3D drivers. The helpers are then used to optionally enable Transparent Hugepage for Panfrost and Panthor. For Panthor on a Rock 5B, this series makes the first memcpy() to an entire BO object mapped in userspace about twice as fast with Transparent Hugepage enabled. Implementing a fault-around handler using the arm64 contiguous page hint (contptes) could also greatly help reduce page tables overhead for small pages by mapping several contiguous pages around a faulty address at once. This will be proposed in another patch series. Loïc Molinari (11): drm/shmem-helper: Simplify page offset calculation in fault handler drm/shmem-helper: Map huge pages in fault handler drm/gem: Introduce drm_gem_get_unmapped_area() fop drm/gem: Add huge tmpfs mountpoint helpers drm/i915: Use huge tmpfs mountpoint helpers drm/v3d: Use huge tmpfs mountpoint helpers drm/gem: Get rid of *_with_mnt helpers drm/panthor: Introduce huge tmpfs mountpoint option drm/panthor: Improve IOMMU map/unmap debugging logs drm/panfrost: Introduce huge tmpfs mountpoint option Documentation/gpu/drm-mm: Add THP paragraph to GEM mapping section Documentation/gpu/drm-mm.rst | 22 +- drivers/gpu/drm/drm_gem.c | 203 +++++++++++++----- drivers/gpu/drm/drm_gem_shmem_helper.c | 97 +++++---- drivers/gpu/drm/i915/Makefile | 3 +- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 47 ++-- drivers/gpu/drm/i915/gem/i915_gemfs.c | 69 ------ drivers/gpu/drm/i915/gem/i915_gemfs.h | 14 -- .../gpu/drm/i915/gem/selftests/huge_pages.c | 11 +- drivers/gpu/drm/i915/i915_drv.h | 5 - drivers/gpu/drm/panfrost/panfrost_device.c | 3 + drivers/gpu/drm/panfrost/panfrost_drv.c | 6 + drivers/gpu/drm/panfrost/panfrost_drv.h | 9 + drivers/gpu/drm/panfrost/panfrost_gem.c | 18 ++ drivers/gpu/drm/panfrost/panfrost_gem.h | 2 + drivers/gpu/drm/panthor/panthor_device.c | 3 + drivers/gpu/drm/panthor/panthor_drv.c | 7 + drivers/gpu/drm/panthor/panthor_drv.h | 9 + drivers/gpu/drm/panthor/panthor_gem.c | 18 ++ drivers/gpu/drm/panthor/panthor_gem.h | 2 + drivers/gpu/drm/panthor/panthor_mmu.c | 19 +- drivers/gpu/drm/v3d/Makefile | 3 +- drivers/gpu/drm/v3d/v3d_bo.c | 6 +- drivers/gpu/drm/v3d/v3d_drv.c | 2 +- drivers/gpu/drm/v3d/v3d_drv.h | 11 +- drivers/gpu/drm/v3d/v3d_gem.c | 27 ++- drivers/gpu/drm/v3d/v3d_gemfs.c | 60 ------ include/drm/drm_device.h | 15 ++ include/drm/drm_gem.h | 37 +++- include/drm/drm_gem_shmem_helper.h | 3 - 29 files changed, 439 insertions(+), 292 deletions(-) delete mode 100644 drivers/gpu/drm/i915/gem/i915_gemfs.c delete mode 100644 drivers/gpu/drm/i915/gem/i915_gemfs.h create mode 100644 drivers/gpu/drm/panfrost/panfrost_drv.h create mode 100644 drivers/gpu/drm/panthor/panthor_drv.h delete mode 100644 drivers/gpu/drm/v3d/v3d_gemfs.c -- 2.47.3