Infra: AWS Update to Ubuntu 20.04
[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: Inst - Update Package Cache (APT)
5   apt:
6     update_cache: yes
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   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"
25   tags:
26     - perf-conf-turbo-boost
27
28 - name: Conf - Adjust nr_hugepages
29   # change the minimum size of the hugepage pool.
30   # 2G VPP, 4GB per VNF/CNF, 2G reserve
31   sysctl:
32     name: "vm.nr_hugepages"
33     value: "{{ sysctl.vm.nr_hugepages  }}"
34     state: "present"
35     sysctl_file: "/etc/sysctl.d/90-csit.conf"
36     reload: "yes"
37   tags:
38     - perf-conf-sysctl
39
40 - name: Conf - Adjust max_map_count
41   # this file contains the maximum number of memory map areas a process
42   # may have. memory map areas are used as a side-effect of calling
43   # malloc, directly by mmap and mprotect, and also when loading shared
44   # libraries.
45   #
46   # while most applications need less than a thousand maps, certain
47   # programs, particularly malloc debuggers, may consume lots of them,
48   # e.g., up to one or two maps per allocation.
49   # must be greater than or equal to (2 * vm.nr_hugepages).
50   sysctl:
51     name: "vm.max_map_count"
52     value: "{{ sysctl.vm.nr_hugepages * 4  }}"
53     state: "present"
54     sysctl_file: "/etc/sysctl.d/90-csit.conf"
55     reload: "yes"
56   tags:
57     - perf-conf-sysctl
58
59 - name: Conf - Adjust hugetlb_shm_group
60   # hugetlb_shm_group contains group id that is allowed to create sysv
61   # shared memory segment using hugetlb page.
62   sysctl:
63     name: "vm.hugetlb_shm_group"
64     value: "1000"
65     state: "present"
66     sysctl_file: "/etc/sysctl.d/90-csit.conf"
67     reload: "yes"
68   tags:
69     - perf-conf-sysctl
70
71 - name: Conf - Adjust swappiness
72   # this control is used to define how aggressive the kernel will swap
73   # memory pages.  higher values will increase agressiveness, lower values
74   # decrease the amount of swap.  a value of 0 instructs the kernel not to
75   # initiate swap until the amount of free and file-backed pages is less
76   # than the high water mark in a zone.
77   sysctl:
78     name: "vm.swappiness"
79     value: "0"
80     state: "present"
81     sysctl_file: "/etc/sysctl.d/90-csit.conf"
82     reload: "yes"
83   tags:
84     - perf-conf-sysctl
85
86 - name: Conf - Adjust shmmax
87   # shared memory max must be greator or equal to the total size of hugepages.
88   # for 2mb pages, totalhugepagesize = vm.nr_hugepages * 2 * 1024 * 1024
89   # if the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax)
90   # is greater than the calculated totalhugepagesize then set this parameter
91   # to current shmmax value.
92   sysctl:
93     name: "kernel.shmmax"
94     value: "{{ sysctl.vm.nr_hugepages * 2 * 1024 * 1024 }}"
95     state: "present"
96     sysctl_file: "/etc/sysctl.d/90-csit.conf"
97     reload: "yes"
98   tags:
99     - perf-conf-sysctl
100
101 - name: Conf - Adjust watchdog_cpumask
102   # this value can be used to control on which cpus the watchdog may run.
103   # the default cpumask is all possible cores, but if no_hz_full is
104   # enabled in the kernel config, and cores are specified with the
105   # nohz_full= boot argument, those cores are excluded by default.
106   # offline cores can be included in this mask, and if the core is later
107   # brought online, the watchdog will be started based on the mask value.
108   #
109   # typically this value would only be touched in the nohz_full case
110   # to re-enable cores that by default were not running the watchdog,
111   # if a kernel lockup was suspected on those cores.
112   sysctl:
113     name: "kernel.watchdog_cpumask"
114     value: "{{ sysctl.kernel.watchdog_cpumask }}"
115     state: "present"
116     sysctl_file: "/etc/sysctl.d/90-csit.conf"
117     reload: "yes"
118   tags:
119     - perf-conf-sysctl
120
121 - name: Conf - Adjust randomize_va_space
122   # this option can be used to select the type of process address
123   # space randomization that is used in the system, for architectures
124   # that support this feature.
125   # 0 - turn the process address space randomization off.  this is the
126   #     default for architectures that do not support this feature anyways,
127   #     and kernels that are booted with the "norandmaps" parameter.
128   sysctl:
129     name: "kernel.randomize_va_space"
130     value: "0"
131     state: "present"
132     sysctl_file: "/etc/sysctl.d/90-csit.conf"
133     reload: "yes"
134   tags:
135     - perf-conf-sysctl
136
137 - name: Conf - Cpufrequtils
138   copy:
139     src: "files/cpufrequtils"
140     dest: "/etc/default/cpufrequtils"
141     owner: "root"
142     group: "root"
143     mode: 0644
144   tags:
145     - perf-conf-cpufrequtils
146
147 - name: Conf - Irqbalance
148   template:
149     src: "files/irqbalance"
150     dest: "/etc/default/irqbalance"
151     owner: "root"
152     group: "root"
153     mode: 0644
154   tags:
155     - perf-conf-irqbalance
156
157 - name: Conf - Set Ondemand Service To Disable
158   service:
159     name: "ondemand"
160     enabled: "no"
161   tags:
162     - perf-conf-ondemand
163
164 - name: Conf - Kernel Parameters
165   lineinfile:
166     path: "/etc/default/grub"
167     state: "present"
168     regexp: "^GRUB_CMDLINE_LINUX="
169     line: "GRUB_CMDLINE_LINUX=\"{% for key, value in grub.items() %}{% if value is sameas true %}{{key}} {% else %}{{key}}={{value}} {% endif %}{% endfor %}\""
170   notify:
171     - "Update GRUB"
172   tags:
173     - perf-conf-grub
174
175 - meta: flush_handlers
176
177 - name: Conf - Load Kernel Modules By Default
178   lineinfile:
179     path: "/etc/modules"
180     state: "present"
181     line: "{{ item }}"
182   with_items:
183     - "vfio-pci"
184   notify:
185     - "Reboot Server"
186   tags:
187     - perf-conf-load-kernel-modules
188
189 - meta: flush_handlers