2 .\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
4 .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
5 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH PRCTL 1 "April 9, 2016"
8 prctl \- get or set the resource controls of running processes, tasks, and
13 \fBprctl\fR [\fB-P\fR] [\fB-t\fR [basic | privileged | system]]
14 [\fB-n\fR \fIname\fR [\fB-srx\fR] [\fB-v\fR \fIvalue\fR] [\fB-e\fR | \fB-d\fR \fIaction\fR] [\fB-p\fR \fIpid\fR]]
15 [\fB-i\fR \fIidtype\fR] \fIid\fR...
20 The \fBprctl\fR utility allows the examination and modification of the resource
21 controls associated with an active process, task, or project on the system. It
22 allows access to the basic and privileged limits and the current usage on
26 See \fBresource_controls\fR(5) for a description of the resource controls
27 supported in the current release of the Solaris operating system.
30 The following options are supported:
34 \fB\fB-d\fR | \fB-e\fR \fIaction\fR\fR
38 Disables (\fB-d\fR) or enables (\fB-e\fR) the specified \fIaction\fR on the
39 resource control value specified by \fB-v\fR, \fB-t\fR, and \fB-p\fR. If any of
40 the \fB-v\fR, \fB-t\fR, or \fB-p\fR options are unspecified, they match any
41 value, privilege, or recipient pid. For example, specifying only \fB-v\fR
42 modifies the first resource control with matching value, matching any privilege
43 and recipient pid. If no matching resource control value is found, a new value
44 is added as if \fB-s\fR were specified.
53 This action is only available with \fB-d\fR. It disables all actions. This
54 fails on resource control values that have the \fBdeny\fR global flag.
63 Indicates that the resource control attempts to deny granting the resource to
64 the process, task, project, or zone on a request for resources in excess of the
65 resource control value. \fBdeny\fR actions can not be enabled if the resource
66 control has the \fBno-deny\fR global flag. \fBdeny\fR actions can not be
67 disabled if the resource control has the \fBdeny\fR global flag.
76 This action is only available with \fB-d\fR. It deactivates the \fBsignal\fR
83 \fB\fBsignal\fR=\fIsignum\fR\fR
86 In the \fBsignal=\fR\fIsignum\fR action, \fIsignum\fR is a signal number (or
87 string representation of a signal). Setting a \fBsignal\fR action on a resource
88 control with the \fBno-local-action\fR global flag fails. A limited set of
89 signals can be sent. See \fBNOTES\fR for additional details.
97 \fB\fB-i\fR \fIidtype\fR\fR
101 Specifies the type of the id operands. Valid \fIidtype\fRs are \fBprocess\fR,
102 \fBtask\fR, \fBproject\fR, or \fBzone\fR. Also allowed are \fBpid\fR,
103 \fBtaskid\fR, \fBprojid\fR, and \fBzoneid\fR. The default id type, if the
104 \fB-i\fR option is omitted, is \fBprocess\fR.
106 For a modify operation, the entity to which id operands are members is the
107 target entity. For instance, setting a project resource control on an \fB-i\fR
108 \fBprocess\fR sets the resource control on the project to which each given
109 process argument is a member.
111 For a get operation, the resource controls are listed for all entities to which
112 the id operands are members. For example, \fB-i\fR \fBtask\fR \fItaskid\fR
113 lists the task, project, and zone resource controls for the task, and for the
114 project and zone to which that task is a member.
120 \fB\fB-n\fR \fIname\fR\fR
124 Specifies the name of the resource control to get or set. If the \fIname\fR is
125 unspecified, all resource controls are retrieved.
131 \fB\fB-p\fR \fIpid\fR\fR
135 When manipulating (using \fB-s\fR, \fB-r\fR, \fB-x\fR, \fB-d\fR, or \fB-e\fR) a
136 basic task project, or zone resource control values, a recipient \fIpid\fR can
137 be specified using \fB-p\fR. When setting a new basic resource control or
138 controls on a task, project, or zone, the \fB-p\fR option is required if the
139 \fB-i\fR \fIidtype\fR option argument is not \fBprocess\fR.
149 Display resource control values in space delimited format.
159 Replaces the first resource control value (matching with the \fB-t\fR
160 \fBprivilege\fR) with the new value specified through the \fB-v\fR option.
170 Set a new resource control value.
172 This option requires the \fB-v\fR option.
174 If you do not specify the \fB-t\fR option, basic privilege is used. If you want
175 to set a basic task, process, or zone rctl, \fB-p\fR is required. If \fB-e\fR
176 or \fB-d\fR are also specified, the action on the new \fBrctl\fR is set as
179 For compatibility with prior releases, this option is implied if \fB-v\fR is
180 specified, without any of \fB-e\fR, \fB-d\fR, \fB-r\fR, or \fB-x\fR.
182 See \fBresource_controls\fR(5) for a description of unit modifiers and scaling
183 factors you can use to express large values when setting a resource control
190 \fB\fB-t\fR [ \fBbasic\fR | \fBprivileged\fR | \fBsystem\fR ]\fR
194 Specifies which resource control type to set. Unless the "lowerable" flag is
195 set for a resource control, only invocations by users (or setuid programs) who
196 have privileges equivalent to those of root can modify privileged resource
197 controls. See \fBrctlblk_set_value\fR(3C) for a description of the
198 \fBRCTL_GLOBAL_LOWERABLE\fR flag. If the type is not specified, \fBbasic\fR is
199 assumed. For a get operation, the values of all resource control types,
200 including \fBsystem\fR, are displayed if no type is specified.
206 \fB\fB-v\fR \fIvalue\fR\fR
210 Specifies the value for the resource control for a set operation. If no
211 \fIvalue\fR is specified, then the modification (deletion, action enabling or
212 disabling) is carried out on the lowest-valued resource control with the given
215 See \fBresource_controls\fR(5) for a description of unit modifiers and scaling
216 factors you can use to express large values when setting a resource control
227 Deletes the specified resource control value. If the delete option is not
228 provided, the default operation of \fBprctl\fR is to modify a resource control
229 value of matching value and privilege, or insert a new value with the given
230 privilege. The matching criteria are discussed more fully in \fBsetrctl\fR(2).
235 If none of the \fB-s\fR, \fB-r\fR, \fB-x\fR, \fB-v\fR, \fB-d\fR, or \fB-e\fR
236 options are specified, the invocation is considered a get operation. Otherwise,
237 it is considered a modify operation.
240 The following operand is supported:
247 The \fBID\fR of the entity (\fBprocess\fR, \fBtask\fR, \fBproject\fR, or
248 \fBzone\fR) to interrogate. If the invoking user's credentials are unprivileged
249 and the entity being interrogated possesses different credentials, the
250 operation fails. If no \fIid\fR is specified, an error message is returned.
255 \fBExample 1 \fRDisplaying Current Resource Control Settings
258 The following example displays current resource control settings for a task to
259 which the current shell belongs:
264 example$ ps -o taskid -p $$
267 example$ prctl -i task 8
269 NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
272 system 18.4Es inf none -
275 system 2.15G max deny -
276 project.max-contracts
277 privileged 10.0K - deny -
278 project.max-locked-memory
280 privileged 508MB - deny -
282 privileged 8.19K - deny -
283 project.max-shm-memory
284 privileged 508MB - deny -
286 privileged 128 - deny -
288 privileged 128 - deny -
290 privileged 128 - deny -
291 project.max-crypto-memory
293 privileged 508MB - deny -
296 system 2.15G max deny -
299 system 2.15G max deny -
302 privileged 1 - none -
304 system 16.0EB max deny -
306 system 16.8M max deny -
308 system 16.8M max deny -
310 system 16.8M max deny -
312 system 2.15G max deny -
314 privileged 1 - none -
315 zone.max-locked-memory
317 privileged 508MB - deny -
323 \fBExample 2 \fRDisplaying, Replacing, and Verifying the Value of a Specific
327 The following examples displays, replaces, and verifies the value of a specific
328 control on an existing project:
333 example# prctl -n project.cpu-shares -i project group.staff
334 project: 10: group.staff
335 NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
338 privileged 1 - none -
339 system 65.5K max none -
341 example# prctl -n project.cpu-shares -v 10 -r -i project group.staff
342 example# prctl -n project.cpu-shares -i project group.staff
343 project: 10: group.staff
344 NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
347 privileged 10 - none -
348 system 65.5K max none -
354 \fBExample 3 \fRAdjusting Resources
357 The following example uses the \fBproject.max-locked-memory\fR resource.
361 First, use \fBid\fR \fB-p\fR to find out which project the current shell is a
367 /home/garfield> id -p
368 uid=77880(garfield) gid=10(staff) projid=10(group.staff)
375 Using the target project, identify the resource limit value before the change:
380 /home/garfield> prctl -n project.max-locked-memory -i project \e
382 project 10: group.staff
383 project.max-locked-memory
384 privileged 256MB - deny -
385 system 16.0EB max deny -
387 current limit is 256 Megabytes.
394 Next, adjust the \fBproject.max-locked-memory\fR limit to 300 Megabytes for the
400 # prctl -n project.max-locked-memory -v 300M -r -i project group.staff
407 The resource limit value after the change shows a new value of 300 Megabytes:
412 # prctl -n project.max-locked-memory -i project group.staff
413 project 10:group.staff
414 project.max-locked-memory
416 privileged 300MB - deny -
417 system 16.0EB max deny -
423 \fBExample 4 \fRModifying CPU Caps for a Project
426 The \fBprctl\fR command can use the \fBproject.cpu-cap\fR resource control (see
427 \fBresource_controls\fR(5)) to set and modify CPU caps for a project. (The same
428 resource control can be used in the \fB/etc/project\fR file. See
429 \fBproject\fR(4)) The following command modifies the CPU cap to limit
430 \fBuser.smith\fR to three CPUs:
435 # \fBprctl -r -t privileged -n project.cpu-cap -v 300 -i project user.smith\fR
442 The \fBprctl\fR \fB-r\fR option, used above, is used to dynamically change a
443 CPU cap for a project or zone. For example, the following command will change
444 the cap set in the preceding command to 80 percent:
449 # \fBprctl -r -t privileged -n project.cpu-cap -v 80 -i project user.smith\fR
456 To remove a CPU cap, enter:
461 # \fBprctl -x -n project.cpu-cap $$\fR
467 \fBExample 5 \fRModifying CPU Caps for a Zone
470 The \fBprctl\fR command can use the \fBzone.cpu-cap\fR resource control (see
471 \fBresource_controls\fR(5)) to set and modify CPU caps for a zone. (The same
472 resource control can be manipulated using the \fBzonecfg\fR(8) command.) The
473 following command modifies the CPU cap to limit the global zone to 80 percent
479 # \fBprctl -t privileged -n zone.cpu-cap -v 80 -i zone global\fR
486 The cap can be lowered to 50% using:
491 # \fBprctl -r -t privileged -n zone.cpu-cap -v 50 -i zone global\fR
498 The following exit values are returned:
514 Fatal error encountered.
523 Invalid command line options were specified.
529 \fB\fB/proc/pid/*\fR\fR
532 Process information and control files
537 See \fBattributes\fR(5) for descriptions of the following attributes:
545 ATTRIBUTE TYPE ATTRIBUTE VALUE
547 Interface Stability See below.
552 The command-line syntax is Committed. The human-readable output is Uncommitted.
553 The parsable output is Committed.
556 \fBrctladm\fR(8), \fBzonecfg\fR(8), \fBsetrctl\fR(2),
557 \fBrctlblk_get_local_action\fR(3C), \fBproject\fR(4), \fBattributes\fR(5),
558 \fBresource_controls\fR(5)
561 The valid signals that can be set on a resource control block allowing local
562 actions are \fBSIGABRT\fR, \fBSIGXRES\fR, \fBSIGHUP\fR, \fBSIGSTOP\fR,
563 \fBSIGTERM\fR, and \fBSIGKILL\fR. Additionally, CPU time related controls can
564 issue the \fBSIGXCPU\fR signal, and file size related controls can send the
565 \fBSIGXFSZ\fR signal.