On Tue, Aug 09, 2022 at 08:41:37PM +0200, Christoph Hellwig wrote: > On Tue, Aug 09, 2022 at 10:46:04AM -0600, Keith Busch wrote: > > > For swiotlb, though, we can error out the mapping if the requested memory uses > > swiotlb with the device: the driver's .dma_map() can return ENOTSUPP if > > is_swiotlb_buffer() is true. Would that be more acceptable? > > No, is_swiotlb_buffer and similar are not exported APIs. The functions are implemented under 'include/linux/', indistinguishable from exported APIs. I think I understand why they are there, but they look the same as exported functions from a driver perspective. > More importantly with the various secure hypervisor schemes swiotlb is > unfortunately actually massively increasing these days. On those systems all > streaming mappings use swiotlb. And the only way to get any kind of > half-decent I/O performance would be the "special" premapped allocator, which > is another reason why I'd like to see it. Perhaps I'm being daft, but I'm totally missing why I should care if swiotlb leverages this feature. If you're using that, you've traded performance for security or compatibility already. If this idea can be used to make it perform better, then great, but that shouldn't be the reason to hold this up IMO. This optimization needs to be easy to reach if we expect anyone to use it. Working with arbitrary user addresses with minimal additions to the user ABI was deliberate. If you want a special allocator, we can always add one later; this series doesn't affect that. If this has potential to starve system resource though, I can constrain it to specific users like CAP_SYS_ADMIN, or maybe only memory allocated from hugetlbfs. Or perhaps a more complicated scheme of shuffling dma mapping resources on demand if that is an improvement over the status quo.