From: Alex Mastro <amastro@fb.com>
To: Matt Evans <matt@ozlabs.org>
Cc: "Alex Williamson" <alex@shazbot.org>,
"Leon Romanovsky" <leon@kernel.org>,
"Jason Gunthorpe" <jgg@nvidia.com>,
"Christian König" <christian.koenig@amd.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Logan Gunthorpe" <logang@deltatee.com>,
"Kevin Tian" <kevin.tian@intel.com>,
"Pranjal Shrivastava" <praan@google.com>,
"Longfang Liu" <liulongfang@huawei.com>,
"Mahmoud Adam" <mngyadam@amazon.de>,
"David Matlack" <dmatlack@google.com>,
"Björn Töpel" <bjorn@kernel.org>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Ankit Agrawal" <ankita@nvidia.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Vivek Kasireddy" <vivek.kasireddy@intel.com>,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
kvm@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v7 6/9] vfio/pci: Convert BAR mmap() to use a DMABUF
Date: Mon, 28 Sep 2026 10:59:05 -0700 [thread overview]
Message-ID: <arqq6VXW8Rif59BL@devgpu015.cco6.facebook.com> (raw)
In-Reply-To: <20260924152159.49702-7-matt@ozlabs.org>
I used [1] to validate that the problematic sequence that deadlocks
in v5 is resolved by this v7 series.
The test stands up a spoofed nvgrace device [2] in QEMU and runs a test [3]
which:
1. Launch reader thread: pread() from vfio device fd into a userfaultfd-managed
page.
2. Wait until the uffd fires, but do not resolve the fault. Now pread()
from 1. is blocked, holding memory_lock(R) inside nvgrace_gpu_read_mem().
3. Launch writer thread: pwrite() the PCI command word, queuing for
memory_lock(W) inside vfio_basic_config_write().
4. Launch mmap thread: mmap() on the vfio device fd, taking mmap_lock(W)
and triggering the internal dma-buf export that backs the mapping.
5. Resolve the uffd fault.
6. Join the threads.
On v5 the dma-buf export in step 4 takes memory_lock(W) and blocks behind the
reader and the queued writer. The reader's fault path nests mmap_lock(R) inside
memory_lock(R), while the mapper holds mmap_lock(W) across the mmap handler and
waits on memory_lock (lockdep reports the cycle).
On v7 the export takes only the new dmabuf_lock, which neither the reader nor
the writer holds, so step 4 completes while the uffd fault is unresolved.
Tested-by: Alex Mastro <amastro@fb.com>
Reviewed-by: Alex Mastro <amastro@fb.com>
[1] https://github.com/opsound/vfio-dmabuf-lab.git
[2] https://github.com/opsound/qemu/commit/349f0b12ca633fc42532aeda33273079b2b8e5d4
[3] https://github.com/opsound/vfio-dmabuf-lab/blob/cfe762123076c4543fdc4e8d5e9b62ad6bf998d9/tests/nvgrace_uaccess_test.c#L309
Alex
next prev parent reply other threads:[~2026-09-28 18:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 15:21 [PATCH v7 0/9] vfio/pci: Add mmap() for DMABUFs Matt Evans
2026-09-24 15:21 ` [PATCH v7 1/9] vfio/pci: Remove DMABUF export dependency on vdev->memory_lock Matt Evans
2026-09-24 15:37 ` sashiko-bot
2026-09-29 14:12 ` Matt Evans
2026-09-24 15:21 ` [PATCH v7 2/9] vfio/pci: Un-revoke DMABUFs in LOW_POWER_ENTRY_WITH_WAKEUP resume Matt Evans
2026-09-24 15:30 ` sashiko-bot
2026-09-24 15:21 ` [PATCH v7 3/9] dma-buf: Provide dma_buf_set_name() Matt Evans
2026-09-24 15:29 ` sashiko-bot
2026-09-25 8:39 ` Christian König
2026-09-29 11:43 ` Matt Evans
2026-09-24 15:21 ` [PATCH v7 4/9] vfio/pci: Add a helper to look up PFNs for DMABUFs Matt Evans
2026-09-24 15:35 ` sashiko-bot
2026-09-24 15:21 ` [PATCH v7 5/9] vfio/pci: Add a helper to create a DMABUF for a BAR-map VMA Matt Evans
2026-09-24 15:38 ` sashiko-bot
2026-09-24 15:21 ` [PATCH v7 6/9] vfio/pci: Convert BAR mmap() to use a DMABUF Matt Evans
2026-09-24 15:34 ` sashiko-bot
2026-09-28 17:59 ` Alex Mastro [this message]
2026-09-24 15:21 ` [PATCH v7 7/9] vfio/pci: Clean up BAR zap and revocation Matt Evans
2026-09-24 15:34 ` sashiko-bot
2026-09-24 15:21 ` [PATCH v7 8/9] vfio/pci: Support mmap() of a VFIO DMABUF Matt Evans
2026-09-24 15:36 ` sashiko-bot
2026-09-24 15:21 ` [PATCH v7 9/9] vfio/pci: Revoke a DMABUF on request from userspace Matt Evans
2026-09-24 15:35 ` sashiko-bot
2026-10-01 21:38 ` [PATCH v7 0/9] vfio/pci: Add mmap() for DMABUFs Alex Williamson
2026-10-02 14:04 ` Matt Evans
2026-10-02 14:51 ` Jason Gunthorpe
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=arqq6VXW8Rif59BL@devgpu015.cco6.facebook.com \
--to=amastro@fb.com \
--cc=alex@shazbot.org \
--cc=ankita@nvidia.com \
--cc=apopple@nvidia.com \
--cc=bhelgaas@google.com \
--cc=bjorn@kernel.org \
--cc=christian.koenig@amd.com \
--cc=dmatlack@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=leon@kernel.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=liulongfang@huawei.com \
--cc=logang@deltatee.com \
--cc=matt@ozlabs.org \
--cc=mngyadam@amazon.de \
--cc=praan@google.com \
--cc=sumit.semwal@linaro.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.