<chapter id="chp-vminfo"><title><literal>vminfo</literal> Provider</title><highlights><para>The <literal>vminfo</literal> provider makes available probes that correspond to the <literal>vm</literal> kernel statistics. Because these statistics provide the input for system monitoring utilities like <olink targetdoc="refman1m" targetptr="vmstat-1m" remap="external"><citerefentry><refentrytitle>vmstat</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink>, the <literal>vminfo</literal> provider enables quick exploration of observed aberrant behavior.</para>
</highlights><sect1 id="chp-vminfo-1"><title>Probes</title><para><indexterm><primary>probes</primary><secondary><literal>vminfo</literal></secondary></indexterm><indexterm><primary><literal>vminfo</literal> probe</primary></indexterm>The <literal>vminfo</literal> provider makes available probes that correspond to the fields in the <literal>vm</literal> named kernel statistic: a probe provided by <literal>vminfo</literal> fires immediately before the corresponding <literal>vm</literal> value is incremented. To display both the names and the current values of the <literal>vm</literal> named kernel statistic, use the <olink targetdoc="refman1m" targetptr="kstat-1m" remap="external"><citerefentry><refentrytitle>kstat</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> command, as shown in the following example:</para><screen><userinput>$ kstat -n vm</userinput>
module: cpu                             instance: 0
name:   vm                              class:    misc
        anonfree                        13
        anonpgin                        2620
        anonpgout                       13
        as_fault                        12528831
        cow_fault                       2278711
        crtime                          202.10625712
        dfree                           1328740
        execfree                        0
        execpgin                        5541
        ...</screen><para>The <literal>vminfo</literal> probes are described in <olink targetptr="tbl-vminfo" remap="internal">Table&nbsp;24&ndash;1</olink>.</para><table frame="topbot" id="tbl-vminfo"><title><literal>vminfo</literal> Probes</title><tgroup cols="2" colsep="0" rowsep="0"><colspec colname="colspec0" colwidth="1.00in"/><colspec colname="colspec1" colwidth="4.00in"/><tbody><row><entry colname="colspec0"><para><literal>anonfree</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever an unmodified anonymous page is freed as part of paging activity. Anonymous pages are those that are not associated with a file. Memory containing such pages includes heap memory, stack memory, or memory obtained by explicitly mapping <olink targetdoc="refman7" targetptr="zero-7d" remap="external"><citerefentry><refentrytitle>zero</refentrytitle><manvolnum>7D</manvolnum></citerefentry></olink>.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>anonpgin</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever an anonymous page is paged in from a swap device.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>anonpgout</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a modified anonymous page is paged out to a swap device.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>as_fault</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a fault is taken on a page and the fault is neither a protection fault nor a copy-on-write fault.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>cow_fault</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a copy-on-write fault is taken on a page. <literal>arg0</literal> contains the number of pages that are created as a result of the copy-on-write.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>dfree</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a page is freed as a result of paging activity. Whenever <literal>dfree</literal> fires, exactly one of <literal>anonfree</literal>, <literal>execfree</literal> or <literal>fsfree</literal> will also subsequently fire.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>execfree</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever an unmodified executable page is freed as a result of paging activity.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>execpgin</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever an executable page is paged in from the backing store.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>execpgout</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a modified executable page is paged out to the backing store. Most paging of executable pages occurs in terms of <literal>execfree</literal>. <literal>execpgout</literal> can only fire if an executable page is modified in memory, an uncommon occurrence in most systems.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>fsfree</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever an unmodified file system data page is freed as part of paging activity.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>fspgin</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a file system page is paged in from the backing store.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>fspgout</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a modified file system page is paged out to the backing store.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>kernel_asflt</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a page fault is taken by the kernel on a page in its own address space. Whenever <literal>kernel_asflt</literal> fires, it will be immediately preceded by a firing of the <literal>as_fault</literal> probe.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>maj_fault</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a page fault is taken that results in I/O from a backing store or swap device. Whenever <literal>maj_fault</literal> fires, it will be immediately preceded by a firing of the <literal>pgin</literal> probe.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>pgfrec</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a page is reclaimed off of the free page list.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>pgin</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a page is paged in from the backing store or from a swap device. This probe differs from <literal>maj_fault</literal> in that <literal>maj_fault</literal> only fires when a page is paged in as a result of a page fault. <literal>pgin</literal> fires every time a page is paged in, regardless of the reason.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>pgout</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a page is paged out to the backing store or to a swap device.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>pgpgin</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a page is paged in from the backing store or from a swap device. The only difference between <literal>pgpgin</literal> and <literal>pgin</literal> is that <literal>pgpgin</literal> contains the number of pages paged in as <literal>arg0</literal>. <literal>pgin</literal> always contains 1 in <literal>arg0</literal>.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>pgpgout</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a page is paged out to the backing store or to a swap device. The only difference between <literal>pgpgout</literal> and <literal>pgout</literal> is that <literal>pgpgout</literal> contains the number of pages paged out as <literal>arg0</literal>. (<literal>pgout</literal> always contains 1 in <literal>arg0</literal>.)</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>pgrec</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a page is reclaimed.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>pgrrun</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever the pager is scheduled.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>pgswapin</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever pages from a swapped-out process are swapped in. The number of pages swapped in is contained in <literal>arg0</literal>.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>pgswapout</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever pages are swapped out as part of swapping out a process. The number of pages swapped out is contained in <literal>arg0</literal>.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>prot_fault</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a page fault is taken due to a protection violation.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>rev</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever the page daemon begins a new revolution through all pages.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>scan</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever the page daemon examines a page.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>softlock</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a page is faulted as a part of placing a software lock on the page.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>swapin</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a swapped-out process is swapped back in.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>swapout</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a process is swapped out.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>zfod</literal></para>
