The patch titled Subject: mm: inline vm_insert_pfn_prot() into caller has been added to the -mm tree. Its filename is mm-inline-vm_insert_pfn_prot-into-caller.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-inline-vm_insert_pfn_prot-into-caller.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-inline-vm_insert_pfn_prot-into-caller.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Matthew Wilcox <willy@xxxxxxxxxxxxx> Subject: mm: inline vm_insert_pfn_prot() into caller vm_insert_pfn_prot() is only called from vmf_insert_pfn_prot(), so inline it and convert some of the errnos into vm_fault codes earlier. Link: http://lkml.kernel.org/r/20180828145728.11873-9-willy@xxxxxxxxxxxxx Signed-off-by: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Nicolas Pitre <nicolas.pitre@xxxxxxxxxx> Cc: Souptick Joarder <jrdr.linux@xxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memory.c | 55 +++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 31 deletions(-) --- a/mm/memory.c~mm-inline-vm_insert_pfn_prot-into-caller +++ a/mm/memory.c @@ -1819,36 +1819,6 @@ out: return retval; } -static int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, - unsigned long pfn, pgprot_t pgprot) -{ - int ret; - /* - * Technically, architectures with pte_special can avoid all these - * restrictions (same for remap_pfn_range). However we would like - * consistency in testing and feature parity among all, so we should - * try to keep these invariants in place for everybody. - */ - BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); - BUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) == - (VM_PFNMAP|VM_MIXEDMAP)); - BUG_ON((vma->vm_flags & VM_PFNMAP) && is_cow_mapping(vma->vm_flags)); - BUG_ON((vma->vm_flags & VM_MIXEDMAP) && pfn_valid(pfn)); - - if (addr < vma->vm_start || addr >= vma->vm_end) - return -EFAULT; - - if (!pfn_modify_allowed(pfn, pgprot)) - return -EACCES; - - track_pfn_insert(vma, &pgprot, __pfn_to_pfn_t(pfn, PFN_DEV)); - - ret = insert_pfn(vma, addr, __pfn_to_pfn_t(pfn, PFN_DEV), pgprot, - false); - - return ret; -} - /** * vmf_insert_pfn_prot - insert single pfn into user vma with specified pgprot * @vma: user vma to map to @@ -1870,7 +1840,30 @@ static int vm_insert_pfn_prot(struct vm_ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot) { - int err = vm_insert_pfn_prot(vma, addr, pfn, pgprot); + int err; + + /* + * Technically, architectures with pte_special can avoid all these + * restrictions (same for remap_pfn_range). However we would like + * consistency in testing and feature parity among all, so we should + * try to keep these invariants in place for everybody. + */ + BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); + BUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) == + (VM_PFNMAP|VM_MIXEDMAP)); + BUG_ON((vma->vm_flags & VM_PFNMAP) && is_cow_mapping(vma->vm_flags)); + BUG_ON((vma->vm_flags & VM_MIXEDMAP) && pfn_valid(pfn)); + + if (addr < vma->vm_start || addr >= vma->vm_end) + return VM_FAULT_SIGBUS; + + if (!pfn_modify_allowed(pfn, pgprot)) + return VM_FAULT_SIGBUS; + + track_pfn_insert(vma, &pgprot, __pfn_to_pfn_t(pfn, PFN_DEV)); + + err = insert_pfn(vma, addr, __pfn_to_pfn_t(pfn, PFN_DEV), pgprot, + false); if (err == -ENOMEM) return VM_FAULT_OOM; _ Patches currently in -mm which might be from willy@xxxxxxxxxxxxx are cramfs-convert-to-use-vmf_insert_mixed.patch mm-remove-vm_insert_mixed.patch mm-introduce-vmf_insert_pfn_prot.patch x86-convert-vdso-to-use-vm_fault_t.patch mm-make-vm_insert_pfn_prot-static.patch mm-remove-references-to-vm_insert_pfn.patch mm-remove-vm_insert_pfn.patch mm-inline-vm_insert_pfn_prot-into-caller.patch mm-convert-__vm_insert_mixed-to-vm_fault_t.patch mm-convert-insert_pfn-to-vm_fault_t.patch