Re: [PATCH v2 13/22] iommufd: Add mmap interface

Jason Gunthorpe
2025-05-06T12:52:29Z

On Mon, May 05, 2025 at 12:50:56PM -0700, Nicolin Chen wrote:

> I wanted to ask: what should we pass in to the "entry"? An mmap
> structure that hold the pfn range? Or just pfn_start?

Some kind of struct telling you what is behind that pfn range so you
can invoke the right driver callback and retun the right pfns..

> With that being said, it seems that I have been misusing the
> mtree data structure, treating it as an xarray. In your very
> first email suggesting the mmap design, where you mentioned
> "xarray" first and "maple tree" following. So, I thought they
> can be used in the similar way, especially after reading this:
> https://lwn.net/Articles/846175/

This job requires a range based datastructure. Meaning you insert PFNs
A->B and then a lookup would search for any intersection with A->B.

In maple tree you can do this rather directly since it is inherently
range based.

In xarray you can do it with the multi-order feature or you can do it
by replicating the entry across the whole range.

Jason