Revert "fix(IPsecUtil): Delete keywords no longer used"
[csit.git] / fdio.infra.ansible / roles / performance_tuning / tasks / main.yaml
1 ---
2 # file: roles/performance_tuning/tasks/main.yaml
3
4 - name: Inst - Update Package Cache (APT)
5   ansible.builtin.apt:
6     update_cache: true
7     cache_valid_time: 3600
8   when:
9     - ansible_distribution|lower == 'ubuntu'
10   tags:
11     - perf-inst-prerequisites
12
13 - name: Inst - Machine Prerequisites
14   ansible.builtin.package:
15     name: "{{ packages | flatten(levels=1) }}"
16     state: latest
17   tags:
18     - perf-inst-prerequisites
19
20 - name: Conf - Turbo Boost
21   import_tasks: turbo_boost.yaml
22   when: >
23     cpu_microarchitecture == "skylake" or
24     cpu_microarchitecture == "cascadelake" or
25     cpu_microarchitecture == "icelake" or
26     cpu_microarchitecture == "sapphirerapids"
27   tags:
28     - perf-conf-turbo-boost
29
30 - name: Conf - Adjust max_map_count
31   # this file contains the maximum number of memory map areas a process
32   # may have. memory map areas are used as a side-effect of calling
33   # malloc, directly by mmap and mprotect, and also when loading shared
34   # libraries.
35   #
36   # while most applications need less than a thousand maps, certain
37   # programs, particularly malloc debuggers, may consume lots of them,
38   # e.g., up to one or two maps per allocation.
39   # must be greater than or equal to (2 * vm.nr_hugepages).
40   ansible.builtin.sysctl:
41     name: "vm.max_map_count"
42     value: "{{ sysctl.vm.nr_hugepages * 4  }}"
43     state: "present"
44     sysctl_file: "/etc/sysctl.d/90-csit.conf"
45     reload: "yes"
46   tags:
47     - perf-conf-sysctl
48
49 - name: Conf - Adjust hugetlb_shm_group
50   # hugetlb_shm_group contains group id that is allowed to create sysv
51   # shared memory segment using hugetlb page.
52   ansible.builtin.sysctl:
53     name: "vm.hugetlb_shm_group"
54     value: "1000"
55     state: "present"
56     sysctl_file: "/etc/sysctl.d/90-csit.conf"
57     reload: "yes"
58   tags:
59     - perf-conf-sysctl
60
61 - name: Conf - Adjust swappiness
62   # this control is used to define how aggressive the kernel will swap
63   # memory pages.  higher values will increase agressiveness, lower values
64   # decrease the amount of swap.  a value of 0 instructs the kernel not to
65   # initiate swap until the amount of free and file-backed pages is less
66   # than the high water mark in a zone.
67   ansible.builtin.sysctl:
68     name: "vm.swappiness"
69     value: "0"
70     state: "present"
71     sysctl_file: "/etc/sysctl.d/90-csit.conf"
72     reload: "yes"
73   tags:
74     - perf-conf-sysctl
75
76 - name: Conf - Adjust shmmax
77   # shared memory max must be greator or equal to the total size of hugepages.
78   # for 2mb pages, totalhugepagesize = vm.nr_hugepages * 2 * 1024 * 1024
79   # if the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax)
80   # is greater than the calculated totalhugepagesize then set this parameter
81   # to current shmmax value.
82   ansible.builtin.sysctl:
83     name: "kernel.shmmax"
84     value: "{{ sysctl.vm.nr_hugepages * 2 * 1024 * 1024 }}"
85     state: "present"
86     sysctl_file: "/etc/sysctl.d/90-csit.conf"
87     reload: "yes"
88   tags:
89     - perf-conf-sysctl
90
91 - name: Conf - Adjust watchdog_cpumask
92   # this value can be used to control on which cpus the watchdog may run.
93   # the default cpumask is all possible cores, but if no_hz_full is
94   # enabled in the kernel config, and cores are specified with the
95   # nohz_full= boot argument, those cores are excluded by default.
96   # offline cores can be included in this mask, and if the core is later
97   # brought online, the watchdog will be started based on the mask value.
98   #
99   # typically this value would only be touched in the nohz_full case
100   # to re-enable cores that by default were not running the watchdog,
101   # if a kernel lockup was suspected on those cores.
102   ansible.builtin.sysctl:
103     name: "kernel.watchdog_cpumask"
104     value: "{{ sysctl.kernel.watchdog_cpumask }}"
105     state: "present"
106     sysctl_file: "/etc/sysctl.d/90-csit.conf"
107     reload: "yes"
108   tags:
109     - perf-conf-sysctl
110
111 - name: Conf - Adjust randomize_va_space
112   # this option can be used to select the type of process address
113   # space randomization that is used in the system, for architectures
114   # that support this feature.
115   # 0 - turn the process address space randomization off.  this is the
116   #     default for architectures that do not support this feature anyways,
117   #     and kernels that are booted with the "norandmaps" parameter.
118   ansible.builtin.sysctl:
119     name: "kernel.randomize_va_space"
120     value: "0"
121     state: "present"
122     sysctl_file: "/etc/sysctl.d/90-csit.conf"
123     reload: "yes"
124   tags:
125     - perf-conf-sysctl
126
127 - name: Conf - Cpufrequtils
128   ansible.builtin.copy:
129     src: "files/cpufrequtils"
130     dest: "/etc/default/cpufrequtils"
131     owner: "root"
132     group: "root"
133     mode: 0644
134   tags:
135     - perf-conf-cpufrequtils
136
137 - name: Conf - Irqbalance
138   ansible.builtin.template:
139     src: "files/irqbalance"
140     dest: "/etc/default/irqbalance"
141     owner: "root"
142     group: "root"
143     mode: 0644
144   tags:
145     - perf-conf-irqbalance
146
147 - name: Conf - Kernel Parameters
148   ansible.builtin.lineinfile:
149     path: "/etc/default/grub"
150     state: "present"
151     regexp: "^GRUB_CMDLINE_LINUX="
152     line: "GRUB_CMDLINE_LINUX=\"{% for key, value in grub.items() %}{% if value is sameas true %}{{key}} {% else %}{{key}}={{value}} {% endif %}{% endfor %}\""
153   notify:
154     - "Update GRUB"
155   tags:
156     - perf-conf-grub
157
158 - meta: flush_handlers
159
160 - name: Conf - Load Kernel Modules By Default
161   ansible.builtin.lineinfile:
162     path: "/etc/modules"
163     state: "present"
164     line: "{{ item }}"
165   with_items:
166     - "vfio-pci"
167   notify:
168     - "Reboot Server"
169   tags:
170     - perf-conf-load-kernel-modules
171
172 - name: Conf - Create a directory for 1G HugeTLBs hugepages
173   ansible.builtin.file:
174     path: "/dev/hugepages1G"
175     state: "directory"
176     mode: 0755
177   tags:
178     - perf-conf-hugepages-1g
179
180 - name: Conf - Mount 1G HugeTLBs hugepages
181   ansible.builtin.mount:
182     path: "/dev/hugepages1G"
183     src: "hugetlbfs"
184     opts: "pagesize=1G"
185     boot: false
186     state: "mounted"
187     fstype: "hugetlbfs"
188   tags:
189     - perf-conf-hugepages-1g
190
191 - name: Create a directory if it does not exist
192   ansible.builtin.file:
193     path: "/dev/hugepages2M"
194     state: "directory"
195     mode: 0755
196   tags:
197     - perf-conf-hugepages-2m
198
199 - name: Conf - Create a directory for 2M HugeTLBs hugepages
200   ansible.builtin.mount:
201     path: "/dev/hugepages2M"
202     src: "hugetlbfs"
203     opts: "pagesize=2M"
204     boot: false
205     state: "mounted"
206     fstype: "hugetlbfs"
207   tags:
208     - perf-conf-hugepages-2m
209
210 - meta: flush_handlers