mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qiliang Yuan <qiliang.yuan@linux.dev>
To: "Sumit Semwal" <sumit.semwal@linaro.org>,
	"Christian König" <christian.koenig@amd.com>,
	"Philipp Stanner" <phasta@kernel.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Vivek Kasireddy" <vivek.kasireddy@intel.com>,
	"Shuah Khan" <shuah@kernel.org>
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"T.J. Mercier" <tjmercier@google.com>,
	"Philip Yang" <Philip.Yang@amd.com>,
	linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	"Qiliang Yuan" <qiliang.yuan@linux.dev>,
	"Natalie Vock" <nat@pixelcluster.dev>
Subject: [PATCH v3 0/3] udmabuf: speed up mmap() of huge page backed buffers
Date: Tue, 01 Dec 2026 12:16:19 -0500	[thread overview]
Message-ID: <20261201-feat-udmabuf-huge-pfnmap-v3-0-144cc7a48f09@linux.dev> (raw)

QEMU and crosvm export virtio-gpu blob resources from guest memory as
udmabufs, which the host renderer and display mmap(). The guest memory is
often backed by 2 MiB huge pages, yet udmabuf maps it 4 KiB at a time:
mapping and touching a 4 GiB buffer inserts a million PTEs and takes over
200 ms.

Patch 1 has mmap() of a dma-buf align large mappings to PMD boundaries,
which any exporter mapping contiguous memory with PMDs needs, such as the
proposed VFIO dma-buf mmap() [1]. Patch 2 maps the huge page backed
ranges of a udmabuf with PMDs, which cuts the time to map and touch it
by 93% for hugetlb and shmem THP backed buffers and adds under 1 ms
per GiB for 4 KiB backed ones. It depends on Lorenzo's series in mm/core
[2]. Patch 3 adds selftests.

[1] https://lore.kernel.org/r/20260527102319.100128-1-mattev@meta.com
[2] https://lore.kernel.org/r/20261117-huge-pfnmap-fault-races-v2-0-276007e73bcb@kernel.org

Signed-off-by: Qiliang Yuan <qiliang.yuan@linux.dev>
---
V2 -> V3:
- 1/3: Add Reviewed-by (T.J. Mercier).
- 2/3: Pre-fault only the PMD-sized range of the fault in all cases and
  drop the THP check before it (T.J. Mercier).
- 2/3: Say in the commit message that it depends on Lorenzo's series and
  that 4 KiB backed buffers now take a fault per PMD-sized range, with
  numbers for them under PR_SET_THP_DISABLE (T.J. Mercier).
- 2/3: Comment that the THP sysfs settings don't apply to the mapping
  (T.J. Mercier).
- 3/3: Size the buffer from hpage_pmd_size and Hugepagesize, use 8 huge
  pages, and test a buffer at a one page offset and a fault next to a
  PMD after THP was disabled (T.J. Mercier).

V1 -> V2:
- 1/3: Add Reviewed-by (Christian König).
- 2/3: Pre-fault only the faulting PMD range when the VMA can't have
  PMDs, so that disabling THP after a PMD was mapped no longer has
  vmf_insert_pfn() walk into that PMD (Sashiko review).
- 3/3: Give each huge page its own data pattern, skip the alignment
  check for 32-bit tasks and read the inherited mapping in the forked
  child (Sashiko review).

v2: https://lore.kernel.org/r/20261123-feat-udmabuf-huge-pfnmap-v2-0-3254f801fc36@linux.dev
v1: https://lore.kernel.org/r/20261122-feat-udmabuf-huge-pfnmap-v1-0-dcba888940c2@linux.dev

---
Qiliang Yuan (3):
      dma-buf: align large mappings to PMD boundaries
      udmabuf: map huge page backed ranges with PMDs
      selftests/udmabuf: test mapping a huge page backed udmabuf

 drivers/dma-buf/dma-buf.c                         |   1 +
 drivers/dma-buf/udmabuf.c                         |  73 ++++++++-
 tools/testing/selftests/drivers/dma-buf/udmabuf.c | 171 +++++++++++++++++++++-
 3 files changed, 239 insertions(+), 6 deletions(-)
---
base-commit: 28f286b0dfa9610d4ee2447415e964e8bc603056
change-id: 20261121-feat-udmabuf-huge-pfnmap-3258272d077e

Best regards,
-- 
Qiliang Yuan <qiliang.yuan@linux.dev>


             reply	other threads:[~2026-12-01 17:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 17:16 Qiliang Yuan [this message]
2026-12-01 17:16 ` [PATCH v3 1/3] dma-buf: align large mappings to PMD boundaries Qiliang Yuan
2026-12-01 17:16 ` [PATCH v3 2/3] udmabuf: map huge page backed ranges with PMDs Qiliang Yuan
2026-12-01 17:16 ` [PATCH v3 3/3] selftests/udmabuf: test mapping a huge page backed udmabuf Qiliang Yuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201-feat-udmabuf-huge-pfnmap-v3-0-144cc7a48f09@linux.dev \
    --to=qiliang.yuan@linux.dev \
    --cc=Philip.Yang@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=nat@pixelcluster.dev \
    --cc=phasta@kernel.org \
    --cc=shuah@kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=tjmercier@google.com \
    --cc=vivek.kasireddy@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®