From nobody Wed Dec 17 21:29:44 2025 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 016E22820A9 for ; Sat, 4 Oct 2025 09:31:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759570281; cv=none; b=KIRW35kSqp3TzXzvmutUwFKkdg3t3gJgRueyBwRerUXVRnLwH4Nynfigjv4SCHcwUBXEE4iyXN7WH6qCUkaRTY6QyMjIaIKyg0i80ZBO1x5IpZmhGzvYQrn3/1dmDMlVLIEQhZbJrUS1rzDFZ2l1FuvlzCIiI0Qvn5QHHUYGR1E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759570281; c=relaxed/simple; bh=D0Fu/ldQhntehM2Mq/IXQJTZKKJwzHie8we5EhgLjv8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gtP1DctedtEgGhIT7EX1MoEazmeQsnfU8/tHpDvWgRrZ9EHm9aBY2xrOuKBSUaSYYmlRVEzUyc44ZthizJNUVm+3fIM4uZjAvjbwfAs34w7WSWQR5Ssgsc6z+st/16VQbcII4O8Nru0YGMQNujZPMOxe6+GlVBrEDJ+bd+QF+54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=AMlhrgUf; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="AMlhrgUf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1759570278; bh=D0Fu/ldQhntehM2Mq/IXQJTZKKJwzHie8we5EhgLjv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AMlhrgUfj67oXsQPTFjfkhXxPYErzu07l7zcQuFt1VeLOO4l1kddXtiTb2X/cetOS 6XMF0S8g5Fu73Rg3lAVLMWykZe56IdRC60HwD9pv/MEZTOZ6Rsmkio0eJfbmu1nwCK d4IdxOltI8YwNAtsLWvnJxFMf/9AVfESz8Ub5ydUncWsPC7OnRkCO+XAq+H4dRQyS2 llItYjnG94oPb9HEZHBOeRVHE+Lsuht91g6GWGJTZzTqRPBN3VlqNnsa57784xcp1/ Of2brQuMsVBOznatNjK2ireFQDvmFsXBo6sqcHe+RO6GcwaxxUcglmxauY2WbuVjd7 UuGUKAQRIUOaA== 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 9C0FC17E13DA; Sat, 4 Oct 2025 11:31:17 +0200 (CEST) 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 , Christopher Healy Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-mm@kvack.org, kernel@collabora.com Subject: [PATCH v3 10/10] Documentation/gpu/drm-mm: Add THP paragraph to GEM mapping section Date: Sat, 4 Oct 2025 11:30:53 +0200 Message-ID: <20251004093054.21388-11-loic.molinari@collabora.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251004093054.21388-1-loic.molinari@collabora.com> References: <20251004093054.21388-1-loic.molinari@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add a paragraph to the GEM objects mapping section explaining how transparent huge pages are handled by GEM. Signed-off-by: Lo=C3=AFc Molinari Reviewed-by: Bagas Sanjaya --- Documentation/gpu/drm-mm.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Documentation/gpu/drm-mm.rst b/Documentation/gpu/drm-mm.rst index d55751cad67c..0ce6e27f8463 100644 --- a/Documentation/gpu/drm-mm.rst +++ b/Documentation/gpu/drm-mm.rst @@ -283,6 +283,8 @@ made up of several fields, the more interesting ones be= ing: void (*open)(struct vm_area_struct * area); void (*close)(struct vm_area_struct * area); vm_fault_t (*fault)(struct vm_fault *vmf); + vm_fault_t (*huge_fault)(struct vm_fault *vmf, + unsigned int order); }; =20 =20 @@ -290,7 +292,7 @@ The open and close operations must update the GEM objec= t reference count. Drivers can use the drm_gem_vm_open() and drm_gem_vm_close() helper functions directly as open and close handlers. =20 -The fault operation handler is responsible for mapping individual pages +The fault operation handlers are responsible for mapping individual pages to userspace when a page fault occurs. Depending on the memory allocation scheme, drivers can allocate pages at fault time, or can decide to allocate memory for the GEM object at the time the object is @@ -299,6 +301,19 @@ created. Drivers that want to map the GEM object upfront instead of handling page faults can implement their own mmap file operation handler. =20 +In order to reduce page table overhead, if the internal shmem mountpoint +"shm_mnt" is configured to use transparent huge pages (for builds with +CONFIG_TRANSPARENT_HUGEPAGE enabled) and if the shmem backing store +manages to allocate huge pages, faulty addresses within huge pages will +be mapped into the tables using the huge page fault handler. In such +cases, mmap() user address alignment for GEM objects is handled by +providing a custom get_unmapped_area properly forwarding to the shmem +backing store. For most drivers, which don't create a huge mountpoint by +default or through a module parameter, transparent huge pages can be +enabled by either setting the "transparent_hugepage_shmem" kernel +parameter or the "/sys/kernel/mm/transparent_hugepage/shmem_enabled" +sysfs knob. + For platforms without MMU the GEM core provides a helper method drm_gem_dma_get_unmapped_area(). The mmap() routines will call this to get= a proposed address for the mapping. --=20 2.47.3