Updated 22 March 2010
Linux Logo

Enable Zone to Use Fair Share Schedule (FSS) of CPU's


Description:
  • This procedure describes how to enable the the Fair Share Schedular (FSS) with a zone to manage CPU resources.
Prerequisites:
  • Resource Pools must be enable.
  • Must be root.
Notes:
  • Fair Share Schedular (FSS) of CPU's allocates a share value to each zone. For the zones that are busy, CPU allocation is based on the ratio of the zone's shares over the total shares of the busy zones. It's advantage is the best division of CPU resources amongst the zones, where shares are the quantum not CPUs, and as such may be the only way to go if you have more zones than CPUs.
  • An advantage of fixed CPU's per zone is there is better level 1 and level 2 cache hit rates for each zone.
  • A disadvantage will be that zone that is idle would not share CPU resources with a zone that has a high demand.
References:

Step Action Description
1 Enable Pool
  • Use pgrep and pooladm to check to see if resource pool faclility is already running.
  • If not already running use pooladm -e to start resource pool facility.
# pooladm -e
global# pgrep -l poold
global# pooladm
pooladm: couldn't open pools state file: Facility is not active 
global# 
global# pooladm -e
global# 
global# pgrep -l poold
 1429 poold
global# pooladm
 
system titan
        string  system.comment 
        int     system.version 1
[...]
2 Configure Pools Script

To enable a zone to use the Fair Shair utility with its processors, only a pool needs to be defined.

  • Create a text file consisting of the parameters for creation of the new pools. This text file contains three definition types.
    • defines a pool with pool.scheduler assigned as "FSS".
mypool temporary text file
# myscript - poolcfg script for varying CPUs.
#
# Load using:
# pooladm -x; pooladm -s; poolcfg -f myscript; pooladm -c
# 
# 14-Jan-2005   Brendan Gregg   Created this.
 
create pool work1-pool ( string pool.scheduler = "FSS" )
create pool work2-pool ( string pool.scheduler = "FSS" )
create pool work3-pool ( string pool.scheduler = "FSS" )
create pool work4-pool

This text file consist of three entry types with key words:

  • create pool - creates a resource pool using the keywords "create pool <pool name>-pool" followed by in parenthesis assign the parameter string pool.scheduler to "FSS". The pool name should use the "-pool" convention.
create pool <pool name>-pool ( string pool.scheduler = "FSS" )
3 Configure Pools Configure and activate the new pool and processor set configuration using the pooladm and poolcfg in this order:
pooladm -x - flush current in-memory pool configuration
pooladm -s - create default /etc/pooladm.conf configuration file
poolcfg -f <pool file name> - process and save "pool file name" configuration in /etc/pooladm.conf
global# ls /etc/pooladm.conf
/etc/pooladm.conf: No such file or directory
global# pooladm -x
global# pooladm -s
global# ls /etc/pooladm.conf
/etc/pooladm.conf
global# poolcfg -f <myscript>
Notes:
  • Creating a temporary script configuration file to define a pool and processor set is the recommended procedure. But it may also be accomplished temporarily using poolcfg -dc
global# poolcfg -dc info
global# poolcfg -dc 'create pset work1-pset'
global# poolcfg -dc 'create pool work1-pool'
global# poolcfg -dc 'modify pset work1-pset ( uint pset.min = 2; uint pset.max = 8 )'
global# poolcfg -dc 'modify pool work1-pool ( string pool.scheduler = "FSS" )'
global# poolcfg -dc 'modify pool work1-pool ( int pool.importance = 10 )'
global# poolcfg -dc 'destroy pool work1-pool'

The "-d" option changes the memory configuration directly.

  • Use "poolcfg -dc info" to verify that the new pool set does exist.
  • Be careful when rerunning those four commands on a system that already has zones and pools configured. Existing zones may need to be rebooted or poolbind to attach their processor set.
4 Load Pools
  • Use "pooladm -c" to load processor set.
  • Check the processor sets by running "psrset" before and after to check if any processor sets have been automatically created.
