Chapter 3. Realtime-Specific Tuning
Important
3.1. Setting Scheduler Priorities
Table 3.1. Priority Map
| Priority | Threads | Description |
|---|---|---|
1 | Low priority kernel threads | Priority 1 is usually reserved for those tasks that need to be just above SCHED_OTHER |
2 - 49 | Available for use | Range used for typical application priorities |
50 | Default hard-IRQ value | |
51 - 98 | High priority threads | Use this range for threads that execute periodically and must have quick response times. Do not use this range for CPU-bound threads as you will starve interrupts. |
99 | Watchdogs and migration | System threads that must run at the highest priority |
Procedure 3.1. Using rtctl to Set Priorities
- Priorities are set using a series of levels, ranging from
0(lowest priority) to99(highest priority). The system startup script,rtctl, may be used to change the default priorities of threads following kernel boot. Its default is to not modify any thread priorities.To view scheduling priorities of running threads, use the tuna utility:~]#
tuna --show_threadsthread ctxt_switches pid SCHED_ rtpri affinity voluntary nonvoluntary cmd 2 OTHER 0 0xfff 451 3 kthreadd 3 FIFO 1 0 46395 2 ksoftirqd/0 5 OTHER 0 0 11 1 kworker/0:0H 7 FIFO 99 0 9 1 posixcputmr/0 ...[output truncated]... - The
rtctlscript relies on the/etc/rtgroupsfile:...[comments_truncated]... # kthreads:*:*:*:\[.*\]$ # softirq:f:1:*:\[ksoftirqd\/.*\] # rcu:f:1:*:\[rcu[bc]\/.*\] # rpciod:o:*:*:\[rpciod.*\] # lockd:*:*:*:\[lockd.*\] # nfsd:*:*:*:\[nfsd.*\] # hardirq:f:50:*:\[irq[\-_/].*\] # rcun:f:99:*:\[rcun\/.*\] # watchdog:f:99:*:\[watchdog\/.*\] # migration:f:99:*:\[migration\/.*\]
- Each line defines a group that will match some set of threads. By default, all the groups are commented out with a leading hash sign (
#). You can uncomment a group and edit its parameters, or you can add a new group with your own name and parameters. You can also change the priority of a group by adjusting its parameters.Warning
Do not change the priority of the kernel threads because these threads are meant to run only when triggered. Changing their priority may have a negative impact.In fact, themigrationthread is astopthread and is protected in thesched_setscheduler()kernel function. Any attempt at changing the policy and priority of themigration/xthread (wherexis the number of per-CPU core) will fail with anInvalid argumentmessage.The entries in this file are written in the following format:[group name]:[scheduler policy]:[scheduler priority]:[regular expression]
In thescheduler policyfield, the following values are accepted:TheoSets a policy of other. If the policy is set too, thescheduler priorityfield will be set to0and ignored.bSets a policy of batch.fSets a policy of FIFO.*If the policy is set to *, no change will be made to any matched thread policy.regular expressionfield matches the thread name to be modified. - After editing the file, you will need to restart the
rtctlservice to reload it with the new settings:~]#
systemctl stop rtctl~]#systemctl start rtctl
For more information, or for further reading, the following man pages are related to the information given in this section.
- rtctl(1)
- rtgroups(5)

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.