diff --git a/playbooks/configure_network.yaml b/playbooks/configure_network.yaml index c0091244a..05ff9fcf6 100644 --- a/playbooks/configure_network.yaml +++ b/playbooks/configure_network.yaml @@ -39,6 +39,12 @@ tasks_from: kernelargs.yml tags: - edpm_kernel + - name: Configure KSM for kernel + import_role: + name: osp.edpm.edpm_kernel + tasks_from: ksm.yml + tags: + - edpm_kernel - name: import edpm_network_config import_role: name: osp.edpm.edpm_network_config diff --git a/roles/edpm_bootstrap/defaults/main.yml b/roles/edpm_bootstrap/defaults/main.yml index 3e069da64..63f22f3aa 100644 --- a/roles/edpm_bootstrap/defaults/main.yml +++ b/roles/edpm_bootstrap/defaults/main.yml @@ -40,6 +40,7 @@ edpm_bootstrap_packages_bootstrap: - tmpwatch - sysstat - iproute-tc + - ksmtuned edpm_bootstrap_release_version_package: - rhosp-release diff --git a/roles/edpm_bootstrap/meta/argument_specs.yml b/roles/edpm_bootstrap/meta/argument_specs.yml index 16165ddcc..65ec51b9b 100644 --- a/roles/edpm_bootstrap/meta/argument_specs.yml +++ b/roles/edpm_bootstrap/meta/argument_specs.yml @@ -29,6 +29,7 @@ argument_specs: - tmpwatch - sysstat - iproute-tc + - ksmtuned description: "List of packages that are requred to bootstrap EDPM." edpm_bootstrap_release_version_package: diff --git a/roles/edpm_kernel/defaults/main.yml b/roles/edpm_kernel/defaults/main.yml index 676cd5593..d4f293e3a 100644 --- a/roles/edpm_kernel/defaults/main.yml +++ b/roles/edpm_kernel/defaults/main.yml @@ -35,3 +35,6 @@ edpm_kernel_hugepages_remove: false # This should be synced with edpm_nova_compute role edpm_nova_compute_config_dir: /var/lib/config-data/ansible-generated/nova_libvirt + +# KSM control +edpm_kernel_enable_ksm: false diff --git a/roles/edpm_kernel/handlers/main.yml b/roles/edpm_kernel/handlers/main.yml new file mode 100644 index 000000000..357fb55b5 --- /dev/null +++ b/roles/edpm_kernel/handlers/main.yml @@ -0,0 +1,19 @@ +--- +# Copyright Red Hat, Inc. 2023 +# All Rights Reserved. +# +# 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: Delete PageKSM + ansible.builtin.command: echo 2 >/sys/kernel/mm/ksm/run + become: true diff --git a/roles/edpm_kernel/meta/argument_specs.yml b/roles/edpm_kernel/meta/argument_specs.yml index 9958b947e..cba266dd7 100644 --- a/roles/edpm_kernel/meta/argument_specs.yml +++ b/roles/edpm_kernel/meta/argument_specs.yml @@ -52,3 +52,7 @@ argument_specs: type: dict default: {} description: Hugepages configuration dictionary. + edpm_kernel_enable_ksm: + default: false + description: Enable/Disable KSM (disabling it unloads all shared PageKSM!) + type: bool diff --git a/roles/edpm_kernel/tasks/ksm.yml b/roles/edpm_kernel/tasks/ksm.yml new file mode 100644 index 000000000..0847aa0e6 --- /dev/null +++ b/roles/edpm_kernel/tasks/ksm.yml @@ -0,0 +1,40 @@ +--- +# Copyright 2023 Red Hat, Inc. +# All Rights Reserved. +# +# 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: Disable KSM services + become: true + when: not edpm_kernel_enable_ksm|bool + ansible.builtin.systemd: + name: "{{ item }}" + state: stopped + enabled: false + loop: + - ksm.service + - ksmtuned.service + # NOTE(bogdando): when KSM is disabled, any memory pages that were shared + # prior to deactivating KSM are still shared. So delete them all + notify: Delete PageKSM + +- name: Enable KSM + become: true + when: edpm_kernel_enable_ksm|bool + ansible.builtin.systemd: + name: "{{ item }}" + state: started + enabled: true + loop: + - ksm.service + - ksmtuned.service diff --git a/roles/edpm_nova_compute/defaults/main.yml b/roles/edpm_nova_compute/defaults/main.yml index 1e94b479f..53d84901c 100644 --- a/roles/edpm_nova_compute/defaults/main.yml +++ b/roles/edpm_nova_compute/defaults/main.yml @@ -83,7 +83,6 @@ edpm_nova_compute_file_backed_memory: 0 # role specific edpm_nova_compute_volume_use_multipath: false # role specific edpm_nova_compute_hw_machine_type: "x86_64=q35" # role specific edpm_nova_compute_additional_cell: false -edpm_nova_compute_enable_ksm: false # role specific edpm_nova_compute_cinder_password: "{{ edpm_cinder_password | default('') }}" # sensitive, assert not empty edpm_nova_compute_keystone_region: regionOne edpm_nova_compute_num_pcie_ports: 16 # role specific diff --git a/roles/edpm_nova_compute/meta/argument_specs.yml b/roles/edpm_nova_compute/meta/argument_specs.yml index cead43180..b7d1fc97b 100644 --- a/roles/edpm_nova_compute/meta/argument_specs.yml +++ b/roles/edpm_nova_compute/meta/argument_specs.yml @@ -419,10 +419,6 @@ argument_specs: default: '{{ edpm_enable_internal_tls | default (false) }}' description: '' type: str - edpm_nova_compute_enable_ksm: - default: false - description: '' - type: bool edpm_nova_compute_enable_rbd_backend: default: false description: '' diff --git a/roles/edpm_nova_compute/tasks/configure.yml b/roles/edpm_nova_compute/tasks/configure.yml index 9c8705dcb..6e32d6832 100644 --- a/roles/edpm_nova_compute/tasks/configure.yml +++ b/roles/edpm_nova_compute/tasks/configure.yml @@ -28,60 +28,6 @@ state: present reload: true -- name: Enable/disable ksm - block: - - name: Disable KSM on compute - when: not edpm_nova_compute_enable_ksm|bool - block: - - name: Check for ksm - ansible.builtin.shell: systemctl is-active ksm.service || systemctl is-enabled ksm.service - become: true - failed_when: false - register: ksm_service_check - - - name: Disable KSM services - ansible.builtin.service: - name: "{{ item }}" - state: stopped - enabled: false - with_items: - - ksm.service - - ksmtuned.service - when: - - not ansible_check_mode - - ksm_service_check.rc is defined - - ksm_service_check.rc == 0 - register: ksmdisabled - - # When KSM is disabled, any memory pages that were shared prior to - # deactivating KSM are still shared. To delete all of the PageKSM - # in the system, we use: - - name: Delete PageKSM after disable ksm on compute - ansible.builtin.command: echo 2 >/sys/kernel/mm/ksm/run - when: - - ksm_service_check.rc is defined - - ksm_service_check.rc == 0 - - ksmdisabled is changed - - - name: Enable KSM on compute - when: edpm_nova_compute_enable_ksm|bool - block: - - name: Make sure package providing ksmtuned is installed (RHEL8 or CentOS8) - ansible.builtin.package: - name: qemu-kvm-common - state: present - when: - - ansible_facts['distribution_major_version'] is version('8', '==') - - - name: Enable ksmtunded - ansible.builtin.service: - name: "{{ item }}" - state: started - enabled: true - with_items: - - ksm.service - - ksmtuned.service - - name: Configure nova.conf when: edpm_nova_compute_config_use_ansible block: