Solaris: Zone memory capping

First you have to have created a zone with memory capping enabled. This would be done during the zonecfg setup:

zonecfg:s8-zone-solar97> add capped-memory
zonecfg:zone:capped-memory> set physical=50m
zonecfg:zone:capped-memory> set swap=100m
zonecfg:zone:capped-memory> set locked=30m
zonecfg:zone:capped-memory> end

Once you zone is configured installed and running, you can view the resources of a zone:

# /bin/prctl -n zone.max-swap `pgrep -z <zone> init`
process: 999: /sbin/init
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
zone.max-swap
        privileged      100.0MB      -   deny                                -
        system          16.0EB     max   deny                                -
# /bin/prctl -n zone.max-locked-memory `pgrep -z <zone> init`
process: 999: /sbin/init
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
zone.max-locked-memory
        privileged      30.0MB      -   deny                                 -
        system          16.0EB    max   deny                                 -
# rcapstat -z 1 1
id zone            nproc    vm   rss   cap    at avgat    pg avgpg
2 <zone>            -      48M   36M   50M    0K    0K    0K    0K

To change the max-swap resource do the following:

# prctl -n zone.max-swap -r -v 200M `pgrep -z  <zone> init`

To change the max-locked-memory resource do the following:

# prctl -n zone.max-locked-memory -r -v 100M `pgrep -z  <zone> init`

Changing the physical memory capping is a little different, you’ll need to use the rcapadm command:

# rcapadm -z <zone> -m 100M

Then to view all the resources again, you should see the changes:

# /bin/prctl -n zone.max-swap `pgrep -z <zone> init`
process: 999: /sbin/init
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
zone.max-swap
       privileged      200.0MB      -   deny                                 -
       system          16.0EB     max   deny                                 -
# /bin/prctl -n zone.max-locked-memory `pgrep -z <zone> init`
process: 999: /sbin/init
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
zone.max-locked-memory
        privileged      100.0MB     -   deny                                 -
        system          16.0EB    max   deny                                 -
# rcapstat -z 1 1
id zone            nproc    vm   rss   cap    at avgat    pg avgpg
2 <zone>            -      48M   36M   100M   0K    0K    0K    0K

That’s it. To make the changes permanent, you’ll need to go into zonecfg and adjust the resources that way.

# zonecfg -z <zone>
zonecfg:s8-zone-solar97> select capped-memory
zonecfg:zone:capped-memory> set physical=100m
zonecfg:zone:capped-memory> set swap=200m
zonecfg:zone:capped-memory> set locked=100m
zonecfg:zone:capped-memory> end
zonecfg:zone:> commit

This will save the zone configuration file so the next time the zone boots the memory limit will be set, otherwise the changes are only temporary.

Leave a Comment

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top