Skip to content

Commit 7e6c4dc

Browse files
authored
Refactor and update rt-conf how to (#145)
* Add example config Signed-off-by: Farshid Tavakolizadeh <[email protected]>
1 parent c1db0e4 commit 7e6c4dc

File tree

3 files changed

+117
-117
lines changed

3 files changed

+117
-117
lines changed

docs/.custom_wordlist.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,17 @@ Telegraf
9191
Tickless
9292
Timerlat
9393
UC
94+
Uncomment
9495
UEFI
9596
VC
9697
VIRT
9798
WCAG
9899
aarch
99100
ABI
100101
amd
101-
<<<<<<< HEAD
102102
args
103-
=======
104103
apparmor
105104
autotools
106-
>>>>>>> origin/main
107105
benchmarking
108106
bh
109107
bitmask
@@ -197,6 +195,7 @@ mutexes
197195
ng
198196
nohz
199197
ondemand
198+
oneshot
200199
optimization
201200
oslat
202201
osnoise

docs/how-to/rt-conf-cli.md

Lines changed: 62 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,103 @@
11
# How-to tune Real-Time Ubuntu using rt-conf
22

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.
55

6-
## Install `rt-conf` snap
6+
## Install
77

8-
The `rt-conf` application is available as a snap and can be installed with:
8+
Install rt-conf as a snap:
99

1010
```shell
11-
sudo snap install rt-conf
11+
sudo snap install rt-conf --beta --devmode
1212
```
13-
<!-- TODO: Complement information with supported systems once the tool is in a stable state -->
1413

15-
## Edit Configuration file
1614

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).
1918
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+
````
4025

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.
4632

47-
### Fine tune IRQ affinity
33+
## Configure
4834

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`:
5236

53-
Examples:
37+
```{literalinclude} rt-conf-config.yaml
38+
:language: yaml
39+
```
5440

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.
6243

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.
6646

67-
### Fine tune CPU frequency scaling
47+
Refer to the {doc}`../reference/rt-conf-yaml` for more details.
6848

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.
7149

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
7451

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
7955
```
8056

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.
8259
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+
```
8463

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.
8768

69+
If re-applying non-persistent configurations on boot is not wanted, disable the service:
8870
```shell
89-
rt-conf --conf
71+
sudo snap stop --disable rt-conf
9072
```
9173

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:
9378
```shell
94-
rt-conf --conf=<custom-config>.yaml
79+
sudo snap set rt-conf config-file=/home/ubuntu/rt-conf/config.yaml
9580
```
9681

97-
## Debug mode
82+
```{note}
83+
The configuration file must be in a location accessible to the snap, such as a user home directory.
9884
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+
```
10087

88+
To revert to the default path:
10189
```shell
102-
DEBUG=true rt-conf --conf
90+
sudo snap unset rt-conf config-file
10391
```
10492

105-
<!-- TODO: necessary to add session reagarding connection of snap interfaces. -->
106-
107-
## Execute application
93+
### Verbose logging
10894

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
12498
```
12599

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-
```
145100

146101
% 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

docs/how-to/rt-conf-config.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Several fields use the CPU Lists format.
2+
# For the CPU Lists spec, refer to
3+
# https://docs.kernel.org/admin-guide/kernel-parameters.html#cpu-lists
4+
5+
# Kernel command line parameters
6+
# TODO add reboot requirement
7+
kernel_cmdline:
8+
# Isolate CPUs from general execution
9+
# Format: CPU Lists
10+
# isolcpus: "2-3"
11+
12+
# Enable/disable dynamic ticks during idle time
13+
# Supported values: on | off
14+
# nohz: "on"
15+
16+
# Enable/disable full dynamic ticks
17+
# Format: CPU Lists
18+
# nohz_full: "2-3"
19+
20+
# Allocated CPUs for kernel threads
21+
# Format: CPU Lists
22+
# kthread_cpus: "0-1"
23+
24+
# Allocate CPUs for IRQ handling
25+
# Format: CPU Lists
26+
# irqaffinity: "0-1"
27+
28+
# Runtime options for IRQ affinity
29+
irq_tuning:
30+
# - # CPUs to which the IRQs are to be moved
31+
# # Format: range, e.g. 0-2
32+
# cpus: "2-3"
33+
# # Arguments used to filter IRQs
34+
# filter:
35+
# actions: "iwlwifi"
36+
# chip_name: "IR-PCI"
37+
# name: "edge"
38+
# type: "edge"
39+
40+
# Runtime options for CPU frequency scaling
41+
cpu_governance:
42+
# - # CPUs to which the scaling_governor options are to be applied
43+
# # Format: CPU Lists
44+
# cpus: "0-1"
45+
# # CPU frequency scaling governor
46+
# # Supported values depends on the system, typically: performance, powersave
47+
# scaling_governor: "performance"
48+
# # Minimum CPU frequency
49+
# # Format: frequency with unit, one of "GHz", "MHz", "kHz", "Hz"
50+
# min_freq: "1GHz"
51+
# # Maximum CPU frequency
52+
# # Format: same as min_frequency
53+
# max_freq: "5.2gHz"

0 commit comments

Comments
 (0)