diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/nommu.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/mm/nommu.c b/mm/nommu.c index db45efac17cc..029fadac0fb5 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -1147,14 +1147,26 @@ int __vm_enough_memory(long pages, int cap_sys_admin) | |||
1147 | * only call if we're about to fail. | 1147 | * only call if we're about to fail. |
1148 | */ | 1148 | */ |
1149 | n = nr_free_pages(); | 1149 | n = nr_free_pages(); |
1150 | |||
1151 | /* | ||
1152 | * Leave reserved pages. The pages are not for anonymous pages. | ||
1153 | */ | ||
1154 | if (n <= totalreserve_pages) | ||
1155 | goto error; | ||
1156 | else | ||
1157 | n -= totalreserve_pages; | ||
1158 | |||
1159 | /* | ||
1160 | * Leave the last 3% for root | ||
1161 | */ | ||
1150 | if (!cap_sys_admin) | 1162 | if (!cap_sys_admin) |
1151 | n -= n / 32; | 1163 | n -= n / 32; |
1152 | free += n; | 1164 | free += n; |
1153 | 1165 | ||
1154 | if (free > pages) | 1166 | if (free > pages) |
1155 | return 0; | 1167 | return 0; |
1156 | vm_unacct_memory(pages); | 1168 | |
1157 | return -ENOMEM; | 1169 | goto error; |
1158 | } | 1170 | } |
1159 | 1171 | ||
1160 | allowed = totalram_pages * sysctl_overcommit_ratio / 100; | 1172 | allowed = totalram_pages * sysctl_overcommit_ratio / 100; |
@@ -1175,7 +1187,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin) | |||
1175 | */ | 1187 | */ |
1176 | if (atomic_read(&vm_committed_space) < (long)allowed) | 1188 | if (atomic_read(&vm_committed_space) < (long)allowed) |
1177 | return 0; | 1189 | return 0; |
1178 | 1190 | error: | |
1179 | vm_unacct_memory(pages); | 1191 | vm_unacct_memory(pages); |
1180 | 1192 | ||
1181 | return -ENOMEM; | 1193 | return -ENOMEM; |