From 4c72b415a9689986fede6775d31af67980ef7aaa Mon Sep 17 00:00:00 2001 From: Stepan Andrushko Date: Fri, 5 Oct 2018 21:42:33 +0300 Subject: Add CPU isolation support for Yardstick NSB setup 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 --- .../enable_cpu_isolation_on_boot/defaults/main.yml | 21 ++++++++ .../enable_cpu_isolation_on_boot/tasks/main.yml | 59 ++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 ansible/roles/enable_cpu_isolation_on_boot/defaults/main.yml create mode 100644 ansible/roles/enable_cpu_isolation_on_boot/tasks/main.yml (limited to 'ansible/roles') 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 index 000000000..37c3fd8e1 --- /dev/null +++ b/ansible/roles/enable_cpu_isolation_on_boot/defaults/main.yml @@ -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 index 000000000..b41a2b307 --- /dev/null +++ b/ansible/roles/enable_cpu_isolation_on_boot/tasks/main.yml @@ -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 -- cgit 1.2.3-korg