Tuesday, July 28, 2015

CPU Pinning and NUMA Topology on RDO Kilo && Hypervisor Upgrade up to qemu-kvm-ev-2.1.2-23.el7.1 on CentOS 7.1

Posting bellow follows up http://redhatstackblog.redhat.com/2015/05/05/cpu-pinning-and-numa-topology-awareness-in-openstack-compute/
on RDO Kilo upgraded via  qemu-kvm-ev-2.1.2-23.el7.1  on CentOS 7.1
Recent build on CentOS 7.X qemu-kvm-ev-2.1.2-23.el7.1 
enables CPU Pinning and NUMA Topology for RDO Kilo on CentOS 7.1
Qemu-kvm upgrade is supposed to be done as post installation procedure,
i.e. after RDO Kilo deployment on the system. Final target is to reproduce mentioned article on i7 4790 Haswell CPU box, perform launching nova instance with CPU pinning.

See also CPU Pinning and NUMA Topology on RDO Kilo on Fedora Server 22

[root@Centos71 x86_64]# numactl --hardware
available: 1 nodes (0)
node 0 cpus: 0 1 2 3 4 5 6 7
node 0 size: 16326 MB
node 0 free: 4695 MB
node distances:
node   0
0:  10

# virsh capabilities
   .  .  .  .  .

 <topology>
      <cells num='1'>
        <cell id='0'>
          <memory unit='KiB'>16718464</memory>
          <pages unit='KiB' size='4'>4179616</pages>
          <pages unit='KiB' size='2048'>0</pages>
          <distances>
            <sibling id='0' value='10'/>
          </distances>
          <cpus num='8'>
            <cpu id='0' socket_id='0' core_id='0' siblings='0,4'/>
            <cpu id='1' socket_id='0' core_id='1' siblings='1,5'/>
            <cpu id='2' socket_id='0' core_id='2' siblings='2,6'/>
            <cpu id='3' socket_id='0' core_id='3' siblings='3,7'/>
            <cpu id='4' socket_id='0' core_id='0' siblings='0,4'/>
            <cpu id='5' socket_id='0' core_id='1' siblings='1,5'/>
            <cpu id='6' socket_id='0' core_id='2' siblings='2,6'/>
            <cpu id='7' socket_id='0' core_id='3' siblings='3,7'/>
          </cpus>
        </cell>
      </cells>
</topology>



On each Compute node that pinning of virtual machines will be permitted on open the /etc/nova/nova.conf file and make the following modifications:
  • Set the vcpu_pin_set value to a list or range of logical CPU cores  to reserve for virtual machine processes. OpenStack Compute will ensure guest virtual machine instances are pinned to these virtual CPU cores. 
  • vcpu_pin_set=2,3,6,7
  • Set the reserved_host_memory_mb to reserve RAM for host processes. For the purposes of testing used  the default of 512 MB: 
  • reserved_host_memory_mb=512 
# systemctl restart openstack-nova-compute.service

************************************
SCHEDULER CONFIGURATION
************************************
Update /etc/nova/nova.conf

scheduler_default_filters=RetryFilter,AvailabilityZoneFilter,RamFilter,
ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,CoreFilter,
NUMATopologyFilter,AggregateInstanceExtraSpecsFilter

# systemctl restart openstack-nova-scheduler.service


 At this point if  creating  a guest you may see some changes to appear in the XML, pinning the guest vCPU(s) to the cores listed in vcpu_pin_set:

<vcpu placement='static' cpuset='2-3,6-7'>1</vcpu>

Add to vmlinuz grub2 command line at the end 


isolcpus=2,3,6,7

***************************
REBOOT SYSTEM
***************************

[root@Centos71 ~(keystone_admin)]# nova aggregate-create performance
+----+-------------+-------------------+-------+----------+
| Id | Name        | Availability Zone | Hosts | Metadata |
+----+-------------+-------------------+-------+----------+
| 1  | performance | -                 |       |          |
+----+-------------+-------------------+-------+----------+

[root@Centos71 ~(keystone_admin)]# nova aggregate-set-metadata 1
pinned=true
Metadata has been successfully updated for aggregate 1.
+----+-------------+-------------------+-------+---------------+
| Id | Name        | Availability Zone | Hosts | Metadata      |
+----+-------------+-------------------+-------+---------------+
| 1  | performance | -                 |       | 'pinned=true' |
+----+-------------+-------------------+-------+---------------+


