<chapter id="rm.rcapd.task-1"><title>Administering the Resource Capping Daemon
(Tasks)</title><highlights><para>This chapter contains procedures for configuring and using the resource
capping daemon <command>rcapd</command>.</para><para>For an overview of <command>rcapd</command>, see <olink targetptr="rm.rcapd-1" remap="internal">Chapter&nbsp;10, Physical Memory Control Using the
Resource Capping Daemon (Overview)</olink>.</para>
</highlights><sect1 id="fxcau"><title>Setting the Resident Set Size Cap</title><para>Define a physical memory resource resident set size (RSS) cap for a
project by adding an <literal>rcap.max-rss</literal> attribute to the <command>project</command> database entry.</para><task id="fxcey"><title>How to Add an <literal>rcap.max-rss</literal> Attribute
for a Project</title><procedure><step><para>Become superuser, or assume a role that includes the Process Management
profile.</para><para>The System Administrator role includes the Process Management
profile. For information on how to create the role and assign the role to
a user, see Managing RBAC (Task Map) in <citetitle>System Administration Guide:
Security Services</citetitle>.</para>
</step><step><para>Add this attribute to the <filename>/etc/project</filename> file:</para><screen>rcap.max-rss=<replaceable>value</replaceable></screen>
</step>
</procedure><example id="fxcez"><title>RSS Project Cap</title><para>The following line in the <filename>/etc/project</filename> file sets
an RSS cap of 10 Gbytes for a project named <literal>db</literal>.</para><screen>db:100::db,root::rcap.max-rss=10737418240</screen><para>Note that the system might round the specified cap value to a page size.</para>
</example>
</task><task id="fxcfa"><title>How to Use the <command>projmod</command> Command
to Add an <literal>rcap.max-rss</literal> Attribute for a Project</title><procedure><step><para>Become superuser, or assume a role that includes the Process Management
profile.</para><para>The System Administrator role includes the Process Management
profile. For information on how to create the role and assign the role to
a user, see Managing RBAC (Task Map) in <citetitle>System Administration Guide:
Security Services</citetitle>.</para>
</step><step><para>Set an <literal>rcap.max-rss</literal> attribute of 10 Gbytes
in the <filename>/etc/project</filename> file, in this case for a project
named <literal>db</literal>.</para><screen># <userinput>projmod -a -K rcap.max-rss=10GB db</userinput></screen><para>The <filename>/etc/project</filename> file then contains the line:</para><screen>db:100::db,root::rcap.max-rss=10737418240</screen>
</step>
</procedure>
</task>
</sect1><sect1 id="rm.rcapd.task-26"><title>Configuring and Using the Resource Capping
Daemon (Task Map)</title><informaltable frame="all"><tgroup cols="3" colsep="1" rowsep="1"><colspec colwidth="33*"/><colspec colwidth="33*"/><colspec colwidth="33*"/><thead><row><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry><para>Set the memory cap enforcement threshold.</para>
</entry><entry><para>Configure a cap that will be enforced when the physical memory available
to processes is low.</para>
</entry><entry><para><olink targetptr="rm.rcapd.task-3" remap="internal">How to Set the Memory Cap Enforcement
Threshold</olink></para>
</entry>
</row><row><entry><para>Set the operation interval.</para>
</entry><entry><para>The interval is applied to the periodic operations performed by the
resource capping daemon.</para>
</entry><entry><para><olink targetptr="rm.rcapd.task-6" remap="internal">How to Set Operation Intervals</olink></para>
</entry>
</row><row><entry><para>Enable resource capping.</para>
</entry><entry><para>Activate resource capping on your system.</para>
</entry><entry><para><olink targetptr="rm.rcapd.task-10" remap="internal">How to Enable Resource Capping</olink></para>
</entry>
</row><row><entry><para>Disable resource capping.</para>
</entry><entry><para>Deactivate resource capping on your system.</para>
</entry><entry><para><olink targetptr="rm.rcapd.task-14" remap="internal">How to Disable Resource Capping</olink></para>
</entry>
</row><row><entry><para>Report cap and project information.</para>
</entry><entry><para>View example commands for producing reports.</para>
</entry><entry><para><olink targetptr="rm.rcapd.task-20" remap="internal">Reporting Cap and Project Information</olink></para>
</entry>
</row><row><entry><para>Monitor a project's resident set size.</para>
</entry><entry><para>Produce a report on the resident set size of a project.</para>
</entry><entry><para><olink targetptr="rm.rcapd.task-21" remap="internal">Monitoring the RSS of a Project</olink></para>
</entry>
</row><row><entry><para>Determine a project's working set size.</para>
</entry><entry><para>Produce a report on the working set size of a project.</para>
</entry><entry><para><olink targetptr="rm.rcapd.task-22" remap="internal">Determining the Working Set Size
of a Project</olink></para>
</entry>
</row><row><entry><para>Report on memory utilization and memory caps.</para>
</entry><entry><para>Print a memory utilization and cap enforcement line at the end of the
report for each interval.</para>
</entry><entry><para><olink targetptr="rm.rcapd.task-23" remap="internal">Reporting Memory Utilization and
the Memory Cap Enforcement Threshold</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="rm.rcapd.task-2"><title>Administering the Resource Capping Daemon
With <command>rcapadm</command></title><para>This section contains procedures for configuring the resource capping
daemon with <command>rcapadm</command>. See <olink targetptr="rm.rcapd-19" remap="internal">rcapd
Configuration</olink> and the <olink targetdoc="group-refman" targetptr="rcapadm-1m" remap="external"><citerefentry><refentrytitle>rcapadm</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man page for more information.</para><para>If used without arguments, <command>rcapadm</command> displays the current
status of the resource capping daemon if it has been configured.</para><task id="rm.rcapd.task-3"><title>How to Set the Memory Cap Enforcement Threshold</title><tasksummary><para>Caps can be configured so that they will not be enforced until the physical
memory available to processes is low. See <olink targetptr="rm.rcapd-17" remap="internal">Memory
Cap Enforcement Threshold</olink> for more information.</para><para>The minimum (and default) value is <literal>0</literal>, which means
that memory caps are always enforced. To set a different minimum, follow this
procedure.</para>
</tasksummary><procedure><step><para>Become superuser, or assume a role that includes the Process Management
profile.</para><para>The System Administrator role includes the Process Management
profile. For information on how to create the role and assign the role to
a user, see Managing RBAC (Task Map) in <citetitle>System Administration Guide:
Security Services</citetitle>.</para>
</step><step id="rm.rcapd.task-step-5"><para>Use the <option>c</option> option of <command>rcapadm</command> to set a different physical memory utilization value for
memory cap enforcement.</para><screen># <userinput>rcapadm -c <replaceable>percent</replaceable></userinput></screen><para><replaceable>percent</replaceable> is in the range 0 to 100. Higher
values are less restrictive. A higher value means capped project workloads
can execute without having caps enforced until the system's memory utilization
exceeds this threshold.</para>
</step>
</procedure><taskrelated role="see-also"><para>To display the current physical memory utilization and the cap enforcement
threshold, see <olink targetptr="rm.rcapd.task-23" remap="internal">Reporting Memory Utilization
and the Memory Cap Enforcement Threshold</olink>.</para>
</taskrelated>
</task><task id="rm.rcapd.task-6"><title>How to Set Operation Intervals</title><tasksummary><para><olink targetptr="rm.rcapd-21" remap="internal">rcapd Operation Intervals</olink> contains
information about the intervals for the periodic operations performed by <literal>rcapd</literal>. To set operation intervals using <literal>rcapadm</literal>,
follow this procedure.</para>
</tasksummary><procedure><step id="rm.rcapd.task-step-8"><para>Become superuser, or assume a role that
includes the Process Management profile.</para><para>The System Administrator
role includes the Process Management profile. For information on how to create
the role and assign the role to a user, see Managing RBAC (Task Map) in <citetitle>System Administration Guide: Security Services</citetitle>.</para>
</step><step id="rm.rcapd.task-step-9"><para>Use the <option>i</option> option to
set interval values.</para><screen># <userinput>rcapadm -i <replaceable>interval=value</replaceable>,...,<replaceable>interval=value</replaceable></userinput> </screen><note><para>All interval values are specified in seconds.</para>
</note>
</step>
</procedure>
</task><task id="rm.rcapd.task-10"><title>How to Enable Resource Capping</title><tasksummary><para>There
are three ways to enable resource capping on your system. Enabling resource
capping also sets the <literal>/etc/rcap.conf</literal> file with default
values.</para>
</tasksummary><procedure><step id="rm.rcapd.task-step-12"><para>Become superuser, or assume a role
that includes the Process Management profile.</para><para>The System Administrator
role includes the Process Management profile. For information on how to create
the role and assign the role to a user, see Managing RBAC (Task Map) in <citetitle>System Administration Guide: Security Services</citetitle>.</para>
</step><step id="rm.rcapd.task-step-13"><para>Enable the resource capping daemon
in one of the following ways:</para><itemizedlist><listitem><para>Turn on resource capping using the <command>svcadm</command> command.</para><screen># <userinput>svcadm enable rcap</userinput></screen>
</listitem><listitem><para>Enable the resource capping daemon so that it will be started
now and also be started each time the system is booted:</para><screen># <userinput>rcapadm -E</userinput></screen>
</listitem><listitem><para>Enable the resource capping daemon at boot without starting
it now by also specifying the <option>n</option> option:</para><screen># <userinput>rcapadm -n -E</userinput></screen>
</listitem>
</itemizedlist>
</step>
</procedure>
</task><task id="rm.rcapd.task-14"><title>How to Disable Resource Capping</title><tasksummary><para>There are three ways to disable resource capping on your system.</para>
</tasksummary><procedure><step id="rm.rcapd.task-step-16"><para>Become superuser, or assume a role
that includes the Process Management profile.</para><para>The System Administrator
role includes the Process Management profile. For information on how to create
the role and assign the role to a user, see Managing RBAC (Task Map) in <citetitle>System Administration Guide: Security Services</citetitle>.</para>
</step><step id="rm.rcapd.task-step-17"><para>Disable the resource capping daemon
in one of the following ways:</para><stepalternatives><step><para>Turn off resource capping using the <command>svcadm</command> command.</para><screen># <userinput>svcadm disable rcap</userinput></screen>
</step><step><para>To disable the resource capping daemon so that it will be stopped
now and not be started when the system is booted, type:</para><screen># <userinput>rcapadm -D</userinput></screen>
</step><step><para>To disable the resource capping daemon without stopping it, also
specify the <option>n</option> option:</para><screen># <userinput>rcapadm -n -D</userinput></screen>
</step>
</stepalternatives><tip><para>Disabling the Resource Capping Daemon Safely</para>
</tip><para>Use <command>rcapadm</command> <option>D</option> to safely disable <literal>rcapd</literal>.
If the daemon is killed (see the <citerefentry><refentrytitle>kill</refentrytitle><manvolnum>1</manvolnum></citerefentry> man page), processes might be left
in a stopped state and need to be manually restarted. To resume a process
running, use the <command>prun</command> command. See the <olink targetdoc="group-refman" targetptr="prun-1" remap="external"><citerefentry><refentrytitle>prun</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink> man page for more information.</para>
</step>
</procedure>
</task>
</sect1><sect1 id="rm.rcapd.task-19"><title>Producing Reports With <command>rcapstat</command></title><para>Use <command>rcapstat</command> to report resource capping statistics. <olink targetptr="rm.rcapd-22" remap="internal">Monitoring Resource Utilization With rcapstat</olink> explains
how to use the <command>rcapstat</command> command to generate reports. That
section also describes the column headings in the report. The <olink targetdoc="group-refman" targetptr="rcapstat-1" remap="external"><citerefentry><refentrytitle>rcapstat</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink> man page also
contains this information.</para><para>The following subsections use examples to illustrate how to produce
reports for specific purposes.</para><sect2 id="rm.rcapd.task-20"><title>Reporting Cap and Project Information</title><para>In this example, caps are defined for two projects associated with two
users. <literal>user1</literal> has a cap of 50 megabytes, and <literal>user2</literal> has
a cap of 10 megabytes.</para><para>The following command produces five reports at 5-second sampling intervals.</para><screen>user1machine% <userinput>rcapstat 5 5</userinput>
    id project  nproc     vm    rss   cap    at avgat    pg avgpg
