Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
  Previous   Contents   Next 
   
 
Chapter 8

Resource Controls

After you determine the resource consumption of workloads on your system as described in Chapter 7, Extended Accounting, you can place bounds on resource usage and prevent workloads from over-consuming resources. The resource controls facility, which extends the UNIX resource limit concept, is the constraint mechanism that is used for this purpose.

Overview

UNIX systems have traditionally provided a resource limit facility (rlimit). The rlimit facility allows administrators to set one or more numerical limits on the amount of resources a process can consume. These limits include per-process CPU time that is used, per-process core file size, and per-process maximum heap size. Heap size is the amount of memory that is allocated for the process data segment.

In the Solaris operating environment, the concept of a per-process resource limit has been extended to the task and project entities that are described in Chapter 6, Projects and Tasks. These extended limits can now be observed on a system-wide basis. These enhancements are provided by the resource controls (rctls) facility.

The resource controls facility provides compatibility interfaces for the resource limits facility. Existing applications that utilize resource limits continue to run unchanged. These applications can be observed in the same way as applications that are modified to make use of the resource controls facility.

Resource controls provide a mechanism for constraint on system resources. Processes, tasks, and projects can be prevented from consuming amounts of specified system resources. This mechanism leads to a more manageable system by preventing over-consumption of resources.

Constraint mechanisms can be used to support capacity-planning processes. An encountered constraint can provide information about application resource needs without necessarily denying the resource to the application.

Resource controls can also serve as a simple attribute mechanism for resource management facilities. For example, the number of CPU shares that are made available to a project in the fair share scheduler (FSS) scheduling class is defined by the project.cpu-shares resource control. Because the project is assigned a fixed number of shares by the control, the various actions that are associated with exceeding a control are not relevant. For this reason, the current value for the project.cpu-shares control is considered an attribute on the specified project.

Administering Resource Controls

The resource controls facility is configured through the project database (see Chapter 6, Projects and Tasks). Resource control attributes are set in the final field of the project database entry. The values that are associated with each resource control are enclosed in parentheses, and they appear as plain text that is separated by commas. The values in parentheses comprise an "action clause." Each action clause is composed of a privilege level, a threshold value, and an action that is associated with the particular threshold. Each resource control can have multiple action clauses, which are also separated by commas. The following entry defines a per-process address-space limit and a per-task lightweight process limit on a project entity.

development:101:Developers:::task.max-lwps=(privileged,10,deny);
  process.max-address-space=(privileged,209715200,deny)

The rctladm(1M) command allows you to make runtime interrogations of and modifications to the resource controls facility, with global scope. The prctl(1) command allows you to make runtime interrogations of and modifications to the resource controls facility, with local scope.

Available Resource Controls

A list of the standard resource controls available in this release is shown in the following table.

The table describes the resource that is constrained by each control and identifies the default units that are used by the project database for that resource. The default units are of two types:

  • Quantities represent a limited amount.

  • Indexes represent a maximum valid identifier.

Thus, project.cpu-shares specifies the number of shares the project is entitled to, while process.max-file-descriptor specifies the highest file number that can be assigned to a process by the open(2) system call.

Table 8-1 Standard Resource Controls

Control Name

Description

Default Unit

project.cpu-shares

The number of CPU shares that are granted to this project for use with FSS(7)

Quantity (shares)

task.max-cpu-time

Maximum CPU time available to this task's processes

Time (milliseconds)

task.max-lwps

Maximum number of LWPs simultaneously available to this task's processes

Quantity (LWPs)

process.max-cpu-time

Maximum CPU time available to this process

Time (milliseconds)

process.max-file-descriptor

Maximum file descriptor index available to this process

Index (maximum file descriptor)

process.max-file-size

Maximum file offset available for writing by this process

Size (bytes)

process.max-core-size

Maximum size of a core file that is created by this process

Size (bytes)

process.max-data-size

Maximum heap memory available to this process

Size (bytes)

process.max-stack-size

Maximum stack memory segment available to this process

Size (bytes)

process.max-address-space

Maximum amount of address space, as summed over segment sizes, available to this process

Size (bytes)

Resource Control Values and Privilege Levels

A threshold value on a resource control constitutes an enforcement point where local actions can be triggered or global actions, such as logging, can occur.

Each threshold value must be associated with a privilege level, which will be one of the following three types.

  • Basic, which can be modified by the owner of the calling process

  • Privileged, which can be modified only by privileged (superuser) callers

  • System, which is fixed for the duration of the operating system instance

A particular resource control is guaranteed to have one system value, which is defined by the system (or resource provider). The system value represents how much of the resource the current implementation of the operating system is capable of providing.

Any number of privileged values can be defined, and only one basic value is allowed. Operations that are performed without specifying a privilege value are assigned a basic privilege by default.

The privilege level for a resource control value is defined in the privilege field of the resource control block as RCTL_BASIC, RCTL_PRIVILEGED, or RCTL_SYSTEM. See getrctl(2) for more information. You can use the prctl command to modify values that are associated with basic and privileged levels.

Actions on Resource Control Values

For each threshold value that is placed on a resource control, you can associate one or more actions.

  • You can choose to deny the resource requests for an amount greater than the threshold.

  • You can choose to send a signal to the violating or observing process if the threshold value is reached.

Because of implementation restrictions, the global properties of each control can restrict the set of available actions that can be set on the threshold value. A list of available signal actions is presented in the following table. For additional information on signals, see signal(3HEAD).

Table 8-2 Signals Available to Resource Control Values

Signal

Notes

SIGABRT

 

SIGHUP

 

SIGTERM

 

SIGKILL

 

SIGSTOP

 

SIGXRES

 

SIGXFSZ

Available only to resource controls with the RCTL_GLOBAL_FILE_SIZE property (process.max-file-size). See rctlblk_set_value(3C) for more information.

SIGXCPU

Available only to resource controls with the RCTL_GLOBAL_CPUTIME property (process.max-cpu-time). See rctlblk_set_value(3C) for more information.

Resource Control Flags and Properties

Each resource control available on the system has a certain set of properties that are associated with it. This set of properties is defined as a set of global flags, which are associated with all controlled instances of that resource. Global flags cannot be modified, but they can be retrieved by using either rctladm or the getrctl system call.

Local flags define the default behavior and configuration for a specific threshold value of that resource control on a specific process or process collective. The local flags for one threshold value do not affect the behavior of other defined threshold values for that same resource control. However, the global flags affect the behavior for every value that is associated with a particular control. Local flags can be modified, within the constraints that are supplied by their corresponding global flags, by the prctl command or the setrctl system call (see setrctl(2)).

For the complete list of local flags, global flags, and their definitions, see rctlblk_set_value(3C).

To determine system behavior when a threshold value for a particular resource control is reached, use rctladm to display the global flags for the resource control . For example, to display the values for process.max-cpu-time, type the following:

$ rctladm process.max-cpu-time
	process.max-cpu-time   syslog=off   [ lowerable no-deny cpu-time inf ]

The global flags indicate the following.

 
 
 
  Previous   Contents   Next