global# pooladm -x
global# pooladm -s
global# poolcfg -f <pool file name>
global# pooladm -c
global# psrset
global#

No processor sets are created when using an FSS pool.

  • Use "pooladm" to check the current state in more detail.
global# pooladm
 
system titan
        string  system.comment 
        int system.version 1
        boolean system.bind-default true
        int system.poold.pid 220

        pool work4-pool
                int     pool.sys_id 4
                boolean pool.active true
                boolean pool.default false
                int     pool.importance 1
                string  pool.comment 
                pset    pset_default
 
        pool work1-pool
                int     pool.sys_id 1
                boolean pool.active true
                boolean pool.default false
                string  pool.scheduler FSS
                int     pool.importance 1
                string  pool.comment 
                pset    pset_default
 
        pool pool_default
                int     pool.sys_id 0
                boolean pool.active true
                boolean pool.default true
                int     pool.importance 1
                string  pool.comment 
                pset    pset_default

        pool work3-pool
                int     pool.sys_id 3
                boolean pool.active true
                boolean pool.default false
                string  pool.scheduler FSS
                int     pool.importance 1
                string  pool.comment 
                pset    pset_default

        pool work2-pool
                int     pool.sys_id 2
                boolean pool.active true
                boolean pool.default false
                string  pool.scheduler FSS
                int     pool.importance 1
                string  pool.comment 
                pset    pset_default

        pset pset_default
                int     pset.sys_id -1
                boolean pset.default true
                uint    pset.min 1
                uint    pset.max 65536
                string  pset.units population
                uint    pset.load 48155
                uint    pset.size 8
                string  pset.comment 

                cpu
                        int     cpu.sys_id 1
                        string  cpu.comment 
                        string  cpu.status on-line

                cpu
                        int     cpu.sys_id 0
                        string  cpu.comment 
                        string  cpu.status on-line

                cpu
                        int     cpu.sys_id 3
                        string  cpu.comment 
                        string  cpu.status on-line

                cpu
                        int     cpu.sys_id 2
                        string  cpu.comment 
                        string  cpu.status on-line

                cpu
                        int     cpu.sys_id 515
                        string  cpu.comment 
                        string  cpu.status on-line

                cpu
                        int     cpu.sys_id 514
                        string  cpu.comment 
                        string  cpu.status on-line

                cpu
                        int     cpu.sys_id 513
                        string  cpu.comment 
                        string  cpu.status on-line

                cpu
                        int     cpu.sys_id 512
                        string  cpu.comment 
                        string  cpu.status on-line
global#
5 Enable Fair Share Sceduler Use /usr/sbin/dispadmin to assign Fair Share to the processor schedule and enable the process schedule if not already running. You can verify that FFS is running using ps -efc.
global# ps -efc
     UID   PID  PPID  CLS PRI    STIME TTY         TIME CMD
    root     0     0  SYS  96   Aug 02 ?           1:58 sched
    root     1     0   TS  59   Aug 02 ?           0:06 /sbin/init
    root     2     0  SYS  98   Aug 02 ?           0:00 pageout
    root     3     0  SYS  60   Aug 02 ?          72:17 fsflush
    root     7     1   TS  59   Aug 02 ?           1:05 /lib/svc/bin/svc.startd
    root     9     1   TS  59   Aug 02 ?           0:21 /lib/svc/bin/svc.configd
    root   107     1   TS  59   Aug 02 ?           1:02 /usr/sbin/nscd
  daemon   195     1   TS  59   Aug 02 ?           0:00 /usr/sbin/rpcbind
    root   615   595   TS  59   Aug 02 ?           0:05 /sbin/init 
    root   105     1   TS  59   Aug 02 ?           0:00 /usr/lib/picl/picld
    root   196     1   TS  59   Aug 02 ?           0:00 /usr/sbin/cron
  daemon   109     1   TS  59   Aug 02 ?           0:00 /usr/lib/crypto/kcfd
     ......              ......            .....             ......
     ......              ......            .....             ......
global# ls /etc/dispadmin.conf
/etc/dispadmin.conf: No such file or directory
global# /usr/sbin/dispadmin -d FSS
global# ls /etc/dispadmin.conf
/etc/dispadmin.conf
global# cat /etc/dispadmin.conf
#
# /etc/dispadmin.conf
#
# Do NOT edit this file by hand -- use dispadmin(1m) instead.
#
DEFAULT_SCHEDULER=FSS
global#
6 # init 6 Reboot the system to start or restart the Fair Share Scheduler. Verify that FFS is running using ps -efc. TS will chnage to FSS in the CLS column (Schedule Class).
global# init 6
  ......           ......         .....       ......
  ......           ......         .....       ......
global login:
  ......           ......         .....       ......
  ......           ......         .....       ......
global# ps -efc
     UID   PID  PPID  CLS PRI    STIME TTY         TIME CMD
    root     0     0  SYS  96 17:26:28 ?           1:54 sched
    root     1     0  FSS  59 17:26:31 ?           0:00 /sbin/init
    root     2     0  SYS  98 17:26:31 ?           0:00 pageout
    root     3     0  SYS  60 17:26:31 ?           0:01 fsflush
  daemon   201     1  FSS  29 17:26:42 ?           0:00 /usr/lib/nfs/lockd
    root     7     1  FSS  29 17:26:32 ?           0:01 /lib/svc/bin/svc.startd
    root     9     1  FSS  29 17:26:33 ?           0:03 /lib/svc/bin/svc.configd
    root   207     7  FSS  29 17:26:43 ?           0:00 /usr/lib/saf/sac -t 300
  daemon   194     1  FSS  29 17:26:42 ?           0:00 /usr/sbin/rpcbind
    root   110     1  FSS  29 17:26:36 ?           0:00 /usr/lib/sysevent/syseventd
    root   311     1  FSS  29 17:26:45 ?           0:00 /usr/sbin/syslogd
  daemon   106     1  FSS  29 17:26:36 ?           0:00 /usr/lib/crypto/kcfd
     www  1557  1029  FSS   1 17:37:08 ?           0:00 /usr/apache/bin/httpd
   smmsp  1512     1  FSS   1 17:28:35 ?           0:00 /usr/lib/sendmail -Ac -q15m
    root   192     1  FSS  29 17:26:42 ?           0:00 /usr/sbin/cron
     ......              ......            .....             ......
     ......              ......            .....             ......
global#
Notes:
  • The creation of the /etc/dispadmin file will start the process schedule when the global zone is rebooted. The /etc/dispadmin files contains the parameter to initiate the Fair Share Scheduler (FSS) as the default scheduler (DEFAULT_SCHEDULER=FSS). If the /etc/dispadmin file is delete and the system rebooted, the process schedule will be deactivated.
5 Configure Zones Use /usr/sbin/zonecfg to assigned the Fair Share Scheduler pool and then set shared parameter to a zone using the "add rctl" option.
# zonecfg -z <zone name>
zonecfg:workzone1> set pool=<pool name>
zonecfg:workzone1> add rctl
zonecfg:workzone1:rctl> set name=zone.cpu-shares
zonecfg:workzone1:rctl> add value (priv=priviledged,limit=<share value>,action=none)
zonecfg:workzone1:rctl> end
zonecfg:workzone1> verify
zonecfg:workzone1> exit
 
