From: Dan Williams <dan.j.williams@intel.com> To: akpm@linux-foundation.org Cc: Michal Hocko <mhocko@suse.com>, jack@suse.cz, linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hch@lst.de, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Subject: [PATCH v4 05/18] dax: stop using VM_MIXEDMAP for dax Date: Sat, 23 Dec 2017 16:56:27 -0800 [thread overview] Message-ID: <151407698763.38751.8605535379424429182.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) In-Reply-To: <151407695916.38751.2866053440557472361.stgit@dwillia2-desk3.amr.corp.intel.com> VM_MIXEDMAP is used by dax to direct mm paths like vm_normal_page() that the memory page it is dealing with is not typical memory from the linear map. The get_user_pages_fast() path, since it does not resolve the vma, is already using {pte,pmd}_devmap() as a stand-in for VM_MIXEDMAP, so we use that as a VM_MIXEDMAP replacement in some locations. In the cases where there is no pte to consult we fallback to using vma_is_dax() to detect the VM_MIXEDMAP special case. Now that we have explicit driver pfn_t-flag opt-in/opt-out for get_user_pages() support for DAX we can stop setting VM_MIXEDMAP. This also means we no longer need to worry about safely manipulating vm_flags in a future where we support dynamically changing the dax mode of a file. Cc: Jan Kara <jack@suse.cz> Cc: Michal Hocko <mhocko@suse.com> Cc: Jeff Moyer <jmoyer@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- drivers/dax/device.c | 2 +- fs/ext2/file.c | 1 - fs/ext4/file.c | 2 +- fs/xfs/xfs_file.c | 2 +- include/linux/mm.h | 1 + include/linux/vma.h | 23 +++++++++++++++++++++++ mm/huge_memory.c | 6 ++---- mm/ksm.c | 3 +++ mm/madvise.c | 2 +- mm/memory.c | 8 ++++++-- mm/migrate.c | 3 ++- mm/mlock.c | 5 +++-- mm/mmap.c | 8 ++++---- 13 files changed, 48 insertions(+), 18 deletions(-) create mode 100644 include/linux/vma.h diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 7b0bf825c4e7..c514ad48ff73 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -463,7 +463,7 @@ static int dax_mmap(struct file *filp, struct vm_area_struct *vma) return rc; vma->vm_ops = &dax_vm_ops; - vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; + vma->vm_flags |= VM_HUGEPAGE; return 0; } diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 2da67699dc33..62c12c75b788 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -126,7 +126,6 @@ static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) file_accessed(file); vma->vm_ops = &ext2_dax_vm_ops; - vma->vm_flags |= VM_MIXEDMAP; return 0; } #else diff --git a/fs/ext4/file.c b/fs/ext4/file.c index a0ae27b1bc66..983cee466a89 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -367,7 +367,7 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) file_accessed(file); if (IS_DAX(file_inode(file))) { vma->vm_ops = &ext4_dax_vm_ops; - vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; + vma->vm_flags |= VM_HUGEPAGE; } else { vma->vm_ops = &ext4_file_vm_ops; } diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 8601275cc5e6..1d6d4a3ecd42 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1130,7 +1130,7 @@ xfs_file_mmap( file_accessed(filp); vma->vm_ops = &xfs_file_vm_ops; if (IS_DAX(file_inode(filp))) - vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; + vma->vm_flags |= VM_HUGEPAGE; return 0; } diff --git a/include/linux/mm.h b/include/linux/mm.h index 09637c353de0..dc124b278173 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2405,6 +2405,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn); int vm_insert_mixed_mkwrite(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn); +bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn); int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len); diff --git a/include/linux/vma.h b/include/linux/vma.h new file mode 100644 index 000000000000..e71487e8c5f0 --- /dev/null +++ b/include/linux/vma.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright(c) 2017 Intel Corporation. All rights reserved. */ +#ifndef __VMA_H__ +#define __VMA_H__ +#include <linux/fs.h> +#include <linux/mm.h> +#include <linux/mm_types.h> +#include <linux/hugetlb_inline.h> + +/* + * There are several vma types that have special handling in the + * get_user_pages() path and other core mm paths that must not assume + * normal pages. vma_is_special() consolidates some common checks for + * VM_SPECIAL, hugetlb and dax vmas, but note that there are 'special' + * vmas and circumstances beyond these types. In other words this helper + * is not exhaustive for example this does not replace VM_PFNMAP checks. + */ +static inline bool vma_is_special(struct vm_area_struct *vma) +{ + return vma && (is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL) + || vma_is_dax(vma)); +} +#endif /* __VMA_H__ */ diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 2f2f5e774902..d1b891f27675 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -765,11 +765,10 @@ int vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, * but we need to be consistent with PTEs and architectures that * can't support a 'special' bit. */ - BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); + BUG_ON(!((vma->vm_flags & VM_PFNMAP) || vm_mixed_ok(vma, pfn))); 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(!pfn_t_devmap(pfn)); if (addr < vma->vm_start || addr >= vma->vm_end) return VM_FAULT_SIGBUS; @@ -824,11 +823,10 @@ int vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, * but we need to be consistent with PTEs and architectures that * can't support a 'special' bit. */ - BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); + BUG_ON(!((vma->vm_flags & VM_PFNMAP) || vm_mixed_ok(vma, pfn))); 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(!pfn_t_devmap(pfn)); if (addr < vma->vm_start || addr >= vma->vm_end) return VM_FAULT_SIGBUS; diff --git a/mm/ksm.c b/mm/ksm.c index be8f4576f842..0bd1fda485fd 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -2372,6 +2372,9 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start, VM_HUGETLB | VM_MIXEDMAP)) return 0; /* just ignore the advice */ + if (vma_is_dax(vma)) + return 0; + #ifdef VM_SAO if (*vm_flags & VM_SAO) return 0; diff --git a/mm/madvise.c b/mm/madvise.c index 751e97aa2210..eff3ec1e2574 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -96,7 +96,7 @@ static long madvise_behavior(struct vm_area_struct *vma, new_flags |= VM_DONTDUMP; break; case MADV_DODUMP: - if (new_flags & VM_SPECIAL) { + if (vma_is_dax(vma) || (new_flags & VM_SPECIAL)) { error = -EINVAL; goto out; } diff --git a/mm/memory.c b/mm/memory.c index 48a13473b401..1efb005e8fab 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -831,6 +831,8 @@ struct page *_vm_normal_page(struct vm_area_struct *vma, unsigned long addr, return vma->vm_ops->find_special_page(vma, addr); if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP)) return NULL; + if (pte_devmap(pte)) + return NULL; if (is_zero_pfn(pfn)) return NULL; @@ -918,6 +920,8 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, } } + if (pmd_devmap(pmd)) + return NULL; if (is_zero_pfn(pfn)) return NULL; if (unlikely(pfn > highest_memmap_pfn)) @@ -1228,7 +1232,7 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, * efficient than faulting. */ if (!(vma->vm_flags & (VM_HUGETLB | VM_PFNMAP | VM_MIXEDMAP)) && - !vma->anon_vma) + !vma->anon_vma && !vma_is_dax(vma)) return 0; if (is_vm_hugetlb_page(vma)) @@ -1897,7 +1901,7 @@ int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_pfn_prot); -static bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn) +bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn) { /* these checks mirror the abort conditions in vm_normal_page */ if (vma->vm_flags & VM_MIXEDMAP) diff --git a/mm/migrate.c b/mm/migrate.c index 4d0be47a322a..624d43a455be 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -46,6 +46,7 @@ #include <linux/page_owner.h> #include <linux/sched/mm.h> #include <linux/ptrace.h> +#include <linux/vma.h> #include <asm/tlbflush.h> @@ -2938,7 +2939,7 @@ int migrate_vma(const struct migrate_vma_ops *ops, /* Sanity check the arguments */ start &= PAGE_MASK; end &= PAGE_MASK; - if (!vma || is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL)) + if (!vma || vma_is_special(vma)) return -EINVAL; if (start < vma->vm_start || start >= vma->vm_end) return -EINVAL; diff --git a/mm/mlock.c b/mm/mlock.c index 30472d438794..a10580f77c84 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -23,6 +23,7 @@ #include <linux/hugetlb.h> #include <linux/memcontrol.h> #include <linux/mm_inline.h> +#include <linux/vma.h> #include "internal.h" @@ -520,8 +521,8 @@ static int mlock_fixup(struct vm_area_struct *vma, struct vm_area_struct **prev, int lock = !!(newflags & VM_LOCKED); vm_flags_t old_flags = vma->vm_flags; - if (newflags == vma->vm_flags || (vma->vm_flags & VM_SPECIAL) || - is_vm_hugetlb_page(vma) || vma == get_gate_vma(current->mm)) + if (newflags == vma->vm_flags || vma_is_special(vma) + || vma == get_gate_vma(current->mm)) /* don't set VM_LOCKED or VM_LOCKONFAULT and don't count */ goto out; diff --git a/mm/mmap.c b/mm/mmap.c index a4d546821214..b063e363cf27 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -45,6 +45,7 @@ #include <linux/moduleparam.h> #include <linux/pkeys.h> #include <linux/oom.h> +#include <linux/vma.h> #include <linux/uaccess.h> #include <asm/cacheflush.h> @@ -1737,11 +1738,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vm_stat_account(mm, vm_flags, len >> PAGE_SHIFT); if (vm_flags & VM_LOCKED) { - if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) || - vma == get_gate_vma(current->mm))) - mm->locked_vm += (len >> PAGE_SHIFT); - else + if (vma_is_special(vma) || vma == get_gate_vma(current->mm)) vma->vm_flags &= VM_LOCKED_CLEAR_MASK; + else + mm->locked_vm += (len >> PAGE_SHIFT); } if (file) _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: Dan Williams <dan.j.williams@intel.com> To: akpm@linux-foundation.org Cc: Michal Hocko <mhocko@suse.com>, jack@suse.cz, linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org, Jeff Moyer <jmoyer@redhat.com>, linux-fsdevel@vger.kernel.org, ross.zwisler@linux.intel.com, hch@lst.de, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Subject: [PATCH v4 05/18] dax: stop using VM_MIXEDMAP for dax Date: Sat, 23 Dec 2017 16:56:27 -0800 [thread overview] Message-ID: <151407698763.38751.8605535379424429182.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) In-Reply-To: <151407695916.38751.2866053440557472361.stgit@dwillia2-desk3.amr.corp.intel.com> VM_MIXEDMAP is used by dax to direct mm paths like vm_normal_page() that the memory page it is dealing with is not typical memory from the linear map. The get_user_pages_fast() path, since it does not resolve the vma, is already using {pte,pmd}_devmap() as a stand-in for VM_MIXEDMAP, so we use that as a VM_MIXEDMAP replacement in some locations. In the cases where there is no pte to consult we fallback to using vma_is_dax() to detect the VM_MIXEDMAP special case. Now that we have explicit driver pfn_t-flag opt-in/opt-out for get_user_pages() support for DAX we can stop setting VM_MIXEDMAP. This also means we no longer need to worry about safely manipulating vm_flags in a future where we support dynamically changing the dax mode of a file. Cc: Jan Kara <jack@suse.cz> Cc: Michal Hocko <mhocko@suse.com> Cc: Jeff Moyer <jmoyer@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- drivers/dax/device.c | 2 +- fs/ext2/file.c | 1 - fs/ext4/file.c | 2 +- fs/xfs/xfs_file.c | 2 +- include/linux/mm.h | 1 + include/linux/vma.h | 23 +++++++++++++++++++++++ mm/huge_memory.c | 6 ++---- mm/ksm.c | 3 +++ mm/madvise.c | 2 +- mm/memory.c | 8 ++++++-- mm/migrate.c | 3 ++- mm/mlock.c | 5 +++-- mm/mmap.c | 8 ++++---- 13 files changed, 48 insertions(+), 18 deletions(-) create mode 100644 include/linux/vma.h diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 7b0bf825c4e7..c514ad48ff73 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -463,7 +463,7 @@ static int dax_mmap(struct file *filp, struct vm_area_struct *vma) return rc; vma->vm_ops = &dax_vm_ops; - vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; + vma->vm_flags |= VM_HUGEPAGE; return 0; } diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 2da67699dc33..62c12c75b788 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -126,7 +126,6 @@ static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) file_accessed(file); vma->vm_ops = &ext2_dax_vm_ops; - vma->vm_flags |= VM_MIXEDMAP; return 0; } #else diff --git a/fs/ext4/file.c b/fs/ext4/file.c index a0ae27b1bc66..983cee466a89 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -367,7 +367,7 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) file_accessed(file); if (IS_DAX(file_inode(file))) { vma->vm_ops = &ext4_dax_vm_ops; - vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; + vma->vm_flags |= VM_HUGEPAGE; } else { vma->vm_ops = &ext4_file_vm_ops; } diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 8601275cc5e6..1d6d4a3ecd42 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1130,7 +1130,7 @@ xfs_file_mmap( file_accessed(filp); vma->vm_ops = &xfs_file_vm_ops; if (IS_DAX(file_inode(filp))) - vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; + vma->vm_flags |= VM_HUGEPAGE; return 0; } diff --git a/include/linux/mm.h b/include/linux/mm.h index 09637c353de0..dc124b278173 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2405,6 +2405,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn); int vm_insert_mixed_mkwrite(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn); +bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn); int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len); diff --git a/include/linux/vma.h b/include/linux/vma.h new file mode 100644 index 000000000000..e71487e8c5f0 --- /dev/null +++ b/include/linux/vma.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright(c) 2017 Intel Corporation. All rights reserved. */ +#ifndef __VMA_H__ +#define __VMA_H__ +#include <linux/fs.h> +#include <linux/mm.h> +#include <linux/mm_types.h> +#include <linux/hugetlb_inline.h> + +/* + * There are several vma types that have special handling in the + * get_user_pages() path and other core mm paths that must not assume + * normal pages. vma_is_special() consolidates some common checks for + * VM_SPECIAL, hugetlb and dax vmas, but note that there are 'special' + * vmas and circumstances beyond these types. In other words this helper + * is not exhaustive for example this does not replace VM_PFNMAP checks. + */ +static inline bool vma_is_special(struct vm_area_struct *vma) +{ + return vma && (is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL) + || vma_is_dax(vma)); +} +#endif /* __VMA_H__ */ diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 2f2f5e774902..d1b891f27675 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -765,11 +765,10 @@ int vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, * but we need to be consistent with PTEs and architectures that * can't support a 'special' bit. */ - BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); + BUG_ON(!((vma->vm_flags & VM_PFNMAP) || vm_mixed_ok(vma, pfn))); 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(!pfn_t_devmap(pfn)); if (addr < vma->vm_start || addr >= vma->vm_end) return VM_FAULT_SIGBUS; @@ -824,11 +823,10 @@ int vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, * but we need to be consistent with PTEs and architectures that * can't support a 'special' bit. */ - BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); + BUG_ON(!((vma->vm_flags & VM_PFNMAP) || vm_mixed_ok(vma, pfn))); 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(!pfn_t_devmap(pfn)); if (addr < vma->vm_start || addr >= vma->vm_end) return VM_FAULT_SIGBUS; diff --git a/mm/ksm.c b/mm/ksm.c index be8f4576f842..0bd1fda485fd 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -2372,6 +2372,9 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start, VM_HUGETLB | VM_MIXEDMAP)) return 0; /* just ignore the advice */ + if (vma_is_dax(vma)) + return 0; + #ifdef VM_SAO if (*vm_flags & VM_SAO) return 0; diff --git a/mm/madvise.c b/mm/madvise.c index 751e97aa2210..eff3ec1e2574 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -96,7 +96,7 @@ static long madvise_behavior(struct vm_area_struct *vma, new_flags |= VM_DONTDUMP; break; case MADV_DODUMP: - if (new_flags & VM_SPECIAL) { + if (vma_is_dax(vma) || (new_flags & VM_SPECIAL)) { error = -EINVAL; goto out; } diff --git a/mm/memory.c b/mm/memory.c index 48a13473b401..1efb005e8fab 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -831,6 +831,8 @@ struct page *_vm_normal_page(struct vm_area_struct *vma, unsigned long addr, return vma->vm_ops->find_special_page(vma, addr); if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP)) return NULL; + if (pte_devmap(pte)) + return NULL; if (is_zero_pfn(pfn)) return NULL; @@ -918,6 +920,8 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, } } + if (pmd_devmap(pmd)) + return NULL; if (is_zero_pfn(pfn)) return NULL; if (unlikely(pfn > highest_memmap_pfn)) @@ -1228,7 +1232,7 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, * efficient than faulting. */ if (!(vma->vm_flags & (VM_HUGETLB | VM_PFNMAP | VM_MIXEDMAP)) && - !vma->anon_vma) + !vma->anon_vma && !vma_is_dax(vma)) return 0; if (is_vm_hugetlb_page(vma)) @@ -1897,7 +1901,7 @@ int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_pfn_prot); -static bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn) +bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn) { /* these checks mirror the abort conditions in vm_normal_page */ if (vma->vm_flags & VM_MIXEDMAP) diff --git a/mm/migrate.c b/mm/migrate.c index 4d0be47a322a..624d43a455be 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -46,6 +46,7 @@ #include <linux/page_owner.h> #include <linux/sched/mm.h> #include <linux/ptrace.h> +#include <linux/vma.h> #include <asm/tlbflush.h> @@ -2938,7 +2939,7 @@ int migrate_vma(const struct migrate_vma_ops *ops, /* Sanity check the arguments */ start &= PAGE_MASK; end &= PAGE_MASK; - if (!vma || is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_SPECIAL)) + if (!vma || vma_is_special(vma)) return -EINVAL; if (start < vma->vm_start || start >= vma->vm_end) return -EINVAL; diff --git a/mm/mlock.c b/mm/mlock.c index 30472d438794..a10580f77c84 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -23,6 +23,7 @@ #include <linux/hugetlb.h> #include <linux/memcontrol.h> #include <linux/mm_inline.h> +#include <linux/vma.h> #include "internal.h" @@ -520,8 +521,8 @@ static int mlock_fixup(struct vm_area_struct *vma, struct vm_area_struct **prev, int lock = !!(newflags & VM_LOCKED); vm_flags_t old_flags = vma->vm_flags; - if (newflags == vma->vm_flags || (vma->vm_flags & VM_SPECIAL) || - is_vm_hugetlb_page(vma) || vma == get_gate_vma(current->mm)) + if (newflags == vma->vm_flags || vma_is_special(vma) + || vma == get_gate_vma(current->mm)) /* don't set VM_LOCKED or VM_LOCKONFAULT and don't count */ goto out; diff --git a/mm/mmap.c b/mm/mmap.c index a4d546821214..b063e363cf27 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -45,6 +45,7 @@ #include <linux/moduleparam.h> #include <linux/pkeys.h> #include <linux/oom.h> +#include <linux/vma.h> #include <linux/uaccess.h> #include <asm/cacheflush.h> @@ -1737,11 +1738,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, vm_stat_account(mm, vm_flags, len >> PAGE_SHIFT); if (vm_flags & VM_LOCKED) { - if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) || - vma == get_gate_vma(current->mm))) - mm->locked_vm += (len >> PAGE_SHIFT); - else + if (vma_is_special(vma) || vma == get_gate_vma(current->mm)) vma->vm_flags &= VM_LOCKED_CLEAR_MASK; + else + mm->locked_vm += (len >> PAGE_SHIFT); } if (file)
next prev parent reply other threads:[~2017-12-24 0:59 UTC|newest] Thread overview: 136+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-12-24 0:56 [PATCH v4 00/18] dax: fix dma vs truncate/hole-punch Dan Williams 2017-12-24 0:56 ` Dan Williams 2017-12-24 0:56 ` Dan Williams 2017-12-24 0:56 ` [PATCH v4 01/18] mm, dax: introduce pfn_t_special() Dan Williams 2017-12-24 0:56 ` Dan Williams 2018-01-04 8:16 ` Christoph Hellwig 2018-01-04 8:16 ` Christoph Hellwig 2017-12-24 0:56 ` [PATCH v4 02/18] ext4: auto disable dax instead of failing mount Dan Williams 2017-12-24 0:56 ` Dan Williams 2018-01-03 14:20 ` Jan Kara 2018-01-03 14:20 ` Jan Kara 2017-12-24 0:56 ` [PATCH v4 03/18] ext2: " Dan Williams 2017-12-24 0:56 ` Dan Williams 2018-01-03 14:21 ` Jan Kara 2018-01-03 14:21 ` Jan Kara 2017-12-24 0:56 ` [PATCH v4 04/18] dax: require 'struct page' by default for filesystem dax Dan Williams 2017-12-24 0:56 ` Dan Williams 2018-01-03 15:29 ` Jan Kara 2018-01-03 15:29 ` Jan Kara 2018-01-04 8:16 ` Christoph Hellwig 2018-01-04 8:16 ` Christoph Hellwig 2018-01-08 11:58 ` Gerald Schaefer 2018-01-08 11:58 ` Gerald Schaefer 2017-12-24 0:56 ` Dan Williams [this message] 2017-12-24 0:56 ` [PATCH v4 05/18] dax: stop using VM_MIXEDMAP for dax Dan Williams 2018-01-03 15:27 ` Jan Kara 2018-01-03 15:27 ` Jan Kara 2017-12-24 0:56 ` [PATCH v4 06/18] dax: stop using VM_HUGEPAGE " Dan Williams 2017-12-24 0:56 ` Dan Williams 2017-12-24 0:56 ` [PATCH v4 07/18] dax: store pfns in the radix Dan Williams 2017-12-24 0:56 ` Dan Williams 2017-12-27 0:17 ` Ross Zwisler 2017-12-27 0:17 ` Ross Zwisler 2018-01-02 20:15 ` Dan Williams 2018-01-02 20:15 ` Dan Williams 2018-01-03 15:39 ` Jan Kara 2018-01-03 15:39 ` Jan Kara 2017-12-24 0:56 ` [PATCH v4 08/18] tools/testing/nvdimm: add 'bio_delay' mechanism Dan Williams 2017-12-24 0:56 ` Dan Williams 2017-12-27 18:08 ` Ross Zwisler 2017-12-27 18:08 ` Ross Zwisler 2018-01-02 20:35 ` Dan Williams 2018-01-02 20:35 ` Dan Williams 2018-01-02 21:44 ` Dave Chinner 2018-01-02 21:44 ` Dave Chinner 2018-01-02 21:51 ` Dan Williams 2018-01-02 21:51 ` Dan Williams 2018-01-03 15:46 ` Jan Kara 2018-01-03 15:46 ` Jan Kara 2018-01-03 20:37 ` Jeff Moyer 2018-01-03 20:37 ` Jeff Moyer 2017-12-24 0:56 ` [PATCH v4 09/18] mm, dax: enable filesystems to trigger dev_pagemap ->page_free callbacks Dan Williams 2017-12-24 0:56 ` Dan Williams 2018-01-04 8:20 ` Christoph Hellwig 2018-01-04 8:20 ` Christoph Hellwig 2017-12-24 0:56 ` [PATCH v4 10/18] mm, dev_pagemap: introduce CONFIG_DEV_PAGEMAP_OPS Dan Williams 2017-12-24 0:56 ` Dan Williams 2018-01-04 8:25 ` Christoph Hellwig 2018-01-04 8:25 ` Christoph Hellwig 2017-12-24 0:56 ` [PATCH v4 11/18] fs, dax: introduce DEFINE_FSDAX_AOPS Dan Williams 2017-12-24 0:56 ` Dan Williams 2017-12-27 5:29 ` Matthew Wilcox 2017-12-27 5:29 ` Matthew Wilcox 2018-01-02 20:21 ` Dan Williams 2018-01-02 20:21 ` Dan Williams 2018-01-03 16:05 ` Jan Kara 2018-01-03 16:05 ` Jan Kara 2018-01-04 8:27 ` Christoph Hellwig 2018-01-04 8:27 ` Christoph Hellwig 2018-01-02 21:41 ` Dave Chinner 2018-01-02 21:41 ` Dave Chinner 2017-12-24 0:57 ` [PATCH v4 12/18] xfs: use DEFINE_FSDAX_AOPS Dan Williams 2017-12-24 0:57 ` Dan Williams 2018-01-02 21:15 ` Darrick J. Wong 2018-01-02 21:15 ` Darrick J. Wong 2018-01-02 21:40 ` Dan Williams 2018-01-02 21:40 ` Dan Williams 2018-01-03 16:09 ` Jan Kara 2018-01-03 16:09 ` Jan Kara 2018-01-04 8:28 ` Christoph Hellwig 2018-01-04 8:28 ` Christoph Hellwig 2017-12-24 0:57 ` [PATCH v4 13/18] ext4: " Dan Williams 2017-12-24 0:57 ` Dan Williams 2017-12-24 0:57 ` Dan Williams 2018-01-04 8:29 ` Christoph Hellwig 2018-01-04 8:29 ` Christoph Hellwig 2018-01-04 8:29 ` Christoph Hellwig 2017-12-24 0:57 ` [PATCH v4 14/18] ext2: " Dan Williams 2017-12-24 0:57 ` Dan Williams 2018-01-04 8:29 ` Christoph Hellwig 2018-01-04 8:29 ` Christoph Hellwig 2017-12-24 0:57 ` [PATCH v4 15/18] mm, fs, dax: use page->mapping to warn if dma collides with truncate Dan Williams 2017-12-24 0:57 ` Dan Williams 2018-01-04 8:30 ` Christoph Hellwig 2018-01-04 8:30 ` Christoph Hellwig 2018-01-04 9:39 ` Jan Kara 2018-01-04 9:39 ` Jan Kara 2017-12-24 0:57 ` [PATCH v4 16/18] wait_bit: introduce {wait_on,wake_up}_atomic_one Dan Williams 2017-12-24 0:57 ` Dan Williams 2018-01-04 8:30 ` Christoph Hellwig 2018-01-04 8:30 ` Christoph Hellwig 2017-12-24 0:57 ` [PATCH v4 17/18] mm, fs, dax: dax_flush_dma, handle dma vs block-map-change collisions Dan Williams 2017-12-24 0:57 ` Dan Williams 2018-01-04 8:31 ` Christoph Hellwig 2018-01-04 8:31 ` Christoph Hellwig 2018-01-04 11:12 ` Jan Kara 2018-01-04 11:12 ` Jan Kara 2018-01-07 21:58 ` Dan Williams 2018-01-07 21:58 ` Dan Williams 2018-01-08 13:50 ` Jan Kara 2018-01-08 13:50 ` Jan Kara 2018-03-08 17:02 ` Dan Williams 2018-03-08 17:02 ` Dan Williams 2018-03-09 12:56 ` Jan Kara 2018-03-09 12:56 ` Jan Kara 2018-03-09 16:15 ` Dan Williams 2018-03-09 16:15 ` Dan Williams 2018-03-09 17:26 ` Dan Williams 2018-03-09 17:26 ` Dan Williams 2017-12-24 0:57 ` [PATCH v4 18/18] xfs, dax: wire up dax_flush_dma support via a new xfs_sync_dma helper Dan Williams 2017-12-24 0:57 ` Dan Williams 2018-01-02 21:07 ` Darrick J. Wong 2018-01-02 21:07 ` Darrick J. Wong 2018-01-02 23:00 ` Dave Chinner 2018-01-02 23:00 ` Dave Chinner 2018-01-03 2:21 ` Dan Williams 2018-01-03 2:21 ` Dan Williams 2018-01-03 7:51 ` Dave Chinner 2018-01-03 7:51 ` Dave Chinner 2018-01-04 8:34 ` Christoph Hellwig 2018-01-04 8:34 ` Christoph Hellwig 2018-01-04 8:33 ` Christoph Hellwig 2018-01-04 8:33 ` Christoph Hellwig 2018-01-04 8:17 ` [PATCH v4 00/18] dax: fix dma vs truncate/hole-punch Christoph Hellwig 2018-01-04 8:17 ` Christoph Hellwig 2018-01-04 8:17 ` Christoph Hellwig
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=151407698763.38751.8605535379424429182.stgit@dwillia2-desk3.amr.corp.intel.com \ --to=dan.j.williams@intel.com \ --cc=akpm@linux-foundation.org \ --cc=hch@lst.de \ --cc=jack@suse.cz \ --cc=kirill.shutemov@linux.intel.com \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-nvdimm@lists.01.org \ --cc=linux-xfs@vger.kernel.org \ --cc=mhocko@suse.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.