[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240807161248.37a618f2@mordecai.tesarici.cz>
Date: Wed, 7 Aug 2024 16:12:48 +0200
From: Petr Tesařík <petr@...arici.cz>
To: Catalin Marinas <catalin.marinas@....com>
Cc: Robin Murphy <robin.murphy@....com>, Baruch Siach <baruch@...s.co.il>,
Christoph Hellwig <hch@....de>, Marek Szyprowski
<m.szyprowski@...sung.com>, Will Deacon <will@...nel.org>,
iommu@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
linux-s390@...r.kernel.org, Ramon Fried <ramon@...reality.ai>, Elad Nachman
<enachman@...vell.com>
Subject: Re: [PATCH v5 1/3] dma: improve DMA zone selection
On Wed, 7 Aug 2024 14:58:49 +0100
Catalin Marinas <catalin.marinas@....com> wrote:
> Thanks Robin for having a look.
>
> On Wed, Aug 07, 2024 at 02:13:06PM +0100, Robin Murphy wrote:
> > On 2024-08-02 7:03 am, Baruch Siach wrote:
> > > When device DMA limit does not fit in DMA32 zone it should use DMA zone,
> > > even when DMA zone is stricter than needed.
> > >
> > > Same goes for devices that can't allocate from the entire normal zone.
> > > Limit to DMA32 in that case.
> >
> > Per the bot report this only works for CONFIG_ARCH_KEEP_MEMBLOCK,
>
> Yeah, I just noticed.
>
> > however
> > the whole concept looks wrong anyway. The logic here is that we're only
> > forcing a particular zone if there's *no* chance of the higher zone being
> > usable. For example, ignoring offsets for simplicity, if we have a 40-bit
> > DMA mask then we *do* want to initially try allocating from ZONE_NORMAL even
> > if max_pfn is above 40 bits, since we still might get a usable allocation
> > from between 32 and 40 bits, and if we don't, then we'll fall back to
> > retrying from the DMA zone(s) anyway.
>
> Ah, I did not read the code further down in __dma_direct_alloc_pages(),
> it does fall back to a GFP_DMA allocation if !dma_coherent_ok().
> Similarly with swiotlb_alloc_tlb(), it keeps retrying until the
> allocation fails.
Er, you certainly mean it keeps retrying as long as the allocation
fails.
Yes, that's true. The initial GFP zone flags are a best-effort guess,
and a stricter zone can be chosen in the end. This whole logic tries to
select the highest zone that satisfies the limit, because allocating
some pages and freeing them immediately is wasteful, especially for
high-order allocations.
> So yes, this patch can be dropped.
+1
Petr T
Powered by blists - more mailing lists