how to configure CPU pinning to a VM

  • create a flavor through OpenStack dashboard or command line
# for example, with an ID of 6, 4 GB of RAM, 120 GB root disk, and two vCPUs
sudo nova flavor-create m1.small 6 4096 120 2

  • reflect pinning to a flavor
sudo openstack flavor set m1.small --property hw:cpu_policy=dedicated

  • optionally, reflect hugepage to a flavor
sudo openstack flavor set m1.small --property hw:mem_page_size=large

  • optionally, reflect thread siblings to a flavor if you use hyperthreading
# default cpu_thread_policy is prefer, so this option can be omitted
sudo openstack flavor set m1.small --property hw:cpu_thread_policy=prefer

  • manually restrict cpu_sockets to 1 since openstack assigns 2 sockets even though there is 1 socket in physical topology
# cpu_cores & cpu_threads can be manually set based on physical topology
sudo openstack flavor set m1.small --property hw:cpu_sockets=1
sudo openstack flavor set m1.small --property hw:cpu_cores=1
sudo openstack flavor set m1.small --property hw:cpu_threads=2

  • provision VM through OpenStack dashboard or command line with the flavor

  • verify cputuned VM as below
virsh
virsh>list
virsh>edit id
search 'cputune' keyword and see whether pinning config is there, for example
  <cputune>
    <shares>2048</shares>
    <vcpupin vcpu='0' cpuset='0'/>
    <vcpupin vcpu='1' cpuset='1'/>
    <emulatorpin cpuset='0-1'/>
  </cputune>

https://docs.openstack.org/admin-guide/compute-cpu-topologies.html

Leave a Reply

Your email address will not be published.