├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── javaagent ├── pom.xml └── src │ └── main │ └── java │ └── ru │ ├── devexperts │ └── jagent │ │ ├── ClassInfo.java │ │ ├── ClassInfoCache.java │ │ ├── ClassInfoMap.java │ │ ├── ClassInfoVisitor.java │ │ ├── FrameClassWriter.java │ │ ├── InnerJarClassLoader.java │ │ └── Log.java │ └── raiffeisen │ ├── PerfPtProf.java │ └── instrumenter │ ├── ClassInstrumenter.java │ ├── InstrumenterAsm.java │ └── MemInstrHelper.java └── libperf ├── Build ├── CREDITS ├── Documentation ├── Build.txt ├── Makefile ├── android.txt ├── asciidoc.conf ├── callchain-overhead-calculation.txt ├── examples.txt ├── intel-bts.txt ├── intel-pt.txt ├── itrace.txt ├── jit-interface.txt ├── jitdump-specification.txt ├── manpage-1.72.xsl ├── manpage-base.xsl ├── manpage-bold-literal.xsl ├── manpage-normal.xsl ├── manpage-suppress-sp.xsl ├── perf-annotate.txt ├── perf-archive.txt ├── perf-bench.txt ├── perf-buildid-cache.txt ├── perf-buildid-list.txt ├── perf-c2c.txt ├── perf-config.txt ├── perf-data.txt ├── perf-diff.txt ├── perf-evlist.txt ├── perf-ftrace.txt ├── perf-help.txt ├── perf-inject.txt ├── perf-kallsyms.txt ├── perf-kmem.txt ├── perf-kvm.txt ├── perf-list.txt ├── perf-lock.txt ├── perf-mem.txt ├── perf-probe.txt ├── perf-record.txt ├── perf-report.txt ├── perf-sched.txt ├── perf-script-perl.txt ├── perf-script-python.txt ├── perf-script.txt ├── perf-stat.txt ├── perf-test.txt ├── perf-timechart.txt ├── perf-top.txt ├── perf-trace.txt ├── perf.data-file-format.txt ├── perf.txt ├── perfconfig.example └── tips.txt ├── MANIFEST ├── Makefile ├── Makefile.config ├── Makefile.perf ├── arch ├── Build ├── alpha │ └── Build ├── arm │ ├── Build │ ├── Makefile │ ├── annotate │ │ └── instructions.c │ ├── include │ │ ├── dwarf-regs-table.h │ │ └── perf_regs.h │ ├── tests │ │ ├── Build │ │ ├── dwarf-unwind.c │ │ └── regs_load.S │ └── util │ │ ├── Build │ │ ├── auxtrace.c │ │ ├── cs-etm.c │ │ ├── cs-etm.h │ │ ├── dwarf-regs.c │ │ ├── pmu.c │ │ ├── unwind-libdw.c │ │ └── unwind-libunwind.c ├── arm64 │ ├── Build │ ├── Makefile │ ├── annotate │ │ └── instructions.c │ ├── include │ │ ├── dwarf-regs-table.h │ │ └── perf_regs.h │ ├── tests │ │ ├── Build │ │ ├── dwarf-unwind.c │ │ └── regs_load.S │ └── util │ │ ├── Build │ │ ├── dwarf-regs.c │ │ └── unwind-libunwind.c ├── common.c ├── common.h ├── mips │ └── Build ├── parisc │ └── Build ├── powerpc │ ├── Build │ ├── Makefile │ ├── annotate │ │ └── instructions.c │ ├── include │ │ ├── arch-tests.h │ │ ├── dwarf-regs-table.h │ │ └── perf_regs.h │ ├── tests │ │ ├── Build │ │ ├── arch-tests.c │ │ ├── dwarf-unwind.c │ │ └── regs_load.S │ └── util │ │ ├── Build │ │ ├── book3s_hcalls.h │ │ ├── book3s_hv_exits.h │ │ ├── dwarf-regs.c │ │ ├── header.c │ │ ├── kvm-stat.c │ │ ├── perf_regs.c │ │ ├── skip-callchain-idx.c │ │ ├── sym-handling.c │ │ ├── unwind-libdw.c │ │ └── unwind-libunwind.c ├── s390 │ ├── Build │ ├── Makefile │ ├── annotate │ │ └── instructions.c │ ├── include │ │ ├── dwarf-regs-table.h │ │ └── perf_regs.h │ └── util │ │ ├── Build │ │ ├── auxtrace.c │ │ ├── dwarf-regs.c │ │ ├── header.c │ │ ├── kvm-stat.c │ │ ├── machine.c │ │ └── unwind-libdw.c ├── sh │ ├── Build │ ├── Makefile │ ├── include │ │ └── dwarf-regs-table.h │ └── util │ │ ├── Build │ │ └── dwarf-regs.c ├── sparc │ ├── Build │ ├── Makefile │ ├── include │ │ └── dwarf-regs-table.h │ └── util │ │ ├── Build │ │ └── dwarf-regs.c ├── x86 │ ├── Build │ ├── Makefile │ ├── annotate │ │ └── instructions.c │ ├── entry │ │ └── syscalls │ │ │ ├── syscall_64.tbl │ │ │ └── syscalltbl.sh │ ├── include │ │ ├── arch-tests.h │ │ ├── dwarf-regs-table.h │ │ ├── generated │ │ │ └── asm │ │ │ │ └── syscalls_64.c │ │ └── perf_regs.h │ ├── tests │ │ ├── Build │ │ ├── arch-tests.c │ │ ├── dwarf-unwind.c │ │ ├── gen-insn-x86-dat.awk │ │ ├── gen-insn-x86-dat.sh │ │ ├── insn-x86-dat-32.c │ │ ├── insn-x86-dat-64.c │ │ ├── insn-x86-dat-src.c │ │ ├── insn-x86.c │ │ ├── intel-cqm.c │ │ ├── perf-time-to-tsc.c │ │ ├── rdpmc.c │ │ └── regs_load.S │ └── util │ │ ├── Build │ │ ├── auxtrace.c │ │ ├── dwarf-regs.c │ │ ├── group.c │ │ ├── header.c │ │ ├── intel-bts.c │ │ ├── intel-pt.c │ │ ├── kvm-stat.c │ │ ├── perf_regs.c │ │ ├── pmu.c │ │ ├── tsc.c │ │ ├── unwind-libdw.c │ │ └── unwind-libunwind.c └── xtensa │ ├── Build │ ├── Makefile │ ├── include │ └── dwarf-regs-table.h │ └── util │ ├── Build │ └── dwarf-regs.c ├── bench ├── Build ├── bench.h ├── futex-hash.c ├── futex-lock-pi.c ├── futex-requeue.c ├── futex-wake-parallel.c ├── futex-wake.c ├── futex.h ├── mem-functions.c ├── mem-memcpy-arch.h ├── mem-memcpy-x86-64-asm-def.h ├── mem-memcpy-x86-64-asm.S ├── mem-memset-arch.h ├── mem-memset-x86-64-asm-def.h ├── mem-memset-x86-64-asm.S ├── numa.c ├── sched-messaging.c └── sched-pipe.c ├── builtin-annotate.c ├── builtin-bench.c ├── builtin-buildid-cache.c ├── builtin-buildid-list.c ├── builtin-c2c.c ├── builtin-config.c ├── builtin-data.c ├── builtin-diff.c ├── builtin-evlist.c ├── builtin-ftrace.c ├── builtin-help.c ├── builtin-inject.c ├── builtin-kallsyms.c ├── builtin-kmem.c ├── builtin-kvm.c ├── builtin-list.c ├── builtin-lock.c ├── builtin-mem.c ├── builtin-probe.c ├── builtin-record.c ├── builtin-report.c ├── builtin-sched.c ├── builtin-script.c ├── builtin-stat.c ├── builtin-timechart.c ├── builtin-top.c ├── builtin-trace.c ├── builtin-version.c ├── builtin.h ├── check-headers.sh ├── command-list.txt ├── design.txt ├── jit-methods.cpp ├── jit-methods.hpp ├── jni-wrapper.cpp ├── jni-wrapper.hpp ├── jvmti-agent.cpp ├── jvmti ├── Build ├── jvmti_agent.c ├── jvmti_agent.h └── libjvmti.c ├── perf-archive.sh ├── perf-completion.sh ├── perf-map-file.c ├── perf-map-file.hpp ├── perf-read-vdso.c ├── perf-script.py ├── perf-sys.h ├── perf-with-kcore.sh ├── perf.c ├── perf.h ├── pmu-events ├── Build ├── README ├── arch │ ├── powerpc │ │ ├── mapfile.csv │ │ ├── power8 │ │ │ ├── cache.json │ │ │ ├── floating-point.json │ │ │ ├── frontend.json │ │ │ ├── marked.json │ │ │ ├── memory.json │ │ │ ├── other.json │ │ │ ├── pipeline.json │ │ │ ├── pmc.json │ │ │ └── translation.json │ │ └── power9 │ │ │ ├── cache.json │ │ │ ├── floating-point.json │ │ │ ├── frontend.json │ │ │ ├── marked.json │ │ │ ├── memory.json │ │ │ ├── other.json │ │ │ ├── pipeline.json │ │ │ ├── pmc.json │ │ │ └── translation.json │ └── x86 │ │ ├── bonnell │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ └── virtual-memory.json │ │ ├── broadwell │ │ ├── bdw-metrics.json │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ ├── uncore.json │ │ └── virtual-memory.json │ │ ├── broadwellde │ │ ├── bdwde-metrics.json │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ ├── uncore-cache.json │ │ ├── uncore-memory.json │ │ ├── uncore-power.json │ │ └── virtual-memory.json │ │ ├── broadwellx │ │ ├── bdx-metrics.json │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ ├── uncore-cache.json │ │ ├── uncore-interconnect.json │ │ ├── uncore-memory.json │ │ ├── uncore-power.json │ │ └── virtual-memory.json │ │ ├── goldmont │ │ ├── cache.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ └── virtual-memory.json │ │ ├── goldmontplus │ │ ├── cache.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ └── virtual-memory.json │ │ ├── haswell │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── hsw-metrics.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ ├── uncore.json │ │ └── virtual-memory.json │ │ ├── haswellx │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── hsx-metrics.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ ├── uncore-cache.json │ │ ├── uncore-interconnect.json │ │ ├── uncore-memory.json │ │ ├── uncore-power.json │ │ └── virtual-memory.json │ │ ├── ivybridge │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── ivb-metrics.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ ├── uncore.json │ │ └── virtual-memory.json │ │ ├── ivytown │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── ivt-metrics.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ ├── uncore-cache.json │ │ ├── uncore-interconnect.json │ │ ├── uncore-memory.json │ │ ├── uncore-power.json │ │ └── virtual-memory.json │ │ ├── jaketown │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── jkt-metrics.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ ├── uncore-cache.json │ │ ├── uncore-interconnect.json │ │ ├── uncore-memory.json │ │ ├── uncore-power.json │ │ └── virtual-memory.json │ │ ├── knightslanding │ │ ├── cache.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── pipeline.json │ │ ├── uncore-memory.json │ │ └── virtual-memory.json │ │ ├── mapfile.csv │ │ ├── nehalemep │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ └── virtual-memory.json │ │ ├── nehalemex │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ └── virtual-memory.json │ │ ├── sandybridge │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ ├── snb-metrics.json │ │ ├── uncore.json │ │ └── virtual-memory.json │ │ ├── silvermont │ │ ├── cache.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── pipeline.json │ │ └── virtual-memory.json │ │ ├── skylake │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ ├── skl-metrics.json │ │ ├── uncore.json │ │ └── virtual-memory.json │ │ ├── skylakex │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ ├── skx-metrics.json │ │ ├── uncore-memory.json │ │ ├── uncore-other.json │ │ └── virtual-memory.json │ │ ├── westmereep-dp │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ └── virtual-memory.json │ │ ├── westmereep-sp │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ └── virtual-memory.json │ │ └── westmereex │ │ ├── cache.json │ │ ├── floating-point.json │ │ ├── frontend.json │ │ ├── memory.json │ │ ├── other.json │ │ ├── pipeline.json │ │ └── virtual-memory.json ├── jevents ├── jevents.c ├── jevents.h ├── jsmn.c ├── jsmn.h ├── json.c ├── json.h ├── pmu-events.c └── pmu-events.h ├── profiler-backend.cpp ├── profiler-backend.hpp ├── profiler.cpp ├── profiler.hpp ├── python ├── tracepoint.py └── twatch.py ├── ru_raiffeisen_PerfPtProf.h ├── scripts ├── Build ├── perl │ ├── Perf-Trace-Util │ │ ├── Build │ │ ├── Context.c │ │ ├── Context.xs │ │ ├── Makefile.PL │ │ ├── README │ │ ├── lib │ │ │ └── Perf │ │ │ │ └── Trace │ │ │ │ ├── Context.pm │ │ │ │ ├── Core.pm │ │ │ │ └── Util.pm │ │ └── typemap │ ├── bin │ │ ├── check-perf-trace-record │ │ ├── failed-syscalls-record │ │ ├── failed-syscalls-report │ │ ├── rw-by-file-record │ │ ├── rw-by-file-report │ │ ├── rw-by-pid-record │ │ ├── rw-by-pid-report │ │ ├── rwtop-record │ │ ├── rwtop-report │ │ ├── wakeup-latency-record │ │ └── wakeup-latency-report │ ├── check-perf-trace.pl │ ├── failed-syscalls.pl │ ├── rw-by-file.pl │ ├── rw-by-pid.pl │ ├── rwtop.pl │ └── wakeup-latency.pl └── python │ ├── Perf-Trace-Util │ ├── Build │ ├── Context.c │ └── lib │ │ └── Perf │ │ └── Trace │ │ ├── Core.py │ │ ├── EventClass.py │ │ ├── SchedGui.py │ │ └── Util.py │ ├── bin │ ├── compaction-times-record │ ├── compaction-times-report │ ├── event_analyzing_sample-record │ ├── event_analyzing_sample-report │ ├── export-to-postgresql-record │ ├── export-to-postgresql-report │ ├── export-to-sqlite-record │ ├── export-to-sqlite-report │ ├── failed-syscalls-by-pid-record │ ├── failed-syscalls-by-pid-report │ ├── futex-contention-record │ ├── futex-contention-report │ ├── intel-pt-events-record │ ├── intel-pt-events-report │ ├── net_dropmonitor-record │ ├── net_dropmonitor-report │ ├── netdev-times-record │ ├── netdev-times-report │ ├── sched-migration-record │ ├── sched-migration-report │ ├── sctop-record │ ├── sctop-report │ ├── stackcollapse-record │ ├── stackcollapse-report │ ├── syscall-counts-by-pid-record │ ├── syscall-counts-by-pid-report │ ├── syscall-counts-record │ └── syscall-counts-report │ ├── call-graph-from-sql.py │ ├── check-perf-trace.py │ ├── compaction-times.py │ ├── event_analyzing_sample.py │ ├── export-to-postgresql.py │ ├── export-to-sqlite.py │ ├── failed-syscalls-by-pid.py │ ├── futex-contention.py │ ├── intel-pt-events.py │ ├── net_dropmonitor.py │ ├── netdev-times.py │ ├── sched-migration.py │ ├── sctop.py │ ├── stackcollapse.py │ ├── stat-cpi.py │ ├── syscall-counts-by-pid.py │ └── syscall-counts.py ├── tests ├── .gitignore ├── Build ├── attr.c ├── attr.py ├── attr │ ├── README │ ├── base-record │ ├── base-stat │ ├── test-record-C0 │ ├── test-record-basic │ ├── test-record-branch-any │ ├── test-record-branch-filter-any │ ├── test-record-branch-filter-any_call │ ├── test-record-branch-filter-any_ret │ ├── test-record-branch-filter-hv │ ├── test-record-branch-filter-ind_call │ ├── test-record-branch-filter-k │ ├── test-record-branch-filter-u │ ├── test-record-count │ ├── test-record-data │ ├── test-record-freq │ ├── test-record-graph-default │ ├── test-record-graph-dwarf │ ├── test-record-graph-fp │ ├── test-record-group │ ├── test-record-group-sampling │ ├── test-record-group1 │ ├── test-record-no-buffering │ ├── test-record-no-inherit │ ├── test-record-no-samples │ ├── test-record-period │ ├── test-record-raw │ ├── test-stat-C0 │ ├── test-stat-basic │ ├── test-stat-default │ ├── test-stat-detailed-1 │ ├── test-stat-detailed-2 │ ├── test-stat-detailed-3 │ ├── test-stat-group │ ├── test-stat-group1 │ └── test-stat-no-inherit ├── backward-ring-buffer.c ├── bitmap.c ├── bp_signal.c ├── bp_signal_overflow.c ├── bpf-script-example.c ├── bpf-script-test-kbuild.c ├── bpf-script-test-prologue.c ├── bpf-script-test-relocation.c ├── bpf.c ├── builtin-test.c ├── clang.c ├── code-reading.c ├── cpumap.c ├── dso-data.c ├── dwarf-unwind.c ├── event-times.c ├── event_update.c ├── evsel-roundtrip-name.c ├── evsel-tp-sched.c ├── expr.c ├── fdarray.c ├── hists_common.c ├── hists_common.h ├── hists_cumulate.c ├── hists_filter.c ├── hists_link.c ├── hists_output.c ├── is_printable_array.c ├── keep-tracking.c ├── kmod-path.c ├── llvm.c ├── llvm.h ├── make ├── mem.c ├── mmap-basic.c ├── mmap-thread-lookup.c ├── openat-syscall-all-cpus.c ├── openat-syscall-tp-fields.c ├── openat-syscall.c ├── parse-events.c ├── parse-no-sample-id-all.c ├── perf-hooks.c ├── perf-record.c ├── perf-targz-src-pkg ├── pmu.c ├── python-use.c ├── sample-parsing.c ├── sdt.c ├── shell │ ├── lib │ │ ├── probe.sh │ │ └── probe_vfs_getname.sh │ ├── probe_vfs_getname.sh │ ├── record+script_probe_vfs_getname.sh │ ├── trace+probe_libc_inet_pton.sh │ └── trace+probe_vfs_getname.sh ├── stat.c ├── sw-clock.c ├── switch-tracking.c ├── task-exit.c ├── tests.h ├── thread-map.c ├── thread-mg-share.c ├── topology.c ├── unit_number__scnprintf.c └── vmlinux-kallsyms.c ├── trace ├── beauty │ ├── Build │ ├── beauty.h │ ├── clone.c │ ├── drm_ioctl.sh │ ├── eventfd.c │ ├── fcntl.c │ ├── flock.c │ ├── futex_op.c │ ├── ioctl.c │ ├── kcmp.c │ ├── kcmp_type.sh │ ├── kvm_ioctl.sh │ ├── madvise_behavior.sh │ ├── mmap.c │ ├── mode_t.c │ ├── msg_flags.c │ ├── open_flags.c │ ├── perf_event_open.c │ ├── perf_ioctl.sh │ ├── pid.c │ ├── pkey_alloc.c │ ├── pkey_alloc_access_rights.sh │ ├── prctl.c │ ├── prctl_option.sh │ ├── sched_policy.c │ ├── seccomp.c │ ├── signum.c │ ├── sndrv_ctl_ioctl.sh │ ├── sndrv_pcm_ioctl.sh │ ├── socket_type.c │ ├── statx.c │ ├── vhost_virtio_ioctl.sh │ └── waitid_options.c └── strace │ └── groups │ └── file ├── ui ├── Build ├── browser.c ├── browser.h ├── browsers │ ├── Build │ ├── annotate.c │ ├── header.c │ ├── hists.c │ ├── hists.h │ ├── map.c │ ├── map.h │ └── scripts.c ├── gtk │ ├── Build │ ├── annotate.c │ ├── browser.c │ ├── gtk.h │ ├── helpline.c │ ├── hists.c │ ├── progress.c │ ├── setup.c │ └── util.c ├── helpline.c ├── helpline.h ├── hist.c ├── keysyms.h ├── libslang.h ├── progress.c ├── progress.h ├── setup.c ├── stdio │ └── hist.c ├── tui │ ├── Build │ ├── helpline.c │ ├── progress.c │ ├── setup.c │ ├── tui.h │ └── util.c ├── ui.h ├── util.c └── util.h └── util ├── Build ├── PERF-VERSION-GEN ├── annotate.c ├── annotate.h ├── auxtrace.c ├── auxtrace.h ├── block-range.c ├── block-range.h ├── bpf-loader.c ├── bpf-loader.h ├── bpf-prologue.c ├── bpf-prologue.h ├── branch.c ├── branch.h ├── build-id.c ├── build-id.h ├── c++ ├── Build ├── clang-c.h ├── clang-test.cpp ├── clang.cpp └── clang.h ├── cache.h ├── call-path.c ├── call-path.h ├── callchain.c ├── callchain.h ├── cgroup.c ├── cgroup.h ├── cloexec.c ├── cloexec.h ├── color.c ├── color.h ├── comm.c ├── comm.h ├── compress.h ├── config.c ├── config.h ├── counts.c ├── counts.h ├── cpumap.c ├── cpumap.h ├── cs-etm.h ├── ctype.c ├── data-convert-bt.c ├── data-convert-bt.h ├── data-convert.h ├── data.c ├── data.h ├── db-export.c ├── db-export.h ├── debug.c ├── debug.h ├── demangle-java.c ├── demangle-java.h ├── demangle-rust.c ├── demangle-rust.h ├── drv_configs.c ├── drv_configs.h ├── dso.c ├── dso.h ├── dump-insn.c ├── dump-insn.h ├── dwarf-aux.c ├── dwarf-aux.h ├── dwarf-regs.c ├── env.c ├── env.h ├── event.c ├── event.h ├── evlist.c ├── evlist.h ├── evsel.c ├── evsel.h ├── evsel_fprintf.c ├── expr.h ├── expr.y ├── find-vdso-map.c ├── genelf.c ├── genelf.h ├── genelf_debug.c ├── generate-cmdlist.sh ├── group.h ├── header.c ├── header.h ├── help-unknown-cmd.c ├── help-unknown-cmd.h ├── hist.c ├── hist.h ├── include ├── asm │ ├── asm-offsets.h │ ├── cpufeature.h │ ├── dwarf2.h │ ├── swab.h │ ├── system.h │ └── uaccess.h ├── dwarf-regs.h └── linux │ ├── ctype.h │ └── linkage.h ├── intel-bts.c ├── intel-bts.h ├── intel-pt-decoder ├── Build ├── gen-insn-attr-x86.awk ├── inat-tables.c ├── inat.c ├── inat.h ├── inat_types.h ├── insn.c ├── insn.h ├── intel-pt-decoder.c ├── intel-pt-decoder.h ├── intel-pt-insn-decoder.c ├── intel-pt-insn-decoder.h ├── intel-pt-log.c ├── intel-pt-log.h ├── intel-pt-pkt-decoder.c ├── intel-pt-pkt-decoder.h └── x86-opcode-map.txt ├── intel-pt.c ├── intel-pt.h ├── intlist.c ├── intlist.h ├── jit.h ├── jitdump.c ├── jitdump.h ├── kvm-stat.h ├── levenshtein.c ├── levenshtein.h ├── libunwind ├── arm64.c └── x86_32.c ├── llvm-utils.c ├── llvm-utils.h ├── lzma.c ├── machine.c ├── machine.h ├── map.c ├── map.h ├── mem-events.c ├── mem-events.h ├── memswap.c ├── memswap.h ├── metricgroup.c ├── metricgroup.h ├── mmap.c ├── mmap.h ├── namespaces.c ├── namespaces.h ├── ordered-events.c ├── ordered-events.h ├── parse-branch-options.c ├── parse-branch-options.h ├── parse-events.c ├── parse-events.h ├── parse-events.l ├── parse-events.y ├── parse-regs-options.c ├── parse-regs-options.h ├── path.c ├── path.h ├── perf-hooks-list.h ├── perf-hooks.c ├── perf-hooks.h ├── perf_regs.c ├── perf_regs.h ├── pmu.c ├── pmu.h ├── pmu.l ├── pmu.y ├── print_binary.c ├── print_binary.h ├── probe-event.c ├── probe-event.h ├── probe-file.c ├── probe-file.h ├── probe-finder.c ├── probe-finder.h ├── pstack.c ├── pstack.h ├── python-ext-sources ├── python.c ├── quote.c ├── quote.h ├── rb_resort.h ├── rblist.c ├── rblist.h ├── record.c ├── rwsem.c ├── rwsem.h ├── sane_ctype.h ├── scripting-engines ├── Build ├── trace-event-perl.c └── trace-event-python.c ├── session.c ├── session.h ├── setns.c ├── setup.py ├── smt.c ├── smt.h ├── sort.c ├── sort.h ├── srcline.c ├── srcline.h ├── stat-shadow.c ├── stat.c ├── stat.h ├── strbuf.c ├── strbuf.h ├── strfilter.c ├── strfilter.h ├── string.c ├── string2.h ├── strlist.c ├── strlist.h ├── svghelper.c ├── svghelper.h ├── symbol-elf.c ├── symbol-minimal.c ├── symbol.c ├── symbol.h ├── symbol_fprintf.c ├── syscalltbl.c ├── syscalltbl.h ├── target.c ├── target.h ├── term.c ├── term.h ├── thread-stack.c ├── thread-stack.h ├── thread.c ├── thread.h ├── thread_map.c ├── thread_map.h ├── time-utils.c ├── time-utils.h ├── tool.h ├── top.c ├── top.h ├── trace-event-info.c ├── trace-event-parse.c ├── trace-event-read.c ├── trace-event-scripting.c ├── trace-event.c ├── trace-event.h ├── trigger.h ├── tsc.c ├── tsc.h ├── units.c ├── units.h ├── unwind-libdw.c ├── unwind-libdw.h ├── unwind-libunwind-local.c ├── unwind-libunwind.c ├── unwind.h ├── usage.c ├── util-cxx.h ├── util.c ├── util.h ├── values.c ├── values.h ├── vdso.c ├── vdso.h ├── xyarray.c ├── xyarray.h └── zlib.c /javaagent/src/main/java/ru/devexperts/jagent/ClassInfoMap.java: -------------------------------------------------------------------------------- 1 | package com.devexperts.jagent; 2 | 3 | /* 4 | * #%L 5 | * JAgent Impl 6 | * %% 7 | * Copyright (C) 2015 - 2016 Devexperts, LLC 8 | * %% 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Lesser Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Lesser Public 20 | * License along with this program. If not, see 21 | * . 22 | * #L% 23 | */ 24 | 25 | import java.util.HashMap; 26 | import java.util.Map; 27 | 28 | public class ClassInfoMap { 29 | private final Map map = new HashMap<>(); 30 | 31 | public ClassInfo get(String internalClassName) { 32 | return map.get(internalClassName); 33 | } 34 | 35 | public void put(String internalClassName, ClassInfo classInfo) { 36 | map.put(internalClassName, classInfo); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /javaagent/src/main/java/ru/raiffeisen/PerfPtProf.java: -------------------------------------------------------------------------------- 1 | package ru.raiffeisen; 2 | 3 | public class PerfPtProf { 4 | public static native void init(int cd); 5 | public static native void start(); 6 | public static native void stop(); 7 | } 8 | -------------------------------------------------------------------------------- /libperf/CREDITS: -------------------------------------------------------------------------------- 1 | Most of the infrastructure that 'perf' uses here has been reused 2 | from the Git project, as of version: 3 | 4 | 66996ec: Sync with 1.6.2.4 5 | 6 | Here is an (incomplete!) list of main contributors to those files 7 | in util/* and elsewhere: 8 | 9 | Alex Riesen 10 | Christian Couder 11 | Dmitry Potapov 12 | Jeff King 13 | Johannes Schindelin 14 | Johannes Sixt 15 | Junio C Hamano 16 | Linus Torvalds 17 | Matthias Kestenholz 18 | Michal Ostrowski 19 | Miklos Vajna 20 | Petr Baudis 21 | Pierre Habouzit 22 | René Scharfe 23 | Samuel Tardieu 24 | Shawn O. Pearce 25 | Steffen Prohaska 26 | Steve Haslam 27 | 28 | Thanks guys! 29 | 30 | The full history of the files can be found in the upstream Git commits. 31 | -------------------------------------------------------------------------------- /libperf/Documentation/itrace.txt: -------------------------------------------------------------------------------- 1 | i synthesize instructions events 2 | b synthesize branches events 3 | c synthesize branches events (calls only) 4 | r synthesize branches events (returns only) 5 | x synthesize transactions events 6 | w synthesize ptwrite events 7 | p synthesize power events 8 | e synthesize error events 9 | d create a debug log 10 | g synthesize a call chain (use with i or x) 11 | l synthesize last branch entries (use with i or x) 12 | s skip initial number of events 13 | 14 | The default is all events i.e. the same as --itrace=ibxwpe 15 | 16 | In addition, the period (default 100000) for instructions events 17 | can be specified in units of: 18 | 19 | i instructions 20 | t ticks 21 | ms milliseconds 22 | us microseconds 23 | ns nanoseconds (default) 24 | 25 | Also the call chain size (default 16, max. 1024) for instructions or 26 | transactions events can be specified. 27 | 28 | Also the number of last branch entries (default 64, max. 1024) for 29 | instructions or transactions events can be specified. 30 | 31 | It is also possible to skip events generated (instructions, branches, transactions, 32 | ptwrite, power) at the beginning. This is useful to ignore initialization code. 33 | 34 | --itrace=i0nss1000000 35 | 36 | skips the first million instructions. 37 | -------------------------------------------------------------------------------- /libperf/Documentation/jit-interface.txt: -------------------------------------------------------------------------------- 1 | perf supports a simple JIT interface to resolve symbols for dynamic code generated 2 | by a JIT. 3 | 4 | The JIT has to write a /tmp/perf-%d.map (%d = pid of process) file 5 | 6 | This is a text file. 7 | 8 | Each line has the following format, fields separated with spaces: 9 | 10 | START SIZE symbolname 11 | 12 | START and SIZE are hex numbers without 0x. 13 | symbolname is the rest of the line, so it could contain special characters. 14 | 15 | The ownership of the file has to match the process. 16 | -------------------------------------------------------------------------------- /libperf/Documentation/manpage-1.72.xsl: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /libperf/Documentation/manpage-base.xsl: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 14 | 18 | 19 | 20 | 21 | sp 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | br 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /libperf/Documentation/manpage-bold-literal.xsl: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | 9 | 10 | 11 | fB 12 | 13 | 14 | fR 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /libperf/Documentation/manpage-normal.xsl: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | 8 | 9 | 10 | \ 11 | . 12 | 13 | 14 | -------------------------------------------------------------------------------- /libperf/Documentation/manpage-suppress-sp.xsl: -------------------------------------------------------------------------------- 1 | 5 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /libperf/Documentation/perf-archive.txt: -------------------------------------------------------------------------------- 1 | perf-archive(1) 2 | =============== 3 | 4 | NAME 5 | ---- 6 | perf-archive - Create archive with object files with build-ids found in perf.data file 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'perf archive' [file] 12 | 13 | DESCRIPTION 14 | ----------- 15 | This command runs perf-buildid-list --with-hits, and collects the files with the 16 | buildids found so that analysis of perf.data contents can be possible on another 17 | machine. 18 | 19 | 20 | SEE ALSO 21 | -------- 22 | linkperf:perf-record[1], linkperf:perf-buildid-list[1], linkperf:perf-report[1] 23 | -------------------------------------------------------------------------------- /libperf/Documentation/perf-buildid-list.txt: -------------------------------------------------------------------------------- 1 | perf-buildid-list(1) 2 | ==================== 3 | 4 | NAME 5 | ---- 6 | perf-buildid-list - List the buildids in a perf.data file 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'perf buildid-list ' 12 | 13 | DESCRIPTION 14 | ----------- 15 | This command displays the buildids found in a perf.data file, so that other 16 | tools can be used to fetch packages with matching symbol tables for use by 17 | perf report. 18 | 19 | It can also be used to show the build id of the running kernel or in an ELF 20 | file using -i/--input. 21 | 22 | OPTIONS 23 | ------- 24 | -H:: 25 | --with-hits:: 26 | Show only DSOs with hits. 27 | -i:: 28 | --input=:: 29 | Input file name. (default: perf.data unless stdin is a fifo) 30 | -f:: 31 | --force:: 32 | Don't do ownership validation. 33 | -k:: 34 | --kernel:: 35 | Show running kernel build id. 36 | -v:: 37 | --verbose:: 38 | Be more verbose. 39 | 40 | SEE ALSO 41 | -------- 42 | linkperf:perf-record[1], linkperf:perf-top[1], 43 | linkperf:perf-report[1] 44 | -------------------------------------------------------------------------------- /libperf/Documentation/perf-data.txt: -------------------------------------------------------------------------------- 1 | perf-data(1) 2 | ============== 3 | 4 | NAME 5 | ---- 6 | perf-data - Data file related processing 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'perf data' [] []", 12 | 13 | DESCRIPTION 14 | ----------- 15 | Data file related processing. 16 | 17 | COMMANDS 18 | -------- 19 | convert:: 20 | Converts perf data file into another format (only CTF [1] format is support by now). 21 | It's possible to set data-convert debug variable to get debug messages from conversion, 22 | like: 23 | perf --debug data-convert data convert ... 24 | 25 | OPTIONS for 'convert' 26 | --------------------- 27 | --to-ctf:: 28 | Triggers the CTF conversion, specify the path of CTF data directory. 29 | 30 | -i:: 31 | Specify input perf data file path. 32 | 33 | -v:: 34 | --verbose:: 35 | Be more verbose (show counter open errors, etc). 36 | 37 | --all:: 38 | Convert all events, including non-sample events (comm, fork, ...), to output. 39 | Default is off, only convert samples. 40 | 41 | SEE ALSO 42 | -------- 43 | linkperf:perf[1] 44 | [1] Common Trace Format - http://www.efficios.com/ctf 45 | -------------------------------------------------------------------------------- /libperf/Documentation/perf-evlist.txt: -------------------------------------------------------------------------------- 1 | perf-evlist(1) 2 | ============== 3 | 4 | NAME 5 | ---- 6 | perf-evlist - List the event names in a perf.data file 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'perf evlist ' 12 | 13 | DESCRIPTION 14 | ----------- 15 | This command displays the names of events sampled in a perf.data file. 16 | 17 | OPTIONS 18 | ------- 19 | -i:: 20 | --input=:: 21 | Input file name. (default: perf.data unless stdin is a fifo) 22 | 23 | -F:: 24 | --freq=:: 25 | Show just the sample frequency used for each event. 26 | 27 | -v:: 28 | --verbose=:: 29 | Show all fields. 30 | 31 | -g:: 32 | --group:: 33 | Show event group information. 34 | 35 | --trace-fields:: 36 | Show tracepoint field names. 37 | 38 | SEE ALSO 39 | -------- 40 | linkperf:perf-record[1], linkperf:perf-list[1], 41 | linkperf:perf-report[1] 42 | -------------------------------------------------------------------------------- /libperf/Documentation/perf-help.txt: -------------------------------------------------------------------------------- 1 | perf-help(1) 2 | ============ 3 | 4 | NAME 5 | ---- 6 | perf-help - display help information about perf 7 | 8 | SYNOPSIS 9 | -------- 10 | 'perf help' [-a|--all] [COMMAND] 11 | 12 | DESCRIPTION 13 | ----------- 14 | 15 | With no options and no COMMAND given, the synopsis of the 'perf' 16 | command and a list of the most commonly used perf commands are printed 17 | on the standard output. 18 | 19 | If the option '--all' or '-a' is given, then all available commands are 20 | printed on the standard output. 21 | 22 | If a perf command is named, a manual page for that command is brought 23 | up. The 'man' program is used by default for this purpose, but this 24 | can be overridden by other options or configuration variables. 25 | 26 | Note that `perf --help ...` is identical to `perf help ...` because the 27 | former is internally converted into the latter. 28 | 29 | OPTIONS 30 | ------- 31 | -a:: 32 | --all:: 33 | Prints all the available commands on the standard output. This 34 | option supersedes any other option. 35 | 36 | PERF 37 | ---- 38 | Part of the linkperf:perf[1] suite 39 | -------------------------------------------------------------------------------- /libperf/Documentation/perf-kallsyms.txt: -------------------------------------------------------------------------------- 1 | perf-kallsyms(1) 2 | ============== 3 | 4 | NAME 5 | ---- 6 | perf-kallsyms - Searches running kernel for symbols 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'perf kallsyms symbol_name[,symbol_name...]' 12 | 13 | DESCRIPTION 14 | ----------- 15 | This command searches the running kernel kallsyms file for the given symbol(s) 16 | and prints information about it, including the DSO, the kallsyms begin/end 17 | addresses and the addresses in the ELF kallsyms symbol table (for symbols in 18 | modules). 19 | 20 | OPTIONS 21 | ------- 22 | -v:: 23 | --verbose=:: 24 | Increase verbosity level, showing details about symbol table loading, etc. 25 | -------------------------------------------------------------------------------- /libperf/Documentation/perf-test.txt: -------------------------------------------------------------------------------- 1 | perf-test(1) 2 | ============ 3 | 4 | NAME 5 | ---- 6 | perf-test - Runs sanity tests. 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'perf test [] [{list |[|]}]' 12 | 13 | DESCRIPTION 14 | ----------- 15 | This command does assorted sanity tests, initially through linked routines but 16 | also will look for a directory with more tests in the form of scripts. 17 | 18 | To get a list of available tests use 'perf test list', specifying a test name 19 | fragment will show all tests that have it. 20 | 21 | To run just specific tests, inform test name fragments or the numbers obtained 22 | from 'perf test list'. 23 | 24 | OPTIONS 25 | ------- 26 | -s:: 27 | --skip:: 28 | Tests to skip (comma separated numeric list). 29 | 30 | -v:: 31 | --verbose:: 32 | Be more verbose. 33 | 34 | -F:: 35 | --dont-fork:: 36 | Do not fork child for each test, run all tests within single process. 37 | -------------------------------------------------------------------------------- /libperf/Documentation/perf.txt: -------------------------------------------------------------------------------- 1 | perf(1) 2 | ======= 3 | 4 | NAME 5 | ---- 6 | perf - Performance analysis tools for Linux 7 | 8 | SYNOPSIS 9 | -------- 10 | [verse] 11 | 'perf' [--version] [--help] [OPTIONS] COMMAND [ARGS] 12 | 13 | OPTIONS 14 | ------- 15 | --debug:: 16 | Setup debug variable (see list below) in value 17 | range (0, 10). Use like: 18 | --debug verbose # sets verbose = 1 19 | --debug verbose=2 # sets verbose = 2 20 | 21 | List of debug variables allowed to set: 22 | verbose - general debug messages 23 | ordered-events - ordered events object debug messages 24 | data-convert - data convert command debug messages 25 | 26 | --buildid-dir:: 27 | Setup buildid cache directory. It has higher priority than 28 | buildid.dir config file option. 29 | 30 | -v:: 31 | --version:: 32 | Display perf version. 33 | 34 | -h:: 35 | --help:: 36 | Run perf help command. 37 | 38 | DESCRIPTION 39 | ----------- 40 | Performance counters for Linux are a new kernel-based subsystem 41 | that provide a framework for all things performance analysis. It 42 | covers hardware level (CPU/PMU, Performance Monitoring Unit) features 43 | and software features (software counters, tracepoints) as well. 44 | 45 | SEE ALSO 46 | -------- 47 | linkperf:perf-stat[1], linkperf:perf-top[1], 48 | linkperf:perf-record[1], linkperf:perf-report[1], 49 | linkperf:perf-list[1] 50 | -------------------------------------------------------------------------------- /libperf/Documentation/perfconfig.example: -------------------------------------------------------------------------------- 1 | [colors] 2 | 3 | # These were the old defaults 4 | top = red, lightgray 5 | medium = green, lightgray 6 | normal = black, lightgray 7 | selected = lightgray, magenta 8 | jump_arrows = blue, lightgray 9 | addr = magenta, lightgray 10 | 11 | [tui] 12 | 13 | # Defaults if linked with libslang 14 | report = on 15 | annotate = on 16 | top = on 17 | 18 | [buildid] 19 | 20 | # Default, disable using /dev/null 21 | dir = /root/.debug 22 | 23 | [annotate] 24 | 25 | # Defaults 26 | hide_src_code = false 27 | use_offset = true 28 | jump_arrows = true 29 | show_nr_jumps = false 30 | 31 | [report] 32 | 33 | # Defaults 34 | sort-order = comm,dso,symbol 35 | percent-limit = 0 36 | queue-size = 0 37 | children = true 38 | group = true 39 | -------------------------------------------------------------------------------- /libperf/MANIFEST: -------------------------------------------------------------------------------- 1 | tools/perf 2 | tools/arch 3 | tools/scripts 4 | tools/build 5 | tools/include 6 | tools/lib/traceevent 7 | tools/lib/api 8 | tools/lib/bpf 9 | tools/lib/subcmd 10 | tools/lib/hweight.c 11 | tools/lib/rbtree.c 12 | tools/lib/string.c 13 | tools/lib/symbol/kallsyms.c 14 | tools/lib/symbol/kallsyms.h 15 | tools/lib/find_bit.c 16 | tools/lib/bitmap.c 17 | tools/lib/str_error_r.c 18 | tools/lib/vsprintf.c 19 | -------------------------------------------------------------------------------- /libperf/arch/Build: -------------------------------------------------------------------------------- 1 | libperf-y += common.o 2 | libperf-y += $(SRCARCH)/ 3 | -------------------------------------------------------------------------------- /libperf/arch/alpha/Build: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /libperf/arch/arm/Build: -------------------------------------------------------------------------------- 1 | libperf-y += util/ 2 | libperf-$(CONFIG_DWARF_UNWIND) += tests/ 3 | -------------------------------------------------------------------------------- /libperf/arch/arm/Makefile: -------------------------------------------------------------------------------- 1 | ifndef NO_DWARF 2 | PERF_HAVE_DWARF_REGS := 1 3 | endif 4 | PERF_HAVE_JITDUMP := 1 5 | -------------------------------------------------------------------------------- /libperf/arch/arm/include/dwarf-regs-table.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifdef DEFINE_DWARF_REGSTR_TABLE 3 | /* This is included in perf/util/dwarf-regs.c */ 4 | 5 | static const char * const arm_regstr_tbl[] = { 6 | "%r0", "%r1", "%r2", "%r3", "%r4", 7 | "%r5", "%r6", "%r7", "%r8", "%r9", "%r10", 8 | "%fp", "%ip", "%sp", "%lr", "%pc", 9 | }; 10 | #endif 11 | -------------------------------------------------------------------------------- /libperf/arch/arm/tests/Build: -------------------------------------------------------------------------------- 1 | libperf-y += regs_load.o 2 | libperf-y += dwarf-unwind.o 3 | -------------------------------------------------------------------------------- /libperf/arch/arm/util/Build: -------------------------------------------------------------------------------- 1 | libperf-$(CONFIG_DWARF) += dwarf-regs.o 2 | 3 | libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o 4 | libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o 5 | 6 | libperf-$(CONFIG_AUXTRACE) += pmu.o auxtrace.o cs-etm.o 7 | -------------------------------------------------------------------------------- /libperf/arch/arm/util/cs-etm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(C) 2015 Linaro Limited. All rights reserved. 3 | * Author: Mathieu Poirier 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 as published by 7 | * the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along with 15 | * this program. If not, see . 16 | */ 17 | 18 | #ifndef INCLUDE__PERF_CS_ETM_H__ 19 | #define INCLUDE__PERF_CS_ETM_H__ 20 | 21 | #include "../../util/evsel.h" 22 | 23 | struct auxtrace_record *cs_etm_record_init(int *err); 24 | int cs_etm_set_drv_config(struct perf_evsel_config_term *term); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libperf/arch/arm/util/pmu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(C) 2015 Linaro Limited. All rights reserved. 3 | * Author: Mathieu Poirier 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU General Public License version 2 as published by 7 | * the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope that it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along with 15 | * this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "cs-etm.h" 23 | #include "../../util/pmu.h" 24 | 25 | struct perf_event_attr 26 | *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused) 27 | { 28 | #ifdef HAVE_AUXTRACE_SUPPORT 29 | if (!strcmp(pmu->name, CORESIGHT_ETM_PMU_NAME)) { 30 | /* add ETM default config here */ 31 | pmu->selectable = true; 32 | pmu->set_drv_config = cs_etm_set_drv_config; 33 | } 34 | #endif 35 | return NULL; 36 | } 37 | -------------------------------------------------------------------------------- /libperf/arch/arm/util/unwind-libdw.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include "../../util/unwind-libdw.h" 4 | #include "../../util/perf_regs.h" 5 | #include "../../util/event.h" 6 | 7 | bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) 8 | { 9 | struct unwind_info *ui = arg; 10 | struct regs_dump *user_regs = &ui->sample->user_regs; 11 | Dwarf_Word dwarf_regs[PERF_REG_ARM_MAX]; 12 | 13 | #define REG(r) ({ \ 14 | Dwarf_Word val = 0; \ 15 | perf_reg_value(&val, user_regs, PERF_REG_ARM_##r); \ 16 | val; \ 17 | }) 18 | 19 | dwarf_regs[0] = REG(R0); 20 | dwarf_regs[1] = REG(R1); 21 | dwarf_regs[2] = REG(R2); 22 | dwarf_regs[3] = REG(R3); 23 | dwarf_regs[4] = REG(R4); 24 | dwarf_regs[5] = REG(R5); 25 | dwarf_regs[6] = REG(R6); 26 | dwarf_regs[7] = REG(R7); 27 | dwarf_regs[8] = REG(R8); 28 | dwarf_regs[9] = REG(R9); 29 | dwarf_regs[10] = REG(R10); 30 | dwarf_regs[11] = REG(FP); 31 | dwarf_regs[12] = REG(IP); 32 | dwarf_regs[13] = REG(SP); 33 | dwarf_regs[14] = REG(LR); 34 | dwarf_regs[15] = REG(PC); 35 | 36 | return dwfl_thread_state_registers(thread, 0, PERF_REG_ARM_MAX, 37 | dwarf_regs); 38 | } 39 | -------------------------------------------------------------------------------- /libperf/arch/arm/util/unwind-libunwind.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | 3 | #include 4 | #include 5 | #include "perf_regs.h" 6 | #include "../../util/unwind.h" 7 | #include "../../util/debug.h" 8 | 9 | int libunwind__arch_reg_id(int regnum) 10 | { 11 | switch (regnum) { 12 | case UNW_ARM_R0: 13 | return PERF_REG_ARM_R0; 14 | case UNW_ARM_R1: 15 | return PERF_REG_ARM_R1; 16 | case UNW_ARM_R2: 17 | return PERF_REG_ARM_R2; 18 | case UNW_ARM_R3: 19 | return PERF_REG_ARM_R3; 20 | case UNW_ARM_R4: 21 | return PERF_REG_ARM_R4; 22 | case UNW_ARM_R5: 23 | return PERF_REG_ARM_R5; 24 | case UNW_ARM_R6: 25 | return PERF_REG_ARM_R6; 26 | case UNW_ARM_R7: 27 | return PERF_REG_ARM_R7; 28 | case UNW_ARM_R8: 29 | return PERF_REG_ARM_R8; 30 | case UNW_ARM_R9: 31 | return PERF_REG_ARM_R9; 32 | case UNW_ARM_R10: 33 | return PERF_REG_ARM_R10; 34 | case UNW_ARM_R11: 35 | return PERF_REG_ARM_FP; 36 | case UNW_ARM_R12: 37 | return PERF_REG_ARM_IP; 38 | case UNW_ARM_R13: 39 | return PERF_REG_ARM_SP; 40 | case UNW_ARM_R14: 41 | return PERF_REG_ARM_LR; 42 | case UNW_ARM_R15: 43 | return PERF_REG_ARM_PC; 44 | default: 45 | pr_err("unwind: invalid reg id %d\n", regnum); 46 | return -EINVAL; 47 | } 48 | 49 | return -EINVAL; 50 | } 51 | -------------------------------------------------------------------------------- /libperf/arch/arm64/Build: -------------------------------------------------------------------------------- 1 | libperf-y += util/ 2 | libperf-$(CONFIG_DWARF_UNWIND) += tests/ 3 | -------------------------------------------------------------------------------- /libperf/arch/arm64/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | ifndef NO_DWARF 3 | PERF_HAVE_DWARF_REGS := 1 4 | endif 5 | PERF_HAVE_JITDUMP := 1 6 | PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1 7 | -------------------------------------------------------------------------------- /libperf/arch/arm64/include/dwarf-regs-table.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifdef DEFINE_DWARF_REGSTR_TABLE 3 | /* This is included in perf/util/dwarf-regs.c */ 4 | 5 | static const char * const aarch64_regstr_tbl[] = { 6 | "%x0", "%x1", "%x2", "%x3", "%x4", 7 | "%x5", "%x6", "%x7", "%x8", "%x9", 8 | "%x10", "%x11", "%x12", "%x13", "%x14", 9 | "%x15", "%x16", "%x17", "%x18", "%x19", 10 | "%x20", "%x21", "%x22", "%x23", "%x24", 11 | "%x25", "%x26", "%x27", "%x28", "%x29", 12 | "%lr", "%sp", 13 | }; 14 | #endif 15 | -------------------------------------------------------------------------------- /libperf/arch/arm64/tests/Build: -------------------------------------------------------------------------------- 1 | libperf-y += regs_load.o 2 | libperf-y += dwarf-unwind.o 3 | -------------------------------------------------------------------------------- /libperf/arch/arm64/tests/regs_load.S: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #include 3 | 4 | .text 5 | .type perf_regs_load,%function 6 | #define STR_REG(r) str x##r, [x0, 8 * r] 7 | #define LDR_REG(r) ldr x##r, [x0, 8 * r] 8 | #define SP (8 * 31) 9 | #define PC (8 * 32) 10 | ENTRY(perf_regs_load) 11 | STR_REG(0) 12 | STR_REG(1) 13 | STR_REG(2) 14 | STR_REG(3) 15 | STR_REG(4) 16 | STR_REG(5) 17 | STR_REG(6) 18 | STR_REG(7) 19 | STR_REG(8) 20 | STR_REG(9) 21 | STR_REG(10) 22 | STR_REG(11) 23 | STR_REG(12) 24 | STR_REG(13) 25 | STR_REG(14) 26 | STR_REG(15) 27 | STR_REG(16) 28 | STR_REG(17) 29 | STR_REG(18) 30 | STR_REG(19) 31 | STR_REG(20) 32 | STR_REG(21) 33 | STR_REG(22) 34 | STR_REG(23) 35 | STR_REG(24) 36 | STR_REG(25) 37 | STR_REG(26) 38 | STR_REG(27) 39 | STR_REG(28) 40 | STR_REG(29) 41 | STR_REG(30) 42 | mov x1, sp 43 | str x1, [x0, #SP] 44 | str x30, [x0, #PC] 45 | LDR_REG(1) 46 | ret 47 | ENDPROC(perf_regs_load) 48 | -------------------------------------------------------------------------------- /libperf/arch/arm64/util/Build: -------------------------------------------------------------------------------- 1 | libperf-$(CONFIG_DWARF) += dwarf-regs.o 2 | libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o 3 | 4 | libperf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o \ 5 | ../../arm/util/auxtrace.o \ 6 | ../../arm/util/cs-etm.o 7 | -------------------------------------------------------------------------------- /libperf/arch/common.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef ARCH_PERF_COMMON_H 3 | #define ARCH_PERF_COMMON_H 4 | 5 | #include "../util/env.h" 6 | 7 | extern const char *objdump_path; 8 | 9 | int perf_env__lookup_objdump(struct perf_env *env); 10 | const char *normalize_arch(char *arch); 11 | 12 | #endif /* ARCH_PERF_COMMON_H */ 13 | -------------------------------------------------------------------------------- /libperf/arch/mips/Build: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /libperf/arch/parisc/Build: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /libperf/arch/powerpc/Build: -------------------------------------------------------------------------------- 1 | libperf-y += util/ 2 | libperf-y += tests/ 3 | -------------------------------------------------------------------------------- /libperf/arch/powerpc/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | ifndef NO_DWARF 3 | PERF_HAVE_DWARF_REGS := 1 4 | endif 5 | 6 | HAVE_KVM_STAT_SUPPORT := 1 7 | PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1 8 | PERF_HAVE_JITDUMP := 1 9 | -------------------------------------------------------------------------------- /libperf/arch/powerpc/include/arch-tests.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef ARCH_TESTS_H 3 | #define ARCH_TESTS_H 4 | 5 | #ifdef HAVE_DWARF_UNWIND_SUPPORT 6 | struct thread; 7 | struct perf_sample; 8 | int test__arch_unwind_sample(struct perf_sample *sample, 9 | struct thread *thread); 10 | #endif 11 | 12 | extern struct test arch_tests[]; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /libperf/arch/powerpc/include/dwarf-regs-table.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifdef DEFINE_DWARF_REGSTR_TABLE 3 | /* This is included in perf/util/dwarf-regs.c */ 4 | 5 | /* 6 | * Reference: 7 | * http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html 8 | * http://refspecs.linux-foundation.org/elf/elfspec_ppc.pdf 9 | */ 10 | #define REG_DWARFNUM_NAME(reg, idx) [idx] = "%" #reg 11 | 12 | static const char * const powerpc_regstr_tbl[] = { 13 | "%gpr0", "%gpr1", "%gpr2", "%gpr3", "%gpr4", 14 | "%gpr5", "%gpr6", "%gpr7", "%gpr8", "%gpr9", 15 | "%gpr10", "%gpr11", "%gpr12", "%gpr13", "%gpr14", 16 | "%gpr15", "%gpr16", "%gpr17", "%gpr18", "%gpr19", 17 | "%gpr20", "%gpr21", "%gpr22", "%gpr23", "%gpr24", 18 | "%gpr25", "%gpr26", "%gpr27", "%gpr28", "%gpr29", 19 | "%gpr30", "%gpr31", 20 | REG_DWARFNUM_NAME(msr, 66), 21 | REG_DWARFNUM_NAME(ctr, 109), 22 | REG_DWARFNUM_NAME(link, 108), 23 | REG_DWARFNUM_NAME(xer, 101), 24 | REG_DWARFNUM_NAME(dar, 119), 25 | REG_DWARFNUM_NAME(dsisr, 118), 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libperf/arch/powerpc/tests/Build: -------------------------------------------------------------------------------- 1 | libperf-$(CONFIG_DWARF_UNWIND) += regs_load.o 2 | libperf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o 3 | 4 | libperf-y += arch-tests.o 5 | -------------------------------------------------------------------------------- /libperf/arch/powerpc/tests/arch-tests.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include "tests/tests.h" 4 | #include "arch-tests.h" 5 | 6 | struct test arch_tests[] = { 7 | #ifdef HAVE_DWARF_UNWIND_SUPPORT 8 | { 9 | .desc = "Test dwarf unwind", 10 | .func = test__dwarf_unwind, 11 | }, 12 | #endif 13 | { 14 | .func = NULL, 15 | }, 16 | }; 17 | -------------------------------------------------------------------------------- /libperf/arch/powerpc/util/Build: -------------------------------------------------------------------------------- 1 | libperf-y += header.o 2 | libperf-y += sym-handling.o 3 | libperf-y += kvm-stat.o 4 | libperf-y += perf_regs.o 5 | 6 | libperf-$(CONFIG_DWARF) += dwarf-regs.o 7 | libperf-$(CONFIG_DWARF) += skip-callchain-idx.o 8 | 9 | libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o 10 | libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o 11 | -------------------------------------------------------------------------------- /libperf/arch/powerpc/util/book3s_hv_exits.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef ARCH_PERF_BOOK3S_HV_EXITS_H 3 | #define ARCH_PERF_BOOK3S_HV_EXITS_H 4 | 5 | /* 6 | * PowerPC Interrupt vectors : exit code to name mapping 7 | */ 8 | 9 | #define kvm_trace_symbol_exit \ 10 | {0x0, "RETURN_TO_HOST"}, \ 11 | {0x100, "SYSTEM_RESET"}, \ 12 | {0x200, "MACHINE_CHECK"}, \ 13 | {0x300, "DATA_STORAGE"}, \ 14 | {0x380, "DATA_SEGMENT"}, \ 15 | {0x400, "INST_STORAGE"}, \ 16 | {0x480, "INST_SEGMENT"}, \ 17 | {0x500, "EXTERNAL"}, \ 18 | {0x501, "EXTERNAL_LEVEL"}, \ 19 | {0x502, "EXTERNAL_HV"}, \ 20 | {0x600, "ALIGNMENT"}, \ 21 | {0x700, "PROGRAM"}, \ 22 | {0x800, "FP_UNAVAIL"}, \ 23 | {0x900, "DECREMENTER"}, \ 24 | {0x980, "HV_DECREMENTER"}, \ 25 | {0xc00, "SYSCALL"}, \ 26 | {0xd00, "TRACE"}, \ 27 | {0xe00, "H_DATA_STORAGE"}, \ 28 | {0xe20, "H_INST_STORAGE"}, \ 29 | {0xe40, "H_EMUL_ASSIST"}, \ 30 | {0xf00, "PERFMON"}, \ 31 | {0xf20, "ALTIVEC"}, \ 32 | {0xf40, "VSX"} 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libperf/arch/powerpc/util/header.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "header.h" 9 | #include "util.h" 10 | 11 | #define mfspr(rn) ({unsigned long rval; \ 12 | asm volatile("mfspr %0," __stringify(rn) \ 13 | : "=r" (rval)); rval; }) 14 | 15 | #define SPRN_PVR 0x11F /* Processor Version Register */ 16 | #define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */ 17 | #define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */ 18 | 19 | int 20 | get_cpuid(char *buffer, size_t sz) 21 | { 22 | unsigned long pvr; 23 | int nb; 24 | 25 | pvr = mfspr(SPRN_PVR); 26 | 27 | nb = scnprintf(buffer, sz, "%lu,%lu$", PVR_VER(pvr), PVR_REV(pvr)); 28 | 29 | /* look for end marker to ensure the entire data fit */ 30 | if (strchr(buffer, '$')) { 31 | buffer[nb-1] = '\0'; 32 | return 0; 33 | } 34 | return -1; 35 | } 36 | 37 | char * 38 | get_cpuid_str(void) 39 | { 40 | char *bufp; 41 | 42 | if (asprintf(&bufp, "%.8lx", mfspr(SPRN_PVR)) < 0) 43 | bufp = NULL; 44 | 45 | return bufp; 46 | } 47 | -------------------------------------------------------------------------------- /libperf/arch/s390/Build: -------------------------------------------------------------------------------- 1 | libperf-y += util/ 2 | -------------------------------------------------------------------------------- /libperf/arch/s390/Makefile: -------------------------------------------------------------------------------- 1 | ifndef NO_DWARF 2 | PERF_HAVE_DWARF_REGS := 1 3 | endif 4 | HAVE_KVM_STAT_SUPPORT := 1 5 | PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1 6 | -------------------------------------------------------------------------------- /libperf/arch/s390/annotate/instructions.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | 4 | static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *name) 5 | { 6 | struct ins_ops *ops = NULL; 7 | 8 | /* catch all kind of jumps */ 9 | if (strchr(name, 'j') || 10 | !strncmp(name, "bct", 3) || 11 | !strncmp(name, "br", 2)) 12 | ops = &jump_ops; 13 | /* override call/returns */ 14 | if (!strcmp(name, "bras") || 15 | !strcmp(name, "brasl") || 16 | !strcmp(name, "basr")) 17 | ops = &call_ops; 18 | if (!strcmp(name, "br")) 19 | ops = &ret_ops; 20 | 21 | arch__associate_ins_ops(arch, name, ops); 22 | return ops; 23 | } 24 | 25 | static int s390__annotate_init(struct arch *arch, char *cpuid __maybe_unused) 26 | { 27 | if (!arch->initialized) { 28 | arch->initialized = true; 29 | arch->associate_instruction_ops = s390__associate_ins_ops; 30 | } 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /libperf/arch/s390/util/Build: -------------------------------------------------------------------------------- 1 | libperf-y += header.o 2 | libperf-y += kvm-stat.o 3 | 4 | libperf-$(CONFIG_DWARF) += dwarf-regs.o 5 | libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o 6 | 7 | libperf-y += machine.o 8 | 9 | libperf-$(CONFIG_AUXTRACE) += auxtrace.o 10 | -------------------------------------------------------------------------------- /libperf/arch/s390/util/dwarf-regs.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | /* 3 | * Mapping of DWARF debug register numbers into register names. 4 | * 5 | * Copyright IBM Corp. 2010, 2017 6 | * Author(s): Heiko Carstens , 7 | * Hendrik Brueckner 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "dwarf-regs-table.h" 19 | 20 | const char *get_arch_regstr(unsigned int n) 21 | { 22 | return (n >= ARRAY_SIZE(s390_dwarf_regs)) ? NULL : s390_dwarf_regs[n]; 23 | } 24 | 25 | /* 26 | * Convert the register name into an offset to struct pt_regs (kernel). 27 | * This is required by the BPF prologue generator. The BPF 28 | * program is called in the BPF overflow handler in the perf 29 | * core. 30 | */ 31 | int regs_query_register_offset(const char *name) 32 | { 33 | unsigned long gpr; 34 | 35 | if (!name || strncmp(name, "%r", 2)) 36 | return -EINVAL; 37 | 38 | errno = 0; 39 | gpr = strtoul(name + 2, NULL, 10); 40 | if (errno || gpr >= 16) 41 | return -EINVAL; 42 | 43 | return offsetof(user_pt_regs, gprs) + 8 * gpr; 44 | } 45 | -------------------------------------------------------------------------------- /libperf/arch/s390/util/header.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Implementation of get_cpuid(). 3 | * 4 | * Copyright 2014 IBM Corp. 5 | * Author(s): Alexander Yarygin 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License (version 2 only) 9 | * as published by the Free Software Foundation. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "../../util/header.h" 18 | 19 | int get_cpuid(char *buffer, size_t sz) 20 | { 21 | const char *cpuid = "IBM/S390"; 22 | 23 | if (strlen(cpuid) + 1 > sz) 24 | return -1; 25 | 26 | strcpy(buffer, cpuid); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /libperf/arch/s390/util/machine.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include 4 | #include 5 | #include "util.h" 6 | #include "machine.h" 7 | #include "api/fs/fs.h" 8 | 9 | int arch__fix_module_text_start(u64 *start, const char *name) 10 | { 11 | char path[PATH_MAX]; 12 | 13 | snprintf(path, PATH_MAX, "module/%.*s/sections/.text", 14 | (int)strlen(name) - 2, name + 1); 15 | 16 | if (sysfs__read_ull(path, (unsigned long long *)start) < 0) 17 | return -1; 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /libperf/arch/sh/Build: -------------------------------------------------------------------------------- 1 | libperf-y += util/ 2 | -------------------------------------------------------------------------------- /libperf/arch/sh/Makefile: -------------------------------------------------------------------------------- 1 | ifndef NO_DWARF 2 | PERF_HAVE_DWARF_REGS := 1 3 | endif 4 | -------------------------------------------------------------------------------- /libperf/arch/sh/include/dwarf-regs-table.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifdef DEFINE_DWARF_REGSTR_TABLE 3 | /* This is included in perf/util/dwarf-regs.c */ 4 | 5 | const char * const sh_regstr_tbl[] = { 6 | "r0", 7 | "r1", 8 | "r2", 9 | "r3", 10 | "r4", 11 | "r5", 12 | "r6", 13 | "r7", 14 | "r8", 15 | "r9", 16 | "r10", 17 | "r11", 18 | "r12", 19 | "r13", 20 | "r14", 21 | "r15", 22 | "pc", 23 | "pr", 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libperf/arch/sh/util/Build: -------------------------------------------------------------------------------- 1 | libperf-$(CONFIG_DWARF) += dwarf-regs.o 2 | -------------------------------------------------------------------------------- /libperf/arch/sparc/Build: -------------------------------------------------------------------------------- 1 | libperf-y += util/ 2 | -------------------------------------------------------------------------------- /libperf/arch/sparc/Makefile: -------------------------------------------------------------------------------- 1 | ifndef NO_DWARF 2 | PERF_HAVE_DWARF_REGS := 1 3 | endif 4 | -------------------------------------------------------------------------------- /libperf/arch/sparc/include/dwarf-regs-table.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifdef DEFINE_DWARF_REGSTR_TABLE 3 | /* This is included in perf/util/dwarf-regs.c */ 4 | 5 | static const char * const sparc_regstr_tbl[] = { 6 | "%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7", 7 | "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7", 8 | "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", 9 | "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%fp", "%i7", 10 | "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7", 11 | "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15", 12 | "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23", 13 | "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31", 14 | "%f32", "%f33", "%f34", "%f35", "%f36", "%f37", "%f38", "%f39", 15 | "%f40", "%f41", "%f42", "%f43", "%f44", "%f45", "%f46", "%f47", 16 | "%f48", "%f49", "%f50", "%f51", "%f52", "%f53", "%f54", "%f55", 17 | "%f56", "%f57", "%f58", "%f59", "%f60", "%f61", "%f62", "%f63", 18 | }; 19 | #endif 20 | -------------------------------------------------------------------------------- /libperf/arch/sparc/util/Build: -------------------------------------------------------------------------------- 1 | libperf-$(CONFIG_DWARF) += dwarf-regs.o 2 | -------------------------------------------------------------------------------- /libperf/arch/x86/Build: -------------------------------------------------------------------------------- 1 | libperf-y += util/ 2 | libperf-y += tests/ 3 | -------------------------------------------------------------------------------- /libperf/arch/x86/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | ifndef NO_DWARF 3 | PERF_HAVE_DWARF_REGS := 1 4 | endif 5 | HAVE_KVM_STAT_SUPPORT := 1 6 | PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1 7 | PERF_HAVE_JITDUMP := 1 8 | 9 | ### 10 | # Syscall table generation 11 | # 12 | 13 | out := $(OUTPUT)arch/x86/include/generated/asm 14 | header := $(out)/syscalls_64.c 15 | sys := $(srctree)/tools/perf/arch/x86/entry/syscalls 16 | systbl := $(sys)/syscalltbl.sh 17 | 18 | # Create output directory if not already present 19 | _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)') 20 | 21 | $(header): $(sys)/syscall_64.tbl $(systbl) 22 | @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \ 23 | (diff -B arch/x86/entry/syscalls/syscall_64.tbl ../../arch/x86/entry/syscalls/syscall_64.tbl >/dev/null) \ 24 | || echo "Warning: Kernel ABI header at 'tools/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl'" >&2 )) || true 25 | $(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@ 26 | 27 | clean:: 28 | $(call QUIET_CLEAN, x86) $(RM) $(header) 29 | 30 | archheaders: $(header) 31 | -------------------------------------------------------------------------------- /libperf/arch/x86/entry/syscalls/syscalltbl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # SPDX-License-Identifier: GPL-2.0 3 | 4 | in="$1" 5 | arch="$2" 6 | 7 | syscall_macro() { 8 | nr="$1" 9 | name="$2" 10 | 11 | echo " [$nr] = \"$name\"," 12 | } 13 | 14 | emit() { 15 | nr="$1" 16 | entry="$2" 17 | 18 | syscall_macro "$nr" "$entry" 19 | } 20 | 21 | echo "static const char *syscalltbl_${arch}[] = {" 22 | 23 | sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX) 24 | grep '^[0-9]' "$in" | sort -n > $sorted_table 25 | 26 | max_nr=0 27 | while read nr abi name entry compat; do 28 | if [ $nr -ge 512 ] ; then # discard compat sycalls 29 | break 30 | fi 31 | 32 | emit "$nr" "$name" 33 | max_nr=$nr 34 | done < $sorted_table 35 | 36 | rm -f $sorted_table 37 | 38 | echo "};" 39 | 40 | echo "#define SYSCALLTBL_${arch}_MAX_ID ${max_nr}" 41 | -------------------------------------------------------------------------------- /libperf/arch/x86/include/arch-tests.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef ARCH_TESTS_H 3 | #define ARCH_TESTS_H 4 | 5 | #include 6 | struct test; 7 | 8 | /* Tests */ 9 | int test__rdpmc(struct test *test __maybe_unused, int subtest); 10 | int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest); 11 | int test__insn_x86(struct test *test __maybe_unused, int subtest); 12 | 13 | #ifdef HAVE_DWARF_UNWIND_SUPPORT 14 | struct thread; 15 | struct perf_sample; 16 | int test__arch_unwind_sample(struct perf_sample *sample, 17 | struct thread *thread); 18 | #endif 19 | 20 | extern struct test arch_tests[]; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /libperf/arch/x86/include/dwarf-regs-table.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifdef DEFINE_DWARF_REGSTR_TABLE 3 | /* This is included in perf/util/dwarf-regs.c */ 4 | 5 | static const char * const x86_32_regstr_tbl[] = { 6 | "%ax", "%cx", "%dx", "%bx", "$stack",/* Stack address instead of %sp */ 7 | "%bp", "%si", "%di", 8 | }; 9 | 10 | static const char * const x86_64_regstr_tbl[] = { 11 | "%ax", "%dx", "%cx", "%bx", "%si", "%di", 12 | "%bp", "%sp", "%r8", "%r9", "%r10", "%r11", 13 | "%r12", "%r13", "%r14", "%r15", 14 | }; 15 | #endif 16 | -------------------------------------------------------------------------------- /libperf/arch/x86/tests/Build: -------------------------------------------------------------------------------- 1 | libperf-$(CONFIG_DWARF_UNWIND) += regs_load.o 2 | libperf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o 3 | 4 | libperf-y += arch-tests.o 5 | libperf-y += rdpmc.o 6 | libperf-y += perf-time-to-tsc.o 7 | libperf-$(CONFIG_AUXTRACE) += insn-x86.o 8 | -------------------------------------------------------------------------------- /libperf/arch/x86/tests/arch-tests.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include "tests/tests.h" 4 | #include "arch-tests.h" 5 | 6 | struct test arch_tests[] = { 7 | { 8 | .desc = "x86 rdpmc", 9 | .func = test__rdpmc, 10 | }, 11 | { 12 | .desc = "Convert perf time to TSC", 13 | .func = test__perf_time_to_tsc, 14 | }, 15 | #ifdef HAVE_DWARF_UNWIND_SUPPORT 16 | { 17 | .desc = "DWARF unwind", 18 | .func = test__dwarf_unwind, 19 | }, 20 | #endif 21 | #ifdef HAVE_AUXTRACE_SUPPORT 22 | { 23 | .desc = "x86 instruction decoder - new instructions", 24 | .func = test__insn_x86, 25 | }, 26 | #endif 27 | { 28 | .func = NULL, 29 | }, 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /libperf/arch/x86/tests/gen-insn-x86-dat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # gen-insn-x86-dat: generate data for the insn-x86 test 3 | # Copyright (c) 2015, Intel Corporation. 4 | # 5 | # This program is free software; you can redistribute it and/or modify it 6 | # under the terms and conditions of the GNU General Public License, 7 | # version 2, as published by the Free Software Foundation. 8 | # 9 | # This program is distributed in the hope it will be useful, but WITHOUT 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | # more details. 13 | 14 | set -e 15 | 16 | if [ "$(uname -m)" != "x86_64" ]; then 17 | echo "ERROR: This script only works on x86_64" 18 | exit 1 19 | fi 20 | 21 | cd $(dirname $0) 22 | 23 | trap 'echo "Might need a more recent version of binutils"' EXIT 24 | 25 | echo "Compiling insn-x86-dat-src.c to 64-bit object" 26 | 27 | gcc -g -c insn-x86-dat-src.c 28 | 29 | objdump -dSw insn-x86-dat-src.o | awk -f gen-insn-x86-dat.awk > insn-x86-dat-64.c 30 | 31 | rm -f insn-x86-dat-src.o 32 | 33 | echo "Compiling insn-x86-dat-src.c to 32-bit object" 34 | 35 | gcc -g -c -m32 insn-x86-dat-src.c 36 | 37 | objdump -dSw insn-x86-dat-src.o | awk -f gen-insn-x86-dat.awk > insn-x86-dat-32.c 38 | 39 | rm -f insn-x86-dat-src.o 40 | 41 | trap - EXIT 42 | 43 | echo "Done (use git diff to see the changes)" 44 | -------------------------------------------------------------------------------- /libperf/arch/x86/util/Build: -------------------------------------------------------------------------------- 1 | libperf-y += header.o 2 | libperf-y += tsc.o 3 | libperf-y += pmu.o 4 | libperf-y += kvm-stat.o 5 | libperf-y += perf_regs.o 6 | libperf-y += group.o 7 | 8 | libperf-$(CONFIG_DWARF) += dwarf-regs.o 9 | libperf-$(CONFIG_BPF_PROLOGUE) += dwarf-regs.o 10 | 11 | libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o 12 | libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o 13 | 14 | libperf-$(CONFIG_AUXTRACE) += auxtrace.o 15 | libperf-$(CONFIG_AUXTRACE) += intel-pt.o 16 | libperf-$(CONFIG_AUXTRACE) += intel-bts.o 17 | -------------------------------------------------------------------------------- /libperf/arch/x86/util/group.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include "api/fs/fs.h" 4 | #include "util/group.h" 5 | 6 | /* 7 | * Check whether we can use a group for top down. 8 | * Without a group may get bad results due to multiplexing. 9 | */ 10 | bool arch_topdown_check_group(bool *warn) 11 | { 12 | int n; 13 | 14 | if (sysctl__read_int("kernel/nmi_watchdog", &n) < 0) 15 | return false; 16 | if (n > 0) { 17 | *warn = true; 18 | return false; 19 | } 20 | return true; 21 | } 22 | 23 | void arch_topdown_group_warn(void) 24 | { 25 | fprintf(stderr, 26 | "nmi_watchdog enabled with topdown. May give wrong results.\n" 27 | "Disable with echo 0 > /proc/sys/kernel/nmi_watchdog\n"); 28 | } 29 | -------------------------------------------------------------------------------- /libperf/arch/x86/util/pmu.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | 4 | #include 5 | 6 | #include "../../util/intel-pt.h" 7 | #include "../../util/intel-bts.h" 8 | #include "../../util/pmu.h" 9 | 10 | struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused) 11 | { 12 | #ifdef HAVE_AUXTRACE_SUPPORT 13 | if (!strcmp(pmu->name, INTEL_PT_PMU_NAME)) 14 | return intel_pt_pmu_default_config(pmu); 15 | if (!strcmp(pmu->name, INTEL_BTS_PMU_NAME)) 16 | pmu->selectable = true; 17 | #endif 18 | return NULL; 19 | } 20 | -------------------------------------------------------------------------------- /libperf/arch/xtensa/Build: -------------------------------------------------------------------------------- 1 | libperf-y += util/ 2 | -------------------------------------------------------------------------------- /libperf/arch/xtensa/Makefile: -------------------------------------------------------------------------------- 1 | ifndef NO_DWARF 2 | PERF_HAVE_DWARF_REGS := 1 3 | endif 4 | -------------------------------------------------------------------------------- /libperf/arch/xtensa/include/dwarf-regs-table.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifdef DEFINE_DWARF_REGSTR_TABLE 3 | /* This is included in perf/util/dwarf-regs.c */ 4 | 5 | static const char * const xtensa_regstr_tbl[] = { 6 | "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", 7 | "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", 8 | }; 9 | #endif 10 | -------------------------------------------------------------------------------- /libperf/arch/xtensa/util/Build: -------------------------------------------------------------------------------- 1 | libperf-$(CONFIG_DWARF) += dwarf-regs.o 2 | -------------------------------------------------------------------------------- /libperf/arch/xtensa/util/dwarf-regs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Mapping of DWARF debug register numbers into register names. 3 | * 4 | * Copyright (c) 2015 Cadence Design Systems Inc. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 9 | * 2 of the License, or (at your option) any later version. 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | #define XTENSA_MAX_REGS 16 16 | 17 | const char *xtensa_regs_table[XTENSA_MAX_REGS] = { 18 | "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", 19 | "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", 20 | }; 21 | 22 | const char *get_arch_regstr(unsigned int n) 23 | { 24 | return n < XTENSA_MAX_REGS ? xtensa_regs_table[n] : NULL; 25 | } 26 | -------------------------------------------------------------------------------- /libperf/bench/Build: -------------------------------------------------------------------------------- 1 | #perf-y += sched-messaging.o 2 | #perf-y += sched-pipe.o 3 | #perf-y += mem-functions.o 4 | #perf-y += futex-hash.o 5 | #perf-y += futex-wake.o 6 | #perf-y += futex-wake-parallel.o 7 | #perf-y += futex-requeue.o 8 | #perf-y += futex-lock-pi.o 9 | 10 | perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o 11 | perf-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o 12 | 13 | perf-$(CONFIG_NUMA) += numa.o 14 | -------------------------------------------------------------------------------- /libperf/bench/mem-memcpy-arch.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | #ifdef HAVE_ARCH_X86_64_SUPPORT 4 | 5 | #define MEMCPY_FN(fn, name, desc) \ 6 | void *fn(void *, const void *, size_t); 7 | 8 | #include "mem-memcpy-x86-64-asm-def.h" 9 | 10 | #undef MEMCPY_FN 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /libperf/bench/mem-memcpy-x86-64-asm-def.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | MEMCPY_FN(memcpy_orig, 4 | "x86-64-unrolled", 5 | "unrolled memcpy() in arch/x86/lib/memcpy_64.S") 6 | 7 | MEMCPY_FN(__memcpy, 8 | "x86-64-movsq", 9 | "movsq-based memcpy() in arch/x86/lib/memcpy_64.S") 10 | 11 | MEMCPY_FN(memcpy_erms, 12 | "x86-64-movsb", 13 | "movsb-based memcpy() in arch/x86/lib/memcpy_64.S") 14 | -------------------------------------------------------------------------------- /libperf/bench/mem-memcpy-x86-64-asm.S: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | /* Various wrappers to make the kernel .S file build in user-space: */ 4 | 5 | #define memcpy MEMCPY /* don't hide glibc's memcpy() */ 6 | #define altinstr_replacement text 7 | #define globl p2align 4; .globl 8 | #define _ASM_EXTABLE_FAULT(x, y) 9 | 10 | #include "../../arch/x86/lib/memcpy_64.S" 11 | /* 12 | * We need to provide note.GNU-stack section, saying that we want 13 | * NOT executable stack. Otherwise the final linking will assume that 14 | * the ELF stack should not be restricted at all and set it RWX. 15 | */ 16 | .section .note.GNU-stack,"",@progbits 17 | -------------------------------------------------------------------------------- /libperf/bench/mem-memset-arch.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | #ifdef HAVE_ARCH_X86_64_SUPPORT 4 | 5 | #define MEMSET_FN(fn, name, desc) \ 6 | void *fn(void *, int, size_t); 7 | 8 | #include "mem-memset-x86-64-asm-def.h" 9 | 10 | #undef MEMSET_FN 11 | 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /libperf/bench/mem-memset-x86-64-asm-def.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | MEMSET_FN(memset_orig, 4 | "x86-64-unrolled", 5 | "unrolled memset() in arch/x86/lib/memset_64.S") 6 | 7 | MEMSET_FN(__memset, 8 | "x86-64-stosq", 9 | "movsq-based memset() in arch/x86/lib/memset_64.S") 10 | 11 | MEMSET_FN(memset_erms, 12 | "x86-64-stosb", 13 | "movsb-based memset() in arch/x86/lib/memset_64.S") 14 | -------------------------------------------------------------------------------- /libperf/bench/mem-memset-x86-64-asm.S: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #define memset MEMSET /* don't hide glibc's memset() */ 3 | #define altinstr_replacement text 4 | #define globl p2align 4; .globl 5 | #include "../../arch/x86/lib/memset_64.S" 6 | 7 | /* 8 | * We need to provide note.GNU-stack section, saying that we want 9 | * NOT executable stack. Otherwise the final linking will assume that 10 | * the ELF stack should not be restricted at all and set it RWX. 11 | */ 12 | .section .note.GNU-stack,"",@progbits 13 | -------------------------------------------------------------------------------- /libperf/builtin-version.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include "builtin.h" 3 | #include "perf.h" 4 | #include 5 | #include 6 | 7 | int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused) 8 | { 9 | printf("perf version %s\n", perf_version_string); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /libperf/command-list.txt: -------------------------------------------------------------------------------- 1 | # 2 | # List of known perf commands. 3 | # command name category [deprecated] [common] 4 | # 5 | perf-annotate mainporcelain common 6 | perf-archive mainporcelain common 7 | perf-bench mainporcelain common 8 | perf-buildid-cache mainporcelain common 9 | perf-buildid-list mainporcelain common 10 | perf-data mainporcelain common 11 | perf-diff mainporcelain common 12 | perf-c2c mainporcelain common 13 | perf-config mainporcelain common 14 | perf-evlist mainporcelain common 15 | perf-ftrace mainporcelain common 16 | perf-inject mainporcelain common 17 | perf-kallsyms mainporcelain common 18 | perf-kmem mainporcelain common 19 | perf-kvm mainporcelain common 20 | perf-list mainporcelain common 21 | perf-lock mainporcelain common 22 | perf-mem mainporcelain common 23 | perf-probe mainporcelain full 24 | perf-record mainporcelain common 25 | perf-report mainporcelain common 26 | perf-sched mainporcelain common 27 | perf-script mainporcelain common 28 | perf-stat mainporcelain common 29 | perf-test mainporcelain common 30 | perf-timechart mainporcelain common 31 | perf-top mainporcelain common 32 | perf-trace mainporcelain audit 33 | -------------------------------------------------------------------------------- /libperf/jit-methods.cpp: -------------------------------------------------------------------------------- 1 | #include "jit-methods.hpp" 2 | 3 | int foo() { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /libperf/jit-methods.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(__JIT_METHODS_H__) 2 | #define __JIT_METHODS_H__ 3 | 4 | #if defined(__cplusplus) 5 | #define __API__ extern "C" 6 | #else 7 | #define __API__ 8 | #endif 9 | 10 | 11 | #endif __JIT_METHODS_H__ 12 | -------------------------------------------------------------------------------- /libperf/jni-wrapper.cpp: -------------------------------------------------------------------------------- 1 | #include "profiler.hpp" 2 | #include "ru_raiffeisen_PerfPtProf.h" 3 | 4 | /* 5 | * Class: ru_raiffeisen_PerfPtProf 6 | * Method: init 7 | * Signature: (I)V 8 | */ 9 | JNIEXPORT void JNICALL Java_ru_raiffeisen_PerfPtProf_init 10 | (JNIEnv *, jclass, jint countdown) { 11 | init(countdown); 12 | } 13 | 14 | /* 15 | * Class: ru_raiffeisen_PerfPtProf 16 | * Method: start 17 | * Signature: ()V 18 | */ 19 | JNIEXPORT void JNICALL Java_ru_raiffeisen_PerfPtProf_start 20 | (JNIEnv *, jclass) { 21 | start(); 22 | } 23 | 24 | /* 25 | * Class: ru_raiffeisen_PerfPtProf 26 | * Method: stop 27 | * Signature: ()V 28 | */ 29 | JNIEXPORT void JNICALL Java_ru_raiffeisen_PerfPtProf_stop 30 | (JNIEnv *, jclass) { 31 | stop(); 32 | } 33 | -------------------------------------------------------------------------------- /libperf/jni-wrapper.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RainM/rperf/d0b58ede8ce2fbc60ad35f0cea6ad33be1e486fd/libperf/jni-wrapper.hpp -------------------------------------------------------------------------------- /libperf/jvmti/Build: -------------------------------------------------------------------------------- 1 | jvmti-y += libjvmti.o 2 | jvmti-y += jvmti_agent.o 3 | 4 | CFLAGS_jvmti = -fPIC -DPIC -I$(JDIR)/include -I$(JDIR)/include/linux 5 | CFLAGS_REMOVE_jvmti = -Wmissing-declarations 6 | CFLAGS_REMOVE_jvmti += -Wstrict-prototypes 7 | CFLAGS_REMOVE_jvmti += -Wextra 8 | CFLAGS_REMOVE_jvmti += -Wwrite-strings 9 | -------------------------------------------------------------------------------- /libperf/jvmti/jvmti_agent.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __JVMTI_AGENT_H__ 3 | #define __JVMTI_AGENT_H__ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #if defined(__cplusplus) 10 | extern "C" { 11 | #endif 12 | 13 | typedef struct { 14 | unsigned long pc; 15 | int line_number; 16 | int discrim; /* discriminator -- 0 for now */ 17 | jmethodID methodID; 18 | } jvmti_line_info_t; 19 | 20 | void *jvmti_open(void); 21 | int jvmti_close(void *agent); 22 | int jvmti_write_code(void *agent, char const *symbol_name, 23 | uint64_t vma, void const *code, 24 | const unsigned int code_size); 25 | 26 | int jvmti_write_debug_info(void *agent, uint64_t code, int nr_lines, 27 | jvmti_line_info_t *li, 28 | const char * const * file_names); 29 | 30 | #if defined(__cplusplus) 31 | } 32 | 33 | #endif 34 | #endif /* __JVMTI_H__ */ 35 | -------------------------------------------------------------------------------- /libperf/perf-map-file.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(__PERF_MAP_AGENT_H__) 2 | #define __PERF_MAP_AGENT_H__ 3 | 4 | #include 5 | 6 | #if defined(__cplusplus) 7 | #define __API__ extern "C" 8 | #else 9 | #define __API__ 10 | #endif 11 | 12 | __API__ FILE *perf_map_open(void); 13 | __API__ int perf_map_close(FILE *fp); 14 | __API__ void perf_map_write_entry(FILE *method_file, const void* code_addr, unsigned int code_size, const char* entry); 15 | 16 | #endif // !defined(__PERF_MAP_AGENT_H__) 17 | -------------------------------------------------------------------------------- /libperf/perf-read-vdso.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include 4 | 5 | #define VDSO__MAP_NAME "[vdso]" 6 | 7 | /* 8 | * Include definition of find_vdso_map() also used in util/vdso.c for 9 | * building perf. 10 | */ 11 | #include "util/find-vdso-map.c" 12 | 13 | int main(void) 14 | { 15 | void *start, *end; 16 | size_t size, written; 17 | 18 | if (find_vdso_map(&start, &end)) 19 | return 1; 20 | 21 | size = end - start; 22 | 23 | while (size) { 24 | written = fwrite(start, 1, size, stdout); 25 | if (!written) 26 | return 1; 27 | start += written; 28 | size -= written; 29 | } 30 | 31 | if (fflush(stdout)) 32 | return 1; 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /libperf/perf-script.py: -------------------------------------------------------------------------------- 1 | # perf script event handlers, generated by perf script -g python 2 | # Licensed under the terms of the GNU GPL License version 2 3 | 4 | # The common_* event handler fields are the most useful fields common to 5 | # all events. They don't necessarily correspond to the 'common_*' fields 6 | # in the format files. Those fields not available as handler params can 7 | # be retrieved using Python functions of the form common_*(context). 8 | # See the perf-trace-python Documentation for the list of available functions. 9 | 10 | import os 11 | import sys 12 | 13 | sys.path.append(os.environ['PERF_EXEC_PATH'] + \ 14 | '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') 15 | 16 | from perf_trace_context import * 17 | from Core import * 18 | 19 | 20 | def trace_begin(): 21 | print "in trace_begin" 22 | 23 | def trace_end(): 24 | print "in trace_end" 25 | 26 | def trace_unhandled(event_name, context, event_fields_dict): 27 | print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]) 28 | 29 | def print_header(event_name, cpu, secs, nsecs, pid, comm): 30 | print "%-20s %5u %05u.%09u %8u %-20s " % \ 31 | (event_name, cpu, secs, nsecs, pid, comm), 32 | -------------------------------------------------------------------------------- /libperf/pmu-events/Build: -------------------------------------------------------------------------------- 1 | hostprogs := jevents 2 | 3 | jevents-y += json.o jsmn.o jevents.o 4 | pmu-events-y += pmu-events.o 5 | JDIR = pmu-events/arch/$(SRCARCH) 6 | JSON = $(shell [ -d $(JDIR) ] && \ 7 | find $(JDIR) -name '*.json' -o -name 'mapfile.csv') 8 | # 9 | # Locate/process JSON files in pmu-events/arch/ 10 | # directory and create tables in pmu-events.c. 11 | # 12 | $(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JEVENTS) 13 | $(Q)$(call echo-cmd,gen)$(JEVENTS) $(SRCARCH) pmu-events/arch $(OUTPUT)pmu-events/pmu-events.c $(V) 14 | -------------------------------------------------------------------------------- /libperf/pmu-events/arch/powerpc/mapfile.csv: -------------------------------------------------------------------------------- 1 | # Format: 2 | # PVR,Version,JSON/file/pathname,Type 3 | # 4 | # where 5 | # PVR Processor version 6 | # Version could be used to track version of of JSON file 7 | # but currently unused. 8 | # JSON/file/pathname is the path to JSON file, relative 9 | # to tools/perf/pmu-events/arch/powerpc/. 10 | # Type is core, uncore etc 11 | # 12 | # Multiple PVRs could map to a single JSON file. 13 | # 14 | 15 | # Power8 entries 16 | 004b0000,1,power8,core 17 | 004b0201,1,power8,core 18 | 004c0000,1,power8,core 19 | 004d0000,1,power8,core 20 | 004d0100,1,power8,core 21 | 004d0200,1,power8,core 22 | 004c0100,1,power8,core 23 | 004e0100,1,power9,core 24 | 004e0200,1,power9,core 25 | 004e1200,1,power9,core 26 | -------------------------------------------------------------------------------- /libperf/pmu-events/arch/powerpc/power8/floating-point.json: -------------------------------------------------------------------------------- 1 | [ 2 | {, 3 | "EventCode": "0x2000e", 4 | "EventName": "PM_FXU_BUSY", 5 | "BriefDescription": "fxu0 busy and fxu1 busy", 6 | "PublicDescription": "" 7 | }, 8 | {, 9 | "EventCode": "0x1000e", 10 | "EventName": "PM_FXU_IDLE", 11 | "BriefDescription": "fxu0 idle and fxu1 idle", 12 | "PublicDescription": "" 13 | }, 14 | ] 15 | -------------------------------------------------------------------------------- /libperf/pmu-events/arch/powerpc/power9/floating-point.json: -------------------------------------------------------------------------------- 1 | [ 2 | {, 3 | "EventCode": "0x1415A", 4 | "EventName": "PM_MRK_DATA_FROM_L2_DISP_CONFLICT_LDHITST_CYC", 5 | "BriefDescription": "Duration in cycles to reload from local core's L2 with load hit store conflict due to a marked load" 6 | }, 7 | {, 8 | "EventCode": "0x10058", 9 | "EventName": "PM_MEM_LOC_THRESH_IFU", 10 | "BriefDescription": "Local Memory above threshold for IFU speculation control" 11 | }, 12 | {, 13 | "EventCode": "0x2D028", 14 | "EventName": "PM_RADIX_PWC_L2_PDE_FROM_L2", 15 | "BriefDescription": "A Page Directory Entry was reloaded to a level 2 page walk cache from the core's L2 data cache" 16 | }, 17 | {, 18 | "EventCode": "0x30012", 19 | "EventName": "PM_FLUSH_COMPLETION", 20 | "BriefDescription": "The instruction that was next to complete did not complete because it suffered a flush" 21 | }, 22 | {, 23 | "EventCode": "0x2D154", 24 | "EventName": "PM_MRK_DERAT_MISS_64K", 25 | "BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 64K" 26 | }, 27 | {, 28 | "EventCode": "0x4016E", 29 | "EventName": "PM_THRESH_NOT_MET", 30 | "BriefDescription": "Threshold counter did not meet threshold" 31 | } 32 | ] -------------------------------------------------------------------------------- /libperf/pmu-events/arch/x86/broadwellx/uncore-interconnect.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "BriefDescription": "QPI clock ticks", 4 | "Counter": "0,1,2,3", 5 | "EventCode": "0x14", 6 | "EventName": "UNC_Q_CLOCKTICKS", 7 | "PerPkg": "1", 8 | "Unit": "QPI LL" 9 | }, 10 | { 11 | "BriefDescription": "Number of data flits transmitted . Derived from unc_q_txl_flits_g0.data", 12 | "Counter": "0,1,2,3", 13 | "EventName": "QPI_DATA_BANDWIDTH_TX", 14 | "PerPkg": "1", 15 | "ScaleUnit": "8Bytes", 16 | "UMask": "0x2", 17 | "Unit": "QPI LL" 18 | }, 19 | { 20 | "BriefDescription": "Number of non data (control) flits transmitted . Derived from unc_q_txl_flits_g0.non_data", 21 | "Counter": "0,1,2,3", 22 | "EventName": "QPI_CTL_BANDWIDTH_TX", 23 | "PerPkg": "1", 24 | "ScaleUnit": "8Bytes", 25 | "UMask": "0x4", 26 | "Unit": "QPI LL" 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /libperf/pmu-events/arch/x86/haswellx/uncore-interconnect.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "BriefDescription": "QPI clock ticks", 4 | "Counter": "0,1,2,3", 5 | "EventCode": "0x14", 6 | "EventName": "UNC_Q_CLOCKTICKS", 7 | "PerPkg": "1", 8 | "Unit": "QPI LL" 9 | }, 10 | { 11 | "BriefDescription": "Number of data flits transmitted . Derived from unc_q_txl_flits_g0.data", 12 | "Counter": "0,1,2,3", 13 | "EventName": "QPI_DATA_BANDWIDTH_TX", 14 | "PerPkg": "1", 15 | "ScaleUnit": "8Bytes", 16 | "UMask": "0x2", 17 | "Unit": "QPI LL" 18 | }, 19 | { 20 | "BriefDescription": "Number of non data (control) flits transmitted . Derived from unc_q_txl_flits_g0.non_data", 21 | "Counter": "0,1,2,3", 22 | "EventName": "QPI_CTL_BANDWIDTH_TX", 23 | "PerPkg": "1", 24 | "ScaleUnit": "8Bytes", 25 | "UMask": "0x4", 26 | "Unit": "QPI LL" 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /libperf/pmu-events/arch/x86/knightslanding/frontend.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "EventCode": "0x80", 4 | "Counter": "0,1", 5 | "UMask": "0x3", 6 | "EventName": "ICACHE.ACCESSES", 7 | "SampleAfterValue": "200003", 8 | "BriefDescription": "Counts all instruction fetches, including uncacheable fetches." 9 | }, 10 | { 11 | "EventCode": "0x80", 12 | "Counter": "0,1", 13 | "UMask": "0x1", 14 | "EventName": "ICACHE.HIT", 15 | "SampleAfterValue": "200003", 16 | "BriefDescription": "Counts all instruction fetches that hit the instruction cache." 17 | }, 18 | { 19 | "EventCode": "0x80", 20 | "Counter": "0,1", 21 | "UMask": "0x2", 22 | "EventName": "ICACHE.MISSES", 23 | "SampleAfterValue": "200003", 24 | "BriefDescription": "Counts all instruction fetches that miss the instruction cache or produce memory requests. An instruction fetch miss is counted only once and not once for every cycle it is outstanding." 25 | }, 26 | { 27 | "EventCode": "0xE7", 28 | "Counter": "0,1", 29 | "UMask": "0x1", 30 | "EventName": "MS_DECODED.MS_ENTRY", 31 | "SampleAfterValue": "200003", 32 | "BriefDescription": "Counts the number of times the MSROM starts a flow of uops." 33 | } 34 | ] -------------------------------------------------------------------------------- /libperf/pmu-events/arch/x86/knightslanding/uncore-memory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "BriefDescription": "ddr bandwidth read (CPU traffic only) (MB/sec). ", 4 | "Counter": "0,1,2,3", 5 | "EventCode": "0x03", 6 | "EventName": "UNC_M_CAS_COUNT.RD", 7 | "PerPkg": "1", 8 | "ScaleUnit": "6.4e-05MiB", 9 | "UMask": "0x01", 10 | "Unit": "imc" 11 | }, 12 | { 13 | "BriefDescription": "ddr bandwidth write (CPU traffic only) (MB/sec). ", 14 | "Counter": "0,1,2,3", 15 | "EventCode": "0x03", 16 | "EventName": "UNC_M_CAS_COUNT.WR", 17 | "PerPkg": "1", 18 | "ScaleUnit": "6.4e-05MiB", 19 | "UMask": "0x02", 20 | "Unit": "imc" 21 | }, 22 | { 23 | "BriefDescription": "mcdram bandwidth read (CPU traffic only) (MB/sec). ", 24 | "Counter": "0,1,2,3", 25 | "EventCode": "0x01", 26 | "EventName": "UNC_E_RPQ_INSERTS", 27 | "PerPkg": "1", 28 | "ScaleUnit": "6.4e-05MiB", 29 | "UMask": "0x01", 30 | "Unit": "edc_eclk" 31 | }, 32 | { 33 | "BriefDescription": "mcdram bandwidth write (CPU traffic only) (MB/sec). ", 34 | "Counter": "0,1,2,3", 35 | "EventCode": "0x02", 36 | "EventName": "UNC_E_WPQ_INSERTS", 37 | "PerPkg": "1", 38 | "ScaleUnit": "6.4e-05MiB", 39 | "UMask": "0x01", 40 | "Unit": "edc_eclk" 41 | } 42 | ] 43 | -------------------------------------------------------------------------------- /libperf/pmu-events/arch/x86/nehalemep/frontend.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "EventCode": "0xD0", 4 | "Counter": "0,1,2,3", 5 | "UMask": "0x1", 6 | "EventName": "MACRO_INSTS.DECODED", 7 | "SampleAfterValue": "2000000", 8 | "BriefDescription": "Instructions decoded" 9 | }, 10 | { 11 | "EventCode": "0xA6", 12 | "Counter": "0,1,2,3", 13 | "UMask": "0x1", 14 | "EventName": "MACRO_INSTS.FUSIONS_DECODED", 15 | "SampleAfterValue": "2000000", 16 | "BriefDescription": "Macro-fused instructions decoded" 17 | }, 18 | { 19 | "EventCode": "0x19", 20 | "Counter": "0,1,2,3", 21 | "UMask": "0x1", 22 | "EventName": "TWO_UOP_INSTS_DECODED", 23 | "SampleAfterValue": "2000000", 24 | "BriefDescription": "Two Uop instructions decoded" 25 | } 26 | ] -------------------------------------------------------------------------------- /libperf/pmu-events/arch/x86/nehalemex/frontend.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "EventCode": "0xD0", 4 | "Counter": "0,1,2,3", 5 | "UMask": "0x1", 6 | "EventName": "MACRO_INSTS.DECODED", 7 | "SampleAfterValue": "2000000", 8 | "BriefDescription": "Instructions decoded" 9 | }, 10 | { 11 | "EventCode": "0xA6", 12 | "Counter": "0,1,2,3", 13 | "UMask": "0x1", 14 | "EventName": "MACRO_INSTS.FUSIONS_DECODED", 15 | "SampleAfterValue": "2000000", 16 | "BriefDescription": "Macro-fused instructions decoded" 17 | }, 18 | { 19 | "EventCode": "0x19", 20 | "Counter": "0,1,2,3", 21 | "UMask": "0x1", 22 | "EventName": "TWO_UOP_INSTS_DECODED", 23 | "SampleAfterValue": "2000000", 24 | "BriefDescription": "Two Uop instructions decoded" 25 | } 26 | ] -------------------------------------------------------------------------------- /libperf/pmu-events/arch/x86/silvermont/memory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "PublicDescription": "This event counts the number of times that pipeline was cleared due to memory ordering issues.", 4 | "EventCode": "0xC3", 5 | "Counter": "0,1", 6 | "UMask": "0x2", 7 | "EventName": "MACHINE_CLEARS.MEMORY_ORDERING", 8 | "SampleAfterValue": "200003", 9 | "BriefDescription": "Stalls due to Memory ordering" 10 | } 11 | ] -------------------------------------------------------------------------------- /libperf/pmu-events/arch/x86/skylake/other.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "PublicDescription": "This event counts the number of hardware interruptions received by the processor.", 4 | "EventCode": "0xCB", 5 | "Counter": "0,1,2,3", 6 | "UMask": "0x1", 7 | "EventName": "HW_INTERRUPTS.RECEIVED", 8 | "SampleAfterValue": "100003", 9 | "BriefDescription": "Number of hardware interrupts received by the processor.", 10 | "CounterHTOff": "0,1,2,3,4,5,6,7" 11 | } 12 | ] -------------------------------------------------------------------------------- /libperf/pmu-events/arch/x86/westmereep-dp/frontend.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "EventCode": "0xD0", 4 | "Counter": "0,1,2,3", 5 | "UMask": "0x1", 6 | "EventName": "MACRO_INSTS.DECODED", 7 | "SampleAfterValue": "2000000", 8 | "BriefDescription": "Instructions decoded" 9 | }, 10 | { 11 | "EventCode": "0xA6", 12 | "Counter": "0,1,2,3", 13 | "UMask": "0x1", 14 | "EventName": "MACRO_INSTS.FUSIONS_DECODED", 15 | "SampleAfterValue": "2000000", 16 | "BriefDescription": "Macro-fused instructions decoded" 17 | }, 18 | { 19 | "EventCode": "0x19", 20 | "Counter": "0,1,2,3", 21 | "UMask": "0x1", 22 | "EventName": "TWO_UOP_INSTS_DECODED", 23 | "SampleAfterValue": "2000000", 24 | "BriefDescription": "Two Uop instructions decoded" 25 | } 26 | ] -------------------------------------------------------------------------------- /libperf/pmu-events/arch/x86/westmereep-sp/frontend.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "EventCode": "0xD0", 4 | "Counter": "0,1,2,3", 5 | "UMask": "0x1", 6 | "EventName": "MACRO_INSTS.DECODED", 7 | "SampleAfterValue": "2000000", 8 | "BriefDescription": "Instructions decoded" 9 | }, 10 | { 11 | "EventCode": "0xA6", 12 | "Counter": "0,1,2,3", 13 | "UMask": "0x1", 14 | "EventName": "MACRO_INSTS.FUSIONS_DECODED", 15 | "SampleAfterValue": "2000000", 16 | "BriefDescription": "Macro-fused instructions decoded" 17 | }, 18 | { 19 | "EventCode": "0x19", 20 | "Counter": "0,1,2,3", 21 | "UMask": "0x1", 22 | "EventName": "TWO_UOP_INSTS_DECODED", 23 | "SampleAfterValue": "2000000", 24 | "BriefDescription": "Two Uop instructions decoded" 25 | } 26 | ] -------------------------------------------------------------------------------- /libperf/pmu-events/arch/x86/westmereex/frontend.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "EventCode": "0xD0", 4 | "Counter": "0,1,2,3", 5 | "UMask": "0x1", 6 | "EventName": "MACRO_INSTS.DECODED", 7 | "SampleAfterValue": "2000000", 8 | "BriefDescription": "Instructions decoded" 9 | }, 10 | { 11 | "EventCode": "0xA6", 12 | "Counter": "0,1,2,3", 13 | "UMask": "0x1", 14 | "EventName": "MACRO_INSTS.FUSIONS_DECODED", 15 | "SampleAfterValue": "2000000", 16 | "BriefDescription": "Macro-fused instructions decoded" 17 | }, 18 | { 19 | "EventCode": "0x19", 20 | "Counter": "0,1,2,3", 21 | "UMask": "0x1", 22 | "EventName": "TWO_UOP_INSTS_DECODED", 23 | "SampleAfterValue": "2000000", 24 | "BriefDescription": "Two Uop instructions decoded" 25 | } 26 | ] -------------------------------------------------------------------------------- /libperf/pmu-events/jevents: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RainM/rperf/d0b58ede8ce2fbc60ad35f0cea6ad33be1e486fd/libperf/pmu-events/jevents -------------------------------------------------------------------------------- /libperf/pmu-events/jevents.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef JEVENTS_H 3 | #define JEVENTS_H 1 4 | 5 | int json_events(const char *fn, 6 | int (*func)(void *data, char *name, char *event, char *desc, 7 | char *long_desc, 8 | char *pmu, 9 | char *unit, char *perpkg, char *metric_expr, 10 | char *metric_name, char *metric_group), 11 | void *data); 12 | char *get_cpu_str(void); 13 | 14 | #ifndef min 15 | #define min(x, y) ({ \ 16 | typeof(x) _min1 = (x); \ 17 | typeof(y) _min2 = (y); \ 18 | (void) (&_min1 == &_min2); \ 19 | _min1 < _min2 ? _min1 : _min2; }) 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /libperf/pmu-events/json.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef JSON_H 3 | #define JSON_H 1 4 | 5 | #include "jsmn.h" 6 | 7 | jsmntok_t *parse_json(const char *fn, char **map, size_t *size, int *len); 8 | void free_json(char *map, size_t size, jsmntok_t *tokens); 9 | int json_line(char *map, jsmntok_t *t); 10 | const char *json_name(jsmntok_t *t); 11 | int json_streq(char *map, jsmntok_t *t, const char *s); 12 | int json_len(jsmntok_t *t); 13 | 14 | extern int verbose; 15 | 16 | #include 17 | 18 | extern int eprintf(int level, int var, const char *fmt, ...); 19 | #define pr_fmt(fmt) fmt 20 | 21 | #define pr_err(fmt, ...) \ 22 | eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__) 23 | 24 | #define pr_info(fmt, ...) \ 25 | eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__) 26 | 27 | #define pr_debug(fmt, ...) \ 28 | eprintf(2, verbose, pr_fmt(fmt), ##__VA_ARGS__) 29 | 30 | #ifndef roundup 31 | #define roundup(x, y) ( \ 32 | { \ 33 | const typeof(y) __y = y; \ 34 | (((x) + (__y - 1)) / __y) * __y; \ 35 | } \ 36 | ) 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libperf/pmu-events/pmu-events.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef PMU_EVENTS_H 3 | #define PMU_EVENTS_H 4 | 5 | /* 6 | * Describe each PMU event. Each CPU has a table of PMU events. 7 | */ 8 | struct pmu_event { 9 | const char *name; 10 | const char *event; 11 | const char *desc; 12 | const char *topic; 13 | const char *long_desc; 14 | const char *pmu; 15 | const char *unit; 16 | const char *perpkg; 17 | const char *metric_expr; 18 | const char *metric_name; 19 | const char *metric_group; 20 | }; 21 | 22 | /* 23 | * 24 | * Map a CPU to its table of PMU events. The CPU is identified by the 25 | * cpuid field, which is an arch-specific identifier for the CPU. 26 | * The identifier specified in tools/perf/pmu-events/arch/xxx/mapfile 27 | * must match the get_cpustr() in tools/perf/arch/xxx/util/header.c) 28 | * 29 | * The cpuid can contain any character other than the comma. 30 | */ 31 | struct pmu_events_map { 32 | const char *cpuid; 33 | const char *version; 34 | const char *type; /* core, uncore etc */ 35 | struct pmu_event *table; 36 | }; 37 | 38 | /* 39 | * Global table mapping each known CPU for the architecture to its 40 | * table of PMU events. 41 | */ 42 | extern struct pmu_events_map pmu_events_map[]; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /libperf/profiler-backend.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __PROFILER_HEADER__ 2 | #define __PROFILER_HEADER__ 3 | 4 | #include 5 | 6 | #if defined(__cplusplus) 7 | #define __API__ extern "C" 8 | #else 9 | #define __API__ 10 | #endif 11 | 12 | __API__ void visit_sample(uint64_t timestamp, const char* symbol_name, const char* dso); 13 | __API__ void prepare_top(void); 14 | __API__ int get_top_len(void); 15 | __API__ const char* get_top_by_idx(int idx); 16 | __API__ uint64_t get_counters_by_idx(int idx); 17 | __API__ int get_invoke_count_by_idx(int idx); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /libperf/profiler.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(__PROFILER_HPP__) 2 | #define __PROFILER_HPP__ 3 | 4 | #if defined(__cplusplus) 5 | #define __API__ extern "C" 6 | #else 7 | #define __API__ 8 | #endif 9 | 10 | __API__ void init(int cntr); 11 | __API__ void start(); 12 | __API__ void stop(); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /libperf/ru_raiffeisen_PerfPtProf.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class ru_raiffeisen_PerfPtProf */ 4 | 5 | #ifndef _Included_ru_raiffeisen_PerfPtProf 6 | #define _Included_ru_raiffeisen_PerfPtProf 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: ru_raiffeisen_PerfPtProf 12 | * Method: init 13 | * Signature: (I)V 14 | */ 15 | JNIEXPORT void JNICALL Java_ru_raiffeisen_PerfPtProf_init 16 | (JNIEnv *, jclass, jint); 17 | 18 | /* 19 | * Class: ru_raiffeisen_PerfPtProf 20 | * Method: start 21 | * Signature: ()V 22 | */ 23 | JNIEXPORT void JNICALL Java_ru_raiffeisen_PerfPtProf_start 24 | (JNIEnv *, jclass); 25 | 26 | /* 27 | * Class: ru_raiffeisen_PerfPtProf 28 | * Method: stop 29 | * Signature: ()V 30 | */ 31 | JNIEXPORT void JNICALL Java_ru_raiffeisen_PerfPtProf_stop 32 | (JNIEnv *, jclass); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif 38 | -------------------------------------------------------------------------------- /libperf/scripts/Build: -------------------------------------------------------------------------------- 1 | libperf-$(CONFIG_LIBPERL) += perl/Perf-Trace-Util/ 2 | libperf-$(CONFIG_LIBPYTHON) += python/Perf-Trace-Util/ 3 | -------------------------------------------------------------------------------- /libperf/scripts/perl/Perf-Trace-Util/Build: -------------------------------------------------------------------------------- 1 | libperf-y += Context.o 2 | 3 | CFLAGS_Context.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes 4 | CFLAGS_Context.o += -Wno-unused-parameter -Wno-nested-externs -Wno-undef 5 | CFLAGS_Context.o += -Wno-switch-default -Wno-shadow 6 | -------------------------------------------------------------------------------- /libperf/scripts/perl/Perf-Trace-Util/Context.xs: -------------------------------------------------------------------------------- 1 | /* 2 | * Context.xs. XS interfaces for perf script. 3 | * 4 | * Copyright (C) 2009 Tom Zanussi 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | */ 21 | 22 | #include "EXTERN.h" 23 | #include "perl.h" 24 | #include "XSUB.h" 25 | #include "../../../perf.h" 26 | #include "../../../util/trace-event.h" 27 | 28 | MODULE = Perf::Trace::Context PACKAGE = Perf::Trace::Context 29 | PROTOTYPES: ENABLE 30 | 31 | int 32 | common_pc(context) 33 | struct scripting_context * context 34 | 35 | int 36 | common_flags(context) 37 | struct scripting_context * context 38 | 39 | int 40 | common_lock_depth(context) 41 | struct scripting_context * context 42 | 43 | -------------------------------------------------------------------------------- /libperf/scripts/perl/Perf-Trace-Util/Makefile.PL: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | use 5.010000; 3 | use ExtUtils::MakeMaker; 4 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence 5 | # the contents of the Makefile that is written. 6 | WriteMakefile( 7 | NAME => 'Perf::Trace::Context', 8 | VERSION_FROM => 'lib/Perf/Trace/Context.pm', # finds $VERSION 9 | PREREQ_PM => {}, # e.g., Module::Name => 1.1 10 | ($] >= 5.005 ? ## Add these new keywords supported since 5.005 11 | (ABSTRACT_FROM => 'lib/Perf/Trace/Context.pm', # retrieve abstract from module 12 | AUTHOR => 'Tom Zanussi ') : ()), 13 | LIBS => [''], # e.g., '-lm' 14 | DEFINE => '-I ../..', # e.g., '-DHAVE_SOMETHING' 15 | INC => '-I.', # e.g., '-I. -I/usr/include/other' 16 | # Un-comment this if you add C files to link with later: 17 | OBJECT => 'Context.o', # link all the C files too 18 | ); 19 | -------------------------------------------------------------------------------- /libperf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Context.pm: -------------------------------------------------------------------------------- 1 | package Perf::Trace::Context; 2 | 3 | use 5.010000; 4 | use strict; 5 | use warnings; 6 | 7 | require Exporter; 8 | 9 | our @ISA = qw(Exporter); 10 | 11 | our %EXPORT_TAGS = ( 'all' => [ qw( 12 | ) ] ); 13 | 14 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); 15 | 16 | our @EXPORT = qw( 17 | common_pc common_flags common_lock_depth 18 | ); 19 | 20 | our $VERSION = '0.01'; 21 | 22 | require XSLoader; 23 | XSLoader::load('Perf::Trace::Context', $VERSION); 24 | 25 | 1; 26 | __END__ 27 | =head1 NAME 28 | 29 | Perf::Trace::Context - Perl extension for accessing functions in perf. 30 | 31 | =head1 SYNOPSIS 32 | 33 | use Perf::Trace::Context; 34 | 35 | =head1 SEE ALSO 36 | 37 | Perf (script) documentation 38 | 39 | =head1 AUTHOR 40 | 41 | Tom Zanussi, Etzanussi@gmail.com 42 | 43 | =head1 COPYRIGHT AND LICENSE 44 | 45 | Copyright (C) 2009 by Tom Zanussi 46 | 47 | This library is free software; you can redistribute it and/or modify 48 | it under the same terms as Perl itself, either Perl version 5.10.0 or, 49 | at your option, any later version of Perl 5 you may have available. 50 | 51 | Alternatively, this software may be distributed under the terms of the 52 | GNU General Public License ("GPL") version 2 as published by the Free 53 | Software Foundation. 54 | 55 | =cut 56 | -------------------------------------------------------------------------------- /libperf/scripts/perl/Perf-Trace-Util/typemap: -------------------------------------------------------------------------------- 1 | struct scripting_context * T_PTR 2 | -------------------------------------------------------------------------------- /libperf/scripts/perl/bin/check-perf-trace-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | perf record -a -e kmem:kmalloc -e irq:softirq_entry -e kmem:kfree 3 | -------------------------------------------------------------------------------- /libperf/scripts/perl/bin/failed-syscalls-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | (perf record -e raw_syscalls:sys_exit $@ || \ 3 | perf record -e syscalls:sys_exit $@) 2> /dev/null 4 | -------------------------------------------------------------------------------- /libperf/scripts/perl/bin/failed-syscalls-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: system-wide failed syscalls 3 | # args: [comm] 4 | if [ $# -gt 0 ] ; then 5 | if ! expr match "$1" "-" > /dev/null ; then 6 | comm=$1 7 | shift 8 | fi 9 | fi 10 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/perl/failed-syscalls.pl $comm 11 | -------------------------------------------------------------------------------- /libperf/scripts/perl/bin/rw-by-file-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | perf record -e syscalls:sys_enter_read -e syscalls:sys_enter_write $@ 3 | 4 | -------------------------------------------------------------------------------- /libperf/scripts/perl/bin/rw-by-file-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: r/w activity for a program, by file 3 | # args: 4 | if [ $# -lt 1 ] ; then 5 | echo "usage: rw-by-file " 6 | exit 7 | fi 8 | comm=$1 9 | shift 10 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/perl/rw-by-file.pl $comm 11 | -------------------------------------------------------------------------------- /libperf/scripts/perl/bin/rw-by-pid-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | perf record -e syscalls:sys_enter_read -e syscalls:sys_exit_read -e syscalls:sys_enter_write -e syscalls:sys_exit_write $@ 3 | -------------------------------------------------------------------------------- /libperf/scripts/perl/bin/rw-by-pid-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: system-wide r/w activity 3 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/perl/rw-by-pid.pl 4 | -------------------------------------------------------------------------------- /libperf/scripts/perl/bin/rwtop-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | perf record -e syscalls:sys_enter_read -e syscalls:sys_exit_read -e syscalls:sys_enter_write -e syscalls:sys_exit_write $@ 3 | -------------------------------------------------------------------------------- /libperf/scripts/perl/bin/rwtop-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: system-wide r/w top 3 | # args: [interval] 4 | n_args=0 5 | for i in "$@" 6 | do 7 | if expr match "$i" "-" > /dev/null ; then 8 | break 9 | fi 10 | n_args=$(( $n_args + 1 )) 11 | done 12 | if [ "$n_args" -gt 1 ] ; then 13 | echo "usage: rwtop-report [interval]" 14 | exit 15 | fi 16 | if [ "$n_args" -gt 0 ] ; then 17 | interval=$1 18 | shift 19 | fi 20 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/perl/rwtop.pl $interval 21 | -------------------------------------------------------------------------------- /libperf/scripts/perl/bin/wakeup-latency-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | perf record -e sched:sched_switch -e sched:sched_wakeup $@ 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /libperf/scripts/perl/bin/wakeup-latency-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: system-wide min/max/avg wakeup latency 3 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/perl/wakeup-latency.pl 4 | -------------------------------------------------------------------------------- /libperf/scripts/perl/failed-syscalls.pl: -------------------------------------------------------------------------------- 1 | # failed system call counts 2 | # (c) 2010, Tom Zanussi 3 | # Licensed under the terms of the GNU GPL License version 2 4 | # 5 | # Displays system-wide failed system call totals 6 | # If a [comm] arg is specified, only syscalls called by [comm] are displayed. 7 | 8 | use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib"; 9 | use lib "./Perf-Trace-Util/lib"; 10 | use Perf::Trace::Core; 11 | use Perf::Trace::Context; 12 | use Perf::Trace::Util; 13 | 14 | my $for_comm = shift; 15 | 16 | my %failed_syscalls; 17 | 18 | sub raw_syscalls::sys_exit 19 | { 20 | my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs, 21 | $common_pid, $common_comm, 22 | $id, $ret) = @_; 23 | 24 | if ($ret < 0) { 25 | $failed_syscalls{$common_comm}++; 26 | } 27 | } 28 | 29 | sub syscalls::sys_exit 30 | { 31 | raw_syscalls::sys_exit(@_) 32 | } 33 | 34 | sub trace_end 35 | { 36 | printf("\nfailed syscalls by comm:\n\n"); 37 | 38 | printf("%-20s %10s\n", "comm", "# errors"); 39 | printf("%-20s %6s %10s\n", "--------------------", "----------"); 40 | 41 | foreach my $comm (sort {$failed_syscalls{$b} <=> $failed_syscalls{$a}} 42 | keys %failed_syscalls) { 43 | next if ($for_comm && $comm ne $for_comm); 44 | 45 | printf("%-20s %10s\n", $comm, $failed_syscalls{$comm}); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /libperf/scripts/python/Perf-Trace-Util/Build: -------------------------------------------------------------------------------- 1 | libperf-y += Context.o 2 | 3 | CFLAGS_Context.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs 4 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/compaction-times-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | perf record -e compaction:mm_compaction_begin -e compaction:mm_compaction_end -e compaction:mm_compaction_migratepages -e compaction:mm_compaction_isolate_migratepages -e compaction:mm_compaction_isolate_freepages $@ 3 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/compaction-times-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #description: display time taken by mm compaction 3 | #args: [-h] [-u] [-p|-pv] [-t | [-m] [-fs] [-ms]] [pid|pid-range|comm-regex] 4 | perf script -s "$PERF_EXEC_PATH"/scripts/python/compaction-times.py $@ 5 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/event_analyzing_sample-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # event_analyzing_sample.py can cover all type of perf samples including 5 | # the tracepoints, so no special record requirements, just record what 6 | # you want to analyze. 7 | # 8 | perf record $@ 9 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/event_analyzing_sample-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: analyze all perf samples 3 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/event_analyzing_sample.py 4 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/export-to-postgresql-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # export perf data to a postgresql database. Can cover 5 | # perf ip samples (excluding the tracepoints). No special 6 | # record requirements, just record what you want to export. 7 | # 8 | perf record $@ 9 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/export-to-postgresql-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: export perf data to a postgresql database 3 | # args: [database name] [columns] [calls] 4 | n_args=0 5 | for i in "$@" 6 | do 7 | if expr match "$i" "-" > /dev/null ; then 8 | break 9 | fi 10 | n_args=$(( $n_args + 1 )) 11 | done 12 | if [ "$n_args" -gt 3 ] ; then 13 | echo "usage: export-to-postgresql-report [database name] [columns] [calls]" 14 | exit 15 | fi 16 | if [ "$n_args" -gt 2 ] ; then 17 | dbname=$1 18 | columns=$2 19 | calls=$3 20 | shift 3 21 | elif [ "$n_args" -gt 1 ] ; then 22 | dbname=$1 23 | columns=$2 24 | shift 2 25 | elif [ "$n_args" -gt 0 ] ; then 26 | dbname=$1 27 | shift 28 | fi 29 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/export-to-postgresql.py $dbname $columns $calls 30 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/export-to-sqlite-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # export perf data to a sqlite3 database. Can cover 5 | # perf ip samples (excluding the tracepoints). No special 6 | # record requirements, just record what you want to export. 7 | # 8 | perf record $@ 9 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/export-to-sqlite-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: export perf data to a sqlite3 database 3 | # args: [database name] [columns] [calls] 4 | n_args=0 5 | for i in "$@" 6 | do 7 | if expr match "$i" "-" > /dev/null ; then 8 | break 9 | fi 10 | n_args=$(( $n_args + 1 )) 11 | done 12 | if [ "$n_args" -gt 3 ] ; then 13 | echo "usage: export-to-sqlite-report [database name] [columns] [calls]" 14 | exit 15 | fi 16 | if [ "$n_args" -gt 2 ] ; then 17 | dbname=$1 18 | columns=$2 19 | calls=$3 20 | shift 3 21 | elif [ "$n_args" -gt 1 ] ; then 22 | dbname=$1 23 | columns=$2 24 | shift 2 25 | elif [ "$n_args" -gt 0 ] ; then 26 | dbname=$1 27 | shift 28 | fi 29 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/export-to-sqlite.py $dbname $columns $calls 30 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/failed-syscalls-by-pid-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | (perf record -e raw_syscalls:sys_exit $@ || \ 3 | perf record -e syscalls:sys_exit $@) 2> /dev/null 4 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/failed-syscalls-by-pid-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: system-wide failed syscalls, by pid 3 | # args: [comm] 4 | if [ $# -gt 0 ] ; then 5 | if ! expr match "$1" "-" > /dev/null ; then 6 | comm=$1 7 | shift 8 | fi 9 | fi 10 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/failed-syscalls-by-pid.py $comm 11 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/futex-contention-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | perf record -e syscalls:sys_enter_futex -e syscalls:sys_exit_futex $@ 3 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/futex-contention-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: futext contention measurement 3 | 4 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/futex-contention.py 5 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/intel-pt-events-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # print Intel PT Power Events and PTWRITE. The intel_pt PMU event needs 5 | # to be specified with appropriate config terms. 6 | # 7 | if ! echo "$@" | grep -q intel_pt ; then 8 | echo "Options must include the Intel PT event e.g. -e intel_pt/pwr_evt,ptw/" 9 | echo "and for power events it probably needs to be system wide i.e. -a option" 10 | echo "For example: -a -e intel_pt/pwr_evt,branch=0/ sleep 1" 11 | exit 1 12 | fi 13 | perf record $@ 14 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/intel-pt-events-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: print Intel PT Power Events and PTWRITE 3 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/intel-pt-events.py -------------------------------------------------------------------------------- /libperf/scripts/python/bin/net_dropmonitor-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | perf record -e skb:kfree_skb $@ 3 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/net_dropmonitor-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: display a table of dropped frames 3 | 4 | perf script -s "$PERF_EXEC_PATH"/scripts/python/net_dropmonitor.py $@ 5 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/netdev-times-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | perf record -e net:net_dev_xmit -e net:net_dev_queue \ 3 | -e net:netif_receive_skb -e net:netif_rx \ 4 | -e skb:consume_skb -e skb:kfree_skb \ 5 | -e skb:skb_copy_datagram_iovec -e napi:napi_poll \ 6 | -e irq:irq_handler_entry -e irq:irq_handler_exit \ 7 | -e irq:softirq_entry -e irq:softirq_exit \ 8 | -e irq:softirq_raise $@ 9 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/netdev-times-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: display a process of packet and processing time 3 | # args: [tx] [rx] [dev=] [debug] 4 | 5 | perf script -s "$PERF_EXEC_PATH"/scripts/python/netdev-times.py $@ 6 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/sched-migration-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | perf record -m 16384 -e sched:sched_wakeup -e sched:sched_wakeup_new -e sched:sched_switch -e sched:sched_migrate_task $@ 3 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/sched-migration-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: sched migration overview 3 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/sched-migration.py 4 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/sctop-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | (perf record -e raw_syscalls:sys_enter $@ || \ 3 | perf record -e syscalls:sys_enter $@) 2> /dev/null 4 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/sctop-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: syscall top 3 | # args: [comm] [interval] 4 | n_args=0 5 | for i in "$@" 6 | do 7 | if expr match "$i" "-" > /dev/null ; then 8 | break 9 | fi 10 | n_args=$(( $n_args + 1 )) 11 | done 12 | if [ "$n_args" -gt 2 ] ; then 13 | echo "usage: sctop-report [comm] [interval]" 14 | exit 15 | fi 16 | if [ "$n_args" -gt 1 ] ; then 17 | comm=$1 18 | interval=$2 19 | shift 2 20 | elif [ "$n_args" -gt 0 ] ; then 21 | interval=$1 22 | shift 23 | fi 24 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/sctop.py $comm $interval 25 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/stackcollapse-record: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # stackcollapse.py can cover all type of perf samples including 5 | # the tracepoints, so no special record requirements, just record what 6 | # you want to analyze. 7 | # 8 | perf record "$@" 9 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/stackcollapse-report: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # description: produce callgraphs in short form for scripting use 3 | perf script -s "$PERF_EXEC_PATH"/scripts/python/stackcollapse.py -- "$@" 4 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/syscall-counts-by-pid-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | (perf record -e raw_syscalls:sys_enter $@ || \ 3 | perf record -e syscalls:sys_enter $@) 2> /dev/null 4 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/syscall-counts-by-pid-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: system-wide syscall counts, by pid 3 | # args: [comm] 4 | if [ $# -gt 0 ] ; then 5 | if ! expr match "$1" "-" > /dev/null ; then 6 | comm=$1 7 | shift 8 | fi 9 | fi 10 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/syscall-counts-by-pid.py $comm 11 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/syscall-counts-record: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | (perf record -e raw_syscalls:sys_enter $@ || \ 3 | perf record -e syscalls:sys_enter $@) 2> /dev/null 4 | -------------------------------------------------------------------------------- /libperf/scripts/python/bin/syscall-counts-report: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # description: system-wide syscall counts 3 | # args: [comm] 4 | if [ $# -gt 0 ] ; then 5 | if ! expr match "$1" "-" > /dev/null ; then 6 | comm=$1 7 | shift 8 | fi 9 | fi 10 | perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/syscall-counts.py $comm 11 | -------------------------------------------------------------------------------- /libperf/tests/.gitignore: -------------------------------------------------------------------------------- 1 | llvm-src-base.c 2 | llvm-src-kbuild.c 3 | llvm-src-prologue.c 4 | llvm-src-relocation.c 5 | -------------------------------------------------------------------------------- /libperf/tests/attr/base-record: -------------------------------------------------------------------------------- 1 | [event] 2 | fd=1 3 | group_fd=-1 4 | # 0 or PERF_FLAG_FD_CLOEXEC flag 5 | flags=0|8 6 | cpu=* 7 | type=0|1 8 | size=112 9 | config=0 10 | sample_period=* 11 | sample_type=263 12 | read_format=0 13 | disabled=1 14 | inherit=1 15 | pinned=0 16 | exclusive=0 17 | exclude_user=0 18 | exclude_kernel=0|1 19 | exclude_hv=0 20 | exclude_idle=0 21 | mmap=1 22 | comm=1 23 | freq=1 24 | inherit_stat=0 25 | enable_on_exec=1 26 | task=1 27 | watermark=0 28 | precise_ip=0|1|2|3 29 | mmap_data=0 30 | sample_id_all=1 31 | exclude_host=0|1 32 | exclude_guest=0|1 33 | exclude_callchain_kernel=0 34 | exclude_callchain_user=0 35 | wakeup_events=0 36 | bp_type=0 37 | config1=0 38 | config2=0 39 | branch_sample_type=0 40 | sample_regs_user=0 41 | sample_stack_user=0 42 | -------------------------------------------------------------------------------- /libperf/tests/attr/base-stat: -------------------------------------------------------------------------------- 1 | [event] 2 | fd=1 3 | group_fd=-1 4 | # 0 or PERF_FLAG_FD_CLOEXEC flag 5 | flags=0|8 6 | cpu=* 7 | type=0 8 | size=112 9 | config=0 10 | sample_period=0 11 | sample_type=65536 12 | read_format=3 13 | disabled=1 14 | inherit=1 15 | pinned=0 16 | exclusive=0 17 | exclude_user=0 18 | exclude_kernel=0|1 19 | exclude_hv=0 20 | exclude_idle=0 21 | mmap=0 22 | comm=0 23 | freq=0 24 | inherit_stat=0 25 | enable_on_exec=1 26 | task=0 27 | watermark=0 28 | precise_ip=0 29 | mmap_data=0 30 | sample_id_all=0 31 | exclude_host=0|1 32 | exclude_guest=0|1 33 | exclude_callchain_kernel=0 34 | exclude_callchain_user=0 35 | wakeup_events=0 36 | bp_type=0 37 | config1=0 38 | config2=0 39 | branch_sample_type=0 40 | sample_regs_user=0 41 | sample_stack_user=0 42 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-C0: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -C 0 kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | cpu=0 8 | 9 | # no enable on exec for CPU attached 10 | enable_on_exec=0 11 | 12 | # PERF_SAMPLE_IP | PERF_SAMPLE_TID PERF_SAMPLE_TIME | # PERF_SAMPLE_PERIOD 13 | # + PERF_SAMPLE_CPU added by -C 0 14 | sample_type=391 15 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-basic: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-branch-any: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -b kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=2311 8 | branch_sample_type=8 9 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-branch-filter-any: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -j any kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=2311 8 | branch_sample_type=8 9 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-branch-filter-any_call: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -j any_call kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=2311 8 | branch_sample_type=16 9 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-branch-filter-any_ret: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -j any_ret kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=2311 8 | branch_sample_type=32 9 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-branch-filter-hv: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -j hv kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=2311 8 | branch_sample_type=8 9 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-branch-filter-ind_call: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -j ind_call kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=2311 8 | branch_sample_type=64 9 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-branch-filter-k: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -j k kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=2311 8 | branch_sample_type=8 9 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-branch-filter-u: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -j u kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=2311 8 | branch_sample_type=8 9 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-count: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -c 123 kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_period=123 8 | sample_type=7 9 | freq=0 10 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-data: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -d kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | # sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME | 8 | # PERF_SAMPLE_ADDR | PERF_SAMPLE_PERIOD | PERF_SAMPLE_DATA_SRC 9 | sample_type=33039 10 | mmap_data=1 11 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-freq: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -F 100 kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_period=100 8 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-graph-default: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -g kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=295 8 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-graph-dwarf: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = --call-graph dwarf -- kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=45359 8 | exclude_callchain_user=1 9 | sample_stack_user=8192 10 | # TODO different for each arch, no support for that now 11 | sample_regs_user=* 12 | mmap_data=1 13 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-graph-fp: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = --call-graph fp kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=295 8 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-group: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = --group -e cycles,instructions kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event-1:base-record] 7 | fd=1 8 | group_fd=-1 9 | sample_type=327 10 | read_format=4 11 | 12 | [event-2:base-record] 13 | fd=2 14 | group_fd=1 15 | config=1 16 | sample_type=327 17 | read_format=4 18 | mmap=0 19 | comm=0 20 | task=0 21 | enable_on_exec=0 22 | disabled=0 23 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-group-sampling: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -e '{cycles,cache-misses}:S' kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event-1:base-record] 7 | fd=1 8 | group_fd=-1 9 | sample_type=343 10 | read_format=12 11 | inherit=0 12 | 13 | [event-2:base-record] 14 | fd=2 15 | group_fd=1 16 | 17 | # cache-misses 18 | type=0 19 | config=3 20 | 21 | # default | PERF_SAMPLE_READ 22 | sample_type=343 23 | 24 | # PERF_FORMAT_ID | PERF_FORMAT_GROUP 25 | read_format=12 26 | task=0 27 | mmap=0 28 | comm=0 29 | enable_on_exec=0 30 | disabled=0 31 | 32 | # inherit is disabled for group sampling 33 | inherit=0 34 | 35 | # sampling disabled 36 | sample_freq=0 37 | sample_period=0 38 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-group1: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -e '{cycles,instructions}' kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event-1:base-record] 7 | fd=1 8 | group_fd=-1 9 | sample_type=327 10 | read_format=4 11 | 12 | [event-2:base-record] 13 | fd=2 14 | group_fd=1 15 | type=0 16 | config=1 17 | sample_type=327 18 | read_format=4 19 | mmap=0 20 | comm=0 21 | task=0 22 | enable_on_exec=0 23 | disabled=0 24 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-no-buffering: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = --no-buffering kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=263 8 | watermark=0 9 | wakeup_events=1 10 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-no-inherit: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -i kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=263 8 | inherit=0 9 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-no-samples: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -n kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_period=0 8 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-period: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -c 100 -P kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_period=100 8 | freq=0 9 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-record-raw: -------------------------------------------------------------------------------- 1 | [config] 2 | command = record 3 | args = -R kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-record] 7 | sample_type=1415 8 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-stat-C0: -------------------------------------------------------------------------------- 1 | [config] 2 | command = stat 3 | args = -e cycles -C 0 kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-stat] 7 | # events are disabled by default when attached to cpu 8 | disabled=1 9 | enable_on_exec=0 10 | optional=1 11 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-stat-basic: -------------------------------------------------------------------------------- 1 | [config] 2 | command = stat 3 | args = -e cycles kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-stat] 7 | optional=1 8 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-stat-default: -------------------------------------------------------------------------------- 1 | [config] 2 | command = stat 3 | args = kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | # PERF_TYPE_SOFTWARE / PERF_COUNT_SW_TASK_CLOCK 7 | [event1:base-stat] 8 | fd=1 9 | type=1 10 | config=1 11 | 12 | # PERF_TYPE_SOFTWARE / PERF_COUNT_SW_CONTEXT_SWITCHES 13 | [event2:base-stat] 14 | fd=2 15 | type=1 16 | config=3 17 | 18 | # PERF_TYPE_SOFTWARE / PERF_COUNT_SW_CPU_MIGRATIONS 19 | [event3:base-stat] 20 | fd=3 21 | type=1 22 | config=4 23 | 24 | # PERF_TYPE_SOFTWARE / PERF_COUNT_SW_PAGE_FAULTS 25 | [event4:base-stat] 26 | fd=4 27 | type=1 28 | config=2 29 | 30 | # PERF_TYPE_HARDWARE / PERF_COUNT_HW_CPU_CYCLES 31 | [event5:base-stat] 32 | fd=5 33 | type=0 34 | config=0 35 | optional=1 36 | 37 | # PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_FRONTEND 38 | [event6:base-stat] 39 | fd=6 40 | type=0 41 | config=7 42 | optional=1 43 | 44 | # PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND 45 | [event7:base-stat] 46 | fd=7 47 | type=0 48 | config=8 49 | optional=1 50 | 51 | # PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS 52 | [event8:base-stat] 53 | fd=8 54 | type=0 55 | config=1 56 | optional=1 57 | 58 | # PERF_TYPE_HARDWARE / PERF_COUNT_HW_BRANCH_INSTRUCTIONS 59 | [event9:base-stat] 60 | fd=9 61 | type=0 62 | config=4 63 | optional=1 64 | 65 | # PERF_TYPE_HARDWARE / PERF_COUNT_HW_BRANCH_MISSES 66 | [event10:base-stat] 67 | fd=10 68 | type=0 69 | config=5 70 | optional=1 71 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-stat-group: -------------------------------------------------------------------------------- 1 | [config] 2 | command = stat 3 | args = --group -e cycles,instructions kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event-1:base-stat] 7 | fd=1 8 | group_fd=-1 9 | read_format=3|15 10 | 11 | [event-2:base-stat] 12 | fd=2 13 | group_fd=1 14 | config=1 15 | disabled=0 16 | enable_on_exec=0 17 | read_format=3|15 18 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-stat-group1: -------------------------------------------------------------------------------- 1 | [config] 2 | command = stat 3 | args = -e '{cycles,instructions}' kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event-1:base-stat] 7 | fd=1 8 | group_fd=-1 9 | read_format=3|15 10 | 11 | [event-2:base-stat] 12 | fd=2 13 | group_fd=1 14 | config=1 15 | disabled=0 16 | enable_on_exec=0 17 | read_format=3|15 18 | -------------------------------------------------------------------------------- /libperf/tests/attr/test-stat-no-inherit: -------------------------------------------------------------------------------- 1 | [config] 2 | command = stat 3 | args = -i -e cycles kill >/dev/null 2>&1 4 | ret = 1 5 | 6 | [event:base-stat] 7 | inherit=0 8 | optional=1 9 | -------------------------------------------------------------------------------- /libperf/tests/bpf-script-test-kbuild.c: -------------------------------------------------------------------------------- 1 | /* 2 | * bpf-script-test-kbuild.c 3 | * Test include from kernel header 4 | */ 5 | #ifndef LINUX_VERSION_CODE 6 | # error Need LINUX_VERSION_CODE 7 | # error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig' 8 | #endif 9 | #define SEC(NAME) __attribute__((section(NAME), used)) 10 | 11 | #include 12 | #include 13 | 14 | SEC("func=vfs_llseek") 15 | int bpf_func__vfs_llseek(void *ctx) 16 | { 17 | return 0; 18 | } 19 | 20 | char _license[] SEC("license") = "GPL"; 21 | int _version SEC("version") = LINUX_VERSION_CODE; 22 | -------------------------------------------------------------------------------- /libperf/tests/bpf-script-test-prologue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * bpf-script-test-prologue.c 3 | * Test BPF prologue 4 | */ 5 | #ifndef LINUX_VERSION_CODE 6 | # error Need LINUX_VERSION_CODE 7 | # error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig' 8 | #endif 9 | #define SEC(NAME) __attribute__((section(NAME), used)) 10 | 11 | #include 12 | 13 | /* 14 | * If CONFIG_PROFILE_ALL_BRANCHES is selected, 15 | * 'if' is redefined after include kernel header. 16 | * Recover 'if' for BPF object code. 17 | */ 18 | #ifdef if 19 | # undef if 20 | #endif 21 | 22 | #define FMODE_READ 0x1 23 | #define FMODE_WRITE 0x2 24 | 25 | static void (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) = 26 | (void *) 6; 27 | 28 | SEC("func=null_lseek file->f_mode offset orig") 29 | int bpf_func__null_lseek(void *ctx, int err, unsigned long _f_mode, 30 | unsigned long offset, unsigned long orig) 31 | { 32 | fmode_t f_mode = (fmode_t)_f_mode; 33 | 34 | if (err) 35 | return 0; 36 | if (f_mode & FMODE_WRITE) 37 | return 0; 38 | if (offset & 1) 39 | return 0; 40 | if (orig == SEEK_CUR) 41 | return 0; 42 | return 1; 43 | } 44 | 45 | char _license[] SEC("license") = "GPL"; 46 | int _version SEC("version") = LINUX_VERSION_CODE; 47 | -------------------------------------------------------------------------------- /libperf/tests/clang.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include "tests.h" 3 | #include "debug.h" 4 | #include "util.h" 5 | #include "c++/clang-c.h" 6 | #include 7 | 8 | static struct { 9 | int (*func)(void); 10 | const char *desc; 11 | } clang_testcase_table[] = { 12 | #ifdef HAVE_LIBCLANGLLVM_SUPPORT 13 | { 14 | .func = test__clang_to_IR, 15 | .desc = "builtin clang compile C source to IR", 16 | }, 17 | { 18 | .func = test__clang_to_obj, 19 | .desc = "builtin clang compile C source to ELF object", 20 | }, 21 | #endif 22 | }; 23 | 24 | int test__clang_subtest_get_nr(void) 25 | { 26 | return (int)ARRAY_SIZE(clang_testcase_table); 27 | } 28 | 29 | const char *test__clang_subtest_get_desc(int i) 30 | { 31 | if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table)) 32 | return NULL; 33 | return clang_testcase_table[i].desc; 34 | } 35 | 36 | #ifndef HAVE_LIBCLANGLLVM_SUPPORT 37 | int test__clang(struct test *test __maybe_unused, int i __maybe_unused) 38 | { 39 | return TEST_SKIP; 40 | } 41 | #else 42 | int test__clang(struct test *test __maybe_unused, int i) 43 | { 44 | if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table)) 45 | return TEST_FAIL; 46 | return clang_testcase_table[i].func(); 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /libperf/tests/is_printable_array.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include 4 | #include "tests.h" 5 | #include "debug.h" 6 | #include "print_binary.h" 7 | 8 | int test__is_printable_array(struct test *test __maybe_unused, int subtest __maybe_unused) 9 | { 10 | char buf1[] = { 'k', 'r', 4, 'v', 'a', 0 }; 11 | char buf2[] = { 'k', 'r', 'a', 'v', 4, 0 }; 12 | struct { 13 | char *buf; 14 | unsigned int len; 15 | int ret; 16 | } t[] = { 17 | { (char *) "krava", sizeof("krava"), 1 }, 18 | { (char *) "krava", sizeof("krava") - 1, 0 }, 19 | { (char *) "", sizeof(""), 1 }, 20 | { (char *) "", 0, 0 }, 21 | { NULL, 0, 0 }, 22 | { buf1, sizeof(buf1), 0 }, 23 | { buf2, sizeof(buf2), 0 }, 24 | }; 25 | unsigned int i; 26 | 27 | for (i = 0; i < ARRAY_SIZE(t); i++) { 28 | int ret; 29 | 30 | ret = is_printable_array((char *) t[i].buf, t[i].len); 31 | if (ret != t[i].ret) { 32 | pr_err("failed: test %u\n", i); 33 | return TEST_FAIL; 34 | } 35 | } 36 | 37 | return TEST_OK; 38 | } 39 | -------------------------------------------------------------------------------- /libperf/tests/llvm.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef PERF_TEST_LLVM_H 3 | #define PERF_TEST_LLVM_H 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #include /* for size_t */ 10 | #include /* for bool */ 11 | 12 | extern const char test_llvm__bpf_base_prog[]; 13 | extern const char test_llvm__bpf_test_kbuild_prog[]; 14 | extern const char test_llvm__bpf_test_prologue_prog[]; 15 | extern const char test_llvm__bpf_test_relocation[]; 16 | 17 | enum test_llvm__testcase { 18 | LLVM_TESTCASE_BASE, 19 | LLVM_TESTCASE_KBUILD, 20 | LLVM_TESTCASE_BPF_PROLOGUE, 21 | LLVM_TESTCASE_BPF_RELOCATION, 22 | __LLVM_TESTCASE_MAX, 23 | }; 24 | 25 | int test_llvm__fetch_bpf_obj(void **p_obj_buf, size_t *p_obj_buf_sz, 26 | enum test_llvm__testcase index, bool force, 27 | bool *should_load_fail); 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | #endif 32 | -------------------------------------------------------------------------------- /libperf/tests/perf-hooks.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include 4 | 5 | #include "tests.h" 6 | #include "debug.h" 7 | #include "util.h" 8 | #include "perf-hooks.h" 9 | 10 | static void sigsegv_handler(int sig __maybe_unused) 11 | { 12 | pr_debug("SIGSEGV is observed as expected, try to recover.\n"); 13 | perf_hooks__recover(); 14 | signal(SIGSEGV, SIG_DFL); 15 | raise(SIGSEGV); 16 | exit(-1); 17 | } 18 | 19 | 20 | static void the_hook(void *_hook_flags) 21 | { 22 | int *hook_flags = _hook_flags; 23 | int *p = NULL; 24 | 25 | *hook_flags = 1234; 26 | 27 | /* Generate a segfault, test perf_hooks__recover */ 28 | *p = 0; 29 | } 30 | 31 | int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unused) 32 | { 33 | int hook_flags = 0; 34 | 35 | signal(SIGSEGV, sigsegv_handler); 36 | perf_hooks__set_hook("test", the_hook, &hook_flags); 37 | perf_hooks__invoke_test(); 38 | 39 | /* hook is triggered? */ 40 | if (hook_flags != 1234) { 41 | pr_debug("Setting failed: %d (%p)\n", hook_flags, &hook_flags); 42 | return TEST_FAIL; 43 | } 44 | 45 | /* the buggy hook is removed? */ 46 | if (perf_hooks__get_hook("test")) 47 | return TEST_FAIL; 48 | return TEST_OK; 49 | } 50 | -------------------------------------------------------------------------------- /libperf/tests/perf-targz-src-pkg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # SPDX-License-Identifier: GPL-2.0 3 | # Test one of the main kernel Makefile targets to generate a perf sources tarball 4 | # suitable for build outside the full kernel sources. 5 | # 6 | # This is to test that the tools/perf/MANIFEST file lists all the files needed to 7 | # be in such tarball, which sometimes gets broken when we move files around, 8 | # like when we made some files that were in tools/perf/ available to other tools/ 9 | # codebases by moving it to tools/include/, etc. 10 | 11 | PERF=$1 12 | cd ${PERF}/../.. 13 | make perf-targz-src-pkg > /dev/null 14 | TARBALL=$(ls -rt perf-*.tar.gz) 15 | TMP_DEST=$(mktemp -d) 16 | tar xf ${TARBALL} -C $TMP_DEST 17 | rm -f ${TARBALL} 18 | cd - > /dev/null 19 | make -C $TMP_DEST/perf*/tools/perf > /dev/null 20 | RC=$? 21 | rm -rf ${TMP_DEST} 22 | exit $RC 23 | -------------------------------------------------------------------------------- /libperf/tests/python-use.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | /* 3 | * Just test if we can load the python binding. 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include "tests.h" 10 | 11 | extern int verbose; 12 | 13 | int test__python_use(struct test *test __maybe_unused, int subtest __maybe_unused) 14 | { 15 | char *cmd; 16 | int ret; 17 | 18 | if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | %s %s", 19 | PYTHONPATH, PYTHON, verbose > 0 ? "" : "2> /dev/null") < 0) 20 | return -1; 21 | 22 | ret = system(cmd) ? -1 : 0; 23 | free(cmd); 24 | return ret; 25 | } 26 | -------------------------------------------------------------------------------- /libperf/tests/shell/lib/probe.sh: -------------------------------------------------------------------------------- 1 | # Arnaldo Carvalho de Melo , 2017 2 | 3 | skip_if_no_perf_probe() { 4 | perf probe 2>&1 | grep -q 'is not a perf-command' && return 2 5 | return 0 6 | } 7 | -------------------------------------------------------------------------------- /libperf/tests/shell/lib/probe_vfs_getname.sh: -------------------------------------------------------------------------------- 1 | # Arnaldo Carvalho de Melo , 2017 2 | 3 | perf probe -l 2>&1 | grep -q probe:vfs_getname 4 | had_vfs_getname=$? 5 | 6 | cleanup_probe_vfs_getname() { 7 | if [ $had_vfs_getname -eq 1 ] ; then 8 | perf probe -q -d probe:vfs_getname 9 | fi 10 | } 11 | 12 | add_probe_vfs_getname() { 13 | local verbose=$1 14 | if [ $had_vfs_getname -eq 1 ] ; then 15 | line=$(perf probe -L getname_flags 2>&1 | egrep 'result.*=.*filename;' | sed -r 's/[[:space:]]+([[:digit:]]+)[[:space:]]+result->uptr.*/\1/') 16 | perf probe $verbose "vfs_getname=getname_flags:${line} pathname=result->name:string" 17 | fi 18 | } 19 | 20 | skip_if_no_debuginfo() { 21 | add_probe_vfs_getname -v 2>&1 | egrep -q "^(Failed to find the path for kernel|Debuginfo-analysis is not supported)" && return 2 22 | return 1 23 | } 24 | -------------------------------------------------------------------------------- /libperf/tests/shell/probe_vfs_getname.sh: -------------------------------------------------------------------------------- 1 | # Add vfs_getname probe to get syscall args filenames 2 | # 3 | # Arnaldo Carvalho de Melo , 2017 4 | 5 | . $(dirname $0)/lib/probe.sh 6 | 7 | skip_if_no_perf_probe || exit 2 8 | 9 | . $(dirname $0)/lib/probe_vfs_getname.sh 10 | 11 | add_probe_vfs_getname || skip_if_no_debuginfo 12 | err=$? 13 | cleanup_probe_vfs_getname 14 | exit $err 15 | -------------------------------------------------------------------------------- /libperf/tests/shell/record+script_probe_vfs_getname.sh: -------------------------------------------------------------------------------- 1 | # Use vfs_getname probe to get syscall args filenames 2 | 3 | # Uses the 'perf test shell' library to add probe:vfs_getname to the system 4 | # then use it with 'perf record' using 'touch' to write to a temp file, then 5 | # checks that that was captured by the vfs_getname probe in the generated 6 | # perf.data file, with the temp file name as the pathname argument. 7 | 8 | # Arnaldo Carvalho de Melo , 2017 9 | 10 | . $(dirname $0)/lib/probe.sh 11 | 12 | skip_if_no_perf_probe || exit 2 13 | 14 | . $(dirname $0)/lib/probe_vfs_getname.sh 15 | 16 | perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) 17 | file=$(mktemp /tmp/temporary_file.XXXXX) 18 | 19 | record_open_file() { 20 | echo "Recording open file:" 21 | perf record -o ${perfdata} -e probe:vfs_getname touch $file 22 | } 23 | 24 | perf_script_filenames() { 25 | echo "Looking at perf.data file for vfs_getname records for the file we touched:" 26 | perf script -i ${perfdata} | \ 27 | egrep " +touch +[0-9]+ +\[[0-9]+\] +[0-9]+\.[0-9]+: +probe:vfs_getname: +\([[:xdigit:]]+\) +pathname=\"${file}\"" 28 | } 29 | 30 | add_probe_vfs_getname || skip_if_no_debuginfo 31 | err=$? 32 | if [ $err -ne 0 ] ; then 33 | exit $err 34 | fi 35 | 36 | record_open_file && perf_script_filenames 37 | err=$? 38 | rm -f ${perfdata} 39 | rm -f ${file} 40 | cleanup_probe_vfs_getname 41 | exit $err 42 | -------------------------------------------------------------------------------- /libperf/tests/shell/trace+probe_vfs_getname.sh: -------------------------------------------------------------------------------- 1 | # Check open filename arg using perf trace + vfs_getname 2 | 3 | # Uses the 'perf test shell' library to add probe:vfs_getname to the system 4 | # then use it with 'perf trace' using 'touch' to write to a temp file, then 5 | # checks that that was captured by the vfs_getname was used by 'perf trace', 6 | # that already handles "probe:vfs_getname" if present, and used in the 7 | # "open" syscall "filename" argument beautifier. 8 | 9 | # Arnaldo Carvalho de Melo , 2017 10 | 11 | . $(dirname $0)/lib/probe.sh 12 | 13 | skip_if_no_perf_probe || exit 2 14 | 15 | . $(dirname $0)/lib/probe_vfs_getname.sh 16 | 17 | file=$(mktemp /tmp/temporary_file.XXXXX) 18 | 19 | trace_open_vfs_getname() { 20 | test "$(uname -m)" = s390x && { svc="openat"; txt="dfd: +CWD, +"; } 21 | 22 | perf trace -e ${svc:-open} touch $file 2>&1 | \ 23 | egrep " +[0-9]+\.[0-9]+ +\( +[0-9]+\.[0-9]+ ms\): +touch\/[0-9]+ ${svc:-open}\(${txt}filename: +${file}, +flags: CREAT\|NOCTTY\|NONBLOCK\|WRONLY, +mode: +IRUGO\|IWUGO\) += +[0-9]+$" 24 | } 25 | 26 | 27 | add_probe_vfs_getname || skip_if_no_debuginfo 28 | err=$? 29 | if [ $err -ne 0 ] ; then 30 | exit $err 31 | fi 32 | 33 | trace_open_vfs_getname 34 | err=$? 35 | rm -f ${file} 36 | cleanup_probe_vfs_getname 37 | exit $err 38 | -------------------------------------------------------------------------------- /libperf/tests/unit_number__scnprintf.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include 4 | #include 5 | #include "tests.h" 6 | #include "units.h" 7 | #include "debug.h" 8 | 9 | int test__unit_number__scnprint(struct test *t __maybe_unused, int subtest __maybe_unused) 10 | { 11 | struct { 12 | u64 n; 13 | const char *str; 14 | } test[] = { 15 | { 1, "1B" }, 16 | { 10*1024, "10K" }, 17 | { 20*1024*1024, "20M" }, 18 | { 30*1024*1024*1024ULL, "30G" }, 19 | { 0, "0B" }, 20 | { 0, NULL }, 21 | }; 22 | unsigned i = 0; 23 | 24 | while (test[i].str) { 25 | char buf[100]; 26 | 27 | unit_number__scnprintf(buf, sizeof(buf), test[i].n); 28 | 29 | pr_debug("n %" PRIu64 ", str '%s', buf '%s'\n", 30 | test[i].n, test[i].str, buf); 31 | 32 | if (strcmp(test[i].str, buf)) 33 | return TEST_FAIL; 34 | 35 | i++; 36 | } 37 | 38 | return TEST_OK; 39 | } 40 | -------------------------------------------------------------------------------- /libperf/trace/beauty/Build: -------------------------------------------------------------------------------- 1 | libperf-y += clone.o 2 | libperf-y += fcntl.o 3 | ifeq ($(SRCARCH),$(filter $(SRCARCH),x86)) 4 | libperf-y += ioctl.o 5 | endif 6 | libperf-y += kcmp.o 7 | libperf-y += pkey_alloc.o 8 | libperf-y += prctl.o 9 | libperf-y += statx.o 10 | -------------------------------------------------------------------------------- /libperf/trace/beauty/drm_ioctl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | drm_header_dir=$1 4 | printf "#ifndef DRM_COMMAND_BASE\n" 5 | grep "#define DRM_COMMAND_BASE" $drm_header_dir/drm.h 6 | printf "#endif\n" 7 | 8 | printf "static const char *drm_ioctl_cmds[] = {\n" 9 | grep "^#define DRM_IOCTL.*DRM_IO" $drm_header_dir/drm.h | \ 10 | sed -r 's/^#define +DRM_IOCTL_([A-Z0-9_]+)[ ]+DRM_IO[A-Z]* *\( *(0x[[:xdigit:]]+),*.*/ [\2] = "\1",/g' 11 | grep "^#define DRM_I915_[A-Z_0-9]\+[ ]\+0x" $drm_header_dir/i915_drm.h | \ 12 | sed -r 's/^#define +DRM_I915_([A-Z0-9_]+)[ ]+(0x[[:xdigit:]]+)/\t[DRM_COMMAND_BASE + \2] = "I915_\1",/g' 13 | printf "};\n" 14 | -------------------------------------------------------------------------------- /libperf/trace/beauty/eventfd.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #ifndef EFD_SEMAPHORE 3 | #define EFD_SEMAPHORE 1 4 | #endif 5 | 6 | #ifndef EFD_NONBLOCK 7 | #define EFD_NONBLOCK 00004000 8 | #endif 9 | 10 | #ifndef EFD_CLOEXEC 11 | #define EFD_CLOEXEC 02000000 12 | #endif 13 | 14 | static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg) 15 | { 16 | int printed = 0, flags = arg->val; 17 | 18 | if (flags == 0) 19 | return scnprintf(bf, size, "NONE"); 20 | #define P_FLAG(n) \ 21 | if (flags & EFD_##n) { \ 22 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 23 | flags &= ~EFD_##n; \ 24 | } 25 | 26 | P_FLAG(SEMAPHORE); 27 | P_FLAG(CLOEXEC); 28 | P_FLAG(NONBLOCK); 29 | #undef P_FLAG 30 | 31 | if (flags) 32 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); 33 | 34 | return printed; 35 | } 36 | 37 | #define SCA_EFD_FLAGS syscall_arg__scnprintf_eventfd_flags 38 | -------------------------------------------------------------------------------- /libperf/trace/beauty/flock.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | 4 | #ifndef LOCK_MAND 5 | #define LOCK_MAND 32 6 | #endif 7 | 8 | #ifndef LOCK_READ 9 | #define LOCK_READ 64 10 | #endif 11 | 12 | #ifndef LOCK_WRITE 13 | #define LOCK_WRITE 128 14 | #endif 15 | 16 | #ifndef LOCK_RW 17 | #define LOCK_RW 192 18 | #endif 19 | 20 | static size_t syscall_arg__scnprintf_flock(char *bf, size_t size, 21 | struct syscall_arg *arg) 22 | { 23 | int printed = 0, op = arg->val; 24 | 25 | if (op == 0) 26 | return scnprintf(bf, size, "NONE"); 27 | #define P_CMD(cmd) \ 28 | if ((op & LOCK_##cmd) == LOCK_##cmd) { \ 29 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \ 30 | op &= ~LOCK_##cmd; \ 31 | } 32 | 33 | P_CMD(SH); 34 | P_CMD(EX); 35 | P_CMD(NB); 36 | P_CMD(UN); 37 | P_CMD(MAND); 38 | P_CMD(RW); 39 | P_CMD(READ); 40 | P_CMD(WRITE); 41 | #undef P_OP 42 | 43 | if (op) 44 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", op); 45 | 46 | return printed; 47 | } 48 | 49 | #define SCA_FLOCK syscall_arg__scnprintf_flock 50 | -------------------------------------------------------------------------------- /libperf/trace/beauty/kcmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * trace/beauty/kcmp.c 3 | * 4 | * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo 5 | * 6 | * Released under the GPL v2. (and only v2, not any later version) 7 | */ 8 | 9 | #include "trace/beauty/beauty.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "trace/beauty/generated/kcmp_type_array.c" 16 | 17 | size_t syscall_arg__scnprintf_kcmp_idx(char *bf, size_t size, struct syscall_arg *arg) 18 | { 19 | unsigned long fd = arg->val; 20 | int type = syscall_arg__val(arg, 2); 21 | pid_t pid; 22 | 23 | if (type != KCMP_FILE) 24 | return syscall_arg__scnprintf_long(bf, size, arg); 25 | 26 | pid = syscall_arg__val(arg, arg->idx == 3 ? 0 : 1); /* idx1 -> pid1, idx2 -> pid2 */ 27 | return pid__scnprintf_fd(arg->trace, pid, fd, bf, size); 28 | } 29 | 30 | static size_t kcmp__scnprintf_type(int type, char *bf, size_t size) 31 | { 32 | static DEFINE_STRARRAY(kcmp_types); 33 | return strarray__scnprintf(&strarray__kcmp_types, bf, size, "%d", type); 34 | } 35 | 36 | size_t syscall_arg__scnprintf_kcmp_type(char *bf, size_t size, struct syscall_arg *arg) 37 | { 38 | unsigned long type = arg->val; 39 | 40 | if (type != KCMP_FILE) 41 | arg->mask |= (1 << 3) | (1 << 4); /* Ignore idx1 and idx2 */ 42 | 43 | return kcmp__scnprintf_type(type, bf, size); 44 | } 45 | -------------------------------------------------------------------------------- /libperf/trace/beauty/kcmp_type.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | header_dir=$1 4 | 5 | printf "static const char *kcmp_types[] = {\n" 6 | regex='^[[:space:]]+(KCMP_(\w+)),' 7 | egrep $regex ${header_dir}/kcmp.h | grep -v KCMP_TYPES, | \ 8 | sed -r "s/$regex/\1 \2/g" | \ 9 | xargs printf "\t[%s]\t= \"%s\",\n" 10 | printf "};\n" 11 | -------------------------------------------------------------------------------- /libperf/trace/beauty/kvm_ioctl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | kvm_header_dir=$1 4 | 5 | printf "static const char *kvm_ioctl_cmds[] = {\n" 6 | regex='^#[[:space:]]*define[[:space:]]+KVM_(\w+)[[:space:]]+_IO[RW]*\([[:space:]]*KVMIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*' 7 | egrep $regex ${kvm_header_dir}/kvm.h | \ 8 | sed -r "s/$regex/\2 \1/g" | \ 9 | egrep -v " ((ARM|PPC|S390)_|[GS]ET_(DEBUGREGS|PIT2|XSAVE|TSC_KHZ)|CREATE_SPAPR_TCE_64)" | \ 10 | sort | xargs printf "\t[%s] = \"%s\",\n" 11 | printf "};\n" 12 | -------------------------------------------------------------------------------- /libperf/trace/beauty/madvise_behavior.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | header_dir=$1 4 | 5 | printf "static const char *madvise_advices[] = {\n" 6 | regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MADV_([[:alnum:]_]+)[[:space:]]+([[:digit:]]+)[[:space:]]*.*' 7 | egrep $regex ${header_dir}/mman-common.h | \ 8 | sed -r "s/$regex/\2 \1/g" | \ 9 | sort -n | xargs printf "\t[%s] = \"%s\",\n" 10 | printf "};\n" 11 | -------------------------------------------------------------------------------- /libperf/trace/beauty/perf_event_open.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #ifndef PERF_FLAG_FD_NO_GROUP 3 | # define PERF_FLAG_FD_NO_GROUP (1UL << 0) 4 | #endif 5 | 6 | #ifndef PERF_FLAG_FD_OUTPUT 7 | # define PERF_FLAG_FD_OUTPUT (1UL << 1) 8 | #endif 9 | 10 | #ifndef PERF_FLAG_PID_CGROUP 11 | # define PERF_FLAG_PID_CGROUP (1UL << 2) /* pid=cgroup id, per-cpu mode only */ 12 | #endif 13 | 14 | #ifndef PERF_FLAG_FD_CLOEXEC 15 | # define PERF_FLAG_FD_CLOEXEC (1UL << 3) /* O_CLOEXEC */ 16 | #endif 17 | 18 | static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, 19 | struct syscall_arg *arg) 20 | { 21 | int printed = 0, flags = arg->val; 22 | 23 | if (flags == 0) 24 | return 0; 25 | 26 | #define P_FLAG(n) \ 27 | if (flags & PERF_FLAG_##n) { \ 28 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 29 | flags &= ~PERF_FLAG_##n; \ 30 | } 31 | 32 | P_FLAG(FD_NO_GROUP); 33 | P_FLAG(FD_OUTPUT); 34 | P_FLAG(PID_CGROUP); 35 | P_FLAG(FD_CLOEXEC); 36 | #undef P_FLAG 37 | 38 | if (flags) 39 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); 40 | 41 | return printed; 42 | } 43 | 44 | #define SCA_PERF_FLAGS syscall_arg__scnprintf_perf_flags 45 | -------------------------------------------------------------------------------- /libperf/trace/beauty/perf_ioctl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | header_dir=$1 4 | 5 | printf "static const char *perf_ioctl_cmds[] = {\n" 6 | regex='^#[[:space:]]*define[[:space:]]+PERF_EVENT_IOC_(\w+)[[:space:]]+_IO[RW]*[[:space:]]*\([[:space:]]*.\$.[[:space:]]*,[[:space:]]*([[:digit:]]+).*' 7 | egrep $regex ${header_dir}/perf_event.h | \ 8 | sed -r "s/$regex/\2 \1/g" | \ 9 | sort | xargs printf "\t[%s] = \"%s\",\n" 10 | printf "};\n" 11 | -------------------------------------------------------------------------------- /libperf/trace/beauty/pid.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | size_t syscall_arg__scnprintf_pid(char *bf, size_t size, struct syscall_arg *arg) 3 | { 4 | int pid = arg->val; 5 | struct trace *trace = arg->trace; 6 | size_t printed = scnprintf(bf, size, "%d", pid); 7 | struct thread *thread = machine__findnew_thread(trace->host, pid, pid); 8 | 9 | if (thread != NULL) { 10 | if (!thread->comm_set) 11 | thread__set_comm_from_proc(thread); 12 | 13 | if (thread->comm_set) 14 | printed += scnprintf(bf + printed, size - printed, 15 | " (%s)", thread__comm_str(thread)); 16 | thread__put(thread); 17 | } 18 | 19 | return printed; 20 | } 21 | -------------------------------------------------------------------------------- /libperf/trace/beauty/pkey_alloc_access_rights.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | header_dir=$1 4 | 5 | printf "static const char *pkey_alloc_access_rights[] = {\n" 6 | regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+PKEY_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*' 7 | egrep $regex ${header_dir}/mman-common.h | \ 8 | sed -r "s/$regex/\2 \2 \1/g" | \ 9 | sort | xargs printf "\t[%s ? (ilog2(%s) + 1) : 0] = \"%s\",\n" 10 | printf "};\n" 11 | -------------------------------------------------------------------------------- /libperf/trace/beauty/prctl_option.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | header_dir=$1 4 | 5 | printf "static const char *prctl_options[] = {\n" 6 | regex='^#define[[:space:]]+PR_([GS]ET\w+)[[:space:]]*([[:xdigit:]]+).*' 7 | egrep $regex ${header_dir}/prctl.h | grep -v PR_SET_PTRACER | \ 8 | sed -r "s/$regex/\2 \1/g" | \ 9 | sort -n | xargs printf "\t[%s] = \"%s\",\n" 10 | printf "};\n" 11 | 12 | printf "static const char *prctl_set_mm_options[] = {\n" 13 | regex='^#[[:space:]]+define[[:space:]]+PR_SET_MM_(\w+)[[:space:]]*([[:digit:]]+).*' 14 | egrep $regex ${header_dir}/prctl.h | \ 15 | sed -r "s/$regex/\2 \1/g" | \ 16 | sort -n | xargs printf "\t[%s] = \"%s\",\n" 17 | printf "};\n" 18 | -------------------------------------------------------------------------------- /libperf/trace/beauty/sched_policy.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | 4 | /* 5 | * Not defined anywhere else, probably, just to make sure we 6 | * catch future flags 7 | */ 8 | #define SCHED_POLICY_MASK 0xff 9 | 10 | #ifndef SCHED_DEADLINE 11 | #define SCHED_DEADLINE 6 12 | #endif 13 | #ifndef SCHED_RESET_ON_FORK 14 | #define SCHED_RESET_ON_FORK 0x40000000 15 | #endif 16 | 17 | static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size, 18 | struct syscall_arg *arg) 19 | { 20 | const char *policies[] = { 21 | "NORMAL", "FIFO", "RR", "BATCH", "ISO", "IDLE", "DEADLINE", 22 | }; 23 | size_t printed; 24 | int policy = arg->val, 25 | flags = policy & ~SCHED_POLICY_MASK; 26 | 27 | policy &= SCHED_POLICY_MASK; 28 | if (policy <= SCHED_DEADLINE) 29 | printed = scnprintf(bf, size, "%s", policies[policy]); 30 | else 31 | printed = scnprintf(bf, size, "%#x", policy); 32 | 33 | #define P_POLICY_FLAG(n) \ 34 | if (flags & SCHED_##n) { \ 35 | printed += scnprintf(bf + printed, size - printed, "|%s", #n); \ 36 | flags &= ~SCHED_##n; \ 37 | } 38 | 39 | P_POLICY_FLAG(RESET_ON_FORK); 40 | #undef P_POLICY_FLAG 41 | 42 | if (flags) 43 | printed += scnprintf(bf + printed, size - printed, "|%#x", flags); 44 | 45 | return printed; 46 | } 47 | 48 | #define SCA_SCHED_POLICY syscall_arg__scnprintf_sched_policy 49 | -------------------------------------------------------------------------------- /libperf/trace/beauty/signum.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | 4 | static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg) 5 | { 6 | int sig = arg->val; 7 | 8 | switch (sig) { 9 | #define P_SIGNUM(n) case SIG##n: return scnprintf(bf, size, #n) 10 | P_SIGNUM(HUP); 11 | P_SIGNUM(INT); 12 | P_SIGNUM(QUIT); 13 | P_SIGNUM(ILL); 14 | P_SIGNUM(TRAP); 15 | P_SIGNUM(ABRT); 16 | P_SIGNUM(BUS); 17 | P_SIGNUM(FPE); 18 | P_SIGNUM(KILL); 19 | P_SIGNUM(USR1); 20 | P_SIGNUM(SEGV); 21 | P_SIGNUM(USR2); 22 | P_SIGNUM(PIPE); 23 | P_SIGNUM(ALRM); 24 | P_SIGNUM(TERM); 25 | P_SIGNUM(CHLD); 26 | P_SIGNUM(CONT); 27 | P_SIGNUM(STOP); 28 | P_SIGNUM(TSTP); 29 | P_SIGNUM(TTIN); 30 | P_SIGNUM(TTOU); 31 | P_SIGNUM(URG); 32 | P_SIGNUM(XCPU); 33 | P_SIGNUM(XFSZ); 34 | P_SIGNUM(VTALRM); 35 | P_SIGNUM(PROF); 36 | P_SIGNUM(WINCH); 37 | P_SIGNUM(IO); 38 | P_SIGNUM(PWR); 39 | P_SIGNUM(SYS); 40 | #ifdef SIGEMT 41 | P_SIGNUM(EMT); 42 | #endif 43 | #ifdef SIGSTKFLT 44 | P_SIGNUM(STKFLT); 45 | #endif 46 | #ifdef SIGSWI 47 | P_SIGNUM(SWI); 48 | #endif 49 | default: break; 50 | } 51 | 52 | return scnprintf(bf, size, "%#x", sig); 53 | } 54 | 55 | #define SCA_SIGNUM syscall_arg__scnprintf_signum 56 | -------------------------------------------------------------------------------- /libperf/trace/beauty/sndrv_ctl_ioctl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sound_header_dir=$1 4 | 5 | printf "static const char *sndrv_ctl_ioctl_cmds[] = {\n" 6 | grep "^#define[\t ]\+SNDRV_CTL_IOCTL_" $sound_header_dir/asound.h | \ 7 | sed -r 's/^#define +SNDRV_CTL_IOCTL_([A-Z0-9_]+)[\t ]+_IO[RW]*\( *.U., *(0x[[:xdigit:]]+),?.*/\t[\2] = \"\1\",/g' 8 | printf "};\n" 9 | -------------------------------------------------------------------------------- /libperf/trace/beauty/sndrv_pcm_ioctl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sound_header_dir=$1 4 | 5 | printf "static const char *sndrv_pcm_ioctl_cmds[] = {\n" 6 | grep "^#define[\t ]\+SNDRV_PCM_IOCTL_" $sound_header_dir/asound.h | \ 7 | sed -r 's/^#define +SNDRV_PCM_IOCTL_([A-Z0-9_]+)[\t ]+_IO[RW]*\( *.A., *(0x[[:xdigit:]]+),?.*/\t[\2] = \"\1\",/g' 8 | printf "};\n" 9 | -------------------------------------------------------------------------------- /libperf/trace/beauty/vhost_virtio_ioctl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | vhost_virtio_header_dir=$1 4 | 5 | printf "static const char *vhost_virtio_ioctl_cmds[] = {\n" 6 | regex='^#[[:space:]]*define[[:space:]]+VHOST_(\w+)[[:space:]]+_IOW?\([[:space:]]*VHOST_VIRTIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*' 7 | egrep $regex ${vhost_virtio_header_dir}/vhost.h | \ 8 | sed -r "s/$regex/\2 \1/g" | \ 9 | sort | xargs printf "\t[%s] = \"%s\",\n" 10 | printf "};\n" 11 | 12 | printf "static const char *vhost_virtio_ioctl_read_cmds[] = {\n" 13 | regex='^#[[:space:]]*define[[:space:]]+VHOST_(\w+)[[:space:]]+_IOW?R\([[:space:]]*VHOST_VIRTIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*' 14 | egrep $regex ${vhost_virtio_header_dir}/vhost.h | \ 15 | sed -r "s/$regex/\2 \1/g" | \ 16 | sort | xargs printf "\t[%s] = \"%s\",\n" 17 | printf "};\n" 18 | -------------------------------------------------------------------------------- /libperf/trace/beauty/waitid_options.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include 4 | 5 | static size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, 6 | struct syscall_arg *arg) 7 | { 8 | int printed = 0, options = arg->val; 9 | 10 | #define P_OPTION(n) \ 11 | if (options & W##n) { \ 12 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 13 | options &= ~W##n; \ 14 | } 15 | 16 | P_OPTION(NOHANG); 17 | P_OPTION(UNTRACED); 18 | P_OPTION(CONTINUED); 19 | #undef P_OPTION 20 | 21 | if (options) 22 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", options); 23 | 24 | return printed; 25 | } 26 | 27 | #define SCA_WAITID_OPTIONS syscall_arg__scnprintf_waitid_options 28 | -------------------------------------------------------------------------------- /libperf/trace/strace/groups/file: -------------------------------------------------------------------------------- 1 | access 2 | chmod 3 | creat 4 | execve 5 | faccessat 6 | getcwd 7 | lstat 8 | mkdir 9 | open 10 | openat 11 | quotactl 12 | read 13 | readlink 14 | rename 15 | rmdir 16 | stat 17 | statfs 18 | symlink 19 | unlink 20 | write 21 | -------------------------------------------------------------------------------- /libperf/ui/Build: -------------------------------------------------------------------------------- 1 | libperf-y += setup.o 2 | libperf-y += helpline.o 3 | libperf-y += progress.o 4 | libperf-y += util.o 5 | libperf-y += hist.o 6 | libperf-y += stdio/hist.o 7 | 8 | CFLAGS_setup.o += -DLIBDIR="BUILD_STR($(LIBDIR))" 9 | 10 | libperf-$(CONFIG_SLANG) += browser.o 11 | libperf-$(CONFIG_SLANG) += browsers/ 12 | libperf-$(CONFIG_SLANG) += tui/ 13 | 14 | CFLAGS_browser.o += -DENABLE_SLFUTURE_CONST 15 | -------------------------------------------------------------------------------- /libperf/ui/browsers/Build: -------------------------------------------------------------------------------- 1 | libperf-y += annotate.o 2 | libperf-y += hists.o 3 | libperf-y += map.o 4 | libperf-y += scripts.o 5 | libperf-y += header.o 6 | 7 | CFLAGS_annotate.o += -DENABLE_SLFUTURE_CONST 8 | CFLAGS_hists.o += -DENABLE_SLFUTURE_CONST 9 | CFLAGS_map.o += -DENABLE_SLFUTURE_CONST 10 | CFLAGS_scripts.o += -DENABLE_SLFUTURE_CONST 11 | -------------------------------------------------------------------------------- /libperf/ui/browsers/hists.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_UI_BROWSER_HISTS_H_ 3 | #define _PERF_UI_BROWSER_HISTS_H_ 1 4 | 5 | #include "ui/browser.h" 6 | 7 | struct hist_browser { 8 | struct ui_browser b; 9 | struct hists *hists; 10 | struct hist_entry *he_selection; 11 | struct map_symbol *selection; 12 | struct hist_browser_timer *hbt; 13 | struct pstack *pstack; 14 | struct perf_env *env; 15 | int print_seq; 16 | bool show_dso; 17 | bool show_headers; 18 | float min_pcnt; 19 | u64 nr_non_filtered_entries; 20 | u64 nr_hierarchy_entries; 21 | u64 nr_callchain_rows; 22 | bool c2c_filter; 23 | 24 | /* Get title string. */ 25 | int (*title)(struct hist_browser *browser, 26 | char *bf, size_t size); 27 | }; 28 | 29 | struct hist_browser *hist_browser__new(struct hists *hists); 30 | void hist_browser__delete(struct hist_browser *browser); 31 | int hist_browser__run(struct hist_browser *browser, const char *help); 32 | void hist_browser__init(struct hist_browser *browser, 33 | struct hists *hists); 34 | #endif /* _PERF_UI_BROWSER_HISTS_H_ */ 35 | -------------------------------------------------------------------------------- /libperf/ui/browsers/map.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_UI_MAP_BROWSER_H_ 3 | #define _PERF_UI_MAP_BROWSER_H_ 1 4 | struct map; 5 | 6 | int map__browse(struct map *map); 7 | #endif /* _PERF_UI_MAP_BROWSER_H_ */ 8 | -------------------------------------------------------------------------------- /libperf/ui/gtk/Build: -------------------------------------------------------------------------------- 1 | CFLAGS_gtk += -fPIC $(GTK_CFLAGS) 2 | 3 | gtk-y += browser.o 4 | gtk-y += hists.o 5 | gtk-y += setup.o 6 | gtk-y += util.o 7 | gtk-y += helpline.o 8 | gtk-y += progress.o 9 | gtk-y += annotate.o 10 | -------------------------------------------------------------------------------- /libperf/ui/gtk/setup.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include "gtk.h" 3 | #include "../../util/cache.h" 4 | #include "../../util/debug.h" 5 | 6 | extern struct perf_error_ops perf_gtk_eops; 7 | 8 | int perf_gtk__init(void) 9 | { 10 | perf_error__register(&perf_gtk_eops); 11 | perf_gtk__init_helpline(); 12 | gtk_ui_progress__init(); 13 | perf_gtk__init_hpp(); 14 | 15 | return gtk_init_check(NULL, NULL) ? 0 : -1; 16 | } 17 | 18 | void perf_gtk__exit(bool wait_for_ok __maybe_unused) 19 | { 20 | if (!perf_gtk__is_active_context(pgctx)) 21 | return; 22 | perf_error__unregister(&perf_gtk_eops); 23 | gtk_main_quit(); 24 | } 25 | -------------------------------------------------------------------------------- /libperf/ui/helpline.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_UI_HELPLINE_H_ 3 | #define _PERF_UI_HELPLINE_H_ 1 4 | 5 | #include 6 | #include 7 | 8 | #include "../util/cache.h" 9 | 10 | struct ui_helpline { 11 | void (*pop)(void); 12 | void (*push)(const char *msg); 13 | int (*show)(const char *fmt, va_list ap); 14 | }; 15 | 16 | extern struct ui_helpline *helpline_fns; 17 | 18 | void ui_helpline__init(void); 19 | 20 | void ui_helpline__pop(void); 21 | void ui_helpline__push(const char *msg); 22 | void ui_helpline__vpush(const char *fmt, va_list ap); 23 | void ui_helpline__fpush(const char *fmt, ...); 24 | void ui_helpline__puts(const char *msg); 25 | void ui_helpline__printf(const char *fmt, ...); 26 | int ui_helpline__vshow(const char *fmt, va_list ap); 27 | 28 | extern char ui_helpline__current[512]; 29 | extern char ui_helpline__last_msg[]; 30 | 31 | #endif /* _PERF_UI_HELPLINE_H_ */ 32 | -------------------------------------------------------------------------------- /libperf/ui/keysyms.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_KEYSYMS_H_ 3 | #define _PERF_KEYSYMS_H_ 1 4 | 5 | #include "libslang.h" 6 | 7 | #define K_DOWN SL_KEY_DOWN 8 | #define K_END SL_KEY_END 9 | #define K_ENTER '\r' 10 | #define K_ESC 033 11 | #define K_F1 SL_KEY_F(1) 12 | #define K_HOME SL_KEY_HOME 13 | #define K_LEFT SL_KEY_LEFT 14 | #define K_PGDN SL_KEY_NPAGE 15 | #define K_PGUP SL_KEY_PPAGE 16 | #define K_RIGHT SL_KEY_RIGHT 17 | #define K_TAB '\t' 18 | #define K_UNTAB SL_KEY_UNTAB 19 | #define K_UP SL_KEY_UP 20 | #define K_BKSPC 0x7f 21 | #define K_DEL SL_KEY_DELETE 22 | 23 | /* Not really keys */ 24 | #define K_TIMER -1 25 | #define K_ERROR -2 26 | #define K_RESIZE -3 27 | #define K_SWITCH_INPUT_DATA -4 28 | 29 | #endif /* _PERF_KEYSYMS_H_ */ 30 | -------------------------------------------------------------------------------- /libperf/ui/libslang.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_UI_SLANG_H_ 3 | #define _PERF_UI_SLANG_H_ 1 4 | /* 5 | * slang versions <= 2.0.6 have a "#if HAVE_LONG_LONG" that breaks 6 | * the build if it isn't defined. Use the equivalent one that glibc 7 | * has on features.h. 8 | */ 9 | #include 10 | #ifndef HAVE_LONG_LONG 11 | #define HAVE_LONG_LONG __GLIBC_HAVE_LONG_LONG 12 | #endif 13 | #include 14 | 15 | #if SLANG_VERSION < 20104 16 | #define slsmg_printf(msg, args...) \ 17 | SLsmg_printf((char *)(msg), ##args) 18 | #define slsmg_vprintf(msg, vargs) \ 19 | SLsmg_vprintf((char *)(msg), vargs) 20 | #define slsmg_write_nstring(msg, len) \ 21 | SLsmg_write_nstring((char *)(msg), len) 22 | #define sltt_set_color(obj, name, fg, bg) \ 23 | SLtt_set_color(obj,(char *)(name), (char *)(fg), (char *)(bg)) 24 | #else 25 | #define slsmg_printf SLsmg_printf 26 | #define slsmg_vprintf SLsmg_vprintf 27 | #define slsmg_write_nstring SLsmg_write_nstring 28 | #define sltt_set_color SLtt_set_color 29 | #endif 30 | 31 | #define SL_KEY_UNTAB 0x1000 32 | 33 | #endif /* _PERF_UI_SLANG_H_ */ 34 | -------------------------------------------------------------------------------- /libperf/ui/progress.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include "../cache.h" 4 | #include "progress.h" 5 | 6 | static void null_progress__update(struct ui_progress *p __maybe_unused) 7 | { 8 | } 9 | 10 | static struct ui_progress_ops null_progress__ops = 11 | { 12 | .update = null_progress__update, 13 | }; 14 | 15 | struct ui_progress_ops *ui_progress__ops = &null_progress__ops; 16 | 17 | void ui_progress__update(struct ui_progress *p, u64 adv) 18 | { 19 | u64 last = p->curr; 20 | 21 | p->curr += adv; 22 | 23 | if (p->curr >= p->next) { 24 | u64 nr = DIV_ROUND_UP(p->curr - last, p->step); 25 | 26 | p->next += nr * p->step; 27 | ui_progress__ops->update(p); 28 | } 29 | } 30 | 31 | void __ui_progress__init(struct ui_progress *p, u64 total, 32 | const char *title, bool size) 33 | { 34 | p->curr = 0; 35 | p->next = p->step = total / 16 ?: 1; 36 | p->total = total; 37 | p->title = title; 38 | p->size = size; 39 | 40 | if (ui_progress__ops->init) 41 | ui_progress__ops->init(p); 42 | } 43 | 44 | void ui_progress__finish(void) 45 | { 46 | if (ui_progress__ops->finish) 47 | ui_progress__ops->finish(); 48 | } 49 | -------------------------------------------------------------------------------- /libperf/ui/progress.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_UI_PROGRESS_H_ 3 | #define _PERF_UI_PROGRESS_H_ 1 4 | 5 | #include 6 | 7 | void ui_progress__finish(void); 8 | 9 | struct ui_progress { 10 | const char *title; 11 | u64 curr, next, step, total; 12 | bool size; 13 | }; 14 | 15 | void __ui_progress__init(struct ui_progress *p, u64 total, 16 | const char *title, bool size); 17 | 18 | #define ui_progress__init(p, total, title) \ 19 | __ui_progress__init(p, total, title, false) 20 | 21 | #define ui_progress__init_size(p, total, title) \ 22 | __ui_progress__init(p, total, title, true) 23 | 24 | void ui_progress__update(struct ui_progress *p, u64 adv); 25 | 26 | struct ui_progress_ops { 27 | void (*init)(struct ui_progress *p); 28 | void (*update)(struct ui_progress *p); 29 | void (*finish)(void); 30 | }; 31 | 32 | extern struct ui_progress_ops *ui_progress__ops; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libperf/ui/tui/Build: -------------------------------------------------------------------------------- 1 | libperf-y += setup.o 2 | libperf-y += util.o 3 | libperf-y += helpline.o 4 | libperf-y += progress.o 5 | -------------------------------------------------------------------------------- /libperf/ui/tui/tui.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_TUI_H_ 3 | #define _PERF_TUI_H_ 1 4 | 5 | void tui_progress__init(void); 6 | 7 | #endif /* _PERF_TUI_H_ */ 8 | -------------------------------------------------------------------------------- /libperf/ui/ui.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_UI_H_ 3 | #define _PERF_UI_H_ 1 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | extern pthread_mutex_t ui__lock; 10 | extern void *perf_gtk_handle; 11 | 12 | extern int use_browser; 13 | 14 | void setup_browser(bool fallback_to_pager); 15 | void exit_browser(bool wait_for_ok); 16 | 17 | #ifdef HAVE_SLANG_SUPPORT 18 | int ui__init(void); 19 | void ui__exit(bool wait_for_ok); 20 | #else 21 | static inline int ui__init(void) 22 | { 23 | return -1; 24 | } 25 | static inline void ui__exit(bool wait_for_ok __maybe_unused) {} 26 | #endif 27 | 28 | void ui__refresh_dimensions(bool force); 29 | 30 | struct option; 31 | 32 | int stdio__config_color(const struct option *opt, const char *mode, int unset); 33 | 34 | #endif /* _PERF_UI_H_ */ 35 | -------------------------------------------------------------------------------- /libperf/ui/util.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_UI_UTIL_H_ 3 | #define _PERF_UI_UTIL_H_ 1 4 | 5 | #include 6 | 7 | int ui__getch(int delay_secs); 8 | int ui__popup_menu(int argc, char * const argv[]); 9 | int ui__help_window(const char *text); 10 | int ui__dialog_yesno(const char *msg); 11 | int ui__question_window(const char *title, const char *text, 12 | const char *exit_msg, int delay_secs); 13 | 14 | struct perf_error_ops { 15 | int (*error)(const char *format, va_list args); 16 | int (*warning)(const char *format, va_list args); 17 | }; 18 | 19 | int perf_error__register(struct perf_error_ops *eops); 20 | int perf_error__unregister(struct perf_error_ops *eops); 21 | 22 | #endif /* _PERF_UI_UTIL_H_ */ 23 | -------------------------------------------------------------------------------- /libperf/util/PERF-VERSION-GEN: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # SPDX-License-Identifier: GPL-2.0 3 | 4 | if [ $# -eq 1 ] ; then 5 | OUTPUT=$1 6 | fi 7 | 8 | GVF=${OUTPUT}PERF-VERSION-FILE 9 | 10 | LF=' 11 | ' 12 | 13 | # 14 | # First check if there is a .git to get the version from git describe 15 | # otherwise try to get the version from the kernel Makefile 16 | # 17 | CID= 18 | TAG= 19 | if test -d ../../.git -o -f ../../.git 20 | then 21 | TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null ) 22 | CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID" 23 | elif test -f ../../PERF-VERSION-FILE 24 | then 25 | TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g') 26 | fi 27 | if test -z "$TAG" 28 | then 29 | TAG=$(MAKEFLAGS= make -sC ../.. kernelversion) 30 | fi 31 | VN="$TAG$CID" 32 | if test -n "$CID" 33 | then 34 | # format version string, strip trailing zero of sublevel: 35 | VN=$(echo "$VN" | sed -e 's/-/./g;s/\([0-9]*[.][0-9]*\)[.]0/\1/') 36 | fi 37 | 38 | VN=$(expr "$VN" : v*'\(.*\)') 39 | 40 | if test -r $GVF 41 | then 42 | VC=$(sed -e 's/^#define PERF_VERSION "\(.*\)"/\1/' <$GVF) 43 | else 44 | VC=unset 45 | fi 46 | test "$VN" = "$VC" || { 47 | echo >&2 " PERF_VERSION = $VN" 48 | echo "#define PERF_VERSION \"$VN\"" >$GVF 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /libperf/util/bpf-prologue.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * Copyright (C) 2015, He Kuang 4 | * Copyright (C) 2015, Huawei Inc. 5 | */ 6 | #ifndef __BPF_PROLOGUE_H 7 | #define __BPF_PROLOGUE_H 8 | 9 | #include 10 | #include 11 | #include "probe-event.h" 12 | 13 | #define BPF_PROLOGUE_MAX_ARGS 3 14 | #define BPF_PROLOGUE_START_ARG_REG BPF_REG_3 15 | #define BPF_PROLOGUE_FETCH_RESULT_REG BPF_REG_2 16 | 17 | #ifdef HAVE_BPF_PROLOGUE 18 | int bpf__gen_prologue(struct probe_trace_arg *args, int nargs, 19 | struct bpf_insn *new_prog, size_t *new_cnt, 20 | size_t cnt_space); 21 | #else 22 | #include 23 | 24 | static inline int 25 | bpf__gen_prologue(struct probe_trace_arg *args __maybe_unused, 26 | int nargs __maybe_unused, 27 | struct bpf_insn *new_prog __maybe_unused, 28 | size_t *new_cnt, 29 | size_t cnt_space __maybe_unused) 30 | { 31 | if (!new_cnt) 32 | return -EINVAL; 33 | *new_cnt = 0; 34 | return -ENOTSUP; 35 | } 36 | #endif 37 | #endif /* __BPF_PROLOGUE_H */ 38 | -------------------------------------------------------------------------------- /libperf/util/branch.h: -------------------------------------------------------------------------------- 1 | #ifndef _PERF_BRANCH_H 2 | #define _PERF_BRANCH_H 1 3 | 4 | #include 5 | #include "../perf.h" 6 | 7 | struct branch_type_stat { 8 | bool branch_to; 9 | u64 counts[PERF_BR_MAX]; 10 | u64 cond_fwd; 11 | u64 cond_bwd; 12 | u64 cross_4k; 13 | u64 cross_2m; 14 | }; 15 | 16 | struct branch_flags; 17 | 18 | void branch_type_count(struct branch_type_stat *st, struct branch_flags *flags, 19 | u64 from, u64 to); 20 | 21 | const char *branch_type_name(int type); 22 | void branch_type_stat_display(FILE *fp, struct branch_type_stat *st); 23 | int branch_type_str(struct branch_type_stat *st, char *bf, int bfsize); 24 | 25 | #endif /* _PERF_BRANCH_H */ 26 | -------------------------------------------------------------------------------- /libperf/util/c++/Build: -------------------------------------------------------------------------------- 1 | libperf-$(CONFIG_CLANGLLVM) += clang.o 2 | libperf-$(CONFIG_CLANGLLVM) += clang-test.o 3 | -------------------------------------------------------------------------------- /libperf/util/c++/clang-c.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef PERF_UTIL_CLANG_C_H 3 | #define PERF_UTIL_CLANG_C_H 4 | 5 | #include /* for size_t */ 6 | #include /* for __maybe_unused */ 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #ifdef HAVE_LIBCLANGLLVM_SUPPORT 13 | extern void perf_clang__init(void); 14 | extern void perf_clang__cleanup(void); 15 | 16 | extern int test__clang_to_IR(void); 17 | extern int test__clang_to_obj(void); 18 | 19 | extern int perf_clang__compile_bpf(const char *filename, 20 | void **p_obj_buf, 21 | size_t *p_obj_buf_sz); 22 | #else 23 | 24 | #include 25 | 26 | static inline void perf_clang__init(void) { } 27 | static inline void perf_clang__cleanup(void) { } 28 | 29 | static inline int test__clang_to_IR(void) { return -1; } 30 | static inline int test__clang_to_obj(void) { return -1;} 31 | 32 | static inline int 33 | perf_clang__compile_bpf(const char *filename __maybe_unused, 34 | void **p_obj_buf __maybe_unused, 35 | size_t *p_obj_buf_sz __maybe_unused) 36 | { 37 | return -ENOTSUP; 38 | } 39 | 40 | #endif 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif 46 | -------------------------------------------------------------------------------- /libperf/util/c++/clang.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef PERF_UTIL_CLANG_H 3 | #define PERF_UTIL_CLANG_H 4 | 5 | #include "llvm/ADT/StringRef.h" 6 | #include "llvm/IR/LLVMContext.h" 7 | #include "llvm/IR/Module.h" 8 | #include "llvm/Option/Option.h" 9 | #include 10 | 11 | namespace perf { 12 | 13 | using namespace llvm; 14 | 15 | std::unique_ptr 16 | getModuleFromSource(opt::ArgStringList CFlags, 17 | StringRef Name, StringRef Content); 18 | 19 | std::unique_ptr 20 | getModuleFromSource(opt::ArgStringList CFlags, 21 | StringRef Path); 22 | 23 | std::unique_ptr> 24 | getBPFObjectFromModule(llvm::Module *Module); 25 | 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /libperf/util/cache.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_CACHE_H 3 | #define __PERF_CACHE_H 4 | 5 | #include "strbuf.h" 6 | #include 7 | #include "../ui/ui.h" 8 | 9 | #include 10 | #include 11 | 12 | #define CMD_EXEC_PATH "--exec-path" 13 | #define CMD_DEBUGFS_DIR "--debugfs-dir=" 14 | 15 | #define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH" 16 | #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR" 17 | #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR" 18 | #define PERF_PAGER_ENVIRONMENT "PERF_PAGER" 19 | 20 | int split_cmdline(char *cmdline, const char ***argv); 21 | 22 | #define alloc_nr(x) (((x)+16)*3/2) 23 | 24 | static inline int is_absolute_path(const char *path) 25 | { 26 | return path[0] == '/'; 27 | } 28 | 29 | char *mkpath(const char *fmt, ...) __printf(1, 2); 30 | 31 | #endif /* __PERF_CACHE_H */ 32 | -------------------------------------------------------------------------------- /libperf/util/cgroup.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __CGROUP_H__ 3 | #define __CGROUP_H__ 4 | 5 | #include 6 | 7 | struct option; 8 | 9 | struct cgroup_sel { 10 | char *name; 11 | int fd; 12 | refcount_t refcnt; 13 | }; 14 | 15 | 16 | extern int nr_cgroups; /* number of explicit cgroups defined */ 17 | void close_cgroup(struct cgroup_sel *cgrp); 18 | int parse_cgroups(const struct option *opt, const char *str, int unset); 19 | 20 | #endif /* __CGROUP_H__ */ 21 | -------------------------------------------------------------------------------- /libperf/util/cloexec.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_CLOEXEC_H 3 | #define __PERF_CLOEXEC_H 4 | 5 | unsigned long perf_event_open_cloexec_flag(void); 6 | 7 | #endif /* __PERF_CLOEXEC_H */ 8 | -------------------------------------------------------------------------------- /libperf/util/comm.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_COMM_H 3 | #define __PERF_COMM_H 4 | 5 | #include "../perf.h" 6 | #include 7 | #include 8 | 9 | struct comm_str; 10 | 11 | struct comm { 12 | struct comm_str *comm_str; 13 | u64 start; 14 | struct list_head list; 15 | bool exec; 16 | union { /* Tool specific area */ 17 | void *priv; 18 | u64 db_id; 19 | }; 20 | }; 21 | 22 | void comm__free(struct comm *comm); 23 | struct comm *comm__new(const char *str, u64 timestamp, bool exec); 24 | const char *comm__str(const struct comm *comm); 25 | int comm__override(struct comm *comm, const char *str, u64 timestamp, 26 | bool exec); 27 | 28 | #endif /* __PERF_COMM_H */ 29 | -------------------------------------------------------------------------------- /libperf/util/compress.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef PERF_COMPRESS_H 3 | #define PERF_COMPRESS_H 4 | 5 | #ifdef HAVE_ZLIB_SUPPORT 6 | int gzip_decompress_to_file(const char *input, int output_fd); 7 | #endif 8 | 9 | #ifdef HAVE_LZMA_SUPPORT 10 | int lzma_decompress_to_file(const char *input, int output_fd); 11 | #endif 12 | 13 | #endif /* PERF_COMPRESS_H */ 14 | -------------------------------------------------------------------------------- /libperf/util/counts.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include 4 | #include "evsel.h" 5 | #include "counts.h" 6 | #include "util.h" 7 | 8 | struct perf_counts *perf_counts__new(int ncpus, int nthreads) 9 | { 10 | struct perf_counts *counts = zalloc(sizeof(*counts)); 11 | 12 | if (counts) { 13 | struct xyarray *values; 14 | 15 | values = xyarray__new(ncpus, nthreads, sizeof(struct perf_counts_values)); 16 | if (!values) { 17 | free(counts); 18 | return NULL; 19 | } 20 | 21 | counts->values = values; 22 | } 23 | 24 | return counts; 25 | } 26 | 27 | void perf_counts__delete(struct perf_counts *counts) 28 | { 29 | if (counts) { 30 | xyarray__delete(counts->values); 31 | free(counts); 32 | } 33 | } 34 | 35 | static void perf_counts__reset(struct perf_counts *counts) 36 | { 37 | xyarray__reset(counts->values); 38 | } 39 | 40 | void perf_evsel__reset_counts(struct perf_evsel *evsel) 41 | { 42 | perf_counts__reset(evsel->counts); 43 | } 44 | 45 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads) 46 | { 47 | evsel->counts = perf_counts__new(ncpus, nthreads); 48 | return evsel->counts != NULL ? 0 : -ENOMEM; 49 | } 50 | 51 | void perf_evsel__free_counts(struct perf_evsel *evsel) 52 | { 53 | perf_counts__delete(evsel->counts); 54 | evsel->counts = NULL; 55 | } 56 | -------------------------------------------------------------------------------- /libperf/util/counts.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_COUNTS_H 3 | #define __PERF_COUNTS_H 4 | 5 | #include "xyarray.h" 6 | 7 | struct perf_counts_values { 8 | union { 9 | struct { 10 | u64 val; 11 | u64 ena; 12 | u64 run; 13 | }; 14 | u64 values[3]; 15 | }; 16 | bool loaded; 17 | }; 18 | 19 | struct perf_counts { 20 | s8 scaled; 21 | struct perf_counts_values aggr; 22 | struct xyarray *values; 23 | }; 24 | 25 | 26 | static inline struct perf_counts_values* 27 | perf_counts(struct perf_counts *counts, int cpu, int thread) 28 | { 29 | return xyarray__entry(counts->values, cpu, thread); 30 | } 31 | 32 | struct perf_counts *perf_counts__new(int ncpus, int nthreads); 33 | void perf_counts__delete(struct perf_counts *counts); 34 | 35 | void perf_evsel__reset_counts(struct perf_evsel *evsel); 36 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads); 37 | void perf_evsel__free_counts(struct perf_evsel *evsel); 38 | 39 | #endif /* __PERF_COUNTS_H */ 40 | -------------------------------------------------------------------------------- /libperf/util/data-convert-bt.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __DATA_CONVERT_BT_H 3 | #define __DATA_CONVERT_BT_H 4 | #include "data-convert.h" 5 | #ifdef HAVE_LIBBABELTRACE_SUPPORT 6 | 7 | int bt_convert__perf2ctf(const char *input_name, const char *to_ctf, 8 | struct perf_data_convert_opts *opts); 9 | 10 | #endif /* HAVE_LIBBABELTRACE_SUPPORT */ 11 | #endif /* __DATA_CONVERT_BT_H */ 12 | -------------------------------------------------------------------------------- /libperf/util/data-convert.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __DATA_CONVERT_H 3 | #define __DATA_CONVERT_H 4 | 5 | struct perf_data_convert_opts { 6 | bool force; 7 | bool all; 8 | }; 9 | 10 | #endif /* __DATA_CONVERT_H */ 11 | -------------------------------------------------------------------------------- /libperf/util/demangle-java.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_DEMANGLE_JAVA 3 | #define __PERF_DEMANGLE_JAVA 1 4 | /* 5 | * demangle function flags 6 | */ 7 | #define JAVA_DEMANGLE_NORET 0x1 /* do not process return type */ 8 | 9 | char * java_demangle_sym(const char *str, int flags); 10 | 11 | #endif /* __PERF_DEMANGLE_JAVA */ 12 | -------------------------------------------------------------------------------- /libperf/util/demangle-rust.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_DEMANGLE_RUST 3 | #define __PERF_DEMANGLE_RUST 1 4 | 5 | bool rust_is_mangled(const char *str); 6 | void rust_demangle_sym(char *str); 7 | 8 | #endif /* __PERF_DEMANGLE_RUST */ 9 | -------------------------------------------------------------------------------- /libperf/util/drv_configs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * drv_configs.h: Interface to apply PMU specific configuration 3 | * Copyright (c) 2016-2018, Linaro Ltd. 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | */ 15 | 16 | #ifndef __PERF_DRV_CONFIGS_H 17 | #define __PERF_DRV_CONFIGS_H 18 | 19 | #include "drv_configs.h" 20 | #include "evlist.h" 21 | #include "evsel.h" 22 | 23 | int perf_evlist__apply_drv_configs(struct perf_evlist *evlist, 24 | struct perf_evsel **err_evsel, 25 | struct perf_evsel_config_term **term); 26 | #endif 27 | -------------------------------------------------------------------------------- /libperf/util/dump-insn.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include "dump-insn.h" 4 | 5 | /* Fallback code */ 6 | 7 | __weak 8 | const char *dump_insn(struct perf_insn *x __maybe_unused, 9 | u64 ip __maybe_unused, u8 *inbuf __maybe_unused, 10 | int inlen __maybe_unused, int *lenp) 11 | { 12 | if (lenp) 13 | *lenp = 0; 14 | return "?"; 15 | } 16 | -------------------------------------------------------------------------------- /libperf/util/dump-insn.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_DUMP_INSN_H 3 | #define __PERF_DUMP_INSN_H 1 4 | 5 | #define MAXINSN 15 6 | 7 | #include 8 | 9 | struct thread; 10 | 11 | struct perf_insn { 12 | /* Initialized by callers: */ 13 | struct thread *thread; 14 | u8 cpumode; 15 | bool is64bit; 16 | int cpu; 17 | /* Temporary */ 18 | char out[256]; 19 | }; 20 | 21 | const char *dump_insn(struct perf_insn *x, u64 ip, 22 | u8 *inbuf, int inlen, int *lenp); 23 | #endif 24 | -------------------------------------------------------------------------------- /libperf/util/expr.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef PARSE_CTX_H 3 | #define PARSE_CTX_H 1 4 | 5 | #define EXPR_MAX_OTHER 15 6 | #define MAX_PARSE_ID EXPR_MAX_OTHER 7 | 8 | struct parse_id { 9 | const char *name; 10 | double val; 11 | }; 12 | 13 | struct parse_ctx { 14 | int num_ids; 15 | struct parse_id ids[MAX_PARSE_ID]; 16 | }; 17 | 18 | void expr__ctx_init(struct parse_ctx *ctx); 19 | void expr__add_id(struct parse_ctx *ctx, const char *id, double val); 20 | #ifndef IN_EXPR_Y 21 | int expr__parse(double *final_val, struct parse_ctx *ctx, const char **pp); 22 | #endif 23 | int expr__find_other(const char *p, const char *one, const char ***other, 24 | int *num_other); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /libperf/util/find-vdso-map.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | static int find_vdso_map(void **start, void **end) 3 | { 4 | FILE *maps; 5 | char line[128]; 6 | int found = 0; 7 | 8 | maps = fopen("/proc/self/maps", "r"); 9 | if (!maps) { 10 | fprintf(stderr, "vdso: cannot open maps\n"); 11 | return -1; 12 | } 13 | 14 | while (!found && fgets(line, sizeof(line), maps)) { 15 | int m = -1; 16 | 17 | /* We care only about private r-x mappings. */ 18 | if (2 != sscanf(line, "%p-%p r-xp %*x %*x:%*x %*u %n", 19 | start, end, &m)) 20 | continue; 21 | if (m < 0) 22 | continue; 23 | 24 | if (!strncmp(&line[m], VDSO__MAP_NAME, 25 | sizeof(VDSO__MAP_NAME) - 1)) 26 | found = 1; 27 | } 28 | 29 | fclose(maps); 30 | return !found; 31 | } 32 | -------------------------------------------------------------------------------- /libperf/util/generate-cmdlist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # SPDX-License-Identifier: GPL-2.0 3 | 4 | echo "/* Automatically generated by $0 */ 5 | struct cmdname_help 6 | { 7 | char name[16]; 8 | char help[80]; 9 | }; 10 | 11 | static struct cmdname_help common_cmds[] = {" 12 | 13 | sed -n -e 's/^perf-\([^ ]*\)[ ].* common.*/\1/p' command-list.txt | 14 | sort | 15 | while read cmd 16 | do 17 | sed -n ' 18 | /^NAME/,/perf-'"$cmd"'/H 19 | ${ 20 | x 21 | s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/ 22 | p 23 | }' "Documentation/perf-$cmd.txt" 24 | done 25 | 26 | echo "#ifdef HAVE_LIBELF_SUPPORT" 27 | sed -n -e 's/^perf-\([^ ]*\)[ ].* full.*/\1/p' command-list.txt | 28 | sort | 29 | while read cmd 30 | do 31 | sed -n ' 32 | /^NAME/,/perf-'"$cmd"'/H 33 | ${ 34 | x 35 | s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/ 36 | p 37 | }' "Documentation/perf-$cmd.txt" 38 | done 39 | echo "#endif /* HAVE_LIBELF_SUPPORT */" 40 | 41 | echo "#ifdef HAVE_LIBAUDIT_SUPPORT" 42 | sed -n -e 's/^perf-\([^ ]*\)[ ].* audit*/\1/p' command-list.txt | 43 | sort | 44 | while read cmd 45 | do 46 | sed -n ' 47 | /^NAME/,/perf-'"$cmd"'/H 48 | ${ 49 | x 50 | s/.*perf-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/ 51 | p 52 | }' "Documentation/perf-$cmd.txt" 53 | done 54 | echo "#endif /* HAVE_LIBELF_SUPPORT */" 55 | echo "};" 56 | -------------------------------------------------------------------------------- /libperf/util/group.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef GROUP_H 3 | #define GROUP_H 1 4 | 5 | bool arch_topdown_check_group(bool *warn); 6 | void arch_topdown_group_warn(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libperf/util/help-unknown-cmd.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RainM/rperf/d0b58ede8ce2fbc60ad35f0cea6ad33be1e486fd/libperf/util/help-unknown-cmd.h -------------------------------------------------------------------------------- /libperf/util/include/asm/asm-offsets.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* stub */ 3 | -------------------------------------------------------------------------------- /libperf/util/include/asm/cpufeature.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | #ifndef PERF_CPUFEATURE_H 4 | #define PERF_CPUFEATURE_H 5 | 6 | /* cpufeature.h ... dummy header file for including arch/x86/lib/memcpy_64.S */ 7 | 8 | #define X86_FEATURE_REP_GOOD 0 9 | 10 | #endif /* PERF_CPUFEATURE_H */ 11 | -------------------------------------------------------------------------------- /libperf/util/include/asm/dwarf2.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | #ifndef PERF_DWARF2_H 4 | #define PERF_DWARF2_H 5 | 6 | /* dwarf2.h ... dummy header file for including arch/x86/lib/mem{cpy,set}_64.S */ 7 | 8 | #define CFI_STARTPROC 9 | #define CFI_ENDPROC 10 | #define CFI_REMEMBER_STATE 11 | #define CFI_RESTORE_STATE 12 | 13 | #endif /* PERF_DWARF2_H */ 14 | 15 | -------------------------------------------------------------------------------- /libperf/util/include/asm/swab.h: -------------------------------------------------------------------------------- 1 | /* stub */ 2 | -------------------------------------------------------------------------------- /libperf/util/include/asm/system.h: -------------------------------------------------------------------------------- 1 | /* Empty */ 2 | -------------------------------------------------------------------------------- /libperf/util/include/asm/uaccess.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_ASM_UACCESS_H_ 3 | #define _PERF_ASM_UACCESS_H_ 4 | 5 | #define __get_user(src, dest) \ 6 | ({ \ 7 | (src) = *dest; \ 8 | 0; \ 9 | }) 10 | 11 | #define get_user __get_user 12 | 13 | #define access_ok(type, addr, size) 1 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /libperf/util/include/dwarf-regs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_DWARF_REGS_H_ 3 | #define _PERF_DWARF_REGS_H_ 4 | 5 | #ifdef HAVE_DWARF_SUPPORT 6 | const char *get_arch_regstr(unsigned int n); 7 | /* 8 | * get_dwarf_regstr - Returns ftrace register string from DWARF regnum 9 | * n: DWARF register number 10 | * machine: ELF machine signature (EM_*) 11 | */ 12 | const char *get_dwarf_regstr(unsigned int n, unsigned int machine); 13 | #endif 14 | 15 | #ifdef HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET 16 | /* 17 | * Arch should support fetching the offset of a register in pt_regs 18 | * by its name. See kernel's regs_query_register_offset in 19 | * arch/xxx/kernel/ptrace.c. 20 | */ 21 | int regs_query_register_offset(const char *name); 22 | #endif 23 | #endif 24 | -------------------------------------------------------------------------------- /libperf/util/include/linux/ctype.h: -------------------------------------------------------------------------------- 1 | #include "../util.h" 2 | -------------------------------------------------------------------------------- /libperf/util/include/linux/linkage.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | 3 | #ifndef PERF_LINUX_LINKAGE_H_ 4 | #define PERF_LINUX_LINKAGE_H_ 5 | 6 | /* linkage.h ... for including arch/x86/lib/memcpy_64.S */ 7 | 8 | #define ENTRY(name) \ 9 | .globl name; \ 10 | name: 11 | 12 | #define ENDPROC(name) 13 | 14 | #endif /* PERF_LINUX_LINKAGE_H_ */ 15 | -------------------------------------------------------------------------------- /libperf/util/intel-bts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * intel-bts.h: Intel Processor Trace support 3 | * Copyright (c) 2013-2014, Intel Corporation. 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms and conditions of the GNU General Public License, 7 | * version 2, as published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope it will be useful, but WITHOUT 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | */ 15 | 16 | #ifndef INCLUDE__PERF_INTEL_BTS_H__ 17 | #define INCLUDE__PERF_INTEL_BTS_H__ 18 | 19 | #define INTEL_BTS_PMU_NAME "intel_bts" 20 | 21 | enum { 22 | INTEL_BTS_PMU_TYPE, 23 | INTEL_BTS_TIME_SHIFT, 24 | INTEL_BTS_TIME_MULT, 25 | INTEL_BTS_TIME_ZERO, 26 | INTEL_BTS_CAP_USER_TIME_ZERO, 27 | INTEL_BTS_SNAPSHOT_MODE, 28 | INTEL_BTS_AUXTRACE_PRIV_MAX, 29 | }; 30 | 31 | #define INTEL_BTS_AUXTRACE_PRIV_SIZE (INTEL_BTS_AUXTRACE_PRIV_MAX * sizeof(u64)) 32 | 33 | struct auxtrace_record; 34 | struct perf_tool; 35 | union perf_event; 36 | struct perf_session; 37 | 38 | struct auxtrace_record *intel_bts_recording_init(int *err); 39 | 40 | int intel_bts_process_auxtrace_info(union perf_event *event, 41 | struct perf_session *session); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libperf/util/intel-pt-decoder/inat_types.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_X86_INAT_TYPES_H 2 | #define _ASM_X86_INAT_TYPES_H 3 | /* 4 | * x86 instruction attributes 5 | * 6 | * Written by Masami Hiramatsu 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | * 22 | */ 23 | 24 | /* Instruction attributes */ 25 | typedef unsigned int insn_attr_t; 26 | typedef unsigned char insn_byte_t; 27 | typedef signed int insn_value_t; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /libperf/util/jit.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __JIT_H__ 3 | #define __JIT_H__ 4 | 5 | #include 6 | 7 | int jit_process(struct perf_session *session, struct perf_data *output, 8 | struct machine *machine, char *filename, pid_t pid, u64 *nbytes); 9 | 10 | int jit_inject_record(const char *filename); 11 | 12 | #endif /* __JIT_H__ */ 13 | -------------------------------------------------------------------------------- /libperf/util/levenshtein.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_LEVENSHTEIN_H 3 | #define __PERF_LEVENSHTEIN_H 4 | 5 | int levenshtein(const char *string1, const char *string2, 6 | int swap_penalty, int substition_penalty, 7 | int insertion_penalty, int deletion_penalty); 8 | 9 | #endif /* __PERF_LEVENSHTEIN_H */ 10 | -------------------------------------------------------------------------------- /libperf/util/memswap.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include "memswap.h" 4 | #include 5 | 6 | void mem_bswap_32(void *src, int byte_size) 7 | { 8 | u32 *m = src; 9 | while (byte_size > 0) { 10 | *m = bswap_32(*m); 11 | byte_size -= sizeof(u32); 12 | ++m; 13 | } 14 | } 15 | 16 | void mem_bswap_64(void *src, int byte_size) 17 | { 18 | u64 *m = src; 19 | 20 | while (byte_size > 0) { 21 | *m = bswap_64(*m); 22 | byte_size -= sizeof(u64); 23 | ++m; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /libperf/util/memswap.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef PERF_MEMSWAP_H_ 3 | #define PERF_MEMSWAP_H_ 4 | 5 | void mem_bswap_64(void *src, int byte_size); 6 | void mem_bswap_32(void *src, int byte_size); 7 | 8 | #endif /* PERF_MEMSWAP_H_ */ 9 | -------------------------------------------------------------------------------- /libperf/util/metricgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef METRICGROUP_H 2 | #define METRICGROUP_H 1 3 | 4 | #include "linux/list.h" 5 | #include "rblist.h" 6 | #include 7 | #include "evlist.h" 8 | #include "strbuf.h" 9 | 10 | struct metric_event { 11 | struct rb_node nd; 12 | struct perf_evsel *evsel; 13 | struct list_head head; /* list of metric_expr */ 14 | }; 15 | 16 | struct metric_expr { 17 | struct list_head nd; 18 | const char *metric_expr; 19 | const char *metric_name; 20 | struct perf_evsel **metric_events; 21 | }; 22 | 23 | struct metric_event *metricgroup__lookup(struct rblist *metric_events, 24 | struct perf_evsel *evsel, 25 | bool create); 26 | int metricgroup__parse_groups(const struct option *opt, 27 | const char *str, 28 | struct rblist *metric_events); 29 | 30 | void metricgroup__print(bool metrics, bool groups, char *filter, bool raw); 31 | #endif 32 | -------------------------------------------------------------------------------- /libperf/util/parse-branch-options.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_PARSE_BRANCH_OPTIONS_H 3 | #define _PERF_PARSE_BRANCH_OPTIONS_H 1 4 | #include 5 | int parse_branch_stack(const struct option *opt, const char *str, int unset); 6 | int parse_branch_str(const char *str, __u64 *mode); 7 | #endif /* _PERF_PARSE_BRANCH_OPTIONS_H */ 8 | -------------------------------------------------------------------------------- /libperf/util/parse-regs-options.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_PARSE_REGS_OPTIONS_H 3 | #define _PERF_PARSE_REGS_OPTIONS_H 1 4 | struct option; 5 | int parse_regs(const struct option *opt, const char *str, int unset); 6 | #endif /* _PERF_PARSE_REGS_OPTIONS_H */ 7 | -------------------------------------------------------------------------------- /libperf/util/path.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_PATH_H 3 | #define _PERF_PATH_H 4 | 5 | int path__join(char *bf, size_t size, const char *path1, const char *path2); 6 | int path__join3(char *bf, size_t size, const char *path1, const char *path2, const char *path3); 7 | 8 | bool is_regular_file(const char *file); 9 | 10 | #endif /* _PERF_PATH_H */ 11 | -------------------------------------------------------------------------------- /libperf/util/perf-hooks-list.h: -------------------------------------------------------------------------------- 1 | PERF_HOOK(record_start) 2 | PERF_HOOK(record_end) 3 | PERF_HOOK(test) 4 | -------------------------------------------------------------------------------- /libperf/util/perf-hooks.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef PERF_UTIL_PERF_HOOKS_H 3 | #define PERF_UTIL_PERF_HOOKS_H 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef void (*perf_hook_func_t)(void *ctx); 10 | struct perf_hook_desc { 11 | const char * const hook_name; 12 | perf_hook_func_t * const p_hook_func; 13 | void *hook_ctx; 14 | }; 15 | 16 | extern void perf_hooks__invoke(const struct perf_hook_desc *); 17 | extern void perf_hooks__recover(void); 18 | 19 | #define PERF_HOOK(name) \ 20 | extern struct perf_hook_desc __perf_hook_desc_##name; \ 21 | static inline void perf_hooks__invoke_##name(void) \ 22 | { \ 23 | perf_hooks__invoke(&__perf_hook_desc_##name); \ 24 | } 25 | 26 | #include "perf-hooks-list.h" 27 | #undef PERF_HOOK 28 | 29 | extern int 30 | perf_hooks__set_hook(const char *hook_name, 31 | perf_hook_func_t hook_func, 32 | void *hook_ctx); 33 | 34 | extern perf_hook_func_t 35 | perf_hooks__get_hook(const char *hook_name); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | #endif 41 | -------------------------------------------------------------------------------- /libperf/util/perf_regs.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include "perf_regs.h" 4 | #include "event.h" 5 | 6 | const struct sample_reg __weak sample_reg_masks[] = { 7 | SMPL_REG_END 8 | }; 9 | 10 | int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused, 11 | char **new_op __maybe_unused) 12 | { 13 | return SDT_ARG_SKIP; 14 | } 15 | 16 | #ifdef HAVE_PERF_REGS_SUPPORT 17 | int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) 18 | { 19 | int i, idx = 0; 20 | u64 mask = regs->mask; 21 | 22 | if (regs->cache_mask & (1ULL << id)) 23 | goto out; 24 | 25 | if (!(mask & (1ULL << id))) 26 | return -EINVAL; 27 | 28 | for (i = 0; i < id; i++) { 29 | if (mask & (1ULL << i)) 30 | idx++; 31 | } 32 | 33 | regs->cache_mask |= (1ULL << id); 34 | regs->cache_regs[id] = regs->regs[idx]; 35 | 36 | out: 37 | *valp = regs->cache_regs[id]; 38 | return 0; 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /libperf/util/perf_regs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_REGS_H 3 | #define __PERF_REGS_H 4 | 5 | #include 6 | #include 7 | 8 | struct regs_dump; 9 | 10 | struct sample_reg { 11 | const char *name; 12 | uint64_t mask; 13 | }; 14 | #define SMPL_REG(n, b) { .name = #n, .mask = 1ULL << (b) } 15 | #define SMPL_REG_END { .name = NULL } 16 | 17 | extern const struct sample_reg sample_reg_masks[]; 18 | 19 | enum { 20 | SDT_ARG_VALID = 0, 21 | SDT_ARG_SKIP, 22 | }; 23 | 24 | int arch_sdt_arg_parse_op(char *old_op, char **new_op); 25 | 26 | #ifdef HAVE_PERF_REGS_SUPPORT 27 | #include 28 | 29 | int perf_reg_value(u64 *valp, struct regs_dump *regs, int id); 30 | 31 | #else 32 | #define PERF_REGS_MASK 0 33 | #define PERF_REGS_MAX 0 34 | 35 | static inline const char *perf_reg_name(int id __maybe_unused) 36 | { 37 | return NULL; 38 | } 39 | 40 | static inline int perf_reg_value(u64 *valp __maybe_unused, 41 | struct regs_dump *regs __maybe_unused, 42 | int id __maybe_unused) 43 | { 44 | return 0; 45 | } 46 | #endif /* HAVE_PERF_REGS_SUPPORT */ 47 | #endif /* __PERF_REGS_H */ 48 | -------------------------------------------------------------------------------- /libperf/util/pmu.l: -------------------------------------------------------------------------------- 1 | %option prefix="perf_pmu_" 2 | 3 | %{ 4 | #include 5 | #include 6 | #include "pmu.h" 7 | #include "pmu-bison.h" 8 | 9 | static int value(int base) 10 | { 11 | long num; 12 | 13 | errno = 0; 14 | num = strtoul(perf_pmu_text, NULL, base); 15 | if (errno) 16 | return PP_ERROR; 17 | 18 | perf_pmu_lval.num = num; 19 | return PP_VALUE; 20 | } 21 | 22 | %} 23 | 24 | num_dec [0-9]+ 25 | 26 | %% 27 | 28 | {num_dec} { return value(10); } 29 | config { return PP_CONFIG; } 30 | config1 { return PP_CONFIG1; } 31 | config2 { return PP_CONFIG2; } 32 | - { return '-'; } 33 | : { return ':'; } 34 | , { return ','; } 35 | . { ; } 36 | \n { ; } 37 | 38 | %% 39 | 40 | int perf_pmu_wrap(void) 41 | { 42 | return 1; 43 | } 44 | -------------------------------------------------------------------------------- /libperf/util/print_binary.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef PERF_PRINT_BINARY_H 3 | #define PERF_PRINT_BINARY_H 4 | 5 | #include 6 | #include 7 | 8 | enum binary_printer_ops { 9 | BINARY_PRINT_DATA_BEGIN, 10 | BINARY_PRINT_LINE_BEGIN, 11 | BINARY_PRINT_ADDR, 12 | BINARY_PRINT_NUM_DATA, 13 | BINARY_PRINT_NUM_PAD, 14 | BINARY_PRINT_SEP, 15 | BINARY_PRINT_CHAR_DATA, 16 | BINARY_PRINT_CHAR_PAD, 17 | BINARY_PRINT_LINE_END, 18 | BINARY_PRINT_DATA_END, 19 | }; 20 | 21 | typedef int (*binary__fprintf_t)(enum binary_printer_ops op, 22 | unsigned int val, void *extra, FILE *fp); 23 | 24 | int binary__fprintf(unsigned char *data, size_t len, 25 | size_t bytes_per_line, binary__fprintf_t printer, 26 | void *extra, FILE *fp); 27 | 28 | static inline void print_binary(unsigned char *data, size_t len, 29 | size_t bytes_per_line, binary__fprintf_t printer, 30 | void *extra) 31 | { 32 | binary__fprintf(data, len, bytes_per_line, printer, extra, stdout); 33 | } 34 | 35 | int is_printable_array(char *p, unsigned int len); 36 | 37 | #endif /* PERF_PRINT_BINARY_H */ 38 | -------------------------------------------------------------------------------- /libperf/util/pstack.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_PSTACK_ 3 | #define _PERF_PSTACK_ 4 | 5 | #include 6 | 7 | struct pstack; 8 | struct pstack *pstack__new(unsigned short max_nr_entries); 9 | void pstack__delete(struct pstack *pstack); 10 | bool pstack__empty(const struct pstack *pstack); 11 | void pstack__remove(struct pstack *pstack, void *key); 12 | void pstack__push(struct pstack *pstack, void *key); 13 | void *pstack__pop(struct pstack *pstack); 14 | void *pstack__peek(struct pstack *pstack); 15 | 16 | #endif /* _PERF_PSTACK_ */ 17 | -------------------------------------------------------------------------------- /libperf/util/python-ext-sources: -------------------------------------------------------------------------------- 1 | # 2 | # List of files needed by perf python extension 3 | # 4 | # Each source file must be placed on its own line so that it can be 5 | # processed by Makefile and util/setup.py accordingly. 6 | # 7 | 8 | util/python.c 9 | util/ctype.c 10 | util/evlist.c 11 | util/evsel.c 12 | util/cpumap.c 13 | util/mmap.c 14 | util/namespaces.c 15 | ../lib/bitmap.c 16 | ../lib/find_bit.c 17 | ../lib/hweight.c 18 | ../lib/vsprintf.c 19 | util/thread_map.c 20 | util/util.c 21 | util/xyarray.c 22 | util/cgroup.c 23 | util/parse-branch-options.c 24 | util/rblist.c 25 | util/counts.c 26 | util/print_binary.c 27 | util/strlist.c 28 | util/trace-event.c 29 | ../lib/rbtree.c 30 | util/string.c 31 | util/symbol_fprintf.c 32 | util/units.c 33 | -------------------------------------------------------------------------------- /libperf/util/quote.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_QUOTE_H 3 | #define __PERF_QUOTE_H 4 | 5 | #include 6 | 7 | /* Help to copy the thing properly quoted for the shell safety. 8 | * any single quote is replaced with '\'', any exclamation point 9 | * is replaced with '\!', and the whole thing is enclosed in a 10 | * single quote pair. 11 | * 12 | * For example, if you are passing the result to system() as an 13 | * argument: 14 | * 15 | * sprintf(cmd, "foobar %s %s", sq_quote(arg0), sq_quote(arg1)) 16 | * 17 | * would be appropriate. If the system() is going to call ssh to 18 | * run the command on the other side: 19 | * 20 | * sprintf(cmd, "git-diff-tree %s %s", sq_quote(arg0), sq_quote(arg1)); 21 | * sprintf(rcmd, "ssh %s %s", sq_util/quote.host), sq_quote(cmd)); 22 | * 23 | * Note that the above examples leak memory! Remember to free result from 24 | * sq_quote() in a real application. 25 | */ 26 | 27 | struct strbuf; 28 | 29 | int sq_quote_argv(struct strbuf *, const char **argv, size_t maxlen); 30 | 31 | #endif /* __PERF_QUOTE_H */ 32 | -------------------------------------------------------------------------------- /libperf/util/rwsem.c: -------------------------------------------------------------------------------- 1 | #include "util.h" 2 | #include "rwsem.h" 3 | 4 | int init_rwsem(struct rw_semaphore *sem) 5 | { 6 | return pthread_rwlock_init(&sem->lock, NULL); 7 | } 8 | 9 | int exit_rwsem(struct rw_semaphore *sem) 10 | { 11 | return pthread_rwlock_destroy(&sem->lock); 12 | } 13 | 14 | int down_read(struct rw_semaphore *sem) 15 | { 16 | return perf_singlethreaded ? 0 : pthread_rwlock_rdlock(&sem->lock); 17 | } 18 | 19 | int up_read(struct rw_semaphore *sem) 20 | { 21 | return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock); 22 | } 23 | 24 | int down_write(struct rw_semaphore *sem) 25 | { 26 | return perf_singlethreaded ? 0 : pthread_rwlock_wrlock(&sem->lock); 27 | } 28 | 29 | int up_write(struct rw_semaphore *sem) 30 | { 31 | return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock); 32 | } 33 | -------------------------------------------------------------------------------- /libperf/util/rwsem.h: -------------------------------------------------------------------------------- 1 | #ifndef _PERF_RWSEM_H 2 | #define _PERF_RWSEM_H 3 | 4 | #include 5 | 6 | struct rw_semaphore { 7 | pthread_rwlock_t lock; 8 | }; 9 | 10 | int init_rwsem(struct rw_semaphore *sem); 11 | int exit_rwsem(struct rw_semaphore *sem); 12 | 13 | int down_read(struct rw_semaphore *sem); 14 | int up_read(struct rw_semaphore *sem); 15 | 16 | int down_write(struct rw_semaphore *sem); 17 | int up_write(struct rw_semaphore *sem); 18 | 19 | #endif /* _PERF_RWSEM_H */ 20 | -------------------------------------------------------------------------------- /libperf/util/scripting-engines/Build: -------------------------------------------------------------------------------- 1 | libperf-$(CONFIG_LIBPERL) += trace-event-perl.o 2 | libperf-$(CONFIG_LIBPYTHON) += trace-event-python.o 3 | 4 | CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default 5 | 6 | CFLAGS_trace-event-python.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow 7 | -------------------------------------------------------------------------------- /libperf/util/setns.c: -------------------------------------------------------------------------------- 1 | #include "util.h" 2 | #include 3 | #include 4 | 5 | int setns(int fd, int nstype) 6 | { 7 | return syscall(__NR_setns, fd, nstype); 8 | } 9 | -------------------------------------------------------------------------------- /libperf/util/smt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "api/fs/fs.h" 6 | #include "smt.h" 7 | 8 | int smt_on(void) 9 | { 10 | static bool cached; 11 | static int cached_result; 12 | int cpu; 13 | int ncpu; 14 | 15 | if (cached) 16 | return cached_result; 17 | 18 | ncpu = sysconf(_SC_NPROCESSORS_CONF); 19 | for (cpu = 0; cpu < ncpu; cpu++) { 20 | unsigned long long siblings; 21 | char *str; 22 | size_t strlen; 23 | char fn[256]; 24 | 25 | snprintf(fn, sizeof fn, 26 | "devices/system/cpu/cpu%d/topology/thread_siblings", 27 | cpu); 28 | if (sysfs__read_str(fn, &str, &strlen) < 0) 29 | continue; 30 | /* Entry is hex, but does not have 0x, so need custom parser */ 31 | siblings = strtoull(str, NULL, 16); 32 | free(str); 33 | if (hweight64(siblings) > 1) { 34 | cached_result = 1; 35 | cached = true; 36 | break; 37 | } 38 | } 39 | if (!cached) { 40 | cached_result = 0; 41 | cached = true; 42 | } 43 | return cached_result; 44 | } 45 | -------------------------------------------------------------------------------- /libperf/util/smt.h: -------------------------------------------------------------------------------- 1 | #ifndef SMT_H 2 | #define SMT_H 1 3 | 4 | int smt_on(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /libperf/util/string2.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef PERF_STRING_H 3 | #define PERF_STRING_H 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | s64 perf_atoll(const char *str); 10 | char **argv_split(const char *str, int *argcp); 11 | void argv_free(char **argv); 12 | bool strglobmatch(const char *str, const char *pat); 13 | bool strglobmatch_nocase(const char *str, const char *pat); 14 | bool strlazymatch(const char *str, const char *pat); 15 | static inline bool strisglob(const char *str) 16 | { 17 | return strpbrk(str, "*?[") != NULL; 18 | } 19 | int strtailcmp(const char *s1, const char *s2); 20 | char *strxfrchar(char *s, char from, char to); 21 | 22 | char *ltrim(char *s); 23 | char *rtrim(char *s); 24 | 25 | static inline char *trim(char *s) 26 | { 27 | return ltrim(rtrim(s)); 28 | } 29 | 30 | char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints); 31 | 32 | static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints) 33 | { 34 | return asprintf_expr_inout_ints(var, true, nints, ints); 35 | } 36 | 37 | static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints) 38 | { 39 | return asprintf_expr_inout_ints(var, false, nints, ints); 40 | } 41 | 42 | 43 | #endif /* PERF_STRING_H */ 44 | -------------------------------------------------------------------------------- /libperf/util/syscalltbl.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_SYSCALLTBL_H 3 | #define __PERF_SYSCALLTBL_H 4 | 5 | struct syscalltbl { 6 | union { 7 | int audit_machine; 8 | struct { 9 | int nr_entries; 10 | void *entries; 11 | } syscalls; 12 | }; 13 | }; 14 | 15 | struct syscalltbl *syscalltbl__new(void); 16 | void syscalltbl__delete(struct syscalltbl *tbl); 17 | 18 | const char *syscalltbl__name(const struct syscalltbl *tbl, int id); 19 | int syscalltbl__id(struct syscalltbl *tbl, const char *name); 20 | 21 | int syscalltbl__strglobmatch_first(struct syscalltbl *tbl, const char *syscall_glob, int *idx); 22 | int syscalltbl__strglobmatch_next(struct syscalltbl *tbl, const char *syscall_glob, int *idx); 23 | 24 | #endif /* __PERF_SYSCALLTBL_H */ 25 | -------------------------------------------------------------------------------- /libperf/util/term.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include "term.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void get_term_dimensions(struct winsize *ws) 9 | { 10 | char *s = getenv("LINES"); 11 | 12 | if (s != NULL) { 13 | ws->ws_row = atoi(s); 14 | s = getenv("COLUMNS"); 15 | if (s != NULL) { 16 | ws->ws_col = atoi(s); 17 | if (ws->ws_row && ws->ws_col) 18 | return; 19 | } 20 | } 21 | #ifdef TIOCGWINSZ 22 | if (ioctl(1, TIOCGWINSZ, ws) == 0 && 23 | ws->ws_row && ws->ws_col) 24 | return; 25 | #endif 26 | ws->ws_row = 25; 27 | ws->ws_col = 80; 28 | } 29 | 30 | void set_term_quiet_input(struct termios *old) 31 | { 32 | struct termios tc; 33 | 34 | tcgetattr(0, old); 35 | tc = *old; 36 | tc.c_lflag &= ~(ICANON | ECHO); 37 | tc.c_cc[VMIN] = 0; 38 | tc.c_cc[VTIME] = 0; 39 | tcsetattr(0, TCSANOW, &tc); 40 | } 41 | -------------------------------------------------------------------------------- /libperf/util/term.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_TERM_H 3 | #define __PERF_TERM_H 4 | 5 | struct termios; 6 | struct winsize; 7 | 8 | void get_term_dimensions(struct winsize *ws); 9 | void set_term_quiet_input(struct termios *old); 10 | 11 | #endif /* __PERF_TERM_H */ 12 | -------------------------------------------------------------------------------- /libperf/util/time-utils.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _TIME_UTILS_H_ 3 | #define _TIME_UTILS_H_ 4 | 5 | #include 6 | #include 7 | 8 | struct perf_time_interval { 9 | u64 start, end; 10 | }; 11 | 12 | int parse_nsec_time(const char *str, u64 *ptime); 13 | 14 | int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr); 15 | 16 | bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp); 17 | 18 | int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); 19 | 20 | int fetch_current_timestamp(char *buf, size_t sz); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /libperf/util/tsc.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include 3 | #include 4 | 5 | #include "tsc.h" 6 | 7 | u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc) 8 | { 9 | u64 t, quot, rem; 10 | 11 | t = ns - tc->time_zero; 12 | quot = t / tc->time_mult; 13 | rem = t % tc->time_mult; 14 | return (quot << tc->time_shift) + 15 | (rem << tc->time_shift) / tc->time_mult; 16 | } 17 | 18 | u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc) 19 | { 20 | u64 quot, rem; 21 | 22 | quot = cyc >> tc->time_shift; 23 | rem = cyc & (((u64)1 << tc->time_shift) - 1); 24 | return tc->time_zero + quot * tc->time_mult + 25 | ((rem * tc->time_mult) >> tc->time_shift); 26 | } 27 | 28 | u64 __weak rdtsc(void) 29 | { 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /libperf/util/tsc.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_TSC_H 3 | #define __PERF_TSC_H 4 | 5 | #include 6 | 7 | #include "event.h" 8 | 9 | struct perf_tsc_conversion { 10 | u16 time_shift; 11 | u32 time_mult; 12 | u64 time_zero; 13 | }; 14 | struct perf_event_mmap_page; 15 | 16 | int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, 17 | struct perf_tsc_conversion *tc); 18 | 19 | u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc); 20 | u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc); 21 | u64 rdtsc(void); 22 | 23 | struct perf_event_mmap_page; 24 | struct perf_tool; 25 | struct machine; 26 | 27 | int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, 28 | struct perf_tool *tool, 29 | perf_event__handler_t process, 30 | struct machine *machine); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /libperf/util/units.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include "units.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags) 11 | { 12 | struct parse_tag *i = tags; 13 | 14 | while (i->tag) { 15 | char *s = strchr(str, i->tag); 16 | 17 | if (s) { 18 | unsigned long int value; 19 | char *endptr; 20 | 21 | value = strtoul(str, &endptr, 10); 22 | if (s != endptr) 23 | break; 24 | 25 | if (value > ULONG_MAX / i->mult) 26 | break; 27 | value *= i->mult; 28 | return value; 29 | } 30 | i++; 31 | } 32 | 33 | return (unsigned long) -1; 34 | } 35 | 36 | unsigned long convert_unit(unsigned long value, char *unit) 37 | { 38 | *unit = ' '; 39 | 40 | if (value > 1000) { 41 | value /= 1000; 42 | *unit = 'K'; 43 | } 44 | 45 | if (value > 1000) { 46 | value /= 1000; 47 | *unit = 'M'; 48 | } 49 | 50 | if (value > 1000) { 51 | value /= 1000; 52 | *unit = 'G'; 53 | } 54 | 55 | return value; 56 | } 57 | 58 | int unit_number__scnprintf(char *buf, size_t size, u64 n) 59 | { 60 | char unit[4] = "BKMG"; 61 | int i = 0; 62 | 63 | while (((n / 1024) > 1) && (i < 3)) { 64 | n /= 1024; 65 | i++; 66 | } 67 | 68 | return scnprintf(buf, size, "%" PRIu64 "%c", n, unit[i]); 69 | } 70 | -------------------------------------------------------------------------------- /libperf/util/units.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef PERF_UNIT_H 3 | #define PERF_UNIT_H 4 | 5 | #include 6 | #include 7 | 8 | struct parse_tag { 9 | char tag; 10 | int mult; 11 | }; 12 | 13 | unsigned long parse_tag_value(const char *str, struct parse_tag *tags); 14 | 15 | unsigned long convert_unit(unsigned long value, char *unit); 16 | int unit_number__scnprintf(char *buf, size_t size, u64 n); 17 | 18 | #endif /* PERF_UNIT_H */ 19 | -------------------------------------------------------------------------------- /libperf/util/unwind-libdw.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_UNWIND_LIBDW_H 3 | #define __PERF_UNWIND_LIBDW_H 4 | 5 | #include 6 | #include "unwind.h" 7 | 8 | struct machine; 9 | struct perf_sample; 10 | struct thread; 11 | 12 | bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg); 13 | 14 | struct unwind_info { 15 | Dwfl *dwfl; 16 | struct perf_sample *sample; 17 | struct machine *machine; 18 | struct thread *thread; 19 | unwind_entry_cb_t cb; 20 | void *arg; 21 | int max_stack; 22 | int idx; 23 | struct unwind_entry entries[]; 24 | }; 25 | 26 | #endif /* __PERF_UNWIND_LIBDW_H */ 27 | -------------------------------------------------------------------------------- /libperf/util/usage.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | /* 3 | * usage.c 4 | * 5 | * Various reporting routines. 6 | * Originally copied from GIT source. 7 | * 8 | * Copyright (C) Linus Torvalds, 2005 9 | */ 10 | #include "util.h" 11 | #include "debug.h" 12 | 13 | static __noreturn void usage_builtin(const char *err) 14 | { 15 | fprintf(stderr, "\n Usage: %s\n", err); 16 | exit(129); 17 | } 18 | 19 | /* If we are in a dlopen()ed .so write to a global variable would segfault 20 | * (ugh), so keep things static. */ 21 | static void (*usage_routine)(const char *err) __noreturn = usage_builtin; 22 | 23 | void usage(const char *err) 24 | { 25 | usage_routine(err); 26 | } 27 | -------------------------------------------------------------------------------- /libperf/util/util-cxx.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* 3 | * Support C++ source use utilities defined in util.h 4 | */ 5 | 6 | #ifndef PERF_UTIL_UTIL_CXX_H 7 | #define PERF_UTIL_UTIL_CXX_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /* 14 | * Now 'new' is the only C++ keyword found in util.h: 15 | * in tools/include/linux/rbtree.h 16 | * 17 | * Other keywords, like class and delete, should be 18 | * redefined if necessary. 19 | */ 20 | #define new _new 21 | #include "util.h" 22 | #undef new 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | #endif 28 | -------------------------------------------------------------------------------- /libperf/util/values.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_VALUES_H 3 | #define __PERF_VALUES_H 4 | 5 | #include 6 | 7 | struct perf_read_values { 8 | int threads; 9 | int threads_max; 10 | u32 *pid, *tid; 11 | int counters; 12 | int counters_max; 13 | u64 *counterrawid; 14 | char **countername; 15 | u64 **value; 16 | }; 17 | 18 | int perf_read_values_init(struct perf_read_values *values); 19 | void perf_read_values_destroy(struct perf_read_values *values); 20 | 21 | int perf_read_values_add_value(struct perf_read_values *values, 22 | u32 pid, u32 tid, 23 | u64 rawid, const char *name, u64 value); 24 | 25 | void perf_read_values_display(FILE *fp, struct perf_read_values *values, 26 | int raw); 27 | 28 | #endif /* __PERF_VALUES_H */ 29 | -------------------------------------------------------------------------------- /libperf/util/vdso.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __PERF_VDSO__ 3 | #define __PERF_VDSO__ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #define VDSO__MAP_NAME "[vdso]" 10 | 11 | #define DSO__NAME_VDSO "[vdso]" 12 | #define DSO__NAME_VDSO32 "[vdso32]" 13 | #define DSO__NAME_VDSOX32 "[vdsox32]" 14 | 15 | static inline bool is_vdso_map(const char *filename) 16 | { 17 | return !strcmp(filename, VDSO__MAP_NAME); 18 | } 19 | 20 | struct dso; 21 | 22 | bool dso__is_vdso(struct dso *dso); 23 | 24 | struct machine; 25 | struct thread; 26 | 27 | struct dso *machine__findnew_vdso(struct machine *machine, struct thread *thread); 28 | void machine__exit_vdso(struct machine *machine); 29 | 30 | #endif /* __PERF_VDSO__ */ 31 | -------------------------------------------------------------------------------- /libperf/util/xyarray.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0 2 | #include "xyarray.h" 3 | #include "util.h" 4 | #include 5 | #include 6 | 7 | struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) 8 | { 9 | size_t row_size = ylen * entry_size; 10 | struct xyarray *xy = zalloc(sizeof(*xy) + xlen * row_size); 11 | 12 | if (xy != NULL) { 13 | xy->entry_size = entry_size; 14 | xy->row_size = row_size; 15 | xy->entries = xlen * ylen; 16 | xy->max_x = xlen; 17 | xy->max_y = ylen; 18 | } 19 | 20 | return xy; 21 | } 22 | 23 | void xyarray__reset(struct xyarray *xy) 24 | { 25 | size_t n = xy->entries * xy->entry_size; 26 | 27 | memset(xy->contents, 0, n); 28 | } 29 | 30 | void xyarray__delete(struct xyarray *xy) 31 | { 32 | free(xy); 33 | } 34 | -------------------------------------------------------------------------------- /libperf/util/xyarray.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef _PERF_XYARRAY_H_ 3 | #define _PERF_XYARRAY_H_ 1 4 | 5 | #include 6 | 7 | struct xyarray { 8 | size_t row_size; 9 | size_t entry_size; 10 | size_t entries; 11 | size_t max_x; 12 | size_t max_y; 13 | char contents[]; 14 | }; 15 | 16 | struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size); 17 | void xyarray__delete(struct xyarray *xy); 18 | void xyarray__reset(struct xyarray *xy); 19 | 20 | static inline void *xyarray__entry(struct xyarray *xy, int x, int y) 21 | { 22 | return &xy->contents[x * xy->row_size + y * xy->entry_size]; 23 | } 24 | 25 | static inline int xyarray__max_y(struct xyarray *xy) 26 | { 27 | return xy->max_y; 28 | } 29 | 30 | static inline int xyarray__max_x(struct xyarray *xy) 31 | { 32 | return xy->max_x; 33 | } 34 | 35 | #endif /* _PERF_XYARRAY_H_ */ 36 | --------------------------------------------------------------------------------