</entry><entry colname="colspec1"><para>Probe that fires whenever a zero-filled page is created on demand.</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect1><sect1 id="chp-vminfo-2"><title>Arguments</title><indexterm><primary>probes</primary><secondary><literal>vminfo</literal></secondary><tertiary>arguments</tertiary>
</indexterm><indexterm><primary><literal>vminfo</literal> probe</primary><secondary>arguments</secondary>
</indexterm><informaltable frame="topbot"><tgroup cols="2" colsep="0" rowsep="0"><?PubTbl tgroup dispwid="6.02in"?><colspec colname="colspec0" colwidth="1.00in"/><colspec colname="colspec1" colwidth="4.00in"/><tbody><row><entry><para><literal>arg0</literal></para>
</entry><entry><para>The value by which the statistic is to be incremented. For most probes, this argument is always 1, but for some it may take other values; these probes are noted in <olink targetptr="tbl-vminfo" remap="internal">Table&nbsp;24&ndash;1</olink>.</para>
</entry>
</row><row><entry><para><literal>arg1</literal></para>
</entry><entry><para>A pointer to the current value of the statistic to be incremented. This value is a 64&ndash;bit quantity that will be incremented by the value in <literal>arg0</literal>. Dereferencing this pointer allows consumers to determine the current count of the statistic corresponding to the probe.</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="chp-vminfo-3"><title>Example</title><para><indexterm><primary>probes</primary><secondary><literal>vminfo</literal></secondary><tertiary>example of use</tertiary></indexterm><indexterm><primary><literal>vminfo</literal> probe</primary><secondary>example</secondary></indexterm>Examine the following output from <olink targetdoc="refman1m" targetptr="vmstat-1m" remap="external"><citerefentry><refentrytitle>vmstat</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink>:</para><screen>kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr cd s0 &mdash; &mdash;   in   sy   cs us sy id
 0 1 0 1341844 836720 26 311 1644 0 0 0  0 216 0  0  0  797  817  697  9 10 81
 0 1 0 1341344 835300 238 934 1576 0 0 0 0 194 0  0  0  750 2795  791  7 14 79
 0 1 0 1340764 833668 24 165 1149 0 0 0  0 133 0  0  0  637  813  547  5  4 91
 0 1 0 1340420 833024 24 394 1002 0 0 0  0 130 0  0  0  621 2284  653 14  7 79
 0 1 0 1340068 831520 14 202 380 0 0  0  0 59  0  0  0  482 5688 1434 25  7 68</screen><para>The <literal>pi</literal> column in the above output denotes the number of pages paged in. The <literal>vminfo</literal> provider enables you to learn more about the source of these page-ins, as shown in the following example:</para><screen><userinput>dtrace -n pgin'{@[execname] = count()}'</userinput>
