2 .\" Copyright (c) 2009 Edward Tomasz Napierala
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE
18 .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 .\" POSSIBILITY OF SUCH DAMAGE.
33 .Nd display and update resource limits database
56 requires the kernel to be compiled with:
57 .Bd -ragged -offset indent
62 When called without options, the
64 command writes currently defined RCTL rules to standard output.
68 argument is specified, only rules matching the filter are displayed.
69 The options are as follows:
70 .Bl -tag -width indent
76 Display rules applicable to the process defined by
78 Note that this is different from showing the rules when called without
79 any options, as it shows not just the rules with subject equal to that
80 of process, but also rules for the user, jail, and login class applicable
85 from the RCTL database.
87 Display resource usage for a subject
98 "Human-readable" output.
99 Use unit suffixes: Byte, Kilobyte, Megabyte,
100 Gigabyte, Terabyte and Petabyte.
102 Display user IDs numerically rather than converting them to a user name.
105 Modifying rules affects all currently running and future processes matching
108 Syntax for a rule is subject:subject-id:resource:action=amount/per.
110 .Bl -tag -width "subject-id" -compact -offset indent
112 defines the kind of entity the rule applies to.
122 It can be a process ID, user name, numerical user ID, login class name from
126 identifies the resource the rule controls.
129 section below for details.
131 defines what will happen when a process exceeds the allowed
135 section below for details.
137 defines how much of the resource a process can use before
141 Resources which limit bytes may use prefixes from
142 .Xr expand_number 3 .
144 defines what entity the
147 For example, rule "loginclass:users:vmem:deny=100M/process" means
148 that each process of any user belonging to login class "users" may allocate
149 up to 100MB of virtual memory.
150 Rule "loginclass:users:vmem:deny=100M/user" would mean that for each
151 user belonging to the login class "users", the sum of virtual memory allocated
152 by all the processes of that user will not exceed 100MB.
153 Rule "loginclass:users:vmem:deny=100M/loginclass" would mean that the sum of
154 virtual memory allocated by all processes of all users belonging to that login
155 class will not exceed 100MB.
158 A valid rule has all those fields specified, except for
164 A filter is a rule for which one of more fields other than
167 For example, a filter that matches every rule could be written as ":::=/",
169 A filter that matches all the login classes would be "loginclass:".
170 A filter that matches all defined rules for
175 .Bl -column -offset 3n "pseudoterminals" ".Sy username or numerical User ID"
176 .It Em subject Ta Em subject-id
177 .It Sy process Ta numerical Process ID
178 .It Sy user Ta user name or numerical User ID
179 .It Sy loginclass Ta login class from
181 .It Sy jail Ta jail name
184 .Bl -column -offset 3n "pseudoterminals"
186 .It Sy cputime Ta "CPU time, in seconds"
187 .It Sy datasize Ta "data size, in bytes"
188 .It Sy stacksize Ta "stack size, in bytes"
189 .It Sy coredumpsize Ta "core dump size, in bytes"
190 .It Sy memoryuse Ta "resident set size, in bytes"
191 .It Sy memorylocked Ta "locked memory, in bytes"
192 .It Sy maxproc Ta "number of processes"
193 .It Sy openfiles Ta "file descriptor table size"
194 .It Sy vmemoryuse Ta "address space limit, in bytes"
195 .It Sy pseudoterminals Ta "number of PTYs"
196 .It Sy swapuse Ta "swap space that may be reserved or used, in bytes"
197 .It Sy nthr Ta "number of threads"
198 .It Sy msgqqueued Ta "number of queued SysV messages"
199 .It Sy msgqsize Ta "SysV message queue size, in bytes"
200 .It Sy nmsgq Ta "number of SysV message queues"
201 .It Sy nsem Ta "number of SysV semaphores"
202 .It Sy nsemop Ta "number of SysV semaphores modified in a single semop(2) call"
203 .It Sy nshm Ta "number of SysV shared memory segments"
204 .It Sy shmsize Ta "SysV shared memory size, in bytes"
205 .It Sy wallclock Ta "wallclock time, in seconds"
206 .It Sy pcpu Ta "%CPU, in percents of a single CPU core"
209 .Bl -column -offset 3n "pseudoterminals"
211 .It Sy deny Ta deny the allocation; not supported for
215 .It Sy log Ta "log a warning to the console"
216 .It Sy devctl Ta "send notification to"
227 send a signal to the offending process.
230 for a list of supported signals
233 Not all actions are supported for all resources.
234 Attempting to add a rule with an action not supported by a given resource will
237 Tunables can be set at the
241 .Bl -tag -width indent
242 .It Va kern.racct.enable: No 1
245 This defaults to 1, unless
246 .Cd "options RACCT_DEFAULT_TO_DISABLED"
247 is set in the kernel configuration file.
252 Prevent user "joe" from allocating more than 1GB of virtual memory:
253 .Dl Nm Fl a Ar user:joe:vmemoryuse:deny=1g
255 Remove all RCTL rules:
258 Display resource usage information for jail named "www":
259 .Dl Nm Fl hu Ar jail:www
261 Display all the rules applicable to process with PID 512:
262 .Dl Nm Fl l Ar process:512
267 Display all rules matching user "joe":
270 Display all rules matching login classes:
271 .Dl Nm Ar loginclass:
284 .An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org
285 under sponsorship from the FreeBSD Foundation.
289 may kill the machine due to thrashing.