Why does perf show that sleep takes all cores?
According to man page of perf stat
subocmmand, you have -a
option to profile full system:
http://man7.org/linux/man-pages/man1/perf-stat.1.html
-a, --all-cpus
system-wide collection from all CPUs (default if no target is
specified)
In this "system-wide" mode perf stat
(and perf record
too) will count events on (or profile for record
) all CPUs in the system. When used without additional argument of command
, perf will run until interrupted by Ctrl-C. With argument of command
, perf will count/profile until the command works. Typical usage is
perf stat -a sleep 10 # Profile counting every CPU for 10 seconds
perf record -a sleep 10 # Profile with cycles every CPU for 10 seconds to perf.data
For getting stats of single command use single process profiling (without -a option)
perf stat python3 test.py
For profiling (perf record
) you may run without -a option; or you may use -a and later do some manual filtering in perf report
, focusing only on the pids/tids/dsos of your application (This can be very useful if command to profile uses some interprocess requests to other daemons to do lot of CPU work).
--per-core, -A, -C <cpulist>, --per-socket
options are only for system-wide -a
mode. Try --per-thread
with -p pid
attach to process option.
what's the meaning of cycles annotation in perf stat
This is a thing I hate very much on perf
, that the documentation and manual pages are outdated and searching for meaning of some values is pretty complicated. I did search for them once so I add my findings:
what's the meaning of 1.478 GHz
To my knowledge, the value after #
is recalculation of the native counter value (the value in the first column) to the user-readable form. This value should roughly correspond to clock speed of your processor:
grep MHz /proc/cpuinfo
should give similar value. It is printed from tools/perf/util/stat-shadow.c.
and [46.17%] in cycles's annotation?
This value should correspond the the portion of time, the hardware counter was active. Perf allows to start more hardware counters and multiplex them in runtime, which makes it easier for programmer.
I didn't found the actual place in the code, but it is described in one recently proposed patch as (part of csv
format):
+ - percentage of measurement time the counter was running
perf stat returning not supported for all events on ARCH Linux ARM
The solution I found was to downgrade from perf 4.5-2
to perf 4.3-1
.
cd /var/cache/pacman/pkg/
sudo pacman -U perf-4.3-1-armv7h.pkg.tar.xz
Running perf stat ls
now returns the counters I expect.
Related Topics
How to Correctly Cleanup and Re-Use Sysv Shared Memory Segments
Delimited by Comma Using Awk or Sed with the Tags Below
Dbd::Oracle Installation Causing Error
How to Filter the Running Nodes
Count the Number of Executable Files in Bash
Multiple Ip Addresses on Google Cloud Compute
Counting Number of Lines in a File Using Grep and Wc
Escape Single Quotes in Shell Script
Trailing Arguments with Find -Exec {} +
Adding a Header into Multiple .Txt Files
I Want to Remove Multiple Line of Text on Linux
Grabbing Specific Sections of Text from a String
Why Is Cpu-Cycles Much Less Than CPU Current Frequency
How to Install Cargo on a Rhel Linux Server
Why Do I Get 'Permission Denied' After Using ./File2 in Linux
Executing String Sent from One Terminal in Another in Linux Pseudo-Terminal
How to Convert Pe(Portable Executable) Format to Elf in Linux