3.1. Setting Scheduler Priorities

3.1. Setting Scheduler Priorities

The MRG Realtime kernel allows fine grained control of scheduler priorities. It also allows application level programs to be scheduled at a higher priority than kernel threads. This can be useful but may also carry consequences. It is possible that it will cause the system to hang and other unpredictable behavior if crucial kernel processes are prevented from running as needed. Ultimately the correct settings are workload dependent.

Using rtctl to Set Priorities
  1. Priorities are set using a series of levels, ranging from 0 (lowest priority) to 99 (highest priority). The system startup script rtctl initializes the default priorities of the kernel threads. By requesting the status of the rtctl service, you can view the priorities of the various kernel threads.

    # service rtctl status
    2   TS      - [kthreadd]
    3   FF     99 [migration/0]
    4   FF     99 [posix_cpu_timer]
    5   FF     50 [softirq-high/0]
    6   FF     50 [softirq-timer/0]
    7   FF     90 [softirq-net-tx/]
    ...[output truncated]...
    
  2. The output is in the format:

    [PID] [scheduler policy] [priority] [process name]
    

    In the scheduler policy field, a value of TS indicates a policy of normal and FF indicates a policy of FIFO (first in, first out).

  3. The rtctl system startup script relies on the /etc/rtgroups file. To make changes, open the /etc/rtgroups file in your preferred text editor.

    kthreads:o:0:\[.*\]$
    watchdog:f:99:\[watchdog.*\]
    migration:f:99:\[migration\/.*\]
    posix_cpu_timer:f:99:\[posix_cpu_timer\]
    hardirq:f:95:\[IRQ-.*\]
    ...[output truncated]...
    
  4. Each line represents a process. You can change the priority of the process by adjusting the parameters. The entries in this file are in the format:

    [group name]:[scheduler policy]:[scheduler priority]:[regular expression]
    

    In the scheduler policy field, the following values are accepted:

    o Sets a policy of other. If the policy is set to o, the scheduler priority field will be set to 0 and ignored.
    b Sets a policy of batch.
    f Sets a policy of FIFO.
    * If the policy is set to *, no change will be made to to any matched thread policy.

    The regular expression field matches the thread name to be modified.

  5. After editing the file, you will need to restart the rtctl service to reload it with the new settings:

    # service rtctl stop
    
    # service rtctl start
    Setting kernel thread priorities: done
    

Related Manual Pages

For more information, or for further reading, the following man pages are related to the information given in this section.