Fix: Ansible minor bugs
[csit.git] / resources / tools / testbed-setup / ansible / roles / performance_tuning / tasks / main.yaml
1 ---
2 # file: roles/performance_tuning/tasks/main.yaml
3
4 - name: Performance Tuning - Install Distribution - Release - Machine Prerequisites
5   package:
6     name: "{{ packages | flatten(levels=1) }}"
7     state: latest
8     update_cache: true
9   tags:
10     - install-dependencies
11
12 - name: Performance Tuning - Configure {{ ansible_machine }} Kernel Parameters
13   lineinfile:
14     path: "/etc/default/grub"
15     state: "present"
16     regexp: "^GRUB_CMDLINE_LINUX="
17     line: "{{ grub_cmdline_linux[ansible_machine] | join() }}"
18   notify:
19     - "Update GRUB"
20     - "Reboot server"
21   tags:
22     - set-grub
23
24 - name: Performance Tuning - Turbo Boost
25   import_tasks: turbo_boost.yaml
26   when: >
27     cpu_microarchitecture == "skylake" or
28     cpu_microarchitecture == "cascadelake"
29   tags:
30     - turbo-boost
31
32 - name: Performance Tuning - Adjust nr_hugepages
33   # change the minimum size of the hugepage pool.
34   # 2G VPP, 4GB per VNF/CNF, 2G reserve
35   sysctl:
36     name: "vm.nr_hugepages"
37     value: "{{ sysctl.vm.nr_hugepages  }}"
38     state: "present"
39     sysctl_file: "/etc/sysctl.d/90-csit.conf"
40     reload: "yes"
41   tags:
42     - set-sysctl
43
44 - name: Performance Tuning - Adjust max_map_count
45   # this file contains the maximum number of memory map areas a process
46   # may have. memory map areas are used as a side-effect of calling
47   # malloc, directly by mmap and mprotect, and also when loading shared
48   # libraries.
49   #
50   # while most applications need less than a thousand maps, certain
51   # programs, particularly malloc debuggers, may consume lots of them,
52   # e.g., up to one or two maps per allocation.
53   # must be greater than or equal to (2 * vm.nr_hugepages).
54   sysctl:
55     name: "vm.max_map_count"
56     value: "{{ sysctl.vm.nr_hugepages * 4  }}"
57     state: "present"
58     sysctl_file: "/etc/sysctl.d/90-csit.conf"
59     reload: "yes"
60   tags:
61     - set-sysctl
62
63 - name: Performance Tuning - Adjust hugetlb_shm_group
64   # hugetlb_shm_group contains group id that is allowed to create sysv
65   # shared memory segment using hugetlb page.
66   sysctl:
67     name: "vm.hugetlb_shm_group"
68     value: "1000"
69     state: "present"
70     sysctl_file: "/etc/sysctl.d/90-csit.conf"
71     reload: "yes"
72   tags:
73     - set-sysctl
74
75 - name: Performance Tuning - Adjust swappiness
76   # this control is used to define how aggressive the kernel will swap
77   # memory pages.  higher values will increase agressiveness, lower values
78   # decrease the amount of swap.  a value of 0 instructs the kernel not to
79   # initiate swap until the amount of free and file-backed pages is less
80   # than the high water mark in a zone.
81   sysctl:
82     name: "vm.swappiness"
83     value: "0"
84     state: "present"
85     sysctl_file: "/etc/sysctl.d/90-csit.conf"
86     reload: "yes"
87   tags:
88     - set-sysctl
89
90 - name: Performance Tuning - Adjust shmmax
91   # shared memory max must be greator or equal to the total size of hugepages.
92   # for 2mb pages, totalhugepagesize = vm.nr_hugepages * 2 * 1024 * 1024
93   # if the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax)
94   # is greater than the calculated totalhugepagesize then set this parameter
95   # to current shmmax value.
96   sysctl:
97     name: "kernel.shmmax"
98     value: "{{ sysctl.vm.nr_hugepages * 2 * 1024 * 1024 }}"
99     state: "present"
100     sysctl_file: "/etc/sysctl.d/90-csit.conf"
101     reload: "yes"
102   tags:
103     - set-sysctl
104
105 - name: Performance Tuning - Adjust watchdog_cpumask
106   # this value can be used to control on which cpus the watchdog may run.
107   # the default cpumask is all possible cores, but if no_hz_full is
108   # enabled in the kernel config, and cores are specified with the
109   # nohz_full= boot argument, those cores are excluded by default.
110   # offline cores can be included in this mask, and if the core is later
111   # brought online, the watchdog will be started based on the mask value.
112   #
113   # typically this value would only be touched in the nohz_full case
114   # to re-enable cores that by default were not running the watchdog,
115   # if a kernel lockup was suspected on those cores.
116   sysctl:
117     name: "kernel.watchdog_cpumask"
118     value: "{{ sysctl.kernel.watchdog_cpumask }}"
119     state: "present"
120     sysctl_file: "/etc/sysctl.d/90-csit.conf"
121     reload: "yes"
122   tags:
123     - set-sysctl
124
125 - name: Performance Tuning - Adjust randomize_va_space
126   # this option can be used to select the type of process address
127   # space randomization that is used in the system, for architectures
128   # that support this feature.
129   # 0 - turn the process address space randomization off.  this is the
130   #     default for architectures that do not support this feature anyways,
131   #     and kernels that are booted with the "norandmaps" parameter.
132   sysctl:
133     name: "kernel.randomize_va_space"
134     value: "0"
135     state: "present"
136     sysctl_file: "/etc/sysctl.d/90-csit.conf"
137     reload: "yes"
138   tags:
139     - set-sysctl
140
141 - name: Performance Tuning - Copy Cpufrequtils File
142   copy:
143     src: "files/cpufrequtils"
144     dest: "/etc/default/cpufrequtils"
145     owner: "root"
146     group: "root"
147     mode: "0644"
148   tags:
149     - copy-cpufrequtils
150
151 - name: Performance Tuning - Set Ondemand Service To Disable
152   service:
153     name: "ondemand"
154     enabled: "no"
155   tags:
156     - set-ondemand
157
158 - name: Performance Tuning - Load Kernel Modules By Default
159   lineinfile:
160     path: "/etc/modules"
161     state: "present"
162     line: "{{ item }}"
163   with_items:
164     - "vfio-pci"
165   tags:
166     - load-kernel-modules
167
168 - meta: flush_handlers