Dynamically change zone capped memory

  • Display the zone’s current memory cap:
# rcapstat -z 1 1
    id zone            cappd  nproc     vm     rss    cap    at   avgat    pg   avgpg
     1 zone1           Yes        -    16G     16G    32G    0K      0K    0K      0K
using zonecfg:
# zonecfg -z zone1 info capped-memory
capped-memory:
    physical: 32G
    [swap: 8G]
    [locked: 16G]

If the zone has no memory cap it will not appear in the above output.

Display the zone’s current usage (see the last two columns to view the total cap and the percentage of the cap currently in use):

# zonestat -z zone1 -r memory 1 1
Collecting data for first interval…
Interval: 1, Duration: 0:00:01
PHYSICAL-MEMORY    SYSTEM MEMORY
mem_default              256G
    ZONE     USED    %USED     CAP   %CAP
 [total]     113G    44.4%       -      -
[system]     27.9G   10.9%       -      -
   zone1     46.1G   18.0%   16.0G   72.0%
  • Solaris 10 – 11.1
# prctl -n zone.max-swap -v 48g -r -i zone zone1
# rcapadm -z zone1 -m 16g
  • Solaris 11.2 onwards – Kernel zones will require reboot
# zonecfg –z zone1
zonecfg:zone1> select capped-memory
zonecfg:zone1:capped-memory> set physical=24g
zonecfg:zone1:capped-memory> end
zonecfg:zone1> verify
zonecfg:zone01> exit
# zoneadm -z zone1 apply
zone 'zone1': Checking: Adding capped-memory set physical=24g
zone 'zone1': Applying the changes

Display current memory usage:

$ echo "::memstat" | mdb -k
 Usage Type/Subtype                      Pages    Bytes  %Tot  %Tot/%Subt
 
 Kernel                                8950943    68.2g 14.3%
   Regular Kernel                      2234192    17.0g        3.5%/24.9%
   Defdump prealloc                    6716751    51.2g       10.7%/75.0%
 ZFS                                   5285926    40.3g  8.4%
 Kernel Zones                         26224640   200.0g 41.9%
 User/Anon                              255173     1.9g  0.4%
 Exec and libs                            2376    18.5m  0.0%
 Page Cache                               6894    53.8m  0.0%
 Free (cachelist)                        18459   144.2m  0.0%
 Free                                 21744165   165.8g 34.7%
   Regular Free                       13093413    99.8g       20.9%/60.2%
   MRP reserved mem                    8650752      66g       13.8%/39.7%
 Total                                62488576   476.7g  100%