Home / Resource Management / rcapadm – Solaris Online Resource Capping

rcapadm – Solaris Online Resource Capping

As you know, system resources like CPU,MEMORY,SWAP can be limited to Solaris local zones using capping.We do the resource capping by just using “zonecfg” command. But the changes are instantaneous ?  No. You need to reboot the local zone in a order to take the settings effect.Here we will see how to make the changes instantaneous. But instantaneous    

is not permanent.You need to update zonecfg to make persist across the local zone reboot. 

Here we are going to see how to modify the physical memory,SWAP,CPU & locked memory on the fly while zone is running. These changes are immediate effect. 

Zones-Dynamic Memory  using rcapadm:
To find the current capped physical memory use,

# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   2 sol1             running    /export/zone/sollz1            native   shared
# rcapstat -z 1 1
    id zone            nproc    vm   rss   cap    at avgat    pg avgpg
     2 sol1               31  146M  100M  100M  110M    0K   73M    0K
bash-3.00#

We can see the capped memory value using zonecfg command as well,but there shouldn’t be any memory value modification on the system after the zone boot.

# zonecfg -z sol1 info
zonename: sol1
zonepath: /export/zone/sollz1
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
hostid:
inherit-pkg-dir:
        dir: /lib
inherit-pkg-dir:
        dir: /platform
inherit-pkg-dir:
        dir: /sbin
inherit-pkg-dir:
        dir: /usr
capped-cpu:
        [ncpus: 1.00]
capped-memory:
        physical: 100M

As per the above command output ,capped memory has been set as 100M for local zone “sol1” . Now we will see how to modify that value on fly.

# rcapadm -z sol1 -m 200M
# rcapstat -z 1 1
    id zone            nproc    vm   rss   cap    at avgat    pg avgpg
     2 sol1               31  146M   97M  100M  110M    0K   73M    0K
# rcapstat -z 1 1
    id zone            nproc    vm   rss   cap    at avgat    pg avgpg
     2 sol1               31  146M   97M  200M  110M    0K   73M    0K

After executing rcapadm command ,system takes few seconds to take effect. So please be patient.Now you can see system memory capping has been changed from 100M to 200M.

Zones-Dynamic swap:
To check the currently capped swap space,

# /bin/prctl -n zone.max-swap `pgrep -z sol1 init`
process: 1901: /sbin/init
NAME          PRIVILEGE        VALUE    FLAG   ACTION                       RECIPIENT
zone.max-swap  system          16.0EB    max   deny                                 -

As per the above ,there is no restriction has been set for swap.

To set the swap to specific value,

# prctl -n zone.max-swap -r -v 150M `pgrep -z  sol1 init`
1901:   /sbin/init
prctl: cannot modify system values

Oops.We got an error while setting new swap value for zone.

let us check the usage of prctl.

