On Mon, Sep 15, 2025 at 09:42:59AM -0300, Jason Gunthorpe wrote: > On Mon, Sep 15, 2025 at 01:23:30PM +0100, Lorenzo Stoakes wrote: > > On Mon, Sep 15, 2025 at 09:11:12AM -0300, Jason Gunthorpe wrote: > > > On Wed, Sep 10, 2025 at 09:22:03PM +0100, Lorenzo Stoakes wrote: > > > > +static inline void mmap_action_remap(struct mmap_action *action, > > > > + unsigned long addr, unsigned long pfn, unsigned long > > > > size, > > > > + pgprot_t pgprot) > > > > +{ > > > > + action->type = MMAP_REMAP_PFN; > > > > + > > > > + action->remap.addr = addr; > > > > + action->remap.pfn = pfn; > > > > + action->remap.size = size; > > > > + action->remap.pgprot = pgprot; > > > > +} > > > > > > These helpers drivers are supposed to call really should have kdocs. > > > > > > Especially since 'addr' is sort of ambigous. > > > > OK. > > > > > > > > And I'm wondering why they don't take in the vm_area_desc? Eg shouldn't > > > we be strongly discouraging using anything other than > > > vma->vm_page_prot as the last argument? > > > > I need to abstract desc from action so custom handlers can perform > > sub-actions. It's unfortunate but there we go. > > Why? I don't see this as required > > Just mark the functions as manipulating the action using the 'action' > in the fuction name.
Because now sub-callers that partially map using one method and partially map using another now need to have a desc too that they have to 'just know' which fields to update or artificially set up. The vmcore case does something like this. Instead, we have actions where it's 100% clear what's going to happen. > > > > I'd probably also have a small helper wrapper for the very common case > > > of whole vma: > > > > > > /* Fill the entire VMA with pfns starting at pfn. Caller must have > > > * already checked desc has an appropriate size */ > > > mmap_action_remap_full(struct vm_area_desc *desc, unsigned long pfn) > > > > See above re: desc vs. action. > > Yet, this is the API most places actually want. > > > It'd be hard to know how to get the context right that'd need to be > > supplied to > > the callback. > > > > In kcov's case it'd be kcov->area + an offset. > > Just use pgoff > > > So we'd need an offset parameter, the struct file *, whatever else to be > > passed. > > Yes > > > And then we'll find a driver where that doesn't work and we're screwed. > > Bah, you keep saying that but we also may never even find one. OK let me try something like this, then. I guess I can update it later if we discover such a dirver. > > Jason Cheers, Lorenzo