Re: [PATCH v2 2/4] mm: Add file_operations.get_mapping_order()

Peter Xu
2025-12-16T17:36:17Z

On Tue, Dec 16, 2025 at 01:19:44PM -0400, Jason Gunthorpe wrote:
> On Tue, Dec 16, 2025 at 10:42:39AM -0500, Peter Xu wrote:
> > Also see __thp_get_unmapped_area() processed such pgoff, it allocates VA
> > with len_pad (not len), and pad the retval at last.
> >
> > Please let me know if it didn't work like it, then it might be a bug.
>
> It should all be documented then in the kdoc for the new ops, in this
> kind of language that the resulting VA flows from pgoff

IMHO that's one of the major benefits of this API, so that there's no need
to mention impl details like this.

I thought that's also what you wanted as well.. as you're further
suggesting to offload order adjustments to core mm, which I tend to agree.

Here the point is, the driver should only care about the size of mapping,
nothing else like how exactly the alignments will be calculated, and how
that interacts with pgoff. The kernel mm manages that. It's done exactly
like what anon thp does already when len is pmd aligned.

Or maybe I misunderstood what you're suggesting to document? If so, please
let me know; some example would be greatly helpful.

Thanks,

--
Peter Xu