Este conteúdo não está disponível no idioma selecionado.

Chapter 14. Investigating busy CPUs with perf


When investigating performance issues on a system, you can use the perf tool to identify and monitor the busiest CPUs in order to focus your efforts.

14.1. Displaying CPU events counted with perf stat

You can use perf stat to display which CPU events were counted on by disabling CPU count aggregation. You must count events in the system-wide mode by using the -a flag in order to use this functionality.

Prerequisites

  • You have the perf user space tool installed. For more information, see Installing perf.

Procedure

  • Count the events with CPU count aggregation disabled:

    # perf stat -a -A sleep seconds
    Copy to Clipboard Toggle word wrap

    This command displays the count of a default set of common hardware and software events recorded for a time-period of seconds seconds, as dictated by using the sleep command, over each CPU in ascending order, starting with CPU0. As such, it may be useful to specify an event such as cycles:

    # perf stat -a -A -e cycles sleep seconds
    Copy to Clipboard Toggle word wrap

14.2. Displaying CPU samples taken with perf report

The perf record command samples performance data and stores it in a perf.data file. You can read this file by using the perf report command. The perf record command also records the CPU on which each sample was taken. To view this information, configure the perf report command accordingly.

Prerequisites

  • You have the perf user space tool installed. For more information, see Installing perf.
  • There is a perf.data file created with perf record in the current directory. If the perf.data file was created with root access, you need to run perf report with root access too.

Procedure

  • Display the contents of the perf.data file for further analysis while sorting by CPU:

    # perf report --sort cpu
    Copy to Clipboard Toggle word wrap
    • You can sort by CPU and command to display more detailed information about where CPU time is being spent:

      # perf report --sort cpu,comm
      Copy to Clipboard Toggle word wrap

      This example will list commands from all monitored CPUs by total overhead in descending order of overhead usage and identify the CPU the command was executed.

14.3. Displaying specific CPUs during profiling with perf top

You can configure perf top to display specific CPUs and their relative usage while profiling your system in real time.

Prerequisites

  • You have the perf user space tool installed. For more information, see Installing perf.

Procedure

  • Start the perf top interface while sorting by CPU:

    # perf top --sort cpu
    Copy to Clipboard Toggle word wrap

    This command lists CPUs and their respective overhead in descending order of overhead usage in real time. You can sort by CPU and command for more detailed information of where CPU time is being spent:

    # perf top --sort cpu,comm
    Copy to Clipboard Toggle word wrap

    This command lists commands by total overhead in descending order of overhead usage and identifies the CPU the command was executed on in real time.

14.4. Monitoring specific CPUs by using perf record and perf report

You can use the perf tool to sample performance data from specific CPUs and analyze the results to identify CPU-specific behavior or bottlenecks.

Prerequisites

  • You have the perf user space tool installed. For more information, see Installing perf.

Procedure

  1. Record performance data from specific CPUs:

    Use the -C option with perf record to target specific CPUs. The following examples demonstrate how to specify individual CPUs or a range.

    • To sample data from selected CPUs (comma-separated):

      # perf record -C 0,1 sleep <seconds>
      Copy to Clipboard Toggle word wrap

      This command samples and records performance data from CPUs 0 and 1 for the specified number of seconds.

    • To sample data from a range of CPUs:

      # perf record -C 0-2 sleep <seconds>
      Copy to Clipboard Toggle word wrap

      This command samples and records performance data from CPUs 0, 1, and 2 over the specified duration.

  2. Analyze the recorded performance data:

    Use the perf report command to read and analyze the perf.data file.

    # perf report
    Copy to Clipboard Toggle word wrap

    This command displays the contents of the perf.data file.

    Note

    If you want to see which CPU each sample was recorded on, see Displaying which CPU samples were taken on with perf report.

Voltar ao topo
Red Hat logoGithubredditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar. Explore nossas atualizações recentes.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja o Blog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

Theme

© 2025 Red Hat