linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 001/002] mm: limit growth of 3% hardcoded other user reserve
@ 2013-03-05 23:38 Andrew Shewmaker
  2013-03-05 23:46 ` Simon Jeons
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Shewmaker @ 2013-03-05 23:38 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, alan, simon.jeons, ric.masonn

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

This affects only OVERCOMMIT_NEVER.

Signed-off-by: Andrew Shewmaker <agshew@gmail.com>

---

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

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

diff --git a/mm/mmap.c b/mm/mmap.c
index 49dc7d5..4eb2b1a 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -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;
diff --git a/mm/nommu.c b/mm/nommu.c
index f5d57a3..a93d214 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -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 majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-06 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-05 23:38 [PATCH v4 001/002] mm: limit growth of 3% hardcoded other user reserve Andrew Shewmaker
2013-03-05 23:46 ` Simon Jeons
2013-03-06  0:37   ` Andrew Shewmaker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).