dtrace: description 'pgin' matched 1 probe
<userinput>^C</userinput>
  xterm                                                             1
  ksh                                                               1
  ls                                                                2
  lpstat                                                            7
  sh                                                               17
  soffice                                                          39
  javaldx                                                         103
  soffice.bin                                                    3065</screen><para>The output shows that a process associated with the <trademark>StarOffice</trademark> software, <literal>soffice.bin</literal>, is responsible for most of the page-ins. To get a better picture of <literal>soffice.bin</literal> in terms of virtual memory behavior, you could enable all <literal>vminfo</literal> probes. The following example runs <olink targetdoc="refman1m" targetptr="dtrace-1m" remap="external"><citerefentry><refentrytitle>dtrace</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> while launching the StarOffice software:</para><screen><userinput>dtrace -P vminfo'/execname == "soffice.bin"/{@[probename] = count()}'</userinput>
dtrace: description 'vminfo' matched 42 probes
<userinput>^C</userinput>

  kernel_asflt                                                      1
  fspgin                                                           10
  pgout                                                            16
  execfree                                                         16
  execpgout                                                        16
  fsfree                                                           16
  fspgout                                                          16
  anonfree                                                         16
  anonpgout                                                        16
  pgpgout                                                          16
  dfree                                                            16
  execpgin                                                         80
  prot_fault                                                       85
  maj_fault                                                        88
  pgin                                                             90
  pgpgin                                                           90
  cow_fault                                                       859
  zfod                                                           1619
  pgfrec                                                         8811
  pgrec                                                          8827
  as_fault                                                       9495</screen><para>The following example script provides more information about the virtual memory behavior of the StarOffice software during its startup:</para><programlisting>vminfo:::maj_fault,
vminfo:::zfod,
vminfo:::as_fault
/execname == "soffice.bin" &amp;&amp; start == 0/
{
	/*
	 * This is the first time that a vminfo probe has been hit; record
	 * our initial timestamp.
	 */
	start = timestamp;
}

