2.1. Using the Tuna Interface

2.1. Using the Tuna Interface

Throughout this book, instructions are given for tuning the MRG Realtime kernel directly. The Tuna interface is a tool that assists you with making changes. It has a graphical interface, or can be run through the command shell.

Tuna can be used to change attributes of threads (scheduling policy, scheduler priority and processor affinity) and interrupts (processor affinity). The tool is designed to be used on a running system, and changes take place immediately. This allows any application-specific measurement tools to see and analyze system performance immediately after the changes have been made.

Although changes made in Tuna take immediate effect, changes will not be persistent across reboots. For making persistent changes, see Section 2.2, “Setting persistent tuning parameters”

Installing Tuna Using Yum
  1. Install Tuna using the yum command.

    # yum install tuna
    
  2. Once you have Tuna installed, you can view the help text to see the available options for using the tool in the command shell:

    # tuna --help
    Usage: tuna [OPTIONS]
    	-h, --help                      Give this help list
    	-g, --gui                       Start the GUI
    	-c, --cpus=CPU-LIST             CPU-LIST affected by commands
    	-f, --filter                    Display filter the selected entities
    	-i, --isolate                   Move all threads away from CPU-LIST
    	-I, --include                   Allow all threads to run on CPU-LIST
    	-K, --no_kthreads               Operations will not affect kernel threads
    	-m, --move                      move selected entities to CPU-LIST
    	-t, --threads=THREAD-LIST       THREAD-LIST affected by commands
    	-U, --no_uthreads               Operations will not affect user threads
    	-W, --what_is                   Provides help about selected entities
    
  3. To run the program with a graphical interface, start it from the command line. Although Tuna can be run as an unprivileged user, not all processes will be available for configuration. For this reason, in most cases you will need to run Tuna as root:

    # tuna
    
Tuna main window showing three sections

The main Tuna window is divided into three sections. The window can be resized and the sections are divided by grab bars for adjustment. As values change, entries are shown in bold.

  1. The CPU List

    This list shows all online CPUs and their current usage.

    The check-box beside the name of the CPU is used to filter the task list at the bottom of the window. Only tasks that belong to checked CPUs will be displayed.

    Right-click on a CPU to display isolation options. Selecting Isolate CPU will cause all tasks currently running on that CPU to move to the next available CPU. This can be chosen on one or more CPUs simultaneously, depending on how many CPUs are available on your system.

  2. The IRQ List

    This list shows all the active Interrupt Requests (IRQs), their process ID (PID) and policy and priority information.

    The IRQ list has a right-click menu. The Refresh IRQ list option is provided as IRQs affinity changes may not occur until the next interrupt. Select Set IRQ Attributes to open the IRQ Attributes dialog box.

  3. The Task List

    This list shows all tasks except kernel threads.

    When a process is threaded, the task list shows the original thread with all the other threads collapsed below it. Click on the arrow to the left of the process to expand the thread.

    The right-click menu on the task list is similar to that of the IRQ list. Use Refresh task list will refresh the list with any changes and the Set process attributes will open the Set Process Attributes dialog box.

Important

Any IRQ with a PID of 0 (zero) is a NODELAY IRQ and is not implemented as a kernel thread. Setting the scheduling policy and priority for NODELAY IRQs will have no effect.

Tuna window showing the Set IRQ Attributes dialog box.

Right click on an IRQ and select Set IRQ Attributes to open the IRQ Attributes dialog box.

The IRQ Attributes dialog shows current information about the IRQ. It has three adjustable attributes:

  1. Scheduling Policy

    A drop down list of the available policies.

  2. Scheduler Priority

    A drop down list of the available priorities. This attribute will be disabled if the selected IRQ cannot have a set priority.

  3. Affinity

    A numeric list of CPUs on which the IRQ can be run. This entry can be in the form of a comma-delimited list of CPU numbers, a range using square brackets, or a combination of both. For example: 0, [2-4], 7, 8. This would instruct the IRQ to run on CPUs 0, 2, 3, 4, 7 and 8.

Tuna window showing the Set Process Attributes dialog box.

Right click on a task and select Set Process Attributes to open the Process Attributes dialog box.

The Process Attributes dialog shows current information about the task. It allows you to set scheduling policy, scheduler priority, and CPU affinity for a task or set of tasks.

  1. Thread Selection

    Just the selected thread is selected by default. If the task has more than one thread, use All threads of the selected process to make changes to all of the threads for that task. To use a regular expression (regex) to search for tasks, select All command lines matching the regex below:. This will activate the Command line regex: field and you can enter the regex. This field supports the “*” and “?” wildcards, and will match the entire command line. The task list will update to show only those tasks that match the regex.

  2. Policy, Priority and Affinity

    The Policy drop down box contains the available scheduling policy options.

    The Scheduler Priority drop down box contains the available priorities. This attribute will be disabled if the selected tasks cannot have a set priority.

    The Affinity field contains a numeric list of CPUs on which the selected tasks can be run. This entry can be in the form of a comma-delimited list of CPU numbers, a range using square brackets, or a combination of both.

  3. Task List

    This shows a list of the the tasks currently being adjusted based on the thread and regex selections made.

Using Tuna - An Example

Suppose you have a system with 4 or more processors, and two applications - Foo and Bar. You want to run the applications on dedicated processors and choose processor 1 for Foo and processor 2 for Bar.

  1. The first thing to do is move everything off the chosen processors. Right-click on CPU 1 in the CPU list and select Isolate CPU from the menu. Repeat for CPU 2. The task list shows you that none of the tasks are running on those processors now.

  2. Suppose that Foo is a single task with several threads, and you want the task and all its threads running on CPU 1. Find Foo in the process list, right-click on it and choose Set process attributes from the menu. In the Set Process Attributes dialog, select the radio button for All threads of the selected process. In the Affinity text box, change the text to 1. You can also choose to change the scheduling policy and scheduler priority at this time. Click on OK to save your changes and close the dialog box.

  3. Suppose that Bar is an application that has --none as its first command line argument. Right-click anywhere in the task list and choose Set process attributes from the menu. In the dialog, select the radio-button for All command lines matching the regex below:. Type bar --none * in the Command line regex text box. You will see the task list in the dialog box update to include all the matching processes (including all threads). Change the Affinity to 2. Make any changes you want for the scheduler and priority. Click on OK to save your changes and close the dialog box.