linux-stable/tools/perf/Documentation
Arnaldo Carvalho de Melo 9ea42ba441 perf trace: Support setting cgroups as targets
One can set a cgroup as a default cgroup to be used by all events or
set cgroups with the 'perf stat' and 'perf record' behaviour, i.e.
'-G A' will be the cgroup for events defined so far in the command line.

Here in my main machine, with a kvm instance running a rhel6 guinea pig
I have:

  # ls -la /sys/fs/cgroup/perf_event/ | grep drw
  drwxr-xr-x. 14 root root 360 Mar  6 12:04 ..
  drwxr-xr-x.  3 root root   0 Mar  6 15:05 machine.slice
  #

So I can go ahead and use that cgroup hierarchy, say lets see what
syscalls are being emitted by threads in that 'machine.slice' hierarchy
that are taking more than 100ms:

  # perf trace --duration 100 -G machine.slice
     0.188 (249.850 ms): CPU 0/KVM/23744 ioctl(fd: 16<anon_inode:kvm-vcpu:0>, cmd: KVM_RUN) = 0
   250.274 (249.743 ms): CPU 0/KVM/23744 ioctl(fd: 16<anon_inode:kvm-vcpu:0>, cmd: KVM_RUN) = 0
   500.224 (249.755 ms): CPU 0/KVM/23744 ioctl(fd: 16<anon_inode:kvm-vcpu:0>, cmd: KVM_RUN) = 0
   750.097 (249.934 ms): CPU 0/KVM/23744 ioctl(fd: 16<anon_inode:kvm-vcpu:0>, cmd: KVM_RUN) = 0
  1000.244 (249.780 ms): CPU 0/KVM/23744 ioctl(fd: 16<anon_inode:kvm-vcpu:0>, cmd: KVM_RUN) = 0
  1250.197 (249.796 ms): CPU 0/KVM/23744 ioctl(fd: 16<anon_inode:kvm-vcpu:0>, cmd: KVM_RUN) = 0
  1500.124 (249.859 ms): CPU 0/KVM/23744 ioctl(fd: 16<anon_inode:kvm-vcpu:0>, cmd: KVM_RUN) = 0
  1750.076 (172.900 ms): CPU 0/KVM/23744 ioctl(fd: 16<anon_inode:kvm-vcpu:0>, cmd: KVM_RUN) = 0
   902.570 (1021.116 ms): qemu-system-x8/23667 ppoll(ufds: 0x558151e03180, nfds: 74, tsp: 0x7ffc00cd0900, sigsetsize: 8) = 1
  1923.825 (305.133 ms): qemu-system-x8/23667 ppoll(ufds: 0x558151e03180, nfds: 74, tsp: 0x7ffc00cd0900, sigsetsize: 8) = 1
  2000.172 (229.002 ms): CPU 0/KVM/23744 ioctl(fd: 16<anon_inode:kvm-vcpu:0>, cmd: KVM_RUN) = 0
^C  #

If we look inside that cgroup hierarchy we get:

  # ls -la /sys/fs/cgroup/perf_event/machine.slice/ | grep drw
  drwxr-xr-x. 3 root root 0 Mar  6 15:05 .
  drwxr-xr-x. 2 root root 0 Mar  6 16:16 machine-qemu\x2d2\x2drhel6.sandy.scope
  #

There is just one, but lets say there were more and we would want to see
5 seconds worth of syscall summary for the threads in that cgroup:

  # perf trace --summary -G machine.slice/machine-qemu\\x2d2\\x2drhel6.sandy.scope/ -a sleep 5

   Summary of events:

     qemu-system-x86 (23667), 143858 events, 24.2%

     syscall            calls    total       min       avg       max      stddev
                                 (msec)    (msec)    (msec)    (msec)        (%)
     --------------- -------- --------- --------- --------- ---------     ------
     ppoll              28492  4348.631     0.000     0.153    11.616      1.05%
     futex              19661   140.801     0.001     0.007     2.993      3.20%
     read               18440    68.084     0.001     0.004     1.653      4.33%
     ioctl               5387    24.768     0.002     0.005     0.134      1.62%

     CPU 0/KVM (23744), 449455 events, 75.8%

     syscall            calls    total       min       avg       max      stddev
                               (msec)    (msec)    (msec)    (msec)        (%)
     --------------- -------- --------- --------- --------- ---------     ------
     ioctl             148364  3401.812     0.000     0.023    11.801      1.15%
     futex              36131   404.127     0.001     0.011     7.377      2.63%
     writev             29452   339.688     0.003     0.012     1.740      1.36%
     write              11315    45.992     0.001     0.004     0.105      1.10%

  #

See the documentation about how to set more than one cgroup for
different events in the same command line.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-t126jh4occqvu0xdqlcjygex@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-03-07 10:22:26 -03:00
..
android.txt perf tools: Update android build documentation 2016-07-04 20:27:27 -03:00
asciidoc.conf
Build.txt
callchain-overhead-calculation.txt
examples.txt
intel-bts.txt
intel-pt.txt perf intel-pt: Fix syntax in documentation of config option 2017-09-01 14:45:59 -03:00
itrace.txt perf auxtrace: Add itrace option to output power events 2017-06-27 12:09:58 -03:00
jit-interface.txt
jitdump-specification.txt perf jit: Add jitdump format specification document 2016-10-24 11:07:41 -03:00
Makefile perf tools: Really install manpages via 'make install-man' 2017-08-22 13:24:53 -03:00
manpage-1.72.xsl
manpage-base.xsl
manpage-bold-literal.xsl
manpage-normal.xsl
manpage-suppress-sp.xsl
perf-annotate.txt perf annotate: Add missing arguments in Man page 2018-02-16 14:55:41 -03:00
perf-archive.txt
perf-bench.txt
perf-buildid-cache.txt perf buildid-cache: Document missing --force option 2017-11-16 14:50:07 -03:00
perf-buildid-list.txt
perf-c2c.txt perf tools: Fix spelling mistakes 2017-05-04 09:59:53 -03:00
perf-config.txt perf diff: Add diff.compute config option 2017-02-13 14:29:37 -03:00
perf-data.txt perf data: Document missing --force option 2018-02-15 09:57:33 -03:00
perf-diff.txt perf diff: Add -q/--quiet option 2017-02-20 11:47:08 -03:00
perf-evlist.txt perf evlist: Document missing --force option 2017-11-16 14:50:07 -03:00
perf-ftrace.txt perf ftrace: Add -D option for depth filter 2017-06-19 22:05:54 -03:00
perf-help.txt
perf-inject.txt perf inject: Document missing options 2017-11-16 14:50:05 -03:00
perf-kallsyms.txt perf kallsyms: Fix the usage on the man page 2018-02-21 09:23:36 -03:00
perf-kmem.txt perf kmem: Document a missing option & an argument 2018-02-16 14:55:42 -03:00
perf-kvm.txt
perf-list.txt perf list: Fix group description in the man page 2017-10-23 11:20:54 -03:00
perf-lock.txt perf lock: Document missing options 2017-11-16 14:50:04 -03:00
perf-mem.txt perf mem: Document a missing option 2018-02-16 14:55:42 -03:00
perf-probe.txt perf probe: Support escaped character in parser 2017-12-27 12:15:55 -03:00
perf-record.txt perf record: Throttle user defined frequencies to the maximum allowed 2018-03-05 09:58:44 -03:00
perf-report.txt perf report: Fix description for --mem-mode 2018-02-16 14:55:46 -03:00
perf-sched.txt perf sched: Document missing --force option 2017-11-16 14:50:06 -03:00
perf-script-perl.txt perf script: Fix documentation errors 2017-06-07 20:27:20 -03:00
perf-script-python.txt perf script python: Remove dups in documentation examples 2017-06-07 20:36:12 -03:00
perf-script.txt perf script: Add --show-round-event to display PERF_RECORD_FINISHED_ROUND 2018-02-16 10:09:23 -03:00
perf-stat.txt perf cgroup: Simplify arguments when tracking multiple events 2018-02-22 10:02:27 -03:00
perf-test.txt perf test: Add -F/--dont-fork option 2016-06-30 18:27:45 -03:00
perf-timechart.txt perf timechart: Document missing --force option 2017-11-16 14:50:06 -03:00
perf-top.txt perf top: Allow asking for the maximum allowed sample rate 2018-03-05 09:58:44 -03:00
perf-trace.txt perf trace: Support setting cgroups as targets 2018-03-07 10:22:26 -03:00
perf.data-file-format.txt perf header: Add infrastructure to record first and last sample time 2018-01-08 11:20:51 -03:00
perf.txt
perfconfig.example perf config: Show default report configuration in example and docs 2016-09-01 09:44:13 -03:00
tips.txt perf c2c: Add a tip about cacheline events 2017-12-05 15:43:55 -03:00