vminfo:::maj_fault,
vminfo:::zfod,
vminfo:::as_fault
/execname == "soffice.bin"/
{
	/*
	 * Aggregate on the probename, and lquantize() the number of seconds
	 * since our initial timestamp.  (There are 1,000,000,000 nanoseconds
	 * in a second.)  We assume that the script will be terminated before
	 * 60 seconds elapses.
	 */
	@[probename] =
	    lquantize((timestamp - start) / 1000000000, 0, 60);
}</programlisting><para>Run the script while again starting the StarOffice software. Then, create a new drawing, create a new presentation, and then close all files and quit the application. Press Control-C in the shell running the D script. The results provide a view of some virtual memory behavior over time:</para><screen><userinput># dtrace -s ./soffice.d</userinput>
dtrace: script './soffice.d' matched 10 probes
<userinput>^C</userinput>

 maj_fault                                         
           value  ------------- Distribution ------------- count    
               7 |                                         0        
               8 |@@@@@@@@@                                88       
               9 |@@@@@@@@@@@@@@@@@@@@                     194      
              10 |@                                        18       
              11 |                                         0        
              12 |                                         0        
              13 |                                         2        
              14 |                                         0        
              15 |                                         1        
              16 |@@@@@@@@                                 82       
              17 |                                         0        
              18 |                                         0        
              19 |                                         2        
              20 |                                         0        

  zfod                                              
           value  ------------- Distribution ------------- count    
             &lt; 0 |                                         0        
               0 |@@@@@@@                                  525      
               1 |@@@@@@@@                                 605      
               2 |@@                                       208      
               3 |@@@                                      280      
               4 |                                         4        
               5 |                                         0        
               6 |                                         0        
               7 |                                         0        
               8 |                                         44       
               9 |@@                                       161      
              10 |                                         2        
              11 |                                         0        
              12 |                                         0        
              13 |                                         4        
              14 |                                         0        
              15 |                                         29       
              16 |@@@@@@@@@@@@@@                           1048     
              17 |                                         24       
              18 |                                         0        
              19 |                                         0        
              20 |                                         1        
              21 |                                         0        
              22 |                                         3        
              23 |                                         0        

  as_fault                                          
           value  ------------- Distribution ------------- count    
             &lt; 0 |                                         0        
               0 |@@@@@@@@@@@@@                            4139     
               1 |@@@@@@@                                  2249     
               2 |@@@@@@@                                  2402     
               3 |@                                        594      
               4 |                                         56       
               5 |                                         0        
               6 |                                         0        
               7 |                                         0        
               8 |                                         189      
               9 |@@                                       929      
              10 |                                         39       
              11 |                                         0        
              12 |                                         0        
              13 |                                         6        
              14 |                                         0        
              15 |                                         297      
              16 |@@@@                                     1349     
              17 |                                         24       
              18 |                                         0        
              19 |                                         21       
              20 |                                         1        
              21 |                                         0        
              22 |                                         92       
              23 |                                         0</screen><para>The output shows some StarOffice behavior with respect to the virtual memory system. For example, the <literal>maj_fault</literal> probe didn't fire until a new instance of the application was started. As you would hope, a &ldquo;warm start&rdquo; of StarOffice did not result in new major faults. The <literal>as_fault</literal> output shows an initial burst of activity, latency while the user located the menu to create a new drawing, another period of idleness, and a final burst of activity when the user clicked on a new presentation. The <literal>zfod</literal> output shows that creating the new presentation induced significant pressure for zero-filled pages, but only for a short period of time.</para><para>The next iteration of DTrace investigation in this example would depend on the direction you want to explore. If you want to understand the source of the demand for zero-filled pages, you could aggregate on <function>ustack</function> in a <literal>zfod</literal> enabling. You might want to establish a threshold for zero-filled pages and use the <function>stop</function> destructive action to stop the offending process when the threshold is exceeded. This approach would enable you to use more traditional debugging tools like <olink targetdoc="refman1" targetptr="truss-1" remap="external"><citerefentry><refentrytitle>truss</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink> or <olink targetdoc="refman1" targetptr="mdb-1" remap="external"><citerefentry><refentrytitle>mdb</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink>. The <literal>vminfo</literal> provider enables you to associate statistics seen in the output of conventional tools like <olink targetdoc="refman1m" targetptr="vmstat-1m" remap="external"><citerefentry><refentrytitle>vmstat</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> with the applications that are inducing the systemic behavior.</para>
</sect1><sect1 id="chp-vminfo-stability"><title>Stability</title><para><indexterm><primary>stability</primary><secondary><literal>vminfo</literal></secondary></indexterm><indexterm><primary><literal>vminfo</literal> probe</primary><secondary>stability</secondary></indexterm>The <literal>vminfo</literal> provider uses DTrace's stability mechanism to describe its stabilities, as shown in the following table. For more information about the stability mechanism, see <olink targetptr="chp-stab" remap="internal">Chapter&nbsp;39, Stability</olink>.</para><informaltable frame="topbot"><tgroup cols="4" colsep="0" rowsep="0"><colspec colwidth="25*"/><colspec colwidth="25*"/><colspec colwidth="25*"/><colspec colwidth="25*"/><thead><row rowsep="1"><entry colsep="1"><para>Element</para>
</entry><entry><para>Name stability</para>
</entry><entry><para>Data stability</para>
</entry><entry><para>Dependency class</para>
</entry>
</row>
</thead><tbody><row><entry colsep="1"><para>Provider</para>
</entry><entry><para>Evolving</para>
</entry><entry><para>Evolving</para>
</entry><entry><para><acronym>ISA</acronym></para>
</entry>
</row><row><entry colsep="1"><para>Module</para>
</entry><entry><para>Private</para>
</entry><entry><para>Private</para>
</entry><entry><para>Unknown</para>
</entry>
</row><row><entry colsep="1"><para>Function</para>
</entry><entry><para>Private</para>
</entry><entry><para>Private</para>
</entry><entry><para>Unknown</para>
</entry>
</row><row><entry colsep="1"><para>Name</para>
</entry><entry><para>Evolving</para>
</entry><entry><para>Evolving</para>
</entry><entry><para><acronym>ISA</acronym></para>
</entry>
</row><row><entry colsep="1"><para>Arguments</para>
</entry><entry><para>Private</para>
</entry><entry><para>Private</para>
</entry><entry><para><acronym>ISA</acronym></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1>
</chapter>