All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kingsley Cheung <kingsley@aurema.com>
To: linux-kernel@vger.kernel.org
Cc: trivial@rustcorp.com.au
Subject: [TRIVIAL PATCH 2.4.20] madvise_willneed makes bad limit comparison
Date: Mon, 9 Dec 2002 15:04:26 +1100	[thread overview]
Message-ID: <20021209150426.D12270@aurema.com> (raw)

Hi,

'madvise_willneed' makes an incorrect rss limit comparison.  It
directly compares rlim[RLIMIT_RSS].rlim_cur to rss. The former is in
bytes, whereas the latter is in pages.  The fix for this is trivial.

[As an aside, one question is whether this limit check is needed at
all.  Most rss limit enforcement implementations that I've seen are
'soft', whereas this would give the limit 'hard' semantics.  Do we
really want 'hard' limit semantics?]


diff -urN linux-2.4.20/mm/filemap.c linux-2.4.20patched/mm/filemap.c
--- linux-2.4.20/mm/filemap.c   Mon Dec  9 14:19:13 2002
+++ linux-2.4.20patched/mm/filemap.c    Mon Dec  9 14:36:08 2002
@@ -2471,10 +2471,12 @@
 
        /* Make sure this doesn't exceed the process's max rss. */
        error = -EIO;
-       rlim_rss = current->rlim ?  current->rlim[RLIMIT_RSS].rlim_cur :
-                               LONG_MAX; /* default: see resource.h */
-       if ((vma->vm_mm->rss + (end - start)) > rlim_rss)
-               return error;
+       rlim_rss = current->rlim[RLIMIT_RSS].rlim_cur;
+       if (rlim_rss != RLIM_INFINITY) {
+               rlim_rss >>= PAGE_SHIFT;
+               if ((vma->vm_mm->rss + (end - start)) > rlim_rss)
+                       return error;
+       }
 
        /* round to cluster boundaries if this isn't a "random" area. */
        if (!VM_RandomReadHint(vma)) {


--
		Kingsley

             reply	other threads:[~2002-12-09  3:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-09  4:04 Kingsley Cheung [this message]
2002-12-09  4:53 ` [TRIVIAL PATCH 2.5.50] madvise_willneed makes bad limit comparison Kingsley Cheung
2002-12-09  6:29 ` [TRIVIAL PATCH 2.4.20] " Andrew Morton
2002-12-10  6:08   ` Kingsley Cheung
2002-12-10  7:55     ` Andrew Morton
2002-12-09 19:27 ` Andrew Morton

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=20021209150426.D12270@aurema.com \
    --to=kingsley@aurema.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trivial@rustcorp.com.au \
    /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.