global# zonecfg -z workzone1
zonecfg:workzone1> set pool=work1-pool
zonecfg:workzone1> add rctl
zonecfg:workzone1:rctl> set name=zone.cpu-shares
zonecfg:workzone1:rctl> add value (priv=privileged,limit=30,action=none)
zonecfg:workzone1:rctl> end
zonecfg:workzone1> verify
zonecfg:workzone1> exit
global#
global# zonecfg -z workzone2
zonecfg:workzone2> set pool=work2-pool
zonecfg:workzone2> add rctl
zonecfg:workzone2:rctl> set name=zone.cpu-shares
zonecfg:workzone2:rctl> add value (priv=privileged,limit=15,action=none)
zonecfg:workzone2:rctl> end
zonecfg:workzone2> verify
zonecfg:workzone2> exit
global# 
global# zonecfg -z workzone3
zonecfg:workzone3> set pool=work3-pool
zonecfg:workzone3> add rctl
zonecfg:workzone3:rctl> set name=zone.cpu-shares
zonecfg:workzone3:rctl> add value (priv=privileged,limit=5,action=none)
zonecfg:workzone3:rctl> end
zonecfg:workzone3> verify
zonecfg:workzone3> exit
global#

Verify the zone configuration has been updated by using zonecfg -z <zonename> info. This will display the updated configuration with the pool assignment displayed.

global# zonecfg -z workzone3 info
zonepath: /zones/workzone3
autoboot: true
pool: work3-pool
inherit-pkg-dir:
        dir: /lib
inherit-pkg-dir:
        dir: /platform
inherit-pkg-dir:
        dir: /sbin
inherit-pkg-dir:
        dir: /usr
inherit-pkg-dir:
        dir: /opt/sfw
net:
        address: 192.168.3.44/24
        physical: bge0
rctl:
        name: zone.cpu-shares
        value: (priv=privileged,limit=5,action=none)
global# 
Note: You may also temporarily bind a pool and a processor set using poolbind command with the zoneid as the idtype.
global# poolbind -p work1-pool -i zoneid workzone1
6 Reboot Zones Use zoneadm with the reboot option to reboot the zone. After reboot, verify Fair Share value with /usr/sbin/prctl -n zone.cpu-shares -i zone <zone name>. This will be displayed the Fair Share as the privileged value.
# zoneadm -z <zone name> reboot
 
global# zoneadm -z workzone1 reboot
global#
global# zonecfg -z workzone2 reboot
global# 
global# zonecfg -z workzone3 reboot
global# 
global# /usr/sbin/prctl -n zone.cpu-shares -i zone workzone1
zone: 4: /zones/workzone4
NAME    PRIVILEGE       VALUE    FLAG   ACTION              RECIPIENT
zone.cpu-shares
        privileged         30       -   none                        -
        system          65.5K     max   none                        -
global# /usr/sbin/prctl -n zone.cpu-shares -i zone workzone4
zone: 4: /zones/workzone4
NAME    PRIVILEGE       VALUE    FLAG   ACTION              RECIPIENT
zone.cpu-shares
        privileged         15       -   none                        -
        system          65.5K     max   none                        -
global# /usr/sbin/prctl -n zone.cpu-shares -i zone workzone4
zone: 4: /zones/workzone4
NAME    PRIVILEGE       VALUE    FLAG   ACTION              RECIPIENT
zone.cpu-shares
        privileged          5       -   none                        -
        system          65.5K     max   none                        -
global#
Notes:
  • Other Zones including the Global zone will automatically be assigned a Fair Share value of 1 when using the Fair Share Scheduler. If required, use:

/usr/sbin/prctl -n zone.cpu-share -v <share value> -r zone global

to increase its Fair Share value for the Global Zone.

  • Use /usr/bin/prstat -Z. to show zone process status. These results can only verify that Fair Share has worked properly if the zone has been push to the limits by using a process hog. The example below is running a process hog program on each zone to demonstrate the results.
