diff options
author | Jerome Marchand <jmarchan@redhat.com> | 2013-11-12 18:08:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-12 22:09:11 -0500 |
commit | 00619bcc44d6b779aa366130b354153c222e4380 (patch) | |
tree | 5a885f81a351dfc6ca471823388d89a739406862 /mm/mmap.c | |
parent | 715ea41e60277f28f84d6c937737350e00955d56 (diff) |
mm: factor commit limit calculation
The same calculation is currently done in three differents places.
Factor that code so future changes has to be made at only one place.
[akpm@linux-foundation.org: uninline vm_commit_limit()]
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 4 |
1 files changed, 1 insertions, 3 deletions
@@ -179,14 +179,12 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) | |||
179 | goto error; | 179 | goto error; |
180 | } | 180 | } |
181 | 181 | ||
182 | allowed = (totalram_pages - hugetlb_total_pages()) | 182 | allowed = vm_commit_limit(); |
183 | * sysctl_overcommit_ratio / 100; | ||
184 | /* | 183 | /* |
185 | * Reserve some for root | 184 | * Reserve some for root |
186 | */ | 185 | */ |
187 | if (!cap_sys_admin) | 186 | if (!cap_sys_admin) |
188 | allowed -= sysctl_admin_reserve_kbytes >> (PAGE_SHIFT - 10); | 187 | allowed -= sysctl_admin_reserve_kbytes >> (PAGE_SHIFT - 10); |
189 | allowed += total_swap_pages; | ||
190 | 188 | ||
191 | /* | 189 | /* |
192 | * Don't let a single process grow so big a user can't recover | 190 | * Don't let a single process grow so big a user can't recover |