Skip to content

Commit 314e51b

Browse files
koct9itorvalds
authored andcommitted
mm: kill vma flag VM_RESERVED and mm->reserved_vm counter
A 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. [akpm@linux-foundation.org: drivers/vfio/pci/vfio_pci.c fixup] Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Carsten Otte <cotte@de.ibm.com> Cc: Chris Metcalf <cmetcalf@tilera.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: Eric Paris <eparis@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Hugh Dickins <hughd@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Morris <james.l.morris@oracle.com> Cc: Jason Baron <jbaron@redhat.com> Cc: Kentaro Takeda <takedakn@nttdata.co.jp> Cc: Matt Helsley <matthltc@us.ibm.com> Cc: Nick Piggin <npiggin@kernel.dk> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Robert Richter <robert.richter@amd.com> Cc: Suresh Siddha <suresh.b.siddha@intel.com> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Venkatesh Pallipadi <venki@google.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0103bd1 commit 314e51b

70 files changed

Lines changed: 77 additions & 105 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Documentation/vm/unevictable-lru.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ mlock_fixup() filters several classes of "special" VMAs:
371371
mlock_fixup() will call make_pages_present() in the hugetlbfs VMA range to
372372
allocate the huge pages and populate the ptes.
373373

374-
3) VMAs with VM_DONTEXPAND or VM_RESERVED are generally userspace mappings of
375-
kernel pages, such as the VDSO page, relay channel pages, etc. These pages
374+
3) VMAs with VM_DONTEXPAND are generally userspace mappings of kernel pages,
375+
such as the VDSO page, relay channel pages, etc. These pages
376376
are inherently unevictable and are not managed on the LRU lists.
377377
mlock_fixup() treats these VMAs the same as hugetlbfs VMAs. It calls
378378
make_pages_present() to populate the ptes.

arch/alpha/kernel/pci-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int hose_mmap_page_range(struct pci_controller *hose,
2626
base = sparse ? hose->sparse_io_base : hose->dense_io_base;
2727

2828
vma->vm_pgoff += base >> PAGE_SHIFT;
29-
vma->vm_flags |= (VM_IO | VM_RESERVED);
29+
vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
3030

3131
return io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
3232
vma->vm_end - vma->vm_start,

arch/ia64/kernel/perfmon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2307,7 +2307,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
23072307
*/
23082308
vma->vm_mm = mm;
23092309
vma->vm_file = get_file(filp);
2310-
vma->vm_flags = VM_READ| VM_MAYREAD |VM_RESERVED;
2310+
vma->vm_flags = VM_READ|VM_MAYREAD|VM_DONTEXPAND|VM_DONTDUMP;
23112311
vma->vm_page_prot = PAGE_READONLY; /* XXX may need to change */
23122312

23132313
/*

arch/ia64/mm/init.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ ia64_init_addr_space (void)
138138
vma->vm_mm = current->mm;
139139
vma->vm_end = PAGE_SIZE;
140140
vma->vm_page_prot = __pgprot(pgprot_val(PAGE_READONLY) | _PAGE_MA_NAT);
141-
vma->vm_flags = VM_READ | VM_MAYREAD | VM_IO | VM_RESERVED;
141+
vma->vm_flags = VM_READ | VM_MAYREAD | VM_IO |
142+
VM_DONTEXPAND | VM_DONTDUMP;
142143
down_write(&current->mm->mmap_sem);
143144
if (insert_vm_struct(current->mm, vma)) {
144145
up_write(&current->mm->mmap_sem);

arch/powerpc/kvm/book3s_hv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ static const struct vm_operations_struct kvm_rma_vm_ops = {
11831183

11841184
static int kvm_rma_mmap(struct file *file, struct vm_area_struct *vma)
11851185
{
1186-
vma->vm_flags |= VM_RESERVED;
1186+
vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
11871187
vma->vm_ops = &kvm_rma_vm_ops;
11881188
return 0;
11891189
}

arch/sparc/kernel/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ static int __pci_mmap_make_offset(struct pci_dev *pdev,
779779
static void __pci_mmap_set_flags(struct pci_dev *dev, struct vm_area_struct *vma,
780780
enum pci_mmap_state mmap_state)
781781
{
782-
vma->vm_flags |= (VM_IO | VM_RESERVED);
782+
vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
783783
}
784784

785785
/* Set vm_page_prot of VMA, as appropriate for this architecture, for a pci

arch/unicore32/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ int vectors_user_mapping(void)
380380
return install_special_mapping(mm, 0xffff0000, PAGE_SIZE,
381381
VM_READ | VM_EXEC |
382382
VM_MAYREAD | VM_MAYEXEC |
383-
VM_RESERVED,
383+
VM_DONTEXPAND | VM_DONTDUMP,
384384
NULL);
385385
}
386386

arch/x86/xen/mmu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,8 +2451,7 @@ int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
24512451

24522452
prot = __pgprot(pgprot_val(prot) | _PAGE_IOMAP);
24532453

2454-
BUG_ON(!((vma->vm_flags & (VM_PFNMAP | VM_RESERVED | VM_IO)) ==
2455-
(VM_PFNMAP | VM_RESERVED | VM_IO)));
2454+
BUG_ON(!((vma->vm_flags & (VM_PFNMAP | VM_IO)) == (VM_PFNMAP | VM_IO)));
24562455

24572456
rmd.mfn = mfn;
24582457
rmd.prot = prot;

drivers/char/mbcs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static int mbcs_gscr_mmap(struct file *fp, struct vm_area_struct *vma)
507507

508508
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
509509

510-
/* Remap-pfn-range will mark the range VM_IO and VM_RESERVED */
510+
/* Remap-pfn-range will mark the range VM_IO */
511511
if (remap_pfn_range(vma,
512512
vma->vm_start,
513513
__pa(soft->gscr_addr) >> PAGE_SHIFT,

drivers/char/mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static int mmap_mem(struct file *file, struct vm_area_struct *vma)
322322

323323
vma->vm_ops = &mmap_mem_ops;
324324

325-
/* Remap-pfn-range will mark the range VM_IO and VM_RESERVED */
325+
/* Remap-pfn-range will mark the range VM_IO */
326326
if (remap_pfn_range(vma,
327327
vma->vm_start,
328328
vma->vm_pgoff,

0 commit comments

Comments
 (0)