Create a new flavor for performance intensive instances. Here is created the m1.small.performance flavor, based on the values used in the existing m1.small flavor. The differences in behaviour between the two will be the result of the metadata to be  added  to the new flavor.


[root@Centos71 ~(keystone_admin)]# nova flavor-create m1.small.performance 6 4096 20 4
+----+----------------------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name                 | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+----------------------+-----------+------+-----------+------+-------+-------------+-----------+
| 6  | m1.small.performance | 4096      | 20   | 0                |          | 4     | 1.0  | True      |
+----+----------------------+-----------+------+-----------+------+-------+-------------+-----------+

[root@Centos71 ~(keystone_admin)]# nova flavor-key 6 set hw:cpu_policy=dedicated

[root@Centos71 ~(keystone_admin)]# nova flavor-key 6 set aggregate_instance_extra_specs:pinned=true


[root@Centos71 ~(keystone_admin)]# nova aggregate-add-host 1 Centos71.localdomain

Host Centos71.localdomain has been successfully added for aggregate 1
+----+-------------+-------------------+------------------------+---------------+
| Id | Name        | Availability Zone | Hosts                  | Metadata      |
+----+-------------+-------------------+------------------------+---------------+
| 1  | performance | -                 | 'Centos71.localdomain' | 'pinned=true' |
+----+-------------+-------------------+------------------------+---------------+



[root@Centos71 ~(keystone_admin)]# .   keystonerc_demo

[root@Centos71 ~(keystone_demo)]# glance image-list
+--------------------------------------+-----------------+-------------+------------------+------------+--------+
| ID                                   | Name            | Disk Format | Container Format | Size       | Status |
+--------------------------------------+-----------------+-------------+------------------+------------+--------+
| 4a2d708c-7624-439f-9e7e-6e133062e23a | CentOS71Image   | qcow2       | bare             | 1004994560 | active |
| fae94d4b-e810-46a9-8a8f-94dfb812e098 | cirros          | qcow2       | bare             | 13200896   | active |
| f823f0a0-bcdf-416d-915a-8d7cc0278ed7 | Fedora20image   | qcow2       | bare             | 210829312  | active |
| 2198786d-e77f-47ec-959f-fcf7435d5e78 | Fedora21image   | qcow2       | bare             | 158443520  | active |
| 5f1ca33e-d5cc-43fb-9d88-5a7ef0f75959 | VF22Image       | qcow2       | bare             | 228599296  | active |
+--------------------------------------+-----------------+-------------+------------------+------------+--------+

[root@Centos71 ~(keystone_demo)]#  neutron net-list
+--------------------------------------+----------+-----------------------------------------------------+
| id                                   | name     | subnets                                             |
+--------------------------------------+----------+-----------------------------------------------------+
| ab4bd4f8-22b7-43c3-ac60-c1a917a230d7 | public   | 4cbcf377-3742-4385-8362-c071f499ad9c 192.168.1.0/24 |
| 93e0b4be-7900-4a34-adef-758578f75774 | demo_net | 17a5e4f7-fd1b-45fa-b84f-c3af1378c42c 50.0.0.0/24    |
+--------------------------------------+----------+-----------------------------------------------------+

[root@Centos71 ~(keystone_demo)]# nova boot --image 5f1ca33e-d5cc-43fb-9d88-5a7ef0f75959 --key-name oskeydev --flavor m1.small.performance --nic net-id=93e0b4be-7900-4a34-adef-758578f75774 vf22-instance

