Questo contenuto non è disponibile nella lingua selezionata.

Chapter 14. Investigating busy CPUs with perf


When investigating performance issues on a system, use perf to identify and monitor the busiest CPUs. This helps you 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

    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

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
    • You can sort by CPU and command to display more detailed information about where CPU time is being spent:

      # perf report --sort cpu,comm

      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

    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

    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

Use perf to sample performance data from specific CPUs and analyze the results to identify CPU-specific 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>

      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>

      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

    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.

Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2026 Red Hat
Torna in cima