Add CPU isolation support for Yardstick NSB setup 15/63215/8
authorStepan Andrushko <stepanx.andrushko@intel.com>
Fri, 5 Oct 2018 18:42:33 +0000 (21:42 +0300)
committerStepan Andrushko <stepanx.andrushko@intel.com>
Wed, 6 Feb 2019 16:40:55 +0000 (18:40 +0200)
Add support to define CPU isolation in grub by using NSB setup script.
List of CPU's to be isolated is not used by default and is defined in
install-inventory.ini.
Warning: reboot is required to apply CPU isolation to grub.

JIRA: YARDSTICK-1467

Change-Id: I54ffa925a8f3059180d17ff4f1c41ff6e0f12066
Signed-off-by: Stepan Andrushko <stepanx.andrushko@intel.com>
ansible/install-inventory.ini
ansible/install.yaml
ansible/roles/enable_cpu_isolation_on_boot/defaults/main.yml [new file with mode: 0644]
ansible/roles/enable_cpu_isolation_on_boot/tasks/main.yml [new file with mode: 0644]
ansible/ubuntu_server_baremetal_deploy_samplevnfs.yml

index d0a8ef9..bcd57db 100644 (file)
@@ -25,4 +25,9 @@ ubuntu_archive={"amd64": "http://archive.ubuntu.com/ubuntu/", "arm64": "http://p
 # path_to_img=/tmp/workspace/yardstick-image.img
 # Uncomment credentials below if needed
 # ansible_user=root
-# ansible_pass=root
+# ansible_ssh_pass=root
+
+# List of CPUs to be isolated (not used by default)
+# Grub line will be extended with: "isolcpus=<ISOL_CPUS> nohz=on nohz_full=<ISOL_CPUS> rcu_nocbs=1<ISOL_CPUS>"
+# ISOL_CPUS=2-27,30-55 # physical cpu's for all NUMA nodes, four cpu's reserved for kernel
+# ISOL_CPUS=2-27,58-83 # physical cpu's for first NUMA node, four cpu's reserved for kernel
index 6146c7f..847f01c 100644 (file)
@@ -67,6 +67,7 @@
     # can't update grub in chroot/docker
     - enable_hugepages_on_boot
     - enable_iommu_on_boot
+    - enable_cpu_isolation_on_boot
     # needed for collectd plugins
     - increase_open_file_limits
     - install_image_dependencies
diff --git a/ansible/roles/enable_cpu_isolation_on_boot/defaults/main.yml b/ansible/roles/enable_cpu_isolation_on_boot/defaults/main.yml
new file mode 100644 (file)
index 0000000..37c3fd8
--- /dev/null
@@ -0,0 +1,21 @@
+# Copyright (c) 2018 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+grub_file: "/etc/default/grub"
+isolcpus_help_string: '  # added by Yardstick ansible isolcpus role'
+isolcpu_params: " isolcpus={{ ISOL_CPUS }} nohz=on nohz_full={{ ISOL_CPUS }} rcu_nocbs={{ ISOL_CPUS }}"
+enable_isolcpu: 'GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX{{ isolcpu_params }}"'
+update_grub:
+  Debian: "update-grub2"
+  RedHat: "grub2-mkconfig -o /boot/grub2/grub.cfg"
diff --git a/ansible/roles/enable_cpu_isolation_on_boot/tasks/main.yml b/ansible/roles/enable_cpu_isolation_on_boot/tasks/main.yml
new file mode 100644 (file)
index 0000000..b41a2b3
--- /dev/null
@@ -0,0 +1,59 @@
+# Copyright (c) 2018 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+- name: Check if isolcpus is set by this role in {{ grub_file}}
+  lineinfile:
+    path: "{{ grub_file }}"
+    regexp: '{{ isolcpus_help_string }}'
+    state: absent
+  check_mode: yes
+  register: is_nsb_isolcpus_role
+  ignore_errors: True
+
+- name: Check if isolcpus is set by someone else
+  lineinfile:
+    path: "{{ grub_file }}"
+    regexp: "isolcpus="
+    state: absent
+  check_mode: yes
+  register: is_isolcpu
+  ignore_errors: True
+
+- name: Send warning that CPU isolation cannot be configured
+  debug:
+    msg: "WARNING: CPU isolation is not configured"
+  when:
+    - not is_nsb_isolcpus_role.changed and not is_isolcpu.changed
+    - ISOL_CPUS is not defined
+
+- name: Send info that CPU isolation configured by someone else
+  debug:
+    msg: "INFO: NOT modified, CPU isolation is already configured by someone."
+  when:
+    - not is_nsb_isolcpus_role.changed and is_isolcpu.changed
+
+- name: Add/update isolcpus when ISOL_CPUS is defined and not set at all or set by this role
+  lineinfile:
+    path: "{{ grub_file }}"
+    regexp: "{{ isolcpus_help_string }}"
+    line: '{{ enable_isolcpu }} {{ isolcpus_help_string }}'
+  when:
+    - is_nsb_isolcpus_role.changed or not is_nsb_isolcpus_role.changed and not is_isolcpu.changed
+    - ISOL_CPUS is defined
+
+- name: Update grub for bare metal usage
+  command: "{{ update_grub[ansible_os_family] }}"
+  when:
+    - is_nsb_isolcpus_role.changed or not is_nsb_isolcpus_role.changed and not is_isolcpu.changed
+    - ISOL_CPUS is defined
index 4f4d7d0..8ca8650 100644 (file)
@@ -27,6 +27,7 @@
 #     can't update grub in chroot/docker
     - enable_hugepages_on_boot
     - enable_iommu_on_boot
+    - enable_cpu_isolation_on_boot
     # needed for collectd plugins
     - increase_open_file_limits
     - install_image_dependencies