PRCTL(1) | User Commands | PRCTL(1) |
prctl - get or set the resource controls of running processes, tasks, and projects
prctl [-P] [-t [basic | privileged | system]]
[-n name [-srx] [-v value] [-e | -d action] [-p pid]]
[-i idtype] id...
The prctl utility allows the examination and modification of the resource controls associated with an active process, task, or project on the system. It allows access to the basic and privileged limits and the current usage on the specified entity.
See resource_controls(7) for a description of the resource controls supported in the current release of the Solaris operating system.
The following options are supported:
-d | -e action
Actions:
all
deny
signal
signal=signum
-i idtype
For a modify operation, the entity to which id operands are members is the target entity. For instance, setting a project resource control on an -i process sets the resource control on the project to which each given process argument is a member.
For a get operation, the resource controls are listed for all entities to which the id operands are members. For example, -i task taskid lists the task, project, and zone resource controls for the task, and for the project and zone to which that task is a member.
-n name
-p pid
-P
-r
-s
This option requires the -v option.
If you do not specify the -t option, basic privilege is used. If you want to set a basic task, process, or zone rctl, -p is required. If -e or -d are also specified, the action on the new rctl is set as well.
For compatibility with prior releases, this option is implied if -v is specified, without any of -e, -d, -r, or -x.
See resource_controls(7) for a description of unit modifiers and scaling factors you can use to express large values when setting a resource control value.
-t [ basic | privileged | system ]
-v value
See resource_controls(7) for a description of unit modifiers and scaling factors you can use to express large values when setting a resource control value.
-x
If none of the -s, -r, -x, -v, -d, or -e options are specified, the invocation is considered a get operation. Otherwise, it is considered a modify operation.
The following operand is supported:
id
Example 1 Displaying Current Resource Control Settings
The following example displays current resource control settings for a task to which the current shell belongs:
example$ ps -o taskid -p $$ TASKID 8 example$ prctl -i task 8 136150: /bin/ksh NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT task.max-cpu-time
usage 8s
system 18.4Es inf none - task.max-processes
usage 30
system 2.15G max deny - task.max-lwps
usage 39
system 2.15G max deny - project.max-contracts
privileged 10.0K - deny - project.max-locked-memory
usage 0B
privileged 508MB - deny - project.max-port-ids
privileged 8.19K - deny - project.max-shm-memory
privileged 508MB - deny - project.max-shm-ids
privileged 128 - deny - project.max-msg-ids
privileged 128 - deny - project.max-sem-ids
privileged 128 - deny - project.max-crypto-memory
usage 0B privileged 508MB - deny - project.max-tasks
usage 2
system 2.15G max deny - project.max-processes
usage 30
system 2.15G max deny - project.max-lwps
usage 39
system 2.15G max deny - project.cpu-shares
usage 1
privileged 1 - none - zone.max-shm-memory
system 16.0EB max deny - zone.max-shm-ids
system 16.8M max deny - zone.max-sem-ids
system 16.8M max deny - zone.max-msg-ids
system 16.8M max deny - zone.max-processes
system 2.15G max deny - zone.max-lwps
system 2.15G max deny - zone.cpu-shares
privileged 1 - none - zone.max-locked-memory
usage 0B
privileged 508MB - deny -
Example 2 Displaying, Replacing, and Verifying the Value of a Specific Control
The following examples displays, replaces, and verifies the value of a specific control on an existing project:
example# prctl -n project.cpu-shares -i project group.staff project: 10: group.staff NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT project.cpu-shares
usage 1
privileged 1 - none -
system 65.5K max none - example# prctl -n project.cpu-shares -v 10 -r -i project group.staff example# prctl -n project.cpu-shares -i project group.staff project: 10: group.staff NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT project.cpu-shares
usage 10
privileged 10 - none -
system 65.5K max none -
Example 3 Adjusting Resources
The following example uses the project.max-locked-memory resource.
First, use id -p to find out which project the current shell is a member of:
/home/garfield> id -p
uid=77880(garfield) gid=10(staff) projid=10(group.staff)
Using the target project, identify the resource limit value before the change:
/home/garfield> prctl -n project.max-locked-memory -i project \
group.staff project 10: group.staff project.max-locked-memory
privileged 256MB - deny - system 16.0EB max deny - current limit is 256 Megabytes.
Next, adjust the project.max-locked-memory limit to 300 Megabytes for the target project:
# prctl -n project.max-locked-memory -v 300M -r -i project group.staff
The resource limit value after the change shows a new value of 300 Megabytes:
# prctl -n project.max-locked-memory -i project group.staff project 10:group.staff project.max-locked-memory usage 200MG
privileged 300MB - deny - system 16.0EB max deny -
Example 4 Modifying CPU Caps for a Project
The prctl command can use the project.cpu-cap resource control (see resource_controls(7)) to set and modify CPU caps for a project. (The same resource control can be used in the /etc/project file. See project(5)) The following command modifies the CPU cap to limit user.smith to three CPUs:
# prctl -r -t privileged -n project.cpu-cap -v 300 -i project user.smith
The prctl -r option, used above, is used to dynamically change a CPU cap for a project or zone. For example, the following command will change the cap set in the preceding command to 80 percent:
# prctl -r -t privileged -n project.cpu-cap -v 80 -i project user.smith
To remove a CPU cap, enter:
# prctl -x -n project.cpu-cap $$
Example 5 Modifying CPU Caps for a Zone
The prctl command can use the zone.cpu-cap resource control (see resource_controls(7)) to set and modify CPU caps for a zone. (The same resource control can be manipulated using the zonecfg(8) command.) The following command modifies the CPU cap to limit the global zone to 80 percent of a CPU:
# prctl -t privileged -n zone.cpu-cap -v 80 -i zone global
The cap can be lowered to 50% using:
# prctl -r -t privileged -n zone.cpu-cap -v 50 -i zone global
The following exit values are returned:
0
1
2
/proc/pid/*
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | See below. |
The command-line syntax is Committed. The human-readable output is Uncommitted. The parsable output is Committed.
setrctl(2), rctlblk_get_local_action(3C), project(5), attributes(7), resource_controls(7), rctladm(8), zonecfg(8)
The valid signals that can be set on a resource control block allowing local actions are SIGABRT, SIGXRES, SIGHUP, SIGSTOP, SIGTERM, and SIGKILL. Additionally, CPU time related controls can issue the SIGXCPU signal, and file size related controls can send the SIGXFSZ signal.
January 23, 2021 | OmniOS |