4.5. Examples of Using Tuna


Example 4.1. Assigning Tasks to Specific CPUs

The following example uses a system with four or more processors, and shows how to make all ssh threads run on CPU 0 and 1, and all http threads on CPU 2 and 3.
# tuna --cpus=0,1 --threads=ssh\* --move --cpus=2,3 --threads=http\* --move
The above example command performs the following operations sequentially:
  1. Select CPUs 0 and 1.
  2. Select all threads that begin with ssh.
  3. Move the selected threads to the selected CPUs. Tuna sets the affinity mask of threads starting with ssh to the appropriate CPUs. The CPUs can be expressed numerically as 0 and 1, in hex mask as 0x3, or in binary as 11.
  4. Reset the CPU list to 2 and 3.
  5. Select all threads that begin with http.
  6. Move the selected threads to the selected CPUs. Tuna sets the affinity mask of threads starting with http to the appropriate CPUs. The CPUs can be expressed numerically as 2 and 3, in hex mask as 0xC, or in binary as 1100.

Example 4.2. Viewing Current Configurations

The following example uses the --show_threads (-P) parameter to display the current configuration, and then tests if the requested changes were made as expected.
# tuna --threads=gnome-sc\* \
        --show_threads \
        --cpus=0 \
        --move \
        --show_threads \
        --cpus=1 \
        --move \
        --show_threads \
        --cpus=+0 \
        --move \
        --show_threads

                       thread       ctxt_switches
     pid SCHED_ rtpri affinity voluntary nonvoluntary             cmd
   3861   OTHER     0      0,1     33997           58 gnome-screensav
                       thread       ctxt_switches
     pid SCHED_ rtpri affinity voluntary nonvoluntary             cmd
   3861   OTHER     0        0     33997           58 gnome-screensav
                       thread       ctxt_switches
     pid SCHED_ rtpri affinity voluntary nonvoluntary             cmd
   3861   OTHER     0        1     33997           58 gnome-screensav
                       thread       ctxt_switches
     pid SCHED_ rtpri affinity voluntary nonvoluntary             cmd
   3861   OTHER     0      0,1     33997           58 gnome-screensav
The above example command performs the following operations sequentially:
  1. Select all threads that begin with gnome-sc.
  2. Show the selected threads to enable the user to verify their affinity mask and RT priority.
  3. Select CPU 0.
  4. Move the gnome-sc threads to the selected CPU (CPU 0).
  5. Show the result of the move.
  6. Reset the CPU list to CPU 1.
  7. Move the gnome-sc threads to the selected CPU (CPU 1).
  8. Show the result of the move.
  9. Add CPU 0 to the CPU list.
  10. Move the gnome-sc threads to the selected CPUs (CPUs 0 and 1).
  11. Show the result of the move.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.