112270   user1     24   123M    35M   50M   50M    0K 3312K    0K
 78194   user2      1  2368K  1856K   10M    0K    0K    0K    0K
    id project  nproc     vm    rss   cap    at avgat    pg avgpg
112270   user1     24   123M    35M   50M    0K    0K    0K    0K
 78194   user2      1  2368K  1856K   10M    0K    0K    0K    0K
    id project  nproc     vm    rss   cap    at avgat    pg avgpg
112270   user1     24   123M    35M   50M    0K    0K    0K    0K
 78194   user2      1  2368K  1928K   10M    0K    0K    0K    0K
    id project  nproc     vm    rss   cap    at avgat    pg avgpg
112270   user1     24   123M    35M   50M    0K    0K    0K    0K
 78194   user2      1  2368K  1928K   10M    0K    0K    0K    0K
    id project  nproc     vm    rss   cap    at avgat    pg avgpg
112270   user1     24   123M    35M   50M    0K    0K    0K    0K
 78194   user2      1  2368K  1928K   10M    0K    0K    0K    0K </screen><para>The first three lines of output constitute the first report, which contains
the cap and project information for the two projects and paging statistics
since <command>rcapd</command> was started. The <literal>at</literal> and <literal>pg</literal> columns are a number greater than zero for <literal>user1</literal> and
zero for <literal>user2</literal>, which indicates that at some time in the
daemon's history, <literal>user1</literal> exceeded its cap but <literal>user2</literal> did
not.</para><para>The subsequent reports show no significant activity.</para>
</sect2><sect2 id="rm.rcapd.task-21"><title>Monitoring the RSS of a Project</title><para>The following example uses project <literal>user1</literal>, which has
an RSS in excess of its RSS cap.</para><para>The following command produces five reports at 5-second sampling intervals.</para><screen>user1machine% <userinput>rcapstat 5 5</userinput></screen><screen>    id project  nproc    vm   rss   cap    at avgat     pg  avgpg
376565   user1      3 6249M 6144M 6144M  690M  220M  5528K  2764K
376565   user1      3 6249M 6144M 6144M    0M  131M  4912K  1637K
376565   user1      3 6249M 6171M 6144M   27M  147M  6048K  2016K
376565   user1      3 6249M 6146M 6144M 4872M  174M  4368K  1456K
376565   user1      3 6249M 6156M 6144M   12M  161M  3376K  1125K</screen><para>The <literal>user1</literal> project has three processes that are actively
using physical memory. The positive values in the <literal>pg</literal> column
indicate that <command>rcapd</command> is consistently paging out memory as
it attempts to meet the cap by lowering the physical memory utilization of
the project's processes. However, <command>rcapd</command> does not succeed
in keeping the RSS below the cap value. This is indicated by the varying <literal>rss</literal> values that do not show a corresponding decrease. As soon as
memory is paged out, the workload uses it again and the RSS count goes back
up. This means that all of the project's resident memory is being actively
used and the working set size (<emphasis>WSS</emphasis>) is greater than the
cap. Thus, <command>rcapd</command> is forced to page out some of the working
set to meet the cap. Under this condition, the system will continue to experience
high page fault rates, and associated I/O, until one of the following occurs:</para><itemizedlist><listitem><para>The WSS becomes smaller.</para>
</listitem><listitem><para>The cap is raised.</para>
</listitem><listitem><para>The application changes its memory access pattern.</para>
</listitem>
</itemizedlist><para>In this situation, shortening the sample interval might reduce the discrepancy
between the RSS value and the cap value by causing <command>rcapd</command> to
sample the workload and enforce caps more frequently.</para><note><para>A page fault occurs when either a new page must be created or
the system must copy in a page from a swap device.</para>
</note>
</sect2><sect2 id="rm.rcapd.task-22"><title>Determining the Working Set Size of a
Project</title><para>The following example is a continuation of the previous example, and
it uses the same project.</para><para>The previous example shows that the <literal>user1</literal> project
is using more physical memory than its cap allows. This example shows how
much memory the project workload requires.</para><screen>user1machine% <userinput>rcapstat 5 5</userinput>
    id project  nproc    vm   rss   cap    at avgat     pg  avgpg
376565   user1      3 6249M 6144M 6144M  690M    0K   689M     0K
376565   user1      3 6249M 6144M 6144M    0K    0K     0K     0K
376565   user1      3 6249M 6171M 6144M   27M    0K    27M     0K
376565   user1      3 6249M 6146M 6144M 4872K    0K  4816K     0K
376565   user1      3 6249M 6156M 6144M   12M    0K    12M     0K
376565   user1      3 6249M 6150M 6144M 5848K    0K  5816K     0K
376565   user1      3 6249M 6155M 6144M   11M    0K    11M     0K
376565   user1      3 6249M 6150M   10G   32K    0K    32K     0K
376565   user1      3 6249M 6214M   10G    0K    0K     0K     0K
376565   user1      3 6249M 6247M   10G    0K    0K     0K     0K
376565   user1      3 6249M 6247M   10G    0K    0K     0K     0K
376565   user1      3 6249M 6247M   10G    0K    0K     0K     0K
376565   user1      3 6249M 6247M   10G    0K    0K     0K     0K
376565   user1      3 6249M 6247M   10G    0K    0K     0K     0K
376565   user1      3 6249M 6247M   10G    0K    0K     0K     0K</screen><para>Halfway through the cycle, the cap on the <literal>user1</literal> project
was increased from 6 Gbytes to 10 Gbytes. This increase stops cap enforcement
and allows the resident set size to grow, limited only by other processes
and the amount of memory in the machine. The <literal>rss</literal> column
might stabilize to reflect the project working set size (WSS), 6247M in this
example. This is the minimum cap value that allows the project's processes
to operate without continuously incurring page faults.</para><para>While the cap on <literal>user1</literal> is 6 Gbytes, in every 5&ndash;second
sample interval the RSS decreases and I/O increases as <command>rcapd</command> pages
out some of the workload's memory. Shortly after a page out completes, the
workload, needing those pages, pages them back in as it continues running.
This cycle repeats until the cap is raised to 10 Gbytes, approximately halfway
through the example. The RSS then stabilizes at 6.1 Gbytes. Since the workload's
RSS is now below the cap, no more paging occurs. The I/O associated with paging
stops as well. Thus, the project required 6.1 Gbytes to perform
the work it was doing at the time it was being observed.</para><para>Also see the <olink targetdoc="group-refman" targetptr="vmstat-1m" remap="external"><citerefentry><refentrytitle>vmstat</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> and <olink targetdoc="group-refman" targetptr="iostat-1m" remap="external"><citerefentry><refentrytitle>iostat</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man pages.</para>
</sect2><sect2 id="rm.rcapd.task-23"><title>Reporting Memory Utilization and the Memory
Cap Enforcement Threshold</title><para>You can use the <option>g</option> option of <command>rcapstat</command> to
report the following:</para><itemizedlist><listitem><para>Current physical memory utilization as a percentage of physical
memory installed on the system</para>
</listitem><listitem><para>System memory cap enforcement threshold set by <command>rcapadm</command></para>
</listitem>
</itemizedlist><para>The <option>g</option> option causes a memory utilization and cap enforcement
line to be printed at the end of the report for each interval.</para><screen># <userinput>rcapstat -g</userinput>
    id project   nproc    vm   rss   cap    at avgat   pg  avgpg
376565    rcap       0    0K    0K   10G    0K    0K   0K     0K
physical memory utilization: 55%   cap enforcement threshold: 0%
    id project   nproc    vm   rss   cap    at avgat   pg  avgpg
376565    rcap       0    0K    0K   10G    0K    0K   0K     0K
physical memory utilization: 55%   cap enforcement threshold: 0%</screen>
</sect2>
</sect1>
</chapter>