mmap.c (440fdb53b4ae58602711b5b8c3a139ace2404dbb) | mmap.c (34b4e4aa3c470ce8fa2bd78abb1741b4b58baad7) |
---|---|
1/* 2 * mm/mmap.c 3 * 4 * Written by obz. 5 * 6 * Address space accounting code <alan@redhat.com> 7 */ 8 --- 79 unchanged lines hidden (view full) --- 88 * Strict overcommit modes added 2002 Feb 26 by Alan Cox. 89 * Additional code 2002 Jul 20 by Robert Love. 90 * 91 * cap_sys_admin is 1 if the process has admin privileges, 0 otherwise. 92 * 93 * Note this is a helper function intended to be used by LSMs which 94 * wish to use this logic. 95 */ | 1/* 2 * mm/mmap.c 3 * 4 * Written by obz. 5 * 6 * Address space accounting code <alan@redhat.com> 7 */ 8 --- 79 unchanged lines hidden (view full) --- 88 * Strict overcommit modes added 2002 Feb 26 by Alan Cox. 89 * Additional code 2002 Jul 20 by Robert Love. 90 * 91 * cap_sys_admin is 1 if the process has admin privileges, 0 otherwise. 92 * 93 * Note this is a helper function intended to be used by LSMs which 94 * wish to use this logic. 95 */ |
96int __vm_enough_memory(long pages, int cap_sys_admin) | 96int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) |
97{ 98 unsigned long free, allowed; 99 100 vm_acct_memory(pages); 101 102 /* 103 * Sometimes we want to use more memory than we have 104 */ --- 56 unchanged lines hidden (view full) --- 161 * Leave the last 3% for root 162 */ 163 if (!cap_sys_admin) 164 allowed -= allowed / 32; 165 allowed += total_swap_pages; 166 167 /* Don't let a single process grow too big: 168 leave 3% of the size of this process for other processes */ | 97{ 98 unsigned long free, allowed; 99 100 vm_acct_memory(pages); 101 102 /* 103 * Sometimes we want to use more memory than we have 104 */ --- 56 unchanged lines hidden (view full) --- 161 * Leave the last 3% for root 162 */ 163 if (!cap_sys_admin) 164 allowed -= allowed / 32; 165 allowed += total_swap_pages; 166 167 /* Don't let a single process grow too big: 168 leave 3% of the size of this process for other processes */ |
169 allowed -= current->mm->total_vm / 32; | 169 allowed -= mm->total_vm / 32; |
170 171 /* 172 * cast `allowed' as a signed long because vm_committed_space 173 * sometimes has a negative value 174 */ 175 if (atomic_read(&vm_committed_space) < (long)allowed) 176 return 0; 177error: --- 1894 unchanged lines hidden (view full) --- 2072 if (!vma->vm_file) { 2073 BUG_ON(vma->anon_vma); 2074 vma->vm_pgoff = vma->vm_start >> PAGE_SHIFT; 2075 } 2076 __vma = find_vma_prepare(mm,vma->vm_start,&prev,&rb_link,&rb_parent); 2077 if (__vma && __vma->vm_start < vma->vm_end) 2078 return -ENOMEM; 2079 if ((vma->vm_flags & VM_ACCOUNT) && | 170 171 /* 172 * cast `allowed' as a signed long because vm_committed_space 173 * sometimes has a negative value 174 */ 175 if (atomic_read(&vm_committed_space) < (long)allowed) 176 return 0; 177error: --- 1894 unchanged lines hidden (view full) --- 2072 if (!vma->vm_file) { 2073 BUG_ON(vma->anon_vma); 2074 vma->vm_pgoff = vma->vm_start >> PAGE_SHIFT; 2075 } 2076 __vma = find_vma_prepare(mm,vma->vm_start,&prev,&rb_link,&rb_parent); 2077 if (__vma && __vma->vm_start < vma->vm_end) 2078 return -ENOMEM; 2079 if ((vma->vm_flags & VM_ACCOUNT) && |
2080 security_vm_enough_memory(vma_pages(vma))) | 2080 security_vm_enough_memory_mm(mm, vma_pages(vma))) |
2081 return -ENOMEM; 2082 vma_link(mm, vma, prev, rb_link, rb_parent); 2083 return 0; 2084} 2085 2086/* 2087 * Copy the vma structure to a new location in the same mm, 2088 * prior to moving page table entries, to effect an mremap move. --- 138 unchanged lines hidden --- | 2081 return -ENOMEM; 2082 vma_link(mm, vma, prev, rb_link, rb_parent); 2083 return 0; 2084} 2085 2086/* 2087 * Copy the vma structure to a new location in the same mm, 2088 * prior to moving page table entries, to effect an mremap move. --- 138 unchanged lines hidden --- |