From: Christoph Hellwig <hch@lst.de>
To: Robin Murphy <robin.murphy@arm.com>
Cc: John Garry <john.g.garry@oracle.com>,
Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
iommu@lists.linux.dev, linux-nvme@lists.infradead.org,
Adrian Huang <ahuang12@lenovo.com>
Subject: Re: dma_opt_mapping_size returns way too low sizes when using IOMMU
Date: Wed, 19 Aug 2026 10:57:32 +0200 [thread overview]
Message-ID: <20260819085732.GA8649@lst.de> (raw)
In-Reply-To: <3ac5346a-485f-4c1a-8c3a-ad649f2c76f0@arm.com>
[adding Adrian who originall added the cap to NVMe to work around a
softlockup, see commit 3710e2b056cb ("nvme-pci: clamp max_hw_sectors
based on DMA optimized limitation")]
On Mon, Aug 17, 2026 at 06:04:24PM +0100, Robin Murphy wrote:
>> page order, i.e. the idea was that we should not be getting streaming IOs
>> larger than that value. But in looking at lore, 8 was very originally
>> proposed, but I can't see any discussion on why that changed or any
>> relation to page max order.
>
> From a quick skim I can't spot any specific mention in the original threads
> or accompanying paper, but I have a feeling it was as much about just
> balancing memory consumption with observable performance improvement, and
> larger sizes weren't significantly impactful to the original testing, which
> did seem to be focused on networking rather than storage.
Yeah, network transfer sizes tend to be much lower than those for
storage.
> Since these days we have the flexibly-sized depot, and now even
> lazy-allocation of the CPU magazines, we might be in a better position to
> consider scaling IOVA_RANGE_CACHE_MAX_SIZE up without too much inherent
> overhead (I guess the base cost per level will just be 2*NR_CPUS + 1
> pointers now).
That would be useful. Is just incrementing it enough or do we need more
fine tuning?
> The larger sizes we cache, though, the more it's also going
> to blow up IOVA consumption if freeing/reallocation isn't well balanced
> across CPUs, so for devices/systems with limited IOVA space, at some point
> the flush_rcache case is liable to start adding more overhead than the
> caching itself saves...
Storage drivers tend to steer I/O completions to the submitting CPU by
default. There are some exceptions, though. For example polling with
a dedicated polling thread will usually not do this. Then again the
overlap of polled I/O and IOMMU usage should be about 0 right now.
This could change with the dmabuf I/O path, but that would lock down
the IOVA for the lifetime of the dmabuf and sidestep the entire
issue here.
> FWIW, my understanding of the idea we settled on for opt_mapping_size was
> that it was never meant to be an absolute target, just a boundary between
> where callers can expect "ideal" mapping performance, and where it may
> start scaling with size/contention/etc., and thus it's for the callers to
> judge whether larger sizes are still worth it for their particular
> use-case.
That would suggest the approach done in the SAS transport class makes
more sense and NVMe should just cap to the max mapping size. Of course
even that might be the wrong answer. For example for HDD we really do
want much larger I/O sizes even if it slows down the IOMMU, but right
now HDD on NVMe isn't really beyond the proof of concept stage, at
least discounting things like smart NICs as an in-between layer.
next prev parent reply other threads:[~2026-08-19 8:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 8:36 dma_opt_mapping_size returns way too low sizes when using IOMMU Christoph Hellwig
2026-08-17 9:12 ` John Garry
2026-08-17 9:18 ` Christoph Hellwig
2026-08-17 10:11 ` John Garry
2026-08-17 17:04 ` Robin Murphy
2026-08-19 8:57 ` Christoph Hellwig [this message]
2026-08-19 8:51 ` Christoph Hellwig
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=20260819085732.GA8649@lst.de \
--to=hch@lst.de \
--cc=ahuang12@lenovo.com \
--cc=iommu@lists.linux.dev \
--cc=john.g.garry@oracle.com \
--cc=joro@8bytes.org \
--cc=linux-nvme@lists.infradead.org \
--cc=m.szyprowski@samsung.com \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/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