All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] hw/nvme: lift IOV_MAX limit in DMA path
@ 2026-08-19 15:24 Daniel Gomez
  2026-08-19 15:24 ` [PATCH v2 1/7] dma-helpers: fix unaligned discard_back Daniel Gomez
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Daniel Gomez @ 2026-08-19 15:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Peter Xu, Philippe Mathieu-Daudé, Keith Busch,
	Klaus Jensen, Klaus Jensen, Jesper Devantier, qemu-block,
	Daniel Gomez, Daniel Gomez, GOST

Raise the QEMU NVMe controller's MDTS beyond the 2 MiB cap.

Commit 53493c1f83 ("hw/nvme: cap MDTS value for internal limitation")
needed the 2 MiB cap because dma_blk_io() submitted the full sglist
in one preadv()/pwritev() call, which the host kernel rejects when the
iovec count exceeds IOV_MAX. This series moves the IOV_MAX bound down to
dma_blk_cb(), where we batch in IOV_MAX chunks when necessary.

dma_blk_cb() now breaks its accumulation at IOV_MAX and submits the
next chunk via the existing re-entry path. With that the DMA-path
nvme_map_addr() guard and the MDTS cap are removed. The cap stays only
for CMB/PMR, whose transfers go through a different path and are still
bounded by IOV_MAX.

This series builds cleanly under ubsan with large mdts and passes the
following fio tests on a 4k LBA QEMU NVMe device:

fio \
    --name=mdts-stress \
    --filename=/mnt/mdts/stress.fio \
    --rw=randwrite \
    --bs=8M \
    --ioengine=psync \
    --direct=0 \
    --numjobs=8 \
    --time_based \
    --runtime=600 \
    --fsync=8 \
    --end_fsync=1 \
    --group_reporting \
    --refill_buffers \
    --norandommap \
    --offset_align=32k

fio --name=demo --filename=/dev/nvme0n1 \
    --rw=write --bs=8M --size=8M --direct=1 \
    --iomem_align=4 --verify=crc32c --do_verify=0

fio --name=demo --filename=/dev/nvme0n1 \
    --rw=write --bs=8M --size=8M --direct=1 \
    --verify=crc32c --verify_only

---
Changes in v2:
- Update cover letter.
- Rebase on top of nvme.next branch, tree:
https://gitlab.com/birkelund/qemu
- Keep the 2 MiB mdts cap for CMB/PMR configurations (Klaus)
- Fix the `mem` leak reported by Keith
- Drop NVME_MDTS_MAX, ie. unlimited mdts as long as Linux host supports
it.
Allowing larger mdts, also meant we needed to:
- Clamp the mdts and zasl shifts to stay within uint64_t
- Cap qemu_iovec_init() to IOV_MAX when the sg list is large
- Keep IO chunks aligned when chunking at IOV_MAX
- Fix the wrong bytes being discarded in the discard path
- Link to v1: https://lore.kernel.org/qemu-devel/20260529-align-nvme-mdts-with-linux-v1-0-221d4d21ab43@samsung.com

To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@mailo.com>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Klaus Jensen <its@irrelevant.dk>
Cc: Klaus Jensen <k.jensen@samsung.com>
Cc: Jesper Devantier <foss@defmacro.it>
Cc: qemu-block@nongnu.org
Cc: Daniel Gomez <da.gomez@kernel.org>
Cc: Daniel Gomez <da.gomez@samsung.com>
Cc: GOST <gost.dev@samsung.com>
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>

---
Daniel Gomez (7):
      dma-helpers: fix unaligned discard_back
      dma-helpers: ensure IOV_MAX chunks end aligned
      dma-helpers: cap iovec allocation at IOV_MAX
      dma-helpers: chunk dma_blk_cb at IOV_MAX
      hw/nvme: clamp mdts and zasl shifts
      hw/nvme: drop DMA-path IOV_MAX guard
      hw/nvme: cap mdts for CMB/PMR-only

 hw/nvme/ctrl.c       | 21 +++++++++++++--------
 system/dma-helpers.c | 19 ++++++++++++++++---
 2 files changed, 29 insertions(+), 11 deletions(-)
---
base-commit: 7a34f7b8794b29cd1bd4dfa45f7d8e8daba7cff5
change-id: 20260528-align-nvme-mdts-with-linux-67d618f6730b

Best regards,
--  
Daniel Gomez <da.gomez@samsung.com>



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-09-09 12:36 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-19 15:24 [PATCH v2 0/7] hw/nvme: lift IOV_MAX limit in DMA path Daniel Gomez
2026-08-19 15:24 ` [PATCH v2 1/7] dma-helpers: fix unaligned discard_back Daniel Gomez
2026-09-04 21:57   ` Jesper Wendel Devantier
2026-09-09 12:17     ` Daniel Gomez
2026-08-19 15:24 ` [PATCH v2 2/7] dma-helpers: ensure IOV_MAX chunks end aligned Daniel Gomez
2026-08-19 15:24 ` [PATCH v2 3/7] dma-helpers: cap iovec allocation at IOV_MAX Daniel Gomez
2026-09-04 21:57   ` Jesper Wendel Devantier
2026-08-19 15:24 ` [PATCH v2 4/7] dma-helpers: chunk dma_blk_cb " Daniel Gomez
2026-09-04 21:58   ` Jesper Wendel Devantier
2026-08-19 15:24 ` [PATCH v2 5/7] hw/nvme: clamp mdts and zasl shifts Daniel Gomez
2026-09-04 21:58   ` Jesper Wendel Devantier
2026-08-19 15:24 ` [PATCH v2 6/7] hw/nvme: drop DMA-path IOV_MAX guard Daniel Gomez
2026-09-04 21:59   ` Jesper Wendel Devantier
2026-08-19 15:24 ` [PATCH v2 7/7] hw/nvme: cap mdts for CMB/PMR-only Daniel Gomez
2026-09-04 22:02   ` Jesper Wendel Devantier
2026-09-09 12:35     ` Daniel Gomez
2026-09-04 22:00 ` [PATCH v2 0/7] hw/nvme: lift IOV_MAX limit in DMA path Keith Busch

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.