We currently migrate to MediaWiki from our old installation, but not all content has been migrated yet. Take a look at the Wiki Team page for instructions how to help or browse through our new wiki at wiki.linux-vserver.org to find the information already migrated.

u/rlimits (vs2.0)

Limit ProcFS config Code Unit Description
-t CPU   cpu U- s amount of cpu time in seconds
-f FSIZE   fsize U- kb size of files created by the shell
-d DATA   data U- kb size of a process's data segment
-s STACK   stack U- kb stack size
-c CORE   core U- kb size of core files created
-m RSS RSS rss -R page resident set size
-u NPROC PROC nproc UR 1 number of processes
-n NOFILE FILES nofile UR 1 number of file handles
-l MEMLOCK VML memlock UR page pages locked into memory
-v AS/VM VM as -R page virtual memory pages
-? LOCKS LOCKS locks UR 1 file system locks
-? SIGPENDING    Ur 1 pending signals
-p MSGQUEUE MSGQ   -r 512b message queue size
-? NICE    U- 1 minimum nice level
-? RTPRIO    U- 1 maximum realtime prio
-- NSOCK (16) SOCK   -R 1 number of sockets
-- OPENFD (17) OFD   -R 1 number of file descriptors
-- ANON (18) ANON   -r page anonymous memory pages
-- SHMEM (19) SHM   -r page shared memory pages

Code Description
U ... ulimit (supported)
R ... rlimit (fully supported)
r ... rlimit (accounted/planned)
- ... unsupported

Note: The basic unit of memory is the page. Nobody knows how large a page is, this is architecture-dependent, but typically PAGE_SIZE = 4096. (PAGE_SIZE equals 1 << PAGE_SHIFT, and PAGE_SHIFT is 12, 13, 14, 15, 16 on the various architectures). If one is lucky, the getpagesize() system call returns the page size.

Resource Limiting The Whole VServer

RSS and AS, at least, can be applied across the whole VServer. See Caps And Flags for details.


For example, if RSS (the real memory) and VM (the virtual address space) should be restricted, the appropriate config files could be the following. Note that you might have to create these directories.

# ls -al /etc/vservers/vs27/rlimits
total 28
drwxr-xr-x  2 root root 4096 2005-08-24 12:37 .
drwxr-xr-x  5 root root 4096 2005-08-24 00:22 ..
-rw-r--r--  1 root root    6 2005-08-24 12:43 as
-rw-r--r--  1 root root    6 2005-08-24 00:36 memlock
-rw-r--r--  1 root root    5 2005-08-24 12:42 nproc
-rw-r--r--  1 root root    6 2005-08-24 12:37 rss

# cat /etc/vservers/vs27/rlimits/rss

# cat /etc/vservers/vs27/rlimits/as

ProcFS shows current values of the limits:

# cat /proc/virtual/27/limit
PROC:            6              18            5000           0
VM:           3705           23158           90000           0
VML:             0               0           10000           0
RSS:          1344            7965           10000           0
ANON:          205             205              -1           0
FILES:          87             150              -1           0
OFD:            37              37              -1           0
LOCKS:           2               6              -1           0
SOCK:            3               3              -1           0
MSGQ:            0               0              -1           0
SHM:             0               0              -1           0

Columns are:

  1. (short) name
  2. current value
  3. observed maximum
  4. hard limit (maximum)
  5. number of hits (max)

So column 5 shows how often the maximum was reached and the kernel had to deny a resource request.

To be continued ...

Determining Page Size

You can use this program to determine the page size for your architecture (if it supports the getpagesize() function)

#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>

int main(int argc, char *argv[])
        int page_size = getpagesize();
        printf("The page size is %d\n", page_size);

Here's how to compile and run it (assuming you save it as pagesize.c):

# gcc pagesize.c -o pagesize
# ./pagesize 
The page size is 4096

The following snippet from the getpagesize man page has some interesting information:

"Whether getpagesize() is present as a Linux system call depends on the architecture. If it is, it returns the kernel symbol PAGE_SIZE, which is architecture and machine model dependent. Generally, one uses binaries that are architecture but not machine model dependent, in order to have a single binary distribution per architecture. This means that a user program should not find PAGE_SIZE at compile time from a header file, but use an actual system call, at least for those architectures (like sun4) where this dependency exists. Here libc4, libc5, glibc 2.0 fail because their getpagesize() returns a statically derived value, and does not use a system call. Things are OK in glibc 2.1."

If you prefer, you can get the pagesize also using python, just start a python console and write:

>>> import resource
>>> resource.getpagesize()