|
|
2.6. Process Resource AttributesSpecific limits are imposed on how much of a given resource a process can consume. Traditionally, these limits were accessible with the shell limit(1) or ulimit(1) commands (depending on which shell was being used). Solaris 10 includes the plimit(1) command, which checks and sets process limits. sol10$ plimit $$ 13475: -ksh resource current maximum time(seconds) unlimited unlimited file(blocks) unlimited unlimited data(kbytes) unlimited unlimited stack(kbytes) 8192 unlimited coredump(blocks) unlimited unlimited nofiles(descriptors) 256 65536 vmemory(kbytes) unlimited unlimited The resource limits displayed are defined as follows.
Solaris 10 extends process resource attributes and controls, adding supporting commands to display and manage process resource allocation. sol10$ prctl $$ process: 13475: -ksh NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT process.max-port-events privileged 65.5K - deny - system 2.15G max deny - process.max-msg-messages privileged 8.19K - deny - system 4.29G max deny - process.max-msg-qbytes privileged 64.0KB - deny - system 16.0EB max deny - process.max-sem-ops privileged 512 - deny - system 2.15G max deny - process.max-sem-nsems privileged 512 - deny - system 32.8K max deny - process.max-address-space privileged 16.0EB max deny - system 16.0EB max deny - process.max-file-descriptor basic 256 - deny 13475 privileged 65.5K - deny - system 2.15G max deny - process.max-core-size privileged 8.00EB max deny - system 8.00EB max deny - process.max-stack-size basic 8.00MB - deny 13475 privileged 8.00EB - deny - system 8.00EB max deny - process.max-data-size privileged 16.0EB max deny - system 16.0EB max deny - process.max-file-size privileged 8.00EB max deny,signal=XFSZ - system 8.00EB max deny - process.max-cpu-time privileged 18.4Es inf signal=XCPU - system 18.4Es inf none - . . . The prctl(1) example lists the set of resource controls bound to a process. Other resource controls at the project, task, and zone level are not explored here (see Chapter 7). prctl(1) can also dynamically change the value of a resource where the applied change has scope for the life of the process. Note that the resources listed in the above example include the set of traditional thresholds discussed earlier (open files descriptors, stack size, etc.), along with a set of resources that apply to a process's use of the System V interprocess communication (IPC) facilities. The parameters for System V semaphores, shared memory, and message queues, which historically were set systemwide in the /etc/system file, have been integrated into process-level controls. The actual number of parameters that apply to System V IPC have also been reduced, and the default values are larger than in previous Solaris releases. See the System Administration Guide: Solaris ContainersResource Management and Zones for specific information on setting and using these controls. Each defined resource has a privilege level and action associated with it. The privilege levels are defined as follows:
The action attribute specifies what happens when a resource threshold is reached. For local scope actions (the execution context of the process), a resource action attribute can be set to take no action (none), deny a request for the resource (deny), or send a signal when the resource threshold is reached. For the signal action, there are choices as to which signal should be generated. The implementation is built on links in the proc_t. . . . struct rctl_set *p_rctls; /* resource controls for this process */ rlim64_t p_stk_ctl; /* currently enforced stack size */ rlim64_t p_fsz_ctl; /* currently enforced file size */ rlim64_t p_vmem_ctl; /* currently enforced addr-space size */ rlim64_t p_fno_ctl; /* currently enforced file-desc limit */ pid_t p_ancpid; /* ancestor pid, used by exacct */ . . . See usr/src/uts/common/sys/proc.h The resource controls, along with the attributes, are maintained in an rctl_set, linked to the process through the p_rctls link. Several process-level limits are maintained directly in the proc_t (p_stk_ctl, etc.) as a performance optimizationthe values can be tested without traversal of additional links and structures. rctl_set links to a hash table of resource control structures that provide the entity-level information. In this example, the process is the entity to which the resource information is bound. Other possible entities are projects, tasks, and zones. rctl_set also links to an rctl_dict_entry that defines the systemwide scope for the resource. Figure 2.7 illustrates the big picture. Figure 2.7. Process Resource Control Structures
At system initialization, a systemwide primary set of resource controls is instantiated. The resource management framework provides a registration facility by which kernel subsystems can register their resource controls. The per-entity resource controls are defined and managed by the kernel subsystem and code for the particular entity. For example, process resource controls are defined in the usr/src/uts/common/os/rctl_proc.c source file. An initialization function, rctlproc_init(), is called at boot time to register the process resource controls and add them to the systemwide dictionary, which is referenced through the rctl_dict hash table. When a process is created with the fork(2) system call, the new (child) process inherits a duplicate copy of the parent's resource controls, which reflect the default values and attributes if changes were not explicitly made with the administrative controls prctl(1) and rctladm(1). As the process executes and consumes resourcesopening files, growing memory, using System V semaphores, etc.each subsystem in the kernel that manages a controlled resources imposes a limit test to determine if the process request can be granted. If it cannot, the attribute for the resource defines what action to take (none, deny, or send a signal). The lookup for a specific resource is done dynamically for each process by hashing on the resource control ID and referencing the resource value and attributes through the per-resource rctl_val_t. You can examine the system's resource control dictionary by using mdb(1). > ::walk rctl_dict_list |::print rctl_dict_entry_t { rcd_next = 0xffffffff80a2fbb0 rcd_name = 0xfffffffffb8b1038 "process.max-port-events" rcd_default_value = 0xffffffff80a28b88 rcd_ops = rctl_absolute_ops rcd_id = 0xc rcd_entity = 0 (RCENTITY_PROCESS) rcd_flagaction = 0x20100000 rcd_syslog_level = 0 rcd_strlog_flags = 0 rcd_max_native = 0x7fffffff rcd_max_ilp32 = 0x7fffffff } { rcd_next = 0xffffffff80a2fc00 rcd_name = 0xfffffffffb8b1088 "process.max-msg-messages" rcd_default_value = 0xffffffff80a28c08 rcd_ops = rctl_absolute_ops rcd_id = 0xb rcd_entity = 0 (RCENTITY_PROCESS) rcd_flagaction = 0x20100000 rcd_syslog_level = 0 rcd_strlog_flags = 0 rcd_max_native = 0xffffffff rcd_max_ilp32 = 0xffffffff . . . |
|
|