Skip to contentSkip to conversation

mm: limit growth of 3% hardcoded other user reserve

PATCH Superseded Andrew Shewmaker 2 participants 3 messages Mar 5, 2013 – Mar 6, 2013

Subsystems (2)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 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 8MB.

This affects only OVERCOMMIT_NEVER.

---

Rebased onto v3.8-mmotm-2013-03-01-15-50

No longer assumes 4kb pages.
Code duplicated for nommu.

mm/mmap.c +4 -2
index 49dc7d5..4eb2b1a 100644
@@ -184,9 +184,11 @@ 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 8MB for other processes
+         */
 	if (mm)
-		allowed -= mm->total_vm / 32;
+		allowed -= min(mm->total_vm / 32, 1 << (23 - PAGE_SHIFT));
 
 	if (percpu_counter_read_positive(&vm_committed_as) < allowed)
 		return 0;
mm/nommu.c +4 -2
index f5d57a3..a93d214 100644
@@ -1945,9 +1945,11 @@ 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 8MB for other processes
+         */
 	if (mm)
-		allowed -= mm->total_vm / 32;
+		allowed -= min(mm->total_vm / 32, 1 << (23 - PAGE_SHIFT));
 
 	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>

#1 lore raw
Quoted 6 lines · Andrew Shewmaker

Limit the growth of the memory reserved for other processes to the smaller of 3% or 8MB.

This affects only OVERCOMMIT_NEVER.

Please add changelog, otherwise it's for other guys to review.

Quoted 34 lines

---

Rebased onto v3.8-mmotm-2013-03-01-15-50

No longer assumes 4kb pages.
Code duplicated for nommu.

mm/mmap.c +4 -2
index 49dc7d5..4eb2b1a 100644
@@ -184,9 +184,11 @@ 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 8MB for other processes
+         */
  	if (mm)
-		allowed -= mm->total_vm / 32;
+		allowed -= min(mm->total_vm / 32, 1 << (23 - PAGE_SHIFT));
 
  	if (percpu_counter_read_positive(&vm_committed_as) < allowed)
  		return 0;
mm/nommu.c +0 -0
index f5d57a3..a93d214 100644
@@ -1945,9 +1945,11 @@ 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:

mm/nommu.c int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) · line 1955

Quoted 10 lines
mm/nommu.c +4 -2
-	   leave 3% of the size of this process for other processes */
+	 * leave the smaller of 3% of the size of this process
+         * or 8MB for other processes
+         */
  	if (mm)
-		allowed -= mm->total_vm / 32;
+		allowed -= min(mm->total_vm / 32, 1 << (23 - PAGE_SHIFT));
 
  	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>

#2 lore raw
Quoted 10 lines · Simon Jeons
Quoted 6 lines · Andrew Shewmaker

Limit the growth of the memory reserved for other processes to the smaller of 3% or 8MB.

This affects only OVERCOMMIT_NEVER.

Please add changelog, otherwise it's for other guys to review.

Sorry, I'll be sure to include one in the future. And it looks like I do need a v5 ... I think this needs to be tunable like the admin reserve. The default certainly needs to be higher since this reserve is only for OVERCOMMIT_NEVER mode and 8MB is too little to allow the user to recover. I was thinking of OVERCOMMIT_GUESS mode when I chose it.

v4:
* Rebased onto v3.8-mmotm-2013-03-01-15-50
* No longer assumes 4kb pages
* Code duplicated for nommu

v3:
* New patch summary because it wasn't unique
New is "mm: limit growth of 3% hardcoded other user reserve" Old was "mm: tuning hardcoded reserve memory"
* Limits growth to min(3% process size, some constant k) as Alan Cox suggested. I chose k=2000 pages (8MB) to allow recovery with sshd or login, bash, and top or kill

v2:
* Rebased onto v3.8-mmotm-2013-02-19-17-20

v1:
* Based on 3.8
* Remove hardcoded 3% other user reserve in OVERCOMMIT_NEVER mode

Quoted 32 lines
Quoted 32 lines

---

Rebased onto v3.8-mmotm-2013-03-01-15-50

No longer assumes 4kb pages.
Code duplicated for nommu.

mm/mmap.c +4 -2
index 49dc7d5..4eb2b1a 100644
@@ -184,9 +184,11 @@ 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 8MB for other processes
+         */
 	if (mm)
-		allowed -= mm->total_vm / 32;
+		allowed -= min(mm->total_vm / 32, 1 << (23 - PAGE_SHIFT));
 	if (percpu_counter_read_positive(&vm_committed_as) < allowed)
 		return 0;
mm/nommu.c +0 -1
index f5d57a3..a93d214 100644
@@ -1945,9 +1945,11 @@ 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 */
Quoted 9 lines

mm/nommu.c int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) · line 1953

Quoted 8 lines
mm/nommu.c +4 -1
+	 * leave the smaller of 3% of the size of this process
+         * or 8MB for other processes
+         */
 	if (mm)
-		allowed -= mm->total_vm / 32;
+		allowed -= min(mm->total_vm / 32, 1 << (23 - PAGE_SHIFT));
 	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>