+--------------------------------------+--------------------------------------------------+
| Property                             | Value                                            |
+--------------------------------------+--------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                           |
| OS-EXT-AZ:availability_zone          | nova                                             |
| OS-EXT-STS:power_state               | 0                                                |
| OS-EXT-STS:task_state                | scheduling                                       |
| OS-EXT-STS:vm_state                  | building                                         |
| OS-SRV-USG:launched_at               | -                                                |
| OS-SRV-USG:terminated_at             | -                                                |
| accessIPv4                           |                                                  |
| accessIPv6                           |                                                  |
| adminPass                            | trBdDQWd75ck                                     |
| config_drive                         |                                                  |
| created                              | 2015-07-29T07:59:23Z                             |
| flavor                               | m1.small.performance (6)                         |
| hostId                               |                                                  |
| id                                   | d7fda7ca-7124-4c8b-a085-1da784d57348             |
| image                                | VF22Image (5f1ca33e-d5cc-43fb-9d88-5a7ef0f75959) |
| key_name                             | oskeydev                                         |
| metadata                             | {}                                               |
| name                                 | vf22-instance                                    |
| os-extended-volumes:volumes_attached | []                                               |
| progress                             | 0                                                |
| security_groups                      | default                                          |
| status                               | BUILD                                            |
| tenant_id                            | 8c9defac20a74633af4bb4773e45f11e                 |
| updated                              | 2015-07-29T07:59:23Z                             |
| user_id                              | da79d2c66db747eab942bdbe20bb3f44                 |
+--------------------------------------+--------------------------------------------------+

[root@Centos71 ~(keystone_demo)]# nova list
+--------------------------------------+---------------+-----------+------------+-------------+-----------------------------------+
| ID                                   | Name          | Status    | Task State | Power State | Networks                          |
+--------------------------------------+---------------+-----------+------------+-------------+-----------------------------------+
| 455877f2-7070-48a7-bb24-e0702be2fbc5 | CentOS7RSX05  | SUSPENDED | -          | Shutdown    | demo_net=50.0.0.13, 192.168.1.153 |
| 44645495-a158-4b99-b96b-26f8178fa28f | VF22Devs      | ACTIVE    | -          | Running     | demo_net=50.0.0.23, 192.168.1.163 |
| d7fda7ca-7124-4c8b-a085-1da784d57348 | vf22-instance | ACTIVE    | -          | Running     | demo_net=50.0.0.24, 192.168.1.164 |
+--------------------------------------+---------------+-----------+------------+-------------+-----------------------------------+

[root@Centos71 ~(keystone_demo)]# nova show d7fda7ca-7124-4c8b-a085-1da784d57348
+--------------------------------------+----------------------------------------------------------+
| Property                             | Value                                                    |
+--------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                   |
| OS-EXT-AZ:availability_zone          | nova                                                     |
| OS-EXT-STS:power_state               | 1                                                        |
| OS-EXT-STS:task_state                | -                                                        |
| OS-EXT-STS:vm_state                  | active                                                   |
| OS-SRV-USG:launched_at               | 2015-07-29T08:00:12.000000                               |
| OS-SRV-USG:terminated_at             | -                                                        |
| accessIPv4                           |                                                          |
| accessIPv6                           |                                                          |
| config_drive                         |                                                          |
| created                              | 2015-07-29T07:59:23Z                                     |
| demo_net network                     | 50.0.0.24, 192.168.1.164                                 |
| flavor                               | m1.small.performance (6)                                 |
| hostId                               | de84a0c94e3271ef0f4620e113814fa69132fea1be65e7ad33edde7d |
| id                                   | d7fda7ca-7124-4c8b-a085-1da784d57348                     |
| image                                | VF22Image (5f1ca33e-d5cc-43fb-9d88-5a7ef0f75959)         |
| key_name                             | oskeydev                                                 |
| metadata                             | {}                                                       |
| name                                 | vf22-instance                                            |
| os-extended-volumes:volumes_attached | []                                                       |
| progress                             | 0                                                        |
| security_groups                      | default                                                  |
| status                               | ACTIVE                                                   |
| tenant_id                            | 8c9defac20a74633af4bb4773e45f11e                         |
| updated                              | 2015-07-29T08:00:12Z                                     |
| user_id                              | da79d2c66db747eab942bdbe20bb3f44                         |
+--------------------------------------+---------------------------------------------------------


[root@Centos71 x86_64]# virsh list
 Id    Name                           State
----------------------------------------------------
 2     instance-0000000d              running
 3     instance-0000000e              running

[root@Centos71 x86_64]# virsh dumpxml instance-0000000e > vf22-02.xml

Please, see http://redhatstackblog.redhat.com/2015/05/05/cpu-pinning-and-numa-topology-awareness-in-openstack-compute/
regarding detailed explanation of highlighted blocks, keeping in mind that pinning is done to logical CPU cores ( not physical due to 4 Core CPU with HT enabled ). Multiple cells are also absent, due limitations of i7 47XX Haswell CPU architecture

