linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Linux-2.6.11-rc5: kernel/sys.c setrlimit() RLIMIT_RSS cleanup
@ 2005-02-27 10:17 stone_wang
  2005-02-27 10:31 ` Andrew Morton
  2005-02-27 17:21 ` Rik van Riel
  0 siblings, 2 replies; 4+ messages in thread
From: stone_wang @ 2005-02-27 10:17 UTC (permalink / raw)
  To: riel, akpm; +Cc: linux-mm, Linux Kernel Mailing List


ulimit dont enforce RLIMIT_RSS now,while sys_setrlimit() pretend it(RLIMIT_RSS) is enforced. 

This may cause confusion to users, and may lead to un-guaranteed dependence on "ulimit -m" to limit users/applications.

The patch fixed the problem. 

-- snip from system run with patched(patch attached) 2.6.11-rc5 kernel
$ ulimit  -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 1024
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4091
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

$ ulimit  -m 100000
bash: ulimit: max memory size: cannot modify limit: Function not implemented

-
patch: 2.6.11-rc5 kernel/sys.c setrlimit() RLIMIT_RSS cleanup

Signed-Off-By: Stone Wang  <stone_wang@sohu.com>

diff -urpN linux-2.6.11-rc5-original/kernel/sys.c linux-2.6.11-rc5-cleanup/kernel/sys.c
--- linux-2.6.11-rc5-original/kernel/sys.c      2005-02-26 17:34:38.000000000 -0500
+++ linux-2.6.11-rc5-cleanup/kernel/sys.c       2005-02-27 17:27:20.000000000 -0500
@@ -1488,6 +1488,14 @@ asmlinkage long sys_setrlimit(unsigned i
        if (new_rlim.rlim_cur > new_rlim.rlim_max)
                return -EINVAL;
        old_rlim = current->signal->rlim + resource;
+
+       /* We dont enforce RLIMIT_RSS ulimit yet. But for application
+          compatability, we warn only when asked to change system default value. */
+       if( resource == RLIMIT_RSS &&
+           ((new_rlim.rlim_max != old_rlim->rlim_max)||
+            (new_rlim.rlim_cur != old_rlim->rlim_cur)) )
+               return -ENOSYS;
+
        if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
            !capable(CAP_SYS_RESOURCE))
                return -EPERM;

--
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:"aart@kvack.org"> aart@kvack.org </a>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Linux-2.6.11-rc5: kernel/sys.c setrlimit() RLIMIT_RSS cleanup
  2005-02-27 10:17 [PATCH] Linux-2.6.11-rc5: kernel/sys.c setrlimit() RLIMIT_RSS cleanup stone_wang
@ 2005-02-27 10:31 ` Andrew Morton
  2005-02-27 23:56   ` Peter Chubb
  2005-02-27 17:21 ` Rik van Riel
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2005-02-27 10:31 UTC (permalink / raw)
  To: stone_wang; +Cc: riel, linux-mm, linux-kernel

<stone_wang@sohu.com> wrote:
>
> $ ulimit  -m 100000
>  bash: ulimit: max memory size: cannot modify limit: Function not implemented

I don't know about this.  The change could cause existing applications and
scripts to fail.  Sure, we'll do that sometimes but this doesn't seem
important enough.
--
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:"aart@kvack.org"> aart@kvack.org </a>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Linux-2.6.11-rc5: kernel/sys.c setrlimit() RLIMIT_RSS cleanup
  2005-02-27 10:17 [PATCH] Linux-2.6.11-rc5: kernel/sys.c setrlimit() RLIMIT_RSS cleanup stone_wang
  2005-02-27 10:31 ` Andrew Morton
@ 2005-02-27 17:21 ` Rik van Riel
  1 sibling, 0 replies; 4+ messages in thread
From: Rik van Riel @ 2005-02-27 17:21 UTC (permalink / raw)
  To: stone_wang; +Cc: akpm, linux-mm, Linux Kernel Mailing List

On Sun, 27 Feb 2005 stone_wang@sohu.com wrote:

> ulimit dont enforce RLIMIT_RSS now,while sys_setrlimit() pretend 
> it(RLIMIT_RSS) is enforced.
> 
> This may cause confusion to users, and may lead to un-guaranteed 
> dependence on "ulimit -m" to limit users/applications.
> 
> The patch fixed the problem. 

Some kernels do enforce the RSS rlimit.  Your patch could break
systems that have the RSS rlimit in their configuration files
because they used to run a kernel that enforces the RSS rlimit.

-- 
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
--
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:"aart@kvack.org"> aart@kvack.org </a>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Linux-2.6.11-rc5: kernel/sys.c setrlimit() RLIMIT_RSS cleanup
  2005-02-27 10:31 ` Andrew Morton
@ 2005-02-27 23:56   ` Peter Chubb
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Chubb @ 2005-02-27 23:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: stone_wang, riel, linux-mm, linux-kernel

>>>>> "Andrew" == Andrew Morton <akpm@osdl.org> writes:

Andrew> <stone_wang@sohu.com> wrote:
>>  $ ulimit -m 100000 bash: ulimit: max memory size: cannot modify
>> limit: Function not implemented

Andrew> I don't know about this.  The change could cause existing
Andrew> applications and scripts to fail.  Sure, we'll do that
Andrew> sometimes but this doesn't seem important enough. 

What's more, there have been (and still are) out-of-tree patches to
enforce rlimit-RSS in various ways.  There just hasn't been consensus
yet on the best implementation.

-- 
Dr Peter Chubb  http://www.gelato.unsw.edu.au  peterc AT gelato.unsw.edu.au
The technical we do immediately,  the political takes *forever*
--
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:"aart@kvack.org"> aart@kvack.org </a>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-02-27 23:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-27 10:17 [PATCH] Linux-2.6.11-rc5: kernel/sys.c setrlimit() RLIMIT_RSS cleanup stone_wang
2005-02-27 10:31 ` Andrew Morton
2005-02-27 23:56   ` Peter Chubb
2005-02-27 17:21 ` Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox