[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230407055548.GC6803@lst.de>
Date: Fri, 7 Apr 2023 07:55:48 +0200
From: Christoph Hellwig <hch@....de>
To: Petr Tesarik <petrtesarik@...weicloud.com>
Cc: Christoph Hellwig <hch@....de>, Jonathan Corbet <corbet@....net>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Robin Murphy <robin.murphy@....com>,
Borislav Petkov <bp@...e.de>,
"Paul E. McKenney" <paulmck@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Randy Dunlap <rdunlap@...radead.org>,
Damien Le Moal <damien.lemoal@...nsource.wdc.com>,
Kim Phillips <kim.phillips@....com>,
"Steven Rostedt (Google)" <rostedt@...dmis.org>,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>,
"open list:DMA MAPPING HELPERS" <iommu@...ts.linux.dev>,
Roberto Sassu <roberto.sassu@...wei.com>, petr@...arici.cz,
Alexander Graf <graf@...zon.com>
Subject: Re: [RFC v1 3/4] swiotlb: Allow dynamic allocation of bounce
buffers
On Tue, Mar 28, 2023 at 09:54:35AM +0200, Petr Tesarik wrote:
> I tend to agree here. However, it's the DMABUF design itself that causes
> some trouble. The buffer is allocated by the v3d driver, which does not
> have the restriction, so the DMA API typically allocates an address
> somewhere near the 4G boundary. Userspace then exports the buffer, sends
> it to another process as a file descriptor and imports it into the vc4
> driver, which requires DMA below 1G. In the beginning, v3d had no idea
> that the buffer would be exported to userspace, much less that it would
> be later imported into vc4.
Then we need to either:
a) figure out a way to communicate these addressing limitations
b) find a way to migrate a buffer into other memory, similar to
how page migration works for page cache
> BTW my testing also suggests that the streaming DMA API is quite
> inefficient, because UAS performance _improved_ with swiotlb=force.
> Sure, this should probably be addressed in the UAS and/or xHCI driver,
> but what I mean is that moving away from swiotlb may even cause
> performance regressions, which is counter-intuitive. At least I would
> _not_ have expected it.
That is indeed very odd. Are you running with a very slow iommu
driver there? Or what is the actual use case there in general?
> >> + gfp = (attrs & DMA_ATTR_MAY_SLEEP) ? GFP_KERNEL : GFP_NOWAIT;
> >> + slot = kmalloc(sizeof(*slot), gfp | __GFP_NOWARN);
> >> + if (!slot)
> >> + goto err;
> >> +
> >> + slot->orig_addr = orig_addr;
> >> + slot->alloc_size = alloc_size;
> >> + slot->page = dma_direct_alloc_pages(dev, PAGE_ALIGN(alloc_size),
> >> + &slot->dma_addr, dir,
> >> + gfp | __GFP_NOWARN);
> >> + if (!slot->page)
> >> + goto err_free_slot;
> >
> > Without GFP_NOIO allocations this will deadlock eventually.
>
> Ah, that would affect the non-sleeping case (GFP_KERNEL), right?
Yes.
Powered by blists - more mailing lists