From: Matt <matthew.keenan@ntlworld.com>
To: unlisted-recipients:; (no To-header on input)
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] BUG #3054 madvise doesn't fail for exceding RSS limit.
Date: Sat, 04 Jun 2005 23:56:08 +0100 [thread overview]
Message-ID: <42A23188.8080100@ntlworld.com> (raw)
In-Reply-To: <42A23047.5000600@ntlworld.com>
sorry that error return should be -EIO not -ENOMEM, sorry! new patch
attached.
--- linux-2.6.11.10/mm/madvise.c 2005-04-12 15:58:30.000000000 +0100
+++ linux/mm/madvise.c 2005-06-04 23:25:03.000000000 +0100
@@ -70,6 +70,17 @@
end = vma->vm_end;
end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
+ /*
+ * This doesn't account for pages that may already be mapped
+ * due to readahead, but since this is merely a hint to the
+ * kernel no real harm should be done, it will just make things
+ * run a little slower. Sometimes less is more! More than enough
+ * code for this minor corner case.
+ */
+ if (((max_sane_readahead(end-start) <<
PAGE_SHIFT)+current->mm->rss)>
+ current->signal->rlim[RLIMIT_RSS].rlim_cur)
+ return -EIO;
+
force_page_cache_readahead(file->f_mapping,
file, start, max_sane_readahead(end - start));
return 0;
Matt wrote:
> Patch that fixes bug #3054. Compiles, tests ok.
>
> --- linux-2.6.11.10/mm/madvise.c 2005-05-12 15:58:30.000000000 +0100
> +++ linux/mm/madvise.c 2005-06-04 23:25:03.000000000 +0100
> @@ -70,6 +70,17 @@
> end = vma->vm_end;
> end = ((end - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
>
> + /*
> + * This doesn't account for pages that may already be mapped
> + * due to readahead, but since this is merely a hint to the
> + * kernel no real harm should be done, it will just make things
> + * run a little slower. Sometimes less is more! More than enough
> + * code for this minor corner case.
> + */
> + if (((max_sane_readahead(end-start) <<
> PAGE_SHIFT)+current->mm->rss)>
> + current->signal->rlim[RLIMIT_RSS].rlim_cur)
> + return -ENOMEM;
> +
> force_page_cache_readahead(file->f_mapping,
> file, start, max_sane_readahead(end - start));
> return 0;
>
>
prev parent reply other threads:[~2005-06-04 22:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-04 22:50 [PATCH] BUG #3054 madvise doesn't fail for exceding RSS limit Matt
2005-06-04 22:56 ` Matt [this message]
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=42A23188.8080100@ntlworld.com \
--to=matthew.keenan@ntlworld.com \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox