From: "Jörn Engel" <joern@logfs.org>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH, RFC] mm: Implement RLIMIT_RSS
Date: Tue, 11 Jun 2013 14:29:21 -0400 [thread overview]
Message-ID: <20130611182921.GB25941@logfs.org> (raw)
I've seen a couple of instances where people try to impose a vsize
limit simply because there is no rss limit in Linux. The vsize limit
is a horrible approximation and even this patch seems to be an
improvement.
Would there be strong opposition to actually supporting RLIMIT_RSS?
JA?rn
--
It's not whether you win or lose, it's how you place the blame.
-- unknown
Not quite perfect, but close enough for many purposes. This checks rss
limit inside may_expand_vm() and will fail if we are already over the
limit.
Signed-off-by: Joern Engel <joern@logfs.org>
---
mm/mmap.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index ab652fa..ea90c73 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2446,12 +2446,19 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
int may_expand_vm(struct mm_struct *mm, unsigned long npages)
{
unsigned long cur = mm->total_vm; /* pages */
- unsigned long lim;
+ unsigned long lim, rlim;
lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
+ rlim = rlimit(RLIMIT_RSS) >> PAGE_SHIFT;
if (cur + npages > lim)
return 0;
+ if (cur + npages > rlim) {
+ /* Yes, the rss limit is somewhat imprecise. */
+ if (get_mm_rss(mm) > rlim) {
+ return 0;
+ }
+ }
return 1;
}
--
1.7.10.4
--
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>
WARNING: multiple messages have this Message-ID (diff)
From: "Jörn Engel" <joern@logfs.org>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH, RFC] mm: Implement RLIMIT_RSS
Date: Tue, 11 Jun 2013 14:29:21 -0400 [thread overview]
Message-ID: <20130611182921.GB25941@logfs.org> (raw)
I've seen a couple of instances where people try to impose a vsize
limit simply because there is no rss limit in Linux. The vsize limit
is a horrible approximation and even this patch seems to be an
improvement.
Would there be strong opposition to actually supporting RLIMIT_RSS?
Jörn
--
It's not whether you win or lose, it's how you place the blame.
-- unknown
Not quite perfect, but close enough for many purposes. This checks rss
limit inside may_expand_vm() and will fail if we are already over the
limit.
Signed-off-by: Joern Engel <joern@logfs.org>
---
mm/mmap.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index ab652fa..ea90c73 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2446,12 +2446,19 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
int may_expand_vm(struct mm_struct *mm, unsigned long npages)
{
unsigned long cur = mm->total_vm; /* pages */
- unsigned long lim;
+ unsigned long lim, rlim;
lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
+ rlim = rlimit(RLIMIT_RSS) >> PAGE_SHIFT;
if (cur + npages > lim)
return 0;
+ if (cur + npages > rlim) {
+ /* Yes, the rss limit is somewhat imprecise. */
+ if (get_mm_rss(mm) > rlim) {
+ return 0;
+ }
+ }
return 1;
}
--
1.7.10.4
next reply other threads:[~2013-06-11 19:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-11 18:29 Jörn Engel [this message]
2013-06-11 18:29 ` [PATCH, RFC] mm: Implement RLIMIT_RSS Jörn Engel
2013-06-11 21:16 ` Johannes Weiner
2013-06-11 21:16 ` Johannes Weiner
2013-06-11 21:53 ` Jörn Engel
2013-06-11 21:53 ` Jörn Engel
2013-06-13 8:57 ` Minchan Kim
2013-06-13 8:57 ` Minchan Kim
2013-06-13 14:43 ` Jörn Engel
2013-06-13 14:43 ` Jörn Engel
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=20130611182921.GB25941@logfs.org \
--to=joern@logfs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.