Skip to contentSkip to conversation

mm: limit growth of 3% hardcoded other user reserve

PATCH Superseded Andrew Shewmaker 1 participant 1 message Mar 1, 2013

Subsystems (2)

v3 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 mm: limit growth of 3% hardcoded other user reserve

Limit the growth of the memory reserved for other processes to the smaller of 3% or 2000 pages.

This affects OVERCOMMIT_NEVER mode.

---

I had simply removed the reserve previously, but that caused forks to fail easily. This allows a user to recover similar to the simple 3% reserve, but allows a single process to allocate more memory.

Alan suggested the min(3%, k), and I've k=2000 pages seems to work well. It allows enough free pages to for sshd, bash, and top, in case some sort of recovery is necessary. Of course, memory will still be exhausted eventually.

mm/mmap.c +3 -2
index d1e4124..6134b1d 100644
@@ -183,9 +183,10 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
 	allowed += total_swap_pages;
 
 	/* Don't let a single process grow too big:
-	   leave 3% of the size of this process for other processes */
+	 * leave the smaller of 3% of the size of this process 
+         * or 2000 pages for other processes */
 	if (mm)
-		allowed -= mm->total_vm / 32;
+		allowed -= min(mm->total_vm / 32, 2000UL);
 
 	if (percpu_counter_read_positive(&vm_committed_as) < allowed)
 		return 0;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>