In my last entry, I described how to change the memory configuration of a running zone. The natural next question is of course, if that also works with CPUs that have been assigned to a zone. The answer, of course, is “yes”.
You might wonder why that would be necessary in the first place. After all, there’s the Fair Share Scheduler, that’s extremely capable of managing zones’ CPU usage. However, there are reasons to assign dedicated CPU resources to zones, licensing is one, SLAs with specified CPU requirements another. In such cases, you configure a fixed amount of CPUs (more precisely, strands) for a zone. Being able to change this configuration on the fly then becomes desirable. I’ll show how to do that in this blog entry.
In general, there are two ways to assign exclusive CPUs to a zone. The classic approach is by using a resource pool with an associated processor set. One or more zones can then be bound to that pool. The easier solution is to use the parameter “dedicated-cpu” directly when configuring the zone. In this second case, Solaris will create a temporary pool to manage these resources. So effectively, the implementation is the same in both cases. Which makes it clear how to change the CPU configuration in both cases: By changing the pool. If you do this in the classical approach, the change to the pool will be persistent. If working with the temporary pool created for the zone, you will also need to change the zone’s configuration if you want the change to survive a zone restart.
If you configured you zone with “dedicated-cpu”, the temporary pool (and also the temporary processor set that goes along with it) will usually be called “SUNWtmp_<zonename>”. If not, you’ll know the name of the pool… In both cases, everything else is the same:
Let’s assume a zone called orazone, currently configured with 1 CPU. It’s to be assigned a second CPU. The current pool configuration is like this:As we can see in the definition of pset SUNWtmp_orazone, it has been assigned CPU #0. To add another CPU to this pool, you’ll need these two commands:root@benjaminchen:~# pooladm
system default
stringsystem.comment
intsystem.version 1
booleansystem.bind-default true
stringsystem.poold.objectives wt-load
pool pool_default
intpool.sys_id 0
booleanpool.active true
booleanpool.default true
intpool.importance 1
stringpool.comment
psetpset_default
pool SUNWtmp_orazone
intpool.sys_id 5
booleanpool.active true
booleanpool.default false
intpool.importance 1
stringpool.comment
booleanpool.temporary true
psetSUNWtmp_orazone
pset pset_default
intpset.sys_id -1
booleanpset.default true
uintpset.min 1
uintpset.max 65536
stringpset.units population
uintpset.load 687
uintpset.size 3
stringpset.comment
cpu
intcpu.sys_id 1
stringcpu.comment
stringcpu.status on-line
cpu
intcpu.sys_id 3
stringcpu.comment
stringcpu.status on-line
cpu
intcpu.sys_id 2
stringcpu.comment
stringcpu.status on-line
pset SUNWtmp_orazone
intpset.sys_id 2
booleanpset.default false
uintpset.min 1
uintpset.max 1
stringpset.units population
uintpset.load 478
uintpset.size 1
stringpset.comment
booleanpset.temporary true
cpu
intcpu.sys_id 0
stringcpu.comment
stringcpu.status on-line
root@benjaminchen:~# poolcfg -dc 'modify pset SUNWtmp_orapset \
(uint pset.max=2)'
root@benjaminchen:~# poolcfg -dc 'transfer to pset \
orapset (cpu 1)'
To remove that CPU from the pool again, use these:
root@benjaminchen:~# poolcfg -dc 'transfer to pset pset_default \
(cpu 1)'
root@benjaminchen:~# poolcfg -dc 'modify pset SUNWtmp_orapset \
(uint pset.max=1)'
That’s it. If you’ve used “dedicated-cpu” for your zone’s configuration, you’ll need to change that before the next reboot. If not, you’d have to use the pool name you assigned to the zone.
Further details:
- Solaris Admin Guide – Resource Pools
http://docs.oracle.com/cd/E19683-01/817-1592/rmpool-1/index.html
