[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250627150200.2192c6b1@mordecai.tesarici.cz>
Date: Fri, 27 Jun 2025 15:02:00 +0200
From: Petr Tesarik <ptesarik@...e.com>
To: Christoph Hellwig <hch@...radead.org>
Cc: Robin Murphy <robin.murphy@....com>, Marek Szyprowski
<m.szyprowski@...sung.com>, Bagas Sanjaya <bagasdotme@...il.com>, Jonathan
Corbet <corbet@....net>, Andrew Morton <akpm@...ux-foundation.org>, Leon
Romanovsky <leon@...nel.org>, Keith Busch <kbusch@...nel.org>, Caleb Sander
Mateos <csander@...estorage.com>, Sagi Grimberg <sagi@...mberg.me>, Jens
Axboe <axboe@...nel.dk>, John Garry <john.g.garry@...cle.com>, "open
list:DOCUMENTATION" <linux-doc@...r.kernel.org>, open list
<linux-kernel@...r.kernel.org>, "open list:MEMORY MANAGEMENT"
<linux-mm@...ck.org>, iommu@...ts.linux.dev
Subject: Re: [PATCH 7/8] docs: dma-api: update streaming DMA API physical
address constraints
On Fri, 27 Jun 2025 05:55:09 -0700
Christoph Hellwig <hch@...radead.org> wrote:
> On Thu, Jun 26, 2025 at 05:45:18PM +0100, Robin Murphy wrote:
> > Indeed that might actually end up pushing things in the opposite direction,
> > at least in some cases. Right now, a driver with, say, a 40-bit DMA mask is
> > usually better off not special-casing DMA buffers, and just making plain
> > GFP_KERNEL allocations for everything (on the assumption that 64-bit systems
> > with masses of memory *should* have SWIOTLB to cover things in the worst
> > case), vs. artificially constraining its DMA buffers to GFP_DMA32 and having
> > to deal with allocation failure more often. However with a more precise and
> > flexible allocator, there's then a much stronger incentive for such drivers
> > to explicitly mark *every* allocation that may be used for DMA, in order to
> > get the optimal behaviour.
>
> It really should be using dma_alloc_pages to ensure it gets addressable
> memory for these cases. For sub-page allocations it could use dmapool,
> but that's a little annoying because it does coherent allocations which
> 95% of the users don't actually need.
Wow, thank you for this insight! There's one item on my TODO list:
convert SLAB_CACHE_DMA caches to dmapool. But now I see it would
introduce a regression (accessing DMA-coherent pages may be much
slower). I could implement a variant of dmapool which allocates normal
pages from a given physical address range, and it seems it would be
actually useful.
Petr T
Powered by blists - more mailing lists