[TRIVIAL PATCH 2.4.20] madvise_willneed makes bad limit comparison

From: Kingsley Cheung (kingsley@aurema.com)
Date: Sun Dec 08 2002 - 23:04:26 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Dec 15 2002 - 22:00:13 EST