The patch titled Subject: mm/hmm: cleanup special vma handling (VM_SPECIAL) has been added to the -mm tree. Its filename is mm-hmm-cleanup-special-vma-handling-vm_special.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-hmm-cleanup-special-vma-handling-vm_special.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-hmm-cleanup-special-vma-handling-vm_special.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: Jérôme Glisse <jglisse@xxxxxxxxxx> Subject: mm/hmm: cleanup special vma handling (VM_SPECIAL) Special vma (one with any of the VM_SPECIAL flags) can not be accessed by devicees because there is no consistent model across device drivers on those vmas and their backing memory. This patch directly uses hmm_range struct for hmm_pfns_special() argument as it is always affecting the whole vma and thus the whole range. It also makes behavior consistent: after this patch both hmm_vma_fault() and hmm_vma_get_pfns() return -EINVAL when facing such vmas. Previously hmm_vma_fault() returned 0 and hmm_vma_get_pfns() returned -EINVAL but both were filling the HMM pfn array with special entries. Link: http://lkml.kernel.org/r/20180316191414.3223-9-jglisse@xxxxxxxxxx Signed-off-by: Jérôme Glisse <jglisse@xxxxxxxxxx> Cc: Evgeny Baskakov <ebaskakov@xxxxxxxxxx> Cc: Ralph Campbell <rcampbell@xxxxxxxxxx> Cc: Mark Hairgrove <mhairgrove@xxxxxxxxxx> Cc: John Hubbard <jhubbard@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/hmm.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff -puN mm/hmm.c~mm-hmm-cleanup-special-vma-handling-vm_special mm/hmm.c --- a/mm/hmm.c~mm-hmm-cleanup-special-vma-handling-vm_special +++ a/mm/hmm.c @@ -281,14 +281,6 @@ static int hmm_vma_do_fault(struct mm_wa return -EAGAIN; } -static void hmm_pfns_special(uint64_t *pfns, - unsigned long addr, - unsigned long end) -{ - for (; addr < end; addr += PAGE_SIZE, pfns++) - *pfns = HMM_PFN_SPECIAL; -} - static int hmm_pfns_bad(unsigned long addr, unsigned long end, struct mm_walk *walk) @@ -486,6 +478,14 @@ fault: return 0; } +static void hmm_pfns_special(struct hmm_range *range) +{ + unsigned long addr = range->start, i = 0; + + for (; addr < range->end; addr += PAGE_SIZE, i++) + range->pfns[i] = HMM_PFN_SPECIAL; +} + /* * hmm_vma_get_pfns() - snapshot CPU page table for a range of virtual addresses * @range: range being snapshoted and all needed informations @@ -509,12 +509,6 @@ int hmm_vma_get_pfns(struct hmm_range *r struct mm_walk mm_walk; struct hmm *hmm; - /* FIXME support hugetlb fs */ - if (is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL)) { - hmm_pfns_special(range->pfns, range->start, range->end); - return -EINVAL; - } - /* Sanity check, this really should not happen ! */ if (range->start < vma->vm_start || range->start >= vma->vm_end) return -EINVAL; @@ -528,6 +522,12 @@ int hmm_vma_get_pfns(struct hmm_range *r if (!hmm->mmu_notifier.ops) return -EINVAL; + /* FIXME support hugetlb fs */ + if (is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL)) { + hmm_pfns_special(range); + return -EINVAL; + } + /* Initialize range to track CPU page table update */ spin_lock(&hmm->lock); range->valid = true; @@ -693,6 +693,12 @@ int hmm_vma_fault(struct hmm_range *rang if (!hmm->mmu_notifier.ops) return -EINVAL; + /* FIXME support hugetlb fs */ + if (is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL)) { + hmm_pfns_special(range); + return -EINVAL; + } + /* Initialize range to track CPU page table update */ spin_lock(&hmm->lock); range->valid = true; @@ -710,12 +716,6 @@ int hmm_vma_fault(struct hmm_range *rang return 0; } - /* FIXME support hugetlb fs */ - if (is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL)) { - hmm_pfns_special(range->pfns, range->start, range->end); - return 0; - } - hmm_vma_walk.fault = true; hmm_vma_walk.write = write; hmm_vma_walk.block = block; _ Patches currently in -mm which might be from jglisse@xxxxxxxxxx are mm-hmm-fix-header-file-if-else-endif-maze.patch mm-hmm-hmm_pfns_bad-was-accessing-wrong-struct.patch mm-hmm-use-struct-for-hmm_vma_fault-hmm_vma_get_pfns-parameters.patch mm-hmm-remove-hmm_pfn_read-flag-and-ignore-peculiar-architecture.patch mm-hmm-use-uint64_t-for-hmm-pfn-instead-of-defining-hmm_pfn_t-to-ulong.patch mm-hmm-cleanup-special-vma-handling-vm_special.patch mm-hmm-do-not-differentiate-between-empty-entry-or-missing-directory.patch mm-hmm-rename-hmm_pfn_device_unaddressable-to-hmm_pfn_device_private.patch mm-hmm-move-hmm_pfns_clear-closer-to-where-it-is-use.patch mm-hmm-factor-out-pte-and-pmd-handling-to-simplify-hmm_vma_walk_pmd.patch mm-hmm-change-hmm_vma_fault-to-allow-write-fault-on-page-basis.patch mm-hmm-use-device-driver-encoding-for-hmm-pfn.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html