From: Andrew Shewmaker <agshew@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
alan@lxorguk.ukuu.org.uk, simon.jeons@gmail.com,
ric.masonn@gmail.com
Subject: [PATCH v3 001/002] mm: limit growth of 3% hardcoded other user reserve
Date: Fri, 1 Mar 2013 18:32:08 -0500 [thread overview]
Message-ID: <20130301233208.GA1848@localhost.localdomain> (raw)
Limit the growth of the memory reserved for other processes
to the smaller of 3% or 2000 pages.
This affects OVERCOMMIT_NEVER mode.
Signed-off-by: Andrew Shewmaker <agshew@gmail.com>
---
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.
diff --git a/mm/mmap.c b/mm/mmap.c
index d1e4124..6134b1d 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -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 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>
reply other threads:[~2013-03-01 23:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130301233208.GA1848@localhost.localdomain \
--to=agshew@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ric.masonn@gmail.com \
--cc=simon.jeons@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).