On Sun, Feb 22, 2004 at 12:55:38PM +0100, Martin Schulze scribbled:
> Marek Habersack wrote:
> > Hey,
> >
> > I've just noticed that the two sources disagree on the units used for the
> > RLIMIT_RSS resource. libc docs claim that all the memory limits are
> > expressed in bytes while setrlimit(2) claims RLIMIT_RSS size is in pages
> > (which bash's ulimit seems to agree with).
> > The kernel seems to agree with the libc docs. So, should I file a bug
> > against the manpages or the libc docs?
>
> Manual pages from the man-pages project/package document the standard,
> not primarily its implementation from random entities, even if the
> entity in question may be the Free Software Foundation.
The thing is that RLIMIT_RSS is not documented by any standard (unless you
count the *BSD manpages[1,2,3] as one). I have looked closely at the 2.4 kernel
sources and it seems that linux does it the other way around and, indeed,
the RLIMIT_RSS is in pages (as evidenced by [4,5] - PAGE_SHIFT is a macro
that defines the number of bits by which a value must be left/right shifted
in order to obtain memory size in pages/bytes respectively. It's
architecture-specific).
> However, if you can prove, by quoting the source, that libc behaves
> different than what is written in our manpages, I'm willing to add
> a note and pass it upstream, who may reject it, though.
The comments in the bits/resource.h file confirm that libc thinks the
amount is in bytes and I can't find any place where libc converts the value
passed by the user to pages. Therefore, if somebody believes the libc
docs/headers/sources, they will end up passing an incorrect value for the
limit to the kernel (not that it matters on kernel v2.6)
I've already reassigned Bug#234139 to libc6 and I'm Cc'ing this mail to the
BTS since it corrects the mistake I made in the bug report.
sorry for the initial confusion and thanks,
marek
[1] http://www.freebsd.org/cgi/man.cgi?query=setrlimit&sektion=0&manpath=FreeBSD+5.2-RELEASE+and+Ports&format=html
[2] http://netbsd.gw.com/cgi-bin/man-cgi?setrlimit++NetBSD-current
[3] http://www.openbsd.org/cgi-bin/man.cgi?query=setrlimit&sektion=0&manpath=OpenBSD+Current&format=html
[4] http://lxr.linux.no/source/mm/filemap.c?v=2.4.22#L2518
[5] http://lxr.linux.no/source/fs/proc/array.c?v=2.4.22#L213