|
1 | 1 | # How-to tune Real-Time Ubuntu using rt-conf |
2 | 2 |
|
3 | | -RT-conf is an application that helps users tune their system for real-time responsiveness. |
4 | | -This guide provides usage instructions for its command-line interface. |
| 3 | +*rt-conf* is a tool that helps users tune their system for real-time responsiveness. |
| 4 | +This guide describes how to install and use it on Ubuntu. |
5 | 5 |
|
6 | | -## Install `rt-conf` snap |
| 6 | +## Install |
7 | 7 |
|
8 | | -The `rt-conf` application is available as a snap and can be installed with: |
| 8 | +Install rt-conf as a snap: |
9 | 9 |
|
10 | 10 | ```shell |
11 | | -sudo snap install rt-conf |
| 11 | +sudo snap install rt-conf --beta --devmode |
12 | 12 | ``` |
13 | | -<!-- TODO: Complement information with supported systems once the tool is in a stable state --> |
14 | 13 |
|
15 | | -## Edit Configuration file |
16 | 14 |
|
17 | | -The actions made by the `rt-conf` tool are mainly driven by the options set in the YAML configuration file. |
18 | | -Checkout the [configuration schema][config_yaml] for all the possible configuration keys on the YAML configuration file. |
| 15 | +````{admonition} Developer mode |
| 16 | +The snap must be installed with `--devmode` to allow IRQ configuration. |
| 17 | +This is due to issue [#67](https://github.com/canonical/rt-conf/issues/67). |
19 | 18 |
|
20 | | -### Configure kernel command line args |
21 | | - |
22 | | -Kernel command line are used to tune the system in a static way. |
23 | | -Every change needs a reboot, to take effect. |
24 | | -After boot, to revert the change, it's necessary to change back and reboot again. |
25 | | -Here are some examples of useful configurations. |
26 | | - |
27 | | - - CPU isolation with `isolcpus`. |
28 | | - Useful to run real-time workloads on the isolated CPUs. |
29 | | - ```yaml |
30 | | - kernel_cmdline: |
31 | | - isolcpus: "3-4" |
32 | | - ``` |
33 | | -
|
34 | | - - Disable dynamic ticks on given CPUs to reduce OS jitter: |
35 | | - ```yaml |
36 | | - kernel_cmdline: |
37 | | - nohz: "on" |
38 | | - nohz_full: "3-4" |
39 | | - ``` |
| 19 | +When installed in developer mode, the snap will not update automatically. |
| 20 | +To force an update: |
| 21 | +```shell |
| 22 | +sudo snap refresh rt-conf |
| 23 | +``` |
| 24 | +```` |
40 | 25 |
|
41 | | - - Allocate IRQ affinity to CPUs not used by the real-time workloads: |
42 | | - ```yaml |
43 | | - kernel_cmdline: |
44 | | - irqaffinity: "0-2,5-n" |
45 | | - ``` |
| 26 | +Grant access to allow GRUB configuration on a system that supports it: |
| 27 | +```shell |
| 28 | +sudo snap connect rt-conf:etc-default-grub |
| 29 | +``` |
| 30 | +rt-conf uses this access to write a drop-in GRUB config file at `/etc/default/grub.d/60_rt-conf.cfg`. |
| 31 | +This file is removed when uninstalling the rt-conf snap. |
46 | 32 |
|
47 | | -### Fine tune IRQ affinity |
| 33 | +## Configure |
48 | 34 |
|
49 | | -Some workloads may require specific IRQ affinity tuning. |
50 | | -Like being able to handle IRQs coming from a specific network card interface on an isolated CPU running a real-time workload. |
51 | | -For that, the `irq_tunning` top level field configuration can be set. |
| 35 | +The default configuration file is located at `/var/snap/rt-conf/common/config.yaml`: |
52 | 36 |
|
53 | | -Examples: |
| 37 | +```{literalinclude} rt-conf-config.yaml |
| 38 | +:language: yaml |
| 39 | +``` |
54 | 40 |
|
55 | | -- Handle IRQs coming from wifi interface on specific CPUs: |
56 | | - ```yaml |
57 | | - irq_tuning: |
58 | | - - cpus: "3-4" |
59 | | - filter: |
60 | | - actions: "iwlwifi" |
61 | | - ``` |
| 41 | +The configuration file includes several examples. |
| 42 | +Uncomment useful examples and modify them to meet the tuning requirements. |
62 | 43 |
|
63 | | -```{note} |
64 | | -The matching filters names are the same as you can found on the [sysfs ABI for kernel/irq directory][sysfs-abi] (excluding `hwirq` and `wakeup`). |
65 | | -``` |
| 44 | +If a configuration is commented out, rt-conf will not perform any operations. |
| 45 | +Anything that is set on your system remains untouched. |
66 | 46 |
|
67 | | -### Fine tune CPU frequency scaling |
| 47 | +Refer to the {doc}`../reference/rt-conf-yaml` for more details. |
68 | 48 |
|
69 | | -Some heavy real-time workloads may benefit from being handle on CPUs with higher frequencies. |
70 | | -Doing do by running them in `performance` mode. |
71 | 49 |
|
72 | | -The CPU scaling governor can be set using `cpu_governance` top level field configuration. |
73 | | -The specified CPUs are the ones which will receive the set scaling governor. |
| 50 | +## Run |
74 | 51 |
|
75 | | -```yaml |
76 | | -cpu_governance: |
77 | | - - cpus: "3-4" |
78 | | - scaling_governor: "performance" |
| 52 | +Once ready with the configurations, run rt-conf: |
| 53 | +```shell |
| 54 | +sudo rt-conf |
79 | 55 | ``` |
80 | 56 |
|
81 | | -## Set configuration file |
| 57 | +```{admonition} Kernel command line parameters |
| 58 | +Pay attention to the output as it shows platform-specific instructions to complete kernel command line configurations. |
82 | 59 |
|
83 | | -There are two ways to pass the YAML configuration file: |
| 60 | +Setting kernel command line via rt-conf is not supported on [Ubuntu Core][UC]. |
| 61 | +Instead, refer to {ref}`ubuntu-core-kernel-cmdline`. |
| 62 | +``` |
84 | 63 |
|
85 | | -- Relying on the default location, set to `$SNAP_COMMON/config.yaml`. |
86 | | - Checkout [snap environment variables documentation][snap_env_variables]. |
| 64 | +The kernel command line parameters are persisted on the system, but this is not the case for other configurations. |
| 65 | +The IRQ and CPU governance are reset to the system defaults after a reboot. |
| 66 | +The rt-conf snap has a oneshot service which runs on every boot to re-apply the non-persistent configurations. |
| 67 | +This service runs only once and stops immediately after setting the configurations. |
87 | 68 |
|
| 69 | +If re-applying non-persistent configurations on boot is not wanted, disable the service: |
88 | 70 | ```shell |
89 | | -rt-conf --conf |
| 71 | +sudo snap stop --disable rt-conf |
90 | 72 | ``` |
91 | 73 |
|
92 | | -- Pass using the `--conf` flag: |
| 74 | +### Change configuration path |
| 75 | + |
| 76 | +The configuration file path can be changed with [snap configurations][snap-config]. |
| 77 | +For example: |
93 | 78 | ```shell |
94 | | -rt-conf --conf=<custom-config>.yaml |
| 79 | +sudo snap set rt-conf config-file=/home/ubuntu/rt-conf/config.yaml |
95 | 80 | ``` |
96 | 81 |
|
97 | | -## Debug mode |
| 82 | +```{note} |
| 83 | +The configuration file must be in a location accessible to the snap, such as a user home directory. |
98 | 84 |
|
99 | | -To enable debug logging set the `DEBUG` environment variable to `true`: |
| 85 | +The file must be owned by and writable to root only. |
| 86 | +``` |
100 | 87 |
|
| 88 | +To revert to the default path: |
101 | 89 | ```shell |
102 | | -DEBUG=true rt-conf --conf |
| 90 | +sudo snap unset rt-conf config-file |
103 | 91 | ``` |
104 | 92 |
|
105 | | -<!-- TODO: necessary to add session reagarding connection of snap interfaces. --> |
106 | | - |
107 | | -## Execute application |
| 93 | +### Verbose logging |
108 | 94 |
|
109 | | -Example of `rt-conf` execution, with kernel command line and IRQ affinity tuning settings. |
110 | | - |
111 | | -Used configuration YAML: |
112 | | -```yaml |
113 | | -kernel_cmdline: |
114 | | - isolcpus: "1-2" |
115 | | - nohz: "on" |
116 | | - nohz_full: "1-2" |
117 | | - kthread_cpus: "0,3" |
118 | | - irqaffinity: "0,3" |
119 | | -
|
120 | | -irq_tuning: |
121 | | - - cpus: "2" |
122 | | - filter: |
123 | | - actions: "acpi" |
| 95 | +To enable debug logging set: |
| 96 | +```shell |
| 97 | +sudo snap set rt-conf verbose=true |
124 | 98 | ``` |
125 | 99 |
|
126 | | -Executing `rt-conf` from configuration file located at home directory: |
127 | | - |
128 | | -```{terminal} |
129 | | - :input: sudo rt-conf --config=$HOME/config.yaml |
130 | | - :user: ubuntu |
131 | | - :host: ubuntu |
132 | | - :dir: ~ |
133 | | -
|
134 | | -2025/04/02 14:44:59 Final kcmdline: nohz_full=1-2 kthread_cpus=0,3 irqaffinity=0,3 isolcpus=1-2 nohz=on |
135 | | -Detected bootloader: GRUB |
136 | | -Updated default grub file: /etc/default/grub |
137 | | -
|
138 | | -Please run: |
139 | | -
|
140 | | - sudo update-grub |
141 | | -
|
142 | | -to apply the changes to your bootloader. |
143 | | -2025/04/02 14:44:59 Set /proc/irq/9/smp_affinity_list to 2 |
144 | | -``` |
145 | 100 |
|
146 | 101 | % Links |
147 | | -[snap_env_variables]: https://snapcraft.io/docs/environment-variables |
148 | | -[tui_wikipedia]: https://en.wikipedia.org/wiki/Text-based_user_interface |
149 | | -[GRUB]: https://www.gnu.org/software/grub/ |
150 | | -[ubuntu_desktop]: https://ubuntu.com/download/desktop |
151 | | -[ubuntu_server]: https://ubuntu.com/download/server |
152 | | -[uc]: https://ubuntu.com/core |
153 | | - |
154 | | -[config_yaml]: https://documentation.ubuntu.com/real-time/en/rt-conf/reference/rt-conf-yaml/ |
155 | | -[sysfs-abi]: https://github.com/torvalds/linux/blob/master/Documentation/ABI/testing/sysfs-kernel-irq |
| 102 | +[UC]: https://ubuntu.com/core |
| 103 | +[snap-config]: https://snapcraft.io/docs/configuration-in-snaps |
0 commit comments