usage:
    Report resource control values and actions:
        prctl [-P] [-t [basic | privileged | system]
        [-n name] [-i process | task | project | zone] id ...
        -P space delimited output
        -t privilege level of rctl values to get
        -n name of resource control values to get
        -i idtype of operand list
    Manipulate resource control values:
        prctl [-t [basic | privileged | system]
        -n name [-srx] [-v value] [-p pid ] [-e | -d action]
        [-i process | task | project | zone] id ...
        -t privilege level of rctl value to set/replace/delete/modify
        -n name of resource control to set/replace/delete/modify
        -s set new resource control value
        -r replace first rctl value of matching privilege
        -x delete first rctl value of matching privilege, value, and
           recipient pid
        -v value of rctl to set/replace/delete/modify
        -p recipient pid of rctl to set/replace/delete/modify
        -e enable action of first rctl value of matching privilege,
           value, and recipient pid
        -d disable action of first rctl value of matching privilege,
           value, and recipient pid
        -i idtype of operand list

 “-r” option is used to replace the existing value.We suppose to use “-s” option to set new value. 

Let us try this as well.

# prctl -n zone.max-swap -s -v 150M `pgrep -z  sol1 init`
1901:   /sbin/init
prctl: failed to create resource control zone.max-swap for pid 1901: Invalid argument
bash-3.00#

After a lot of research, I got the workaround for this issue.prctl command will work only if you have already configured swap,locked memory and capped-cpu respectively for each type of resource. In my zone setup , i don;t have pre-configured swap.That’s why i was getting error while modifying it and unable to set new value as well.

So the bottom line is , if you have existing capped values for swap,locked memory & cpu ,you can modify it.Otherwise you can’t modify these values are in fly.

# zonecfg -z sol1
zonecfg:sol1> select capped-memory
zonecfg:sol1:capped-memory> info
capped-memory:
        physical: 100M
zonecfg:sol1:capped-memory> set swap=100m
zonecfg:sol1:capped-memory> set locked=10M
zonecfg:sol1:capped-memory> info
capped-memory:
        physical: 100M
        [swap: 100M]
        [locked: 10M]
zonecfg:sol1:capped-memory> end
zonecfg:sol1> verify
zonecfg:sol1> commit
zonecfg:sol1> exit
# zoneadm -z sol1 reboot



Now you can try to set swap values,

# prctl -n zone.max-swap -r -v 150M `pgrep -z  sol1 init`
# /bin/prctl -n zone.max-swap `pgrep -z sol1 init`
process: 7652: /sbin/init
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
zone.max-swap
        privileged       150MB      -   deny                                 -
        system          16.0EB    max   deny


  wow …its working fine.

Zones-Dynamic locked memory:
Let’s try to set new locked memory ,

# /bin/prctl -n zone.max-locked-memory `pgrep -z sol1 init`
process: 7652: /sbin/init
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
zone.max-locked-memory
        privileged      10.0MB      -   deny                                 -
        system          16.0EB    max   deny                                 -
# prctl -n zone.max-locked-memory -r -v 20M `pgrep -z sol1 init`
# /bin/prctl -n zone.max-locked-memory `pgrep -z sol1 init`
process: 7652: /sbin/init
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
zone.max-locked-memory
        privileged      20.0MB      -   deny                                 -
        system          16.0EB    max   deny                                 -
bash-3.00#



Cool..Its  working fine for locked memory as well.

Zones:Dynamic CPU:
We can modify the number of CPU’s using prctl command if capped-cpu is already configured on local zones.

# /bin/prctl -n zone.cpu-cap  `pgrep -z sol1 init`
process: 9383: /sbin/init
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
zone.cpu-cap
        privileged        100       -   deny                                 -
        system          4.29G     inf   deny

Existing  value is showing as 100 . In zonecfg we have assigned “ncpus=1” . Which means zone sol1 can use 100% CPU time from one processor.

Let us set 200, so that zone sol1 can use 100% time of two CPU’s.

# prctl -n zone.cpu-cap -v 200 -r -i zone sol1
# /bin/prctl -n zone.cpu-cap  `pgrep -z sol1 init`
process: 9383: /sbin/init
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
zone.cpu-cap
        privileged        200       -   deny                                 -
        system          4.29G     inf   deny                                 -
#

This has been done.Now zone “sol1” can use 2 CPU’s completely. 
Note:Solaris 10 5/08: The zone.cpu-cap resource control sets an absolute limit on the amount of CPU resources that can be consumed by a zone. A value of 100 means 100 percent of one CPU as the project.cpu-cap setting. A value of 125 is 125 percent, because 100 percent corresponds to one full CPU on the system when using CPU caps.Refer:http://docs.oracle.com/cd/E19455-01/817-1592/z.config.ov-13/index.html

Thank you for reading this article. Please leave a  comment if you have any doubt.I will get back to you.
VMTURBO-CLOUD-CAPACITY

One comment

  1. Hi friend what is the difference between physical and locked in rcapadm ?