On Mon, Sep 08, 2025 at 10:24:47AM -0300, Jason Gunthorpe wrote: > On Mon, Sep 08, 2025 at 12:10:43PM +0100, Lorenzo Stoakes wrote: > > resctl uses remap_pfn_range(), but holds a mutex over the > > operation. Therefore, establish the mutex in mmap_prepare(), release it in > > mmap_complete() and release it in mmap_abort() should the operation fail. > > The mutex can't do anything relative to remap_pfn, no reason to hold it. > > > @@ -1053,15 +1087,11 @@ static int pseudo_lock_dev_mmap(struct file *filp, > > struct vm_area_struct *vma) > > return -ENOSPC; > > } > > > > - memset(plr->kmem + off, 0, vsize); > > + /* No CoW allowed so don't need to specify pfn. */ > > + remap_pfn_range_prepare(desc, 0); > > This would be a good place to make a more generic helper.. > > ret = remap_pfn_no_cow(desc, phys);
Ha, funny I suggested a _no_cow() thing earlier :) seems we are agreed on that then! Presumably you mean remap_pfn_no_cow_prepare()? > > And it can consistently check for !shared internally. > > Store phys in the desc and use common code to trigger the PTE population > during complete. We can use mmap_context for this, I guess it's not a terrible idea to set .pfn but I just don't want to add any confusion as to what doing that means in the non-generic mmap_complete case. > > Jason Cheers, Lorenzo