* [PATCH v11 00/10] drm: Reduce page tables overhead with THP
@ 2025-12-05 9:11 Loïc Molinari
2025-12-05 9:11 ` [PATCH v11 01/10] drm/shmem-helper: Simplify page offset calculation in fault handler Loïc Molinari
0 siblings, 1 reply; 3+ messages in thread
From: Loïc Molinari @ 2025-12-05 9:11 UTC (permalink / raw)
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, Maíra Canal,
Hugh Dickins, Baolin Wang, Andrew Morton, Loïc Molinari,
Al Viro, Mikołaj Wasiak, Christian Brauner, Nitin Gote,
Andi Shyti, Jonathan Corbet, Christopher Healy, Matthew Wilcox,
Bagas Sanjaya
Cc: linux-kernel, dri-devel, intel-gfx, linux-mm, linux-doc, kernel
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 (10):
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/panfrost: Introduce huge tmpfs mountpoint option
Documentation/gpu/drm-mm: Add THP paragraph to GEM mapping section
Documentation/gpu/drm-mm.rst | 29 ++-
drivers/gpu/drm/drm_gem.c | 202 +++++++++++++-----
drivers/gpu/drm/drm_gem_shmem_helper.c | 79 +++----
drivers/gpu/drm/i915/Makefile | 3 +-
drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 48 +++--
drivers/gpu/drm/i915/gem/i915_gemfs.c | 71 ------
drivers/gpu/drm/i915/gem/i915_gemfs.h | 14 --
.../gpu/drm/i915/gem/selftests/huge_pages.c | 16 +-
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/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 | 21 +-
drivers/gpu/drm/v3d/v3d_gemfs.c | 62 ------
include/drm/drm_device.h | 15 ++
include/drm/drm_gem.h | 40 +++-
include/drm/drm_gem_shmem_helper.h | 3 -
28 files changed, 418 insertions(+), 289 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v11 01/10] drm/shmem-helper: Simplify page offset calculation in fault handler
2025-12-05 9:11 [PATCH v11 00/10] drm: Reduce page tables overhead with THP Loïc Molinari
@ 2025-12-05 9:11 ` Loïc Molinari
0 siblings, 0 replies; 3+ messages in thread
From: Loïc Molinari @ 2025-12-05 9:11 UTC (permalink / raw)
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, Maíra Canal,
Hugh Dickins, Baolin Wang, Andrew Morton, Loïc Molinari,
Al Viro, Mikołaj Wasiak, Christian Brauner, Nitin Gote,
Andi Shyti, Jonathan Corbet, Christopher Healy, Matthew Wilcox,
Bagas Sanjaya
Cc: linux-kernel, dri-devel, intel-gfx, linux-mm, linux-doc, kernel
For a fault at address addr, the page offset is
page_offset = (vmf->address - vma->vm_start) >> PAGE_SHIFT
= ((addr & PAGE_MASK) - vma->vm_start) >> PAGE_SHIFT
= (addr - vma->vm_start) >> PAGE_SHIFT
Since the faulty logical page offset based on VMA is
vmf->pgoff = vma->vm_pgoff + ((addr - vma->vm_start) >> PAGE_SHIFT)
We can slightly simplify the calculation using
page_offset = vmf->pgoff - vma->vm_pgoff
v11:
- remove misleading comment
- add Boris R-b
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
---
drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index dc94a27710e5..e47ab3ebb5c2 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -577,8 +577,8 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf)
struct page *page;
pgoff_t page_offset;
- /* We don't use vmf->pgoff since that has the fake offset */
- page_offset = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
+ /* Offset to faulty address in the VMA. */
+ page_offset = vmf->pgoff - vma->vm_pgoff;
dma_resv_lock(shmem->base.resv, NULL);
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v11 00/10] drm: Reduce page tables overhead with THP
@ 2025-12-02 10:17 Loïc Molinari
0 siblings, 0 replies; 3+ messages in thread
From: Loïc Molinari @ 2025-12-02 10:17 UTC (permalink / raw)
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, Maíra Canal,
Hugh Dickins, Baolin Wang, Andrew Morton, Loïc Molinari,
Al Viro, Mikołaj Wasiak, Christian Brauner, Nitin Gote,
Andi Shyti, Jonathan Corbet, Christopher Healy, Matthew Wilcox,
Bagas Sanjaya
Cc: linux-kernel, dri-devel, intel-gfx, linux-mm, linux-doc, kernel
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 (10):
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/panfrost: Introduce huge tmpfs mountpoint option
Documentation/gpu/drm-mm: Add THP paragraph to GEM mapping section
Documentation/gpu/drm-mm.rst | 29 ++-
drivers/gpu/drm/drm_gem.c | 202 +++++++++++++-----
drivers/gpu/drm/drm_gem_shmem_helper.c | 79 +++----
drivers/gpu/drm/i915/Makefile | 3 +-
drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 48 +++--
drivers/gpu/drm/i915/gem/i915_gemfs.c | 71 ------
drivers/gpu/drm/i915/gem/i915_gemfs.h | 14 --
.../gpu/drm/i915/gem/selftests/huge_pages.c | 16 +-
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/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 | 21 +-
drivers/gpu/drm/v3d/v3d_gemfs.c | 62 ------
include/drm/drm_device.h | 15 ++
include/drm/drm_gem.h | 40 +++-
include/drm/drm_gem_shmem_helper.h | 3 -
28 files changed, 418 insertions(+), 289 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-05 9:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-05 9:11 [PATCH v11 00/10] drm: Reduce page tables overhead with THP Loïc Molinari
2025-12-05 9:11 ` [PATCH v11 01/10] drm/shmem-helper: Simplify page offset calculation in fault handler Loïc Molinari
-- strict thread matches above, loose matches on Subject: below --
2025-12-02 10:17 [PATCH v11 00/10] drm: Reduce page tables overhead with THP Loïc Molinari
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox