1514f1c67SArnaldo Carvalho de Meloperf-trace(1) 2514f1c67SArnaldo Carvalho de Melo============= 3514f1c67SArnaldo Carvalho de Melo 4514f1c67SArnaldo Carvalho de MeloNAME 5514f1c67SArnaldo Carvalho de Melo---- 6514f1c67SArnaldo Carvalho de Meloperf-trace - strace inspired tool 7514f1c67SArnaldo Carvalho de Melo 8514f1c67SArnaldo Carvalho de MeloSYNOPSIS 9514f1c67SArnaldo Carvalho de Melo-------- 10514f1c67SArnaldo Carvalho de Melo[verse] 11514f1c67SArnaldo Carvalho de Melo'perf trace' 125e2485b1SDavid Ahern'perf trace record' 13514f1c67SArnaldo Carvalho de Melo 14514f1c67SArnaldo Carvalho de MeloDESCRIPTION 15514f1c67SArnaldo Carvalho de Melo----------- 16514f1c67SArnaldo Carvalho de MeloThis command will show the events associated with the target, initially 17514f1c67SArnaldo Carvalho de Melosyscalls, but other system events like pagefaults, task lifetime events, 18514f1c67SArnaldo Carvalho de Meloscheduling events, etc. 19514f1c67SArnaldo Carvalho de Melo 205e2485b1SDavid AhernThis is a live mode tool in addition to working with perf.data files like 215e2485b1SDavid Ahernthe other perf tools. Files can be generated using the 'perf record' command 225e2485b1SDavid Ahernbut the session needs to include the raw_syscalls events (-e 'raw_syscalls:*'). 2396355f2cSMasanari IidaAlternatively, 'perf trace record' can be used as a shortcut to 245e2485b1SDavid Ahernautomatically include the raw_syscalls events when writing events to a file. 255e2485b1SDavid Ahern 265e2485b1SDavid AhernThe following options apply to perf trace; options to perf trace record are 275e2485b1SDavid Ahernfound in the perf record man page. 28514f1c67SArnaldo Carvalho de Melo 29514f1c67SArnaldo Carvalho de MeloOPTIONS 30514f1c67SArnaldo Carvalho de Melo------- 31514f1c67SArnaldo Carvalho de Melo 32ac9be8eeSDavid Ahern-a:: 33514f1c67SArnaldo Carvalho de Melo--all-cpus:: 34514f1c67SArnaldo Carvalho de Melo System-wide collection from all CPUs. 35514f1c67SArnaldo Carvalho de Melo 362ae3a312SArnaldo Carvalho de Melo-e:: 372ae3a312SArnaldo Carvalho de Melo--expr:: 38017037ffSArnaldo Carvalho de Melo--event:: 39017037ffSArnaldo Carvalho de Melo List of syscalls and other perf events (tracepoints, HW cache events, 4027702bcfSArnaldo Carvalho de Melo etc) to show. Globbing is supported, e.g.: "epoll_*", "*msg*", etc. 41017037ffSArnaldo Carvalho de Melo See 'perf list' for a complete list of events. 42b059efdfSArnaldo Carvalho de Melo Prefixing with ! shows all syscalls but the ones specified. You may 43b059efdfSArnaldo Carvalho de Melo need to escape it. 442ae3a312SArnaldo Carvalho de Melo 45e36b7821SAlexis Berlemont-D msecs:: 46e36b7821SAlexis Berlemont--delay msecs:: 47e36b7821SAlexis BerlemontAfter starting the program, wait msecs before measuring. This is useful to 48e36b7821SAlexis Berlemontfilter out the startup phase of the program, which is often very different. 49e36b7821SAlexis Berlemont 50c24ff998SArnaldo Carvalho de Melo-o:: 51c24ff998SArnaldo Carvalho de Melo--output=:: 52c24ff998SArnaldo Carvalho de Melo Output file name. 53c24ff998SArnaldo Carvalho de Melo 54514f1c67SArnaldo Carvalho de Melo-p:: 55514f1c67SArnaldo Carvalho de Melo--pid=:: 56514f1c67SArnaldo Carvalho de Melo Record events on existing process ID (comma separated list). 57514f1c67SArnaldo Carvalho de Melo 58ac9be8eeSDavid Ahern-t:: 59514f1c67SArnaldo Carvalho de Melo--tid=:: 60514f1c67SArnaldo Carvalho de Melo Record events on existing thread ID (comma separated list). 61514f1c67SArnaldo Carvalho de Melo 62ac9be8eeSDavid Ahern-u:: 63514f1c67SArnaldo Carvalho de Melo--uid=:: 64514f1c67SArnaldo Carvalho de Melo Record events in threads owned by uid. Name or number. 65514f1c67SArnaldo Carvalho de Melo 669ea42ba4SArnaldo Carvalho de Melo-G:: 679ea42ba4SArnaldo Carvalho de Melo--cgroup:: 689ea42ba4SArnaldo Carvalho de Melo Record events in threads in a cgroup. 699ea42ba4SArnaldo Carvalho de Melo 709ea42ba4SArnaldo Carvalho de Melo Look for cgroups to set at the /sys/fs/cgroup/perf_event directory, then 719ea42ba4SArnaldo Carvalho de Melo remove the /sys/fs/cgroup/perf_event/ part and try: 729ea42ba4SArnaldo Carvalho de Melo 739ea42ba4SArnaldo Carvalho de Melo perf trace -G A -e sched:*switch 749ea42ba4SArnaldo Carvalho de Melo 759ea42ba4SArnaldo Carvalho de Melo Will set all raw_syscalls:sys_{enter,exit}, pgfault, vfs_getname, etc 769ea42ba4SArnaldo Carvalho de Melo _and_ sched:sched_switch to the 'A' cgroup, while: 779ea42ba4SArnaldo Carvalho de Melo 789ea42ba4SArnaldo Carvalho de Melo perf trace -e sched:*switch -G A 799ea42ba4SArnaldo Carvalho de Melo 809ea42ba4SArnaldo Carvalho de Melo will only set the sched:sched_switch event to the 'A' cgroup, all the 819ea42ba4SArnaldo Carvalho de Melo other events (raw_syscalls:sys_{enter,exit}, etc are left "without" 829ea42ba4SArnaldo Carvalho de Melo a cgroup (on the root cgroup, sys wide, etc). 839ea42ba4SArnaldo Carvalho de Melo 849ea42ba4SArnaldo Carvalho de Melo Multiple cgroups: 859ea42ba4SArnaldo Carvalho de Melo 869ea42ba4SArnaldo Carvalho de Melo perf trace -G A -e sched:*switch -G B 879ea42ba4SArnaldo Carvalho de Melo 889ea42ba4SArnaldo Carvalho de Melo the syscall ones go to the 'A' cgroup, the sched:sched_switch goes 899ea42ba4SArnaldo Carvalho de Melo to the 'B' cgroup. 909ea42ba4SArnaldo Carvalho de Melo 91f078c385SArnaldo Carvalho de Melo--filter-pids=:: 92f078c385SArnaldo Carvalho de Melo Filter out events for these pids and for 'trace' itself (comma separated list). 93f078c385SArnaldo Carvalho de Melo 947c304ee0SArnaldo Carvalho de Melo-v:: 957c304ee0SArnaldo Carvalho de Melo--verbose=:: 967c304ee0SArnaldo Carvalho de Melo Verbosity level. 977c304ee0SArnaldo Carvalho de Melo 98514f1c67SArnaldo Carvalho de Melo--no-inherit:: 99514f1c67SArnaldo Carvalho de Melo Child tasks do not inherit counters. 100514f1c67SArnaldo Carvalho de Melo 101ac9be8eeSDavid Ahern-m:: 102514f1c67SArnaldo Carvalho de Melo--mmap-pages=:: 10327050f53SJiri Olsa Number of mmap data pages (must be a power of two) or size 10427050f53SJiri Olsa specification with appended unit character - B/K/M/G. The 10527050f53SJiri Olsa size is rounded up to have nearest pages power of two value. 106514f1c67SArnaldo Carvalho de Melo 107ac9be8eeSDavid Ahern-C:: 108514f1c67SArnaldo Carvalho de Melo--cpu:: 109514f1c67SArnaldo Carvalho de MeloCollect samples only on the list of CPUs provided. Multiple CPUs can be provided as a 110514f1c67SArnaldo Carvalho de Melocomma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. 111514f1c67SArnaldo Carvalho de MeloIn per-thread mode with inheritance mode on (default), Events are captured only when 112514f1c67SArnaldo Carvalho de Melothe thread executes on the designated CPUs. Default is to monitor all CPUs. 113514f1c67SArnaldo Carvalho de Melo 1149b9d28a0SSihyeon Jang--duration:: 115ae9ed035SArnaldo Carvalho de Melo Show only events that had a duration greater than N.M ms. 116ae9ed035SArnaldo Carvalho de Melo 1179b9d28a0SSihyeon Jang--sched:: 1181302d88eSArnaldo Carvalho de Melo Accrue thread runtime and provide a summary at the end of the session. 1191302d88eSArnaldo Carvalho de Melo 120*0a6545bdSArnaldo Carvalho de Melo--failure:: 121*0a6545bdSArnaldo Carvalho de Melo Show only syscalls that failed, i.e. that returned < 0. 122*0a6545bdSArnaldo Carvalho de Melo 1239b9d28a0SSihyeon Jang-i:: 1249b9d28a0SSihyeon Jang--input:: 1256810fc91SDavid Ahern Process events from a given perf data file. 1266810fc91SDavid Ahern 1279b9d28a0SSihyeon Jang-T:: 1289b9d28a0SSihyeon Jang--time:: 1294bb09192SDavid Ahern Print full timestamp rather time relative to first sample. 1304bb09192SDavid Ahern 13150c95cbdSArnaldo Carvalho de Melo--comm:: 13250c95cbdSArnaldo Carvalho de Melo Show process COMM right beside its ID, on by default, disable with --no-comm. 13350c95cbdSArnaldo Carvalho de Melo 134fd2eabafSDavid Ahern-s:: 135bf2575c1SDavid Ahern--summary:: 136fd2eabafSDavid Ahern Show only a summary of syscalls by thread with min, max, and average times 137fd2eabafSDavid Ahern (in msec) and relative stddev. 138fd2eabafSDavid Ahern 139fd2eabafSDavid Ahern-S:: 140fd2eabafSDavid Ahern--with-summary:: 141fd2eabafSDavid Ahern Show all syscalls followed by a summary by thread with min, max, and 142fd2eabafSDavid Ahern average times (in msec) and relative stddev. 143bf2575c1SDavid Ahern 144c522739dSArnaldo Carvalho de Melo--tool_stats:: 145c522739dSArnaldo Carvalho de Melo Show tool stats such as number of times fd->pathname was discovered thru 146c522739dSArnaldo Carvalho de Melo hooking the open syscall return + vfs_getname or via reading /proc/pid/fd, etc. 147c522739dSArnaldo Carvalho de Melo 1489b9d28a0SSihyeon Jang-f:: 1499b9d28a0SSihyeon Jang--force:: 1509b9d28a0SSihyeon Jang Don't complain, do it. 1519b9d28a0SSihyeon Jang 152598d02c5SStanislav Fomichev-F=[all|min|maj]:: 153598d02c5SStanislav Fomichev--pf=[all|min|maj]:: 154598d02c5SStanislav Fomichev Trace pagefaults. Optionally, you can specify whether you want minor, 155598d02c5SStanislav Fomichev major or all pagefaults. Default value is maj. 156598d02c5SStanislav Fomichev 157e281a960SStanislav Fomichev--syscalls:: 158739cf305SRavi Bangoria Trace system calls. This options is enabled by default, disable with 159739cf305SRavi Bangoria --no-syscalls. 160e281a960SStanislav Fomichev 161566a0885SMilian Wolff--call-graph [mode,type,min[,limit],order[,key][,branch]]:: 162566a0885SMilian Wolff Setup and enable call-graph (stack chain/backtrace) recording. 163566a0885SMilian Wolff See `--call-graph` section in perf-record and perf-report 164566a0885SMilian Wolff man pages for details. The ones that are most useful in 'perf trace' 165566a0885SMilian Wolff are 'dwarf' and 'lbr', where available, try: 'perf trace --call-graph dwarf'. 166566a0885SMilian Wolff 167f3e459d1SArnaldo Carvalho de Melo Using this will, for the root user, bump the value of --mmap-pages to 4 168f3e459d1SArnaldo Carvalho de Melo times the maximum for non-root users, based on the kernel.perf_event_mlock_kb 169f3e459d1SArnaldo Carvalho de Melo sysctl. This is done only if the user doesn't specify a --mmap-pages value. 170f3e459d1SArnaldo Carvalho de Melo 17144621819SArnaldo Carvalho de Melo--kernel-syscall-graph:: 17244621819SArnaldo Carvalho de Melo Show the kernel callchains on the syscall exit path. 17344621819SArnaldo Carvalho de Melo 174c6d4a494SArnaldo Carvalho de Melo--max-stack:: 175c6d4a494SArnaldo Carvalho de Melo Set the stack depth limit when parsing the callchain, anything 176c6d4a494SArnaldo Carvalho de Melo beyond the specified depth will be ignored. Note that at this point 177c6d4a494SArnaldo Carvalho de Melo this is just about the presentation part, i.e. the kernel is still 178c6d4a494SArnaldo Carvalho de Melo not limiting, the overhead of callchains needs to be set via the 179c6d4a494SArnaldo Carvalho de Melo knobs in --call-graph dwarf. 180c6d4a494SArnaldo Carvalho de Melo 18105614993SArnaldo Carvalho de Melo Implies '--call-graph dwarf' when --call-graph not present on the 18205614993SArnaldo Carvalho de Melo command line, on systems where DWARF unwinding was built in. 18305614993SArnaldo Carvalho de Melo 184fe176085SArnaldo Carvalho de Melo Default: /proc/sys/kernel/perf_event_max_stack when present for 185fe176085SArnaldo Carvalho de Melo live sessions (without --input/-i), 127 otherwise. 186c6d4a494SArnaldo Carvalho de Melo 1875cf9c84eSArnaldo Carvalho de Melo--min-stack:: 1885cf9c84eSArnaldo Carvalho de Melo Set the stack depth limit when parsing the callchain, anything 1895cf9c84eSArnaldo Carvalho de Melo below the specified depth will be ignored. Disabled by default. 1905cf9c84eSArnaldo Carvalho de Melo 19105614993SArnaldo Carvalho de Melo Implies '--call-graph dwarf' when --call-graph not present on the 19205614993SArnaldo Carvalho de Melo command line, on systems where DWARF unwinding was built in. 19305614993SArnaldo Carvalho de Melo 194591421e1SArnaldo Carvalho de Melo--print-sample:: 195591421e1SArnaldo Carvalho de Melo Print the PERF_RECORD_SAMPLE PERF_SAMPLE_ info for the 196591421e1SArnaldo Carvalho de Melo raw_syscalls:sys_{enter,exit} tracepoints, for debugging. 197591421e1SArnaldo Carvalho de Melo 1989d9cad76SKan Liang--proc-map-timeout:: 1999d9cad76SKan Liang When processing pre-existing threads /proc/XXX/mmap, it may take a long time, 2009d9cad76SKan Liang because the file may be huge. A time out is needed in such cases. 2019d9cad76SKan Liang This option sets the time out limit. The default value is 500 ms. 2029d9cad76SKan Liang 203598d02c5SStanislav FomichevPAGEFAULTS 204598d02c5SStanislav Fomichev---------- 205598d02c5SStanislav Fomichev 206598d02c5SStanislav FomichevWhen tracing pagefaults, the format of the trace is as follows: 207598d02c5SStanislav Fomichev 208598d02c5SStanislav Fomichev<min|maj>fault [<ip.symbol>+<ip.offset>] => <addr.dso@addr.offset> (<map type><addr level>). 209598d02c5SStanislav Fomichev 210598d02c5SStanislav Fomichev- min/maj indicates whether fault event is minor or major; 211598d02c5SStanislav Fomichev- ip.symbol shows symbol for instruction pointer (the code that generated the 212598d02c5SStanislav Fomichev fault); if no debug symbols available, perf trace will print raw IP; 213598d02c5SStanislav Fomichev- addr.dso shows DSO for the faulted address; 214598d02c5SStanislav Fomichev- map type is either 'd' for non-executable maps or 'x' for executable maps; 215598d02c5SStanislav Fomichev- addr level is either 'k' for kernel dso or '.' for user dso. 216598d02c5SStanislav Fomichev 217598d02c5SStanislav FomichevFor symbols resolution you may need to install debugging symbols. 218598d02c5SStanislav Fomichev 219598d02c5SStanislav FomichevPlease be aware that duration is currently always 0 and doesn't reflect actual 220598d02c5SStanislav Fomichevtime it took for fault to be handled! 221598d02c5SStanislav Fomichev 222598d02c5SStanislav FomichevWhen --verbose specified, perf trace tries to print all available information 223598d02c5SStanislav Fomichevfor both IP and fault address in the form of dso@symbol+offset. 224598d02c5SStanislav Fomichev 225598d02c5SStanislav FomichevEXAMPLES 226598d02c5SStanislav Fomichev-------- 227598d02c5SStanislav Fomichev 228e281a960SStanislav FomichevTrace only major pagefaults: 229e281a960SStanislav Fomichev 230e281a960SStanislav Fomichev $ perf trace --no-syscalls -F 231e281a960SStanislav Fomichev 232598d02c5SStanislav FomichevTrace syscalls, major and minor pagefaults: 233598d02c5SStanislav Fomichev 234598d02c5SStanislav Fomichev $ perf trace -F all 235598d02c5SStanislav Fomichev 236598d02c5SStanislav Fomichev 1416.547 ( 0.000 ms): python/20235 majfault [CRYPTO_push_info_+0x0] => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0@0x61be0 (x.) 237598d02c5SStanislav Fomichev 238598d02c5SStanislav Fomichev As you can see, there was major pagefault in python process, from 239598d02c5SStanislav Fomichev CRYPTO_push_info_ routine which faulted somewhere in libcrypto.so. 240598d02c5SStanislav Fomichev 241514f1c67SArnaldo Carvalho de MeloSEE ALSO 242514f1c67SArnaldo Carvalho de Melo-------- 243514f1c67SArnaldo Carvalho de Melolinkperf:perf-record[1], linkperf:perf-script[1] 244