global# /usr/bin/prstat -Z
   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
  2008 root     4000K 1168K cpu513  28    0   0:02:11 3.7% cpuhog.pl/1
  2018 root     4000K 1168K cpu1    32    0   0:02:11 3.7% cpuhog.pl/1
  2015 root     4000K 1168K cpu515  30    0   0:02:13 3.6% cpuhog.pl/1
  2020 root     4000K 1168K cpu3    29    0   0:02:13 3.6% cpuhog.pl/1
  2010 root     4000K 1168K run     17    0   0:02:11 3.5% cpuhog.pl/1
  2013 root     4000K 1168K run     28    0   0:02:11 3.5% cpuhog.pl/1
  2005 root     4008K 2320K run      8    0   0:02:11 3.5% cpuhog.pl/1
  2014 root     4000K 1168K cpu0    30    0   0:02:11 3.5% cpuhog.pl/1
  2007 root     4000K 1168K run     20    0   0:02:11 3.5% cpuhog.pl/1
  2016 root     4000K 1168K cpu512  28    0   0:02:12 3.5% cpuhog.pl/1
  2021 root     4000K 1168K run     17    0   0:02:11 3.4% cpuhog.pl/1
  2009 root     4000K 1168K run     14    0   0:02:14 3.3% cpuhog.pl/1
  2012 root     4000K 1168K run     16    0   0:02:08 3.3% cpuhog.pl/1
  2006 root     4000K 1304K run     18    0   0:02:13 3.3% cpuhog.pl/1
  2017 root     4000K 1168K run     25    0   0:02:10 3.3% cpuhog.pl/1
ZONEID    NPROC  SIZE   RSS MEMORY      TIME  CPU ZONE
     2       51  182M   93M   0.5%   0:37:27  59% workzone1
     4       51  182M   92M   0.5%   0:16:25  30% workzone2
     3       51  183M   93M   0.5%   0:16:30  10% workzone3
     0       61  359M  194M   1.1%   0:00:11 0.1% global
     1       34  116M   72M   0.4%   0:00:12 0.0% workzone4
Total: 248 processes, 659 lwps, load averages: 51.19, 40.28, 20.52
<control -C>
global#
  • You can also set the Fair Share value for a zone by using /usr/sbin/prctl with the following syntax:

/usr/sbin/prctl -n zone.cpu-share -v <share value> -r zone <zone name>

The Fair Share value will be retained as long as the global zone is not rebooted.

  • Using /usr/sbin/prctl to change the Fair Share value will not display in the zone configuration information with /usr/sbin/zonecfg.
global# /usr/sbin/zonecfg -z workzone4 info
zonepath: /zones/workzone4
autoboot: true
pool: 
inherit-pkg-dir:
        dir: /lib
inherit-pkg-dir:
        dir: /platform
inherit-pkg-dir:
        dir: /sbin
inherit-pkg-dir:
        dir: /usr
inherit-pkg-dir:
        dir: /opt/sfw
net:
        address: 192.168.3.25/24
        physical: bge0
global# /usr/sbin/prctl -n zone.cpu-shares -i zone workzone4
zone: 4: workzone4
NAME    PRIVILEGE       VALUE    FLAG   ACTION              RECIPIENT
zone.cpu-shares
        privileged          1       -   none                        -
        system          65.5K     max   none                        -
global# /usr/sbin/prctl -n zone.cpu-share -v 30 -r zone workzone4
global# /usr/sbin/zonecfg -z workzone4 info
zonepath: /zones/workzone4
autoboot: true
pool: 
inherit-pkg-dir:
        dir: /lib
inherit-pkg-dir:
        dir: /platform
inherit-pkg-dir:
        dir: /sbin
inherit-pkg-dir:
        dir: /usr
inherit-pkg-dir:
        dir: /opt/sfw
net:
        address: 192.168.3.25/24
        physical: bge0
global# /usr/sbin/prctl -n zone.cpu-shares -i zone workzone4
zone: 4: /zones/workzone4
NAME    PRIVILEGE       VALUE    FLAG   ACTION              RECIPIENT
zone.cpu-shares
        privileged         30       -   none                        -
        system          65.5K     max   none                        -
global#
  • If you disable the Fair Share Scheduler, by removing the /etc/dispadmin.conf file and rebootiing the gloabl zone, but do not update the zone configuration that contain a Fair Share value, when restarted they will continue to use the Fair Share Scheduler.
  • Under References above are two useful scripts developed by Brendan Gregg, a consultant for Sun Micorsystems. zonefss is useful for display and setting the Fair Share Scheduler values for a zone.
Click for more info