mm: vma->vm_flags diet
Subsystems (59)
v3 cover mm: vma->vm_flags diet
This patchset kills some VM_* flags in vma->vm_flags, as result there appears five free bits.
Changes since v2 [ https://lkml.org/lkml/2012/4/7/67 ]
* killing VM_EXECUTABLE combined back into single patch
* new (the biggest one) patch which kills VM_RESERVED
---
Konstantin Khlebnikov (8):
mm, x86, pat: rework linear pfn-mmap tracking
mm: introduce arch-specific vma flag VM_ARCH_1
mm: kill vma flag VM_INSERTPAGE
mm: kill vma flag VM_CAN_NONLINEAR
mm: use mm->exe_file instead of first VM_EXECUTABLE vma->vm_file
mm: kill vma flag VM_EXECUTABLE and mm->num_exe_file_vmas
mm: prepare VM_DONTDUMP for using in drivers
mm: kill vma flag VM_RESERVED and mm->reserved_vm counter
Suresh Siddha (2):
x86, pat: remove the dependency on 'vm_pgoff' in track/untrack pfn vma routines x86, pat: separate the pfn attribute tracking for remap_pfn_range and vm_insert_pfn
Documentation/vm/unevictable-lru.txt | 4 - arch/alpha/kernel/pci-sysfs.c | 2 arch/ia64/kernel/perfmon.c | 2 arch/ia64/mm/init.c | 3 - arch/powerpc/kvm/book3s_hv.c | 2 arch/powerpc/oprofile/cell/spu_task_sync.c | 15 +--- arch/sparc/kernel/pci.c | 2 arch/tile/mm/elf.c | 19 ++--- arch/unicore32/kernel/process.c | 2 arch/x86/mm/pat.c | 89 ++++++++++++++++------ arch/x86/xen/mmu.c | 3 - drivers/char/mbcs.c | 2 drivers/char/mem.c | 2 drivers/char/mspec.c | 2 drivers/gpu/drm/drm_gem.c | 2 drivers/gpu/drm/drm_vm.c | 10 -- drivers/gpu/drm/exynos/exynos_drm_gem.c | 2 drivers/gpu/drm/gma500/framebuffer.c | 3 - drivers/gpu/drm/ttm/ttm_bo_vm.c | 4 - drivers/gpu/drm/udl/udl_fb.c | 2 drivers/infiniband/hw/ehca/ehca_uverbs.c | 4 - drivers/infiniband/hw/ipath/ipath_file_ops.c | 2 drivers/infiniband/hw/qib/qib_file_ops.c | 2 drivers/media/video/meye.c | 2 drivers/media/video/omap/omap_vout.c | 2 drivers/media/video/sn9c102/sn9c102_core.c | 3 - drivers/media/video/usbvision/usbvision-video.c | 3 - drivers/media/video/videobuf-dma-sg.c | 2 drivers/media/video/videobuf-vmalloc.c | 2 drivers/media/video/videobuf2-memops.c | 2 drivers/media/video/vino.c | 2 drivers/misc/carma/carma-fpga.c | 2 drivers/misc/sgi-gru/grufile.c | 5 - drivers/mtd/mtdchar.c | 2 drivers/oprofile/buffer_sync.c | 17 +--- drivers/scsi/sg.c | 2 drivers/staging/android/ashmem.c | 1 drivers/staging/media/easycap/easycap_main.c | 2 drivers/staging/omapdrm/omap_gem_dmabuf.c | 2 drivers/staging/tidspbridge/rmgr/drv_interface.c | 2 drivers/uio/uio.c | 4 - drivers/usb/mon/mon_bin.c | 2 drivers/video/68328fb.c | 2 drivers/video/aty/atyfb_base.c | 3 - drivers/video/fb-puv3.c | 3 - drivers/video/fb_defio.c | 2 drivers/video/fbmem.c | 3 - drivers/video/gbefb.c | 2 drivers/video/omap2/omapfb/omapfb-main.c | 2 drivers/video/sbuslib.c | 5 - drivers/video/smscufx.c | 1 drivers/video/udlfb.c | 1 drivers/video/vermilion/vermilion.c | 1 drivers/video/vfb.c | 1 drivers/xen/gntalloc.c | 2 drivers/xen/gntdev.c | 2 drivers/xen/privcmd.c | 3 - fs/9p/vfs_file.c | 1 fs/binfmt_elf.c | 4 - fs/binfmt_elf_fdpic.c | 2 fs/btrfs/file.c | 2 fs/ceph/addr.c | 2 fs/cifs/file.c | 1 fs/ext4/file.c | 2 fs/fuse/file.c | 1 fs/gfs2/file.c | 2 fs/hugetlbfs/inode.c | 2 fs/nfs/file.c | 1 fs/nilfs2/file.c | 2 fs/ocfs2/mmap.c | 2 fs/proc/task_mmu.c | 2 fs/ubifs/file.c | 1 fs/xfs/xfs_file.c | 2 include/asm-generic/pgtable.h | 57 ++++++++------ include/linux/fs.h | 2 include/linux/mempolicy.h | 2 include/linux/mm.h | 69 +++++++---------- include/linux/mm_types.h | 2 include/linux/mman.h | 1 kernel/auditsc.c | 13 --- kernel/events/core.c | 2 kernel/fork.c | 24 ------ mm/filemap.c | 2 mm/filemap_xip.c | 3 - mm/fremap.c | 14 ++- mm/huge_memory.c | 22 +---- mm/ksm.c | 8 +- mm/madvise.c | 8 +- mm/memory.c | 62 ++++++++------- mm/mlock.c | 2 mm/mmap.c | 29 +------ mm/nommu.c | 21 ++--- mm/shmem.c | 3 - mm/vmalloc.c | 3 - security/selinux/selinuxfs.c | 2 security/tomoyo/util.c | 9 -- sound/core/pcm_native.c | 6 + sound/usb/usx2y/us122l.c | 2 sound/usb/usx2y/usX2Yhwdep.c | 2 sound/usb/usx2y/usx2yhwdeppcm.c | 2 100 files changed, 303 insertions(+), 370 deletions(-)
Signature · 7 lines
Signature -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 1/10 x86, pat: remove the dependency on 'vm_pgoff' in track/untrack pfn vma routines
From: Suresh Siddha <[email protected]>
'pfn' argument for track_pfn_vma_new() can be used for reserving the attribute for the pfn range. No need to depend on 'vm_pgoff'
Similarly, untrack_pfn_vma() can depend on the 'pfn' argument if it is non-zero or can use follow_phys() to get the starting value of the pfn range.
Also the non zero 'size' argument can be used instead of recomputing it from vma.
This cleanup also prepares the ground for the track/untrack pfn vma routines to take over the ownership of setting PAT specific vm_flag in the 'vma'.
[[email protected]: Clear pfn to paddr conversion]
--- arch/x86/mm/pat.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-)
arch/x86/mm/pat.c +19 -14
@@ -704,21 +704,18 @@ int track_pfn_vma_copy(struct vm_area_struct *vma)int track_pfn_vma_new (struct vm_area_struct *vma,pgprot_t *prot,unsigned long pfn,unsigned long size) { +resource_size_t paddr = (resource_size_t )pfn <<PAGE_SHIFT ;unsigned long flags; -resource_size_t paddr; -unsigned long vma_size = vma->vm_end - vma->vm_start; -if (is_linear_pfn_mapping (vma)) { -/* reserve the whole chunk starting from vm_pgoff */ - paddr = (resource_size_t )vma->vm_pgoff <<PAGE_SHIFT ; -return reserve_pfn_range (paddr, vma_size, prot,0 ); - } +/* reserve the whole chunk starting from paddr */ +if (is_linear_pfn_mapping (vma)) +return reserve_pfn_range (paddr, size, prot,0 );if (!pat_enabled)return 0 ;/* for vm_insert_pfn and friends, we set prot based on lookup */ - flags =lookup_memtype (pfn <<PAGE_SHIFT ); + flags =lookup_memtype (paddr); *prot =__pgprot ((pgprot_val (vma->vm_page_prot) & (~_PAGE_CACHE_MASK)) | flags);
@@ -728,20 +725,28 @@ int track_pfn_vma_new(struct vm_area_struct *vma, pgprot_t *prot,/* * untrack_pfn_vma is called while unmapping a pfnmap for a region. * untrack can be called for a specific region indicated by pfn and size or -* can be for the entire vma (in which case size can be zero). +* can be for the entire vma (in which case pfn, size are zero). */ void untrack_pfn_vma (struct vm_area_struct *vma,unsigned long pfn,unsigned long size) {resource_size_t paddr; -unsigned long vma_size = vma->vm_end - vma->vm_start; +unsigned long prot; -if (is_linear_pfn_mapping (vma)) { -/* free the whole chunk starting from vm_pgoff */ - paddr = (resource_size_t )vma->vm_pgoff <<PAGE_SHIFT ; -free_pfn_range (paddr, vma_size); +if (!is_linear_pfn_mapping (vma))return ; + +/* free the chunk starting from pfn or the whole chunk */ + paddr = (resource_size_t )pfn <<PAGE_SHIFT ; +if (!paddr && !size) { +if (follow_phys (vma, vma->vm_start,0 , &prot, &paddr)) { +WARN_ON_ONCE (1 ); +return ; + } + + size = vma->vm_end - vma->vm_start; } +free_pfn_range (paddr, size); }pgprot_t pgprot_writecombine (pgprot_t prot)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 2/10 x86, pat: separate the pfn attribute tracking for remap_pfn_range and vm_insert_pfn
In reply to Konstantin KhlebnikovFrom: Suresh Siddha <[email protected]>
With PAT enabled, vm_insert_pfn() looks up the existing pfn memory attribute and uses it. Expectation is that the driver reserves the memory attributes for the pfn before calling vm_insert_pfn().
remap_pfn_range() (when called for the whole vma) will setup a new attribute (based on the prot argument) for the specified pfn range. This addresses the legacy usage which typically calls remap_pfn_range() with a desired memory attribute. For ranges smaller than the vma size (which is typically not the case), remap_pfn_range() will use the existing memory attribute for the pfn range.
Expose two different API's for these different behaviors. track_pfn_insert() for tracking the pfn attribute set by vm_insert_pfn() and track_pfn_remap() for the remap_pfn_range().
This cleanup also prepares the ground for the track/untrack pfn vma routines to take over the ownership of setting PAT specific vm_flag in the 'vma'.
[[email protected]: Clear checks in track_pfn_remap()]
--- arch/x86/mm/pat.c | 49 ++++++++++++++++++++++++++++--------- include/asm-generic/pgtable.h | 55 ++++++++++++++++++++++++----------------- mm/memory.c | 13 ++++------ 3 files changed, 75 insertions(+), 42 deletions(-)
arch/x86/mm/pat.c +38 -11
@@ -664,13 +664,13 @@ static void free_pfn_range(u64 paddr, unsigned long size) }/* -* track_pfn_vma_copy is called when vma that is covering the pfnmap gets +* track_pfn_copy is called when vma that is covering the pfnmap gets * copied through copy_page_range(). * * If the vma has a linear pfn mapping for the entire range, we get the prot * from pte and reserve the entire vma range with single reserve_pfn_range call. */ -int track_pfn_vma_copy (struct vm_area_struct *vma) +int track_pfn_copy (struct vm_area_struct *vma) {resource_size_t paddr;unsigned long prot;
@@ -694,15 +694,12 @@ int track_pfn_vma_copy(struct vm_area_struct *vma) }/* -* track_pfn_vma_new is called when a _new_ pfn mapping is being established -* for physical range indicated by pfn and size. -* * prot is passed in as a parameter for the new mapping. If the vma has a * linear pfn mapping for the entire range reserve the entire vma range with * single reserve_pfn_range call. */ -int track_pfn_vma_new (struct vm_area_struct *vma,pgprot_t *prot, -unsigned long pfn,unsigned long size) +int track_pfn_remap (struct vm_area_struct *vma,pgprot_t *prot, +unsigned long pfn,unsigned long size) {resource_size_t paddr = (resource_size_t )pfn <<PAGE_SHIFT ;unsigned long flags;
@@ -714,8 +711,38 @@ int track_pfn_vma_new(struct vm_area_struct *vma, pgprot_t *prot,if (!pat_enabled)return 0 ; -/* for vm_insert_pfn and friends, we set prot based on lookup */ +/* +* for anything smaller than the vma size, +* we set prot based on the lookup. +*/ flags =lookup_memtype (paddr); + +/* +* Check memtype for the rest pages +*/ +while (size >PAGE_SIZE ) { + size -=PAGE_SIZE ; + paddr +=PAGE_SIZE ; +if (flags !=lookup_memtype (paddr)) +return -EINVAL ; + } + + *prot =__pgprot ((pgprot_val (vma->vm_page_prot) & (~_PAGE_CACHE_MASK)) | + flags); + +return 0 ; +} + +int track_pfn_insert (struct vm_area_struct *vma,pgprot_t *prot, +unsigned long pfn) +{ +unsigned long flags; + +if (!pat_enabled) +return 0 ; + +/* we set prot based on lookup */ + flags =lookup_memtype ((resource_size_t )pfn <<PAGE_SHIFT ); *prot =__pgprot ((pgprot_val (vma->vm_page_prot) & (~_PAGE_CACHE_MASK)) | flags);
@@ -723,12 +750,12 @@ int track_pfn_vma_new(struct vm_area_struct *vma, pgprot_t *prot, }/* -* untrack_pfn_vma is called while unmapping a pfnmap for a region. +* untrack_pfn is called while unmapping a pfnmap for a region. * untrack can be called for a specific region indicated by pfn and size or * can be for the entire vma (in which case pfn, size are zero). */ -void untrack_pfn_vma (struct vm_area_struct *vma,unsigned long pfn, -unsigned long size) +void untrack_pfn (struct vm_area_struct *vma,unsigned long pfn, +unsigned long size) {resource_size_t paddr;unsigned long prot;
include/asm-generic/pgtable.h +32 -23
80 lines not on this page · raw message
mm/memory.c +5 -8
@@ -1060,7 +1060,7 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,* We do not free on error cases below as remove_vma * gets called on error from higher level routine */ - ret =track_pfn_vma_copy (vma); + ret =track_pfn_copy (vma);if (ret)return ret; }
@@ -1328,7 +1328,7 @@ static void unmap_single_vma(struct mmu_gather *tlb,uprobe_munmap (vma, start, end);if (unlikely (is_pfn_mapping (vma))) -untrack_pfn_vma (vma,0 ,0 ); +untrack_pfn (vma,0 ,0 );if (start != end) {if (unlikely (is_vm_hugetlb_page (vma))) {
@@ -2159,14 +2159,11 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,if (addr < vma->vm_start || addr >= vma->vm_end)return -EFAULT ; -if (track_pfn_vma_new (vma, &pgprot, pfn,PAGE_SIZE )) +if (track_pfn_insert (vma, &pgprot, pfn))return -EINVAL ; ret =insert_pfn (vma, addr, pfn, pgprot); -if (ret) -untrack_pfn_vma (vma, pfn,PAGE_SIZE ); -return ret; }EXPORT_SYMBOL (vm_insert_pfn);
@@ -2308,7 +2305,7 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, vma->vm_flags |=VM_IO |VM_RESERVED |VM_PFNMAP ; - err =track_pfn_vma_new (vma, &prot, pfn,PAGE_ALIGN (size)); + err =track_pfn_remap (vma, &prot, pfn,PAGE_ALIGN (size));if (err) {/* * To indicate that track_pfn related cleanup is not
@@ -2332,7 +2329,7 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, }while (pgd++, addr = next, addr != end);if (err) -untrack_pfn_vma (vma, pfn,PAGE_ALIGN (size)); +untrack_pfn (vma, pfn,PAGE_ALIGN (size));return err; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 3/10 mm, x86, pat: rework linear pfn-mmap tracking
In reply to Konstantin KhlebnikovThis patch replaces generic vma-flag VM_PFN_AT_MMAP with x86-only VM_PAT.
We can toss mapping address from remap_pfn_range() into track_pfn_vma_new(), and collect all PAT-related logic together in arch/x86/.
This patch also restores orignal frustration-free is_cow_mapping() check in remap_pfn_range(), as it was before commit v2.6.28-rc8-88-g3c8bb73 ("x86: PAT: store vm_pgoff for all linear_over_vma_region mappings - v3")
is_linear_pfn_mapping() checks can be removed from mm/huge_memory.c, because it already handled by VM_PFNMAP in VM_NO_THP bit-mask.
[[email protected]: Reset the VM_PAT flag as part of untrack_pfn_vma()]
--- arch/x86/mm/pat.c | 17 ++++++++++++----- include/asm-generic/pgtable.h | 6 ++++-- include/linux/mm.h | 20 +------------------- mm/huge_memory.c | 19 +++---------------- mm/memory.c | 26 ++++++++++---------------- 5 files changed, 30 insertions(+), 58 deletions(-)
arch/x86/mm/pat.c +12 -5
@@ -677,7 +677,7 @@ int track_pfn_copy(struct vm_area_struct *vma)unsigned long vma_size = vma->vm_end - vma->vm_start;pgprot_t pgprot; -if (is_linear_pfn_mapping (vma)) { +if (vma->vm_flags &VM_PAT ) {/* * reserve the whole chunk covered by vma. We need the * starting address and protection from pte.
@@ -699,14 +699,20 @@ int track_pfn_copy(struct vm_area_struct *vma)* single reserve_pfn_range call. */ int track_pfn_remap (struct vm_area_struct *vma,pgprot_t *prot, -unsigned long pfn,unsigned long size) +unsigned long pfn,unsigned long addr,unsigned long size) {resource_size_t paddr = (resource_size_t )pfn <<PAGE_SHIFT ;unsigned long flags;/* reserve the whole chunk starting from paddr */ -if (is_linear_pfn_mapping (vma)) -return reserve_pfn_range (paddr, size, prot,0 ); +if (addr == vma->vm_start && size == (vma->vm_end - vma->vm_start)) { +int ret; + + ret =reserve_pfn_range (paddr, size, prot,0 ); +if (!ret) + vma->vm_flags |=VM_PAT ; +return ret; + }if (!pat_enabled)return 0 ;
@@ -760,7 +766,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn,resource_size_t paddr;unsigned long prot; -if (!is_linear_pfn_mapping (vma)) +if (!(vma->vm_flags &VM_PAT ))return ;/* free the chunk starting from pfn or the whole chunk */
@@ -774,6 +780,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, size = vma->vm_end - vma->vm_start; }free_pfn_range (paddr, size); + vma->vm_flags &= ~VM_PAT ; }pgprot_t pgprot_writecombine (pgprot_t prot)
include/asm-generic/pgtable.h +4 -2
@@ -391,7 +391,8 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm,* by remap_pfn_range() for physical range indicated by pfn and size. */ static inline int track_pfn_remap (struct vm_area_struct *vma,pgprot_t *prot, -unsigned long pfn,unsigned long size) +unsigned long pfn,unsigned long addr, +unsigned long size) {return 0 ; }
@@ -426,7 +427,8 @@ static inline void untrack_pfn(struct vm_area_struct *vma, }#else extern int track_pfn_remap (struct vm_area_struct *vma,pgprot_t *prot, -unsigned long pfn,unsigned long size); +unsigned long pfn,unsigned long addr, +unsigned long size);extern int track_pfn_insert (struct vm_area_struct *vma,pgprot_t *prot,unsigned long pfn);extern int track_pfn_copy (struct vm_area_struct *vma);
include/linux/mm.h +1 -19
@@ -117,7 +117,7 @@ extern unsigned int kobjsize(const void *objp);#define VM_CAN_NONLINEAR 0x08000000/* Has ->fault & does nonlinear pages */ #define VM_MIXEDMAP 0x10000000/* Can contain "struct page" and pure PFN pages */ #define VM_SAO 0x20000000/* Strong Access Ordering (powerpc) */ -#define VM_PFN_AT_MMAP 0x40000000/* PFNMAP vma that is fully mapped at mmap time */ +#define VM_PAT 0x40000000/* PAT reserves whole VMA at once (x86) */ #define VM_MERGEABLE 0x80000000/* KSM may merge identical pages */ /* Bits set in the VMA until the stack is in its final location */
@@ -159,24 +159,6 @@ extern pgprot_t protection_map[16];#define FAULT_FLAG_KILLABLE 0x20/* The fault task is in SIGKILL killable region */ /* -* This interface is used by x86 PAT code to identify a pfn mapping that is -* linear over entire vma. This is to optimize PAT code that deals with -* marking the physical region with a particular prot. This is not for generic -* mm use. Note also that this check will not work if the pfn mapping is -* linear for a vma starting at physical address 0. In which case PAT code -* falls back to slow path of reserving physical range page by page. -*/ -static inline int is_linear_pfn_mapping (struct vm_area_struct *vma) -{ -return !!(vma->vm_flags &VM_PFN_AT_MMAP ); -} - -static inline int is_pfn_mapping (struct vm_area_struct *vma) -{ -return !!(vma->vm_flags &VM_PFNMAP ); -} - -/* * vm_fault is filled by the the pagefault handler and passed to the vma's * ->fault function. The vma's ->fault is responsible for returning a bitmask * of VM_FAULT_xxx flags that give details about how the fault was handled.
mm/huge_memory.c +3 -16
@@ -1655,11 +1655,7 @@ int khugepaged_enter_vma_merge(struct vm_area_struct *vma)if (vma->vm_ops)/* khugepaged not yet working on file or special mappings */ return 0 ; -/* -* If is_pfn_mapping() is true is_learn_pfn_mapping() must be -* true too, verify it here. -*/ -VM_BUG_ON (is_linear_pfn_mapping (vma) || vma->vm_flags &VM_NO_THP ); +VM_BUG_ON (vma->vm_flags &VM_NO_THP ); hstart = (vma->vm_start + ~HPAGE_PMD_MASK ) &HPAGE_PMD_MASK ; hend = vma->vm_end &HPAGE_PMD_MASK ;if (hstart < hend)
@@ -1913,11 +1909,7 @@ static void collapse_huge_page(struct mm_struct *mm, goto out;if (is_vma_temporary_stack (vma)) goto out; -/* -* If is_pfn_mapping() is true is_learn_pfn_mapping() must be -* true too, verify it here. -*/ -VM_BUG_ON (is_linear_pfn_mapping (vma) || vma->vm_flags &VM_NO_THP ); +VM_BUG_ON (vma->vm_flags &VM_NO_THP ); pgd =pgd_offset (mm, address);if (!pgd_present (*pgd))
@@ -2155,12 +2147,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, goto skip;if (is_vma_temporary_stack (vma)) goto skip; -/* -* If is_pfn_mapping() is true is_learn_pfn_mapping() -* must be true too, verify it here. -*/ -VM_BUG_ON (is_linear_pfn_mapping (vma) || - vma->vm_flags &VM_NO_THP ); +VM_BUG_ON (vma->vm_flags &VM_NO_THP ); hstart = (vma->vm_start + ~HPAGE_PMD_MASK ) &HPAGE_PMD_MASK ; hend = vma->vm_end &HPAGE_PMD_MASK ;
mm/memory.c +10 -16
@@ -1055,7 +1055,7 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,if (is_vm_hugetlb_page (vma))return copy_hugetlb_page_range (dst_mm, src_mm, vma); -if (unlikely (is_pfn_mapping (vma))) { +if (unlikely (vma->vm_flags &VM_PFNMAP )) {/* * We do not free on error cases below as remove_vma * gets called on error from higher level routine
@@ -1327,7 +1327,7 @@ static void unmap_single_vma(struct mmu_gather *tlb,if (vma->vm_file)uprobe_munmap (vma, start, end); -if (unlikely (is_pfn_mapping (vma))) +if (unlikely (vma->vm_flags &VM_PFNMAP ))untrack_pfn (vma,0 ,0 );if (start != end) {
@@ -2296,26 +2296,20 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,* There's a horrible special case to handle copy-on-write * behaviour that some programs depend on. We mark the "original" * un-COW'ed pages by matching them up with "vma->vm_pgoff". +* See vm_normal_page() for details. */ -if (addr == vma->vm_start && end == vma->vm_end) { +if (is_cow_mapping (vma->vm_flags)) { +if (addr != vma->vm_start || end != vma->vm_end) +return -EINVAL ; vma->vm_pgoff = pfn; - vma->vm_flags |=VM_PFN_AT_MMAP ; - }else if (is_cow_mapping (vma->vm_flags)) + } + + err =track_pfn_remap (vma, &prot, pfn, addr,PAGE_ALIGN (size)); +if (err)return -EINVAL ; vma->vm_flags |=VM_IO |VM_RESERVED |VM_PFNMAP ; - err =track_pfn_remap (vma, &prot, pfn,PAGE_ALIGN (size)); -if (err) { -/* -* To indicate that track_pfn related cleanup is not -* needed from higher level routine calling unmap_vmas -*/ - vma->vm_flags &= ~(VM_IO |VM_RESERVED |VM_PFNMAP ); - vma->vm_flags &= ~VM_PFN_AT_MMAP ; -return -EINVAL ; - } -BUG_ON (addr >= end); pfn -= addr >>PAGE_SHIFT ; pgd =pgd_offset (mm, addr);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 4/10 mm: introduce arch-specific vma flag VM_ARCH_1
In reply to Konstantin KhlebnikovThis patch combines several arch-specific vma flags into one.
before patch:
0x00000200 0x01000000 0x20000000 0x40000000 x86 VM_NOHUGEPAGE VM_HUGEPAGE - VM_PAT powerpc - - VM_SAO - parisc VM_GROWSUP - - - ia64 VM_GROWSUP - - - nommu - VM_MAPPED_COPY - - others - - - -
after patch:
0x00000200 0x01000000 0x20000000 0x40000000 x86 - VM_PAT VM_HUGEPAGE VM_NOHUGEPAGE powerpc - VM_SAO - - parisc - VM_GROWSUP - - ia64 - VM_GROWSUP - - nommu - VM_MAPPED_COPY - - others - VM_ARCH_1 - -
And voila! One completely free bit.
--- include/linux/mm.h | 34 +++++++++++++++++++++------------- mm/huge_memory.c | 2 +- mm/ksm.c | 7 ++++++- 3 files changed, 28 insertions(+), 15 deletions(-)
include/linux/mm.h +21 -13
@@ -70,6 +70,8 @@ extern unsigned int kobjsize(const void *objp);/* * vm_flags in vm_area_struct, see mm_types.h. */ +#define VM_NONE 0x00000000 +#define VM_READ 0x00000001/* currently active flags */ #define VM_WRITE 0x00000002#define VM_EXEC 0x00000004
@@ -82,12 +84,6 @@ extern unsigned int kobjsize(const void *objp);#define VM_MAYSHARE 0x00000080#define VM_GROWSDOWN 0x00000100/* general info on the segment */ -#if defined(CONFIG_STACK_GROWSUP ) || defined(CONFIG_IA64 ) -#define VM_GROWSUP 0x00000200 -#else -#define VM_GROWSUP 0x00000000 -#define VM_NOHUGEPAGE 0x00000200/* MADV_NOHUGEPAGE marked this vma */ -#endif #define VM_PFNMAP 0x00000400/* Page-ranges managed without "struct page", just pure PFN */ #define VM_DENYWRITE 0x00000800/* ETXTBSY on write attempts.. */
@@ -106,20 +102,32 @@ extern unsigned int kobjsize(const void *objp);#define VM_NORESERVE 0x00200000/* should the VM suppress accounting */ #define VM_HUGETLB 0x00400000/* Huge TLB Page VM */ #define VM_NONLINEAR 0x00800000/* Is non-linear (remap_file_pages) */ -#ifndef CONFIG_TRANSPARENT_HUGEPAGE -#define VM_MAPPED_COPY 0x01000000/* T if mapped copy of data (nommu mmap) */ -#else -#define VM_HUGEPAGE 0x01000000/* MADV_HUGEPAGE marked this vma */ -#endif +#define VM_ARCH_1 0x01000000/* Architecture-specific flag */ #define VM_INSERTPAGE 0x02000000/* The vma has had "vm_insert_page()" done on it */ #define VM_NODUMP 0x04000000/* Do not include in the core dump */ #define VM_CAN_NONLINEAR 0x08000000/* Has ->fault & does nonlinear pages */ #define VM_MIXEDMAP 0x10000000/* Can contain "struct page" and pure PFN pages */ -#define VM_SAO 0x20000000/* Strong Access Ordering (powerpc) */ -#define VM_PAT 0x40000000/* PAT reserves whole VMA at once (x86) */ +#define VM_HUGEPAGE 0x20000000/* MADV_HUGEPAGE marked this vma */ +#define VM_NOHUGEPAGE 0x40000000/* MADV_NOHUGEPAGE marked this vma */ #define VM_MERGEABLE 0x80000000/* KSM may merge identical pages */ +#if defined(CONFIG_X86 ) +# define VM_PAT VM_ARCH_1/* PAT reserves whole VMA at once (x86) */ +#elif defined(CONFIG_PPC ) +# define VM_SAO VM_ARCH_1/* Strong Access Ordering (powerpc) */ +#elif defined(CONFIG_PARISC ) +# define VM_GROWSUP VM_ARCH_1 +#elif defined(CONFIG_IA64 ) +# define VM_GROWSUP VM_ARCH_1 +#elif !defined(CONFIG_MMU ) +# define VM_MAPPED_COPY VM_ARCH_1/* T if mapped copy of data (nommu mmap) */ +#endif + +#ifndef VM_GROWSUP +# define VM_GROWSUP VM_NONE +#endif +/* Bits set in the VMA until the stack is in its final location */ #define VM_STACK_INCOMPLETE_SETUP (VM_RAND_READ | VM_SEQ_READ)
mm/huge_memory.c +1 -1
@@ -1491,7 +1491,7 @@ out:return ret; } -#define VM_NO_THP (VM_SPECIAL|VM_INSERTPAGE|VM_MIXEDMAP|VM_SAO| \ +#define VM_NO_THP (VM_SPECIAL|VM_INSERTPAGE|VM_MIXEDMAP| \ VM_HUGETLB|VM_SHARED|VM_MAYSHARE) int hugepage_madvise(struct vm_area_struct *vma,
mm/ksm.c +6 -1
@@ -1470,9 +1470,14 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start,if (*vm_flags & (VM_MERGEABLE |VM_SHARED |VM_MAYSHARE |VM_PFNMAP |VM_IO |VM_DONTEXPAND |VM_RESERVED |VM_HUGETLB |VM_INSERTPAGE | -VM_NONLINEAR |VM_MIXEDMAP |VM_SAO )) +VM_NONLINEAR |VM_MIXEDMAP ))return 0 ;/* just ignore the advice */ +#ifdef VM_SAO +if (*vm_flags &VM_SAO ) +return 0 ; +#endif +if (!test_bit (MMF_VM_MERGEABLE , &mm->flags)) { err =__ksm_enter (mm);if (err)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 5/10 mm: kill vma flag VM_INSERTPAGE
In reply to Konstantin KhlebnikovThis patch merges VM_INSERTPAGE into VM_MIXEDMAP. VM_MIXEDMAP VMA can mix pure-pfn ptes, special ptes and normal ptes.
Now copy_page_range() always copies VM_MIXEDMAP VMA on fork like VM_PFNMAP. If driver populates whole VMA at mmap() it probably not expects page-faults.
This patch removes special check from vma_wants_writenotify() which disables pages write tracking for VMA populated via vm_instert_page(). BDI below mapped file should not use dirty-accounting, moreover do_wp_page() can handle this.
vm_insert_page() still marks vma after first usage. Usually it is called from f_op->mmap() handler under mm->mmap_sem write-lock, so it able to change vma->vm_flags. Caller must set VM_MIXEDMAP at mmap time if it wants to call this function from other places, for example from page-fault handler.
--- include/linux/mm.h | 1 - mm/huge_memory.c | 3 +-- mm/ksm.c | 2 +- mm/memory.c | 14 ++++++++++++-- mm/mmap.c | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-)
include/linux/mm.h +0 -1
@@ -103,7 +103,6 @@ extern unsigned int kobjsize(const void *objp);#define VM_HUGETLB 0x00400000/* Huge TLB Page VM */ #define VM_NONLINEAR 0x00800000/* Is non-linear (remap_file_pages) */ #define VM_ARCH_1 0x01000000/* Architecture-specific flag */ -#define VM_INSERTPAGE 0x02000000/* The vma has had "vm_insert_page()" done on it */ #define VM_NODUMP 0x04000000/* Do not include in the core dump */ #define VM_CAN_NONLINEAR 0x08000000/* Has ->fault & does nonlinear pages */
mm/huge_memory.c +1 -2
@@ -1491,8 +1491,7 @@ out:return ret; } -#define VM_NO_THP (VM_SPECIAL|VM_INSERTPAGE|VM_MIXEDMAP| \ - VM_HUGETLB|VM_SHARED|VM_MAYSHARE) +#define VM_NO_THP (VM_SPECIAL|VM_MIXEDMAP|VM_HUGETLB|VM_SHARED|VM_MAYSHARE)int hugepage_madvise (struct vm_area_struct *vma,unsigned long *vm_flags,int advice)
mm/ksm.c +1 -1
@@ -1469,7 +1469,7 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start,*/ if (*vm_flags & (VM_MERGEABLE |VM_SHARED |VM_MAYSHARE |VM_PFNMAP |VM_IO |VM_DONTEXPAND | -VM_RESERVED |VM_HUGETLB |VM_INSERTPAGE | +VM_RESERVED |VM_HUGETLB |VM_NONLINEAR |VM_MIXEDMAP ))return 0 ;/* just ignore the advice */
mm/memory.c +12 -2
@@ -1047,7 +1047,8 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,* readonly mappings. The tradeoff is that copy_page_range is more * efficient than faulting. */ -if (!(vma->vm_flags & (VM_HUGETLB |VM_NONLINEAR |VM_PFNMAP |VM_INSERTPAGE ))) { +if (!(vma->vm_flags & (VM_HUGETLB |VM_NONLINEAR | +VM_PFNMAP |VM_MIXEDMAP ))) {if (!vma->anon_vma)return 0 ; }
@@ -2082,6 +2083,11 @@ out:* ask for a shared writable mapping! * * The page does not need to be reserved. +* +* Usually this function is called from f_op->mmap() handler +* under mm->mmap_sem write-lock, so it can change vma->vm_flags. +* Caller must set VM_MIXEDMAP on vma if it wants to call this +* function from other places, for example from page-fault handler. */ int vm_insert_page (struct vm_area_struct *vma,unsigned long addr,struct page *page)
@@ -2090,7 +2096,11 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,return -EFAULT ;if (!page_count (page))return -EINVAL ; - vma->vm_flags |=VM_INSERTPAGE ; +if (!(vma->vm_flags &VM_MIXEDMAP )) { +BUG_ON (down_read_trylock (&vma->vm_mm->mmap_sem)); +BUG_ON (vma->vm_flags &VM_PFNMAP ); + vma->vm_flags |=VM_MIXEDMAP ; + }return insert_page (vma, addr, page, vma->vm_page_prot); }EXPORT_SYMBOL (vm_insert_page);
mm/mmap.c +1 -1
@@ -1188,7 +1188,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)return 0 ;/* Specialty mapping? */ -if (vm_flags & (VM_PFNMAP |VM_INSERTPAGE )) +if (vm_flags &VM_PFNMAP )return 0 ;/* Can the mapping track the dirty pages? */
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 6/10 mm: kill vma flag VM_CAN_NONLINEAR
In reply to Konstantin KhlebnikovThis patch moves actual ptes filling for non-linear file mappings into special vma operation: ->remap_pages().
File system must implement this method to get non-linear mappings support, if it uses filemap_fault() then generic_file_remap_pages() can be used.
Now device drivers can implement this method and obtain nonlinear vma support.
--- drivers/staging/android/ashmem.c | 1 - fs/9p/vfs_file.c | 1 + fs/btrfs/file.c | 2 +- fs/ceph/addr.c | 2 +- fs/cifs/file.c | 1 + fs/ext4/file.c | 2 +- fs/fuse/file.c | 1 + fs/gfs2/file.c | 2 +- fs/nfs/file.c | 1 + fs/nilfs2/file.c | 2 +- fs/ocfs2/mmap.c | 2 +- fs/ubifs/file.c | 1 + fs/xfs/xfs_file.c | 2 +- include/linux/fs.h | 2 ++ include/linux/mm.h | 7 ++++--- mm/filemap.c | 2 +- mm/filemap_xip.c | 3 ++- mm/fremap.c | 14 ++++++++------ mm/mmap.c | 3 +-- mm/nommu.c | 8 ++++++++ mm/shmem.c | 3 +-- 21 files changed, 39 insertions(+), 23 deletions(-)
drivers/staging/android/ashmem.c +0 -1
@@ -332,7 +332,6 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)if (vma->vm_file)fput (vma->vm_file); vma->vm_file = asma->file; - vma->vm_flags |=VM_CAN_NONLINEAR ; out:mutex_unlock (&ashmem_mutex);
fs/9p/vfs_file.c +1 -0
@@ -735,6 +735,7 @@ v9fs_cached_file_write(struct file *filp, const char __user * data,static const struct vm_operations_struct v9fs_file_vm_ops = { .fault = filemap_fault, .page_mkwrite = v9fs_vm_page_mkwrite, + .remap_pages = generic_file_remap_pages, };
fs/btrfs/file.c +1 -1
@@ -1598,6 +1598,7 @@ out:static const struct vm_operations_struct btrfs_file_vm_ops = { .fault = filemap_fault, .page_mkwrite = btrfs_page_mkwrite, + .remap_pages = generic_file_remap_pages, };static int btrfs_file_mmap (struct file *filp,struct vm_area_struct *vma)
@@ -1609,7 +1610,6 @@ static int btrfs_file_mmap(struct file *filp, struct vm_area_struct *vma)file_accessed (filp); vma->vm_ops = &btrfs_file_vm_ops; - vma->vm_flags |=VM_CAN_NONLINEAR ;return 0 ; }
fs/ceph/addr.c +1 -1
@@ -1222,6 +1222,7 @@ out:static struct vm_operations_struct ceph_vmops = { .fault = filemap_fault, .page_mkwrite = ceph_page_mkwrite, + .remap_pages = generic_file_remap_pages, };int ceph_mmap (struct file *file,struct vm_area_struct *vma)
@@ -1232,6 +1233,5 @@ int ceph_mmap(struct file *file, struct vm_area_struct *vma)return -ENOEXEC ;file_accessed (file); vma->vm_ops = &ceph_vmops; - vma->vm_flags |=VM_CAN_NONLINEAR ;return 0 ; }
fs/cifs/file.c +1 -0
@@ -2842,6 +2842,7 @@ cifs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)static struct vm_operations_struct cifs_file_vm_ops = { .fault = filemap_fault, .page_mkwrite = cifs_page_mkwrite, + .remap_pages = generic_file_remap_pages, };int cifs_file_strict_mmap (struct file *file,struct vm_area_struct *vma)
fs/ext4/file.c +1 -1
@@ -207,6 +207,7 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov,static const struct vm_operations_struct ext4_file_vm_ops = { .fault = filemap_fault, .page_mkwrite = ext4_page_mkwrite, + .remap_pages = generic_file_remap_pages, };static int ext4_file_mmap (struct file *file,struct vm_area_struct *vma)
@@ -217,7 +218,6 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)return -ENOEXEC ;file_accessed (file); vma->vm_ops = &ext4_file_vm_ops; - vma->vm_flags |=VM_CAN_NONLINEAR ;return 0 ; }
fs/fuse/file.c +1 -0
@@ -1376,6 +1376,7 @@ static const struct vm_operations_struct fuse_file_vm_ops = { .close = fuse_vma_close, .fault = filemap_fault, .page_mkwrite = fuse_page_mkwrite, + .remap_pages = generic_file_remap_pages, };static int fuse_file_mmap (struct file *file,struct vm_area_struct *vma)
fs/gfs2/file.c +1 -1
@@ -476,6 +476,7 @@ out:static const struct vm_operations_struct gfs2_vm_ops = { .fault = filemap_fault, .page_mkwrite = gfs2_page_mkwrite, + .remap_pages = generic_file_remap_pages, };/**
@@ -510,7 +511,6 @@ static int gfs2_mmap(struct file *file, struct vm_area_struct *vma)return error; } vma->vm_ops = &gfs2_vm_ops; - vma->vm_flags |=VM_CAN_NONLINEAR ;return 0 ; }
fs/nfs/file.c +1 -0
@@ -546,6 +546,7 @@ out:static const struct vm_operations_struct nfs_file_vm_ops = { .fault = filemap_fault, .page_mkwrite = nfs_vm_page_mkwrite, + .remap_pages = generic_file_remap_pages, };static int nfs_need_sync_write (struct file *filp,struct inode *inode)
fs/nilfs2/file.c +1 -1
@@ -130,13 +130,13 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)static const struct vm_operations_struct nilfs_file_vm_ops = { .fault = filemap_fault, .page_mkwrite = nilfs_page_mkwrite, + .remap_pages = generic_file_remap_pages, };static int nilfs_file_mmap (struct file *file,struct vm_area_struct *vma) {file_accessed (file); vma->vm_ops = &nilfs_file_vm_ops; - vma->vm_flags |=VM_CAN_NONLINEAR ;return 0 ; }
fs/ocfs2/mmap.c +1 -1
@@ -171,6 +171,7 @@ out:static const struct vm_operations_struct ocfs2_file_vm_ops = { .fault = ocfs2_fault, .page_mkwrite = ocfs2_page_mkwrite, + .remap_pages = generic_file_remap_pages, };int ocfs2_mmap (struct file *file,struct vm_area_struct *vma)
@@ -186,7 +187,6 @@ int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)ocfs2_inode_unlock (file->f_dentry->d_inode, lock_level); out: vma->vm_ops = &ocfs2_file_vm_ops; - vma->vm_flags |=VM_CAN_NONLINEAR ;return 0 ; }
fs/ubifs/file.c +1 -0
@@ -1536,6 +1536,7 @@ out_unlock:static const struct vm_operations_struct ubifs_file_vm_ops = { .fault = filemap_fault, .page_mkwrite = ubifs_vm_page_mkwrite, + .remap_pages = generic_file_remap_pages, };static int ubifs_file_mmap (struct file *file,struct vm_area_struct *vma)
fs/xfs/xfs_file.c +1 -1
@@ -935,7 +935,6 @@ xfs_file_mmap( struct vm_area_struct *vma) { vma->vm_ops = &xfs_file_vm_ops; - vma->vm_flags |=VM_CAN_NONLINEAR ;file_accessed (filp);return 0 ;
@@ -1130,4 +1129,5 @@ const struct file_operations xfs_dir_file_operations = {static const struct vm_operations_struct xfs_file_vm_ops = { .fault = filemap_fault, .page_mkwrite = xfs_vm_page_mkwrite, + .remap_pages = generic_file_remap_pages, };
include/linux/fs.h +2 -0
@@ -2413,6 +2413,8 @@ extern int sb_min_blocksize(struct super_block *, int);extern int generic_file_mmap (struct file *,struct vm_area_struct *);extern int generic_file_readonly_mmap (struct file *,struct vm_area_struct *); +extern int generic_file_remap_pages (struct vm_area_struct *,unsigned long addr, +unsigned long size,pgoff_t pgoff);extern int file_read_actor (read_descriptor_t * desc,struct page *page,unsigned long offset,unsigned long size);int generic_write_checks (struct file *file,loff_t *pos,size_t *count,int isblk);extern ssize_t generic_file_aio_read (struct kiocb *,const struct iovec *,unsigned long ,loff_t );
include/linux/mm.h +4 -3
@@ -105,7 +105,6 @@ extern unsigned int kobjsize(const void *objp);#define VM_ARCH_1 0x01000000/* Architecture-specific flag */ #define VM_NODUMP 0x04000000/* Do not include in the core dump */ -#define VM_CAN_NONLINEAR 0x08000000/* Has ->fault & does nonlinear pages */ #define VM_MIXEDMAP 0x10000000/* Can contain "struct page" and pure PFN pages */ #define VM_HUGEPAGE 0x20000000/* MADV_HUGEPAGE marked this vma */ #define VM_NOHUGEPAGE 0x40000000/* MADV_NOHUGEPAGE marked this vma */
@@ -171,8 +170,7 @@ extern pgprot_t protection_map[16];* of VM_FAULT_xxx flags that give details about how the fault was handled. * * pgoff should be used in favour of virtual_address, if possible. If pgoff -* is used, one may set VM_CAN_NONLINEAR in the vma->vm_flags to get nonlinear -* mapping support. +* is used, one may implement ->remap_pages to get nonlinear mapping support. */ struct vm_fault {unsigned int flags;/* FAULT_FLAG_xxx flags */
@@ -230,6 +228,9 @@ struct vm_operations_struct {int (*migrate)(struct vm_area_struct *vma,const nodemask_t *from,const nodemask_t *to,unsigned long flags);#endif +/* called by sys_remap_file_pages() to populate non-linear mapping */ +int (*remap_pages)(struct vm_area_struct *vma,unsigned long addr, +unsigned long size,pgoff_t pgoff); };struct mmu_gather ;
mm/filemap.c +1 -1
@@ -1714,6 +1714,7 @@ EXPORT_SYMBOL(filemap_fault);const struct vm_operations_struct generic_file_vm_ops = { .fault = filemap_fault, + .remap_pages = generic_file_remap_pages, };/* This is used for a general mmap of a disk file */
@@ -1726,7 +1727,6 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)return -ENOEXEC ;file_accessed (file); vma->vm_ops = &generic_file_vm_ops; - vma->vm_flags |=VM_CAN_NONLINEAR ;return 0 ; }
mm/filemap_xip.c +2 -1
@@ -304,6 +304,7 @@ out:static const struct vm_operations_struct xip_file_vm_ops = { .fault = xip_file_fault, + .remap_pages = generic_file_remap_pages, };int xip_file_mmap (struct file * file,struct vm_area_struct * vma)
@@ -312,7 +313,7 @@ int xip_file_mmap(struct file * file, struct vm_area_struct * vma)file_accessed (file); vma->vm_ops = &xip_file_vm_ops; - vma->vm_flags |=VM_CAN_NONLINEAR |VM_MIXEDMAP ; + vma->vm_flags |=VM_MIXEDMAP ;return 0 ; }EXPORT_SYMBOL_GPL (xip_file_mmap);
mm/fremap.c +8 -6
@@ -5,6 +5,7 @@* * started by Ingo Molnar, Copyright (C) 2002, 2003 */ +#include <linux/export.h> #include <linux/backing-dev.h> #include <linux/mm.h> #include <linux/swap.h>
@@ -80,9 +81,10 @@ out:return err; } -static int populate_range (struct mm_struct *mm,struct vm_area_struct *vma, -unsigned long addr,unsigned long size,pgoff_t pgoff) +int generic_file_remap_pages (struct vm_area_struct *vma,unsigned long addr, +unsigned long size,pgoff_t pgoff) { +struct mm_struct *mm = vma->vm_mm;int err; do {
@@ -95,9 +97,9 @@ static int populate_range(struct mm_struct *mm, struct vm_area_struct *vma, pgoff++; }while (size); -return 0 ; - +return 0 ; } +EXPORT_SYMBOL (generic_file_remap_pages);/** * sys_remap_file_pages - remap arbitrary pages of an existing VM_SHARED vma
@@ -167,7 +169,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,if (vma->vm_private_data && !(vma->vm_flags &VM_NONLINEAR )) goto out; -if (!(vma->vm_flags &VM_CAN_NONLINEAR )) +if (!vma->vm_ops->remap_pages) goto out;if (start < vma->vm_start || start + size > vma->vm_end)
@@ -229,7 +231,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, }mmu_notifier_invalidate_range_start (mm, start, start + size); - err =populate_range (mm, vma, start, size, pgoff); + err = vma->vm_ops->remap_pages (vma, start, size, pgoff);mmu_notifier_invalidate_range_end (mm, start, start + size);if (!err && !(flags &MAP_NONBLOCK )) {if (vma->vm_flags &VM_LOCKED ) {
mm/mmap.c +1 -2
@@ -669,8 +669,7 @@ again: remove_next = 1 + (end > next->vm_end);static inline int is_mergeable_vma (struct vm_area_struct *vma,struct file *file,unsigned long vm_flags) { -/* VM_CAN_NONLINEAR may get set later by f_op->mmap() */ -if ((vma->vm_flags ^ vm_flags) & ~VM_CAN_NONLINEAR ) +if (vma->vm_flags ^ vm_flags)return 0 ;if (vma->vm_file != file)return 0 ;
mm/nommu.c +8 -0
@@ -1963,6 +1963,14 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) }EXPORT_SYMBOL (filemap_fault); +int generic_file_remap_pages (struct vm_area_struct *vma,unsigned long addr, +unsigned long size,pgoff_t pgoff) +{ +BUG (); +return 0 ; +} +EXPORT_SYMBOL (generic_file_remap_pages); +static int __access_remote_vm (struct task_struct *tsk,struct mm_struct *mm,unsigned long addr,void *buf,int len,int write) {
mm/shmem.c +1 -2
@@ -1348,7 +1348,6 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma) {file_accessed (file); vma->vm_ops = &shmem_vm_ops; - vma->vm_flags |=VM_CAN_NONLINEAR ;return 0 ; }
@@ -2786,6 +2785,7 @@ static const struct vm_operations_struct shmem_vm_ops = { .set_policy = shmem_set_policy, .get_policy = shmem_get_policy, #endif + .remap_pages = generic_file_remap_pages, }; static struct dentry *shmem_mount(struct file_system_type *fs_type,
@@ -2979,7 +2979,6 @@ int shmem_zero_setup(struct vm_area_struct *vma)fput (vma->vm_file); vma->vm_file = file; vma->vm_ops = &shmem_vm_ops; - vma->vm_flags |=VM_CAN_NONLINEAR ;return 0 ; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 7/10 mm: use mm->exe_file instead of first VM_EXECUTABLE vma->vm_file
In reply to Konstantin KhlebnikovSome security modules and oprofile still uses VM_EXECUTABLE for retrieving task's executable file, after this patch they will use mm->exe_file directly. mm->exe_file protected with mm->mmap_sem, so locking stays the same.
--- arch/powerpc/oprofile/cell/spu_task_sync.c | 15 ++++----------- arch/tile/mm/elf.c | 19 +++++++------------ drivers/oprofile/buffer_sync.c | 17 +++-------------- kernel/auditsc.c | 13 ++----------- kernel/fork.c | 3 +-- security/tomoyo/util.c | 9 ++------- 6 files changed, 19 insertions(+), 57 deletions(-)
arch/powerpc/oprofile/cell/spu_task_sync.c +4 -11
@@ -304,7 +304,7 @@ static inline unsigned long fast_get_dcookie(struct path *path)return cookie; } -/* Look up the dcookie for the task's first VM_EXECUTABLE mapping, +/* Look up the dcookie for the task's mm->exe_file, * which corresponds loosely to "application name". Also, determine * the offset for the SPU ELF object. If computed offset is * non-zero, it implies an embedded SPU object; otherwise, it's a
@@ -321,7 +321,6 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp, {unsigned long app_cookie =0 ;unsigned int my_offset =0 ; -struct file *app =NULL ;struct vm_area_struct *vma;struct mm_struct *mm = spu->mm;
@@ -330,16 +329,10 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,down_read (&mm->mmap_sem); -for (vma = mm->mmap; vma; vma = vma->vm_next) { -if (!vma->vm_file) -continue ; -if (!(vma->vm_flags &VM_EXECUTABLE )) -continue ; - app_cookie =fast_get_dcookie (&vma->vm_file->f_path); +if (mm->exe_file) { + app_cookie =fast_get_dcookie (&mm->exe_file->f_path);pr_debug ("got dcookie for %s\n" , - vma->vm_file->f_dentry->d_name.name); - app = vma->vm_file; -break ; + mm->exe_file->f_dentry->d_name.name); }for (vma = mm->mmap; vma; vma = vma->vm_next) {
arch/tile/mm/elf.c +7 -12
@@ -36,19 +36,14 @@ static void sim_notify_exec(const char *binary_name) }while (c); } -static int notify_exec (void ) +static int notify_exec (struct mm_struct *mm) {int retval =0 ;/* failure */ -struct vm_area_struct *vma = current->mm->mmap; -while (vma) { -if ((vma->vm_flags &VM_EXECUTABLE ) && vma->vm_file) -break ; - vma = vma->vm_next; - } -if (vma) { + +if (mm->exe_file) {char *buf = (char *)__get_free_page (GFP_KERNEL );if (buf) { -char *path =d_path (&vma->vm_file->f_path, +char *path =d_path (&mm->exe_file->f_path, buf,PAGE_SIZE );if (!IS_ERR (path)) {sim_notify_exec (path);
@@ -106,16 +101,16 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,unsigned long vdso_base;int retval =0 ; +down_write (&mm->mmap_sem); +/* * Notify the simulator that an exec just occurred. * If we can't find the filename of the mapping, just use * whatever was passed as the linux_binprm filename. */ -if (!notify_exec ()) +if (!notify_exec (mm))sim_notify_exec (bprm->filename); -down_write (&mm->mmap_sem); -/* * MAYWRITE to allow gdb to COW and set breakpoints */
drivers/oprofile/buffer_sync.c +3 -14
@@ -216,7 +216,7 @@ static inline unsigned long fast_get_dcookie(struct path *path) } -/* Look up the dcookie for the task's first VM_EXECUTABLE mapping, +/* Look up the dcookie for the task's mm->exe_file, * which corresponds loosely to "application name". This is * not strictly necessary but allows oprofile to associate * shared-library samples with particular applications
@@ -224,21 +224,10 @@ static inline unsigned long fast_get_dcookie(struct path *path)static unsigned long get_exec_dcookie (struct mm_struct *mm) {unsigned long cookie =NO_COOKIE ; -struct vm_area_struct *vma; - -if (!mm) - goto out; -for (vma = mm->mmap; vma; vma = vma->vm_next) { -if (!vma->vm_file) -continue ; -if (!(vma->vm_flags &VM_EXECUTABLE )) -continue ; - cookie =fast_get_dcookie (&vma->vm_file->f_path); -break ; - } +if (mm && mm->exe_file) + cookie =fast_get_dcookie (&mm->exe_file->f_path); -out:return cookie; }
kernel/auditsc.c +2 -11
@@ -1158,7 +1158,6 @@ static void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk {char name[sizeof (tsk->comm)];struct mm_struct *mm = tsk->mm; -struct vm_area_struct *vma;/* tsk == current */
@@ -1168,16 +1167,8 @@ static void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tskif (mm) {down_read (&mm->mmap_sem); - vma = mm->mmap; -while (vma) { -if ((vma->vm_flags &VM_EXECUTABLE ) && - vma->vm_file) { -audit_log_d_path (ab," exe=" , - &vma->vm_file->f_path); -break ; - } - vma = vma->vm_next; - } +if (mm->exe_file) +audit_log_d_path (ab," exe=" , &mm->exe_file->f_path);up_read (&mm->mmap_sem); }audit_log_task_context (ab);
kernel/fork.c +1 -2
@@ -659,8 +659,7 @@ struct file *get_mm_exe_file(struct mm_struct *mm) {struct file *exe_file; -/* We need mmap_sem to protect against races with removal of -* VM_EXECUTABLE vmas */ +/* We need mmap_sem to protect against races with removal of exe_file */ down_read (&mm->mmap_sem); exe_file = mm->exe_file;if (exe_file)
security/tomoyo/util.c +2 -7
@@ -949,18 +949,13 @@ bool tomoyo_path_matches_pattern(const struct tomoyo_path_info *filename,const char *tomoyo_get_exe (void ) {struct mm_struct *mm = current->mm; -struct vm_area_struct *vma;const char *cp =NULL ;if (!mm)return NULL ;down_read (&mm->mmap_sem); -for (vma = mm->mmap; vma; vma = vma->vm_next) { -if ((vma->vm_flags &VM_EXECUTABLE ) && vma->vm_file) { - cp =tomoyo_realpath_from_path (&vma->vm_file->f_path); -break ; - } - } +if (mm->exe_file) + cp =tomoyo_realpath_from_path (&mm->exe_file->f_path);up_read (&mm->mmap_sem);return cp; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 8/10 mm: kill vma flag VM_EXECUTABLE and mm->num_exe_file_vmas
In reply to Konstantin KhlebnikovCurrently the kernel sets mm->exe_file during sys_execve() and then tracks number of vmas with VM_EXECUTABLE flag in mm->num_exe_file_vmas, as soon as this counter drops to zero kernel resets mm->exe_file to NULL. Plus it resets mm->exe_file at last mmput() when mm->mm_users drops to zero.
VMA with VM_EXECUTABLE flag appears after mapping file with flag MAP_EXECUTABLE, such vmas can appears only at sys_execve() or after vma splitting, because sys_mmap ignores this flag. Usually binfmt module sets mm->exe_file and mmaps executable vmas with this file, they hold mm->exe_file while task is running.
comment from v2.6.25-6245-g925d1c4 ("procfs task exe symlink"), where all this stuff was introduced:
Quoted 9 lines
The kernel implements readlink of
/proc/pid/exeby getting the file from the first executable VMA. Then the path to the file is reconstructed and reported as the result.Because of the VMA walk the code is slightly different on nommu systems. This patch avoids separate
/proc/pid/execode on nommu systems. Instead of walking the VMAs to find the first executable file-backed VMA we store a reference to the exec'd file in themm_struct.
Quoted 4 lines
That reference would prevent the filesystem holding the executable file from being unmounted even after unmapping the VMAs. So we track the number of
VM_EXECUTABLEVMAs and drop the new reference when the last one is unmapped. This avoids pinning the mounted filesystem.
exe_file's vma accouning is hooked into every file mmap/unmmap and vma split/merge just to fix some hypothetical pinning fs from umounting by mm, which already unmapped all its executable files, but still alive.
Seems like currently nobody depends on this behaviour.
We can try to remove this logic and keep mm->exe_file until final mmput().
mm->exe_file is still protected with mm->mmap_sem, because we want to change it via new sys_prctl(PR_SET_MM_EXE_FILE). Also via this syscall task can change its mm->exe_file and unpin mountpoint explicitly.
--- include/linux/mm.h | 4 ---- include/linux/mm_types.h | 1 - include/linux/mman.h | 1 - kernel/fork.c | 21 --------------------- mm/mmap.c | 22 +++------------------- mm/nommu.c | 11 +---------- 6 files changed, 4 insertions(+), 56 deletions(-)
include/linux/mm.h +0 -4
@@ -87,7 +87,6 @@ extern unsigned int kobjsize(const void *objp);#define VM_PFNMAP 0x00000400/* Page-ranges managed without "struct page", just pure PFN */ #define VM_DENYWRITE 0x00000800/* ETXTBSY on write attempts.. */ -#define VM_EXECUTABLE 0x00001000#define VM_LOCKED 0x00002000#define VM_IO 0x00004000/* Memory mapped I/O or similar */
@@ -1366,9 +1365,6 @@ extern void exit_mmap(struct mm_struct *);extern int mm_take_all_locks (struct mm_struct *mm);extern void mm_drop_all_locks (struct mm_struct *mm); -/* From fs/proc/base.c. callers must _not_ hold the mm's exe_file_lock */ -extern void added_exe_file_vma (struct mm_struct *mm); -extern void removed_exe_file_vma (struct mm_struct *mm);extern void set_mm_exe_file (struct mm_struct *mm,struct file *new_exe_file);extern struct file *get_mm_exe_file (struct mm_struct *mm);
include/linux/mm_types.h +0 -1
@@ -385,7 +385,6 @@ struct mm_struct {/* store ref to file /proc/<pid>/exe symlink points to */ struct file *exe_file; -unsigned long num_exe_file_vmas;#ifdef CONFIG_MMU_NOTIFIER struct mmu_notifier_mm *mmu_notifier_mm;#endif
include/linux/mman.h +0 -1
@@ -86,7 +86,6 @@ calc_vm_flag_bits(unsigned long flags) {return _calc_vm_trans (flags,MAP_GROWSDOWN ,VM_GROWSDOWN ) |_calc_vm_trans (flags,MAP_DENYWRITE ,VM_DENYWRITE ) | -_calc_vm_trans (flags,MAP_EXECUTABLE ,VM_EXECUTABLE ) |_calc_vm_trans (flags,MAP_LOCKED ,VM_LOCKED ); }#endif /* __KERNEL__ */
kernel/fork.c +0 -21
@@ -625,26 +625,6 @@ void mmput(struct mm_struct *mm) }EXPORT_SYMBOL_GPL (mmput); -/* -* We added or removed a vma mapping the executable. The vmas are only mapped -* during exec and are not mapped with the mmap system call. -* Callers must hold down_write() on the mm's mmap_sem for these -*/ -void added_exe_file_vma (struct mm_struct *mm) -{ - mm->num_exe_file_vmas++; -} - -void removed_exe_file_vma (struct mm_struct *mm) -{ - mm->num_exe_file_vmas--; -if ((mm->num_exe_file_vmas ==0 ) && mm->exe_file) { -fput (mm->exe_file); - mm->exe_file =NULL ; - } - -} -void set_mm_exe_file (struct mm_struct *mm,struct file *new_exe_file) {if (new_exe_file)
@@ -652,7 +632,6 @@ void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file)if (mm->exe_file)fput (mm->exe_file); mm->exe_file = new_exe_file; - mm->num_exe_file_vmas =0 ; }struct file *get_mm_exe_file (struct mm_struct *mm)
mm/mmap.c +3 -19
@@ -231,11 +231,8 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)might_sleep ();if (vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close (vma); -if (vma->vm_file) { +if (vma->vm_file)fput (vma->vm_file); -if (vma->vm_flags &VM_EXECUTABLE ) -removed_exe_file_vma (vma->vm_mm); - }mpol_put (vma_policy (vma));kmem_cache_free (vm_area_cachep, vma);return next;
@@ -636,8 +633,6 @@ again: remove_next = 1 + (end > next->vm_end);if (file) {uprobe_munmap (next, next->vm_start, next->vm_end);fput (file); -if (next->vm_flags &VM_EXECUTABLE ) -removed_exe_file_vma (mm); }if (next->anon_vma)anon_vma_merge (vma, next);
@@ -1303,8 +1298,6 @@ munmap_back: error = file->f_op->mmap (file, vma);if (error) goto unmap_and_free_vma; -if (vm_flags &VM_EXECUTABLE ) -added_exe_file_vma (mm);/* Can addr have changed?? *
@@ -1990,11 +1983,8 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,if (anon_vma_clone (new, vma)) goto out_free_mpol; -if (new->vm_file) { +if (new->vm_file)get_file (new->vm_file); -if (vma->vm_flags &VM_EXECUTABLE ) -added_exe_file_vma (mm); - }if (new->vm_ops && new->vm_ops->open) new->vm_ops->open (new);
@@ -2012,11 +2002,8 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,/* Clean everything up if vma_adjust failed. */ if (new->vm_ops && new->vm_ops->close) new->vm_ops->close (new); -if (new->vm_file) { -if (vma->vm_flags &VM_EXECUTABLE ) -removed_exe_file_vma (mm); +if (new->vm_file)fput (new->vm_file); - }unlink_anon_vmas (new); out_free_mpol:mpol_put (pol);
@@ -2419,9 +2406,6 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,if (uprobe_mmap (new_vma)) goto out_free_mempol; - -if (vma->vm_flags &VM_EXECUTABLE ) -added_exe_file_vma (mm); }if (new_vma->vm_ops && new_vma->vm_ops->open) new_vma->vm_ops->open (new_vma);
mm/nommu.c +1 -10
@@ -789,11 +789,8 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)kenter ("%p" , vma);if (vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close (vma); -if (vma->vm_file) { +if (vma->vm_file)fput (vma->vm_file); -if (vma->vm_flags &VM_EXECUTABLE ) -removed_exe_file_vma (mm); - }put_nommu_region (vma->vm_region);kmem_cache_free (vm_area_cachep, vma); }
@@ -1286,10 +1283,6 @@ unsigned long do_mmap_pgoff(struct file *file,get_file (file); vma->vm_file = file;get_file (file); -if (vm_flags &VM_EXECUTABLE ) { -added_exe_file_vma (current->mm); - vma->vm_mm = current->mm; - } }down_write (&nommu_region_sem);
@@ -1442,8 +1435,6 @@ error:kmem_cache_free (vm_region_jar, region);if (vma->vm_file)fput (vma->vm_file); -if (vma->vm_flags &VM_EXECUTABLE ) -removed_exe_file_vma (vma->vm_mm);kmem_cache_free (vm_area_cachep, vma);kleave (" = %d" , ret);return ret;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 9/10 mm: prepare VM_DONTDUMP for using in drivers
In reply to Konstantin KhlebnikovThis patch renames VM_NODUMP into VM_DONTDUMP: this name matches to other negative flags: VM_DONTEXPAND, VM_DONTCOPY. Currently this flag used only for sys_madvise next patch will use it for replacing outdated flag VM_RESERVED.
Also this patch forbids madvise(MADV_DODUMP) for special kernel mappings VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_RESERVED | VM_PFNMAP)
--- fs/binfmt_elf.c | 2 +- include/linux/mm.h | 2 +- mm/madvise.c | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-)
fs/binfmt_elf.c +1 -1
@@ -1115,7 +1115,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,if (always_dump_vma (vma)) goto whole; -if (vma->vm_flags &VM_NODUMP ) +if (vma->vm_flags &VM_DONTDUMP )return 0 ;/* Hugetlb memory check */
include/linux/mm.h +1 -1
@@ -102,7 +102,7 @@ extern unsigned int kobjsize(const void *objp);#define VM_HUGETLB 0x00400000/* Huge TLB Page VM */ #define VM_NONLINEAR 0x00800000/* Is non-linear (remap_file_pages) */ #define VM_ARCH_1 0x01000000/* Architecture-specific flag */ -#define VM_NODUMP 0x04000000/* Do not include in the core dump */ +#define VM_DONTDUMP 0x04000000/* Do not include in the core dump */ #define VM_MIXEDMAP 0x10000000/* Can contain "struct page" and pure PFN pages */ #define VM_HUGEPAGE 0x20000000/* MADV_HUGEPAGE marked this vma */
mm/madvise.c +6 -2
@@ -69,10 +69,14 @@ static long madvise_behavior(struct vm_area_struct * vma, new_flags &= ~VM_DONTCOPY ;break ;case MADV_DONTDUMP : - new_flags |=VM_NODUMP ; + new_flags |=VM_DONTDUMP ;break ;case MADV_DODUMP : - new_flags &= ~VM_NODUMP ; +if (new_flags &VM_SPECIAL ) { + error = -EINVAL ; + goto out; + } + new_flags &= ~VM_DONTDUMP ;break ;case MADV_MERGEABLE :case MADV_UNMERGEABLE :
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 10/10 mm: kill vma flag VM_RESERVED and mm->reserved_vm counter
In reply to Konstantin KhlebnikovA long time ago, in v2.4, VM_RESERVED kept swapout process off VMA, currently it lost original meaning but still has some effects:
| effect | alternative flags
-+------------------------+---------------------------------------------
1| account as reserved_vm | VM_IO 2| skip in core dump | VM_IO, VM_DONTDUMP 3| do not merge or expand | VM_IO, VM_DONTEXPAND, VM_HUGETLB, VM_PFNMAP 4| do not mlock | VM_IO, VM_DONTEXPAND, VM_HUGETLB, VM_PFNMAP
This patch removes reserved_vm counter from mm_struct.
Seems like nobody cares about it, it does not exported into userspace directly, it only reduces total_vm showed in proc.
Thus VM_RESERVED can be replaced with VM_IO or pair VM_DONTEXPAND | VM_DONTDUMP.
remap_pfn_range() and io_remap_pfn_range() set VM_IO|VM_DONTEXPAND|VM_DONTDUMP. remap_vmalloc_range() set VM_DONTEXPAND | VM_DONTDUMP.
--- Documentation/vm/unevictable-lru.txt | 4 ++-- arch/alpha/kernel/pci-sysfs.c | 2 +- arch/ia64/kernel/perfmon.c | 2 +- arch/ia64/mm/init.c | 3 ++- arch/powerpc/kvm/book3s_hv.c | 2 +- arch/sparc/kernel/pci.c | 2 +- arch/unicore32/kernel/process.c | 2 +- arch/x86/xen/mmu.c | 3 +-- drivers/char/mbcs.c | 2 +- drivers/char/mem.c | 2 +- drivers/char/mspec.c | 2 +- drivers/gpu/drm/drm_gem.c | 2 +- drivers/gpu/drm/drm_vm.c | 10 ++-------- drivers/gpu/drm/exynos/exynos_drm_gem.c | 2 +- drivers/gpu/drm/gma500/framebuffer.c | 3 +-- drivers/gpu/drm/ttm/ttm_bo_vm.c | 4 ++-- drivers/gpu/drm/udl/udl_fb.c | 2 +- drivers/infiniband/hw/ehca/ehca_uverbs.c | 4 ++-- drivers/infiniband/hw/ipath/ipath_file_ops.c | 2 +- drivers/infiniband/hw/qib/qib_file_ops.c | 2 +- drivers/media/video/meye.c | 2 +- drivers/media/video/omap/omap_vout.c | 2 +- drivers/media/video/sn9c102/sn9c102_core.c | 3 +-- drivers/media/video/usbvision/usbvision-video.c | 3 +-- drivers/media/video/videobuf-dma-sg.c | 2 +- drivers/media/video/videobuf-vmalloc.c | 2 +- drivers/media/video/videobuf2-memops.c | 2 +- drivers/media/video/vino.c | 2 +- drivers/misc/carma/carma-fpga.c | 2 -- drivers/misc/sgi-gru/grufile.c | 5 ++--- drivers/mtd/mtdchar.c | 2 +- drivers/scsi/sg.c | 2 +- drivers/staging/media/easycap/easycap_main.c | 2 +- drivers/staging/omapdrm/omap_gem_dmabuf.c | 2 +- drivers/staging/tidspbridge/rmgr/drv_interface.c | 2 +- drivers/uio/uio.c | 4 +--- drivers/usb/mon/mon_bin.c | 2 +- drivers/video/68328fb.c | 2 +- drivers/video/aty/atyfb_base.c | 3 +-- drivers/video/fb-puv3.c | 3 +-- drivers/video/fb_defio.c | 2 +- drivers/video/fbmem.c | 3 +-- drivers/video/gbefb.c | 2 +- drivers/video/omap2/omapfb/omapfb-main.c | 2 +- drivers/video/sbuslib.c | 5 ++--- drivers/video/smscufx.c | 1 - drivers/video/udlfb.c | 1 - drivers/video/vermilion/vermilion.c | 1 - drivers/video/vfb.c | 1 - drivers/xen/gntalloc.c | 2 +- drivers/xen/gntdev.c | 2 +- drivers/xen/privcmd.c | 3 ++- fs/binfmt_elf.c | 2 +- fs/binfmt_elf_fdpic.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/proc/task_mmu.c | 2 +- include/linux/mempolicy.h | 2 +- include/linux/mm.h | 3 +-- include/linux/mm_types.h | 1 - kernel/events/core.c | 2 +- mm/ksm.c | 3 +-- mm/memory.c | 11 +++++------ mm/mlock.c | 2 +- mm/mmap.c | 2 -- mm/nommu.c | 2 +- mm/vmalloc.c | 3 +-- security/selinux/selinuxfs.c | 2 +- sound/core/pcm_native.c | 6 +++--- sound/usb/usx2y/us122l.c | 2 +- sound/usb/usx2y/usX2Yhwdep.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 71 files changed, 78 insertions(+), 106 deletions(-)
Documentation/vm/unevictable-lru.txt +2 -2
@@ -371,8 +371,8 @@ mlock_fixup() filters several classes of "special" VMAs: mlock_fixup() will call make_pages_present() in the hugetlbfs VMA range to allocate the huge pages and populate the ptes. -3) VMAs with VM_DONTEXPAND or VM_RESERVED are generally userspace mappings of - kernel pages, such as the VDSO page, relay channel pages, etc. These pages +3) VMAs with VM_DONTEXPAND are generally userspace mappings of kernel pages, + such as the VDSO page, relay channel pages, etc. These pages are inherently unevictable and are not managed on the LRU lists. mlock_fixup() treats these VMAs the same as hugetlbfs VMAs. It calls make_pages_present() to populate the ptes.
arch/alpha/kernel/pci-sysfs.c +1 -1
@@ -26,7 +26,7 @@ static int hose_mmap_page_range(struct pci_controller *hose, base = sparse ? hose->sparse_io_base : hose->dense_io_base; vma->vm_pgoff += base >>PAGE_SHIFT ; - vma->vm_flags |= (VM_IO |VM_RESERVED ); + vma->vm_flags |=VM_IO |VM_DONTEXPAND |VM_DONTDUMP ; return io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, vma->vm_end - vma->vm_start,
arch/ia64/kernel/perfmon.c +1 -1
@@ -2307,7 +2307,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t*/ vma->vm_mm = mm; vma->vm_file = filp; - vma->vm_flags =VM_READ |VM_MAYREAD |VM_RESERVED ; + vma->vm_flags =VM_READ |VM_MAYREAD |VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_page_prot =PAGE_READONLY ;/* XXX may need to change */ /*
arch/ia64/mm/init.c +2 -1
@@ -138,7 +138,8 @@ ia64_init_addr_space (void) vma->vm_mm = current->mm; vma->vm_end =PAGE_SIZE ; vma->vm_page_prot =__pgprot (pgprot_val (PAGE_READONLY ) | _PAGE_MA_NAT); - vma->vm_flags =VM_READ |VM_MAYREAD |VM_IO |VM_RESERVED ; + vma->vm_flags =VM_READ |VM_MAYREAD |VM_IO | +VM_DONTEXPAND |VM_DONTDUMP ;down_write (¤t->mm->mmap_sem);if (insert_vm_struct (current->mm, vma)) {up_write (¤t->mm->mmap_sem);
arch/powerpc/kvm/book3s_hv.c +1 -1
@@ -1183,7 +1183,7 @@ static const struct vm_operations_struct kvm_rma_vm_ops = {static int kvm_rma_mmap (struct file *file,struct vm_area_struct *vma) { - vma->vm_flags |=VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_ops = &kvm_rma_vm_ops;return 0 ; }
arch/sparc/kernel/pci.c +1 -1
@@ -783,7 +783,7 @@ static int __pci_mmap_make_offset(struct pci_dev *pdev,static void __pci_mmap_set_flags (struct pci_dev *dev,struct vm_area_struct *vma,enum pci_mmap_state mmap_state) { - vma->vm_flags |= (VM_IO |VM_RESERVED ); + vma->vm_flags |=VM_IO |VM_DONTEXPAND |VM_DONTDUMP ; }/* Set vm_page_prot of VMA, as appropriate for this architecture, for a pci
arch/unicore32/kernel/process.c +1 -1
@@ -380,7 +380,7 @@ int vectors_user_mapping(void)return install_special_mapping (mm,0xffff0000 ,PAGE_SIZE ,VM_READ |VM_EXEC |VM_MAYREAD |VM_MAYEXEC | -VM_RESERVED , +VM_DONTEXPAND |VM_DONTDUMP ,NULL ); }
arch/x86/xen/mmu.c +1 -2
@@ -2339,8 +2339,7 @@ int xen_remap_domain_mfn_range(struct vm_area_struct *vma, prot =__pgprot (pgprot_val (prot) | _PAGE_IOMAP); -BUG_ON (!((vma->vm_flags & (VM_PFNMAP |VM_RESERVED |VM_IO )) == - (VM_PFNMAP |VM_RESERVED |VM_IO ))); +BUG_ON (!((vma->vm_flags & (VM_PFNMAP |VM_IO )) == (VM_PFNMAP |VM_IO ))); rmd.mfn = mfn; rmd.prot = prot;
drivers/char/mbcs.c +1 -1
@@ -507,7 +507,7 @@ static int mbcs_gscr_mmap(struct file *fp, struct vm_area_struct *vma) vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); -/* Remap-pfn-range will mark the range VM_IO and VM_RESERVED */ +/* Remap-pfn-range will mark the range VM_IO */ if (remap_pfn_range(vma, vma->vm_start, __pa(soft->gscr_addr) >> PAGE_SHIFT,
drivers/char/mem.c +1 -1
@@ -322,7 +322,7 @@ static int mmap_mem(struct file *file, struct vm_area_struct *vma) vma->vm_ops = &mmap_mem_ops; -/* Remap-pfn-range will mark the range VM_IO and VM_RESERVED */ +/* Remap-pfn-range will mark the range VM_IO */ if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
drivers/char/mspec.c +1 -1
@@ -286,7 +286,7 @@ mspec_mmap(struct file *file, struct vm_area_struct *vma,atomic_set (&vdata->refcnt,1 ); vma->vm_private_data = vdata; - vma->vm_flags |= (VM_IO |VM_RESERVED |VM_PFNMAP |VM_DONTEXPAND ); + vma->vm_flags |=VM_IO |VM_PFNMAP |VM_DONTEXPAND |VM_DONTDUMP ;if (vdata->type ==MSPEC_FETCHOP || vdata->type ==MSPEC_UNCACHED ) vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); vma->vm_ops = &mspec_vm_ops;
drivers/gpu/drm/drm_gem.c +1 -1
@@ -706,7 +706,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) goto out_unlock; } - vma->vm_flags |=VM_RESERVED |VM_IO |VM_PFNMAP |VM_DONTEXPAND ; + vma->vm_flags |=VM_IO |VM_PFNMAP |VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_ops = obj->dev->driver->gem_vm_ops; vma->vm_private_data = map->handle; vma->vm_page_prot =pgprot_writecombine (vm_get_page_prot (vma->vm_flags));
drivers/gpu/drm/drm_vm.c +2 -8
@@ -514,8 +514,7 @@ static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma) vma->vm_ops = &drm_vm_dma_ops; - vma->vm_flags |=VM_RESERVED ;/* Don't swap */ - vma->vm_flags |=VM_DONTEXPAND ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ;drm_vm_open_locked (dev, vma);return 0 ;
@@ -652,21 +651,16 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)case _DRM_SHM: vma->vm_ops = &drm_vm_shm_ops; vma->vm_private_data = (void *)map; -/* Don't let this area swap. Change when -DRM_KERNEL advisory is supported. */ - vma->vm_flags |=VM_RESERVED ;break ;case _DRM_SCATTER_GATHER: vma->vm_ops = &drm_vm_sg_ops; vma->vm_private_data = (void *)map; - vma->vm_flags |=VM_RESERVED ; vma->vm_page_prot =drm_dma_prot (map->type, vma);break ;default :return -EINVAL ;/* This should never happen. */ } - vma->vm_flags |=VM_RESERVED ;/* Don't swap */ - vma->vm_flags |=VM_DONTEXPAND ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ;drm_vm_open_locked (dev, vma);return 0 ;
drivers/gpu/drm/exynos/exynos_drm_gem.c +1 -1
@@ -501,7 +501,7 @@ static int exynos_drm_gem_mmap_buffer(struct file *filp,DRM_DEBUG_KMS ("%s\n" , __FILE__); - vma->vm_flags |= (VM_IO |VM_RESERVED ); + vma->vm_flags |=VM_IO |VM_DONTEXPAND |VM_DONTDUMP ;update_vm_cache_attr (exynos_gem_obj, vma);
drivers/gpu/drm/gma500/framebuffer.c +1 -2
@@ -178,8 +178,7 @@ static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)*/ vma->vm_ops = &psbfb_vm_ops; vma->vm_private_data = (void *)psbfb; - vma->vm_flags |=VM_RESERVED |VM_IO | -VM_MIXEDMAP |VM_DONTEXPAND ; + vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ;return 0 ; }
drivers/gpu/drm/ttm/ttm_bo_vm.c +2 -2
@@ -285,7 +285,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,*/ vma->vm_private_data = bo; - vma->vm_flags |=VM_RESERVED |VM_IO |VM_MIXEDMAP |VM_DONTEXPAND ; + vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND |VM_DONTDUMP ;return 0 ; out_unref:ttm_bo_unref (&bo);
@@ -300,7 +300,7 @@ int ttm_fbdev_mmap(struct vm_area_struct *vma, struct ttm_buffer_object *bo) vma->vm_ops = &ttm_bo_vm_ops; vma->vm_private_data =ttm_bo_reference (bo); - vma->vm_flags |=VM_RESERVED |VM_IO |VM_MIXEDMAP |VM_DONTEXPAND ; + vma->vm_flags |=VM_IO |VM_MIXEDMAP |VM_DONTEXPAND ;return 0 ; }EXPORT_SYMBOL (ttm_fbdev_mmap);
drivers/gpu/drm/udl/udl_fb.c +1 -1
@@ -243,7 +243,7 @@ static int udl_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) size =0 ; } - vma->vm_flags |=VM_RESERVED ;/* avoid to swap out this VMA */ +/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ return 0 ; }
drivers/infiniband/hw/ehca/ehca_uverbs.c +2 -2
@@ -117,7 +117,7 @@ static int ehca_mmap_fw(struct vm_area_struct *vma, struct h_galpas *galpas, physical = galpas->user.fw_handle; vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot);ehca_gen_dbg ("vsize=%llx physical=%llx" , vsize, physical); -/* VM_IO | VM_RESERVED are set by remap_pfn_range() */ +/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ ret =remap_4k_pfn (vma, vma->vm_start, physical >>EHCA_PAGESHIFT , vma->vm_page_prot);if (unlikely (ret)) {
@@ -139,7 +139,7 @@ static int ehca_mmap_queue(struct vm_area_struct *vma, struct ipz_queue *queue,u64 start, ofs;struct page *page; - vma->vm_flags |=VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; start = vma->vm_start;for (ofs =0 ; ofs < queue->queue_length; ofs +=PAGE_SIZE ) {u64 virt_addr = (u64 )ipz_qeit_calc (queue, ofs);
drivers/infiniband/hw/ipath/ipath_file_ops.c +1 -1
@@ -1225,7 +1225,7 @@ static int mmap_kvaddr(struct vm_area_struct *vma, u64 pgaddr, vma->vm_pgoff = (unsigned long ) addr >>PAGE_SHIFT ; vma->vm_ops = &ipath_file_vm_ops; - vma->vm_flags |=VM_RESERVED |VM_DONTEXPAND ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; ret =1 ; bail:
drivers/infiniband/hw/qib/qib_file_ops.c +1 -1
@@ -971,7 +971,7 @@ static int mmap_kvaddr(struct vm_area_struct *vma, u64 pgaddr, vma->vm_pgoff = (unsigned long ) addr >>PAGE_SHIFT ; vma->vm_ops = &qib_file_vm_ops; - vma->vm_flags |=VM_RESERVED |VM_DONTEXPAND ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; ret =1 ; bail:
drivers/media/video/meye.c +1 -1
@@ -1647,7 +1647,7 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma) vma->vm_ops = &meye_vm_ops; vma->vm_flags &= ~VM_IO ;/* not I/O memory */ - vma->vm_flags |=VM_RESERVED ;/* avoid to swap out this VMA */ + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_private_data = (void *) (offset / gbufsize);meye_vm_open (vma);
drivers/media/video/omap/omap_vout.c +1 -1
@@ -910,7 +910,7 @@ static int omap_vout_mmap(struct file *file, struct vm_area_struct *vma) q->bufs[i]->baddr = vma->vm_start; - vma->vm_flags |=VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_page_prot =pgprot_writecombine (vma->vm_page_prot); vma->vm_ops = &omap_vout_vm_ops; vma->vm_private_data = (void *) vout;
drivers/media/video/sn9c102/sn9c102_core.c +1 -2
@@ -2126,8 +2126,7 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma)return -EINVAL ; } - vma->vm_flags |=VM_IO ; - vma->vm_flags |=VM_RESERVED ; + vma->vm_flags |=VM_IO |VM_DONTEXPAND |VM_DONTDUMP ; pos = cam->frame[i].bufmem;while (size >0 ) {/* size is page-aligned */
drivers/media/video/usbvision/usbvision-video.c +1 -2
@@ -1090,8 +1090,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) }/* VM_IO is eventually going to replace PageReserved altogether */ - vma->vm_flags |=VM_IO ; - vma->vm_flags |=VM_RESERVED ;/* avoid to swap out this VMA */ + vma->vm_flags |=VM_IO |VM_DONTEXPAND |VM_DONTDUMP ; pos = usbvision->frame[i].data;while (size >0 ) {
drivers/media/video/videobuf-dma-sg.c +1 -1
@@ -582,7 +582,7 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, map->count =1 ; map->q = q; vma->vm_ops = &videobuf_vm_ops; - vma->vm_flags |=VM_DONTEXPAND |VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_flags &= ~VM_IO ;/* using shared anonymous pages */ vma->vm_private_data = map; dprintk(1, "mmap %p: q=%p %08lx-%08lx pgoff %08lx bufs %d-%d\n",
drivers/media/video/videobuf-vmalloc.c +1 -1
@@ -270,7 +270,7 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, } vma->vm_ops = &videobuf_vm_ops; - vma->vm_flags |=VM_DONTEXPAND |VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_private_data = map; dprintk(1, "mmap %p: q=%p %08lx-%08lx (%lx) pgoff %08lx buf %d\n",
drivers/media/video/videobuf2-memops.c +1 -1
@@ -163,7 +163,7 @@ int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr,return ret; } - vma->vm_flags |=VM_DONTEXPAND |VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_private_data = priv; vma->vm_ops = vm_ops;
drivers/media/video/vino.c +1 -1
@@ -3950,7 +3950,7 @@ found: fb->map_count =1 ; - vma->vm_flags |=VM_DONTEXPAND |VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_flags &= ~VM_IO ; vma->vm_private_data = fb; vma->vm_file = file;
drivers/misc/carma/carma-fpga.c +0 -2
@@ -1243,8 +1243,6 @@ static int data_mmap(struct file *filp, struct vm_area_struct *vma)return -EINVAL ; } -/* IO memory (stop cacheing) */ - vma->vm_flags |=VM_IO |VM_RESERVED ; vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); return io_remap_pfn_range(vma, vma->vm_start, addr, vsize,
drivers/misc/sgi-gru/grufile.c +2 -3
@@ -108,9 +108,8 @@ static int gru_file_mmap(struct file *file, struct vm_area_struct *vma) vma->vm_end & (GRU_GSEG_PAGESIZE - 1))return -EINVAL ; - vma->vm_flags |= - (VM_IO |VM_DONTCOPY |VM_LOCKED |VM_DONTEXPAND |VM_PFNMAP | -VM_RESERVED ); + vma->vm_flags |=VM_IO |VM_PFNMAP |VM_LOCKED | +VM_DONTCOPY |VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_page_prot =PAGE_SHARED ; vma->vm_ops = &gru_vm_ops;
drivers/mtd/mtdchar.c +1 -1
@@ -1146,7 +1146,7 @@ static int mtdchar_mmap(struct file *file, struct vm_area_struct *vma) off += start; vma->vm_pgoff = off >>PAGE_SHIFT ; - vma->vm_flags |=VM_IO |VM_RESERVED ; + vma->vm_flags |=VM_IO |VM_DONTEXPAND |VM_DONTDUMP ;#ifdef pgprot_noncachedif (file->f_flags &O_DSYNC || off >=__pa (high_memory))
drivers/scsi/sg.c +1 -1
@@ -1257,7 +1257,7 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) } sfp->mmap_called =1 ; - vma->vm_flags |=VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_private_data = sfp; vma->vm_ops = &sg_mmap_vm_ops;return 0 ;
drivers/staging/media/easycap/easycap_main.c +1 -1
@@ -2246,7 +2246,7 @@ static int easycap_mmap(struct file *file, struct vm_area_struct *pvma)JOT (8 ,"\n" ); pvma->vm_ops = &easycap_vm_ops; - pvma->vm_flags |=VM_RESERVED ; + pvma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ;if (file) pvma->vm_private_data = file->private_data;easycap_vma_open (pvma);
drivers/staging/omapdrm/omap_gem_dmabuf.c +1 -1
@@ -160,7 +160,7 @@ static int omap_gem_dmabuf_mmap(struct dma_buf *buffer, goto out_unlock; } - vma->vm_flags |=VM_RESERVED |VM_IO |VM_PFNMAP |VM_DONTEXPAND ; + vma->vm_flags |=VM_IO |VM_PFNMAP |VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_ops = obj->dev->driver->gem_vm_ops; vma->vm_private_data = obj; vma->vm_page_prot =pgprot_writecombine (vm_get_page_prot (vma->vm_flags));
drivers/staging/tidspbridge/rmgr/drv_interface.c +1 -1
@@ -261,7 +261,7 @@ static int bridge_mmap(struct file *filp, struct vm_area_struct *vma) {u32 status; - vma->vm_flags |=VM_RESERVED |VM_IO ; +/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); dev_dbg(bridge, "%s: vm filp %p start %lx end %lx page_prot %ulx "
drivers/uio/uio.c +1 -3
@@ -653,8 +653,6 @@ static int uio_mmap_physical(struct vm_area_struct *vma)if (mi <0 )return -EINVAL ; - vma->vm_flags |=VM_IO |VM_RESERVED ; - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); return remap_pfn_range(vma,
@@ -666,7 +664,7 @@ static int uio_mmap_physical(struct vm_area_struct *vma)static int uio_mmap_logical (struct vm_area_struct *vma) { - vma->vm_flags |=VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_ops = &uio_vm_ops;uio_vma_open (vma);return 0 ;
drivers/usb/mon/mon_bin.c +1 -1
@@ -1247,7 +1247,7 @@ static int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma) {/* don't do anything here: "fault" will set up page table entries */ vma->vm_ops = &mon_bin_vm_ops; - vma->vm_flags |=VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_private_data = filp->private_data;mon_bin_vma_open (vma);return 0 ;
drivers/video/68328fb.c +1 -1
@@ -400,7 +400,7 @@ static int mc68x328fb_mmap(struct fb_info *info, struct vm_area_struct *vma)#ifndef MMU /* this is uClinux (no MMU) specific code */ - vma->vm_flags |=VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_start = videomemory;return 0 ;
drivers/video/aty/atyfb_base.c +1 -2
@@ -1942,8 +1942,7 @@ static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma) off = vma->vm_pgoff <<PAGE_SHIFT ; size = vma->vm_end - vma->vm_start; -/* To stop the swapper from even considering these pages. */ - vma->vm_flags |= (VM_IO |VM_RESERVED ); +/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ if (((vma->vm_pgoff ==0 ) && (size == info->fix.smem_len)) || ((off == info->fix.smem_len) && (size ==PAGE_SIZE )))
drivers/video/fb-puv3.c +1 -2
@@ -653,9 +653,8 @@ int unifb_mmap(struct fb_info *info, vma->vm_page_prot))return -EAGAIN ; - vma->vm_flags |=VM_RESERVED ;/* avoid to swap out this VMA */ +/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ return 0 ; - }static struct fb_ops unifb_ops = {
drivers/video/fb_defio.c +1 -1
@@ -164,7 +164,7 @@ static const struct address_space_operations fb_deferred_io_aops = {static int fb_deferred_io_mmap (struct fb_info *info,struct vm_area_struct *vma) { vma->vm_ops = &fb_deferred_io_vm_ops; - vma->vm_flags |= (VM_RESERVED |VM_DONTEXPAND ); + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ;if (!(info->flags &FBINFO_VIRTFB )) vma->vm_flags |=VM_IO ; vma->vm_private_data = info;
drivers/video/fbmem.c +1 -2
@@ -1410,8 +1410,7 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)return -EINVAL ; off += start; vma->vm_pgoff = off >>PAGE_SHIFT ; -/* This is an IO map - tell maydump to skip this VMA */ - vma->vm_flags |=VM_IO |VM_RESERVED ; +/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by io_remap_pfn_range()*/ vma->vm_page_prot =vm_get_page_prot (vma->vm_flags);fb_pgprotect (file, vma, off); if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
drivers/video/gbefb.c +1 -1
@@ -1024,7 +1024,7 @@ static int gbefb_mmap(struct fb_info *info,pgprot_val (vma->vm_page_prot) =pgprot_fb (pgprot_val (vma->vm_page_prot)); - vma->vm_flags |=VM_IO |VM_RESERVED ; +/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ /* look for the starting tile */ tile = &gbe_tiles.cpu[offset >>TILE_SHIFT ];
drivers/video/omap2/omapfb/omapfb-main.c +1 -1
@@ -1123,7 +1123,7 @@ static int omapfb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)DBG ("user mmap region start %lx, len %d, off %lx\n" , start, len, off); vma->vm_pgoff = off >>PAGE_SHIFT ; - vma->vm_flags |=VM_IO |VM_RESERVED ; +/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ vma->vm_page_prot =pgprot_writecombine (vma->vm_page_prot); vma->vm_ops = &mmap_user_ops; vma->vm_private_data = rg;
drivers/video/sbuslib.c +2 -3
@@ -57,9 +57,8 @@ int sbusfb_mmap_helper(struct sbus_mmap_map *map, off = vma->vm_pgoff <<PAGE_SHIFT ; -/* To stop the swapper from even considering these pages */ - vma->vm_flags |= (VM_IO |VM_RESERVED ); - +/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ + vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot);/* Each page, see which map applies */
drivers/video/smscufx.c +0 -1
@@ -803,7 +803,6 @@ static int ufx_ops_mmap(struct fb_info *info, struct vm_area_struct *vma) size =0 ; } - vma->vm_flags |=VM_RESERVED ;/* avoid to swap out this VMA */ return 0 ; }
drivers/video/udlfb.c +0 -1
@@ -345,7 +345,6 @@ static int dlfb_ops_mmap(struct fb_info *info, struct vm_area_struct *vma) size =0 ; } - vma->vm_flags |=VM_RESERVED ;/* avoid to swap out this VMA */ return 0 ; }
drivers/video/vermilion/vermilion.c +0 -1
@@ -1018,7 +1018,6 @@ static int vmlfb_mmap(struct fb_info *info, struct vm_area_struct *vma) offset += vinfo->vram_start;pgprot_val (vma->vm_page_prot) |= _PAGE_PCD;pgprot_val (vma->vm_page_prot) &= ~_PAGE_PWT; - vma->vm_flags |=VM_RESERVED |VM_IO ;if (remap_pfn_range (vma, vma->vm_start, offset >>PAGE_SHIFT , size, vma->vm_page_prot))return -EAGAIN ;
drivers/video/vfb.c +0 -1
@@ -439,7 +439,6 @@ static int vfb_mmap(struct fb_info *info, size =0 ; } - vma->vm_flags |=VM_RESERVED ;/* avoid to swap out this VMA */ return 0 ; }
drivers/xen/gntalloc.c +1 -1
@@ -535,7 +535,7 @@ static int gntalloc_mmap(struct file *filp, struct vm_area_struct *vma) vma->vm_private_data = vm_priv; - vma->vm_flags |=VM_RESERVED |VM_DONTEXPAND ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_ops = &gntalloc_vmops;
drivers/xen/gntdev.c +1 -1
@@ -719,7 +719,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) vma->vm_ops = &gntdev_vmops; - vma->vm_flags |=VM_RESERVED |VM_DONTEXPAND ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ;if (use_ptemod) vma->vm_flags |=VM_DONTCOPY ;
drivers/xen/privcmd.c +2 -1
@@ -386,7 +386,8 @@ static int privcmd_mmap(struct file *file, struct vm_area_struct *vma)/* DONTCOPY is essential for Xen because copy_page_range doesn't know * how to recreate these mappings */ - vma->vm_flags |=VM_RESERVED |VM_IO |VM_DONTCOPY |VM_PFNMAP ; + vma->vm_flags |=VM_IO |VM_PFNMAP |VM_DONTCOPY | +VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_ops = &privcmd_vm_ops; vma->vm_private_data =NULL ;
fs/binfmt_elf.c +1 -1
@@ -1127,7 +1127,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma, }/* Do not dump I/O mapped devices or special mappings */ -if (vma->vm_flags & (VM_IO |VM_RESERVED )) +if (vma->vm_flags &VM_IO )return 0 ;/* By default, dump shared memory if mapped from an anonymous file. */
fs/binfmt_elf_fdpic.c +1 -1
@@ -1205,7 +1205,7 @@ static int maydump(struct vm_area_struct *vma, unsigned long mm_flags)int dump_ok;/* Do not dump I/O mapped devices or special mappings */ -if (vma->vm_flags & (VM_IO |VM_RESERVED )) { +if (vma->vm_flags &VM_IO ) {kdcore ("%08lx: %08lx: no (IO)" , vma->vm_start, vma->vm_flags);return 0 ; }
fs/hugetlbfs/inode.c +1 -1
@@ -110,7 +110,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)* way when do_mmap_pgoff unwinds (may be important on powerpc * and ia64). */ - vma->vm_flags |=VM_HUGETLB |VM_RESERVED ; + vma->vm_flags |=VM_HUGETLB |VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_ops = &hugetlb_vm_ops;if (vma->vm_pgoff & (~huge_page_mask (h) >>PAGE_SHIFT ))
fs/proc/task_mmu.c +1 -1
@@ -54,7 +54,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)"VmPTE:\t%8lu kB\n" "VmSwap:\t%8lu kB\n" , hiwater_vm << (PAGE_SHIFT -10 ), - (total_vm - mm->reserved_vm) << (PAGE_SHIFT -10 ), + total_vm << (PAGE_SHIFT -10 ), mm->locked_vm << (PAGE_SHIFT -10 ), mm->pinned_vm << (PAGE_SHIFT -10 ), hiwater_rss << (PAGE_SHIFT-10),
include/linux/mempolicy.h +1 -1
@@ -239,7 +239,7 @@ extern int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol,/* Check if a vma is migratable */ static inline int vma_migratable (struct vm_area_struct *vma) { -if (vma->vm_flags & (VM_IO |VM_HUGETLB |VM_PFNMAP |VM_RESERVED )) +if (vma->vm_flags & (VM_IO |VM_HUGETLB |VM_PFNMAP ))return 0 ;/* * Migration allocates pages in the highest zone. If we cannot
include/linux/mm.h +1 -2
@@ -96,7 +96,6 @@ extern unsigned int kobjsize(const void *objp);#define VM_DONTCOPY 0x00020000/* Do not copy this vma on fork */ #define VM_DONTEXPAND 0x00040000/* Cannot expand with mremap() */ -#define VM_RESERVED 0x00080000/* Count as reserved_vm like IO */ #define VM_ACCOUNT 0x00100000/* Is a VM accounted object */ #define VM_NORESERVE 0x00200000/* should the VM suppress accounting */ #define VM_HUGETLB 0x00400000/* Huge TLB Page VM */
@@ -148,7 +147,7 @@ extern unsigned int kobjsize(const void *objp);* Special vmas that are non-mergable, non-mlock()able. * Note: mm/huge_memory.c VM_NO_THP depends on this definition. */ -#define VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_RESERVED | VM_PFNMAP) +#define VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_PFNMAP)/* * mapping from the currently active vm_flags protection bits (the
include/linux/mm_types.h +0 -1
@@ -340,7 +340,6 @@ struct mm_struct {unsigned long shared_vm;/* Shared pages (files) */ unsigned long exec_vm;/* VM_EXEC & ~VM_WRITE */ unsigned long stack_vm;/* VM_GROWSUP/DOWN */ -unsigned long reserved_vm;/* VM_RESERVED|VM_IO pages */ unsigned long def_flags;unsigned long nr_ptes;/* Page table pages */ unsigned long start_code, end_code, start_data, end_data;
kernel/events/core.c +1 -1
@@ -3669,7 +3669,7 @@ unlock:atomic_inc (&event->mmap_count);mutex_unlock (&event->mmap_mutex); - vma->vm_flags |=VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_ops = &perf_mmap_vmops;return ret;
mm/ksm.c +1 -2
@@ -1469,8 +1469,7 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start,*/ if (*vm_flags & (VM_MERGEABLE |VM_SHARED |VM_MAYSHARE |VM_PFNMAP |VM_IO |VM_DONTEXPAND | -VM_RESERVED |VM_HUGETLB | -VM_NONLINEAR |VM_MIXEDMAP )) +VM_HUGETLB |VM_NONLINEAR |VM_MIXEDMAP ))return 0 ;/* just ignore the advice */ #ifdef VM_SAO
mm/memory.c +5 -6
@@ -2294,14 +2294,13 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,* rest of the world about it: * VM_IO tells people not to look at these pages * (accesses can have side effects). -* VM_RESERVED is specified all over the place, because -* in 2.4 it kept swapout's vma scan off this vma; but -* in 2.6 the LRU scan won't even find its pages, so this -* flag means no more than count its pages in reserved_vm, -* and omit it from core dump, even when VM_IO turned off. * VM_PFNMAP tells the core MM that the base pages are just * raw PFN mappings, and do not have a "struct page" associated * with them. +* VM_DONTEXPAND +* Disable vma merging and expanding with mremap(). +* VM_DONTDUMP +* Omit vma from core dump, even when VM_IO turned off. * * There's a horrible special case to handle copy-on-write * behaviour that some programs depend on. We mark the "original"
@@ -2318,7 +2317,7 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,if (err)return -EINVAL ; - vma->vm_flags |=VM_IO |VM_RESERVED |VM_PFNMAP ; + vma->vm_flags |=VM_IO |VM_PFNMAP |VM_DONTEXPAND |VM_DONTDUMP ;BUG_ON (addr >= end); pfn -= addr >>PAGE_SHIFT ;
mm/mlock.c +1 -1
@@ -227,7 +227,7 @@ long mlock_vma_pages_range(struct vm_area_struct *vma,if (vma->vm_flags & (VM_IO |VM_PFNMAP )) goto no_mlock; -if (!((vma->vm_flags & (VM_DONTEXPAND |VM_RESERVED )) || +if (!((vma->vm_flags &VM_DONTEXPAND ) ||is_vm_hugetlb_page (vma) || vma ==get_gate_vma (current->mm))) {
mm/mmap.c +0 -2
@@ -943,8 +943,6 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags, mm->exec_vm += pages; }else if (flags & stack_flags) mm->stack_vm += pages; -if (flags & (VM_RESERVED |VM_IO )) - mm->reserved_vm += pages; }#endif /* CONFIG_PROC_FS */
mm/nommu.c +1 -1
@@ -1813,7 +1813,7 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,if (addr != (pfn <<PAGE_SHIFT ))return -EINVAL ; - vma->vm_flags |=VM_IO |VM_RESERVED |VM_PFNMAP ; + vma->vm_flags |=VM_IO |VM_PFNMAP |VM_DONTEXPAND |VM_DONTDUMP ;return 0 ; }EXPORT_SYMBOL (remap_pfn_range);
mm/vmalloc.c +1 -2
@@ -2155,8 +2155,7 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr, usize -=PAGE_SIZE ; }while (usize >0 ); -/* Prevent "things" like memory migration? VM_flags need a cleanup... */ - vma->vm_flags |=VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ;return 0 ; }
security/selinux/selinuxfs.c +1 -1
@@ -485,7 +485,7 @@ static int sel_mmap_policy(struct file *filp, struct vm_area_struct *vma)return -EACCES ; } - vma->vm_flags |=VM_RESERVED ; + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; vma->vm_ops = &sel_mmap_policy_ops;return 0 ;
sound/core/pcm_native.c +3 -3
@@ -3038,7 +3038,7 @@ static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct filereturn -EINVAL ; area->vm_ops = &snd_pcm_vm_ops_status; area->vm_private_data = substream; - area->vm_flags |=VM_RESERVED ; + area->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ;return 0 ; }
@@ -3075,7 +3075,7 @@ static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct filereturn -EINVAL ; area->vm_ops = &snd_pcm_vm_ops_control; area->vm_private_data = substream; - area->vm_flags |=VM_RESERVED ; + area->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; return 0; }#else /* ! coherent mmap */
@@ -3169,7 +3169,7 @@ static const struct vm_operations_struct snd_pcm_vm_ops_data_fault = {int snd_pcm_lib_default_mmap (struct snd_pcm_substream *substream,struct vm_area_struct *area) { - area->vm_flags |=VM_RESERVED ; + area->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ;#ifdef ARCH_HAS_DMA_MMAP_COHERENT if (!substream->ops->page && substream->dma_buffer.dev.type ==SNDRV_DMA_TYPE_DEV )
sound/usb/usx2y/us122l.c +1 -1
@@ -262,7 +262,7 @@ static int usb_stream_hwdep_mmap(struct snd_hwdep *hw, } area->vm_ops = &usb_stream_hwdep_vm_ops; - area->vm_flags |=VM_RESERVED ; + area->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; area->vm_private_data = us122l;atomic_inc (&us122l->mmap_count); out:
sound/usb/usx2y/usX2Yhwdep.c +1 -1
@@ -82,7 +82,7 @@ static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct v us428->us428ctls_sharedmem->CtlSnapShotLast =-2 ; } area->vm_ops = &us428ctls_vm_ops; - area->vm_flags |=VM_RESERVED |VM_DONTEXPAND ; + area->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; area->vm_private_data = hw->private_data;return 0 ; }
sound/usb/usx2y/usx2yhwdeppcm.c +1 -1
@@ -723,7 +723,7 @@ static int snd_usX2Y_hwdep_pcm_mmap(struct snd_hwdep * hw, struct file *filp, streturn -ENODEV ; } area->vm_ops = &snd_usX2Y_hwdep_pcm_vm_ops; - area->vm_flags |=VM_RESERVED |VM_DONTEXPAND ; + area->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; area->vm_private_data = hw->private_data;return 0 ; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>