On Tue, Aug 05, 2025 at 09:47:18AM +0200, David Hildenbrand wrote: > > There was discussion here[1] where David Hildenbrand and Jason > > Gunthorpe suggested this should be in common code and I believe there > > was some intent that this would get reused. I took this as > > endorsement from mm folks. This can certainly be pulled back into > > subsystem code. > > Yeah, we ended up here after trying to go the folio-way first, but then > realizing that code that called GUP shouldn't have to worry about > folios, just to detect consecutive pages+PFNs. > > I think this helper will can come in handy even in folio context. > I recall pointing Joanne at it in different fuse context. The scatterlist code should use it also, it is doing the same logic. > The concern is rather false positives, meaning, you want consecutive > PFNs (just like within a folio), but -- because the stars aligned -- > you get consecutive "struct page" that do not translate to consecutive PFNs. I wonder if we can address that from the other side and prevent the memory code from creating a bogus contiguous struct page in the first place so that struct page contiguity directly reflects physical contiguity? Jason