Track maximum size of address space, presented in /proc/self/limits. Signed-off-by: Topi Miettinen <toiwoton@xxxxxxxxx> --- mm/mmap.c | 4 ++++ mm/mremap.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index 4e683dd..4876c21 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2706,6 +2706,9 @@ static int do_brk(unsigned long addr, unsigned long len) out: perf_event_mmap(vma); mm->total_vm += len >> PAGE_SHIFT; + + bump_rlimit(RLIMIT_AS, mm->total_vm << PAGE_SHIFT); + mm->data_vm += len >> PAGE_SHIFT; if (flags & VM_LOCKED) mm->locked_vm += (len >> PAGE_SHIFT); @@ -2926,6 +2929,7 @@ bool may_expand_vm(struct mm_struct *mm, vm_flags_t flags, unsigned long npages) void vm_stat_account(struct mm_struct *mm, vm_flags_t flags, long npages) { mm->total_vm += npages; + bump_rlimit(RLIMIT_AS, mm->total_vm << PAGE_SHIFT); if (is_exec_mapping(flags)) mm->exec_vm += npages; diff --git a/mm/mremap.c b/mm/mremap.c index ade3e13..6be3c01 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -397,6 +397,9 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr, if (vma->vm_flags & VM_LOCKED) bump_rlimit(RLIMIT_MEMLOCK, (mm->locked_vm << PAGE_SHIFT) + new_len - old_len); + bump_rlimit(RLIMIT_AS, (mm->total_vm << PAGE_SHIFT) + + new_len - old_len); + return vma; } -- 2.8.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>