[root@Centos71 x86_64]# cat  vf22-02.xml

<domain type='kvm' id='3'>
  <name>instance-0000000e</name>
  <uuid>d7fda7ca-7124-4c8b-a085-1da784d57348</uuid>
  <metadata>
    <nova:instance xmlns:nova="http://openstack.org/xmlns/libvirt/nova/1.0">
      <nova:package version="2015.1.0-3.el7"/>
      <nova:name>vf22-instance</nova:name>
      <nova:creationTime>2015-07-29 08:00:06</nova:creationTime>
      <nova:flavor name="m1.small.performance">
        <nova:memory>4096</nova:memory>
        <nova:disk>20</nova:disk>
        <nova:swap>0</nova:swap>
        <nova:ephemeral>0</nova:ephemeral>
        <nova:vcpus>4</nova:vcpus>
      </nova:flavor>
      <nova:owner>
        <nova:user uuid="da79d2c66db747eab942bdbe20bb3f44">demo</nova:user>
        <nova:project uuid="8c9defac20a74633af4bb4773e45f11e">demo</nova:project>
      </nova:owner>
      <nova:root type="image" uuid="5f1ca33e-d5cc-43fb-9d88-5a7ef0f75959"/>
    </nova:instance>
  </metadata>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static'>4</vcpu>
  <cputune>
    <shares>4096</shares>
    <vcpupin vcpu='0' cpuset='2'/>
    <vcpupin vcpu='1' cpuset='6'/>
    <vcpupin vcpu='2' cpuset='3'/>
    <vcpupin vcpu='3' cpuset='7'/>
    <emulatorpin cpuset='2-3,6-7'/>
  </cputune>
  <numatune>
    <memory mode='strict' nodeset='0'/>
    <memnode cellid='0' mode='strict' nodeset='0'/>
  </numatune>

  <resource>
    <partition>/machine</partition>
  </resource>
    <sysinfo type='smbios'>
      <system>
        <entry name='manufacturer'>Fedora Project</entry>
        <entry name='product'>OpenStack Nova</entry>
        <entry name='version'>2015.1.0-3.el7</entry>
        <entry name='serial'>b3fae7c3-10bd-455b-88b7-95e586342203</entry>
        <entry name='uuid'>d7fda7ca-7124-4c8b-a085-1da784d57348</entry>
      </system>
    </sysinfo>
  <os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.1.0'>hvm</type>
    <boot dev='hd'/>
    <smbios mode='sysinfo'/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode='host-model'>
    <model fallback='allow'/>
    <topology sockets='2' cores='1' threads='2'/>
    <numa>
      <cell id='0' cpus='0-3' memory='4194304'/>
    </numa>
  </cpu>

 <clock offset='utc'>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/nova/instances/d7fda7ca-7124-4c8b-a085-1da784d57348/disk'/>
      <backingStore type='file' index='1'>
        <format type='raw'/>
        <source file='/var/lib/nova/instances/_base/99f1a80be14fc2563a2af39e944ee1c305ed8c34'/>
        <backingStore/>
      </backingStore>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
    <controller type='usb' index='0'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='fa:16:3e:94:77:fd'/>
      <source bridge='qbr2d20d535-5c'/>
      <target dev='tap2d20d535-5c'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='file'>
      <source path='/var/lib/nova/instances/d7fda7ca-7124-4c8b-a085-1da784d57348/console.log'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <serial type='pty'>
      <source path='/dev/pts/3'/>
      <target port='1'/>
      <alias name='serial1'/>
    </serial>
    <console type='file'>
      <source path='/var/lib/nova/instances/d7fda7ca-7124-4c8b-a085-1da784d57348/console.log'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <channel type='spicevmc'>
      <target type='virtio' name='com.redhat.spice.0' state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='spice' port='5901' autoport='yes' listen='0.0.0.0 ( only  Compute )' keymap='en-us'>
      <listen type='address' address='0.0.0.0 ( only  Compute )'/>
    </graphics>
    <sound model='ich6'>
      <alias name='sound0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </sound>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
      <stats period='10'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='selinux' relabel='yes'>
    <label>system_u:system_r:svirt_t:s0:c670,c918</label>
    <imagelabel>system_u:object_r:svirt_image_t:s0:c670,c918</imagelabel>
  </seclabel>
</domain>