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/nommu.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/nommu.c')
-rw-r--r-- | mm/nommu.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/mm/nommu.c b/mm/nommu.c index ecd1f158548e..d8a957bb9e31 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -1948,13 +1948,12 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) | |||
1948 | goto error; | 1948 | goto error; |
1949 | } | 1949 | } |
1950 | 1950 | ||
1951 | allowed = totalram_pages * sysctl_overcommit_ratio / 100; | 1951 | allowed = vm_commit_limit(); |
1952 | /* | 1952 | /* |
1953 | * Reserve some 3% for root | 1953 | * Reserve some 3% for root |
1954 | */ | 1954 | */ |
1955 | if (!cap_sys_admin) | 1955 | if (!cap_sys_admin) |
1956 | allowed -= sysctl_admin_reserve_kbytes >> (PAGE_SHIFT - 10); | 1956 | allowed -= sysctl_admin_reserve_kbytes >> (PAGE_SHIFT - 10); |
1957 | allowed += total_swap_pages; | ||
1958 | 1957 | ||
1959 | /* | 1958 | /* |
1960 | * Don't let a single process grow so big a user can't recover | 1959 | * Don't let a single process grow so big a user can't recover |