From: Roman Gushchin <klamm@yandex-team.ru>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org,
Roman Gushchin <klamm@yandex-team.ru>,
Andrew Morton <akpm@linux-foundation.org>,
Andrew Shewmaker <agshew@gmail.com>,
Rik van Riel <riel@redhat.com>,
Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Subject: [PATCH] mm: don't account shared file pages in user_reserve_pages
Date: Thu, 29 Jan 2015 14:51:27 +0300 [thread overview]
Message-ID: <1422532287-23601-1-git-send-email-klamm@yandex-team.ru> (raw)
Shared file pages are never accounted in memory overcommit code,
so it isn't reasonable to count them in a code that limits the
maximal size of a process in OVERCOMMIT_NONE mode.
If a process has few large file mappings, the consequent attempts
to allocate anonymous memory may unexpectedly fail with -ENOMEM,
while there is free memory and overcommit limit if significantly
larger than the committed amount (as displayed in /proc/meminfo).
The problem is significantly smoothed by commit c9b1d0981fcc
("mm: limit growth of 3% hardcoded other user reserve"),
which limits the impact of this check with 128Mb (tunable via sysctl),
but it can still be a problem on small machines.
Signed-off-by: Roman Gushchin <klamm@yandex-team.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrew Shewmaker <agshew@gmail.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
mm/mmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index 7f684d5..151fadf 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -220,7 +220,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
*/
if (mm) {
reserve = sysctl_user_reserve_kbytes >> (PAGE_SHIFT - 10);
- allowed -= min(mm->total_vm / 32, reserve);
+ allowed -= min((mm->total_vm - mm->shared_vm) / 32, reserve);
}
if (percpu_counter_read_positive(&vm_committed_as) < allowed)
--
2.1.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>
next reply other threads:[~2015-01-29 11:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 11:51 Roman Gushchin [this message]
2015-01-29 20:11 ` Andrew Shewmaker
2015-01-30 13:30 ` Konstantin Khlebnikov
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=1422532287-23601-1-git-send-email-klamm@yandex-team.ru \
--to=klamm@yandex-team.ru \
--cc=agshew@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=riel@redhat.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