CPU pinning & Hugepages libvirt mounts

Hugepages mount point definition for libivirt. Nova vcpu pin set
parameter definition.

Epic: PROD-8959

Change-Id: I7a5b0b315a31d77b4324963c299546d7d3f4343a
diff --git a/README.rst b/README.rst
index 86fb99b..34cb1e6 100644
--- a/README.rst
+++ b/README.rst
@@ -279,6 +279,25 @@
           devname: eth1
           physical_network: physnet1
 
+CPU pinning & Hugepages
+-----------------------
+
+CPU pinning of virtual machine instances to dedicated physical CPU cores.
+Hugepages mount point for libvirt.
+
+.. code-block:: yaml
+
+  nova:
+    controller:
+      scheduler_default_filters: "DifferentHostFilter,RetryFilter,AvailabilityZoneFilter,RamFilter,CoreFilter,DiskFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,NUMATopologyFilter,AggregateInstanceExtraSpecsFilter"
+
+  nova:
+    compute:
+      vcpu_pin_set: 2,3,4,5
+      hugepages:
+        mount_points:
+        - path: /mnt/hugepages_1GB
+        - path: /mnt/hugepages_2MB
 
 Documentation and Bugs
 ============================
diff --git a/nova/compute.sls b/nova/compute.sls
index ef0c60a..709571a 100644
--- a/nova/compute.sls
+++ b/nova/compute.sls
@@ -181,6 +181,18 @@
     - pkg: nova_compute_packages
   - onlyif: "virsh net-list | grep default"
 
+{%- if compute.hugepages is defined %}
+
+/etc/default/qemu-kvm:
+  file.managed:
+  - contents: KVM_HUGEPAGES=1
+  - require:
+    - pkg: nova_compute_packages
+  - require_in:
+    - service: {{ compute.libvirt_service }}
+
+{%- endif %}
+
 {{ compute.libvirt_service }}:
   service.running:
   - enable: true
@@ -189,6 +201,7 @@
     - cmd: virsh net-undefine default
   - watch:
     - file: /etc/libvirt/{{ compute.libvirt_config }}
+    - file: /etc/libvirt/qemu.conf
 
 {%- if grains.get('init', None) == "upstart" %}
 # MOS9 libvirt fix for upstart
diff --git a/nova/files/liberty/nova-compute.conf.Debian b/nova/files/liberty/nova-compute.conf.Debian
index 769c129..dcd7f88 100644
--- a/nova/files/liberty/nova-compute.conf.Debian
+++ b/nova/files/liberty/nova-compute.conf.Debian
@@ -27,6 +27,10 @@
 
 reserved_host_memory_mb = {{ compute.get('reserved_host_memory_mb', '512') }}
 
+{%- if compute.vcpu_pin_set is defined %}
+vcpu_pin_set={{ compute.vcpu_pin_set }}
+{%- endif %}
+
 allow_resize_to_same_host=True
 
 {%- if compute.get('ceph', {}).ephemeral is defined %}
diff --git a/nova/files/liberty/qemu.conf.Debian b/nova/files/liberty/qemu.conf.Debian
index 5c5722b..f3a8997 100644
--- a/nova/files/liberty/qemu.conf.Debian
+++ b/nova/files/liberty/qemu.conf.Debian
@@ -337,7 +337,10 @@
 # in a location of $MOUNTPOINT/libvirt/qemu
 #
 #hugetlbfs_mount = "/dev/hugepages"
-
+#hugetlbfs_mount = ["/run/hugepages/kvm", "/mnt/hugepages_1GB"]
+{%- if compute.hugepages is defined %}
+hugetlbfs_mount = [{%- for mount in compute.hugepages.mount_points %}"{{ mount.path }}"{% if not loop.last %}, {% endif %}{%- endfor %}]
+{%- endif %}
 
 # Path to the setuid helper for creating tap devices.  This executable
 # is used to create <source type='bridge'> interfaces when libvirtd is
diff --git a/nova/files/mitaka/nova-compute.conf.Debian b/nova/files/mitaka/nova-compute.conf.Debian
index 23080b8..c4e55fe 100644
--- a/nova/files/mitaka/nova-compute.conf.Debian
+++ b/nova/files/mitaka/nova-compute.conf.Debian
@@ -32,6 +32,10 @@
 
 reserved_host_memory_mb = {{ compute.get('reserved_host_memory_mb', '512') }}
 
+{%- if compute.vcpu_pin_set is defined %}
+vcpu_pin_set={{ compute.vcpu_pin_set }}
+{%- endif %}
+
 allow_resize_to_same_host=True
 
 auth_strategy = keystone
diff --git a/nova/files/mitaka/qemu.conf.Debian b/nova/files/mitaka/qemu.conf.Debian
index 5c5722b..f3a8997 100644
--- a/nova/files/mitaka/qemu.conf.Debian
+++ b/nova/files/mitaka/qemu.conf.Debian
@@ -337,7 +337,10 @@
 # in a location of $MOUNTPOINT/libvirt/qemu
 #
 #hugetlbfs_mount = "/dev/hugepages"
-
+#hugetlbfs_mount = ["/run/hugepages/kvm", "/mnt/hugepages_1GB"]
+{%- if compute.hugepages is defined %}
+hugetlbfs_mount = [{%- for mount in compute.hugepages.mount_points %}"{{ mount.path }}"{% if not loop.last %}, {% endif %}{%- endfor %}]
+{%- endif %}
 
 # Path to the setuid helper for creating tap devices.  This executable
 # is used to create <source type='bridge'> interfaces when libvirtd is
diff --git a/tests/pillar/compute_cluster.sls b/tests/pillar/compute_cluster.sls
index e1d3541..3c4b6bc 100644
--- a/tests/pillar/compute_cluster.sls
+++ b/tests/pillar/compute_cluster.sls
@@ -2,6 +2,10 @@
   compute:
     version: liberty
     enabled: true
+    vcpu_pin_set: 1,2,3
+    hugepages:
+      mount_points:
+      - path: /mnt/hugepages_1GB
     virtualization: kvm
     heal_instance_info_cache_interval: 60
     vncproxy_url: openstack:6080