From: William Palacek <William.Palacek@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: <William.Palacek@amd.com>, <Harish.Kasiviswanathan@amd.com>,
<Felix.Kuehling@amd.com>, <christian.koenig@amd.com>,
<philip.yang@amd.com>
Subject: [PATCH 0/4] drm/amdkfd: don't stall other threads during large userptr registration
Date: Wed, 18 Nov 2026 10:10:34 -0500 [thread overview]
Message-ID: <cover.1795014593.git.William.Palacek@amd.com> (raw)
Registering a large userptr BO (hipHostMalloc) holds mmap_lock, p->mutex
and process_info->lock while every page of the range is faulted in. For
32 GiB on MI300X that takes seconds, and every other thread of the
process that submits GPU work waits behind it for the whole time.
Patch 1 limits userptr sg segments to half of sg->length. Larger
physically contiguous segments can overflow the padded segment length in
iommu_dma_map_sg(), and the pin fails. This already happens without the
series; patch 3 makes the pages contiguous enough that it hits on a
freshly booted system, so it goes first.
Patch 2 drops p->mutex from AMDKFD_IOC_GET_CLOCK_COUNTERS, which other
threads call while submitting work.
Patch 3 drops mmap_lock between 2 MiB chunks while faulting userptr
pages in.
Patch 4 faults in and validates userptr pages without p->mutex and
process_info->lock, and adds the BO to the valid list only if no
invalidation happened meanwhile.
Tested with two 32 GiB hipHostMalloc/hipHostFree cycles next to 4
PyTorch streams on 2 GPUs, measuring the worst GPU submission latency
of the other threads (limit 1 s), on the amdgpu 7.2 DKMS driver:
MI300X, IOMMU DMA-FQ unpatched 0/3 (6.1-6.2 s; on other boots
the 32 GiB pin itself fails)
series 3/3 (0.80-0.95 s)
MI300X, IOMMU identity unpatched 0/3 (9.6-10.1 s)
patches 2-3 0/3 (10.5-11.0 s)
patches 2-4 3/3 (0.81-0.93 s)
MI350X, IOMMU identity unpatched 0/4 (4.55-4.84 s)
series 7/7 (0.21-0.39 s)
kfdtest KFDMemoryTest.* and KFDEvictTest.* pass on both GPUs.
William Palacek (4):
drm/amdgpu: limit userptr sg segments to half of sg->length
drm/amdkfd: don't take p->mutex in AMDKFD_IOC_GET_CLOCK_COUNTERS
drm/amdgpu: drop mmap_lock between chunks when faulting userptr pages
drm/amdkfd: register userptr pages without holding KFD process locks
.../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 53 +++++++++++--------
drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c | 14 ++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.h | 2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 9 ++--
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 7 +++
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 10 +++-
drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 2 +-
7 files changed, 66 insertions(+), 31 deletions(-)
--
2.43.0
next reply other threads:[~2026-11-18 15:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 15:10 William Palacek [this message]
2026-11-18 15:10 ` [PATCH 1/4] drm/amdgpu: limit userptr sg segments to half of sg->length William Palacek
2026-11-18 15:10 ` [PATCH 2/4] drm/amdkfd: don't take p->mutex in AMDKFD_IOC_GET_CLOCK_COUNTERS William Palacek
2026-11-18 15:10 ` [PATCH 3/4] drm/amdgpu: drop mmap_lock between chunks when faulting userptr pages William Palacek
2026-11-18 15:10 ` [PATCH 4/4] drm/amdkfd: register userptr pages without holding KFD process locks William Palacek
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=cover.1795014593.git.William.Palacek@amd.com \
--to=william.palacek@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=Harish.Kasiviswanathan@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=philip.yang@amd.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