RCTL(8)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… rctl(8) β€” display and update resource limits database

okay so you found the resource limits page, bestie. this is rctl from the System Manager's Manual, section 8, and it's literally the tool that controls how much of everything a process is allowed to eat. she's giving system admin main character energy and honestly? iconic. let's get into it πŸŽ€


✨ NAME ✨

rctl β€” display and update resource limits database


πŸ¦‹ SYNOPSIS πŸ¦‹

rctl [-h] [-n] [filter ...]
rctl -a rule ...
rctl -l [-h] [-n] filter ...
rctl -r filter ...
rctl -u [-h] filter ...

🌸 DESCRIPTION 🌸

so when you just run rctl with zero options, she writes all the currently defined RCTL rules to standard output. that's it. that's the vibe check. πŸ’–

and if you throw a filter argument in there, you only see the rules that match that filter. slay.

the options are as follows, no cap:

  • -a rule β€” add rule to the RCTL database. new rule, who dis ✨
  • -l filter β€” display the rules applicable to the process defined by filter. and listen, this is not the same as just showing rules with no options β€” this one shows you not just the rules whose subject equals that of the process, but ALSO the rules for the user, jail, and login class that apply to the process. she's thorough, we love that 🫢
  • -r filter β€” remove rules matching filter from the RCTL database. bye bestie πŸ‘‹
  • -u filter β€” display resource utilization for a subject (process, user, loginclass or jail) matching the filter. we're nosy and we're checking the stats πŸ“Š
  • -h β€” "human-readable" output. use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte. no more squinting at giant numbers, we're being nice to ourselves πŸ’…
  • -n β€” display user IDs numerically rather than converting them to a user name. numbers only, no names, she's mysterious πŸ™ˆ
modifications to rules affect all currently running and future processes matching the rule. like, all of them. not just the new ones. periodt πŸ”₯

⭐ RULE SYNTAX ⭐

here's the shape of a rule, memorize it iykyk:

subject:subject-id:resource:action=amount/per
  • subject β€” defines the kind of entity the rule applies to. it can be either process, user, loginclass, or jail.
  • subject-id β€” identifies the subject. it can be a process ID, user name, numerical user ID, login class name from login.conf(5), or jail name.
  • resource β€” identifies the resource the rule controls. see the "RESOURCES" section below for details.
  • action β€” defines what will happen when a process exceeds the allowed amount. see the "ACTIONS" section below for details.
  • amount β€” defines how much of the resource a process can use before the defined action triggers. resources which limit bytes may use prefixes from expand_number(3).
  • per β€” defines what entity the amount gets accounted for.

okay so the per field needs examples because it's lowkey the whole personality of this tool:

  • rule "loginclass:users:vmemoryuse:deny=100M/process" means that each process of any user belonging to login class "users" may allocate up to 100MB of virtual memory.
  • rule "loginclass:users:vmemoryuse:deny=100M/user" would mean that for each user belonging to the login class "users", the sum of virtual memory allocated by all the processes of that user will not exceed 100MB.
  • rule "loginclass:users:vmemoryuse:deny=100M/loginclass" would mean that the sum of virtual memory allocated by all processes of all users belonging to that login class will not exceed 100MB.

see the difference? same rule, different accounting vibes. she contains multitudes πŸ’œ

a valid rule has all those fields specified, except for per, which defaults to the value of subject.

a filter is a rule for which one or more fields other than per is left empty. for example:

  • a filter that matches every rule could be written as ":::=/", or, in short, ":".
  • a filter that matches all the login classes would be "loginclass:".
  • a filter that matches all defined rules for maxproc resource would be "::maxproc".

filters are literally the wildcards of this whole situation, obsessed πŸ¦‹


🧚 SUBJECTS 🧚

  • process β€” numerical Process ID
  • user β€” user name or numerical User ID
  • loginclass β€” login class from login.conf(5)
  • jail β€” jail name

🌈 RESOURCES 🌈

  • cputime β€” CPU time, in seconds
  • datasize β€” data size, in bytes
  • stacksize β€” stack size, in bytes
  • coredumpsize β€” core dump size, in bytes
  • memoryuse β€” resident set size, in bytes
  • memorylocked β€” locked memory, in bytes
  • maxproc β€” number of processes
  • openfiles β€” file descriptor table size
  • vmemoryuse β€” address space limit, in bytes
  • pseudoterminals β€” number of PTYs
  • swapuse β€” swap space that may be reserved or used, in bytes
  • nthr β€” number of threads
  • msgqqueued β€” number of queued SysV messages
  • msgqsize β€” SysV message queue size, in bytes
  • nmsgq β€” number of SysV message queues
  • nsem β€” number of SysV semaphores
  • nsemop β€” number of SysV semaphores modified in a single semop(2) call
  • nshm β€” number of SysV shared memory segments
  • shmsize β€” SysV shared memory size, in bytes
  • wallclock β€” wallclock time, in seconds
  • pcpu β€” %CPU, in percents of a single CPU core
  • readbps β€” filesystem reads, in bytes per second
  • writebps β€” filesystem writes, in bytes per second
  • readiops β€” filesystem reads, in operations per second
  • writeiops β€” filesystem writes, in operations per second

πŸ”₯ ACTIONS πŸ”₯

  • deny β€” deny the allocation; not supported for cputime, wallclock, readbps, writebps, readiops, and writeiops
  • log β€” log a warning to the console
  • devctl β€” send notification to devd(8) using system = "RCTL", subsystem = "rule", type = "matched"
  • sig* β€” e.g. sigterm; send a signal to the offending process. see signal(3) for a list of supported signals
  • throttle β€” slow down process execution; only supported for readbps, writebps, readiops, and writeiops
⚠️ not all actions are supported for all resources. attempting to add a rule with an action not supported by a given resource will result in error. she will simply refuse, and honestly? valid πŸ’€

πŸ’€ EXIT STATUS πŸ’€

the rctl utility exits 0 on success, and >0 if an error occurs. clean and simple, no drama ✨


πŸ“ EXAMPLES πŸ“

prevent user "joe" from allocating more than 1GB of virtual memory:

rctl -a user:joe:vmemoryuse:deny=1g

remove all RCTL rules:

rctl -r :

display resource utilization information for jail named "www":

rctl -hu jail:www

display all the rules applicable to process with PID 512:

rctl -l process:512

display all rules:

rctl

display all rules matching user "joe":

rctl user:joe

display all rules matching login classes:

rctl loginclass:

πŸ’– SEE ALSO πŸ’–

cpuset(1), rctl(4), rctl.conf(5)


πŸ‘‘ HISTORY πŸ‘‘

the rctl command appeared in FreeBSD 9.0. vintage but make it functional πŸ’…


🫢 AUTHORS 🫢

the rctl was developed by Edward Tomasz Napierala <trasz@FreeBSD.org> under sponsorship from the FreeBSD Foundation. king behavior, we stan 🌟


😭 BUGS 😭

okay bestie, read this part carefully because it's giving cautionary tale:

  • limiting memoryuse may kill the machine due to thrashing. like, the whole machine. not a drill πŸ’€
  • the readiops and writeiops counters are only approximations. like readbps and writebps, they are calculated in the filesystem layer, where it is difficult or even impossible to observe actual disk device operations. she's doing her best with what she's got πŸ™ˆ
  • the writebps and writeiops resources generally account for writes to the filesystem cache, not to actual devices. just so you know. no cap.

and that's the page, bestie!! πŸ¦‹ this one was brought to you by the Debian build, dated February 26, 2018 β€” go forth and allocate responsibly, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from