> Move from the deprecated mmap hook to the new mmap_prepare hook. > > We are mapping kernel pages here, so use the discontiguous kernel mapping > mmap action to do so. > > Unwind the rather confusing loop and instead map as many pages as we can at > one time. > > Note that we do not need to pay attention to rsv_schp->k_use_sg here, as > the pages are populated for the length of the buffer at > rsv_schp->page_order granularity as compound pages. > > The discontiguous kernel page mapping logic handles the compound pages for > us. > > sfp->mmap_called keeps the buffer stable for us. As before it is never > cleared, so a failed mmap also leaves it set. > > We also remove some useless vma, vma->vm_file NULL checks - these will > always be non-NULL if you reached the mmap hook logic. > > We retain log output for consistency, but change what's output on page > mapping to indicate that sg_discontig_get() does the work now. > > Note that we drop the VMA_IO_BIT flag for the VMA here. It was never > necessary as we invoke alloc_pages() which gives us refcounted folios that > are fine for GUP to access (VMA_IO_BIT would prevent that). > > Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review ยท https://sashiko.dev/#/patchset/20260914-b4-mmap-prepare-vma-flag-sanify-v2-0-7d9781ed5...@kernel.org?part=18
