perf/core improvements and fixes
Subsystems (6)
Arnaldo Carvalho de Melo
maintainerHi Ingo,
Please consider pulling, several more patches in my queue pending
review, this branch now builds in all of these systems, with Alpine Linux, that uses different versions of libelf, libc helping in keeping this codebase portable, soon I'll add containers for the Android SDK and Yocto:
# perf stat dm alpine:3.4: Ok centos:5: Ok centos:6: Ok centos:7: Ok debian:7: Ok debian:8: Ok debian:experimental: Ok fedora:21: Ok fedora:22: Ok fedora:23: Ok fedora:24: Ok fedora:rawhide: Ok mageia:5: Ok opensuse:13.2: Ok opensuse:42.1: Ok ubuntu:12.04.5: Ok ubuntu:14.04.4: Ok ubuntu:15.10: Ok ubuntu:16.04: Ok
Performance counter stats for 'dm':
1734.724897 task-clock (msec) # 0.003 CPUs utilized
70,156 context-switches # 0.040 M/sec
7,182 cpu-migrations # 0.004 M/sec
51,490 page-faults # 0.030 M/sec
5,093,434,618 cycles # 2.936 GHz
4,839,787,241 instructions # 0.95 insn per cycle
898,488,442 branches # 517.943 M/sec
16,155,791 branch-misses # 1.80% of all branches 684.926493347 seconds time elapsed
#
- Arnaldo
The following changes since commit 44530d588e142a96cf0cd345a7cb8911c4f88720:
Revert "perf/x86/intel, watchdog: Switch NMI watchdog to ref cycles on x86" (2016-07-10 20:58:36 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-20160712
for you to fetch changes up to 6d248fbda59c51ef5f2e90e11551d9e17aeb226f:
tools lib traceevent: Add filter on task CPU id (2016-07-12 16:27:39 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
User visible:
- Add demangling of symbols in programs written in the Rust language (David Tolnay)
- Add support for tracepoints in the python binding, including an example, that sets up and parses sched:sched_switch events, tools/perf/python/tracepoint.py (Jiri Olsa)
- Introduce --stdio-color to setup the color output mode selection in 'annotate' and 'report', allowing emit color escape sequences when redirecting the output of these tools (Arnaldo Carvalho de Melo)
Infrastructure:
- Various tweaks to allow the 'perf trace' beautifiers to build without using kernel headers and in a wider range of Linux distributions/releases (Arnaldo Carvalho de Melo)
- Stop using kernel source files, instead copy what is needed and check when the original kernel source file gets modified, warning the developers about it. This helps in building the tool in older systems and even in recent ones, for just added kernel features for which ABI details (struct changes, defines, etc) still are not available on system headers (Arnaldo Carvalho de Melo)
- Be consistent in how to use strerror_r, adding a wrapper that makes sure that it returns a pointer to passed buffer, and using the XSI variant, that is available in more libc implementations (Arnaldo Carvalho de Melo)
- Avoid checking code drift on busibox's diff perf intel-pt-decoder, as it doesn't have the '-I' command line switch to check for regexps (Arnaldo Carvalho de Melo)
- Add missing headers in various places (Arnaldo Carvalho de Melo)
- Remove unneeded headers from various other places (Arnaldo Carvalho de Melo)
- Add feature detection for gelf_getnote(), disabling SDT support if not present (Arnaldo Carvalho de Melo)
- Fix oddities with gcc 5.3.0 by initializing some variables (Arnaldo Carvalho de Melo)
- With those changes in place perf now builds on Alpine Linux 3.4, in addition to on centos (5, 6, 7), debian (7, 8, experimental), fedora (21, 22, 23, 24, rawhide), mageia 5, opensuse (13.2, 42.1) and ubuntu (12.04.5, 14.04.4, 15.10, 16.04) and will be test build on those systems prior to future pull requests.
----------------------------------------------------------------
Arnaldo Carvalho de Melo (52):
perf ui stdio: Add way to setup the color output mode selection
perf annotate: Introduce --stdio-color to setup the color output mode selection perf report: Introduce --stdio-color to setup the color output mode selection perf trace beauty msg_flags: Remove MSG_TRYHARD
perf trace beauty flock: Add missing fcntl.h include
perf trace beauty open_flags: Add missing headers
perf trace beauty mmap: Add more conditional defines
perf trace beauty flock: Add more conditional defines
perf trace beauty open_flags: Add more conditional defines
tools: Introduce str_error_r()
perf bench: Add missing pthread.h include for CPU_*() macros
perf tests: Add missing pthread.h include for CPU_*() macros
perf trace: Add conditional define for AT_FDCWD
perf tests openat-syscall-tp-fields: Add some conditional defines
perf bench: Disentangle headers
perf tools: Move syscall number fallbacks from perf-sys.h to tools/arch/x86/include/asm/ perf strbuf: Add missing headers
perf quote: Disentangle headers
perf tests cpumap: Add missing headers
perf test fdarray: Add missing poll.h header
perf tests x86 rdpmc: Add missing headers
perf tools: Add missing header to color.c
perf tools: Remove needless includes from cache.h
perf evsel: Uninline the is_function_event method
perf tools: Uninline scnprintf() and vscnprint()
tools lib traceevent: Use str_error_r()
tools lib api fs: Use str_error_r()
tools lib: Guard the strlcpy() header with __GLIBC__
tools lib subcmd: Use str_error_r()
perf bench futex: Add missing compiler.h header
perf tools: event.h needs asm/perf_regs.h
tools: Add copy of perf_event.h to tools/include/linux/
perf bench: Copy kernel files needed to build mem{cpy,set} x86_64 benchmarks tools lib bpf: Copy bpf.h and bpf_common.h from the kernel
tools: Copy uapi/asm/perf_regs.h from the kernel
perf test bpf: Use epoll_wait() instead of epoll_pwait()
tools: Copy uapi/linux/hw_breakpoint.h from the kernel
perf tools: Introduce weak alternative to sched_getcpu()
perf tools: Remove unneeded magic.h include from util.h
perf trace: Remove unused sys/ptrace.h include
kvm arm/arm64: Remove trailing whitespace from headers
tools: Copy the header files needed by perf tools
perf tools: Fallback to reading sysfs to get cacheline size
perf trace beauty futex_op: Add missing defines for older systems
perf trace beauty seccomp: Remove seccomp.h include
perf symbols: Provide a GElf_Nhdr typedef
perf script python: Silence -Werror=maybe-uninitialized on gcc 5.3.0
tools: Copy the bitsperlong.h files from the kernel
perf tools: Add the tools/ stringify copy to the MANIFEST
perf tools: Don't add kernel directories to the header search path
perf intel-pt-decoder: Avoid checking code drift on busibox's diff
perf tools: Add feature detection for gelf_getnote()
David Tolnay (1):
perf symbols: Add Rust demangling
Jiri Olsa (12):
perf hists: Introduce hist_entry__init function
perf hists: Introduce hist_entry_ops
perf hists: Introduce hists__add_entry_ops function perf evlist: Make event2evsel public
perf tools: Introduce trace_event__tp_format_id()
perf python: Init perf_event_attr::size in perf.evsel constructor perf python: Fix pyrf_evlist__read_on_cpu event consuming perf python: Put perf.event objects into dictionary perf python: Add perf.tracepoint method
perf python: Add struct evsel into struct pyrf_event perf python: Add support to resolve tracepoint fields perf python: Add tracepoint example
Steven Rostedt (1):
tools lib traceevent: Add filter on task CPU id
arch/arm/include/uapi/asm/kvm.h | 4 +-
tools/arch/alpha/include/uapi/asm/bitsperlong.h | 8 +
tools/arch/arm/include/uapi/asm/kvm.h | 224 +++++
tools/arch/arm/include/uapi/asm/perf_regs.h | 23 +
tools/arch/arm64/include/uapi/asm/bitsperlong.h | 23 +
tools/arch/arm64/include/uapi/asm/kvm.h | 258 ++++++
tools/arch/arm64/include/uapi/asm/perf_regs.h | 40 +
tools/arch/frv/include/uapi/asm/bitsperlong.h | 1 +
tools/arch/h8300/include/asm/bitsperlong.h | 14 +
tools/arch/hexagon/include/uapi/asm/bitsperlong.h | 26 +
tools/arch/ia64/include/uapi/asm/bitsperlong.h | 8 +
tools/arch/m32r/include/uapi/asm/bitsperlong.h | 1 +
.../arch/microblaze/include/uapi/asm/bitsperlong.h | 1 +
tools/arch/mips/include/uapi/asm/bitsperlong.h | 8 +
tools/arch/mips/include/uapi/asm/kvm.h | 208 +++++
tools/arch/mn10300/include/uapi/asm/bitsperlong.h | 1 +
tools/arch/parisc/include/uapi/asm/bitsperlong.h | 14 +
tools/arch/powerpc/include/uapi/asm/bitsperlong.h | 12 +
tools/arch/powerpc/include/uapi/asm/kvm.h | 612 +++++++++++++
tools/arch/powerpc/include/uapi/asm/perf_regs.h | 50 ++
tools/arch/s390/include/uapi/asm/bitsperlong.h | 12 +
tools/arch/s390/include/uapi/asm/kvm.h | 192 ++++
tools/arch/s390/include/uapi/asm/kvm_perf.h | 25 +
tools/arch/s390/include/uapi/asm/sie.h | 250 ++++++
tools/arch/score/include/uapi/asm/bitsperlong.h | 6 +
tools/arch/sparc/include/uapi/asm/bitsperlong.h | 12 +
tools/arch/tile/include/uapi/asm/bitsperlong.h | 26 +
tools/arch/x86/include/asm/cpufeatures.h | 316 +++++++
tools/arch/x86/include/asm/disabled-features.h | 60 ++
tools/arch/x86/include/asm/required-features.h | 103 +++
tools/arch/x86/include/asm/unistd_32.h | 12 +
tools/arch/x86/include/asm/unistd_64.h | 12 +
tools/arch/x86/include/uapi/asm/bitsperlong.h | 12 +
tools/arch/x86/include/uapi/asm/kvm.h | 360 ++++++++
tools/arch/x86/include/uapi/asm/kvm_perf.h | 16 +
tools/arch/x86/include/uapi/asm/perf_regs.h | 33 +
tools/arch/x86/include/uapi/asm/svm.h | 178 ++++
tools/arch/x86/include/uapi/asm/vmx.h | 136 +++
tools/arch/x86/lib/memcpy_64.S | 297 +++++++
tools/arch/x86/lib/memset_64.S | 138 +++
tools/build/Makefile.feature | 1 +
tools/build/feature/Makefile | 4 +
tools/build/feature/test-all.c | 5 +
tools/build/feature/test-libelf-gelf_getnote.c | 7 +
tools/include/asm-generic/bitops/__ffs.h | 1 +
tools/include/asm-generic/bitops/atomic.h | 1 +
tools/include/asm-generic/bitsperlong.h | 25 +
.../{perf/util => }/include/asm/alternative-asm.h | 4 +-
tools/include/linux/kernel.h | 28 +-
tools/include/linux/string.h | 4 +-
tools/include/uapi/asm-generic/bitsperlong.h | 15 +
tools/include/uapi/linux/bpf.h | 389 ++++++++
tools/include/uapi/linux/bpf_common.h | 55 ++
tools/include/uapi/linux/hw_breakpoint.h | 30 +
tools/include/uapi/linux/perf_event.h | 983 +++++++++++++++++++++
tools/lib/api/Makefile | 1 +
tools/lib/api/fs/tracing_path.c | 3 +-
tools/lib/bpf/Makefile | 8 +-
tools/lib/str_error_r.c | 26 +
tools/lib/subcmd/run-command.c | 5 +-
tools/lib/traceevent/event-parse.c | 8 +-
tools/lib/traceevent/parse-filter.c | 18 +-
tools/lib/vsprintf.c | 24 +
tools/objtool/Build | 5 +
tools/objtool/builtin-check.c | 1 +
tools/perf/Documentation/perf-annotate.txt | 7 +
tools/perf/Documentation/perf-report.txt | 7 +
tools/perf/MANIFEST | 41 +-
tools/perf/Makefile.perf | 63 ++
tools/perf/arch/common.c | 1 +
tools/perf/arch/x86/tests/rdpmc.c | 8 +-
tools/perf/bench/futex-hash.c | 15 +-
tools/perf/bench/futex-lock-pi.c | 11 +-
tools/perf/bench/futex-requeue.c | 11 +-
tools/perf/bench/futex-wake-parallel.c | 11 +-
tools/perf/bench/futex-wake.c | 11 +-
tools/perf/bench/mem-memcpy-x86-64-asm.S | 2 +-
tools/perf/bench/mem-memset-x86-64-asm.S | 2 +-
tools/perf/bench/numa.c | 4 +-
tools/perf/builtin-annotate.c | 3 +
tools/perf/builtin-buildid-cache.c | 8 +-
tools/perf/builtin-help.c | 8 +-
tools/perf/builtin-kvm.c | 4 +-
tools/perf/builtin-probe.c | 2 +-
tools/perf/builtin-record.c | 6 +-
tools/perf/builtin-report.c | 3 +
tools/perf/builtin-sched.c | 2 +-
tools/perf/builtin-stat.c | 4 +-
tools/perf/builtin-top.c | 6 +-
tools/perf/builtin-trace.c | 9 +-
tools/perf/config/Makefile | 16 +-
tools/perf/perf-sys.h | 18 -
tools/perf/perf.c | 18 +-
tools/perf/python/tracepoint.py | 47 +
tools/perf/tests/backward-ring-buffer.c | 4 +-
tools/perf/tests/bpf-script-example.c | 4 +-
tools/perf/tests/bpf.c | 10 +-
tools/perf/tests/builtin-test.c | 2 +-
tools/perf/tests/cpumap.c | 7 +
tools/perf/tests/event-times.c | 2 +-
tools/perf/tests/fdarray.c | 1 +
tools/perf/tests/llvm.c | 1 +
tools/perf/tests/mmap-basic.c | 9 +-
tools/perf/tests/openat-syscall-all-cpus.c | 7 +-
tools/perf/tests/openat-syscall-tp-fields.c | 11 +-
tools/perf/tests/openat-syscall.c | 2 +-
tools/perf/tests/perf-record.c | 11 +-
tools/perf/tests/sw-clock.c | 4 +-
tools/perf/tests/task-exit.c | 4 +-
tools/perf/trace/beauty/flock.c | 17 +
tools/perf/trace/beauty/futex_op.c | 16 +
tools/perf/trace/beauty/mmap.c | 77 +-
tools/perf/trace/beauty/msg_flags.c | 1 -
tools/perf/trace/beauty/open_flags.c | 15 +
tools/perf/trace/beauty/seccomp.c | 2 -
tools/perf/ui/browsers/hists.c | 2 +-
tools/perf/ui/gtk/util.c | 1 +
tools/perf/ui/helpline.c | 1 +
tools/perf/ui/setup.c | 7 +
tools/perf/ui/tui/setup.c | 2 +
tools/perf/ui/ui.h | 4 +
tools/perf/util/Build | 11 +
tools/perf/util/alias.c | 1 +
tools/perf/util/bpf-loader.c | 2 +-
tools/perf/util/build-id.c | 2 +-
tools/perf/util/cache.h | 3 -
tools/perf/util/cloexec.c | 18 +-
tools/perf/util/color.c | 3 +
tools/perf/util/data.c | 4 +-
tools/perf/util/debug.h | 2 +-
tools/perf/util/demangle-rust.c | 269 ++++++
tools/perf/util/demangle-rust.h | 7 +
tools/perf/util/dso.c | 6 +-
tools/perf/util/dso.h | 1 +
tools/perf/util/event.h | 1 +
tools/perf/util/evlist.c | 8 +-
tools/perf/util/evlist.h | 3 +
tools/perf/util/evsel.c | 20 +-
tools/perf/util/evsel.h | 18 +-
tools/perf/util/help-unknown-cmd.c | 1 +
tools/perf/util/hist.c | 204 +++--
tools/perf/util/hist.h | 11 +
tools/perf/util/include/asm/unistd_32.h | 1 -
tools/perf/util/include/asm/unistd_64.h | 1 -
tools/perf/util/intel-pt-decoder/Build | 5 +-
tools/perf/util/levenshtein.c | 4 +-
tools/perf/util/llvm-utils.c | 10 +-
tools/perf/util/path.c | 2 +
tools/perf/util/probe-event.c | 6 +-
tools/perf/util/probe-file.c | 12 +-
tools/perf/util/probe-finder.c | 4 +-
tools/perf/util/python-ext-sources | 2 +
tools/perf/util/python.c | 162 +++-
tools/perf/util/quote.c | 4 +-
tools/perf/util/quote.h | 3 +-
.../util/scripting-engines/trace-event-python.c | 4 +-
tools/perf/util/sort.h | 6 +
tools/perf/util/strbuf.c | 2 +-
tools/perf/util/strbuf.h | 3 +
tools/perf/util/symbol-elf.c | 11 +
tools/perf/util/target.c | 3 +-
tools/perf/util/trace-event.c | 8 +
tools/perf/util/trace-event.h | 2 +
tools/perf/util/util.h | 6 +-
164 files changed, 6478 insertions(+), 333 deletions(-)
create mode 100644 tools/arch/alpha/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/arm/include/uapi/asm/kvm.h
create mode 100644 tools/arch/arm/include/uapi/asm/perf_regs.h
create mode 100644 tools/arch/arm64/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/arm64/include/uapi/asm/kvm.h
create mode 100644 tools/arch/arm64/include/uapi/asm/perf_regs.h
create mode 100644 tools/arch/frv/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/h8300/include/asm/bitsperlong.h
create mode 100644 tools/arch/hexagon/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/ia64/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/m32r/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/microblaze/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/mips/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/mips/include/uapi/asm/kvm.h
create mode 100644 tools/arch/mn10300/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/parisc/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/powerpc/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/powerpc/include/uapi/asm/kvm.h
create mode 100644 tools/arch/powerpc/include/uapi/asm/perf_regs.h
create mode 100644 tools/arch/s390/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/s390/include/uapi/asm/kvm.h
create mode 100644 tools/arch/s390/include/uapi/asm/kvm_perf.h
create mode 100644 tools/arch/s390/include/uapi/asm/sie.h
create mode 100644 tools/arch/score/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/sparc/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/tile/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/x86/include/asm/cpufeatures.h
create mode 100644 tools/arch/x86/include/asm/disabled-features.h
create mode 100644 tools/arch/x86/include/asm/required-features.h
create mode 100644 tools/arch/x86/include/asm/unistd_32.h
create mode 100644 tools/arch/x86/include/asm/unistd_64.h
create mode 100644 tools/arch/x86/include/uapi/asm/bitsperlong.h
create mode 100644 tools/arch/x86/include/uapi/asm/kvm.h
create mode 100644 tools/arch/x86/include/uapi/asm/kvm_perf.h
create mode 100644 tools/arch/x86/include/uapi/asm/perf_regs.h
create mode 100644 tools/arch/x86/include/uapi/asm/svm.h
create mode 100644 tools/arch/x86/include/uapi/asm/vmx.h
create mode 100644 tools/arch/x86/lib/memcpy_64.S
create mode 100644 tools/arch/x86/lib/memset_64.S
create mode 100644 tools/build/feature/test-libelf-gelf_getnote.c
create mode 100644 tools/include/asm-generic/bitsperlong.h
rename tools/{perf/util => }/include/asm/alternative-asm.h (66%)
create mode 100644 tools/include/uapi/asm-generic/bitsperlong.h
create mode 100644 tools/include/uapi/linux/bpf.h
create mode 100644 tools/include/uapi/linux/bpf_common.h
create mode 100644 tools/include/uapi/linux/hw_breakpoint.h
create mode 100644 tools/include/uapi/linux/perf_event.h
create mode 100644 tools/lib/str_error_r.c
create mode 100644 tools/lib/vsprintf.c
create mode 100755 tools/perf/python/tracepoint.py
create mode 100644 tools/perf/util/demangle-rust.c
create mode 100644 tools/perf/util/demangle-rust.h
delete mode 100644 tools/perf/util/include/asm/unistd_32.h
delete mode 100644 tools/perf/util/include/asm/unistd_64.hArnaldo Carvalho de Melo
maintainerPATCH 1/66 perf hists: Introduce hist_entry__init function
From: Jiri Olsa <[email protected]>
Move the 'struct hist_entry' initialization code to a separate function. It'll be useful and more clear for the following patches that introduce allocation callbacks.
Releasing the hist_entry object in hist_entry__new function (where it's allocated) rather than in hist_entry__init.
--- tools/perf/util/hist.c | 139 ++++++++++++++++++++++++++----------------------- 1 file changed, 73 insertions(+), 66 deletions(-)
tools/perf/util/hist.c +73 -66
@@ -352,86 +352,93 @@ void hists__delete_entries(struct hists *hists)* histogram, sorted on item, collects periods */ -static struct hist_entry *hist_entry__new (struct hist_entry *template, -bool sample_self) -{ -size_t callchain_size =0 ; -struct hist_entry *he; +static int hist_entry__init (struct hist_entry *he, +struct hist_entry *template, +bool sample_self) +{ + *he = *template; + +if (symbol_conf.cumulate_callchain) { + he->stat_acc =malloc (sizeof (he->stat)); +if (he->stat_acc ==NULL ) +return -ENOMEM ; +memcpy (he->stat_acc, &he->stat,sizeof (he->stat)); +if (!sample_self) +memset (&he->stat,0 ,sizeof (he->stat)); + } -if (symbol_conf.use_callchain) - callchain_size =sizeof (struct callchain_root ); +map__get (he->ms.map); - he =zalloc (sizeof (*he) + callchain_size); +if (he->branch_info) { +/* +* This branch info is (a part of) allocated from +* sample__resolve_bstack() and will be freed after +* adding new entries. So we need to save a copy. +*/ + he->branch_info =malloc (sizeof (*he->branch_info)); +if (he->branch_info ==NULL ) { +map__zput (he->ms.map); +free (he->stat_acc); +return -ENOMEM ; + } -if (he !=NULL ) { - *he = *template; +memcpy (he->branch_info, template->branch_info, +sizeof (*he->branch_info)); -if (symbol_conf.cumulate_callchain) { - he->stat_acc =malloc (sizeof (he->stat)); -if (he->stat_acc ==NULL ) { -free (he); -return NULL ; - } -memcpy (he->stat_acc, &he->stat,sizeof (he->stat)); -if (!sample_self) -memset (&he->stat,0 ,sizeof (he->stat)); - } +map__get (he->branch_info->from.map); +map__get (he->branch_info->to.map); + } -map__get (he->ms.map); +if (he->mem_info) { +map__get (he->mem_info->iaddr.map); +map__get (he->mem_info->daddr.map); + } -if (he->branch_info) { -/* -* This branch info is (a part of) allocated from -* sample__resolve_bstack() and will be freed after -* adding new entries. So we need to save a copy. -*/ - he->branch_info =malloc (sizeof (*he->branch_info)); -if (he->branch_info ==NULL ) { -map__zput (he->ms.map); -free (he->stat_acc); -free (he); -return NULL ; - } +if (symbol_conf.use_callchain) +callchain_init (he->callchain); -memcpy (he->branch_info, template->branch_info, -sizeof (*he->branch_info)); +if (he->raw_data) { + he->raw_data =memdup (he->raw_data, he->raw_size); -map__get (he->branch_info->from.map); -map__get (he->branch_info->to.map); +if (he->raw_data ==NULL ) { +map__put (he->ms.map); +if (he->branch_info) { +map__put (he->branch_info->from.map); +map__put (he->branch_info->to.map); +free (he->branch_info); + } +if (he->mem_info) { +map__put (he->mem_info->iaddr.map); +map__put (he->mem_info->daddr.map); + } +free (he->stat_acc); +return -ENOMEM ; } + } +INIT_LIST_HEAD (&he->pairs.node); +thread__get (he->thread); -if (he->mem_info) { -map__get (he->mem_info->iaddr.map); -map__get (he->mem_info->daddr.map); - } +if (!symbol_conf.report_hierarchy) + he->leaf = true; -if (symbol_conf.use_callchain) -callchain_init (he->callchain); +return 0 ; +} -if (he->raw_data) { - he->raw_data =memdup (he->raw_data, he->raw_size); +static struct hist_entry *hist_entry__new (struct hist_entry *template, +bool sample_self) +{ +size_t callchain_size =0 ; +struct hist_entry *he; +int err =0 ; -if (he->raw_data ==NULL ) { -map__put (he->ms.map); -if (he->branch_info) { -map__put (he->branch_info->from.map); -map__put (he->branch_info->to.map); -free (he->branch_info); - } -if (he->mem_info) { -map__put (he->mem_info->iaddr.map); -map__put (he->mem_info->daddr.map); - } -free (he->stat_acc); -free (he); -return NULL ; - } - } -INIT_LIST_HEAD (&he->pairs.node); -thread__get (he->thread); +if (symbol_conf.use_callchain) + callchain_size =sizeof (struct callchain_root ); -if (!symbol_conf.report_hierarchy) - he->leaf = true; + he =zalloc (sizeof (*he) + callchain_size); +if (he) { + err =hist_entry__init (he, template, sample_self); +if (err) +zfree (&he); }return he;
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 2/66 perf hists: Introduce hist_entry_ops
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introducing allocation callbacks, that allows to extend current hist_entry object into objects with special needs without polluting the current hist_entry object.
--- tools/perf/util/hist.c | 31 +++++++++++++++++++++++++++---- tools/perf/util/sort.h | 6 ++++++ 2 files changed, 33 insertions(+), 4 deletions(-)
tools/perf/util/hist.c +27 -4
@@ -424,21 +424,42 @@ static int hist_entry__init(struct hist_entry *he,return 0 ; } +static void *hist_entry__zalloc (size_t size) +{ +return zalloc (size +sizeof (struct hist_entry )); +} + +static void hist_entry__free (void *ptr) +{ +free (ptr); +} + +static struct hist_entry_ops default_ops = { + .new = hist_entry__zalloc, + .free = hist_entry__free, +}; +static struct hist_entry *hist_entry__new (struct hist_entry *template,bool sample_self) { +struct hist_entry_ops *ops = template->ops;size_t callchain_size =0 ;struct hist_entry *he;int err =0 ; +if (!ops) + ops = template->ops = &default_ops; +if (symbol_conf.use_callchain) callchain_size =sizeof (struct callchain_root ); - he =zalloc (sizeof (*he) + callchain_size); + he = ops->new (callchain_size);if (he) { err =hist_entry__init (he, template, sample_self); -if (err) -zfree (&he); +if (err) { + ops->free (he); + he =NULL ; + } }return he;
@@ -1050,6 +1071,8 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)void hist_entry__delete (struct hist_entry *he) { +struct hist_entry_ops *ops = he->ops; +thread__zput (he->thread);map__zput (he->ms.map);
@@ -1074,7 +1097,7 @@ void hist_entry__delete(struct hist_entry *he)free_callchain (he->callchain);free (he->trace_output);free (he->raw_data); -free (he); + ops->free (he); }/*
tools/perf/util/sort.h +6 -0
@@ -67,6 +67,11 @@ struct hist_entry_diff { }; }; +struct hist_entry_ops { +void *(*new)(size_t size); +void (*free)(void *ptr); +}; +/** * struct hist_entry - histogram entry *
@@ -125,6 +130,7 @@ struct hist_entry {void *trace_output;struct perf_hpp_list *hpp_list;struct hist_entry *parent_he; +struct hist_entry_ops *ops; union { /* this is for hierarchical entry structure */ struct {
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 3/66 perf hists: Introduce hists__add_entry_ops function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Introducing hists__add_entry_ops function to allow using the allocation callbacks externally.
--- tools/perf/util/hist.c | 42 +++++++++++++++++++++++++++++++++++------- tools/perf/util/hist.h | 11 +++++++++++ 2 files changed, 46 insertions(+), 7 deletions(-)
tools/perf/util/hist.c +35 -7
@@ -559,13 +559,15 @@ out:return he; } -struct hist_entry *hists__add_entry (struct hists *hists, -struct addr_location *al, -struct symbol *sym_parent, -struct branch_info *bi, -struct mem_info *mi, -struct perf_sample *sample, -bool sample_self) +static struct hist_entry * +__hists__add_entry (struct hists *hists, +struct addr_location *al, +struct symbol *sym_parent, +struct branch_info *bi, +struct mem_info *mi, +struct perf_sample *sample, +bool sample_self, +struct hist_entry_ops *ops) {struct hist_entry entry = { .thread = al->thread,
@@ -592,11 +594,37 @@ struct hist_entry *hists__add_entry(struct hists *hists, .transaction = sample->transaction, .raw_data = sample->raw_data, .raw_size = sample->raw_size, + .ops = ops, };return hists__findnew_entry (hists, &entry, al, sample_self); } +struct hist_entry *hists__add_entry (struct hists *hists, +struct addr_location *al, +struct symbol *sym_parent, +struct branch_info *bi, +struct mem_info *mi, +struct perf_sample *sample, +bool sample_self) +{ +return __hists__add_entry (hists, al, sym_parent, bi, mi, + sample, sample_self,NULL ); +} + +struct hist_entry *hists__add_entry_ops (struct hists *hists, +struct hist_entry_ops *ops, +struct addr_location *al, +struct symbol *sym_parent, +struct branch_info *bi, +struct mem_info *mi, +struct perf_sample *sample, +bool sample_self) +{ +return __hists__add_entry (hists, al, sym_parent, bi, mi, + sample, sample_self, ops); +} +static int iter_next_nop_entry (struct hist_entry_iter *iter__maybe_unused ,struct addr_location *al__maybe_unused )
tools/perf/util/hist.h +11 -0
@@ -10,6 +10,7 @@#include "ui/progress.h" struct hist_entry ; +struct hist_entry_ops ;struct addr_location ;struct symbol ;
@@ -127,6 +128,16 @@ struct hist_entry *hists__add_entry(struct hists *hists,struct mem_info *mi, struct perf_sample *sample, bool sample_self); + +struct hist_entry *hists__add_entry_ops (struct hists *hists, +struct hist_entry_ops *ops, +struct addr_location *al, +struct symbol *sym_parent, +struct branch_info *bi, +struct mem_info *mi, +struct perf_sample *sample, +bool sample_self); +int hist_entry_iter__add (struct hist_entry_iter *iter,struct addr_location *al,int max_stack_depth,void *arg);
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 4/66 perf ui stdio: Add way to setup the color output mode selection
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
In --stdio we turn off color output when the output is not a tty, which is not always desirable, for instance, in:
perf annotate | more
the 'more' tool is perfectly capable of processing the escape sequences for colored output.
Allow using the existing logic for .perfconfig's "color.ui" to be used from the command line by providing a stdio__config_color() helper, that will be used by annotate and report in follow up patches.
--- tools/perf/ui/setup.c | 7 +++++++ tools/perf/ui/ui.h | 4 ++++ 2 files changed, 11 insertions(+)
tools/perf/ui/setup.c +7 -0
@@ -60,6 +60,13 @@ static inline int setup_gtk_browser(void) { return -1; }static inline void exit_gtk_browser (bool wait_for_ok__maybe_unused ) {}#endif +int stdio__config_color (const struct option *opt__maybe_unused , +const char *mode,int unset__maybe_unused ) +{ + perf_use_color_default =perf_config_colorbool ("color.ui" , mode,-1 ); +return 0 ; +} +void setup_browser (bool fallback_to_pager) {if (use_browser <2 && (!isatty (1 ) || dump_trace))
tools/perf/ui/ui.h +4 -0
@@ -26,4 +26,8 @@ static inline void ui__exit(bool wait_for_ok __maybe_unused) {}void ui__refresh_dimensions (bool force); +struct option ; + +int stdio__config_color (const struct option *opt,const char *mode,int unset); +#endif /* _PERF_UI_H_ */
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 5/66 perf annotate: Introduce --stdio-color to setup the color output mode selection
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
'perf annotate --stdio' will colorize entries with most hits and possibly some other aspects of its output, but those colors gets suppressed if we redirect the output to a non-tty, allow keeping the colors by adding a new option, --stdio-color, now this use case will also output escape sequences for colors:
$ perf annotate --stdio-color | more
--- tools/perf/Documentation/perf-annotate.txt | 7 +++++++ tools/perf/builtin-annotate.c | 3 +++ 2 files changed, 10 insertions(+)
tools/perf/Documentation/perf-annotate.txt +7 -0
@@ -61,6 +61,13 @@ OPTIONS --stdio:: Use the stdio interface. +--stdio-color:: + 'always', 'never' or 'auto', allowing configuring color output + via the command line, in addition to via "color.ui" .perfconfig. + Use '--stdio-color always' to generate color even when redirecting + to a pipe or file. Using just '--stdio-color' is equivalent to + using 'always'. + --tui:: Use the TUI interface. Use of --tui requires a tty, if one is not present, as when piping to other commands, the stdio interface is used. This interfaces starts by centering on the line with more
tools/perf/builtin-annotate.c +3 -0
@@ -339,6 +339,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) "Show event group information together"),OPT_BOOLEAN (0 ,"show-total-period" , &symbol_conf.show_total_period,"Show a column with the sum of periods" ), +OPT_CALLBACK_DEFAULT (0 ,"stdio-color" ,NULL ,"mode" , +"'always' (default), 'never' or 'auto' only applicable to --stdio mode" , + stdio__config_color,"always" ), OPT_END() };int ret =hists__init ();
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 6/66 perf report: Introduce --stdio-color to setup the color output mode selection
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
'perf report --stdio' will colorize entries with most hits and possibly some other aspects of its output, but those colors gets suppressed if we redirect the output to a non-tty, allow keeping the colors by adding a new option, --stdio-color, now this use case will also output escape sequences for colors:
$ perf annotate --stdio-color | more
--- tools/perf/Documentation/perf-report.txt | 7 +++++++ tools/perf/builtin-report.c | 3 +++ 2 files changed, 10 insertions(+)
tools/perf/Documentation/perf-report.txt +7 -0
@@ -265,6 +265,13 @@ OPTIONS --stdio:: Use the stdio interface. +--stdio-color:: + 'always', 'never' or 'auto', allowing configuring color output + via the command line, in addition to via "color.ui" .perfconfig. + Use '--stdio-color always' to generate color even when redirecting + to a pipe or file. Using just '--stdio-color' is equivalent to + using 'always'. + --tui:: Use the TUI interface, that is integrated with annotate and allows zooming into DSOs or threads, among other features. Use of --tui requires a tty, if one is not present, as when piping to other
tools/perf/builtin-report.c +3 -0
@@ -817,6 +817,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) "Show raw trace event output (do not use print fmt or plugins)"),OPT_BOOLEAN (0 ,"hierarchy" , &symbol_conf.report_hierarchy,"Show entries in a hierarchy" ), +OPT_CALLBACK_DEFAULT (0 ,"stdio-color" ,NULL ,"mode" , +"'always' (default), 'never' or 'auto' only applicable to --stdio mode" , + stdio__config_color,"always" ),OPT_END () }; struct perf_data_file file = {
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 7/66 perf trace beauty msg_flags: Remove MSG_TRYHARD
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
It is the same as MSG_DONTROUTE and is only defined together with _GNU_SOURCE.
--- tools/perf/trace/beauty/msg_flags.c | 1 - 1 file changed, 1 deletion(-)
tools/perf/trace/beauty/msg_flags.c +0 -1
@@ -33,7 +33,6 @@ static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size,P_MSG_FLAG (OOB );P_MSG_FLAG (PEEK );P_MSG_FLAG (DONTROUTE ); -P_MSG_FLAG (TRYHARD );P_MSG_FLAG (CTRUNC );P_MSG_FLAG (PROBE );P_MSG_FLAG (TRUNC );
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 8/66 perf trace beauty flock: Add missing fcntl.h include
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Those beautifiers need to make sure they include what they reference, as changes in builtin-trace.c may end up removing needed stuff, like when undefining _GNU_SOURCE.
--- tools/perf/trace/beauty/flock.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/trace/beauty/flock.c +1 -0
@@ -1,3 +1,4 @@ +#include <fcntl.h> static size_t syscall_arg__scnprintf_flock (char *bf,size_t size,struct syscall_arg *arg)
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 9/66 perf trace beauty open_flags: Add missing headers
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Those beautifiers need to make sure they include what they reference, as changes in builtin-trace.c may end up removing needed stuff, like when undefining _GNU_SOURCE.
--- tools/perf/trace/beauty/open_flags.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/trace/beauty/open_flags.c +3 -0
@@ -1,3 +1,6 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> static size_t syscall_arg__scnprintf_open_flags (char *bf,size_t size,struct syscall_arg *arg)
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 10/66 perf trace beauty mmap: Add more conditional defines
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Don't handle some flags only if they have its defines in headers at time of building, define what is missing.
--- tools/perf/trace/beauty/mmap.c | 77 ++++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 22 deletions(-)
tools/perf/trace/beauty/mmap.c +55 -22
@@ -1,5 +1,9 @@#include <sys/mman.h> +#ifndef PROT_SEM +#define PROT_SEM 0x8 +#endif +static size_t syscall_arg__scnprintf_mmap_prot (char *bf,size_t size,struct syscall_arg *arg) {
@@ -16,9 +20,7 @@ static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size,P_MMAP_PROT (EXEC );P_MMAP_PROT (READ );P_MMAP_PROT (WRITE ); -#ifdef PROT_SEM P_MMAP_PROT (SEM ); -#endif P_MMAP_PROT (GROWSDOWN );P_MMAP_PROT (GROWSUP );#undef P_MMAP_PROT
@@ -31,10 +33,31 @@ static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size,#define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot +#ifndef MAP_FIXED +#define MAP_FIXED 0x10 +#endif + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS 0x20 +#endif + +#ifndef MAP_32BIT +#define MAP_32BIT 0x40 +#endif +#ifndef MAP_STACK -# define MAP_STACK 0x20000 +#define MAP_STACK 0x20000#endif +#ifndef MAP_HUGETLB +#define MAP_HUGETLB 0x40000 +#endif + +#ifndef MAP_UNINITIALIZED +#define MAP_UNINITIALIZED 0x4000000 +#endif + +static size_t syscall_arg__scnprintf_mmap_flags (char *bf,size_t size,struct syscall_arg *arg) {
@@ -48,26 +71,20 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size,P_MMAP_FLAG (SHARED );P_MMAP_FLAG (PRIVATE ); -#ifdef MAP_32BIT P_MMAP_FLAG(32BIT); -#endif P_MMAP_FLAG (ANONYMOUS );P_MMAP_FLAG (DENYWRITE );P_MMAP_FLAG (EXECUTABLE );P_MMAP_FLAG (FILE );P_MMAP_FLAG (FIXED );P_MMAP_FLAG (GROWSDOWN ); -#ifdef MAP_HUGETLB P_MMAP_FLAG (HUGETLB ); -#endif P_MMAP_FLAG (LOCKED );P_MMAP_FLAG (NONBLOCK );P_MMAP_FLAG (NORESERVE );P_MMAP_FLAG (POPULATE );P_MMAP_FLAG (STACK ); -#ifdef MAP_UNINITIALIZED P_MMAP_FLAG (UNINITIALIZED ); -#endif #undef P_MMAP_FLAGif (flags)
@@ -78,6 +95,13 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size,#define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags +#ifndef MREMAP_MAYMOVE +#define MREMAP_MAYMOVE 1 +#endif +#ifndef MREMAP_FIXED +#define MREMAP_FIXED 2 +#endif +static size_t syscall_arg__scnprintf_mremap_flags (char *bf,size_t size,struct syscall_arg *arg) {
@@ -90,9 +114,7 @@ static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, }P_MREMAP_FLAG (MAYMOVE ); -#ifdef MREMAP_FIXED P_MREMAP_FLAG (FIXED ); -#endif #undef P_MREMAP_FLAGif (flags)
@@ -107,6 +129,10 @@ static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size,#define MADV_HWPOISON 100#endif +#ifndef MADV_SOFT_OFFLINE +#define MADV_SOFT_OFFLINE 101 +#endif +#ifndef MADV_MERGEABLE #define MADV_MERGEABLE 12#endif
@@ -115,6 +141,23 @@ static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size,#define MADV_UNMERGEABLE 13#endif +#ifndef MADV_HUGEPAGE +#define MADV_HUGEPAGE 14 +#endif + +#ifndef MADV_NOHUGEPAGE +#define MADV_NOHUGEPAGE 15 +#endif + +#ifndef MADV_DONTDUMP +#define MADV_DONTDUMP 16 +#endif + +#ifndef MADV_DODUMP +#define MADV_DODUMP 17 +#endif + +static size_t syscall_arg__scnprintf_madvise_behavior (char *bf,size_t size,struct syscall_arg *arg) {
@@ -131,24 +174,14 @@ static size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size,P_MADV_BHV (DONTFORK );P_MADV_BHV (DOFORK );P_MADV_BHV (HWPOISON ); -#ifdef MADV_SOFT_OFFLINE P_MADV_BHV (SOFT_OFFLINE ); -#endif P_MADV_BHV (MERGEABLE );P_MADV_BHV (UNMERGEABLE ); -#ifdef MADV_HUGEPAGE P_MADV_BHV (HUGEPAGE ); -#endif -#ifdef MADV_NOHUGEPAGE P_MADV_BHV (NOHUGEPAGE ); -#endif -#ifdef MADV_DONTDUMP P_MADV_BHV (DONTDUMP ); -#endif -#ifdef MADV_DODUMP P_MADV_BHV (DODUMP ); -#endif -#undef P_MADV_PHV +#undef P_MADV_BHVdefault :break ; }
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 11/66 perf trace beauty flock: Add more conditional defines
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Don't handle some flags only if they have its defines in headers at time of building, define what is missing.
--- tools/perf/trace/beauty/flock.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/perf/trace/beauty/flock.c +16 -0
@@ -1,5 +1,21 @@#include <fcntl.h> +#ifndef LOCK_MAND +#define LOCK_MAND 32 +#endif + +#ifndef LOCK_READ +#define LOCK_READ 64 +#endif + +#ifndef LOCK_WRITE +#define LOCK_WRITE 128 +#endif + +#ifndef LOCK_RW +#define LOCK_RW 192 +#endif +static size_t syscall_arg__scnprintf_flock (char *bf,size_t size,struct syscall_arg *arg) {
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 12/66 perf trace beauty open_flags: Add more conditional defines
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Don't handle some flags only if they have its defines in headers at time of building, define what is missing.
--- tools/perf/trace/beauty/open_flags.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tools/perf/trace/beauty/open_flags.c +12 -0
@@ -2,6 +2,18 @@#include <sys/stat.h> #include <fcntl.h> +#ifndef O_DIRECT +#define O_DIRECT 00040000 +#endif + +#ifndef O_DIRECTORY +#define O_DIRECTORY 00200000 +#endif + +#ifndef O_NOATIME +#define O_NOATIME 01000000 +#endif +static size_t syscall_arg__scnprintf_open_flags (char *bf,size_t size,struct syscall_arg *arg) {
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 13/66 tools: Introduce str_error_r()
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
The tools so far have been using the strerror_r() GNU variant, that returns a string, be it the buffer passed or something else.
But that, besides being tricky in cases where we expect that the function using strerror_r() returns the error formatted in a provided buffer (we have to check if it returned something else and copy that instead), breaks the build on systems not using glibc, like Alpine Linux, where musl libc is used.
So, introduce yet another wrapper, str_error_r(), that has the GNU interface, but uses the portable XSI variant of strerror_r(), so that users rest asured that the provided buffer is used and it is what is returned.
--- tools/include/linux/string.h | 2 ++ tools/lib/str_error_r.c | 26 ++++++++++++++++++++++++++ tools/perf/MANIFEST | 1 + tools/perf/arch/x86/tests/rdpmc.c | 4 ++-- tools/perf/builtin-buildid-cache.c | 8 ++++---- tools/perf/builtin-help.c | 8 ++++---- tools/perf/builtin-kvm.c | 4 ++-- tools/perf/builtin-probe.c | 2 +- tools/perf/builtin-record.c | 6 +++--- tools/perf/builtin-sched.c | 2 +- tools/perf/builtin-stat.c | 4 ++-- tools/perf/builtin-top.c | 6 +++--- tools/perf/builtin-trace.c | 4 ++-- tools/perf/perf.c | 6 +++--- tools/perf/tests/backward-ring-buffer.c | 4 ++-- tools/perf/tests/bpf.c | 4 ++-- tools/perf/tests/builtin-test.c | 2 +- tools/perf/tests/event-times.c | 2 +- tools/perf/tests/mmap-basic.c | 6 +++--- tools/perf/tests/openat-syscall-all-cpus.c | 4 ++-- tools/perf/tests/openat-syscall-tp-fields.c | 4 ++-- tools/perf/tests/openat-syscall.c | 2 +- tools/perf/tests/perf-record.c | 8 ++++---- tools/perf/tests/sw-clock.c | 4 ++-- tools/perf/tests/task-exit.c | 4 ++-- tools/perf/ui/browsers/hists.c | 2 +- tools/perf/util/Build | 5 +++++ tools/perf/util/bpf-loader.c | 2 +- tools/perf/util/cloexec.c | 4 ++-- tools/perf/util/data.c | 4 ++-- tools/perf/util/debug.h | 2 +- tools/perf/util/dso.c | 6 +++--- tools/perf/util/evlist.c | 4 ++-- tools/perf/util/evsel.c | 2 +- tools/perf/util/llvm-utils.c | 8 ++++---- tools/perf/util/probe-event.c | 6 +++--- tools/perf/util/probe-file.c | 10 +++++----- tools/perf/util/probe-finder.c | 4 ++-- tools/perf/util/python-ext-sources | 1 + tools/perf/util/target.c | 2 +- tools/perf/util/util.h | 1 + 41 files changed, 113 insertions(+), 77 deletions(-) create mode 100644 tools/lib/str_error_r.c
tools/include/linux/string.h +2 -0
@@ -12,4 +12,6 @@ int strtobool(const char *s, bool *res);extern size_t strlcpy (char *dest,const char *src,size_t size);#endif +char *str_error_r (int errnum,char *buf,size_t buflen); +#endif /* _LINUX_STRING_H_ */
tools/lib/str_error_r.c new file +26 -0
@@ -0,0 +1,26 @@ +#undef _GNU_SOURCE +#include <string.h> +#include <stdio.h> +#include <linux/string.h> + +/* +* The tools so far have been using the strerror_r() GNU variant, that returns +* a string, be it the buffer passed or something else. +* +* But that, besides being tricky in cases where we expect that the function +* using strerror_r() returns the error formatted in a provided buffer (we have +* to check if it returned something else and copy that instead), breaks the +* build on systems not using glibc, like Alpine Linux, where musl libc is +* used. +* +* So, introduce yet another wrapper, str_error_r(), that has the GNU +* interface, but uses the portable XSI variant of strerror_r(), so that users +* rest asured that the provided buffer is used and it is what is returned. +*/ +char *str_error_r (int errnum,char *buf,size_t buflen) +{ +int err =strerror_r (errnum, buf, buflen); +if (err) +snprintf (buf, buflen,"INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d" , errnum, buf, buflen, err); +return buf; +}
tools/perf/MANIFEST +1 -0
@@ -29,6 +29,7 @@ tools/lib/symbol/kallsyms.c tools/lib/symbol/kallsyms.h tools/lib/find_bit.c tools/lib/bitmap.c +tools/lib/str_error_r.c tools/include/asm/atomic.h tools/include/asm/barrier.h tools/include/asm/bug.h
tools/perf/arch/x86/tests/rdpmc.c +2 -2
@@ -111,14 +111,14 @@ static int __test__rdpmc(void)if (fd <0 ) {pr_err ("Error: sys_perf_event_open() syscall returned " "with %d (%s)\n" , fd, -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf)));return -1 ; } addr =mmap (NULL , page_size,PROT_READ ,MAP_SHARED , fd,0 );if (addr == (void *)(-1 )) {pr_err ("Error: mmap() syscall returned with (%s)\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_close; }
tools/perf/builtin-buildid-cache.c +4 -4
@@ -351,7 +351,7 @@ int cmd_buildid_cache(int argc, const char **argv,continue ; }pr_warning ("Couldn't add %s: %s\n" , - pos->s,strerror_r (errno, sbuf,sizeof (sbuf))); + pos->s,str_error_r (errno, sbuf,sizeof (sbuf))); }strlist__delete (list);
@@ -369,7 +369,7 @@ int cmd_buildid_cache(int argc, const char **argv,continue ; }pr_warning ("Couldn't remove %s: %s\n" , - pos->s,strerror_r (errno, sbuf,sizeof (sbuf))); + pos->s,str_error_r (errno, sbuf,sizeof (sbuf))); }strlist__delete (list);
@@ -387,7 +387,7 @@ int cmd_buildid_cache(int argc, const char **argv,continue ; }pr_warning ("Couldn't remove %s: %s\n" , - pos->s,strerror_r (errno, sbuf,sizeof (sbuf))); + pos->s,str_error_r (errno, sbuf,sizeof (sbuf))); }strlist__delete (list);
@@ -408,7 +408,7 @@ int cmd_buildid_cache(int argc, const char **argv,continue ; }pr_warning ("Couldn't update %s: %s\n" , - pos->s,strerror_r (errno, sbuf,sizeof (sbuf))); + pos->s,str_error_r (errno, sbuf,sizeof (sbuf))); }strlist__delete (list);
tools/perf/builtin-help.c +4 -4
@@ -117,7 +117,7 @@ static void exec_woman_emacs(const char *path, const char *page)free (man_page); }warning ("failed to exec '%s': %s" , path, -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); } }
@@ -150,7 +150,7 @@ static void exec_man_konqueror(const char *path, const char *page)free (man_page); }warning ("failed to exec '%s': %s" , path, -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); } }
@@ -162,7 +162,7 @@ static void exec_man_man(const char *path, const char *page) path ="man" ;execlp (path,"man" , page,NULL );warning ("failed to exec '%s': %s" , path, -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); }static void exec_man_cmd (const char *cmd,const char *page)
@@ -175,7 +175,7 @@ static void exec_man_cmd(const char *cmd, const char *page)free (shell_cmd); }warning ("failed to exec '%s': %s" , cmd, -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); }static void add_man_viewer (const char *name)
tools/perf/builtin-kvm.c +2 -2
@@ -1018,13 +1018,13 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm) err =perf_evlist__open (evlist);if (err <0 ) {printf ("Couldn't create the events: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out; }if (perf_evlist__mmap (evlist, kvm->opts.mmap_pages, false) <0 ) {ui__error ("Failed to mmap the events: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf)));perf_evlist__close (evlist); goto out; }
tools/perf/builtin-probe.c +1 -1
@@ -308,7 +308,7 @@ static void pr_err_with_code(const char *msg, int err)pr_err ("%s" , msg);pr_debug (" Reason: %s (Code: %d)" , -strerror_r (-err, sbuf,sizeof (sbuf)), err); +str_error_r (-err, sbuf,sizeof (sbuf)), err);pr_err ("\n" ); }
tools/perf/builtin-record.c +3 -3
@@ -361,7 +361,7 @@ static int record__mmap_evlist(struct record *rec,return -errno; }else {pr_err ("failed to mmap with %d (%s)\n" , errno, -strerror_r (errno, msg,sizeof (msg))); +str_error_r (errno, msg,sizeof (msg)));if (errno)return -errno;else
@@ -407,7 +407,7 @@ try_again:if (perf_evlist__apply_filters (evlist, &pos)) {error ("failed to set filter \"%s\" on event %s with %d (%s)\n" , pos->filter,perf_evsel__name (pos), errno, -strerror_r (errno, msg,sizeof (msg))); +str_error_r (errno, msg,sizeof (msg))); rc =-1 ; goto out; }
@@ -1003,7 +1003,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)if (forks && workload_exec_errno) {char msg[STRERR_BUFSIZE ]; -const char *emsg =strerror_r (workload_exec_errno, msg,sizeof (msg)); +const char *emsg =str_error_r (workload_exec_errno, msg,sizeof (msg));pr_err ("Workload failed: %s\n" , emsg); err =-1 ; goto out_child;
tools/perf/builtin-sched.c +1 -1
@@ -494,7 +494,7 @@ force_again: }pr_err ("Error: sys_perf_event_open() syscall returned " "with %d (%s)\n%s" , fd, -strerror_r (errno, sbuf,sizeof (sbuf)), info); +str_error_r (errno, sbuf,sizeof (sbuf)), info);exit (EXIT_FAILURE ); }return fd;
tools/perf/builtin-stat.c +2 -2
@@ -596,7 +596,7 @@ try_again:if (perf_evlist__apply_filters (evsel_list, &counter)) {error ("failed to set filter \"%s\" on event %s with %d (%s)\n" , counter->filter,perf_evsel__name (counter), errno, -strerror_r (errno, msg,sizeof (msg))); +str_error_r (errno, msg,sizeof (msg)));return -1 ; }
@@ -637,7 +637,7 @@ try_again:wait (&status);if (workload_exec_errno) { -const char *emsg =strerror_r (workload_exec_errno, msg,sizeof (msg)); +const char *emsg =str_error_r (workload_exec_errno, msg,sizeof (msg));pr_err ("Workload failed: %s\n" , emsg);return -1 ; }
tools/perf/builtin-top.c +3 -3
@@ -907,7 +907,7 @@ try_again:if (perf_evlist__mmap (evlist, opts->mmap_pages, false) <0 ) {ui__error ("Failed to mmap with %d (%s)\n" , - errno,strerror_r (errno, msg,sizeof (msg))); + errno,str_error_r (errno, msg,sizeof (msg))); goto out_err; }
@@ -1028,7 +1028,7 @@ out_delete: out_err_cpu_topo: {char errbuf[BUFSIZ ]; -const char *err =strerror_r (-ret, errbuf,sizeof (errbuf)); +const char *err =str_error_r (-ret, errbuf,sizeof (errbuf));ui__error ("Could not read the CPU topology map: %s\n" , err); goto out_delete;
@@ -1295,7 +1295,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)if (perf_evlist__create_maps (top.evlist, target) <0 ) {ui__error ("Couldn't create thread/CPU maps: %s\n" , - errno ==ENOENT ?"No such process" :strerror_r (errno, errbuf,sizeof (errbuf))); + errno ==ENOENT ?"No such process" :str_error_r (errno, errbuf,sizeof (errbuf))); goto out_delete_evlist; }
tools/perf/builtin-trace.c +2 -2
@@ -1601,7 +1601,7 @@ signed_print:fprintf (trace->output,") = %ld" , ret); }else if (ret <0 && (sc->fmt->errmsg || sc->fmt->errpid)) {char bf[STRERR_BUFSIZE ]; -const char *emsg =strerror_r (-ret, bf,sizeof (bf)), +const char *emsg =str_error_r (-ret, bf,sizeof (bf)), *e =audit_errno_to_name (-ret);fprintf (trace->output,") = -1 %s %s" , e, emsg);
@@ -2402,7 +2402,7 @@ out_error_apply_filters:fprintf (trace->output,"Failed to set filter \"%s\" on event %s with %d (%s)\n" , evsel->filter,perf_evsel__name (evsel), errno, -strerror_r (errno, errbuf,sizeof (errbuf))); +str_error_r (errno, errbuf,sizeof (errbuf))); goto out_delete_evlist; } out_error_mem:
tools/perf/perf.c +3 -3
@@ -374,7 +374,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)/* Check for ENOSPC and EIO errors.. */ if (fflush (stdout)) {fprintf (stderr,"write failure on standard output: %s" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out; }if (ferror (stdout)) {
@@ -383,7 +383,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) }if (fclose (stdout)) {fprintf (stderr,"close failed on standard output: %s" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out; } status =0 ;
@@ -615,7 +615,7 @@ int main(int argc, const char **argv) }fprintf (stderr,"Failed to run command '%s': %s\n" , - cmd,strerror_r (errno, sbuf,sizeof (sbuf))); + cmd,str_error_r (errno, sbuf,sizeof (sbuf))); out:return 1 ; }
tools/perf/tests/backward-ring-buffer.c +2 -2
@@ -60,7 +60,7 @@ static int do_test(struct perf_evlist *evlist, int mmap_pages, err =perf_evlist__mmap (evlist, mmap_pages, true);if (err <0 ) {pr_debug ("perf_evlist__mmap: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf)));return TEST_FAIL ; }
@@ -124,7 +124,7 @@ int test__backward_ring_buffer(int subtest __maybe_unused) err =perf_evlist__open (evlist);if (err <0 ) {pr_debug ("perf_evlist__open: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; }
tools/perf/tests/bpf.c +2 -2
@@ -143,14 +143,14 @@ static int do_test(struct bpf_object *obj, int (*func)(void), err =perf_evlist__open (evlist);if (err <0 ) {pr_debug ("perf_evlist__open: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; } err =perf_evlist__mmap (evlist, opts.mmap_pages, false);if (err <0 ) {pr_debug ("perf_evlist__mmap: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; }
tools/perf/tests/builtin-test.c +1 -1
@@ -258,7 +258,7 @@ static int run_test(struct test *test, int subtest)if (child <0 ) {pr_err ("failed to fork test: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf)));return -1 ; }
tools/perf/tests/event-times.c +1 -1
@@ -37,7 +37,7 @@ static int attach__enable_on_exec(struct perf_evlist *evlist) err =perf_evlist__open (evlist);if (err <0 ) {pr_debug ("perf_evlist__open: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf)));return err; }
tools/perf/tests/mmap-basic.c +3 -3
@@ -49,7 +49,7 @@ int test__basic_mmap(int subtest __maybe_unused)sched_setaffinity (0 ,sizeof (cpu_set), &cpu_set);if (sched_setaffinity (0 ,sizeof (cpu_set), &cpu_set) <0 ) {pr_debug ("sched_setaffinity() failed on CPU %d: %s " , - cpus->map[0 ],strerror_r (errno, sbuf,sizeof (sbuf))); + cpus->map[0 ],str_error_r (errno, sbuf,sizeof (sbuf))); goto out_free_cpus; }
@@ -79,7 +79,7 @@ int test__basic_mmap(int subtest __maybe_unused)if (perf_evsel__open (evsels[i], cpus, threads) <0 ) {pr_debug ("failed to open counter: %s, " "tweak /proc/sys/kernel/perf_event_paranoid?\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; }
@@ -89,7 +89,7 @@ int test__basic_mmap(int subtest __maybe_unused)if (perf_evlist__mmap (evlist,128 , true) <0 ) {pr_debug ("failed to mmap events: %d (%s)\n" , errno, -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; }
tools/perf/tests/openat-syscall-all-cpus.c +2 -2
@@ -41,7 +41,7 @@ int test__openat_syscall_event_on_all_cpus(int subtest __maybe_unused)if (perf_evsel__open (evsel, cpus, threads) <0 ) {pr_debug ("failed to open counter: %s, " "tweak /proc/sys/kernel/perf_event_paranoid?\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_evsel_delete; }
@@ -62,7 +62,7 @@ int test__openat_syscall_event_on_all_cpus(int subtest __maybe_unused)if (sched_setaffinity (0 ,sizeof (cpu_set), &cpu_set) <0 ) {pr_debug ("sched_setaffinity() failed on CPU %d: %s " , cpus->map[cpu], -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_close_fd; }for (i =0 ; i < ncalls; ++i) {
tools/perf/tests/openat-syscall-tp-fields.c +2 -2
@@ -51,14 +51,14 @@ int test__syscall_openat_tp_fields(int subtest __maybe_unused) err =perf_evlist__open (evlist);if (err <0 ) {pr_debug ("perf_evlist__open: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; } err =perf_evlist__mmap (evlist,UINT_MAX , false);if (err <0 ) {pr_debug ("perf_evlist__mmap: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; }
tools/perf/tests/openat-syscall.c +1 -1
@@ -29,7 +29,7 @@ int test__openat_syscall_event(int subtest __maybe_unused)if (perf_evsel__open_per_thread (evsel, threads) <0 ) {pr_debug ("failed to open counter: %s, " "tweak /proc/sys/kernel/perf_event_paranoid?\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_evsel_delete; }
tools/perf/tests/perf-record.c +4 -4
@@ -104,7 +104,7 @@ int test__PERF_RECORD(int subtest __maybe_unused) err =sched__get_first_possible_cpu (evlist->workload.pid, &cpu_mask);if (err <0 ) {pr_debug ("sched__get_first_possible_cpu: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; }
@@ -115,7 +115,7 @@ int test__PERF_RECORD(int subtest __maybe_unused)*/ if (sched_setaffinity (evlist->workload.pid, cpu_mask_size, &cpu_mask) <0 ) {pr_debug ("sched_setaffinity: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; }
@@ -126,7 +126,7 @@ int test__PERF_RECORD(int subtest __maybe_unused) err =perf_evlist__open (evlist);if (err <0 ) {pr_debug ("perf_evlist__open: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; }
@@ -138,7 +138,7 @@ int test__PERF_RECORD(int subtest __maybe_unused) err =perf_evlist__mmap (evlist, opts.mmap_pages, false);if (err <0 ) {pr_debug ("perf_evlist__mmap: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; }
tools/perf/tests/sw-clock.c +2 -2
@@ -70,7 +70,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) err = -errno;pr_debug ("Couldn't open evlist: %s\nHint: check %s, using %" PRIu64" in this test.\n" , -strerror_r (errno, sbuf,sizeof (sbuf)), +str_error_r (errno, sbuf,sizeof (sbuf)), knob, (u64 )attr.sample_freq); goto out_delete_evlist; }
@@ -78,7 +78,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) err =perf_evlist__mmap (evlist,128 , true);if (err <0 ) {pr_debug ("failed to mmap event: %d (%s)\n" , errno, -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; }
tools/perf/tests/task-exit.c +2 -2
@@ -91,13 +91,13 @@ int test__task_exit(int subtest __maybe_unused) err =perf_evlist__open (evlist);if (err <0 ) {pr_debug ("Couldn't open the evlist: %s\n" , -strerror_r (-err, sbuf,sizeof (sbuf))); +str_error_r (-err, sbuf,sizeof (sbuf))); goto out_delete_evlist; }if (perf_evlist__mmap (evlist,128 , true) <0 ) {pr_debug ("failed to mmap events: %d (%s)\n" , errno, -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); goto out_delete_evlist; }
tools/perf/ui/browsers/hists.c +1 -1
@@ -2029,7 +2029,7 @@ static int hist_browser__dump(struct hist_browser *browser) fp =fopen (filename,"w" );if (fp ==NULL ) {char bf[64 ]; -const char *err =strerror_r (errno, bf,sizeof (bf)); +const char *err =str_error_r (errno, bf,sizeof (bf));ui_helpline__fpush ("Couldn't write to %s: %s" , filename, err);return -1 ; }
tools/perf/util/Build +5 -0
@@ -70,6 +70,7 @@ libperf-y += stat.o libperf-y += stat-shadow.o libperf-y += record.o libperf-y += srcline.o +libperf-y += str_error_r.o libperf-y += data.o libperf-y += tsc.o libperf-y += cloexec.o
@@ -173,6 +174,10 @@ $(OUTPUT)util/libstring.o: ../lib/string.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) +$(OUTPUT)util/str_error_r.o: ../lib/str_error_r.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c) + $(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c)
tools/perf/util/bpf-loader.c +1 -1
@@ -1589,7 +1589,7 @@ bpf_loader_strerror(int err, char *buf, size_t size)snprintf (buf, size,"Unknown bpf loader error %d" , err); else snprintf(buf, size, "%s", - strerror_r(err, sbuf, sizeof(sbuf))); + str_error_r(err, sbuf, sizeof(sbuf))); buf[size -1 ] ='\0' ;return -1 ;
tools/perf/util/cloexec.c +2 -2
@@ -58,7 +58,7 @@ static int perf_flag_probe(void)WARN_ONCE (err !=EINVAL && err !=EBUSY ,"perf_event_open(..., PERF_FLAG_FD_CLOEXEC) failed with unexpected error %d (%s)\n" , - err,strerror_r (err, sbuf,sizeof (sbuf))); + err,str_error_r (err, sbuf,sizeof (sbuf)));/* not supported, confirm error related to PERF_FLAG_FD_CLOEXEC */ while (1 ) {
@@ -76,7 +76,7 @@ static int perf_flag_probe(void)if (WARN_ONCE (fd <0 && err !=EBUSY ,"perf_event_open(..., 0) failed unexpectedly with error %d (%s)\n" , - err,strerror_r (err, sbuf,sizeof (sbuf)))) + err,str_error_r (err, sbuf,sizeof (sbuf))))return -1 ;return 0 ;
tools/perf/util/data.c +2 -2
@@ -57,7 +57,7 @@ static int open_file_read(struct perf_data_file *file)int err = errno;pr_err ("failed to open %s: %s" , file->path, -strerror_r (err, sbuf,sizeof (sbuf))); +str_error_r (err, sbuf,sizeof (sbuf)));if (err ==ENOENT && !strcmp (file->path,"perf.data" ))pr_err (" (try 'perf record' first)" );pr_err ("\n" );
@@ -99,7 +99,7 @@ static int open_file_write(struct perf_data_file *file)if (fd <0 )pr_err ("failed to open %s : %s\n" , file->path, -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf)));return fd; }
tools/perf/util/debug.h +1 -1
@@ -38,7 +38,7 @@ extern int debug_data_convert;#define pr_oe_time (t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__)#define pr_oe_time2 (t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) -#define STRERR_BUFSIZE 128/* For the buffer size of strerror_r */ +#define STRERR_BUFSIZE 128/* For the buffer size of str_error_r */ int dump_printf (const char *fmt, ...) __attribute__((format (printf,1 ,2 )));void trace_event (union perf_event *event);
tools/perf/util/dso.c +3 -3
@@ -335,7 +335,7 @@ static int do_open(char *name)return fd;pr_debug ("dso open failed: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf)));if (!dso__data_open_cnt || errno !=EMFILE )break ;
@@ -786,7 +786,7 @@ static int data_file_size(struct dso *dso, struct machine *machine)if (fstat (dso->data.fd, &st) <0 ) { ret = -errno;pr_err ("dso cache fstat failed: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); dso->data.status =DSO_DATA_STATUS_ERROR ; goto out; }
@@ -1366,7 +1366,7 @@ int dso__strerror_load(struct dso *dso, char *buf, size_t buflen)BUG_ON (buflen ==0 );if (errnum >=0 ) { -const char *err =strerror_r (errnum, buf, buflen); +const char *err =str_error_r (errnum, buf, buflen);if (err != buf)scnprintf (buf, buflen,"%s" , err);
tools/perf/util/evlist.c +2 -2
@@ -1790,7 +1790,7 @@ int perf_evlist__strerror_open(struct perf_evlist *evlist, int err, char *buf, size_t size) { int printed, value; -char sbuf[STRERR_BUFSIZE ], *emsg =strerror_r (err, sbuf,sizeof (sbuf)); +char sbuf[STRERR_BUFSIZE ], *emsg =str_error_r (err, sbuf,sizeof (sbuf));switch (err) {case EACCES :
@@ -1842,7 +1842,7 @@ out_default:int perf_evlist__strerror_mmap (struct perf_evlist *evlist,int err,char *buf,size_t size) { -char sbuf[STRERR_BUFSIZE ], *emsg =strerror_r (err, sbuf,sizeof (sbuf)); +char sbuf[STRERR_BUFSIZE ], *emsg =str_error_r (err, sbuf,sizeof (sbuf));int pages_attempted = evlist->mmap_len /1024 , pages_max_per_user, printed =0 ;switch (err) {
tools/perf/util/evsel.c +1 -1
@@ -2419,7 +2419,7 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,"The sys_perf_event_open() syscall returned with %d (%s) for event (%s).\n" "/bin/dmesg may provide additional information.\n" "No CONFIG_PERF_EVENTS=y kernel support configured?" , - err,strerror_r (err, sbuf,sizeof (sbuf)), + err,str_error_r (err, sbuf,sizeof (sbuf)), perf_evsel__name(evsel)); }
tools/perf/util/llvm-utils.c +4 -4
@@ -106,7 +106,7 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz) file =popen (cmd,"r" );if (!file) {pr_err ("ERROR: unable to popen cmd: %s\n" , -strerror_r (errno, serr,sizeof (serr))); +str_error_r (errno, serr,sizeof (serr)));return -EINVAL ; }
@@ -140,7 +140,7 @@ read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz)if (ferror (file)) {pr_err ("ERROR: error occurred when reading from pipe: %s\n" , -strerror_r (errno, serr,sizeof (serr))); +str_error_r (errno, serr,sizeof (serr))); err = -EIO ; goto errout; }
@@ -382,7 +382,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,if (path[0 ] !='-' &&realpath (path, abspath) ==NULL ) { err = errno;pr_err ("ERROR: problems with path %s: %s\n" , - path,strerror_r (err, serr,sizeof (serr))); + path,str_error_r (err, serr,sizeof (serr)));return -err; }
@@ -410,7 +410,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,if (nr_cpus_avail <=0 ) {pr_err ("WARNING:\tunable to get available CPUs in this system: %s\n" -" \tUse 128 instead.\n" ,strerror_r (errno, serr,sizeof (serr))); +" \tUse 128 instead.\n" ,str_error_r (errno, serr,sizeof (serr))); nr_cpus_avail =128 ; } snprintf(nr_cpus_avail_str, sizeof(nr_cpus_avail_str), "%d",
tools/perf/util/probe-event.c +3 -3
@@ -468,7 +468,7 @@ static struct debuginfo *open_debuginfo(const char *module, bool silent) err =kernel_get_module_dso (module, &dso);if (err <0 ) {if (!dso || dso->load_errno ==0 ) { -if (!strerror_r (-err, reason,STRERR_BUFSIZE )) +if (!str_error_r (-err, reason,STRERR_BUFSIZE ))strcpy (reason,"(unknown)" ); }else dso__strerror_load (dso, reason,STRERR_BUFSIZE );
@@ -806,7 +806,7 @@ static int __show_one_line(FILE *fp, int l, bool skip, bool show_num) error:if (ferror (fp)) {pr_warning ("File read error: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf)));return -1 ; }return 0 ;
@@ -886,7 +886,7 @@ static int __show_line_range(struct line_range *lr, const char *module, fp =fopen (lr->path,"r" );if (fp ==NULL ) {pr_warning ("Failed to open %s: %s\n" , lr->path, -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf)));return -errno; }/* Skip to starting line number */
tools/perf/util/probe-file.c +5 -5
@@ -50,7 +50,7 @@ static void print_open_warning(int err, bool uprobe)else pr_warning ("Failed to open %cprobe_events: %s\n" , uprobe ?'u' :'k' , -strerror_r (-err, sbuf,sizeof (sbuf))); +str_error_r (-err, sbuf,sizeof (sbuf))); }static void print_both_open_warning (int kerr,int uerr)
@@ -64,9 +64,9 @@ static void print_both_open_warning(int kerr, int uerr)else {char sbuf[STRERR_BUFSIZE ];pr_warning ("Failed to open kprobe events: %s.\n" , -strerror_r (-kerr, sbuf,sizeof (sbuf))); +str_error_r (-kerr, sbuf,sizeof (sbuf)));pr_warning ("Failed to open uprobe events: %s.\n" , -strerror_r (-uerr, sbuf,sizeof (sbuf))); +str_error_r (-uerr, sbuf,sizeof (sbuf))); } }
@@ -224,7 +224,7 @@ int probe_file__add_event(int fd, struct probe_trace_event *tev)if (write (fd, buf,strlen (buf)) < (int )strlen (buf)) { ret = -errno;pr_warning ("Failed to write event: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf))); } }free (buf);
@@ -262,7 +262,7 @@ static int __del_trace_probe_event(int fd, struct str_node *ent)return 0 ; error:pr_warning ("Failed to delete event: %s\n" , -strerror_r (-ret, buf,sizeof (buf))); +str_error_r (-ret, buf,sizeof (buf)));return ret; }
tools/perf/util/probe-finder.c +2 -2
@@ -381,7 +381,7 @@ formatted:if (ret >=16 ) ret = -E2BIG ;pr_warning ("Failed to convert variable type: %s\n" , -strerror_r (-ret, sbuf,sizeof (sbuf))); +str_error_r (-ret, sbuf,sizeof (sbuf)));return ret; } tvar->type =strdup (buf);
@@ -809,7 +809,7 @@ static int find_lazy_match_lines(struct intlist *list, fp =fopen (fname,"r" );if (!fp) {pr_warning ("Failed to open %s: %s\n" , fname, -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf)));return -errno; }
tools/perf/util/python-ext-sources +1 -0
@@ -13,6 +13,7 @@ util/cpumap.c ../lib/bitmap.c ../lib/find_bit.c ../lib/hweight.c +../lib/str_error_r.c util/thread_map.c util/util.c util/xyarray.c
tools/perf/util/target.c +1 -1
@@ -121,7 +121,7 @@ int target__strerror(struct target *target, int errnum,BUG_ON (buflen ==0 );if (errnum >=0 ) { -const char *err =strerror_r (errnum, buf, buflen); +const char *err =str_error_r (errnum, buf, buflen);if (err != buf)scnprintf (buf, buflen,"%s" , err);
tools/perf/util/util.h +1 -0
@@ -360,4 +360,5 @@ typedef void (*print_binary_t)(enum binary_printer_ops,void print_binary (unsigned char *data,size_t len,size_t bytes_per_line,print_binary_t printer,void *extra); +#endif /* GIT_COMPAT_UTIL_H */
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 14/66 perf bench: Add missing pthread.h include for CPU_*() macros
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/bench/futex-hash.c | 6 +++--- tools/perf/bench/futex-lock-pi.c | 4 +++- tools/perf/bench/futex-requeue.c | 4 +++- tools/perf/bench/futex-wake-parallel.c | 4 +++- tools/perf/bench/futex-wake.c | 4 +++- tools/perf/bench/numa.c | 4 +++- 6 files changed, 18 insertions(+), 8 deletions(-)
tools/perf/bench/futex-hash.c +3 -3
@@ -8,8 +8,10 @@* many threads and futexes as possible. */ +/* For the CLR_() macros */ +#include <pthread.h> +#include "../perf.h" -#include "../util/util.h" #include "../util/stat.h" #include <subcmd/parse-options.h> #include "../util/header.h"
@@ -17,9 +19,7 @@#include "futex.h" #include <err.h> -#include <stdlib.h> #include <sys/time.h> -#include <pthread.h> static unsigned int nthreads =0 ;static unsigned int nsecs =10 ;
tools/perf/bench/futex-lock-pi.c +3 -1
@@ -2,6 +2,9 @@* Copyright (C) 2015 Davidlohr Bueso. */ +/* For the CLR_() macros */ +#include <pthread.h> +#include "../perf.h" #include "../util/util.h" #include "../util/stat.h"
@@ -13,7 +16,6 @@#include <err.h> #include <stdlib.h> #include <sys/time.h> -#include <pthread.h> struct worker {int tid;
tools/perf/bench/futex-requeue.c +3 -1
@@ -8,6 +8,9 @@* requeues without waking up any tasks -- thus mimicking a regular futex_wait. */ +/* For the CLR_() macros */ +#include <pthread.h> +#include "../perf.h" #include "../util/util.h" #include "../util/stat.h"
@@ -19,7 +22,6 @@#include <err.h> #include <stdlib.h> #include <sys/time.h> -#include <pthread.h> static u_int32_t futex1 =0 , futex2 =0 ;
tools/perf/bench/futex-wake-parallel.c +3 -1
@@ -7,6 +7,9 @@* it can be used to measure futex_wake() changes. */ +/* For the CLR_() macros */ +#include <pthread.h> +#include "../perf.h" #include "../util/util.h" #include "../util/stat.h"
@@ -18,7 +21,6 @@#include <err.h> #include <stdlib.h> #include <sys/time.h> -#include <pthread.h> struct thread_data {pthread_t worker;
tools/perf/bench/futex-wake.c +3 -1
@@ -8,6 +8,9 @@* one or more tasks, and thus the waitqueue is never empty. */ +/* For the CLR_() macros */ +#include <pthread.h> +#include "../perf.h" #include "../util/util.h" #include "../util/stat.h"
@@ -19,7 +22,6 @@#include <err.h> #include <stdlib.h> #include <sys/time.h> -#include <pthread.h> /* all threads will block on the same futex */ static u_int32_t futex1 =0 ;
tools/perf/bench/numa.c +3 -1
@@ -4,6 +4,9 @@* numa: Simulate NUMA-sensitive workload and measure their NUMA performance */ +/* For the CLR_() macros */ +#include <pthread.h> +#include "../perf.h" #include "../builtin.h" #include "../util/util.h"
@@ -21,7 +24,6 @@#include <stdlib.h> #include <string.h> #include <unistd.h> -#include <pthread.h> #include <sys/mman.h> #include <sys/time.h> #include <sys/resource.h>
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 15/66 perf tests: Add missing pthread.h include for CPU_*() macros
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/tests/mmap-basic.c | 3 +++ tools/perf/tests/openat-syscall-all-cpus.c | 3 +++ tools/perf/tests/perf-record.c | 3 +++ 3 files changed, 9 insertions(+)
tools/perf/tests/mmap-basic.c +3 -0
@@ -1,3 +1,6 @@ +/* For the CLR_() macros */ +#include <pthread.h> +#include "evlist.h" #include "evsel.h" #include "thread_map.h"
tools/perf/tests/openat-syscall-all-cpus.c +3 -0
@@ -1,3 +1,6 @@ +/* For the CPU_* macros */ +#include <pthread.h> +#include <api/fs/fs.h> #include <linux/err.h> #include "evsel.h"
tools/perf/tests/perf-record.c +3 -0
@@ -1,3 +1,6 @@ +/* For the CLR_() macros */ +#include <pthread.h> +#include <sched.h> #include "evlist.h" #include "evsel.h"
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 16/66 perf trace: Add conditional define for AT_FDCWD
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
This one was only defined if _GNU_SOURCE was set in older glibc versions, check that and provide the define in such cases.
--- tools/perf/builtin-trace.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/builtin-trace.c +4 -0
@@ -334,6 +334,10 @@ static size_t syscall_arg__scnprintf_fd(char *bf, size_t size,#define SCA_FD syscall_arg__scnprintf_fd +#ifndef AT_FDCWD +#define AT_FDCWD -100 +#endif +static size_t syscall_arg__scnprintf_fd_at (char *bf,size_t size,struct syscall_arg *arg) {
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 17/66 perf tests openat-syscall-tp-fields: Add some conditional defines
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
These were only defined if _GNU_SOURCE was set in older glibc versions, check that and provide the defines in such cases.
--- tools/perf/tests/openat-syscall-tp-fields.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/perf/tests/openat-syscall-tp-fields.c +7 -0
@@ -6,6 +6,13 @@#include "tests.h" #include "debug.h" +#ifndef O_DIRECTORY +#define O_DIRECTORY 00200000 +#endif +#ifndef AT_FDCWD +#define AT_FDCWD -100 +#endif +int test__syscall_openat_tp_fields (int subtest__maybe_unused ) {struct record_opts opts = {
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 18/66 perf bench: Disentangle headers
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We should try avoiding that perf.h header, it includes way too much stuff, making it difficult to use things like setting _GNU_SOURCE only on a small set of headers.
--- tools/perf/bench/futex-hash.c | 8 ++++++-- tools/perf/bench/futex-lock-pi.c | 6 +++--- tools/perf/bench/futex-requeue.c | 6 +++--- tools/perf/bench/futex-wake-parallel.c | 6 +++--- tools/perf/bench/futex-wake.c | 6 +++--- 5 files changed, 18 insertions(+), 14 deletions(-)
tools/perf/bench/futex-hash.c +6 -2
@@ -11,10 +11,14 @@/* For the CLR_() macros */ #include <pthread.h> -#include "../perf.h" +#include <errno.h> +#include <signal.h> +#include <stdlib.h> +#include <linux/kernel.h> +#include <sys/time.h> +#include "../util/stat.h" #include <subcmd/parse-options.h> -#include "../util/header.h" #include "bench.h" #include "futex.h"
tools/perf/bench/futex-lock-pi.c +3 -3
@@ -5,11 +5,11 @@/* For the CLR_() macros */ #include <pthread.h> -#include "../perf.h" -#include "../util/util.h" +#include <signal.h> #include "../util/stat.h" #include <subcmd/parse-options.h> -#include "../util/header.h" +#include <linux/kernel.h> +#include <errno.h> #include "bench.h" #include "futex.h"
tools/perf/bench/futex-requeue.c +3 -3
@@ -11,11 +11,11 @@/* For the CLR_() macros */ #include <pthread.h> -#include "../perf.h" -#include "../util/util.h" +#include <signal.h> #include "../util/stat.h" #include <subcmd/parse-options.h> -#include "../util/header.h" +#include <linux/kernel.h> +#include <errno.h> #include "bench.h" #include "futex.h"
tools/perf/bench/futex-wake-parallel.c +3 -3
@@ -10,11 +10,11 @@/* For the CLR_() macros */ #include <pthread.h> -#include "../perf.h" -#include "../util/util.h" +#include <signal.h> #include "../util/stat.h" #include <subcmd/parse-options.h> -#include "../util/header.h" +#include <linux/kernel.h> +#include <errno.h> #include "bench.h" #include "futex.h"
tools/perf/bench/futex-wake.c +3 -3
@@ -11,11 +11,11 @@/* For the CLR_() macros */ #include <pthread.h> -#include "../perf.h" -#include "../util/util.h" +#include <signal.h> #include "../util/stat.h" #include <subcmd/parse-options.h> -#include "../util/header.h" +#include <linux/kernel.h> +#include <errno.h> #include "bench.h" #include "futex.h"
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 19/66 perf tools: Move syscall number fallbacks from perf-sys.h to tools/arch/x86/include/asm/
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
And remove the empty tools/arch/x86/include/asm/unistd_{32,64}.h files introduced by eae7a755ee81 ("perf tools, x86: Build perf on older user-space as well").
This way we get closer to mirroring the kernel for cases where __NR_ can't be found for some include path/_GNU_SOURCE/whatever scenario.
--- tools/arch/x86/include/asm/unistd_32.h | 9 +++++++++ tools/arch/x86/include/asm/unistd_64.h | 9 +++++++++ tools/perf/config/Makefile | 1 + tools/perf/perf-sys.h | 18 ------------------ tools/perf/util/include/asm/unistd_32.h | 1 - tools/perf/util/include/asm/unistd_64.h | 1 - 6 files changed, 19 insertions(+), 20 deletions(-) create mode 100644 tools/arch/x86/include/asm/unistd_32.h create mode 100644 tools/arch/x86/include/asm/unistd_64.h delete mode 100644 tools/perf/util/include/asm/unistd_32.h delete mode 100644 tools/perf/util/include/asm/unistd_64.h
tools/arch/x86/include/asm/unistd_32.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __NR_perf_event_open +# define __NR_perf_event_open 336 +#endif +#ifndef __NR_futex +# define __NR_futex 240 +#endif +#ifndef __NR_gettid +# define __NR_gettid 224 +#endif
tools/arch/x86/include/asm/unistd_64.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __NR_perf_event_open +# define __NR_perf_event_open 298 +#endif +#ifndef __NR_futex +# define __NR_futex 202 +#endif +#ifndef __NR_gettid +# define __NR_gettid 186 +#endif
tools/perf/config/Makefile +1 -0
@@ -209,6 +209,7 @@ CFLAGS += -I$(src-perf)/arch/$(ARCH)/include CFLAGS += -I$(srctree)/tools/include/ CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi CFLAGS += -I$(srctree)/arch/$(ARCH)/include +CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/include CFLAGS += -I$(srctree)/include/uapi CFLAGS += -I$(srctree)/include
tools/perf/perf-sys.h +0 -18
@@ -11,29 +11,11 @@#if defined(__i386__)#define cpu_relax () asm volatile("rep; nop" ::: "memory");#define CPUINFO_PROC {"model name"} -#ifndef __NR_perf_event_open -# define __NR_perf_event_open 336 -#endif -#ifndef __NR_futex -# define __NR_futex 240 -#endif -#ifndef __NR_gettid -# define __NR_gettid 224 -#endif #endif #if defined(__x86_64__)#define cpu_relax () asm volatile("rep; nop" ::: "memory");#define CPUINFO_PROC {"model name"} -#ifndef __NR_perf_event_open -# define __NR_perf_event_open 298 -#endif -#ifndef __NR_futex -# define __NR_futex 202 -#endif -#ifndef __NR_gettid -# define __NR_gettid 186 -#endif #endif #ifdef __powerpc__
tools/perf/util/include/asm/unistd_32.h deleted +0 -1
@@ -1 +0,0 @@ -
tools/perf/util/include/asm/unistd_64.h deleted +0 -1
@@ -1 +0,0 @@ -
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 20/66 perf strbuf: Add missing headers
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We were only indirectly and by luck getting types, etc needed for this file, fix it.
--- tools/perf/util/strbuf.c | 2 +- tools/perf/util/strbuf.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/strbuf.c +1 -1
@@ -1,5 +1,5 @@#include "debug.h" -#include "cache.h" +#include "util.h" #include <linux/kernel.h> int prefixcmp (const char *str,const char *prefix)
tools/perf/util/strbuf.h +3 -0
@@ -40,6 +40,9 @@#include <assert.h> #include <stdarg.h> +#include <stddef.h> +#include <string.h> +#include <sys/types.h> extern char strbuf_slopbuf[];struct strbuf {
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 21/66 perf quote: Disentangle headers
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
No need to include stdio.h from quote.h, also forward declare strbuf.
--- tools/perf/util/quote.c | 4 +++- tools/perf/util/quote.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-)
tools/perf/util/quote.c +3 -1
@@ -1,5 +1,7 @@ -#include "cache.h" +#include <stdlib.h> +#include "strbuf.h" #include "quote.h" +#include "util.h" /* Help to copy the thing properly quoted for the shell safety. * any single quote is replaced with '\'', any exclamation point
tools/perf/util/quote.h +2 -1
@@ -2,7 +2,6 @@#define __PERF_QUOTE_H#include <stddef.h> -#include <stdio.h> /* Help to copy the thing properly quoted for the shell safety. * any single quote is replaced with '\'', any exclamation point
@@ -24,6 +23,8 @@* sq_quote() in a real application. */ +struct strbuf ; +int sq_quote_argv (struct strbuf *,const char **argv,size_t maxlen);#endif /* __PERF_QUOTE_H */
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 22/66 perf tests cpumap: Add missing headers
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
It was getting all sort of needed stuff by sheer luck, via indirect includes, fix it.
--- tools/perf/tests/cpumap.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/perf/tests/cpumap.c +7 -0
@@ -1,5 +1,12 @@#include "tests.h" +#include <stdio.h> #include "cpumap.h" +#include "event.h" +#include <string.h> +#include <linux/bitops.h> +#include "debug.h" + +struct machine ; static int process_event_mask(struct perf_tool *tool __maybe_unused, union perf_event *event,
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 23/66 perf test fdarray: Add missing poll.h header
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
It uses poll() but was getting the needed header by chance, do it explicitely.
--- tools/perf/tests/fdarray.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/tests/fdarray.c +1 -0
@@ -1,4 +1,5 @@#include <api/fd/array.h> +#include <poll.h> #include "util/debug.h" #include "tests/tests.h"
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 24/66 perf tests x86 rdpmc: Add missing headers
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Another case of a file using definitions and getting them by chance, from indirect header inclusion, fix it.
--- tools/perf/arch/x86/tests/rdpmc.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/arch/x86/tests/rdpmc.c +4 -0
@@ -1,12 +1,16 @@ +#include <errno.h> #include <unistd.h> #include <stdlib.h> #include <signal.h> #include <sys/mman.h> +#include <sys/types.h> +#include <sys/wait.h> #include <linux/types.h> #include "perf.h" #include "debug.h" #include "tests/tests.h" #include "cloexec.h" +#include "util.h" #include "arch-tests.h" static u64 rdpmc (unsigned int counter)
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 25/66 perf tools: Add missing header to color.c
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
It uses isatty(), so needs unistd.h, include it.
--- tools/perf/util/color.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/color.c +1 -0
@@ -3,6 +3,7 @@#include "config.h" #include "color.h" #include <math.h> +#include <unistd.h> int perf_use_color_default =-1 ;
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 26/66 perf tools: Remove needless includes from cache.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
The cache.h header doesn't use any of the definitions in some of the headers it includes, ditch them and fix the fallout, where files were getting stuff they needed just because they were including it, sometimes not using what it really exports at all.
--- tools/perf/arch/common.c | 1 + tools/perf/tests/llvm.c | 1 + tools/perf/ui/gtk/util.c | 1 + tools/perf/ui/helpline.c | 1 + tools/perf/ui/tui/setup.c | 2 ++ tools/perf/util/alias.c | 1 + tools/perf/util/cache.h | 3 --- tools/perf/util/levenshtein.c | 4 +++- tools/perf/util/llvm-utils.c | 2 ++ tools/perf/util/path.c | 2 ++ tools/perf/util/target.c | 1 + 11 files changed, 15 insertions(+), 4 deletions(-)
tools/perf/arch/common.c +1 -0
@@ -1,6 +1,7 @@#include <stdio.h> #include <sys/utsname.h> #include "common.h" +#include "../util/util.h" #include "../util/debug.h" const char *const arm_triplets[] = {
tools/perf/tests/llvm.c +1 -0
@@ -5,6 +5,7 @@#include "llvm.h" #include "tests.h" #include "debug.h" +#include "util.h" #ifdef HAVE_LIBBPF_SUPPORT static int test__bpf_parsing (void *obj_buf,size_t obj_buf_sz)
tools/perf/ui/gtk/util.c +1 -0
@@ -1,4 +1,5 @@#include "../util.h" +#include "../../util/util.h" #include "../../util/debug.h" #include "gtk.h"
tools/perf/ui/helpline.c +1 -0
@@ -5,6 +5,7 @@#include "../debug.h" #include "helpline.h" #include "ui.h" +#include "../util.h" char ui_helpline__current[512 ];
tools/perf/ui/tui/setup.c +2 -0
@@ -1,3 +1,4 @@ +#include <errno.h> #include <signal.h> #include <stdbool.h> #ifdef HAVE_BACKTRACE_SUPPORT
@@ -6,6 +7,7 @@#include "../../util/cache.h" #include "../../util/debug.h" +#include "../../util/util.h" #include "../browser.h" #include "../helpline.h" #include "../ui.h"
tools/perf/util/alias.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "util.h" #include "config.h" static const char *alias_key;
tools/perf/util/cache.h +0 -3
@@ -1,11 +1,8 @@#ifndef __PERF_CACHE_H#define __PERF_CACHE_H -#include <stdbool.h> -#include "util.h" #include "strbuf.h" #include <subcmd/pager.h> -#include "../perf.h" #include "../ui/ui.h" #include <linux/string.h>
tools/perf/util/levenshtein.c +3 -1
@@ -1,5 +1,7 @@ -#include "cache.h" #include "levenshtein.h" +#include <errno.h> +#include <stdlib.h> +#include <string.h> /* * This function implements the Damerau-Levenshtein algorithm to
tools/perf/util/llvm-utils.c +2 -0
@@ -3,12 +3,14 @@* Copyright (C) 2015, Huawei Inc. */ +#include <errno.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include "debug.h" #include "llvm-utils.h" #include "config.h" +#include "util.h" #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \ "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\
tools/perf/util/path.c +2 -0
@@ -11,6 +11,8 @@* which is what it's designed for. */ #include "cache.h" +#include "util.h" +#include <limits.h> static char bad_path[] ="/bad-path/" ;/*
tools/perf/util/target.c +1 -0
@@ -7,6 +7,7 @@*/ #include "target.h" +#include "util.h" #include "debug.h" #include <pwd.h>
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 27/66 perf evsel: Uninline the is_function_event method
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
So that we don't have to carry a string.h header in evsel.h
--- tools/perf/util/evsel.c | 18 ++++++++++++++++++ tools/perf/util/evsel.h | 18 +----------------- 2 files changed, 19 insertions(+), 17 deletions(-)
tools/perf/util/evsel.c +18 -0
@@ -200,6 +200,24 @@ void perf_evsel__set_sample_id(struct perf_evsel *evsel, evsel->attr.read_format |=PERF_FORMAT_ID ; } +/** +* perf_evsel__is_function_event - Return whether given evsel is a function +* trace event +* +* @evsel - evsel selector to be tested +* +* Return %true if event is function trace event +*/ +bool perf_evsel__is_function_event (struct perf_evsel *evsel) +{ +#define FUNCTION_EVENT "ftrace:function" + +return evsel->name && + !strncmp (FUNCTION_EVENT , evsel->name,sizeof (FUNCTION_EVENT )); + +#undef FUNCTION_EVENT +} +void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr,int idx) {
tools/perf/util/evsel.h +1 -17
@@ -355,23 +355,7 @@ static inline bool perf_evsel__is_group_event(struct perf_evsel *evsel)return perf_evsel__is_group_leader (evsel) && evsel->nr_members >1 ; } -/** -* perf_evsel__is_function_event - Return whether given evsel is a function -* trace event -* -* @evsel - evsel selector to be tested -* -* Return %true if event is function trace event -*/ -static inline bool perf_evsel__is_function_event (struct perf_evsel *evsel) -{ -#define FUNCTION_EVENT "ftrace:function" - -return evsel->name && - !strncmp (FUNCTION_EVENT , evsel->name,sizeof (FUNCTION_EVENT )); - -#undef FUNCTION_EVENT -} +bool perf_evsel__is_function_event (struct perf_evsel *evsel);static inline bool perf_evsel__is_bpf_output (struct perf_evsel *evsel) {
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 28/66 perf tools: Uninline scnprintf() and vscnprint()
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
They were in tools/include/linux/kernel.h, requiring that it in turn included stdio.h, which is way too heavy.
--- tools/include/linux/kernel.h | 28 +++------------------------- tools/lib/vsprintf.c | 24 ++++++++++++++++++++++++ tools/objtool/builtin-check.c | 1 + tools/perf/MANIFEST | 1 + tools/perf/util/Build | 5 +++++ tools/perf/util/color.c | 2 ++ tools/perf/util/dso.h | 1 + tools/perf/util/help-unknown-cmd.c | 1 + tools/perf/util/python-ext-sources | 1 + 9 files changed, 39 insertions(+), 25 deletions(-) create mode 100644 tools/lib/vsprintf.c
tools/include/linux/kernel.h +3 -25
@@ -2,8 +2,7 @@#define __TOOLS_LINUX_KERNEL_H#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> +#include <stddef.h> #include <assert.h> #define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d))
@@ -70,29 +69,8 @@#define cpu_to_le64 (x) (x)#define cpu_to_le32 (x) (x) -static inline int -vscnprintf (char *buf,size_t size,const char *fmt,va_list args) -{ -int i; -ssize_t ssize = size; - - i =vsnprintf (buf, size, fmt, args); - -return (i >= ssize) ? (ssize -1 ) : i; -} - -static inline int scnprintf (char * buf,size_t size,const char * fmt, ...) -{ -va_list args; -ssize_t ssize = size; -int i; - -va_start (args, fmt); - i =vsnprintf (buf, size, fmt, args); -va_end (args); - -return (i >= ssize) ? (ssize -1 ) : i; -} +int vscnprintf (char *buf,size_t size,const char *fmt,va_list args); +int scnprintf (char * buf,size_t size,const char * fmt, ...);/* * This looks more complex than it should be. But we need to
tools/lib/vsprintf.c new file +24 -0
@@ -0,0 +1,24 @@ +#include <sys/types.h> +#include <linux/kernel.h> +#include <stdio.h> + +int vscnprintf (char *buf,size_t size,const char *fmt,va_list args) +{ +int i =vsnprintf (buf, size, fmt, args); +ssize_t ssize = size; + +return (i >= ssize) ? (ssize -1 ) : i; +} + +int scnprintf (char * buf,size_t size,const char * fmt, ...) +{ +ssize_t ssize = size; +va_list args; +int i; + +va_start (args, fmt); + i =vsnprintf (buf, size, fmt, args); +va_end (args); + +return (i >= ssize) ? (ssize -1 ) : i; +}
tools/objtool/builtin-check.c +1 -0
@@ -26,6 +26,7 @@*/ #include <string.h> +#include <stdlib.h> #include <subcmd/parse-options.h> #include "builtin.h"
tools/perf/MANIFEST +1 -0
@@ -30,6 +30,7 @@ tools/lib/symbol/kallsyms.h tools/lib/find_bit.c tools/lib/bitmap.c tools/lib/str_error_r.c +tools/lib/vsprintf.c tools/include/asm/atomic.h tools/include/asm/barrier.h tools/include/asm/bug.h
tools/perf/util/Build +5 -0
@@ -85,6 +85,7 @@ libperf-y += parse-regs-options.o libperf-y += term.o libperf-y += help-unknown-cmd.o libperf-y += mem-events.o +libperf-y += vsprintf.o libperf-$(CONFIG_LIBBPF) += bpf-loader.o libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
@@ -181,3 +182,7 @@ $(OUTPUT)util/str_error_r.o: ../lib/str_error_r.c FORCE $(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) + +$(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c)
tools/perf/util/color.c +2 -0
@@ -1,6 +1,8 @@#include <linux/kernel.h> #include "cache.h" #include "config.h" +#include <stdlib.h> +#include <stdio.h> #include "color.h" #include <math.h> #include <unistd.h>
tools/perf/util/dso.h +1 -0
@@ -4,6 +4,7 @@#include <linux/atomic.h> #include <linux/types.h> #include <linux/rbtree.h> +#include <sys/types.h> #include <stdbool.h> #include <pthread.h> #include <linux/types.h>
tools/perf/util/help-unknown-cmd.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "config.h" +#include <stdio.h> #include <subcmd/help.h> #include "../builtin.h" #include "levenshtein.h"
tools/perf/util/python-ext-sources +1 -0
@@ -14,6 +14,7 @@ util/cpumap.c ../lib/find_bit.c ../lib/hweight.c ../lib/str_error_r.c +../lib/vsprintf.c util/thread_map.c util/util.c util/xyarray.c
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 29/66 tools lib traceevent: Use str_error_r()
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To make it portable to non-glibc systems, that follow the XSI variant instead of the GNU specific one that gets in place when _GNU_SOURCE is defined.
--- tools/lib/traceevent/event-parse.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
tools/lib/traceevent/event-parse.c +2 -6
@@ -31,6 +31,7 @@#include <errno.h> #include <stdint.h> #include <limits.h> +#include <linux/string.h> #include <netinet/ip6.h> #include "event-parse.h"
@@ -6131,12 +6132,7 @@ int pevent_strerror(struct pevent *pevent __maybe_unused,const char *msg;if (errnum >=0 ) { - msg =strerror_r (errnum, buf, buflen); -if (msg != buf) { -size_t len =strlen (msg); -memcpy (buf, msg,min (buflen -1 , len)); - *(buf +min (buflen -1 , len)) ='\0' ; - } +str_error_r (errnum, buf, buflen);return 0 ; }
Signature · 1 line
2.7.4
Re: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Quoted 32 lines · On Tue, 12 Jul 2016 19:40:04 -0300 Arnaldo Carvalho de Melo <[email protected]>…
From: Arnaldo Carvalho de Melo <[email protected]>
To make it portable to non-glibc systems, that follow the XSI variant instead of the GNU specific one that gets in place when
_GNU_SOURCEis defined.Cc Adrian Hunter <[email protected]>Cc David Ahern <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Steven Rostedt <[email protected]>Cc Wang Nan <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>--- tools/lib/traceevent/event-parse.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)tools/lib/traceevent/event-parse.c +1
-0@@ -31,6 +31,7 @@#include <errno.h> #include <stdint.h> #include <limits.h> +#include <linux/string.h> #include <netinet/ip6.h> #include "event-parse.h" @@ -6131,12 +6132,7 @@ int pevent_strerror(struct pevent *pevent __maybe_unused,const char *msg;
tools/lib/traceevent/event-parse.c int pevent_strerror(struct pevent *pevent __maybe_unused, · line 6136
Quoted 10 lines
tools/lib/traceevent/event-parse.c +1
-6if (errnum >=0 ) { - msg =strerror_r (errnum, buf, buflen); -if (msg != buf) { -size_t len =strlen (msg); -memcpy (buf, msg,min (buflen -1 , len)); - *(buf +min (buflen -1 , len)) ='\0' ; - } +str_error_r (errnum, buf, buflen);return 0 ;
What library is used with this? When I port this over to trace-cmd (which is still needed as I develop this there), it fails to build. "undefined reference to str_error_r"
-- Steve
Quoted 2 lines
tools/lib/traceevent/event-parse.c +0
-0}
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Em Tue, Jul 12, 2016 at 07:11:08PM -0400, Steven Rostedt escreveu:
Quoted 5 lines · On Tue, 12 Jul 2016 19:40:04 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Quoted 3 lines
To make it portable to non-glibc systems, that follow the XSI variant instead of the GNU specific one that gets in place when
_GNU_SOURCEis defined.
Quoted 8 lines
tools/lib/traceevent/event-parse.c int pevent_strerror(struct pevent *pevent __maybe_unused, · line 6133
Quoted 4 lines
#include "
event-parse.h"tools/lib/traceevent/event-parse.c +1
-0@@ -6131,12 +6132,7 @@ int pevent_strerror(struct pevent *pevent __maybe_unused, +str_error_r (errnum, buf, buflen);return 0 ;What library is used with this? When I port this over to trace-cmd (which is still needed as I develop this there), it fails to build. "undefined reference to
str_error_r"
tools/lib/str_error_r.c
Forgot about the out of tree copy :-\
- Arnaldo
Re: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Quoted 15 lines · On Tue, 12 Jul 2016 20:14:24 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Tue, Jul 12, 2016 at 07:11:08PM -0400, Steven Rostedt escreveu:
Quoted 5 lines · On Tue, 12 Jul 2016 19:40:04 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Quoted 3 lines
To make it portable to non-glibc systems, that follow the XSI variant instead of the GNU specific one that gets in place when
_GNU_SOURCEis defined.Quoted 8 lines
tools/lib/traceevent/event-parse.c int pevent_strerror(struct pevent *pevent __maybe_unused, · line 6133
Quoted 4 lines
#include "
event-parse.h"tools/lib/traceevent/event-parse.c +1
-0@@ -6131,12 +6132,7 @@ int pevent_strerror(struct pevent *pevent __maybe_unused, +str_error_r (errnum, buf, buflen);return 0 ;What library is used with this? When I port this over to trace-cmd (which is still needed as I develop this there), it fails to build. "undefined reference to
str_error_r"
Quoted 4 lines
tools/lib/str_error_r.cForgot about the out of tree copy :-\
Yeah, we really need to make this into a real library. I haven't had the time to do that. Hopefully in August I can talk with some people at LinuxCon to see the best way to go about doing that.
Anyway, I may just take that file and port it to trace-cmd.
-- Steve
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Em Tue, Jul 12, 2016 at 07:25:19PM -0400, Steven Rostedt escreveu:
Quoted 18 lines
Quoted 14 lines · On Tue, 12 Jul 2016 20:14:24 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Tue, Jul 12, 2016 at 07:11:08PM -0400, Steven Rostedt escreveu:
Quoted 13 lines · On Tue, 12 Jul 2016 19:40:04 -0300 Arnaldo Carvalho de Melo <[email protected]>…
tools/lib/traceevent/event-parse.c int pevent_strerror(struct pevent *pevent __maybe_unused, · line 6133
Quoted 8 lines
To make it portable to non-glibc systems, that follow the XSI variant instead of the GNU specific one that gets in place when
_GNU_SOURCEis defined.#include "
event-parse.h"tools/lib/traceevent/event-parse.c +1
-0@@ -6131,12 +6132,7 @@ int pevent_strerror(struct pevent *pevent __maybe_unused, +str_error_r (errnum, buf, buflen);return 0 ;What library is used with this? When I port this over to trace-cmd (which is still needed as I develop this there), it fails to build. "undefined reference to
str_error_r"
Quoted 6 lines
Quoted 3 lines
tools/lib/str_error_r.cForgot about the out of tree copy :-\
Yeah, we really need to make this into a real library. I haven't had the time to do that. Hopefully in August I can talk with some people at
What exactly do you mean by that? To grab a copy of what is in tools/ and have it turned into a library somewhere else?
Or to freeze its interfaces and create an .so with a committed to ABI?
I kind of like the way it is now... :-)
Quoted 3 lines
LinuxCon to see the best way to go about doing that.
Anyway, I may just take that file and port it to trace-cmd.
Yeah, that would solve this specific case.
- Arnaldo
Re: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Quoted 9 lines · On Tue, 12 Jul 2016 20:32:18 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Quoted 4 lines
Quoted 1 line
Forgot about the out of tree copy :-\
Yeah, we really need to make this into a real library. I haven't had the time to do that. Hopefully in August I can talk with some people at
What exactly do you mean by that? To grab a copy of what is in
tools/and have it turned into a library somewhere else?Or to freeze its interfaces and create an .so with a committed to ABI?
Yes, this is what we need to do.
Quoted 2 lines
I kind of like the way it is now... :-)
You like the current ABI? Or the fact that we have 4 tools with each their own copies of the library? (and maybe even more)
Quoted 6 lines
Quoted 4 lines
LinuxCon to see the best way to go about doing that.
Anyway, I may just take that file and port it to trace-cmd.
Yeah, that would solve this specific case.
OK, I'll do this.
-- Steve
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Em Wed, Jul 13, 2016 at 08:30:01AM -0400, Steven Rostedt escreveu:
Quoted 10 lines
Quoted 7 lines · On Tue, 12 Jul 2016 20:32:18 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Quoted 4 lines
Quoted 1 line
Forgot about the out of tree copy :-\
Yeah, we really need to make this into a real library. I haven't had the time to do that. Hopefully in August I can talk with some people at
What exactly do you mean by that? To grab a copy of what is in
tools/and have it turned into a library somewhere else?
Quoted 7 lines
Quoted 1 line
Or to freeze its interfaces and create an .so with a committed to ABI?
Yes, this is what we need to do.
Quoted 1 line
I kind of like the way it is now... :-)
You like the current ABI? Or the fact that we have 4 tools with each
I like the lack of an ABI, i.e. I like to use the same rationale for when a out of tree driver breaks because we improve kernel internals. As soon as we commit to an ABI for those libraries, that becomes way more difficult.
And since we're still adding more and more stuff (write_backward, eBPF for kernel and userspace, etc, etc) I fear lots are still very much in flux to commit to something like that.
So if we know what are the needs of those out of the tree tools (can't they be brought in tree? I'm digressing, couldn't resist, sorry ;-)), then we could, if absolutely required, try, without much enthusiasm, relutanctly, see what could be done besides what has been already underway (moving stuff out of tools/perf and into tools/lib).
It would add more burden to me for perhaps reducing the burden to who would use those libraries.
Quoted 1 line
their own copies of the library? (and maybe even more)
Which ones?
- Arnaldo
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
LinuxCon to see the best way to go about doing that.
Anyway, I may just take that file and port it to trace-cmd.
Yeah, that would solve this specific case.
OK, I'll do this.
Re: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Quoted 15 lines · On Wed, 13 Jul 2016 10:51:25 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Wed, Jul 13, 2016 at 08:30:01AM -0400, Steven Rostedt escreveu:
Quoted 13 lines
Quoted 9 lines · On Tue, 12 Jul 2016 20:32:18 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Quoted 4 lines
Quoted 1 line
Forgot about the out of tree copy :-\
Yeah, we really need to make this into a real library. I haven't had the time to do that. Hopefully in August I can talk with some people at
What exactly do you mean by that? To grab a copy of what is in
tools/and have it turned into a library somewhere else?Or to freeze its interfaces and create an .so with a committed to ABI?
Yes, this is what we need to do.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
I kind of like the way it is now... :-)
You like the current ABI? Or the fact that we have 4 tools with each
I like the lack of an ABI, i.e. I like to use the same rationale for when a out of tree driver breaks because we improve kernel internals. As soon as we commit to an ABI for those libraries, that becomes way more difficult.
Yes, ABI is hard. But it can be done. Let's not get lazy. The code came from external sources to begin with. I've been working hard to try to keep the ABI fixed. There's still a few things I would like to change before doing it officially, and that's because this code is quite mature now, and I have an idea of what to change.
One thing I want to do is change the event_format structure to "pevent_event" and the format_field to "pevent_field" just to be more consistent. There's probably a few other changes as well. But once they are done, I think we should get this out into a library.
Quoted 4 lines
And since we're still adding more and more stuff (
write_backward, eBPF for kernel and userspace, etc, etc) I fear lots are still very much in flux to commit to something like that.
We can always add new functions. The old ones will have to be maintained. Anyway, I'm only looking to what is being used externally from perf. We can slowly add functionality. The .so releases should only increment the version if something new is added. I refuse to follow the gtk crap that they find ways to remove or modify existing functions every single release.
Quoted 3 lines
So if we know what are the needs of those out of the tree tools (can't they be brought in tree? I'm digressing, couldn't resist, sorry ;-)),
Well, I Cc'd some of the maintainers. We can see what they think.
Quoted 3 lines
then we could, if absolutely required, try, without much enthusiasm, relutanctly, see what could be done besides what has been already underway (moving stuff out of
tools/perfand intotools/lib).
Note, I'm only looking at making a library out of what is currently in tools/lib. We don't need to move stuff out from perf unless you want to.
There's a trace-cmd library I want to have as well, which I would love to have in the kernel tools/lib directory too. I'd call it libftrace.so. This would include the ways to parse the ftrace ring buffer, as well as parsing and creating trace.dat files.
Quoted 3 lines
It would add more burden to me for perhaps reducing the burden to who would use those libraries.
Well the event-parse.* code has already been pretty stable. I do want to do the renames as I mentioned above before making it official. But once that is done, I would want us to get a libtraceevent.so that distros can provide.
Quoted 4 lines
Quoted 2 lines
their own copies of the library? (and maybe even more)
Which ones?
perf, trace-cmd/kernelshark, powertop and ras-daemon
-- Steve
Quoted 10 lines
- Arnaldo
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
LinuxCon to see the best way to go about doing that.
Anyway, I may just take that file and port it to trace-cmd.
Yeah, that would solve this specific case.
OK, I'll do this.
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Em Wed, Jul 13, 2016 at 03:17:00PM -0400, Steven Rostedt escreveu:
Quoted 20 lines
Quoted 17 lines · On Wed, 13 Jul 2016 10:51:25 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Em Wed, Jul 13, 2016 at 08:30:01AM -0400, Steven Rostedt escreveu:
Quoted 15 lines
Quoted 9 lines · On Tue, 12 Jul 2016 20:32:18 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Quoted 4 lines
Quoted 1 line
Forgot about the out of tree copy :-\
Yeah, we really need to make this into a real library. I haven't had the time to do that. Hopefully in August I can talk with some people at
What exactly do you mean by that? To grab a copy of what is in
tools/and have it turned into a library somewhere else?Or to freeze its interfaces and create an .so with a committed to ABI?
Yes, this is what we need to do.
Quoted 1 line
I kind of like the way it is now... :-)
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
You like the current ABI? Or the fact that we have 4 tools with each
I like the lack of an ABI, i.e. I like to use the same rationale for when a out of tree driver breaks because we improve kernel internals. As soon as we commit to an ABI for those libraries, that becomes way more difficult.
Yes, ABI is hard. But it can be done. Let's not get lazy. The code came
Hey, that is what I call enthusiasm, expecting the patches!
Quoted 1 line
from external sources to begin with. I've been working hard to try to
What code "that come from external sources" are you talking about?
Quoted 3 lines
keep the ABI fixed. There's still a few things I would like to change before doing it officially, and that's because this code is quite mature now, and I have an idea of what to change.
Ah, you're talking about just tools/lib/traceevent/ ?
Quoted 19 lines
One thing I want to do is change the
event_formatstructure to "pevent_event" and theformat_fieldto "pevent_field" just to be more consistent. There's probably a few other changes as well. But once they are done, I think we should get this out into a library.Quoted 3 lines
And since we're still adding more and more stuff (
write_backward, eBPF for kernel and userspace, etc, etc) I fear lots are still very much in flux to commit to something like that.We can always add new functions. The old ones will have to be maintained. Anyway, I'm only looking to what is being used externally from perf. We can slowly add functionality. The .so releases should only increment the version if something new is added. I refuse to follow the gtk crap that they find ways to remove or modify existing functions every single release.
Quoted 2 lines
So if we know what are the needs of those out of the tree tools (can't they be brought in tree? I'm digressing, couldn't resist, sorry ;-)),
Quoted 8 lines
Well, I Cc'd some of the maintainers. We can see what they think.
Quoted 3 lines
then we could, if absolutely required, try, without much enthusiasm, relutanctly, see what could be done besides what has been already underway (moving stuff out of
tools/perfand intotools/lib).Note, I'm only looking at making a library out of what is currently in
tools/lib. We don't need to move stuff out from perf unless you want to.
Hey, if it is only rom tools/lib/traceevent, I have no worries, you're the one proposing turning it into a committed to ABI and you're the main author, also willing to do the work of turning it into a .so, fair enough.
As time goes by and the changes take place that requires we to write tools/build/feature/ entries to cope with changes in its ABI, we'll just do it, it will be just another external library we need and can't do changes in tandem with tools/perf/, we'll have to suport old versions, do feature checks to see if the one present in a particular distro/release has some new feature, etc, etc.
Quoted 5 lines
There's a trace-cmd library I want to have as well, which I would love to have in the kernel
tools/libdirectory too. I'd call it libftrace.so. This would include the ways to parse the ftrace ring buffer, as well as parsing and creating trace.dat files.
Quoted 7 lines
Quoted 2 lines
It would add more burden to me for perhaps reducing the burden to who would use those libraries.
Well the event-parse.* code has already been pretty stable. I do want to do the renames as I mentioned above before making it official. But once that is done, I would want us to get a libtraceevent.so that distros can provide.
I was confused, I was thinking you were talking about code other than tools/lib/traceevent/.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
their own copies of the library? (and maybe even more)
Which ones?
perf, trace-cmd/kernelshark, powertop and ras-daemon
Cool, so this is all just about tools/lib/traceevent/ after all, sure, go ahead, you're the "external source" after all :-)
- Arnaldo
Re: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Quoted 4 lines · On Wed, 13 Jul 2016 17:01:48 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Quoted 1 line
perf, trace-cmd/kernelshark, powertop and ras-daemon
Cool, so this is all just about
tools/lib/traceevent/after all, sure, go ahead, you're the "external source" after all :-)
Great! We're on the same page then ;-)
-- Steve
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Em Wed, Jul 13, 2016 at 09:25:50PM -0400, Steven Rostedt escreveu:
Quoted 7 lines · On Wed, 13 Jul 2016 17:01:48 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Quoted 4 lines
Quoted 1 line
perf, trace-cmd/kernelshark, powertop and ras-daemon
Cool, so this is all just about
tools/lib/traceevent/after all, sure, go ahead, you're the "external source" after all :-)Great! We're on the same page then ;-)
It took a while, now it seems so :-)
- Arnaldo
Re: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Quoted 10 lines · Arnaldo Carvalho de Melo
Em Wed, Jul 13, 2016 at 09:25:50PM -0400, Steven Rostedt escreveu:
Quoted 7 lines · On Wed, 13 Jul 2016 17:01:48 -0300 Arnaldo Carvalho de Melo <[email protected]>…
Quoted 4 lines
Quoted 1 line
perf, trace-cmd/kernelshark, powertop and ras-daemon
Cool, so this is all just about
tools/lib/traceevent/after all, sure, go ahead, you're the "external source" after all :-)Great! We're on the same page then ;-)
It took a while, now it seems so :-)
heya,
after discussing this with Arnaldo I checked the possibility of adding traceevent as a fedora kernel rpm subpackage..
and to my surprise fedora already has following rpms:
(see attached rpm -ql output for list of their files)
kernel-tools
kernel-tools-libs
kernel-tools-libs-devel
I wonder we could solve all this by adding traceevent lib into kernel-libs and kernel-libs-devel packages.
I tried and with easy change to fedora kernel.spec made following rpm:
---
[jolsa@krava fedora]$ rpm -ql -p /home/jolsa/rpmbuild/RPMS/x86_64/kernel-tools-libs-devel-4.7.0-0.rc7.git3.1.fc22.x86_64.rpm /usr/include/cpufreq.h/usr/lib64/libcpupower.so/usr/lib64/libtraceevent.a/usr/lib64/libtraceevent.so/usr/lib64/traceevent/plugins/plugin_cfg80211.so/usr/lib64/traceevent/plugins/plugin_function.so/usr/lib64/traceevent/plugins/plugin_hrtimer.so/usr/lib64/traceevent/plugins/plugin_jbd2.so/usr/lib64/traceevent/plugins/plugin_kmem.so/usr/lib64/traceevent/plugins/plugin_kvm.so/usr/lib64/traceevent/plugins/plugin_mac80211.so/usr/lib64/traceevent/plugins/plugin_sched_switch.so/usr/lib64/traceevent/plugins/plugin_scsi.so/usr/lib64/traceevent/plugins/plugin_xen.so
---
we'll need to make some enhancements to install targets to provide header files and *.so.VERSION files.. and some other minor things
the kernel-tools-libs file could looks like (haven't made this one):
---
[jolsa@krava fedora]$ rpm -ql kernel-tools-libs /usr/lib64/libcpupower.so.0 /usr/lib64/libcpupower.so.0.0.0 /usr/lib64/libtraceevent.so.0 /usr/lib64/libtraceevent.so.0.0.0
---
I haven't checked other distro's kernel packages but I guess it'll be similar
this way we export traceevent lib for other users and its source stays in the kernel
thoughts? ;-)
jirka
---
[jolsa@krava fedora]$ rpm -qa kernel-tools kernel-tools-4.4.14-200.fc22.x86_64 [jolsa@krava fedora]$ rpm -ql kernel-tools /etc/sysconfig/cpupower /usr/bin/centrino-decode/usr/bin/cpupower/usr/bin/powernow-k8-decode/usr/bin/tmon/usr/bin/turbostat /usr/bin/x86_energy_perf_policy /usr/lib/systemd/system/cpupower.service /usr/share/locale/cs/LC_MESSAGES/cpupower.mo /usr/share/locale/de/LC_MESSAGES/cpupower.mo /usr/share/locale/fr/LC_MESSAGES/cpupower.mo /usr/share/locale/it/LC_MESSAGES/cpupower.mo /usr/share/locale/pt/LC_MESSAGES/cpupower.mo /usr/share/man/man1/cpupower-frequency-info.1.gz /usr/share/man/man1/cpupower-frequency-set.1.gz /usr/share/man/man1/cpupower-idle-info.1.gz /usr/share/man/man1/cpupower-idle-set.1.gz /usr/share/man/man1/cpupower-info.1.gz /usr/share/man/man1/cpupower-monitor.1.gz /usr/share/man/man1/cpupower-set.1.gz /usr/share/man/man1/cpupower.1.gz /usr/share/man/man8/turbostat.8.gz /usr/share/man/man8/x86_energy_perf_policy.8.gz [jolsa@krava fedora]$ rpm -ql kernel-tools-libs /usr/lib64/libcpupower.so.0 /usr/lib64/libcpupower.so.0.0.0
[jolsa@krava fedora]$ rpm -ql kernel-tools-libs-devel /usr/include/cpufreq.h /usr/lib64/libcpupower.so
[jolsa@krava fedora]$
Re: [PATCH 29/66] tools lib traceevent: Use str_error_r()
Quoted 8 lines · On Sun, 17 Jul 2016 20:49:38 +0200 Jiri Olsa <[email protected]> wrote:
I haven't checked other distro's kernel packages
but I guess it'll be similarthis way we export traceevent lib for other users and its source stays in the kernel
thoughts? ;-)
I say go for it! :-)
-- Steve
Arnaldo Carvalho de Melo
maintainerPATCH 30/66 tools lib api fs: Use str_error_r()
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To make it portable to non-glibc systems, that follow the XSI variant instead of the GNU specific one that gets in place when _GNU_SOURCE is defined.
--- tools/lib/api/Makefile | 1 + tools/lib/api/fs/tracing_path.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
tools/lib/api/Makefile +1 -0
@@ -26,6 +26,7 @@ endif CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 CFLAGS += -I$(srctree)/tools/lib/api +CFLAGS += -I$(srctree)/tools/include RM = rm -f
tools/lib/api/fs/tracing_path.c +2 -1
@@ -5,6 +5,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <linux/string.h> #include <errno.h> #include <unistd.h> #include "fs.h"
@@ -118,7 +119,7 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename) }break ;default : -snprintf (buf, size,"%s" ,strerror_r (err, sbuf,sizeof (sbuf))); +snprintf (buf, size,"%s" ,str_error_r (err, sbuf,sizeof (sbuf)));break ; }
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 31/66 tools lib: Guard the strlcpy() header with __GLIBC__
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Better to whitelist it for libraries that require it (glibc) than blacklist it with the ones that don't (uclibc, musl libc, etc).
--- tools/include/linux/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/include/linux/string.h +1 -1
@@ -8,7 +8,7 @@ void *memdup(const void *src, size_t len);int strtobool (const char *s,bool *res); -#ifndef __UCLIBC__ +#ifdef __GLIBC__extern size_t strlcpy (char *dest,const char *src,size_t size);#endif
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 32/66 tools lib subcmd: Use str_error_r()
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To make it portable to non-glibc systems, that follow the XSI variant instead of the GNU specific one that gets in place when _GNU_SOURCE is defined.
--- tools/lib/subcmd/run-command.c | 5 +++-- tools/objtool/Build | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-)
tools/lib/subcmd/run-command.c +3 -2
@@ -3,6 +3,7 @@#include <sys/stat.h> #include <fcntl.h> #include <string.h> +#include <linux/string.h> #include <errno.h> #include <sys/wait.h> #include "subcmd-util.h"
@@ -109,7 +110,7 @@ int start_command(struct child_process *cmd)if (cmd->dir &&chdir (cmd->dir))die ("exec %s: cd to %s failed (%s)" , cmd->argv[0 ], - cmd->dir,strerror_r (errno, sbuf,sizeof (sbuf))); + cmd->dir,str_error_r (errno, sbuf,sizeof (sbuf)));if (cmd->env) {for (; *cmd->env; cmd->env++) {if (strchr (*cmd->env,'=' ))
@@ -173,7 +174,7 @@ static int wait_or_whine(pid_t pid)if (errno ==EINTR )continue ;fprintf (stderr," Error: waitpid failed (%s)" , -strerror_r (errno, sbuf,sizeof (sbuf))); +str_error_r (errno, sbuf,sizeof (sbuf)));return -ERR_RUN_COMMAND_WAITPID ; }if (waiting != pid)
tools/objtool/Build +5 -0
@@ -5,9 +5,14 @@ objtool-y += special.o objtool-y += objtool.o objtool-y += libstring.o +objtool-y += str_error_r.o CFLAGS += -I$(srctree)/tools/lib $(OUTPUT)libstring.o: ../lib/string.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) + +$(OUTPUT)str_error_r.o: ../lib/str_error_r.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c)
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 33/66 perf bench futex: Add missing compiler.h header
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Since these files use __maybe_unused, and that is defined in linux/compiler.h, include it.
--- tools/perf/bench/futex-hash.c | 1 + tools/perf/bench/futex-lock-pi.c | 1 + tools/perf/bench/futex-requeue.c | 1 + tools/perf/bench/futex-wake-parallel.c | 1 + tools/perf/bench/futex-wake.c | 1 + 5 files changed, 5 insertions(+)
tools/perf/bench/futex-hash.c +1 -0
@@ -14,6 +14,7 @@#include <errno.h> #include <signal.h> #include <stdlib.h> +#include <linux/compiler.h> #include <linux/kernel.h> #include <sys/time.h>
tools/perf/bench/futex-lock-pi.c +1 -0
@@ -8,6 +8,7 @@#include <signal.h> #include "../util/stat.h" #include <subcmd/parse-options.h> +#include <linux/compiler.h> #include <linux/kernel.h> #include <errno.h> #include "bench.h"
tools/perf/bench/futex-requeue.c +1 -0
@@ -14,6 +14,7 @@#include <signal.h> #include "../util/stat.h" #include <subcmd/parse-options.h> +#include <linux/compiler.h> #include <linux/kernel.h> #include <errno.h> #include "bench.h"
tools/perf/bench/futex-wake-parallel.c +1 -0
@@ -13,6 +13,7 @@#include <signal.h> #include "../util/stat.h" #include <subcmd/parse-options.h> +#include <linux/compiler.h> #include <linux/kernel.h> #include <errno.h> #include "bench.h"
tools/perf/bench/futex-wake.c +1 -0
@@ -14,6 +14,7 @@#include <signal.h> #include "../util/stat.h" #include <subcmd/parse-options.h> +#include <linux/compiler.h> #include <linux/kernel.h> #include <errno.h> #include "bench.h"
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 34/66 perf tools: event.h needs asm/perf_regs.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
As it uses PERF_REGS_MAX, fix it.
--- tools/perf/util/event.h | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/event.h +1 -0
@@ -8,6 +8,7 @@#include "map.h" #include "build-id.h" #include "perf_regs.h" +#include <asm/perf_regs.h> struct mmap_event {struct perf_event_header header;
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 35/66 tools: Add copy of perf_event.h to tools/include/linux/
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We shouldn't use headers from the kernel sources directly, instead we should use the system's headers or in cases where that isn't possible, like with perf_event.h, where the introduction of kernel features such as perf_event_attr.{write_backwards,sample_max_stack} and PERF_EVENT_IOC_PAUSE_OUTPUT take some time to become available in /usr/include/linux/perf_event.h we need a copy.
Do it and check for source code drift, emitting a warning when changes are detected.
--- tools/include/uapi/linux/perf_event.h | 983 ++++++++++++++++++++++++++++++++++ tools/perf/MANIFEST | 3 +- tools/perf/Makefile.perf | 3 + tools/perf/config/Makefile | 1 + 4 files changed, 988 insertions(+), 2 deletions(-) create mode 100644 tools/include/uapi/linux/perf_event.h
tools/include/uapi/linux/perf_event.h new file +983 -0
@@ -0,0 +1,983 @@ +/* +* Performance events: +* +* Copyright (C) 2008-2009, Thomas Gleixner <[email protected]> +* Copyright (C) 2008-2011, Red Hat, Inc., Ingo Molnar +* Copyright (C) 2008-2011, Red Hat, Inc., Peter Zijlstra +* +* Data type definitions, declarations, prototypes. +* +* Started by: Thomas Gleixner and Ingo Molnar +* +* For licencing details see kernel-base/COPYING +*/ +#ifndef _UAPI_LINUX_PERF_EVENT_H +#define _UAPI_LINUX_PERF_EVENT_H + +#include <linux/types.h> +#include <linux/ioctl.h> +#include <asm/byteorder.h> + +/* +* User-space ABI bits: +*/ + +/* +* attr.type +*/ +enum perf_type_id { +PERF_TYPE_HARDWARE =0 , +PERF_TYPE_SOFTWARE =1 , +PERF_TYPE_TRACEPOINT =2 , +PERF_TYPE_HW_CACHE =3 , +PERF_TYPE_RAW =4 , +PERF_TYPE_BREAKPOINT =5 , + +PERF_TYPE_MAX ,/* non-ABI */ +}; + +/* +* Generalized performance event event_id types, used by the +* attr.event_id parameter of the sys_perf_event_open() +* syscall: +*/ +enum perf_hw_id { +/* +* Common hardware events, generalized by the kernel: +*/ +PERF_COUNT_HW_CPU_CYCLES =0 , +PERF_COUNT_HW_INSTRUCTIONS =1 , +PERF_COUNT_HW_CACHE_REFERENCES =2 , +PERF_COUNT_HW_CACHE_MISSES =3 , +PERF_COUNT_HW_BRANCH_INSTRUCTIONS =4 , +PERF_COUNT_HW_BRANCH_MISSES =5 , +PERF_COUNT_HW_BUS_CYCLES =6 , +PERF_COUNT_HW_STALLED_CYCLES_FRONTEND =7 , +PERF_COUNT_HW_STALLED_CYCLES_BACKEND =8 , +PERF_COUNT_HW_REF_CPU_CYCLES =9 , + +PERF_COUNT_HW_MAX ,/* non-ABI */ +}; + +/* +* Generalized hardware cache events: +* +* { L1-D, L1-I, LLC, ITLB, DTLB, BPU, NODE } x +* { read, write, prefetch } x +* { accesses, misses } +*/ +enum perf_hw_cache_id { +PERF_COUNT_HW_CACHE_L1D =0 , +PERF_COUNT_HW_CACHE_L1I =1 , +PERF_COUNT_HW_CACHE_LL =2 , +PERF_COUNT_HW_CACHE_DTLB =3 , +PERF_COUNT_HW_CACHE_ITLB =4 , +PERF_COUNT_HW_CACHE_BPU =5 , +PERF_COUNT_HW_CACHE_NODE =6 , + +PERF_COUNT_HW_CACHE_MAX ,/* non-ABI */ +}; + +enum perf_hw_cache_op_id { +PERF_COUNT_HW_CACHE_OP_READ =0 , +PERF_COUNT_HW_CACHE_OP_WRITE =1 , +PERF_COUNT_HW_CACHE_OP_PREFETCH =2 , + +PERF_COUNT_HW_CACHE_OP_MAX ,/* non-ABI */ +}; + +enum perf_hw_cache_op_result_id { +PERF_COUNT_HW_CACHE_RESULT_ACCESS =0 , +PERF_COUNT_HW_CACHE_RESULT_MISS =1 , + +PERF_COUNT_HW_CACHE_RESULT_MAX ,/* non-ABI */ +}; + +/* +* Special "software" events provided by the kernel, even if the hardware +* does not support performance events. These events measure various +* physical and sw events of the kernel (and allow the profiling of them as +* well): +*/ +enum perf_sw_ids { +PERF_COUNT_SW_CPU_CLOCK =0 , +PERF_COUNT_SW_TASK_CLOCK =1 , +PERF_COUNT_SW_PAGE_FAULTS =2 , +PERF_COUNT_SW_CONTEXT_SWITCHES =3 , +PERF_COUNT_SW_CPU_MIGRATIONS =4 , +PERF_COUNT_SW_PAGE_FAULTS_MIN =5 , +PERF_COUNT_SW_PAGE_FAULTS_MAJ =6 , +PERF_COUNT_SW_ALIGNMENT_FAULTS =7 , +PERF_COUNT_SW_EMULATION_FAULTS =8 , +PERF_COUNT_SW_DUMMY =9 , +PERF_COUNT_SW_BPF_OUTPUT =10 , + +PERF_COUNT_SW_MAX ,/* non-ABI */ +}; + +/* +* Bits that can be set in attr.sample_type to request information +* in the overflow packets. +*/ +enum perf_event_sample_format { +PERF_SAMPLE_IP =1U <<0 , +PERF_SAMPLE_TID =1U <<1 , +PERF_SAMPLE_TIME =1U <<2 , +PERF_SAMPLE_ADDR =1U <<3 , +PERF_SAMPLE_READ =1U <<4 , +PERF_SAMPLE_CALLCHAIN =1U <<5 , +PERF_SAMPLE_ID =1U <<6 , +PERF_SAMPLE_CPU =1U <<7 , +PERF_SAMPLE_PERIOD =1U <<8 , +PERF_SAMPLE_STREAM_ID =1U <<9 , +PERF_SAMPLE_RAW =1U <<10 , +PERF_SAMPLE_BRANCH_STACK =1U <<11 , +PERF_SAMPLE_REGS_USER =1U <<12 , +PERF_SAMPLE_STACK_USER =1U <<13 , +PERF_SAMPLE_WEIGHT =1U <<14 , +PERF_SAMPLE_DATA_SRC =1U <<15 , +PERF_SAMPLE_IDENTIFIER =1U <<16 , +PERF_SAMPLE_TRANSACTION =1U <<17 , +PERF_SAMPLE_REGS_INTR =1U <<18 , + +PERF_SAMPLE_MAX =1U <<19 ,/* non-ABI */ +}; + +/* +* values to program into branch_sample_type when PERF_SAMPLE_BRANCH is set +* +* If the user does not pass priv level information via branch_sample_type, +* the kernel uses the event's priv level. Branch and event priv levels do +* not have to match. Branch priv level is checked for permissions. +* +* The branch types can be combined, however BRANCH_ANY covers all types +* of branches and therefore it supersedes all the other types. +*/ +enum perf_branch_sample_type_shift { +PERF_SAMPLE_BRANCH_USER_SHIFT =0 ,/* user branches */ +PERF_SAMPLE_BRANCH_KERNEL_SHIFT =1 ,/* kernel branches */ +PERF_SAMPLE_BRANCH_HV_SHIFT =2 ,/* hypervisor branches */ + +PERF_SAMPLE_BRANCH_ANY_SHIFT =3 ,/* any branch types */ +PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT =4 ,/* any call branch */ +PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT =5 ,/* any return branch */ +PERF_SAMPLE_BRANCH_IND_CALL_SHIFT =6 ,/* indirect calls */ +PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT =7 ,/* transaction aborts */ +PERF_SAMPLE_BRANCH_IN_TX_SHIFT =8 ,/* in transaction */ +PERF_SAMPLE_BRANCH_NO_TX_SHIFT =9 ,/* not in transaction */ +PERF_SAMPLE_BRANCH_COND_SHIFT =10 ,/* conditional branches */ + +PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT =11 ,/* call/ret stack */ +PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT =12 ,/* indirect jumps */ +PERF_SAMPLE_BRANCH_CALL_SHIFT =13 ,/* direct call */ + +PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT =14 ,/* no flags */ +PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT =15 ,/* no cycles */ + +PERF_SAMPLE_BRANCH_MAX_SHIFT /* non-ABI */ +}; + +enum perf_branch_sample_type { +PERF_SAMPLE_BRANCH_USER =1U <<PERF_SAMPLE_BRANCH_USER_SHIFT , +PERF_SAMPLE_BRANCH_KERNEL =1U <<PERF_SAMPLE_BRANCH_KERNEL_SHIFT , +PERF_SAMPLE_BRANCH_HV =1U <<PERF_SAMPLE_BRANCH_HV_SHIFT , + +PERF_SAMPLE_BRANCH_ANY =1U <<PERF_SAMPLE_BRANCH_ANY_SHIFT , +PERF_SAMPLE_BRANCH_ANY_CALL =1U <<PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT , +PERF_SAMPLE_BRANCH_ANY_RETURN =1U <<PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT , +PERF_SAMPLE_BRANCH_IND_CALL =1U <<PERF_SAMPLE_BRANCH_IND_CALL_SHIFT , +PERF_SAMPLE_BRANCH_ABORT_TX =1U <<PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT , +PERF_SAMPLE_BRANCH_IN_TX =1U <<PERF_SAMPLE_BRANCH_IN_TX_SHIFT , +PERF_SAMPLE_BRANCH_NO_TX =1U <<PERF_SAMPLE_BRANCH_NO_TX_SHIFT , +PERF_SAMPLE_BRANCH_COND =1U <<PERF_SAMPLE_BRANCH_COND_SHIFT , + +PERF_SAMPLE_BRANCH_CALL_STACK =1U <<PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT , +PERF_SAMPLE_BRANCH_IND_JUMP =1U <<PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT , +PERF_SAMPLE_BRANCH_CALL =1U <<PERF_SAMPLE_BRANCH_CALL_SHIFT , + +PERF_SAMPLE_BRANCH_NO_FLAGS =1U <<PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT , +PERF_SAMPLE_BRANCH_NO_CYCLES =1U <<PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT , + +PERF_SAMPLE_BRANCH_MAX =1U <<PERF_SAMPLE_BRANCH_MAX_SHIFT , +}; + +#define PERF_SAMPLE_BRANCH_PLM_ALL \ + (PERF_SAMPLE_BRANCH_USER|\ + PERF_SAMPLE_BRANCH_KERNEL|\ + PERF_SAMPLE_BRANCH_HV) + +/* +* Values to determine ABI of the registers dump. +*/ +enum perf_sample_regs_abi { +PERF_SAMPLE_REGS_ABI_NONE =0 , +PERF_SAMPLE_REGS_ABI_32 =1 , +PERF_SAMPLE_REGS_ABI_64 =2 , +}; + +/* +* Values for the memory transaction event qualifier, mostly for +* abort events. Multiple bits can be set. +*/ +enum { +PERF_TXN_ELISION = (1 <<0 ),/* From elision */ +PERF_TXN_TRANSACTION = (1 <<1 ),/* From transaction */ +PERF_TXN_SYNC = (1 <<2 ),/* Instruction is related */ +PERF_TXN_ASYNC = (1 <<3 ),/* Instruction not related */ +PERF_TXN_RETRY = (1 <<4 ),/* Retry possible */ +PERF_TXN_CONFLICT = (1 <<5 ),/* Conflict abort */ +PERF_TXN_CAPACITY_WRITE = (1 <<6 ),/* Capacity write abort */ +PERF_TXN_CAPACITY_READ = (1 <<7 ),/* Capacity read abort */ + +PERF_TXN_MAX = (1 <<8 ),/* non-ABI */ + +/* bits 32..63 are reserved for the abort code */ + +PERF_TXN_ABORT_MASK = (0xffffffffULL <<32 ), +PERF_TXN_ABORT_SHIFT =32 , +}; + +/* +* The format of the data returned by read() on a perf event fd, +* as specified by attr.read_format: +* +* struct read_format { +* { u64 value; +* { u64 time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED +* { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING +* { u64 id; } && PERF_FORMAT_ID +* } && !PERF_FORMAT_GROUP +* +* { u64 nr; +* { u64 time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED +* { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING +* { u64 value; +* { u64 id; } && PERF_FORMAT_ID +* } cntr[nr]; +* } && PERF_FORMAT_GROUP +* }; +*/ +enum perf_event_read_format { +PERF_FORMAT_TOTAL_TIME_ENABLED =1U <<0 , +PERF_FORMAT_TOTAL_TIME_RUNNING =1U <<1 , +PERF_FORMAT_ID =1U <<2 , +PERF_FORMAT_GROUP =1U <<3 , + +PERF_FORMAT_MAX =1U <<4 ,/* non-ABI */ +}; + +#define PERF_ATTR_SIZE_VER0 64/* sizeof first published struct */ +#define PERF_ATTR_SIZE_VER1 72/* add: config2 */ +#define PERF_ATTR_SIZE_VER2 80/* add: branch_sample_type */ +#define PERF_ATTR_SIZE_VER3 96/* add: sample_regs_user */ +/* add: sample_stack_user */ +#define PERF_ATTR_SIZE_VER4 104/* add: sample_regs_intr */ +#define PERF_ATTR_SIZE_VER5 112/* add: aux_watermark */ + +/* +* Hardware event_id to monitor via a performance monitoring event: +* +* @sample_max_stack: Max number of frame pointers in a callchain, +* should be < /proc/sys/kernel/perf_event_max_stack +*/ +struct perf_event_attr { + +/* +* Major type: hardware/software/tracepoint/etc. +*/ +__u32 type; + +/* +* Size of the attr structure, for fwd/bwd compat. +*/ +__u32 size; + +/* +* Type specific configuration information. +*/ +__u64 config; + +union { +__u64 sample_period; +__u64 sample_freq; + }; + +__u64 sample_type; +__u64 read_format; + +__u64 disabled :1 ,/* off by default */ + inherit :1 ,/* children inherit it */ + pinned :1 ,/* must always be on PMU */ + exclusive :1 ,/* only group on PMU */ + exclude_user :1 ,/* don't count user */ + exclude_kernel :1 ,/* ditto kernel */ + exclude_hv :1 ,/* ditto hypervisor */ + exclude_idle :1 ,/* don't count when idle */ + mmap :1 ,/* include mmap data */ + comm :1 ,/* include comm data */ + freq :1 ,/* use freq, not period */ + inherit_stat :1 ,/* per task counts */ + enable_on_exec :1 ,/* next exec enables */ + task :1 ,/* trace fork/exit */ + watermark :1 ,/* wakeup_watermark */ +/* +* precise_ip: +* +* 0 - SAMPLE_IP can have arbitrary skid +* 1 - SAMPLE_IP must have constant skid +* 2 - SAMPLE_IP requested to have 0 skid +* 3 - SAMPLE_IP must have 0 skid +* +* See also PERF_RECORD_MISC_EXACT_IP +*/ + precise_ip :2 ,/* skid constraint */ + mmap_data :1 ,/* non-exec mmap data */ + sample_id_all :1 ,/* sample_type all events */ + + exclude_host :1 ,/* don't count in host */ + exclude_guest :1 ,/* don't count in guest */ + + exclude_callchain_kernel :1 ,/* exclude kernel callchains */ + exclude_callchain_user :1 ,/* exclude user callchains */ + mmap2 :1 ,/* include mmap with inode data */ + comm_exec :1 ,/* flag comm events that are due to an exec */ + use_clockid :1 ,/* use @clockid for time fields */ + context_switch :1 ,/* context switch data */ + write_backward :1 ,/* Write ring buffer from end to beginning */ + __reserved_1 :36 ; + +union { +__u32 wakeup_events;/* wakeup every n events */ +__u32 wakeup_watermark;/* bytes before wakeup */ + }; + +__u32 bp_type; +union { +__u64 bp_addr; +__u64 config1;/* extension of config */ + }; +union { +__u64 bp_len; +__u64 config2;/* extension of config1 */ + }; +__u64 branch_sample_type;/* enum perf_branch_sample_type */ + +/* +* Defines set of user regs to dump on samples. +* See asm/perf_regs.h for details. +*/ +__u64 sample_regs_user; + +/* +* Defines size of the user stack to dump on samples. +*/ +__u32 sample_stack_user; + +__s32 clockid; +/* +* Defines set of regs to dump for each sample +* state captured on: +* - precise = 0: PMU interrupt +* - precise > 0: sampled instruction +* +* See asm/perf_regs.h for details. +*/ +__u64 sample_regs_intr; + +/* +* Wakeup watermark for AUX area +*/ +__u32 aux_watermark; +__u16 sample_max_stack; +__u16 __reserved_2;/* align to __u64 */ +}; + +#define perf_flags (attr) (*(&(attr)->read_format + 1)) + +/* +* Ioctls that can be done on a perf event fd: +*/ +#define PERF_EVENT_IOC_ENABLE _IO ('$', 0) +#define PERF_EVENT_IOC_DISABLE _IO ('$', 1) +#define PERF_EVENT_IOC_REFRESH _IO ('$', 2) +#define PERF_EVENT_IOC_RESET _IO ('$', 3) +#define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64) +#define PERF_EVENT_IOC_SET_OUTPUT _IO ('$', 5) +#define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *) +#define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *) +#define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32) +#define PERF_EVENT_IOC_PAUSE_OUTPUT _IOW('$', 9, __u32) + +enum perf_event_ioc_flags { +PERF_IOC_FLAG_GROUP =1U <<0 , +}; + +/* +* Structure of the page that can be mapped via mmap +*/ +struct perf_event_mmap_page { +__u32 version;/* version number of this structure */ +__u32 compat_version;/* lowest version this is compat with */ + +/* +* Bits needed to read the hw events in user-space. +* +* u32 seq, time_mult, time_shift, index, width; +* u64 count, enabled, running; +* u64 cyc, time_offset; +* s64 pmc = 0; +* +* do { +* seq = pc->lock; +* barrier() +* +* enabled = pc->time_enabled; +* running = pc->time_running; +* +* if (pc->cap_usr_time && enabled != running) { +* cyc = rdtsc(); +* time_offset = pc->time_offset; +* time_mult = pc->time_mult; +* time_shift = pc->time_shift; +* } +* +* index = pc->index; +* count = pc->offset; +* if (pc->cap_user_rdpmc && index) { +* width = pc->pmc_width; +* pmc = rdpmc(index - 1); +* } +* +* barrier(); +* } while (pc->lock != seq); +* +* NOTE: for obvious reason this only works on self-monitoring +* processes. +*/ +__u32 lock;/* seqlock for synchronization */ +__u32 index;/* hardware event identifier */ +__s64 offset;/* add to hardware event value */ +__u64 time_enabled;/* time event active */ +__u64 time_running;/* time event on cpu */ +union { +__u64 capabilities; +struct { +__u64 cap_bit0 :1 ,/* Always 0, deprecated, see commit 860f085b74e9 */ + cap_bit0_is_deprecated :1 ,/* Always 1, signals that bit 0 is zero */ + + cap_user_rdpmc :1 ,/* The RDPMC instruction can be used to read counts */ + cap_user_time :1 ,/* The time_* fields are used */ + cap_user_time_zero :1 ,/* The time_zero field is used */ + cap_____res :59 ; + }; + }; + +/* +* If cap_user_rdpmc this field provides the bit-width of the value +* read using the rdpmc() or equivalent instruction. This can be used +* to sign extend the result like: +* +* pmc <<= 64 - width; +* pmc >>= 64 - width; // signed shift right +* count += pmc; +*/ +__u16 pmc_width; + +/* +* If cap_usr_time the below fields can be used to compute the time +* delta since time_enabled (in ns) using rdtsc or similar. +* +* u64 quot, rem; +* u64 delta; +* +* quot = (cyc >> time_shift); +* rem = cyc & (((u64)1 << time_shift) - 1); +* delta = time_offset + quot * time_mult + +* ((rem * time_mult) >> time_shift); +* +* Where time_offset,time_mult,time_shift and cyc are read in the +* seqcount loop described above. This delta can then be added to +* enabled and possible running (if index), improving the scaling: +* +* enabled += delta; +* if (index) +* running += delta; +* +* quot = count / running; +* rem = count % running; +* count = quot * enabled + (rem * enabled) / running; +*/ +__u16 time_shift; +__u32 time_mult; +__u64 time_offset; +/* +* If cap_usr_time_zero, the hardware clock (e.g. TSC) can be calculated +* from sample timestamps. +* +* time = timestamp - time_zero; +* quot = time / time_mult; +* rem = time % time_mult; +* cyc = (quot << time_shift) + (rem << time_shift) / time_mult; +* +* And vice versa: +* +* quot = cyc >> time_shift; +* rem = cyc & (((u64)1 << time_shift) - 1); +* timestamp = time_zero + quot * time_mult + +* ((rem * time_mult) >> time_shift); +*/ +__u64 time_zero; +__u32 size;/* Header size up to __reserved[] fields. */ + +/* +* Hole for extension of the self monitor capabilities +*/ + +__u8 __reserved[118 *8 +4 ];/* align to 1k. */ + +/* +* Control data for the mmap() data buffer. +* +* User-space reading the @data_head value should issue an smp_rmb(), +* after reading this value. +* +* When the mapping is PROT_WRITE the @data_tail value should be +* written by userspace to reflect the last read data, after issueing +* an smp_mb() to separate the data read from the ->data_tail store. +* In this case the kernel will not over-write unread data. +* +* See perf_output_put_handle() for the data ordering. +* +* data_{offset,size} indicate the location and size of the perf record +* buffer within the mmapped area. +*/ +__u64 data_head;/* head in the data section */ +__u64 data_tail;/* user-space written tail */ +__u64 data_offset;/* where the buffer starts */ +__u64 data_size;/* data buffer size */ + +/* +* AUX area is defined by aux_{offset,size} fields that should be set +* by the userspace, so that +* +* aux_offset >= data_offset + data_size +* +* prior to mmap()ing it. Size of the mmap()ed area should be aux_size. +* +* Ring buffer pointers aux_{head,tail} have the same semantics as +* data_{head,tail} and same ordering rules apply. +*/ +__u64 aux_head; +__u64 aux_tail; +__u64 aux_offset; +__u64 aux_size; +}; + +#define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0) +#define PERF_RECORD_MISC_CPUMODE_UNKNOWN (0 << 0) +#define PERF_RECORD_MISC_KERNEL (1 << 0) +#define PERF_RECORD_MISC_USER (2 << 0) +#define PERF_RECORD_MISC_HYPERVISOR (3 << 0) +#define PERF_RECORD_MISC_GUEST_KERNEL (4 << 0) +#define PERF_RECORD_MISC_GUEST_USER (5 << 0) + +/* +* Indicates that /proc/PID/maps parsing are truncated by time out. +*/ +#define PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT (1 << 12) +/* +* PERF_RECORD_MISC_MMAP_DATA and PERF_RECORD_MISC_COMM_EXEC are used on +* different events so can reuse the same bit position. +* Ditto PERF_RECORD_MISC_SWITCH_OUT. +*/ +#define PERF_RECORD_MISC_MMAP_DATA (1 << 13) +#define PERF_RECORD_MISC_COMM_EXEC (1 << 13) +#define PERF_RECORD_MISC_SWITCH_OUT (1 << 13) +/* +* Indicates that the content of PERF_SAMPLE_IP points to +* the actual instruction that triggered the event. See also +* perf_event_attr::precise_ip. +*/ +#define PERF_RECORD_MISC_EXACT_IP (1 << 14) +/* +* Reserve the last bit to indicate some extended misc field +*/ +#define PERF_RECORD_MISC_EXT_RESERVED (1 << 15) + +struct perf_event_header { +__u32 type; +__u16 misc; +__u16 size; +}; + +enum perf_event_type { + +/* +* If perf_event_attr.sample_id_all is set then all event types will +* have the sample_type selected fields related to where/when +* (identity) an event took place (TID, TIME, ID, STREAM_ID, CPU, +* IDENTIFIER) described in PERF_RECORD_SAMPLE below, it will be stashed +* just after the perf_event_header and the fields already present for +* the existing fields, i.e. at the end of the payload. That way a newer +* perf.data file will be supported by older perf tools, with these new +* optional fields being ignored. +* +* struct sample_id { +* { u32 pid, tid; } && PERF_SAMPLE_TID +* { u64 time; } && PERF_SAMPLE_TIME +* { u64 id; } && PERF_SAMPLE_ID +* { u64 stream_id;} && PERF_SAMPLE_STREAM_ID +* { u32 cpu, res; } && PERF_SAMPLE_CPU +* { u64 id; } && PERF_SAMPLE_IDENTIFIER +* } && perf_event_attr::sample_id_all +* +* Note that PERF_SAMPLE_IDENTIFIER duplicates PERF_SAMPLE_ID. The +* advantage of PERF_SAMPLE_IDENTIFIER is that its position is fixed +* relative to header.size. +*/ + +/* +* The MMAP events record the PROT_EXEC mappings so that we can +* correlate userspace IPs to code. They have the following structure: +* +* struct { +* struct perf_event_header header; +* +* u32 pid, tid; +* u64 addr; +* u64 len; +* u64 pgoff; +* char filename[]; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_MMAP =1 , + +/* +* struct { +* struct perf_event_header header; +* u64 id; +* u64 lost; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_LOST =2 , + +/* +* struct { +* struct perf_event_header header; +* +* u32 pid, tid; +* char comm[]; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_COMM =3 , + +/* +* struct { +* struct perf_event_header header; +* u32 pid, ppid; +* u32 tid, ptid; +* u64 time; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_EXIT =4 , + +/* +* struct { +* struct perf_event_header header; +* u64 time; +* u64 id; +* u64 stream_id; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_THROTTLE =5 , +PERF_RECORD_UNTHROTTLE =6 , + +/* +* struct { +* struct perf_event_header header; +* u32 pid, ppid; +* u32 tid, ptid; +* u64 time; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_FORK =7 , + +/* +* struct { +* struct perf_event_header header; +* u32 pid, tid; +* +* struct read_format values; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_READ =8 , + +/* +* struct { +* struct perf_event_header header; +* +* # +* # Note that PERF_SAMPLE_IDENTIFIER duplicates PERF_SAMPLE_ID. +* # The advantage of PERF_SAMPLE_IDENTIFIER is that its position +* # is fixed relative to header. +* # +* +* { u64 id; } && PERF_SAMPLE_IDENTIFIER +* { u64 ip; } && PERF_SAMPLE_IP +* { u32 pid, tid; } && PERF_SAMPLE_TID +* { u64 time; } && PERF_SAMPLE_TIME +* { u64 addr; } && PERF_SAMPLE_ADDR +* { u64 id; } && PERF_SAMPLE_ID +* { u64 stream_id;} && PERF_SAMPLE_STREAM_ID +* { u32 cpu, res; } && PERF_SAMPLE_CPU +* { u64 period; } && PERF_SAMPLE_PERIOD +* +* { struct read_format values; } && PERF_SAMPLE_READ +* +* { u64 nr, +* u64 ips[nr]; } && PERF_SAMPLE_CALLCHAIN +* +* # +* # The RAW record below is opaque data wrt the ABI +* # +* # That is, the ABI doesn't make any promises wrt to +* # the stability of its content, it may vary depending +* # on event, hardware, kernel version and phase of +* # the moon. +* # +* # In other words, PERF_SAMPLE_RAW contents are not an ABI. +* # +* +* { u32 size; +* char data[size];}&& PERF_SAMPLE_RAW +* +* { u64 nr; +* { u64 from, to, flags } lbr[nr];} && PERF_SAMPLE_BRANCH_STACK +* +* { u64 abi; # enum perf_sample_regs_abi +* u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_USER +* +* { u64 size; +* char data[size]; +* u64 dyn_size; } && PERF_SAMPLE_STACK_USER +* +* { u64 weight; } && PERF_SAMPLE_WEIGHT +* { u64 data_src; } && PERF_SAMPLE_DATA_SRC +* { u64 transaction; } && PERF_SAMPLE_TRANSACTION +* { u64 abi; # enum perf_sample_regs_abi +* u64 regs[weight(mask)]; } && PERF_SAMPLE_REGS_INTR +* }; +*/ +PERF_RECORD_SAMPLE =9 , + +/* +* The MMAP2 records are an augmented version of MMAP, they add +* maj, min, ino numbers to be used to uniquely identify each mapping +* +* struct { +* struct perf_event_header header; +* +* u32 pid, tid; +* u64 addr; +* u64 len; +* u64 pgoff; +* u32 maj; +* u32 min; +* u64 ino; +* u64 ino_generation; +* u32 prot, flags; +* char filename[]; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_MMAP2 =10 , + +/* +* Records that new data landed in the AUX buffer part. +* +* struct { +* struct perf_event_header header; +* +* u64 aux_offset; +* u64 aux_size; +* u64 flags; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_AUX =11 , + +/* +* Indicates that instruction trace has started +* +* struct { +* struct perf_event_header header; +* u32 pid; +* u32 tid; +* }; +*/ +PERF_RECORD_ITRACE_START =12 , + +/* +* Records the dropped/lost sample number. +* +* struct { +* struct perf_event_header header; +* +* u64 lost; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_LOST_SAMPLES =13 , + +/* +* Records a context switch in or out (flagged by +* PERF_RECORD_MISC_SWITCH_OUT). See also +* PERF_RECORD_SWITCH_CPU_WIDE. +* +* struct { +* struct perf_event_header header; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_SWITCH =14 , + +/* +* CPU-wide version of PERF_RECORD_SWITCH with next_prev_pid and +* next_prev_tid that are the next (switching out) or previous +* (switching in) pid/tid. +* +* struct { +* struct perf_event_header header; +* u32 next_prev_pid; +* u32 next_prev_tid; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_SWITCH_CPU_WIDE =15 , + +PERF_RECORD_MAX ,/* non-ABI */ +}; + +#define PERF_MAX_STACK_DEPTH 127 +#define PERF_MAX_CONTEXTS_PER_STACK 8 + +enum perf_callchain_context { +PERF_CONTEXT_HV = (__u64)-32 , +PERF_CONTEXT_KERNEL = (__u64)-128 , +PERF_CONTEXT_USER = (__u64)-512 , + +PERF_CONTEXT_GUEST = (__u64)-2048 , +PERF_CONTEXT_GUEST_KERNEL = (__u64)-2176 , +PERF_CONTEXT_GUEST_USER = (__u64)-2560 , + +PERF_CONTEXT_MAX = (__u64)-4095 , +}; + +/** +* PERF_RECORD_AUX::flags bits +*/ +#define PERF_AUX_FLAG_TRUNCATED 0x01/* record was truncated to fit */ +#define PERF_AUX_FLAG_OVERWRITE 0x02/* snapshot from overwrite mode */ + +#define PERF_FLAG_FD_NO_GROUP (1UL << 0) +#define PERF_FLAG_FD_OUTPUT (1UL << 1) +#define PERF_FLAG_PID_CGROUP (1UL << 2)/* pid=cgroup id, per-cpu mode only */ +#define PERF_FLAG_FD_CLOEXEC (1UL << 3)/* O_CLOEXEC */ + +union perf_mem_data_src { +__u64 val; +struct { +__u64 mem_op:5 ,/* type of opcode */ + mem_lvl:14 ,/* memory hierarchy level */ + mem_snoop:5 ,/* snoop mode */ + mem_lock:2 ,/* lock instr */ + mem_dtlb:7 ,/* tlb access */ + mem_rsvd:31 ; + }; +}; + +/* type of opcode (load/store/prefetch,code) */ +#define PERF_MEM_OP_NA 0x01/* not available */ +#define PERF_MEM_OP_LOAD 0x02/* load instruction */ +#define PERF_MEM_OP_STORE 0x04/* store instruction */ +#define PERF_MEM_OP_PFETCH 0x08/* prefetch */ +#define PERF_MEM_OP_EXEC 0x10/* code (execution) */ +#define PERF_MEM_OP_SHIFT 0 + +/* memory hierarchy (memory level, hit or miss) */ +#define PERF_MEM_LVL_NA 0x01/* not available */ +#define PERF_MEM_LVL_HIT 0x02/* hit level */ +#define PERF_MEM_LVL_MISS 0x04/* miss level */ +#define PERF_MEM_LVL_L1 0x08/* L1 */ +#define PERF_MEM_LVL_LFB 0x10/* Line Fill Buffer */ +#define PERF_MEM_LVL_L2 0x20/* L2 */ +#define PERF_MEM_LVL_L3 0x40/* L3 */ +#define PERF_MEM_LVL_LOC_RAM 0x80/* Local DRAM */ +#define PERF_MEM_LVL_REM_RAM1 0x100/* Remote DRAM (1 hop) */ +#define PERF_MEM_LVL_REM_RAM2 0x200/* Remote DRAM (2 hops) */ +#define PERF_MEM_LVL_REM_CCE1 0x400/* Remote Cache (1 hop) */ +#define PERF_MEM_LVL_REM_CCE2 0x800/* Remote Cache (2 hops) */ +#define PERF_MEM_LVL_IO 0x1000/* I/O memory */ +#define PERF_MEM_LVL_UNC 0x2000/* Uncached memory */ +#define PERF_MEM_LVL_SHIFT 5 + +/* snoop mode */ +#define PERF_MEM_SNOOP_NA 0x01/* not available */ +#define PERF_MEM_SNOOP_NONE 0x02/* no snoop */ +#define PERF_MEM_SNOOP_HIT 0x04/* snoop hit */ +#define PERF_MEM_SNOOP_MISS 0x08/* snoop miss */ +#define PERF_MEM_SNOOP_HITM 0x10/* snoop hit modified */ +#define PERF_MEM_SNOOP_SHIFT 19 + +/* locked instruction */ +#define PERF_MEM_LOCK_NA 0x01/* not available */ +#define PERF_MEM_LOCK_LOCKED 0x02/* locked transaction */ +#define PERF_MEM_LOCK_SHIFT 24 + +/* TLB access */ +#define PERF_MEM_TLB_NA 0x01/* not available */ +#define PERF_MEM_TLB_HIT 0x02/* hit level */ +#define PERF_MEM_TLB_MISS 0x04/* miss level */ +#define PERF_MEM_TLB_L1 0x08/* L1 */ +#define PERF_MEM_TLB_L2 0x10/* L2 */ +#define PERF_MEM_TLB_WK 0x20/* Hardware Walker*/ +#define PERF_MEM_TLB_OS 0x40/* OS fault handler */ +#define PERF_MEM_TLB_SHIFT 26 + +#define PERF_MEM_S (a, s) \ + (((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT) + +/* +* single taken branch record layout: +* +* from: source instruction (may not always be a branch insn) +* to: branch target +* mispred: branch target was mispredicted +* predicted: branch target was predicted +* +* support for mispred, predicted is optional. In case it +* is not supported mispred = predicted = 0. +* +* in_tx: running in a hardware transaction +* abort: aborting a hardware transaction +* cycles: cycles from last branch (or 0 if not supported) +*/ +struct perf_branch_entry { +__u64 from; +__u64 to; +__u64 mispred:1 ,/* target mispredicted */ + predicted:1 ,/* target predicted */ + in_tx:1 ,/* in transaction */ + abort:1 ,/* transaction abort */ + cycles:16 ,/* cycle count to last branch */ + reserved:44 ; +}; + +#endif /* _UAPI_LINUX_PERF_EVENT_H */
tools/perf/MANIFEST +1 -2
@@ -54,6 +54,7 @@ tools/include/linux/hash.h tools/include/linux/kernel.h tools/include/linux/list.h tools/include/linux/log2.h +tools/include/uapi/linux/perf_event.h tools/include/linux/poison.h tools/include/linux/rbtree.h tools/include/linux/rbtree_augmented.h
@@ -66,7 +67,6 @@ include/asm-generic/bitops/const_hweight.h include/asm-generic/bitops/fls64.h include/asm-generic/bitops/__fls.h include/asm-generic/bitops/fls.h -include/linux/perf_event.h include/linux/list.h include/linux/hash.h include/linux/stringify.h
@@ -79,7 +79,6 @@ arch/*/lib/memset*.S arch/*/include/asm/*features.h include/linux/poison.h include/linux/hw_breakpoint.h -include/uapi/linux/perf_event.h include/uapi/linux/bpf.h include/uapi/linux/bpf_common.h include/uapi/linux/const.h
tools/perf/Makefile.perf +3 -0
@@ -345,6 +345,9 @@ export srctree OUTPUT RM CC LD AR CFLAGS V BISON FLEX AWK include $(srctree)/tools/build/Makefile.include $(PERF_IN): prepare FORCE + @(test -f ../../include/uapi/linux/perf_event.h && ( \ + (diff -B ../include/uapi/linux/perf_event.h ../../include/uapi/linux/perf_event.h >/dev/null) \ + || echo "Warning: tools/include/uapi/linux/perf_event.h differs from kernel" >&2 )) || true $(Q)$(MAKE) $(build)=perf $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
tools/perf/config/Makefile +1 -0
@@ -206,6 +206,7 @@ endif CFLAGS += -I$(src-perf)/util/include CFLAGS += -I$(src-perf)/arch/$(ARCH)/include +CFLAGS += -I$(srctree)/tools/include/uapi CFLAGS += -I$(srctree)/tools/include/ CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi CFLAGS += -I$(srctree)/arch/$(ARCH)/include
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 36/66 perf bench: Copy kernel files needed to build mem{cpy,set} x86_64 benchmarks
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We can't access kernel files directly from tools/, so copy the required bits, and make sure that we detect when the original files, in the kernel, gets modified.
--- tools/arch/x86/include/asm/cpufeatures.h | 316 +++++++++++++++++++++++++ tools/arch/x86/include/asm/disabled-features.h | 60 +++++ tools/arch/x86/include/asm/required-features.h | 103 ++++++++ tools/arch/x86/lib/memcpy_64.S | 297 +++++++++++++++++++++++ tools/arch/x86/lib/memset_64.S | 138 +++++++++++ tools/include/asm/alternative-asm.h | 9 + tools/perf/MANIFEST | 9 +- tools/perf/Makefile.perf | 15 ++ tools/perf/bench/mem-memcpy-x86-64-asm.S | 2 +- tools/perf/bench/mem-memset-x86-64-asm.S | 2 +- tools/perf/util/include/asm/alternative-asm.h | 9 - 11 files changed, 946 insertions(+), 14 deletions(-) create mode 100644 tools/arch/x86/include/asm/cpufeatures.h create mode 100644 tools/arch/x86/include/asm/disabled-features.h create mode 100644 tools/arch/x86/include/asm/required-features.h create mode 100644 tools/arch/x86/lib/memcpy_64.S create mode 100644 tools/arch/x86/lib/memset_64.S create mode 100644 tools/include/asm/alternative-asm.h delete mode 100644 tools/perf/util/include/asm/alternative-asm.h
tools/arch/x86/include/asm/cpufeatures.h new file +316 -0
@@ -0,0 +1,316 @@ +#ifndef _ASM_X86_CPUFEATURES_H +#define _ASM_X86_CPUFEATURES_H + +#ifndef _ASM_X86_REQUIRED_FEATURES_H +#include <asm/required-features.h> +#endif + +#ifndef _ASM_X86_DISABLED_FEATURES_H +#include <asm/disabled-features.h> +#endif + +/* +* Defines x86 CPU feature bits +*/ +#define NCAPINTS 18/* N 32-bit words worth of info */ +#define NBUGINTS 1/* N 32-bit bug flags */ + +/* +* Note: If the comment begins with a quoted string, that string is used +* in /proc/cpuinfo instead of the macro name. If the string is "", +* this feature bit is not displayed in /proc/cpuinfo at all. +*/ + +/* Intel-defined CPU features, CPUID level 0x00000001 (edx), word 0 */ +#define X86_FEATURE_FPU ( 0*32+ 0)/* Onboard FPU */ +#define X86_FEATURE_VME ( 0*32+ 1)/* Virtual Mode Extensions */ +#define X86_FEATURE_DE ( 0*32+ 2)/* Debugging Extensions */ +#define X86_FEATURE_PSE ( 0*32+ 3)/* Page Size Extensions */ +#define X86_FEATURE_TSC ( 0*32+ 4)/* Time Stamp Counter */ +#define X86_FEATURE_MSR ( 0*32+ 5)/* Model-Specific Registers */ +#define X86_FEATURE_PAE ( 0*32+ 6)/* Physical Address Extensions */ +#define X86_FEATURE_MCE ( 0*32+ 7)/* Machine Check Exception */ +#define X86_FEATURE_CX8 ( 0*32+ 8)/* CMPXCHG8 instruction */ +#define X86_FEATURE_APIC ( 0*32+ 9)/* Onboard APIC */ +#define X86_FEATURE_SEP ( 0*32+11)/* SYSENTER/SYSEXIT */ +#define X86_FEATURE_MTRR ( 0*32+12)/* Memory Type Range Registers */ +#define X86_FEATURE_PGE ( 0*32+13)/* Page Global Enable */ +#define X86_FEATURE_MCA ( 0*32+14)/* Machine Check Architecture */ +#define X86_FEATURE_CMOV ( 0*32+15)/* CMOV instructions */ +/* (plus FCMOVcc, FCOMI with FPU) */ +#define X86_FEATURE_PAT ( 0*32+16)/* Page Attribute Table */ +#define X86_FEATURE_PSE36 ( 0*32+17)/* 36-bit PSEs */ +#define X86_FEATURE_PN ( 0*32+18)/* Processor serial number */ +#define X86_FEATURE_CLFLUSH ( 0*32+19)/* CLFLUSH instruction */ +#define X86_FEATURE_DS ( 0*32+21)/* "dts" Debug Store */ +#define X86_FEATURE_ACPI ( 0*32+22)/* ACPI via MSR */ +#define X86_FEATURE_MMX ( 0*32+23)/* Multimedia Extensions */ +#define X86_FEATURE_FXSR ( 0*32+24)/* FXSAVE/FXRSTOR, CR4.OSFXSR */ +#define X86_FEATURE_XMM ( 0*32+25)/* "sse" */ +#define X86_FEATURE_XMM2 ( 0*32+26)/* "sse2" */ +#define X86_FEATURE_SELFSNOOP ( 0*32+27)/* "ss" CPU self snoop */ +#define X86_FEATURE_HT ( 0*32+28)/* Hyper-Threading */ +#define X86_FEATURE_ACC ( 0*32+29)/* "tm" Automatic clock control */ +#define X86_FEATURE_IA64 ( 0*32+30)/* IA-64 processor */ +#define X86_FEATURE_PBE ( 0*32+31)/* Pending Break Enable */ + +/* AMD-defined CPU features, CPUID level 0x80000001, word 1 */ +/* Don't duplicate feature flags which are redundant with Intel! */ +#define X86_FEATURE_SYSCALL ( 1*32+11)/* SYSCALL/SYSRET */ +#define X86_FEATURE_MP ( 1*32+19)/* MP Capable. */ +#define X86_FEATURE_NX ( 1*32+20)/* Execute Disable */ +#define X86_FEATURE_MMXEXT ( 1*32+22)/* AMD MMX extensions */ +#define X86_FEATURE_FXSR_OPT ( 1*32+25)/* FXSAVE/FXRSTOR optimizations */ +#define X86_FEATURE_GBPAGES ( 1*32+26)/* "pdpe1gb" GB pages */ +#define X86_FEATURE_RDTSCP ( 1*32+27)/* RDTSCP */ +#define X86_FEATURE_LM ( 1*32+29)/* Long Mode (x86-64) */ +#define X86_FEATURE_3DNOWEXT ( 1*32+30)/* AMD 3DNow! extensions */ +#define X86_FEATURE_3DNOW ( 1*32+31)/* 3DNow! */ + +/* Transmeta-defined CPU features, CPUID level 0x80860001, word 2 */ +#define X86_FEATURE_RECOVERY ( 2*32+ 0)/* CPU in recovery mode */ +#define X86_FEATURE_LONGRUN ( 2*32+ 1)/* Longrun power control */ +#define X86_FEATURE_LRTI ( 2*32+ 3)/* LongRun table interface */ + +/* Other features, Linux-defined mapping, word 3 */ +/* This range is used for feature bits which conflict or are synthesized */ +#define X86_FEATURE_CXMMX ( 3*32+ 0)/* Cyrix MMX extensions */ +#define X86_FEATURE_K6_MTRR ( 3*32+ 1)/* AMD K6 nonstandard MTRRs */ +#define X86_FEATURE_CYRIX_ARR ( 3*32+ 2)/* Cyrix ARRs (= MTRRs) */ +#define X86_FEATURE_CENTAUR_MCR ( 3*32+ 3)/* Centaur MCRs (= MTRRs) */ +/* cpu types for specific tunings: */ +#define X86_FEATURE_K8 ( 3*32+ 4)/* "" Opteron, Athlon64 */ +#define X86_FEATURE_K7 ( 3*32+ 5)/* "" Athlon */ +#define X86_FEATURE_P3 ( 3*32+ 6)/* "" P3 */ +#define X86_FEATURE_P4 ( 3*32+ 7)/* "" P4 */ +#define X86_FEATURE_CONSTANT_TSC ( 3*32+ 8)/* TSC ticks at a constant rate */ +#define X86_FEATURE_UP ( 3*32+ 9)/* smp kernel running on up */ +#define X86_FEATURE_ART ( 3*32+10)/* Platform has always running timer (ART) */ +#define X86_FEATURE_ARCH_PERFMON ( 3*32+11)/* Intel Architectural PerfMon */ +#define X86_FEATURE_PEBS ( 3*32+12)/* Precise-Event Based Sampling */ +#define X86_FEATURE_BTS ( 3*32+13)/* Branch Trace Store */ +#define X86_FEATURE_SYSCALL32 ( 3*32+14)/* "" syscall in ia32 userspace */ +#define X86_FEATURE_SYSENTER32 ( 3*32+15)/* "" sysenter in ia32 userspace */ +#define X86_FEATURE_REP_GOOD ( 3*32+16)/* rep microcode works well */ +#define X86_FEATURE_MFENCE_RDTSC ( 3*32+17)/* "" Mfence synchronizes RDTSC */ +#define X86_FEATURE_LFENCE_RDTSC ( 3*32+18)/* "" Lfence synchronizes RDTSC */ +#define X86_FEATURE_ACC_POWER ( 3*32+19)/* AMD Accumulated Power Mechanism */ +#define X86_FEATURE_NOPL ( 3*32+20)/* The NOPL (0F 1F) instructions */ +#define X86_FEATURE_ALWAYS ( 3*32+21)/* "" Always-present feature */ +#define X86_FEATURE_XTOPOLOGY ( 3*32+22)/* cpu topology enum extensions */ +#define X86_FEATURE_TSC_RELIABLE ( 3*32+23)/* TSC is known to be reliable */ +#define X86_FEATURE_NONSTOP_TSC ( 3*32+24)/* TSC does not stop in C states */ +/* free, was #define X86_FEATURE_CLFLUSH_MONITOR ( 3*32+25) * "" clflush reqd with monitor */ +#define X86_FEATURE_EXTD_APICID ( 3*32+26)/* has extended APICID (8 bits) */ +#define X86_FEATURE_AMD_DCM ( 3*32+27)/* multi-node processor */ +#define X86_FEATURE_APERFMPERF ( 3*32+28)/* APERFMPERF */ +#define X86_FEATURE_EAGER_FPU ( 3*32+29)/* "eagerfpu" Non lazy FPU restore */ +#define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30)/* TSC doesn't stop in S3 state */ +#define X86_FEATURE_MCE_RECOVERY ( 3*32+31)/* cpu has recoverable machine checks */ + +/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ +#define X86_FEATURE_XMM3 ( 4*32+ 0)/* "pni" SSE-3 */ +#define X86_FEATURE_PCLMULQDQ ( 4*32+ 1)/* PCLMULQDQ instruction */ +#define X86_FEATURE_DTES64 ( 4*32+ 2)/* 64-bit Debug Store */ +#define X86_FEATURE_MWAIT ( 4*32+ 3)/* "monitor" Monitor/Mwait support */ +#define X86_FEATURE_DSCPL ( 4*32+ 4)/* "ds_cpl" CPL Qual. Debug Store */ +#define X86_FEATURE_VMX ( 4*32+ 5)/* Hardware virtualization */ +#define X86_FEATURE_SMX ( 4*32+ 6)/* Safer mode */ +#define X86_FEATURE_EST ( 4*32+ 7)/* Enhanced SpeedStep */ +#define X86_FEATURE_TM2 ( 4*32+ 8)/* Thermal Monitor 2 */ +#define X86_FEATURE_SSSE3 ( 4*32+ 9)/* Supplemental SSE-3 */ +#define X86_FEATURE_CID ( 4*32+10)/* Context ID */ +#define X86_FEATURE_SDBG ( 4*32+11)/* Silicon Debug */ +#define X86_FEATURE_FMA ( 4*32+12)/* Fused multiply-add */ +#define X86_FEATURE_CX16 ( 4*32+13)/* CMPXCHG16B */ +#define X86_FEATURE_XTPR ( 4*32+14)/* Send Task Priority Messages */ +#define X86_FEATURE_PDCM ( 4*32+15)/* Performance Capabilities */ +#define X86_FEATURE_PCID ( 4*32+17)/* Process Context Identifiers */ +#define X86_FEATURE_DCA ( 4*32+18)/* Direct Cache Access */ +#define X86_FEATURE_XMM4_1 ( 4*32+19)/* "sse4_1" SSE-4.1 */ +#define X86_FEATURE_XMM4_2 ( 4*32+20)/* "sse4_2" SSE-4.2 */ +#define X86_FEATURE_X2APIC ( 4*32+21)/* x2APIC */ +#define X86_FEATURE_MOVBE ( 4*32+22)/* MOVBE instruction */ +#define X86_FEATURE_POPCNT ( 4*32+23)/* POPCNT instruction */ +#define X86_FEATURE_TSC_DEADLINE_TIMER ( 4*32+24)/* Tsc deadline timer */ +#define X86_FEATURE_AES ( 4*32+25)/* AES instructions */ +#define X86_FEATURE_XSAVE ( 4*32+26)/* XSAVE/XRSTOR/XSETBV/XGETBV */ +#define X86_FEATURE_OSXSAVE ( 4*32+27)/* "" XSAVE enabled in the OS */ +#define X86_FEATURE_AVX ( 4*32+28)/* Advanced Vector Extensions */ +#define X86_FEATURE_F16C ( 4*32+29)/* 16-bit fp conversions */ +#define X86_FEATURE_RDRAND ( 4*32+30)/* The RDRAND instruction */ +#define X86_FEATURE_HYPERVISOR ( 4*32+31)/* Running on a hypervisor */ + +/* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */ +#define X86_FEATURE_XSTORE ( 5*32+ 2)/* "rng" RNG present (xstore) */ +#define X86_FEATURE_XSTORE_EN ( 5*32+ 3)/* "rng_en" RNG enabled */ +#define X86_FEATURE_XCRYPT ( 5*32+ 6)/* "ace" on-CPU crypto (xcrypt) */ +#define X86_FEATURE_XCRYPT_EN ( 5*32+ 7)/* "ace_en" on-CPU crypto enabled */ +#define X86_FEATURE_ACE2 ( 5*32+ 8)/* Advanced Cryptography Engine v2 */ +#define X86_FEATURE_ACE2_EN ( 5*32+ 9)/* ACE v2 enabled */ +#define X86_FEATURE_PHE ( 5*32+10)/* PadLock Hash Engine */ +#define X86_FEATURE_PHE_EN ( 5*32+11)/* PHE enabled */ +#define X86_FEATURE_PMM ( 5*32+12)/* PadLock Montgomery Multiplier */ +#define X86_FEATURE_PMM_EN ( 5*32+13)/* PMM enabled */ + +/* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */ +#define X86_FEATURE_LAHF_LM ( 6*32+ 0)/* LAHF/SAHF in long mode */ +#define X86_FEATURE_CMP_LEGACY ( 6*32+ 1)/* If yes HyperThreading not valid */ +#define X86_FEATURE_SVM ( 6*32+ 2)/* Secure virtual machine */ +#define X86_FEATURE_EXTAPIC ( 6*32+ 3)/* Extended APIC space */ +#define X86_FEATURE_CR8_LEGACY ( 6*32+ 4)/* CR8 in 32-bit mode */ +#define X86_FEATURE_ABM ( 6*32+ 5)/* Advanced bit manipulation */ +#define X86_FEATURE_SSE4A ( 6*32+ 6)/* SSE-4A */ +#define X86_FEATURE_MISALIGNSSE ( 6*32+ 7)/* Misaligned SSE mode */ +#define X86_FEATURE_3DNOWPREFETCH ( 6*32+ 8)/* 3DNow prefetch instructions */ +#define X86_FEATURE_OSVW ( 6*32+ 9)/* OS Visible Workaround */ +#define X86_FEATURE_IBS ( 6*32+10)/* Instruction Based Sampling */ +#define X86_FEATURE_XOP ( 6*32+11)/* extended AVX instructions */ +#define X86_FEATURE_SKINIT ( 6*32+12)/* SKINIT/STGI instructions */ +#define X86_FEATURE_WDT ( 6*32+13)/* Watchdog timer */ +#define X86_FEATURE_LWP ( 6*32+15)/* Light Weight Profiling */ +#define X86_FEATURE_FMA4 ( 6*32+16)/* 4 operands MAC instructions */ +#define X86_FEATURE_TCE ( 6*32+17)/* translation cache extension */ +#define X86_FEATURE_NODEID_MSR ( 6*32+19)/* NodeId MSR */ +#define X86_FEATURE_TBM ( 6*32+21)/* trailing bit manipulations */ +#define X86_FEATURE_TOPOEXT ( 6*32+22)/* topology extensions CPUID leafs */ +#define X86_FEATURE_PERFCTR_CORE ( 6*32+23)/* core performance counter extensions */ +#define X86_FEATURE_PERFCTR_NB ( 6*32+24)/* NB performance counter extensions */ +#define X86_FEATURE_BPEXT (6*32+26)/* data breakpoint extension */ +#define X86_FEATURE_PTSC ( 6*32+27)/* performance time-stamp counter */ +#define X86_FEATURE_PERFCTR_L2 ( 6*32+28)/* L2 performance counter extensions */ +#define X86_FEATURE_MWAITX ( 6*32+29)/* MWAIT extension (MONITORX/MWAITX) */ + +/* +* Auxiliary flags: Linux defined - For features scattered in various +* CPUID levels like 0x6, 0xA etc, word 7. +* +* Reuse free bits when adding new feature flags! +*/ + +#define X86_FEATURE_CPB ( 7*32+ 2)/* AMD Core Performance Boost */ +#define X86_FEATURE_EPB ( 7*32+ 3)/* IA32_ENERGY_PERF_BIAS support */ + +#define X86_FEATURE_HW_PSTATE ( 7*32+ 8)/* AMD HW-PState */ +#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9)/* AMD ProcFeedbackInterface */ + +#define X86_FEATURE_INTEL_PT ( 7*32+15)/* Intel Processor Trace */ + +/* Virtualization flags: Linux defined, word 8 */ +#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0)/* Intel TPR Shadow */ +#define X86_FEATURE_VNMI ( 8*32+ 1)/* Intel Virtual NMI */ +#define X86_FEATURE_FLEXPRIORITY ( 8*32+ 2)/* Intel FlexPriority */ +#define X86_FEATURE_EPT ( 8*32+ 3)/* Intel Extended Page Table */ +#define X86_FEATURE_VPID ( 8*32+ 4)/* Intel Virtual Processor ID */ + +#define X86_FEATURE_VMMCALL ( 8*32+15)/* Prefer vmmcall to vmcall */ +#define X86_FEATURE_XENPV ( 8*32+16)/* "" Xen paravirtual guest */ + + +/* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */ +#define X86_FEATURE_FSGSBASE ( 9*32+ 0)/* {RD/WR}{FS/GS}BASE instructions*/ +#define X86_FEATURE_TSC_ADJUST ( 9*32+ 1)/* TSC adjustment MSR 0x3b */ +#define X86_FEATURE_BMI1 ( 9*32+ 3)/* 1st group bit manipulation extensions */ +#define X86_FEATURE_HLE ( 9*32+ 4)/* Hardware Lock Elision */ +#define X86_FEATURE_AVX2 ( 9*32+ 5)/* AVX2 instructions */ +#define X86_FEATURE_SMEP ( 9*32+ 7)/* Supervisor Mode Execution Protection */ +#define X86_FEATURE_BMI2 ( 9*32+ 8)/* 2nd group bit manipulation extensions */ +#define X86_FEATURE_ERMS ( 9*32+ 9)/* Enhanced REP MOVSB/STOSB */ +#define X86_FEATURE_INVPCID ( 9*32+10)/* Invalidate Processor Context ID */ +#define X86_FEATURE_RTM ( 9*32+11)/* Restricted Transactional Memory */ +#define X86_FEATURE_CQM ( 9*32+12)/* Cache QoS Monitoring */ +#define X86_FEATURE_MPX ( 9*32+14)/* Memory Protection Extension */ +#define X86_FEATURE_AVX512F ( 9*32+16)/* AVX-512 Foundation */ +#define X86_FEATURE_AVX512DQ ( 9*32+17)/* AVX-512 DQ (Double/Quad granular) Instructions */ +#define X86_FEATURE_RDSEED ( 9*32+18)/* The RDSEED instruction */ +#define X86_FEATURE_ADX ( 9*32+19)/* The ADCX and ADOX instructions */ +#define X86_FEATURE_SMAP ( 9*32+20)/* Supervisor Mode Access Prevention */ +#define X86_FEATURE_PCOMMIT ( 9*32+22)/* PCOMMIT instruction */ +#define X86_FEATURE_CLFLUSHOPT ( 9*32+23)/* CLFLUSHOPT instruction */ +#define X86_FEATURE_CLWB ( 9*32+24)/* CLWB instruction */ +#define X86_FEATURE_AVX512PF ( 9*32+26)/* AVX-512 Prefetch */ +#define X86_FEATURE_AVX512ER ( 9*32+27)/* AVX-512 Exponential and Reciprocal */ +#define X86_FEATURE_AVX512CD ( 9*32+28)/* AVX-512 Conflict Detection */ +#define X86_FEATURE_SHA_NI ( 9*32+29)/* SHA1/SHA256 Instruction Extensions */ +#define X86_FEATURE_AVX512BW ( 9*32+30)/* AVX-512 BW (Byte/Word granular) Instructions */ +#define X86_FEATURE_AVX512VL ( 9*32+31)/* AVX-512 VL (128/256 Vector Length) Extensions */ + +/* Extended state features, CPUID level 0x0000000d:1 (eax), word 10 */ +#define X86_FEATURE_XSAVEOPT (10*32+ 0)/* XSAVEOPT */ +#define X86_FEATURE_XSAVEC (10*32+ 1)/* XSAVEC */ +#define X86_FEATURE_XGETBV1 (10*32+ 2)/* XGETBV with ECX = 1 */ +#define X86_FEATURE_XSAVES (10*32+ 3)/* XSAVES/XRSTORS */ + +/* Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:0 (edx), word 11 */ +#define X86_FEATURE_CQM_LLC (11*32+ 1)/* LLC QoS if 1 */ + +/* Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:1 (edx), word 12 */ +#define X86_FEATURE_CQM_OCCUP_LLC (12*32+ 0)/* LLC occupancy monitoring if 1 */ +#define X86_FEATURE_CQM_MBM_TOTAL (12*32+ 1)/* LLC Total MBM monitoring */ +#define X86_FEATURE_CQM_MBM_LOCAL (12*32+ 2)/* LLC Local MBM monitoring */ + +/* AMD-defined CPU features, CPUID level 0x80000008 (ebx), word 13 */ +#define X86_FEATURE_CLZERO (13*32+0)/* CLZERO instruction */ +#define X86_FEATURE_IRPERF (13*32+1)/* Instructions Retired Count */ + +/* Thermal and Power Management Leaf, CPUID level 0x00000006 (eax), word 14 */ +#define X86_FEATURE_DTHERM (14*32+ 0)/* Digital Thermal Sensor */ +#define X86_FEATURE_IDA (14*32+ 1)/* Intel Dynamic Acceleration */ +#define X86_FEATURE_ARAT (14*32+ 2)/* Always Running APIC Timer */ +#define X86_FEATURE_PLN (14*32+ 4)/* Intel Power Limit Notification */ +#define X86_FEATURE_PTS (14*32+ 6)/* Intel Package Thermal Status */ +#define X86_FEATURE_HWP (14*32+ 7)/* Intel Hardware P-states */ +#define X86_FEATURE_HWP_NOTIFY (14*32+ 8)/* HWP Notification */ +#define X86_FEATURE_HWP_ACT_WINDOW (14*32+ 9)/* HWP Activity Window */ +#define X86_FEATURE_HWP_EPP (14*32+10)/* HWP Energy Perf. Preference */ +#define X86_FEATURE_HWP_PKG_REQ (14*32+11)/* HWP Package Level Request */ + +/* AMD SVM Feature Identification, CPUID level 0x8000000a (edx), word 15 */ +#define X86_FEATURE_NPT (15*32+ 0)/* Nested Page Table support */ +#define X86_FEATURE_LBRV (15*32+ 1)/* LBR Virtualization support */ +#define X86_FEATURE_SVML (15*32+ 2)/* "svm_lock" SVM locking MSR */ +#define X86_FEATURE_NRIPS (15*32+ 3)/* "nrip_save" SVM next_rip save */ +#define X86_FEATURE_TSCRATEMSR (15*32+ 4)/* "tsc_scale" TSC scaling support */ +#define X86_FEATURE_VMCBCLEAN (15*32+ 5)/* "vmcb_clean" VMCB clean bits support */ +#define X86_FEATURE_FLUSHBYASID (15*32+ 6)/* flush-by-ASID support */ +#define X86_FEATURE_DECODEASSISTS (15*32+ 7)/* Decode Assists support */ +#define X86_FEATURE_PAUSEFILTER (15*32+10)/* filtered pause intercept */ +#define X86_FEATURE_PFTHRESHOLD (15*32+12)/* pause filter threshold */ +#define X86_FEATURE_AVIC (15*32+13)/* Virtual Interrupt Controller */ + +/* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 16 */ +#define X86_FEATURE_PKU (16*32+ 3)/* Protection Keys for Userspace */ +#define X86_FEATURE_OSPKE (16*32+ 4)/* OS Protection Keys Enable */ + +/* AMD-defined CPU features, CPUID level 0x80000007 (ebx), word 17 */ +#define X86_FEATURE_OVERFLOW_RECOV (17*32+0)/* MCA overflow recovery support */ +#define X86_FEATURE_SUCCOR (17*32+1)/* Uncorrectable error containment and recovery */ +#define X86_FEATURE_SMCA (17*32+3)/* Scalable MCA */ + +/* +* BUG word(s) +*/ +#define X86_BUG (x) (NCAPINTS*32 + (x)) + +#define X86_BUG_F00F X86_BUG(0)/* Intel F00F */ +#define X86_BUG_FDIV X86_BUG(1)/* FPU FDIV */ +#define X86_BUG_COMA X86_BUG(2)/* Cyrix 6x86 coma */ +#define X86_BUG_AMD_TLB_MMATCH X86_BUG(3)/* "tlb_mmatch" AMD Erratum 383 */ +#define X86_BUG_AMD_APIC_C1E X86_BUG(4)/* "apic_c1e" AMD Erratum 400 */ +#define X86_BUG_11AP X86_BUG(5)/* Bad local APIC aka 11AP */ +#define X86_BUG_FXSAVE_LEAK X86_BUG(6)/* FXSAVE leaks FOP/FIP/FOP */ +#define X86_BUG_CLFLUSH_MONITOR X86_BUG(7)/* AAI65, CLFLUSH required before MONITOR */ +#define X86_BUG_SYSRET_SS_ATTRS X86_BUG(8)/* SYSRET doesn't fix up SS attrs */ +#define X86_BUG_NULL_SEG X86_BUG(9)/* Nulling a selector preserves the base */ +#define X86_BUG_SWAPGS_FENCE X86_BUG(10)/* SWAPGS without input dep on GS */ + + +#ifdef CONFIG_X86_32 +/* +* 64-bit kernels don't use X86_BUG_ESPFIX. Make the define conditional +* to avoid confusion. +*/ +#define X86_BUG_ESPFIX X86_BUG(9)/* "" IRET to 16-bit SS corrupts ESP/RSP high bits */ +#endif + +#endif /* _ASM_X86_CPUFEATURES_H */
tools/arch/x86/include/asm/disabled-features.h new file +60 -0
60 lines not on this page · raw message
tools/arch/x86/include/asm/required-features.h new file +103 -0
103 lines not on this page · raw message
tools/arch/x86/lib/memcpy_64.S new file +297 -0
297 lines not on this page · raw message
tools/arch/x86/lib/memset_64.S new file +138 -0
138 lines not on this page · raw message
tools/include/asm/alternative-asm.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef _TOOLS_ASM_ALTERNATIVE_ASM_H +#define _TOOLS_ASM_ALTERNATIVE_ASM_H + +/* Just disable it so we can build arch/x86/lib/memcpy_64.S for perf bench: */ + +#define altinstruction_entry # +#define ALTERNATIVE_2 # + +#endif
tools/perf/MANIFEST +6 -3
@@ -12,6 +12,11 @@ tools/arch/sparc/include/asm/barrier_32.h tools/arch/sparc/include/asm/barrier_64.h tools/arch/tile/include/asm/barrier.h tools/arch/x86/include/asm/barrier.h +tools/arch/x86/include/asm/cpufeatures.h +tools/arch/x86/include/asm/disabled-features.h +tools/arch/x86/include/asm/required-features.h +tools/arch/x86/lib/memcpy_64.S +tools/arch/x86/lib/memset_64.S tools/arch/xtensa/include/asm/barrier.h tools/scripts tools/build
@@ -31,6 +36,7 @@ tools/lib/find_bit.c tools/lib/bitmap.c tools/lib/str_error_r.c tools/lib/vsprintf.c +tools/include/asm/alternative-asm.h tools/include/asm/atomic.h tools/include/asm/barrier.h tools/include/asm/bug.h
@@ -74,9 +80,6 @@ include/linux/swab.h arch/*/include/asm/unistd*.h arch/*/include/uapi/asm/unistd*.h arch/*/include/uapi/asm/perf_regs.h -arch/*/lib/memcpy*.S -arch/*/lib/memset*.S -arch/*/include/asm/*features.h include/linux/poison.h include/linux/hw_breakpoint.h include/uapi/linux/bpf.h
tools/perf/Makefile.perf +15 -0
@@ -348,6 +348,21 @@ $(PERF_IN): prepare FORCE @(test -f ../../include/uapi/linux/perf_event.h && ( \ (diff -B ../include/uapi/linux/perf_event.h ../../include/uapi/linux/perf_event.h >/dev/null) \ || echo "Warning: tools/include/uapi/linux/perf_event.h differs from kernel" >&2 )) || true + @(test -f ../../arch/x86/include/asm/disabled-features.h && ( \ + (diff -B ../arch/x86/include/asm/disabled-features.h ../../arch/x86/include/asm/disabled-features.h >/dev/null) \ + || echo "Warning: tools/arch/x86/include/asm/disabled-features.h differs from kernel" >&2 )) || true + @(test -f ../../arch/x86/include/asm/required-features.h && ( \ + (diff -B ../arch/x86/include/asm/required-features.h ../../arch/x86/include/asm/required-features.h >/dev/null) \ + || echo "Warning: tools/arch/x86/include/asm/required-features.h differs from kernel" >&2 )) || true + @(test -f ../../arch/x86/include/asm/cpufeatures.h && ( \ + (diff -B ../arch/x86/include/asm/cpufeatures.h ../../arch/x86/include/asm/cpufeatures.h >/dev/null) \ + || echo "Warning: tools/arch/x86/include/asm/cpufeatures.h differs from kernel" >&2 )) || true + @(test -f ../../arch/x86/lib/memcpy_64.S && ( \ + (diff -B ../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memcpy_64.S >/dev/null) \ + || echo "Warning: tools/arch/x86/lib/memcpy_64.S differs from kernel" >&2 )) || true + @(test -f ../../arch/x86/lib/memset_64.S && ( \ + (diff -B ../arch/x86/lib/memset_64.S ../../arch/x86/lib/memset_64.S >/dev/null) \ + || echo "Warning: tools/arch/x86/lib/memset_64.S differs from kernel" >&2 )) || true $(Q)$(MAKE) $(build)=perf $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
tools/perf/bench/mem-memcpy-x86-64-asm.S +1 -1
@@ -6,7 +6,7 @@ #define globl p2align 4; .globl #define _ASM_EXTABLE_FAULT(x, y) -#include "../../../arch/x86/lib/memcpy_64.S" +#include "../../arch/x86/lib/memcpy_64.S" /* * We need to provide note.GNU-stack section, saying that we want * NOT executable stack. Otherwise the final linking will assume that
tools/perf/bench/mem-memset-x86-64-asm.S +1 -1
@@ -1,7 +1,7 @@ #define memset MEMSET /* don't hide glibc's memset() */ #define altinstr_replacement text #define globl p2align 4; .globl -#include "../../../arch/x86/lib/memset_64.S" +#include "../../arch/x86/lib/memset_64.S" /* * We need to provide note.GNU-stack section, saying that we want
tools/perf/util/include/asm/alternative-asm.h deleted +0 -9
@@ -1,9 +0,0 @@ -#ifndef _PERF_ASM_ALTERNATIVE_ASM_H -#define _PERF_ASM_ALTERNATIVE_ASM_H - -/* Just disable it so we can build arch/x86/lib/memcpy_64.S for perf bench: */ - -#define altinstruction_entry # -#define ALTERNATIVE_2 # - -#endif
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 37/66 tools lib bpf: Copy bpf.h and bpf_common.h from the kernel
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To allow the build to complete on older systems, where those files are either not uptodate, lacking some recent additions or not present at all.
And check if the copy drifts from the kernel, as in this synthetic test:
BUILD: Doing 'make -j4' parallel build
Warning: tools/include/linux/bpf.h differs from kernel
Warning: tools/include/linux/bpf_common.h differs from kernel
--- tools/include/uapi/linux/bpf.h | 389 ++++++++++++++++++++++++++++++++++ tools/include/uapi/linux/bpf_common.h | 55 +++++ tools/lib/bpf/Makefile | 8 +- tools/perf/MANIFEST | 5 +- tools/perf/config/Makefile | 5 +- 5 files changed, 456 insertions(+), 6 deletions(-) create mode 100644 tools/include/uapi/linux/bpf.h create mode 100644 tools/include/uapi/linux/bpf_common.h
tools/include/uapi/linux/bpf.h new file +389 -0
@@ -0,0 +1,389 @@ +/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of version 2 of the GNU General Public +* License as published by the Free Software Foundation. +*/ +#ifndef _UAPI__LINUX_BPF_H__ +#define _UAPI__LINUX_BPF_H__ + +#include <linux/types.h> +#include <linux/bpf_common.h> + +/* Extended instruction set based on top of classic BPF */ + +/* instruction classes */ +#define BPF_ALU64 0x07/* alu mode in double word width */ + +/* ld/ldx fields */ +#define BPF_DW 0x18/* double word */ +#define BPF_XADD 0xc0/* exclusive add */ + +/* alu/jmp fields */ +#define BPF_MOV 0xb0/* mov reg to reg */ +#define BPF_ARSH 0xc0/* sign extending arithmetic shift right */ + +/* change endianness of a register */ +#define BPF_END 0xd0/* flags for endianness conversion: */ +#define BPF_TO_LE 0x00/* convert to little-endian */ +#define BPF_TO_BE 0x08/* convert to big-endian */ +#define BPF_FROM_LE BPF_TO_LE +#define BPF_FROM_BE BPF_TO_BE + +#define BPF_JNE 0x50/* jump != */ +#define BPF_JSGT 0x60/* SGT is signed '>', GT in x86 */ +#define BPF_JSGE 0x70/* SGE is signed '>=', GE in x86 */ +#define BPF_CALL 0x80/* function call */ +#define BPF_EXIT 0x90/* function return */ + +/* Register numbers */ +enum { +BPF_REG_0 =0 , +BPF_REG_1 , +BPF_REG_2 , +BPF_REG_3 , +BPF_REG_4 , +BPF_REG_5 , +BPF_REG_6 , +BPF_REG_7 , +BPF_REG_8 , +BPF_REG_9 , +BPF_REG_10 , + __MAX_BPF_REG, +}; + +/* BPF has 10 general purpose 64-bit registers and stack frame. */ +#define MAX_BPF_REG __MAX_BPF_REG + +struct bpf_insn { +__u8 code;/* opcode */ +__u8 dst_reg:4 ;/* dest register */ +__u8 src_reg:4 ;/* source register */ +__s16 off;/* signed offset */ +__s32 imm;/* signed immediate constant */ +}; + +/* BPF syscall commands, see bpf(2) man-page for details. */ +enum bpf_cmd { +BPF_MAP_CREATE , +BPF_MAP_LOOKUP_ELEM , +BPF_MAP_UPDATE_ELEM , +BPF_MAP_DELETE_ELEM , +BPF_MAP_GET_NEXT_KEY , +BPF_PROG_LOAD , +BPF_OBJ_PIN , +BPF_OBJ_GET , +}; + +enum bpf_map_type { +BPF_MAP_TYPE_UNSPEC , +BPF_MAP_TYPE_HASH , +BPF_MAP_TYPE_ARRAY , +BPF_MAP_TYPE_PROG_ARRAY , +BPF_MAP_TYPE_PERF_EVENT_ARRAY , +BPF_MAP_TYPE_PERCPU_HASH , +BPF_MAP_TYPE_PERCPU_ARRAY , +BPF_MAP_TYPE_STACK_TRACE , +}; + +enum bpf_prog_type { +BPF_PROG_TYPE_UNSPEC , +BPF_PROG_TYPE_SOCKET_FILTER , +BPF_PROG_TYPE_KPROBE , +BPF_PROG_TYPE_SCHED_CLS , +BPF_PROG_TYPE_SCHED_ACT , +BPF_PROG_TYPE_TRACEPOINT , +}; + +#define BPF_PSEUDO_MAP_FD 1 + +/* flags for BPF_MAP_UPDATE_ELEM command */ +#define BPF_ANY 0/* create new element or update existing */ +#define BPF_NOEXIST 1/* create new element if it didn't exist */ +#define BPF_EXIST 2/* update existing element */ + +#define BPF_F_NO_PREALLOC (1U << 0) + +union bpf_attr { +struct {/* anonymous struct used by BPF_MAP_CREATE command */ +__u32 map_type;/* one of enum bpf_map_type */ +__u32 key_size;/* size of key in bytes */ +__u32 value_size;/* size of value in bytes */ +__u32 max_entries;/* max number of entries in a map */ +__u32 map_flags;/* prealloc or not */ + }; + +struct {/* anonymous struct used by BPF_MAP_*_ELEM commands */ +__u32 map_fd; +__aligned_u64 key; +union { +__aligned_u64 value; +__aligned_u64 next_key; + }; +__u64 flags; + }; + +struct {/* anonymous struct used by BPF_PROG_LOAD command */ +__u32 prog_type;/* one of enum bpf_prog_type */ +__u32 insn_cnt; +__aligned_u64 insns; +__aligned_u64 license; +__u32 log_level;/* verbosity level of verifier */ +__u32 log_size;/* size of user buffer */ +__aligned_u64 log_buf;/* user supplied buffer */ +__u32 kern_version;/* checked when prog_type=kprobe */ + }; + +struct {/* anonymous struct used by BPF_OBJ_* commands */ +__aligned_u64 pathname; +__u32 bpf_fd; + }; +} __attribute__((aligned (8 ))); + +/* integer value in 'imm' field of BPF_CALL instruction selects which helper +* function eBPF program intends to call +*/ +enum bpf_func_id { + BPF_FUNC_unspec, + BPF_FUNC_map_lookup_elem,/* void *map_lookup_elem(&map, &key) */ + BPF_FUNC_map_update_elem,/* int map_update_elem(&map, &key, &value, flags) */ + BPF_FUNC_map_delete_elem,/* int map_delete_elem(&map, &key) */ + BPF_FUNC_probe_read,/* int bpf_probe_read(void *dst, int size, void *src) */ + BPF_FUNC_ktime_get_ns,/* u64 bpf_ktime_get_ns(void) */ + BPF_FUNC_trace_printk,/* int bpf_trace_printk(const char *fmt, int fmt_size, ...) */ + BPF_FUNC_get_prandom_u32,/* u32 prandom_u32(void) */ + BPF_FUNC_get_smp_processor_id,/* u32 raw_smp_processor_id(void) */ + +/** +* skb_store_bytes(skb, offset, from, len, flags) - store bytes into packet +* @skb: pointer to skb +* @offset: offset within packet from skb->mac_header +* @from: pointer where to copy bytes from +* @len: number of bytes to store into packet +* @flags: bit 0 - if true, recompute skb->csum +* other bits - reserved +* Return: 0 on success +*/ + BPF_FUNC_skb_store_bytes, + +/** +* l3_csum_replace(skb, offset, from, to, flags) - recompute IP checksum +* @skb: pointer to skb +* @offset: offset within packet where IP checksum is located +* @from: old value of header field +* @to: new value of header field +* @flags: bits 0-3 - size of header field +* other bits - reserved +* Return: 0 on success +*/ + BPF_FUNC_l3_csum_replace, + +/** +* l4_csum_replace(skb, offset, from, to, flags) - recompute TCP/UDP checksum +* @skb: pointer to skb +* @offset: offset within packet where TCP/UDP checksum is located +* @from: old value of header field +* @to: new value of header field +* @flags: bits 0-3 - size of header field +* bit 4 - is pseudo header +* other bits - reserved +* Return: 0 on success +*/ + BPF_FUNC_l4_csum_replace, + +/** +* bpf_tail_call(ctx, prog_array_map, index) - jump into another BPF program +* @ctx: context pointer passed to next program +* @prog_array_map: pointer to map which type is BPF_MAP_TYPE_PROG_ARRAY +* @index: index inside array that selects specific program to run +* Return: 0 on success +*/ + BPF_FUNC_tail_call, + +/** +* bpf_clone_redirect(skb, ifindex, flags) - redirect to another netdev +* @skb: pointer to skb +* @ifindex: ifindex of the net device +* @flags: bit 0 - if set, redirect to ingress instead of egress +* other bits - reserved +* Return: 0 on success +*/ + BPF_FUNC_clone_redirect, + +/** +* u64 bpf_get_current_pid_tgid(void) +* Return: current->tgid << 32 | current->pid +*/ + BPF_FUNC_get_current_pid_tgid, + +/** +* u64 bpf_get_current_uid_gid(void) +* Return: current_gid << 32 | current_uid +*/ + BPF_FUNC_get_current_uid_gid, + +/** +* bpf_get_current_comm(char *buf, int size_of_buf) +* stores current->comm into buf +* Return: 0 on success +*/ + BPF_FUNC_get_current_comm, + +/** +* bpf_get_cgroup_classid(skb) - retrieve a proc's classid +* @skb: pointer to skb +* Return: classid if != 0 +*/ + BPF_FUNC_get_cgroup_classid, + BPF_FUNC_skb_vlan_push,/* bpf_skb_vlan_push(skb, vlan_proto, vlan_tci) */ + BPF_FUNC_skb_vlan_pop,/* bpf_skb_vlan_pop(skb) */ + +/** +* bpf_skb_[gs]et_tunnel_key(skb, key, size, flags) +* retrieve or populate tunnel metadata +* @skb: pointer to skb +* @key: pointer to 'struct bpf_tunnel_key' +* @size: size of 'struct bpf_tunnel_key' +* @flags: room for future extensions +* Retrun: 0 on success +*/ + BPF_FUNC_skb_get_tunnel_key, + BPF_FUNC_skb_set_tunnel_key, + BPF_FUNC_perf_event_read,/* u64 bpf_perf_event_read(&map, index) */ +/** +* bpf_redirect(ifindex, flags) - redirect to another netdev +* @ifindex: ifindex of the net device +* @flags: bit 0 - if set, redirect to ingress instead of egress +* other bits - reserved +* Return: TC_ACT_REDIRECT +*/ + BPF_FUNC_redirect, + +/** +* bpf_get_route_realm(skb) - retrieve a dst's tclassid +* @skb: pointer to skb +* Return: realm if != 0 +*/ + BPF_FUNC_get_route_realm, + +/** +* bpf_perf_event_output(ctx, map, index, data, size) - output perf raw sample +* @ctx: struct pt_regs* +* @map: pointer to perf_event_array map +* @index: index of event in the map +* @data: data on stack to be output as raw data +* @size: size of data +* Return: 0 on success +*/ + BPF_FUNC_perf_event_output, + BPF_FUNC_skb_load_bytes, + +/** +* bpf_get_stackid(ctx, map, flags) - walk user or kernel stack and return id +* @ctx: struct pt_regs* +* @map: pointer to stack_trace map +* @flags: bits 0-7 - numer of stack frames to skip +* bit 8 - collect user stack instead of kernel +* bit 9 - compare stacks by hash only +* bit 10 - if two different stacks hash into the same stackid +* discard old +* other bits - reserved +* Return: >= 0 stackid on success or negative error +*/ + BPF_FUNC_get_stackid, + +/** +* bpf_csum_diff(from, from_size, to, to_size, seed) - calculate csum diff +* @from: raw from buffer +* @from_size: length of from buffer +* @to: raw to buffer +* @to_size: length of to buffer +* @seed: optional seed +* Return: csum result +*/ + BPF_FUNC_csum_diff, + +/** +* bpf_skb_[gs]et_tunnel_opt(skb, opt, size) +* retrieve or populate tunnel options metadata +* @skb: pointer to skb +* @opt: pointer to raw tunnel option data +* @size: size of @opt +* Return: 0 on success for set, option size for get +*/ + BPF_FUNC_skb_get_tunnel_opt, + BPF_FUNC_skb_set_tunnel_opt, + __BPF_FUNC_MAX_ID, +}; + +/* All flags used by eBPF helper functions, placed here. */ + +/* BPF_FUNC_skb_store_bytes flags. */ +#define BPF_F_RECOMPUTE_CSUM (1ULL << 0) +#define BPF_F_INVALIDATE_HASH (1ULL << 1) + +/* BPF_FUNC_l3_csum_replace and BPF_FUNC_l4_csum_replace flags. +* First 4 bits are for passing the header field size. +*/ +#define BPF_F_HDR_FIELD_MASK 0xfULL + +/* BPF_FUNC_l4_csum_replace flags. */ +#define BPF_F_PSEUDO_HDR (1ULL << 4) +#define BPF_F_MARK_MANGLED_0 (1ULL << 5) + +/* BPF_FUNC_clone_redirect and BPF_FUNC_redirect flags. */ +#define BPF_F_INGRESS (1ULL << 0) + +/* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */ +#define BPF_F_TUNINFO_IPV6 (1ULL << 0) + +/* BPF_FUNC_get_stackid flags. */ +#define BPF_F_SKIP_FIELD_MASK 0xffULL +#define BPF_F_USER_STACK (1ULL << 8) +#define BPF_F_FAST_STACK_CMP (1ULL << 9) +#define BPF_F_REUSE_STACKID (1ULL << 10) + +/* BPF_FUNC_skb_set_tunnel_key flags. */ +#define BPF_F_ZERO_CSUM_TX (1ULL << 1) +#define BPF_F_DONT_FRAGMENT (1ULL << 2) + +/* BPF_FUNC_perf_event_output flags. */ +#define BPF_F_INDEX_MASK 0xffffffffULL +#define BPF_F_CURRENT_CPU BPF_F_INDEX_MASK + +/* user accessible mirror of in-kernel sk_buff. +* new fields can only be added to the end of this structure +*/ +struct __sk_buff { +__u32 len; +__u32 pkt_type; +__u32 mark; +__u32 queue_mapping; +__u32 protocol; +__u32 vlan_present; +__u32 vlan_tci; +__u32 vlan_proto; +__u32 priority; +__u32 ingress_ifindex; +__u32 ifindex; +__u32 tc_index; +__u32 cb[5 ]; +__u32 hash; +__u32 tc_classid; +__u32 data; +__u32 data_end; +}; + +struct bpf_tunnel_key { +__u32 tunnel_id; +union { +__u32 remote_ipv4; +__u32 remote_ipv6[4 ]; + }; +__u8 tunnel_tos; +__u8 tunnel_ttl; +__u16 tunnel_ext; +__u32 tunnel_label; +}; + +#endif /* _UAPI__LINUX_BPF_H__ */
tools/include/uapi/linux/bpf_common.h new file +55 -0
55 lines not on this page · raw message
tools/lib/bpf/Makefile +7 -1
@@ -68,7 +68,7 @@ FEATURE_USER = .libbpf FEATURE_TESTS = libelf libelf-getphdrnum libelf-mmap bpf FEATURE_DISPLAY = libelf bpf -INCLUDES = -I. -I$(srctree)/tools/include -I$(srctree)/arch/$(ARCH)/include/uapi -I$(srctree)/include/uapi +INCLUDES = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(ARCH)/include/uapi -I$(srctree)/tools/include/uapi FEATURE_CHECK_CFLAGS-bpf = $(INCLUDES) check_feat := 1
@@ -154,6 +154,12 @@ all: fixdep $(VERSION_FILES) all_cmd all_cmd: $(CMD_TARGETS) $(BPF_IN): force elfdep bpfdep + @(test -f ../../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \ + (diff -B ../../include/uapi/linux/bpf.h ../../../include/uapi/linux/bpf.h >/dev/null) || \ + echo "Warning: tools/include/uapi/linux/bpf.h differs from kernel" >&2 )) || true + @(test -f ../../../include/uapi/linux/bpf_common.h -a -f ../../../include/uapi/linux/bpf_common.h && ( \ + (diff -B ../../include/uapi/linux/bpf_common.h ../../../include/uapi/linux/bpf_common.h >/dev/null) || \ + echo "Warning: tools/include/uapi/linux/bpf_common.h differs from kernel" >&2 )) || true $(Q)$(MAKE) $(build)=libbpf $(OUTPUT)libbpf.so: $(BPF_IN)
tools/perf/MANIFEST +2 -3
@@ -23,7 +23,6 @@ tools/build tools/arch/x86/include/asm/atomic.h tools/arch/x86/include/asm/rmwcc.h tools/lib/traceevent -tools/lib/bpf tools/lib/api tools/lib/bpf tools/lib/subcmd
@@ -60,6 +59,8 @@ tools/include/linux/hash.h tools/include/linux/kernel.h tools/include/linux/list.h tools/include/linux/log2.h +tools/include/uapi/linux/bpf.h +tools/include/uapi/linux/bpf_common.h tools/include/uapi/linux/perf_event.h tools/include/linux/poison.h tools/include/linux/rbtree.h
@@ -82,8 +83,6 @@ arch/*/include/uapi/asm/unistd*.h arch/*/include/uapi/asm/perf_regs.h include/linux/poison.h include/linux/hw_breakpoint.h -include/uapi/linux/bpf.h -include/uapi/linux/bpf_common.h include/uapi/linux/const.h include/uapi/linux/swab.h include/uapi/linux/hw_breakpoint.h
tools/perf/config/Makefile +3 -2
@@ -115,7 +115,7 @@ endif FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS) FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf -FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/arch/$(ARCH)/include/uapi -I$(srctree)/include/uapi +FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(ARCH)/include/uapi -I$(srctree)/tools/include/uapi # include ARCH specific config -include $(src-perf)/arch/$(ARCH)/Makefile
@@ -210,7 +210,8 @@ CFLAGS += -I$(srctree)/tools/include/uapi CFLAGS += -I$(srctree)/tools/include/ CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi CFLAGS += -I$(srctree)/arch/$(ARCH)/include -CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/include +CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/uapi +CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/ CFLAGS += -I$(srctree)/include/uapi CFLAGS += -I$(srctree)/include
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 38/66 tools: Copy uapi/asm/perf_regs.h from the kernel
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To allow the build to complete on older systems, where those files are either not uptodate, lacking some recent additions or not present at all.
And check if the copy drifts from the kernel.
--- tools/arch/arm/include/uapi/asm/perf_regs.h | 23 ++++++++++++ tools/arch/arm64/include/uapi/asm/perf_regs.h | 40 ++++++++++++++++++++ tools/arch/powerpc/include/uapi/asm/perf_regs.h | 50 +++++++++++++++++++++++++ tools/arch/x86/include/uapi/asm/perf_regs.h | 33 ++++++++++++++++ tools/perf/MANIFEST | 2 +- tools/perf/Makefile.perf | 12 ++++++ tools/perf/config/Makefile | 3 +- 7 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 tools/arch/arm/include/uapi/asm/perf_regs.h create mode 100644 tools/arch/arm64/include/uapi/asm/perf_regs.h create mode 100644 tools/arch/powerpc/include/uapi/asm/perf_regs.h create mode 100644 tools/arch/x86/include/uapi/asm/perf_regs.h
tools/arch/arm/include/uapi/asm/perf_regs.h new file +23 -0
@@ -0,0 +1,23 @@ +#ifndef _ASM_ARM_PERF_REGS_H +#define _ASM_ARM_PERF_REGS_H + +enum perf_event_arm_regs { +PERF_REG_ARM_R0 , +PERF_REG_ARM_R1 , +PERF_REG_ARM_R2 , +PERF_REG_ARM_R3 , +PERF_REG_ARM_R4 , +PERF_REG_ARM_R5 , +PERF_REG_ARM_R6 , +PERF_REG_ARM_R7 , +PERF_REG_ARM_R8 , +PERF_REG_ARM_R9 , +PERF_REG_ARM_R10 , +PERF_REG_ARM_FP , +PERF_REG_ARM_IP , +PERF_REG_ARM_SP , +PERF_REG_ARM_LR , +PERF_REG_ARM_PC , +PERF_REG_ARM_MAX , +}; +#endif /* _ASM_ARM_PERF_REGS_H */
tools/arch/arm64/include/uapi/asm/perf_regs.h new file +40 -0
@@ -0,0 +1,40 @@ +#ifndef _ASM_ARM64_PERF_REGS_H +#define _ASM_ARM64_PERF_REGS_H + +enum perf_event_arm_regs { +PERF_REG_ARM64_X0 , +PERF_REG_ARM64_X1 , +PERF_REG_ARM64_X2 , +PERF_REG_ARM64_X3 , +PERF_REG_ARM64_X4 , +PERF_REG_ARM64_X5 , +PERF_REG_ARM64_X6 , +PERF_REG_ARM64_X7 , +PERF_REG_ARM64_X8 , +PERF_REG_ARM64_X9 , +PERF_REG_ARM64_X10 , +PERF_REG_ARM64_X11 , +PERF_REG_ARM64_X12 , +PERF_REG_ARM64_X13 , +PERF_REG_ARM64_X14 , +PERF_REG_ARM64_X15 , +PERF_REG_ARM64_X16 , +PERF_REG_ARM64_X17 , +PERF_REG_ARM64_X18 , +PERF_REG_ARM64_X19 , +PERF_REG_ARM64_X20 , +PERF_REG_ARM64_X21 , +PERF_REG_ARM64_X22 , +PERF_REG_ARM64_X23 , +PERF_REG_ARM64_X24 , +PERF_REG_ARM64_X25 , +PERF_REG_ARM64_X26 , +PERF_REG_ARM64_X27 , +PERF_REG_ARM64_X28 , +PERF_REG_ARM64_X29 , +PERF_REG_ARM64_LR , +PERF_REG_ARM64_SP , +PERF_REG_ARM64_PC , +PERF_REG_ARM64_MAX , +}; +#endif /* _ASM_ARM64_PERF_REGS_H */
tools/arch/powerpc/include/uapi/asm/perf_regs.h new file +50 -0
50 lines not on this page · raw message
tools/arch/x86/include/uapi/asm/perf_regs.h new file +33 -0
@@ -0,0 +1,33 @@ +#ifndef _ASM_X86_PERF_REGS_H +#define _ASM_X86_PERF_REGS_H + +enum perf_event_x86_regs { +PERF_REG_X86_AX , +PERF_REG_X86_BX , +PERF_REG_X86_CX , +PERF_REG_X86_DX , +PERF_REG_X86_SI , +PERF_REG_X86_DI , +PERF_REG_X86_BP , +PERF_REG_X86_SP , +PERF_REG_X86_IP , +PERF_REG_X86_FLAGS , +PERF_REG_X86_CS , +PERF_REG_X86_SS , +PERF_REG_X86_DS , +PERF_REG_X86_ES , +PERF_REG_X86_FS , +PERF_REG_X86_GS , +PERF_REG_X86_R8 , +PERF_REG_X86_R9 , +PERF_REG_X86_R10 , +PERF_REG_X86_R11 , +PERF_REG_X86_R12 , +PERF_REG_X86_R13 , +PERF_REG_X86_R14 , +PERF_REG_X86_R15 , + +PERF_REG_X86_32_MAX =PERF_REG_X86_GS +1 , +PERF_REG_X86_64_MAX =PERF_REG_X86_R15 +1 , +}; +#endif /* _ASM_X86_PERF_REGS_H */
tools/perf/MANIFEST +1 -1
@@ -80,7 +80,7 @@ include/linux/stringify.h include/linux/swab.h arch/*/include/asm/unistd*.h arch/*/include/uapi/asm/unistd*.h -arch/*/include/uapi/asm/perf_regs.h +tools/arch/*/include/uapi/asm/perf_regs.h include/linux/poison.h include/linux/hw_breakpoint.h include/uapi/linux/const.h
tools/perf/Makefile.perf +12 -0
@@ -363,6 +363,18 @@ $(PERF_IN): prepare FORCE @(test -f ../../arch/x86/lib/memset_64.S && ( \ (diff -B ../arch/x86/lib/memset_64.S ../../arch/x86/lib/memset_64.S >/dev/null) \ || echo "Warning: tools/arch/x86/lib/memset_64.S differs from kernel" >&2 )) || true + @(test -f ../../arch/arm/include/uapi/asm/perf_regs.h && ( \ + (diff -B ../arch/arm/include/uapi/asm/perf_regs.h ../../arch/arm/include/uapi/asm/perf_regs.h >/dev/null) \ + || echo "Warning: tools/arch/arm/include/uapi/asm/perf_regs.h differs from kernel" >&2 )) || true + @(test -f ../../arch/arm64/include/uapi/asm/perf_regs.h && ( \ + (diff -B ../arch/arm64/include/uapi/asm/perf_regs.h ../../arch/arm64/include/uapi/asm/perf_regs.h >/dev/null) \ + || echo "Warning: tools/arch/arm64/include/uapi/asm/perf_regs.h differs from kernel" >&2 )) || true + @(test -f ../../arch/powerpc/include/uapi/asm/perf_regs.h && ( \ + (diff -B ../arch/powerpc/include/uapi/asm/perf_regs.h ../../arch/powerpc/include/uapi/asm/perf_regs.h >/dev/null) \ + || echo "Warning: tools/arch/powerpc/include/uapi/asm/perf_regs.h differs from kernel" >&2 )) || true + @(test -f ../../arch/x86/include/uapi/asm/perf_regs.h && ( \ + (diff -B ../arch/x86/include/uapi/asm/perf_regs.h ../../arch/x86/include/uapi/asm/perf_regs.h >/dev/null) \ + || echo "Warning: tools/arch/x86/include/uapi/asm/perf_regs.h differs from kernel" >&2 )) || true $(Q)$(MAKE) $(build)=perf $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
tools/perf/config/Makefile +2 -1
@@ -208,9 +208,10 @@ CFLAGS += -I$(src-perf)/util/include CFLAGS += -I$(src-perf)/arch/$(ARCH)/include CFLAGS += -I$(srctree)/tools/include/uapi CFLAGS += -I$(srctree)/tools/include/ +CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/uapi +CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/ CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi CFLAGS += -I$(srctree)/arch/$(ARCH)/include -CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/uapi CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/ CFLAGS += -I$(srctree)/include/uapi CFLAGS += -I$(srctree)/include
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 39/66 perf test bpf: Use epoll_wait() instead of epoll_pwait()
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
The prototype for epoll_wait() is available in older distros, so use it instead of epoll_pwait() (removing the last NULL arg, the sigmask, makes it the same thing anyway) to avoid breaking the build.
--- tools/perf/tests/bpf-script-example.c | 4 ++-- tools/perf/tests/bpf.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
tools/perf/tests/bpf-script-example.c +2 -2
@@ -31,8 +31,8 @@ struct bpf_map_def SEC("maps") flip_table = { .max_entries = 1, }; -SEC("func=sys_epoll_pwait") -int bpf_func__sys_epoll_pwait (void *ctx) +SEC("func=sys_epoll_wait") +int bpf_func__sys_epoll_wait (void *ctx) {int ind =0 ;int *flag =bpf_map_lookup_elem (&flip_table, &ind);
tools/perf/tests/bpf.c +3 -3
@@ -13,13 +13,13 @@#ifdef HAVE_LIBBPF_SUPPORT -static int epoll_pwait_loop (void ) +static int epoll_wait_loop (void ) {int i;/* Should fail NR_ITERS times */ for (i =0 ; i <NR_ITERS ; i++) -epoll_pwait (-(i +1 ),NULL ,0 ,0 ,NULL ); +epoll_wait (-(i +1 ),NULL ,0 ,0 );return 0 ; }
@@ -61,7 +61,7 @@ static struct {"[basic_bpf_test]" ,"fix 'perf test LLVM' first" ,"load bpf object failed" , - &epoll_pwait_loop, + &epoll_wait_loop, (NR_ITERS +1 ) /2 , }, #ifdef HAVE_BPF_PROLOGUE
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 40/66 tools: Copy uapi/linux/hw_breakpoint.h from the kernel
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To allow the build to complete on older systems, where those files are either not uptodate, lacking some recent additions or not present at all.
And check if the copy drifts from the kernel.
--- tools/include/uapi/linux/hw_breakpoint.h | 30 ++++++++++++++++++++++++++++++ tools/perf/MANIFEST | 3 +-- tools/perf/Makefile.perf | 3 +++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tools/include/uapi/linux/hw_breakpoint.h
tools/include/uapi/linux/hw_breakpoint.h new file +30 -0
@@ -0,0 +1,30 @@ +#ifndef _UAPI_LINUX_HW_BREAKPOINT_H +#define _UAPI_LINUX_HW_BREAKPOINT_H + +enum { +HW_BREAKPOINT_LEN_1 =1 , +HW_BREAKPOINT_LEN_2 =2 , +HW_BREAKPOINT_LEN_4 =4 , +HW_BREAKPOINT_LEN_8 =8 , +}; + +enum { +HW_BREAKPOINT_EMPTY =0 , +HW_BREAKPOINT_R =1 , +HW_BREAKPOINT_W =2 , +HW_BREAKPOINT_RW =HW_BREAKPOINT_R |HW_BREAKPOINT_W , +HW_BREAKPOINT_X =4 , +HW_BREAKPOINT_INVALID =HW_BREAKPOINT_RW |HW_BREAKPOINT_X , +}; + +enum bp_type_idx { +TYPE_INST =0 , +#ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS +TYPE_DATA =0 , +#else +TYPE_DATA =1 , +#endif +TYPE_MAX +}; + +#endif /* _UAPI_LINUX_HW_BREAKPOINT_H */
tools/perf/MANIFEST +1 -2
@@ -61,6 +61,7 @@ tools/include/linux/list.h tools/include/linux/log2.h tools/include/uapi/linux/bpf.h tools/include/uapi/linux/bpf_common.h +tools/include/uapi/linux/hw_breakpoint.h tools/include/uapi/linux/perf_event.h tools/include/linux/poison.h tools/include/linux/rbtree.h
@@ -82,10 +83,8 @@ arch/*/include/asm/unistd*.h arch/*/include/uapi/asm/unistd*.h tools/arch/*/include/uapi/asm/perf_regs.h include/linux/poison.h -include/linux/hw_breakpoint.h include/uapi/linux/const.h include/uapi/linux/swab.h -include/uapi/linux/hw_breakpoint.h arch/x86/include/asm/svm.h arch/x86/include/asm/vmx.h arch/x86/include/asm/kvm_host.h
tools/perf/Makefile.perf +3 -0
@@ -348,6 +348,9 @@ $(PERF_IN): prepare FORCE @(test -f ../../include/uapi/linux/perf_event.h && ( \ (diff -B ../include/uapi/linux/perf_event.h ../../include/uapi/linux/perf_event.h >/dev/null) \ || echo "Warning: tools/include/uapi/linux/perf_event.h differs from kernel" >&2 )) || true + @(test -f ../../include/uapi/linux/hw_breakpoint.h && ( \ + (diff -B ../include/uapi/linux/hw_breakpoint.h ../../include/uapi/linux/hw_breakpoint.h >/dev/null) \ + || echo "Warning: tools/include/uapi/linux/hw_breakpoint.h differs from kernel" >&2 )) || true @(test -f ../../arch/x86/include/asm/disabled-features.h && ( \ (diff -B ../arch/x86/include/asm/disabled-features.h ../../arch/x86/include/asm/disabled-features.h >/dev/null) \ || echo "Warning: tools/arch/x86/include/asm/disabled-features.h differs from kernel" >&2 )) || true
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 41/66 perf tools: Introduce weak alternative to sched_getcpu()
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Which is just a wrapper for sys_getcpu and is not present in at least musl libc.
--- tools/arch/x86/include/asm/unistd_32.h | 3 +++ tools/arch/x86/include/asm/unistd_64.h | 3 +++ tools/perf/util/cloexec.c | 14 ++++++++++---- tools/perf/util/util.h | 4 ++++ 4 files changed, 20 insertions(+), 4 deletions(-)
tools/arch/x86/include/asm/unistd_32.h +3 -0
@@ -7,3 +7,6 @@#ifndef __NR_gettid# define __NR_gettid 224#endif +#ifndef __NR_getcpu +# define __NR_getcpu 318 +#endif
tools/arch/x86/include/asm/unistd_64.h +3 -0
@@ -7,3 +7,6 @@#ifndef __NR_gettid# define __NR_gettid 186#endif +#ifndef __NR_getcpu +# define __NR_getcpu 309 +#endif
tools/perf/util/cloexec.c +10 -4
@@ -4,18 +4,24 @@#include "cloexec.h" #include "asm/bug.h" #include "debug.h" +#include <unistd.h> +#include <asm/unistd.h> +#include <sys/syscall.h> static unsigned long flag =PERF_FLAG_FD_CLOEXEC ; -#ifdef __GLIBC_PREREQ -#if !__GLIBC_PREREQ (2 ,6 )int __weak sched_getcpu (void ) { +#ifdef __NR_getcpu +unsigned cpu; +int err =syscall (__NR_getcpu, &cpu,NULL ,NULL ); +if (!err) +return cpu; +#else errno =ENOSYS ; +#endif return -1 ; } -#endif -#endif static int perf_flag_probe (void ) {
tools/perf/util/util.h +4 -0
@@ -361,4 +361,8 @@ void print_binary(unsigned char *data, size_t len, size_t bytes_per_line, print_binary_t printer, void *extra); +#ifndef __GLIBC__ +extern int sched_getcpu (void ); +#endif +#endif /* GIT_COMPAT_UTIL_H */
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 42/66 perf tools: Remove unneeded magic.h include from util.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Not used anymore, IIRC it was for useless PROC_FS_MAGIC procfs checks, but those are long gone.
--- tools/perf/util/util.h | 1 - 1 file changed, 1 deletion(-)
tools/perf/util/util.h +0 -1
@@ -72,7 +72,6 @@#include <sys/ioctl.h> #include <inttypes.h> #include <linux/kernel.h> -#include <linux/magic.h> #include <linux/types.h> #include <sys/ttydefaults.h> #include <api/fs/tracing_path.h>
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 43/66 perf trace: Remove unused sys/ptrace.h include
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/builtin-trace.c | 1 - 1 file changed, 1 deletion(-)
tools/perf/builtin-trace.c +0 -1
@@ -43,7 +43,6 @@#include <linux/err.h> #include <linux/filter.h> #include <linux/audit.h> -#include <sys/ptrace.h> #include <linux/random.h> #include <linux/stringify.h>
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 44/66 kvm arm/arm64: Remove trailing whitespace from headers
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Noticed while making a copy of these files to tools/ where those kernel files were being directly accessed, which we're not allowing anymore to avoid that changes in the kernel side break tooling.
--- arch/arm/include/uapi/asm/kvm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/uapi/asm/kvm.h +2 -2
@@ -139,8 +139,8 @@ struct kvm_arch_memory_slot {#define ARM_CP15_REG64 (...) __ARM_CP15_REG64(__VA_ARGS__)#define KVM_REG_ARM_TIMER_CTL ARM_CP15_REG32(0, 14, 3, 1) -#define KVM_REG_ARM_TIMER_CNT ARM_CP15_REG64(1, 14) -#define KVM_REG_ARM_TIMER_CVAL ARM_CP15_REG64(3, 14) +#define KVM_REG_ARM_TIMER_CNT ARM_CP15_REG64(1, 14) +#define KVM_REG_ARM_TIMER_CVAL ARM_CP15_REG64(3, 14)/* Normal registers are mapped as coprocessor 16. */ #define KVM_REG_ARM_CORE (0x0010 << KVM_REG_ARM_COPROC_SHIFT)
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 45/66 tools: Copy the header files needed by perf tools
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Those kernel files were being directly accessed, which we're not allowing anymore to avoid that changes in the kernel side break tooling.
Warn if these copies drift from the original files.
--- tools/arch/arm/include/uapi/asm/kvm.h | 224 ++++++++++ tools/arch/arm64/include/uapi/asm/kvm.h | 258 ++++++++++++ tools/arch/mips/include/uapi/asm/kvm.h | 208 ++++++++++ tools/arch/powerpc/include/uapi/asm/kvm.h | 612 ++++++++++++++++++++++++++++ tools/arch/s390/include/uapi/asm/kvm.h | 192 +++++++++ tools/arch/s390/include/uapi/asm/kvm_perf.h | 25 ++ tools/arch/s390/include/uapi/asm/sie.h | 250 ++++++++++++ tools/arch/x86/include/uapi/asm/kvm.h | 360 ++++++++++++++++ tools/arch/x86/include/uapi/asm/kvm_perf.h | 16 + tools/arch/x86/include/uapi/asm/svm.h | 178 ++++++++ tools/arch/x86/include/uapi/asm/vmx.h | 136 +++++++ tools/perf/MANIFEST | 15 +- tools/perf/Makefile.perf | 30 ++ 13 files changed, 2495 insertions(+), 9 deletions(-) create mode 100644 tools/arch/arm/include/uapi/asm/kvm.h create mode 100644 tools/arch/arm64/include/uapi/asm/kvm.h create mode 100644 tools/arch/mips/include/uapi/asm/kvm.h create mode 100644 tools/arch/powerpc/include/uapi/asm/kvm.h create mode 100644 tools/arch/s390/include/uapi/asm/kvm.h create mode 100644 tools/arch/s390/include/uapi/asm/kvm_perf.h create mode 100644 tools/arch/s390/include/uapi/asm/sie.h create mode 100644 tools/arch/x86/include/uapi/asm/kvm.h create mode 100644 tools/arch/x86/include/uapi/asm/kvm_perf.h create mode 100644 tools/arch/x86/include/uapi/asm/svm.h create mode 100644 tools/arch/x86/include/uapi/asm/vmx.h
tools/arch/arm/include/uapi/asm/kvm.h new file +224 -0
@@ -0,0 +1,224 @@ +/* +* Copyright (C) 2012 - Virtual Open Systems and Columbia University +* Author: Christoffer Dall <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License, version 2, as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef __ARM_KVM_H__ +#define __ARM_KVM_H__ + +#include <linux/types.h> +#include <linux/psci.h> +#include <asm/ptrace.h> + +#define __KVM_HAVE_GUEST_DEBUG +#define __KVM_HAVE_IRQ_LINE +#define __KVM_HAVE_READONLY_MEM + +#define KVM_REG_SIZE (id) \ + (1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT)) + +/* Valid for svc_regs, abt_regs, und_regs, irq_regs in struct kvm_regs */ +#define KVM_ARM_SVC_sp svc_regs[0] +#define KVM_ARM_SVC_lr svc_regs[1] +#define KVM_ARM_SVC_spsr svc_regs[2] +#define KVM_ARM_ABT_sp abt_regs[0] +#define KVM_ARM_ABT_lr abt_regs[1] +#define KVM_ARM_ABT_spsr abt_regs[2] +#define KVM_ARM_UND_sp und_regs[0] +#define KVM_ARM_UND_lr und_regs[1] +#define KVM_ARM_UND_spsr und_regs[2] +#define KVM_ARM_IRQ_sp irq_regs[0] +#define KVM_ARM_IRQ_lr irq_regs[1] +#define KVM_ARM_IRQ_spsr irq_regs[2] + +/* Valid only for fiq_regs in struct kvm_regs */ +#define KVM_ARM_FIQ_r8 fiq_regs[0] +#define KVM_ARM_FIQ_r9 fiq_regs[1] +#define KVM_ARM_FIQ_r10 fiq_regs[2] +#define KVM_ARM_FIQ_fp fiq_regs[3] +#define KVM_ARM_FIQ_ip fiq_regs[4] +#define KVM_ARM_FIQ_sp fiq_regs[5] +#define KVM_ARM_FIQ_lr fiq_regs[6] +#define KVM_ARM_FIQ_spsr fiq_regs[7] + +struct kvm_regs { +struct pt_regs usr_regs;/* R0_usr - R14_usr, PC, CPSR */ +unsigned long svc_regs[3 ];/* SP_svc, LR_svc, SPSR_svc */ +unsigned long abt_regs[3 ];/* SP_abt, LR_abt, SPSR_abt */ +unsigned long und_regs[3 ];/* SP_und, LR_und, SPSR_und */ +unsigned long irq_regs[3 ];/* SP_irq, LR_irq, SPSR_irq */ +unsigned long fiq_regs[8 ];/* R8_fiq - R14_fiq, SPSR_fiq */ +}; + +/* Supported Processor Types */ +#define KVM_ARM_TARGET_CORTEX_A15 0 +#define KVM_ARM_TARGET_CORTEX_A7 1 +#define KVM_ARM_NUM_TARGETS 2 + +/* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */ +#define KVM_ARM_DEVICE_TYPE_SHIFT 0 +#define KVM_ARM_DEVICE_TYPE_MASK (0xffff << KVM_ARM_DEVICE_TYPE_SHIFT) +#define KVM_ARM_DEVICE_ID_SHIFT 16 +#define KVM_ARM_DEVICE_ID_MASK (0xffff << KVM_ARM_DEVICE_ID_SHIFT) + +/* Supported device IDs */ +#define KVM_ARM_DEVICE_VGIC_V2 0 + +/* Supported VGIC address types */ +#define KVM_VGIC_V2_ADDR_TYPE_DIST 0 +#define KVM_VGIC_V2_ADDR_TYPE_CPU 1 + +#define KVM_VGIC_V2_DIST_SIZE 0x1000 +#define KVM_VGIC_V2_CPU_SIZE 0x2000 + +#define KVM_ARM_VCPU_POWER_OFF 0/* CPU is started in OFF state */ +#define KVM_ARM_VCPU_PSCI_0_2 1/* CPU uses PSCI v0.2 */ + +struct kvm_vcpu_init { +__u32 target; +__u32 features[7 ]; +}; + +struct kvm_sregs { +}; + +struct kvm_fpu { +}; + +struct kvm_guest_debug_arch { +}; + +struct kvm_debug_exit_arch { +}; + +struct kvm_sync_regs { +}; + +struct kvm_arch_memory_slot { +}; + +/* If you need to interpret the index values, here is the key: */ +#define KVM_REG_ARM_COPROC_MASK 0x000000000FFF0000 +#define KVM_REG_ARM_COPROC_SHIFT 16 +#define KVM_REG_ARM_32_OPC2_MASK 0x0000000000000007 +#define KVM_REG_ARM_32_OPC2_SHIFT 0 +#define KVM_REG_ARM_OPC1_MASK 0x0000000000000078 +#define KVM_REG_ARM_OPC1_SHIFT 3 +#define KVM_REG_ARM_CRM_MASK 0x0000000000000780 +#define KVM_REG_ARM_CRM_SHIFT 7 +#define KVM_REG_ARM_32_CRN_MASK 0x0000000000007800 +#define KVM_REG_ARM_32_CRN_SHIFT 11 + +#define ARM_CP15_REG_SHIFT_MASK (x,n) \ + (((x) << KVM_REG_ARM_ ## n ## _SHIFT) & KVM_REG_ARM_ ## n ## _MASK) + +#define __ARM_CP15_REG (op1,crn,crm,op2) \ + (KVM_REG_ARM | (15 << KVM_REG_ARM_COPROC_SHIFT) | \ + ARM_CP15_REG_SHIFT_MASK(op1, OPC1) | \ + ARM_CP15_REG_SHIFT_MASK(crn, 32_CRN) | \ + ARM_CP15_REG_SHIFT_MASK(crm, CRM) | \ + ARM_CP15_REG_SHIFT_MASK(op2, 32_OPC2)) + +#define ARM_CP15_REG32 (...) (__ARM_CP15_REG(__VA_ARGS__) | KVM_REG_SIZE_U32) + +#define __ARM_CP15_REG64 (op1,crm) \ + (__ARM_CP15_REG(op1, 0, crm, 0) | KVM_REG_SIZE_U64) +#define ARM_CP15_REG64 (...) __ARM_CP15_REG64(__VA_ARGS__) + +#define KVM_REG_ARM_TIMER_CTL ARM_CP15_REG32(0, 14, 3, 1) +#define KVM_REG_ARM_TIMER_CNT ARM_CP15_REG64(1, 14) +#define KVM_REG_ARM_TIMER_CVAL ARM_CP15_REG64(3, 14) + +/* Normal registers are mapped as coprocessor 16. */ +#define KVM_REG_ARM_CORE (0x0010 << KVM_REG_ARM_COPROC_SHIFT) +#define KVM_REG_ARM_CORE_REG (name) (offsetof(struct kvm_regs, name) / 4) + +/* Some registers need more space to represent values. */ +#define KVM_REG_ARM_DEMUX (0x0011 << KVM_REG_ARM_COPROC_SHIFT) +#define KVM_REG_ARM_DEMUX_ID_MASK 0x000000000000FF00 +#define KVM_REG_ARM_DEMUX_ID_SHIFT 8 +#define KVM_REG_ARM_DEMUX_ID_CCSIDR (0x00 << KVM_REG_ARM_DEMUX_ID_SHIFT) +#define KVM_REG_ARM_DEMUX_VAL_MASK 0x00000000000000FF +#define KVM_REG_ARM_DEMUX_VAL_SHIFT 0 + +/* VFP registers: we could overload CP10 like ARM does, but that's ugly. */ +#define KVM_REG_ARM_VFP (0x0012 << KVM_REG_ARM_COPROC_SHIFT) +#define KVM_REG_ARM_VFP_MASK 0x000000000000FFFF +#define KVM_REG_ARM_VFP_BASE_REG 0x0 +#define KVM_REG_ARM_VFP_FPSID 0x1000 +#define KVM_REG_ARM_VFP_FPSCR 0x1001 +#define KVM_REG_ARM_VFP_MVFR1 0x1006 +#define KVM_REG_ARM_VFP_MVFR0 0x1007 +#define KVM_REG_ARM_VFP_FPEXC 0x1008 +#define KVM_REG_ARM_VFP_FPINST 0x1009 +#define KVM_REG_ARM_VFP_FPINST2 0x100A + +/* Device Control API: ARM VGIC */ +#define KVM_DEV_ARM_VGIC_GRP_ADDR 0 +#define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1 +#define KVM_DEV_ARM_VGIC_GRP_CPU_REGS 2 +#define KVM_DEV_ARM_VGIC_CPUID_SHIFT 32 +#define KVM_DEV_ARM_VGIC_CPUID_MASK (0xffULL << KVM_DEV_ARM_VGIC_CPUID_SHIFT) +#define KVM_DEV_ARM_VGIC_OFFSET_SHIFT 0 +#define KVM_DEV_ARM_VGIC_OFFSET_MASK (0xffffffffULL << KVM_DEV_ARM_VGIC_OFFSET_SHIFT) +#define KVM_DEV_ARM_VGIC_GRP_NR_IRQS 3 +#define KVM_DEV_ARM_VGIC_GRP_CTRL 4 +#define KVM_DEV_ARM_VGIC_CTRL_INIT 0 + +/* KVM_IRQ_LINE irq field index values */ +#define KVM_ARM_IRQ_TYPE_SHIFT 24 +#define KVM_ARM_IRQ_TYPE_MASK 0xff +#define KVM_ARM_IRQ_VCPU_SHIFT 16 +#define KVM_ARM_IRQ_VCPU_MASK 0xff +#define KVM_ARM_IRQ_NUM_SHIFT 0 +#define KVM_ARM_IRQ_NUM_MASK 0xffff + +/* irq_type field */ +#define KVM_ARM_IRQ_TYPE_CPU 0 +#define KVM_ARM_IRQ_TYPE_SPI 1 +#define KVM_ARM_IRQ_TYPE_PPI 2 + +/* out-of-kernel GIC cpu interrupt injection irq_number field */ +#define KVM_ARM_IRQ_CPU_IRQ 0 +#define KVM_ARM_IRQ_CPU_FIQ 1 + +/* +* This used to hold the highest supported SPI, but it is now obsolete +* and only here to provide source code level compatibility with older +* userland. The highest SPI number can be set via KVM_DEV_ARM_VGIC_GRP_NR_IRQS. +*/ +#ifndef __KERNEL__ +#define KVM_ARM_IRQ_GIC_MAX 127 +#endif + +/* One single KVM irqchip, ie. the VGIC */ +#define KVM_NR_IRQCHIPS 1 + +/* PSCI interface */ +#define KVM_PSCI_FN_BASE 0x95c1ba5e +#define KVM_PSCI_FN (n) (KVM_PSCI_FN_BASE + (n)) + +#define KVM_PSCI_FN_CPU_SUSPEND KVM_PSCI_FN(0) +#define KVM_PSCI_FN_CPU_OFF KVM_PSCI_FN(1) +#define KVM_PSCI_FN_CPU_ON KVM_PSCI_FN(2) +#define KVM_PSCI_FN_MIGRATE KVM_PSCI_FN(3) + +#define KVM_PSCI_RET_SUCCESS PSCI_RET_SUCCESS +#define KVM_PSCI_RET_NI PSCI_RET_NOT_SUPPORTED +#define KVM_PSCI_RET_INVAL PSCI_RET_INVALID_PARAMS +#define KVM_PSCI_RET_DENIED PSCI_RET_DENIED + +#endif /* __ARM_KVM_H__ */
tools/arch/arm64/include/uapi/asm/kvm.h new file +258 -0
258 lines not on this page · raw message
tools/arch/mips/include/uapi/asm/kvm.h new file +208 -0
208 lines not on this page · raw message
tools/arch/powerpc/include/uapi/asm/kvm.h new file +612 -0
612 lines not on this page · raw message
tools/arch/s390/include/uapi/asm/kvm.h new file +192 -0
192 lines not on this page · raw message
tools/arch/s390/include/uapi/asm/kvm_perf.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Definitions for perf-kvm on s390 +* +* Copyright 2014 IBM Corp. +* Author(s): Alexander Yarygin <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License (version 2 only) +* as published by the Free Software Foundation. +*/ + +#ifndef __LINUX_KVM_PERF_S390_H +#define __LINUX_KVM_PERF_S390_H + +#include <asm/sie.h> + +#define DECODE_STR_LEN 40 + +#define VCPU_ID "id" + +#define KVM_ENTRY_TRACE "kvm:kvm_s390_sie_enter" +#define KVM_EXIT_TRACE "kvm:kvm_s390_sie_exit" +#define KVM_EXIT_REASON "icptcode" + +#endif
tools/arch/s390/include/uapi/asm/sie.h new file +250 -0
250 lines not on this page · raw message
tools/arch/x86/include/uapi/asm/kvm.h new file +360 -0
360 lines not on this page · raw message
tools/arch/x86/include/uapi/asm/kvm_perf.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef _ASM_X86_KVM_PERF_H +#define _ASM_X86_KVM_PERF_H + +#include <asm/svm.h> +#include <asm/vmx.h> +#include <asm/kvm.h> + +#define DECODE_STR_LEN 20 + +#define VCPU_ID "vcpu_id" + +#define KVM_ENTRY_TRACE "kvm:kvm_entry" +#define KVM_EXIT_TRACE "kvm:kvm_exit" +#define KVM_EXIT_REASON "exit_reason" + +#endif /* _ASM_X86_KVM_PERF_H */
tools/arch/x86/include/uapi/asm/svm.h new file +178 -0
178 lines not on this page · raw message
tools/arch/x86/include/uapi/asm/vmx.h new file +136 -0
136 lines not on this page · raw message
tools/perf/MANIFEST +6 -9
@@ -15,8 +15,14 @@ tools/arch/x86/include/asm/barrier.h tools/arch/x86/include/asm/cpufeatures.h tools/arch/x86/include/asm/disabled-features.h tools/arch/x86/include/asm/required-features.h +tools/arch/x86/include/uapi/asm/svm.h +tools/arch/x86/include/uapi/asm/vmx.h +tools/arch/x86/include/uapi/asm/kvm.h +tools/arch/x86/include/uapi/asm/kvm_perf.h tools/arch/x86/lib/memcpy_64.S tools/arch/x86/lib/memset_64.S +tools/arch/s390/include/uapi/asm/kvm_perf.h +tools/arch/s390/include/uapi/asm/sie.h tools/arch/xtensa/include/asm/barrier.h tools/scripts tools/build
@@ -85,12 +91,3 @@ tools/arch/*/include/uapi/asm/perf_regs.h include/linux/poison.h include/uapi/linux/const.h include/uapi/linux/swab.h -arch/x86/include/asm/svm.h -arch/x86/include/asm/vmx.h -arch/x86/include/asm/kvm_host.h -arch/x86/include/uapi/asm/svm.h -arch/x86/include/uapi/asm/vmx.h -arch/x86/include/uapi/asm/kvm.h -arch/x86/include/uapi/asm/kvm_perf.h -arch/s390/include/uapi/asm/sie.h -arch/s390/include/uapi/asm/kvm_perf.h
tools/perf/Makefile.perf +30 -0
@@ -378,6 +378,36 @@ $(PERF_IN): prepare FORCE @(test -f ../../arch/x86/include/uapi/asm/perf_regs.h && ( \ (diff -B ../arch/x86/include/uapi/asm/perf_regs.h ../../arch/x86/include/uapi/asm/perf_regs.h >/dev/null) \ || echo "Warning: tools/arch/x86/include/uapi/asm/perf_regs.h differs from kernel" >&2 )) || true + @(test -f ../../arch/x86/include/uapi/asm/kvm.h && ( \ + (diff -B ../arch/x86/include/uapi/asm/kvm.h ../../arch/x86/include/uapi/asm/kvm.h >/dev/null) \ + || echo "Warning: tools/arch/x86/include/uapi/asm/kvm.h differs from kernel" >&2 )) || true + @(test -f ../../arch/x86/include/uapi/asm/kvm_perf.h && ( \ + (diff -B ../arch/x86/include/uapi/asm/kvm_perf.h ../../arch/x86/include/uapi/asm/kvm_perf.h >/dev/null) \ + || echo "Warning: tools/arch/x86/include/uapi/asm/kvm_perf.h differs from kernel" >&2 )) || true + @(test -f ../../arch/x86/include/uapi/asm/svm.h && ( \ + (diff -B ../arch/x86/include/uapi/asm/svm.h ../../arch/x86/include/uapi/asm/svm.h >/dev/null) \ + || echo "Warning: tools/arch/x86/include/uapi/asm/svm.h differs from kernel" >&2 )) || true + @(test -f ../../arch/x86/include/uapi/asm/vmx.h && ( \ + (diff -B ../arch/x86/include/uapi/asm/vmx.h ../../arch/x86/include/uapi/asm/vmx.h >/dev/null) \ + || echo "Warning: tools/arch/x86/include/uapi/asm/vmx.h differs from kernel" >&2 )) || true + @(test -f ../../arch/powerpc/include/uapi/asm/kvm.h && ( \ + (diff -B ../arch/powerpc/include/uapi/asm/kvm.h ../../arch/powerpc/include/uapi/asm/kvm.h >/dev/null) \ + || echo "Warning: tools/arch/powerpc/include/uapi/asm/kvm.h differs from kernel" >&2 )) || true + @(test -f ../../arch/s390/include/uapi/asm/kvm.h && ( \ + (diff -B ../arch/s390/include/uapi/asm/kvm.h ../../arch/s390/include/uapi/asm/kvm.h >/dev/null) \ + || echo "Warning: tools/arch/s390/include/uapi/asm/kvm.h differs from kernel" >&2 )) || true + @(test -f ../../arch/s390/include/uapi/asm/kvm_perf.h && ( \ + (diff -B ../arch/s390/include/uapi/asm/kvm_perf.h ../../arch/s390/include/uapi/asm/kvm_perf.h >/dev/null) \ + || echo "Warning: tools/arch/s390/include/uapi/asm/kvm_perf.h differs from kernel" >&2 )) || true + @(test -f ../../arch/s390/include/uapi/asm/sie.h && ( \ + (diff -B ../arch/s390/include/uapi/asm/sie.h ../../arch/s390/include/uapi/asm/sie.h >/dev/null) \ + || echo "Warning: tools/arch/s390/include/uapi/asm/sie.h differs from kernel" >&2 )) || true + @(test -f ../../arch/arm/include/uapi/asm/kvm.h && ( \ + (diff -B ../arch/arm/include/uapi/asm/kvm.h ../../arch/arm/include/uapi/asm/kvm.h >/dev/null) \ + || echo "Warning: tools/arch/arm/include/uapi/asm/kvm.h differs from kernel" >&2 )) || true + @(test -f ../../arch/arm64/include/uapi/asm/kvm.h && ( \ + (diff -B ../arch/arm64/include/uapi/asm/kvm.h ../../arch/arm64/include/uapi/asm/kvm.h >/dev/null) \ + || echo "Warning: tools/arch/arm64/include/uapi/asm/kvm.h differs from kernel" >&2 )) || true $(Q)$(MAKE) $(build)=perf $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 46/66 perf tools: Fallback to reading sysfs to get cacheline size
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
On systems where sysconf(_SC_LEVEL1_DCACHE_LINESIZE) is not available, such as musl LIBC and Android's bionic libc.
--- tools/perf/perf.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
tools/perf/perf.c +11 -1
@@ -497,6 +497,16 @@ void pthread__unblock_sigwinch(void)pthread_sigmask (SIG_UNBLOCK , &set,NULL ); } +#ifdef _SC_LEVEL1_DCACHE_LINESIZE +#define cache_line_size (cacheline_sizep) *cacheline_sizep = sysconf(_SC_LEVEL1_DCACHE_LINESIZE) +#else +static void cache_line_size (int *cacheline_sizep) +{ +if (sysfs__read_int ("devices/system/cpu/cpu0/cache/index0/coherency_line_size" , cacheline_sizep)) +perror ("cannot determine cache line size" ); +} +#endif +int main (int argc,const char **argv) {const char *cmd;
@@ -509,7 +519,7 @@ int main(int argc, const char **argv)/* The page_size is placed in util object. */ page_size =sysconf (_SC_PAGE_SIZE); - cacheline_size =sysconf (_SC_LEVEL1_DCACHE_LINESIZE); +cache_line_size (&cacheline_size);if (sysctl__read_int ("kernel/perf_event_max_stack" , &value) ==0 ) sysctl_perf_event_max_stack = value;
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 47/66 perf trace beauty futex_op: Add missing defines for older systems
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/trace/beauty/futex_op.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/perf/trace/beauty/futex_op.c +16 -0
@@ -1,5 +1,21 @@#include <linux/futex.h> +#ifndef FUTEX_WAIT_BITSET +#define FUTEX_WAIT_BITSET 9 +#endif +#ifndef FUTEX_WAKE_BITSET +#define FUTEX_WAKE_BITSET 10 +#endif +#ifndef FUTEX_WAIT_REQUEUE_PI +#define FUTEX_WAIT_REQUEUE_PI 11 +#endif +#ifndef FUTEX_CMP_REQUEUE_PI +#define FUTEX_CMP_REQUEUE_PI 12 +#endif +#ifndef FUTEX_CLOCK_REALTIME +#define FUTEX_CLOCK_REALTIME 256 +#endif +static size_t syscall_arg__scnprintf_futex_op (char *bf,size_t size,struct syscall_arg *arg) { enum syscall_futex_args {
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 48/66 perf trace beauty seccomp: Remove seccomp.h include
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
All we need from it is already conditionally defined, and this header file is not present in older systems, so ditch it.
--- tools/perf/trace/beauty/seccomp.c | 2 -- 1 file changed, 2 deletions(-)
tools/perf/trace/beauty/seccomp.c +0 -2
@@ -1,5 +1,3 @@ -#include <linux/seccomp.h> -#ifndef SECCOMP_SET_MODE_STRICT #define SECCOMP_SET_MODE_STRICT 0#endif
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 49/66 perf symbols: Provide a GElf_Nhdr typedef
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
This one can be safely defined to be Elf64_Nhdr, as it is in elfutils's libelf, but not on musl libc, as both Elf64_Nhdr and Elf32_Nhdr have the same layout.
--- tools/perf/util/symbol-elf.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/symbol-elf.c +1 -0
@@ -16,6 +16,7 @@#define EM_AARCH64 183/* ARM 64 bit */ #endif +typedef Elf64_Nhdr GElf_Nhdr ;#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT extern char *cplus_demangle (const char *,int );
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 50/66 perf script python: Silence -Werror=maybe-uninitialized on gcc 5.3.0
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Sounds like a compiler bug, but to silence it, initialize those variables to NULL.
Noticed on:
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-5.3.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 5.3.0' --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-esp --enable-cloog-backend --enable-languages=c,c++,objc,java,fortran,ada --disable-libssp --disable-libmudflap --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-system-zlib
Thread model: posix
gcc version 5.3.0 (Alpine 5.3.0)
--- tools/perf/util/scripting-engines/trace-event-python.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/scripting-engines/trace-event-python.c +2 -2
@@ -273,7 +273,7 @@ static PyObject *get_field_numeric_entry(struct event_format *event, struct format_field *field, void *data) { bool is_array = field->flags & FIELD_IS_ARRAY; -PyObject *obj, *list =NULL ; +PyObject *obj =NULL , *list =NULL ;unsigned long long val;unsigned int item_size, n_items, i;
@@ -392,7 +392,7 @@ static void python_process_tracepoint(struct perf_sample *sample, struct addr_location *al) {struct event_format *event = evsel->tp_format; -PyObject *handler, *context, *t, *obj, *callchain; +PyObject *handler, *context, *t, *obj =NULL , *callchain;PyObject *dict =NULL ;static char handler_name[256 ];struct format_field *field;
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 51/66 tools: Copy the bitsperlong.h files from the kernel
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We use it in bitops/__ffs.h and bitops/atomic.h, that we also got from the kernel, but were getting it from either newer systems that carry it in /usr/include, or from the kernel sources, that we decided not to touch from tools/ code. Fix it.
--- tools/arch/alpha/include/uapi/asm/bitsperlong.h | 8 +++++++ tools/arch/arm64/include/uapi/asm/bitsperlong.h | 23 +++++++++++++++++++ tools/arch/frv/include/uapi/asm/bitsperlong.h | 1 + tools/arch/h8300/include/asm/bitsperlong.h | 14 ++++++++++++ tools/arch/hexagon/include/uapi/asm/bitsperlong.h | 26 ++++++++++++++++++++++ tools/arch/ia64/include/uapi/asm/bitsperlong.h | 8 +++++++ tools/arch/m32r/include/uapi/asm/bitsperlong.h | 1 + .../arch/microblaze/include/uapi/asm/bitsperlong.h | 1 + tools/arch/mips/include/uapi/asm/bitsperlong.h | 8 +++++++ tools/arch/mn10300/include/uapi/asm/bitsperlong.h | 1 + tools/arch/parisc/include/uapi/asm/bitsperlong.h | 14 ++++++++++++ tools/arch/powerpc/include/uapi/asm/bitsperlong.h | 12 ++++++++++ tools/arch/s390/include/uapi/asm/bitsperlong.h | 12 ++++++++++ tools/arch/score/include/uapi/asm/bitsperlong.h | 6 +++++ tools/arch/sparc/include/uapi/asm/bitsperlong.h | 12 ++++++++++ tools/arch/tile/include/uapi/asm/bitsperlong.h | 26 ++++++++++++++++++++++ tools/arch/x86/include/uapi/asm/bitsperlong.h | 12 ++++++++++ tools/include/asm-generic/bitops/__ffs.h | 1 + tools/include/asm-generic/bitops/atomic.h | 1 + tools/include/asm-generic/bitsperlong.h | 25 +++++++++++++++++++++ tools/include/uapi/asm-generic/bitsperlong.h | 15 +++++++++++++ 21 files changed, 227 insertions(+) create mode 100644 tools/arch/alpha/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/arm64/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/frv/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/h8300/include/asm/bitsperlong.h create mode 100644 tools/arch/hexagon/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/ia64/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/m32r/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/microblaze/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/mips/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/mn10300/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/parisc/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/powerpc/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/s390/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/score/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/sparc/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/tile/include/uapi/asm/bitsperlong.h create mode 100644 tools/arch/x86/include/uapi/asm/bitsperlong.h create mode 100644 tools/include/asm-generic/bitsperlong.h create mode 100644 tools/include/uapi/asm-generic/bitsperlong.h
tools/arch/alpha/include/uapi/asm/bitsperlong.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef __ASM_ALPHA_BITSPERLONG_H +#define __ASM_ALPHA_BITSPERLONG_H + +#define __BITS_PER_LONG 64 + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_ALPHA_BITSPERLONG_H */
tools/arch/arm64/include/uapi/asm/bitsperlong.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright (C) 2012 ARM Ltd. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef __ASM_BITSPERLONG_H +#define __ASM_BITSPERLONG_H + +#define __BITS_PER_LONG 64 + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_BITSPERLONG_H */
tools/arch/frv/include/uapi/asm/bitsperlong.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/bitsperlong.h>
tools/arch/h8300/include/asm/bitsperlong.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef __ASM_H8300_BITS_PER_LONG +#define __ASM_H8300_BITS_PER_LONG + +#include <asm-generic/bitsperlong.h> + +#if !defined(__ASSEMBLY__) +/* h8300-unknown-linux required long */ +#define __kernel_size_t __kernel_size_t +typedef unsigned long __kernel_size_t ; +typedef long __kernel_ssize_t ; +typedef long __kernel_ptrdiff_t ; +#endif + +#endif /* __ASM_H8300_BITS_PER_LONG */
tools/arch/hexagon/include/uapi/asm/bitsperlong.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef __ASM_HEXAGON_BITSPERLONG_H +#define __ASM_HEXAGON_BITSPERLONG_H + +#define __BITS_PER_LONG 32 + +#include <asm-generic/bitsperlong.h> + +#endif
tools/arch/ia64/include/uapi/asm/bitsperlong.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef __ASM_IA64_BITSPERLONG_H +#define __ASM_IA64_BITSPERLONG_H + +#define __BITS_PER_LONG 64 + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_IA64_BITSPERLONG_H */
tools/arch/m32r/include/uapi/asm/bitsperlong.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/bitsperlong.h>
tools/arch/microblaze/include/uapi/asm/bitsperlong.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/bitsperlong.h>
tools/arch/mips/include/uapi/asm/bitsperlong.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef __ASM_MIPS_BITSPERLONG_H +#define __ASM_MIPS_BITSPERLONG_H + +#define __BITS_PER_LONG _MIPS_SZLONG + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_MIPS_BITSPERLONG_H */
tools/arch/mn10300/include/uapi/asm/bitsperlong.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/bitsperlong.h>
tools/arch/parisc/include/uapi/asm/bitsperlong.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef __ASM_PARISC_BITSPERLONG_H +#define __ASM_PARISC_BITSPERLONG_H + +#if defined(__LP64__) +#define __BITS_PER_LONG 64 +#define SHIFT_PER_LONG 6 +#else +#define __BITS_PER_LONG 32 +#define SHIFT_PER_LONG 5 +#endif + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_PARISC_BITSPERLONG_H */
tools/arch/powerpc/include/uapi/asm/bitsperlong.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ASM_POWERPC_BITSPERLONG_H +#define __ASM_POWERPC_BITSPERLONG_H + +#if defined(__powerpc64__) +# define __BITS_PER_LONG 64 +#else +# define __BITS_PER_LONG 32 +#endif + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_POWERPC_BITSPERLONG_H */
tools/arch/s390/include/uapi/asm/bitsperlong.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ASM_S390_BITSPERLONG_H +#define __ASM_S390_BITSPERLONG_H + +#ifndef __s390x__ +#define __BITS_PER_LONG 32 +#else +#define __BITS_PER_LONG 64 +#endif + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_S390_BITSPERLONG_H */
tools/arch/score/include/uapi/asm/bitsperlong.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASM_SCORE_BITSPERLONG_H +#define _ASM_SCORE_BITSPERLONG_H + +#include <asm-generic/bitsperlong.h> + +#endif /* _ASM_SCORE_BITSPERLONG_H */
tools/arch/sparc/include/uapi/asm/bitsperlong.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ASM_ALPHA_BITSPERLONG_H +#define __ASM_ALPHA_BITSPERLONG_H + +#if defined(__sparc__) && defined(__arch64__) +#define __BITS_PER_LONG 64 +#else +#define __BITS_PER_LONG 32 +#endif + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_ALPHA_BITSPERLONG_H */
tools/arch/tile/include/uapi/asm/bitsperlong.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright 2010 Tilera Corporation. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation, version 2. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or +* NON INFRINGEMENT. See the GNU General Public License for +* more details. +*/ + +#ifndef _ASM_TILE_BITSPERLONG_H +#define _ASM_TILE_BITSPERLONG_H + +#ifdef __LP64__ +# define __BITS_PER_LONG 64 +#else +# define __BITS_PER_LONG 32 +#endif + +#include <asm-generic/bitsperlong.h> + +#endif /* _ASM_TILE_BITSPERLONG_H */
tools/arch/x86/include/uapi/asm/bitsperlong.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ASM_X86_BITSPERLONG_H +#define __ASM_X86_BITSPERLONG_H + +#if defined(__x86_64__) && !defined(__ILP32__) +# define __BITS_PER_LONG 64 +#else +# define __BITS_PER_LONG 32 +#endif + +#include <asm-generic/bitsperlong.h> + +#endif /* __ASM_X86_BITSPERLONG_H */
tools/include/asm-generic/bitops/__ffs.h +1 -0
@@ -2,6 +2,7 @@#define _TOOLS_LINUX_ASM_GENERIC_BITOPS___FFS_H_#include <asm/types.h> +#include <asm/bitsperlong.h> /** * __ffs - find first bit in word.
tools/include/asm-generic/bitops/atomic.h +1 -0
@@ -2,6 +2,7 @@#define _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_#include <asm/types.h> +#include <asm/bitsperlong.h> static inline void set_bit (int nr,unsigned long *addr) {
tools/include/asm-generic/bitsperlong.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef __ASM_GENERIC_BITS_PER_LONG +#define __ASM_GENERIC_BITS_PER_LONG + +#include <uapi/asm-generic/bitsperlong.h> + + +#ifdef CONFIG_64BIT +#define BITS_PER_LONG 64 +#else +#define BITS_PER_LONG 32 +#endif /* CONFIG_64BIT */ + +/* +* FIXME: The check currently breaks x86-64 build, so it's +* temporarily disabled. Please fix x86-64 and reenable +*/ +#if 0 &&BITS_PER_LONG != __BITS_PER_LONG +#error Inconsistent word size. Check asm/bitsperlong.h +#endif + +#ifndef BITS_PER_LONG_LONG +#define BITS_PER_LONG_LONG 64 +#endif + +#endif /* __ASM_GENERIC_BITS_PER_LONG */
tools/include/uapi/asm-generic/bitsperlong.h new file +15 -0
@@ -0,0 +1,15 @@ +#ifndef _UAPI__ASM_GENERIC_BITS_PER_LONG +#define _UAPI__ASM_GENERIC_BITS_PER_LONG + +/* +* There seems to be no way of detecting this automatically from user +* space, so 64 bit architectures should override this in their +* bitsperlong.h. In particular, an architecture that supports +* both 32 and 64 bit user space must not rely on CONFIG_64BIT +* to decide it, but rather check a compiler provided macro. +*/ +#ifndef __BITS_PER_LONG +#define __BITS_PER_LONG 32 +#endif + +#endif /* _UAPI__ASM_GENERIC_BITS_PER_LONG */
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 52/66 perf tools: Add the tools/ stringify copy to the MANIFEST
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
So that we don't end up using the kernel one when building out of tree, via a detached tarball.
--- tools/perf/MANIFEST | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/MANIFEST +1 -1
@@ -73,6 +73,7 @@ tools/include/linux/poison.h tools/include/linux/rbtree.h tools/include/linux/rbtree_augmented.h tools/include/linux/string.h +tools/include/linux/stringify.h tools/include/linux/types.h tools/include/linux/err.h tools/include/linux/bitmap.h
@@ -83,7 +84,6 @@ include/asm-generic/bitops/__fls.h include/asm-generic/bitops/fls.h include/linux/list.h include/linux/hash.h -include/linux/stringify.h include/linux/swab.h arch/*/include/asm/unistd*.h arch/*/include/uapi/asm/unistd*.h
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 53/66 perf tools: Don't add kernel directories to the header search path
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We've decided not to access kernel source files because changes there could break the tooling side, this is one more step in that direction.
--- tools/perf/config/Makefile | 4 ---- 1 file changed, 4 deletions(-)
tools/perf/config/Makefile +0 -4
@@ -210,11 +210,7 @@ CFLAGS += -I$(srctree)/tools/include/uapi CFLAGS += -I$(srctree)/tools/include/ CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/uapi CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/include/ -CFLAGS += -I$(srctree)/arch/$(ARCH)/include/uapi -CFLAGS += -I$(srctree)/arch/$(ARCH)/include CFLAGS += -I$(srctree)/tools/arch/$(ARCH)/ -CFLAGS += -I$(srctree)/include/uapi -CFLAGS += -I$(srctree)/include # $(obj-perf) for generated common-cmds.h # $(obj-perf)/util for generated bison/flex headers
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 54/66 perf intel-pt-decoder: Avoid checking code drift on busibox's diff
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
That doesn't have -I to match lines.
--- tools/perf/util/intel-pt-decoder/Build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/intel-pt-decoder/Build +4 -1
@@ -7,8 +7,11 @@ $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_table $(call rule_mkdir) @$(call echo-cmd,gen)$(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@ || rm -f $@ +# Busybox's diff doesn't have -I, avoid warning in the case + $(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/intel-pt-insn-decoder.c util/intel-pt-decoder/inat.c $(OUTPUT)util/intel-pt-decoder/inat-tables.c - @(test -d ../../kernel -a -d ../../tools -a -d ../perf && (( \ + @(diff -I 2>&1 | grep -q 'option requires an argument' && \ + test -d ../../kernel -a -d ../../tools -a -d ../perf && (( \ diff -B -I'^#include' util/intel-pt-decoder/insn.c ../../arch/x86/lib/insn.c >/dev/null && \ diff -B -I'^#include' util/intel-pt-decoder/inat.c ../../arch/x86/lib/inat.c >/dev/null && \ diff -B util/intel-pt-decoder/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null && \
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 55/66 perf tools: Add feature detection for gelf_getnote()
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
That is not present on some libelf implementations, such as the one used in Alpine Linux: libelf-0.8.13.
This ends up disabling the SDT code, that relies on this function.
One alternative would be to provide an weak fallback implementation or the open coded variant used by the buildid sysfs notes reading code.
--- tools/build/Makefile.feature | 1 + tools/build/feature/Makefile | 4 ++++ tools/build/feature/test-all.c | 5 +++++ tools/build/feature/test-libelf-gelf_getnote.c | 7 +++++++ tools/perf/config/Makefile | 6 ++++++ tools/perf/util/build-id.c | 2 +- tools/perf/util/probe-file.c | 2 ++ tools/perf/util/symbol-elf.c | 2 ++ 8 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tools/build/feature/test-libelf-gelf_getnote.c
tools/build/Makefile.feature +1 -0
@@ -40,6 +40,7 @@ FEATURE_TESTS_BASIC := \ libbfd \ libelf \ libelf-getphdrnum \ + libelf-gelf_getnote \ libelf-getshdrstrndx \ libelf-mmap \ libnuma \
tools/build/feature/Makefile +4 -0
@@ -17,6 +17,7 @@ FILES= \ test-cplus-demangle.bin \ test-libelf.bin \ test-libelf-getphdrnum.bin \ + test-libelf-gelf_getnote.bin \ test-libelf-getshdrstrndx.bin \ test-libelf-mmap.bin \ test-libnuma.bin \
@@ -99,6 +100,9 @@ $(OUTPUT)test-libelf-mmap.bin: $(OUTPUT)test-libelf-getphdrnum.bin: $(BUILD) -lelf +$(OUTPUT)test-libelf-gelf_getnote.bin: + $(BUILD) -lelf + $(OUTPUT)test-libelf-getshdrstrndx.bin: $(BUILD) -lelf
tools/build/feature/test-all.c +5 -0
@@ -49,6 +49,10 @@# include "test-libelf-getphdrnum.c" #undef main +#define main main_test_libelf_gelf_getnote +# include "test-libelf-gelf_getnote.c" +#undef main +#define main main_test_libelf_getshdrstrndx# include "test-libelf-getshdrstrndx.c" #undef main
@@ -153,6 +157,7 @@ int main(int argc, char *argv[])main_test_dwarf ();main_test_dwarf_getlocations ();main_test_libelf_getphdrnum (); +main_test_libelf_gelf_getnote ();main_test_libelf_getshdrstrndx ();main_test_libunwind ();main_test_libaudit ();
tools/build/feature/test-libelf-gelf_getnote.c new file +7 -0
@@ -0,0 +1,7 @@ +#include <stdlib.h> +#include <gelf.h> + +int main (void ) +{ +return gelf_getnote (NULL ,0 ,NULL ,NULL ,NULL ); +}
tools/perf/config/Makefile +6 -0
@@ -309,6 +309,12 @@ ifndef NO_LIBELF CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT endif + ifeq ($(feature-libelf-gelf_getnote), 1) + CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT + else + msg := $(warning gelf_getnote() not found on libelf, SDT support disabled); + endif + ifeq ($(feature-libelf-getshdrstrndx), 1) CFLAGS += -DHAVE_ELF_GETSHDRSTRNDX_SUPPORT endif
tools/perf/util/build-id.c +1 -1
@@ -533,7 +533,7 @@ int build_id_cache__list_build_ids(const char *pathname,return ret; } -#ifdef HAVE_LIBELF_SUPPORT +#if defined(HAVE_LIBELF_SUPPORT ) && defined(HAVE_GELF_GETNOTE_SUPPORT )static int build_id_cache__add_sdt_cache (const char *sbuild_id,const char *realname) {
tools/perf/util/probe-file.c +2 -0
@@ -624,6 +624,7 @@ out_err:return ret; } +#ifdef HAVE_GELF_GETNOTE_SUPPORT static unsigned long long sdt_note__get_addr (struct sdt_note *note) { return note->bit32 ? (unsigned long long)note->addr.a32[0]
@@ -682,6 +683,7 @@ int probe_cache__scan_sdt(struct probe_cache *pcache, const char *pathname)cleanup_sdt_note_list (&sdtlist); return ret; } +#endif static int probe_cache_entry__write (struct probe_cache_entry *entry,int fd) {
tools/perf/util/symbol-elf.c +2 -0
@@ -1790,6 +1790,7 @@ void kcore_extract__delete(struct kcore_extract *kce)unlink (kce->extract_filename); } +#ifdef HAVE_GELF_GETNOTE_SUPPORT /** * populate_sdt_note : Parse raw data and identify SDT note * @elf: elf of the opened file
@@ -2041,6 +2042,7 @@ int sdt_notes__get_count(struct list_head *start) count++; return count; } +#endif void symbol__elf_init (void ) {
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 56/66 perf symbols: Add Rust demangling
In reply to Arnaldo Carvalho de MeloFrom: David Tolnay <[email protected]>
Rust demangling is another step after bfd demangling. Add a diagnosis to identify mangled Rust symbols based on the hash that the Rust mangler appends as the last path component, as well as other characteristics. Add a demangler to reconstruct the original symbol.
Committer notes:
How I tested it:
Enabled COPR on Fedora 24 and then installed the 'rust-binary' package, with it:
$ cat src/main.rs
fn main() {
println!("Hello, world!");
}
$ cat Cargo.toml
[package] name = "hello_world"
version = "0.0.1"
authors = [ "Arnaldo Carvalho de Melo <[email protected]>" ]
$ perf record cargo bench
Compiling hello_world v0.0.1 (file:///home/acme/projects/hello_world)
Running target/release/hello_world-d4b9dab4b2a47d75running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.096 MB perf.data (1457 samples) ] $
Before this patch:
$ perf report --stdio --dsos librbml-e8edd0fd.so
# dso: librbml-e8edd0fd.so
#
# Total Lost Samples: 0
#
# Samples: 1K of event 'cycles:u'
# Event count (approx.): 979599126
#
# Overhead Command Symbol
# ........ ....... .............................................................................................................
#
1.78% rustc [.] rbml::reader::maybe_get_doc::hb9d387df6024b15b
1.50% rustc [.] _$LT$reader..DocsIterator$LT$$u27$a$GT$$u20$as$u20$std..iter..Iterator$GT$::next::hd9af9e60d79a35c8
1.20% rustc [.] rbml::reader::doc_at::hc88107fba445af31
0.46% rustc [.] _$LT$reader..TaggedDocsIterator$LT$$u27$a$GT$$u20$as$u20$std..iter..Iterator$GT$::next::h0cb40e696e4bb489
0.35% rustc [.] rbml::reader::Decoder::_next_int::h66eef7825a398bc3
0.29% rustc [.] rbml::reader::Decoder::_next_sub::h8e5266005580b836
0.15% rustc [.] rbml::reader::get_doc::h094521c645459139
0.14% rustc [.] _$LT$reader..Decoder$LT$$u27$doc$GT$$u20$as$u20$serialize..Decoder$GT$::read_u32::h0acea2fff9669327
0.07% rustc [.] rbml::reader::Decoder::next_doc::h6714d469c9dfaf91
0.07% rustc [.] _ZN4rbml6reader10doc_as_u6417h930b740aa94f1d3aE@plt
0.06% rustc [.] _fini
$After:
$ perf report --stdio --dsos librbml-e8edd0fd.so
# dso: librbml-e8edd0fd.so
#
# Total Lost Samples: 0
#
# Samples: 1K of event 'cycles:u'
# Event count (approx.): 979599126
#
# Overhead Command Symbol
# ........ ....... .................................................................
#
1.78% rustc [.] rbml::reader::maybe_get_doc
1.50% rustc [.] <reader::DocsIterator<'a> as std::iter::Iterator>::next
1.20% rustc [.] rbml::reader::doc_at
0.46% rustc [.] <reader::TaggedDocsIterator<'a> as std::iter::Iterator>::next
0.35% rustc [.] rbml::reader::Decoder::_next_int
0.29% rustc [.] rbml::reader::Decoder::_next_sub
0.15% rustc [.] rbml::reader::get_doc
0.14% rustc [.] <reader::Decoder<'doc> as serialize::Decoder>::read_u32
0.07% rustc [.] rbml::reader::Decoder::next_doc
0.07% rustc [.] _ZN4rbml6reader10doc_as_u6417h930b740aa94f1d3aE@plt
0.06% rustc [.] _fini
$--- tools/perf/util/Build | 1 + tools/perf/util/demangle-rust.c | 269 ++++++++++++++++++++++++++++++++++++++++ tools/perf/util/demangle-rust.h | 7 ++ tools/perf/util/symbol-elf.c | 8 ++ 4 files changed, 285 insertions(+) create mode 100644 tools/perf/util/demangle-rust.c create mode 100644 tools/perf/util/demangle-rust.h
tools/perf/util/Build +1 -0
@@ -113,6 +113,7 @@ libperf-y += scripting-engines/ libperf-$(CONFIG_ZLIB) += zlib.o libperf-$(CONFIG_LZMA) += lzma.o libperf-y += demangle-java.o +libperf-y += demangle-rust.o ifdef CONFIG_JITDUMP libperf-$(CONFIG_LIBELF) += jitdump.o
tools/perf/util/demangle-rust.c new file +269 -0
269 lines not on this page · raw message
tools/perf/util/demangle-rust.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __PERF_DEMANGLE_RUST +#define __PERF_DEMANGLE_RUST 1 + +bool rust_is_mangled (const char *str); +void rust_demangle_sym (char *str); + +#endif /* __PERF_DEMANGLE_RUST */
tools/perf/util/symbol-elf.c +8 -0
@@ -7,6 +7,7 @@#include "symbol.h" #include "demangle-java.h" +#include "demangle-rust.h" #include "machine.h" #include "vdso.h" #include <symbol/kallsyms.h>
@@ -1081,6 +1082,13 @@ new_symbol: demangled =bfd_demangle (NULL , elf_name, demangle_flags);if (demangled ==NULL ) demangled =java_demangle_sym (elf_name,JAVA_DEMANGLE_NORET ); +else if (rust_is_mangled (demangled)) +/* +* Input to Rust demangling is the BFD-demangled +* name which it Rust-demangles in place. +*/ +rust_demangle_sym (demangled); +if (demangled !=NULL ) elf_name = demangled; }
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 57/66 perf evlist: Make event2evsel public
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
It will be used outside of evlist.c object in folowing patches.
--- tools/perf/util/evlist.c | 4 ++-- tools/perf/util/evlist.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
tools/perf/util/evlist.c +2 -2
@@ -651,8 +651,8 @@ static int perf_evlist__event2id(struct perf_evlist *evlist,return 0 ; } -static struct perf_evsel *perf_evlist__event2evsel (struct perf_evlist *evlist, -union perf_event *event) +struct perf_evsel *perf_evlist__event2evsel (struct perf_evlist *evlist, +union perf_event *event) {struct perf_evsel *first =perf_evlist__first (evlist);struct hlist_head *head;
tools/perf/util/evlist.h +3 -0
@@ -323,4 +323,7 @@ void perf_event_attr__set_max_precise_ip(struct perf_event_attr *attr);struct perf_evsel *perf_evlist__find_evsel_by_str (struct perf_evlist *evlist,const char *str); + +struct perf_evsel *perf_evlist__event2evsel (struct perf_evlist *evlist, +union perf_event *event);#endif /* __PERF_EVLIST_H */
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 58/66 perf tools: Introduce trace_event__tp_format_id()
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
To get struct event_format object from tracepoint ID. It will be used in following patches.
--- tools/perf/util/trace-event.c | 8 ++++++++ tools/perf/util/trace-event.h | 2 ++ 2 files changed, 10 insertions(+)
tools/perf/util/trace-event.c +8 -0
@@ -105,3 +105,11 @@ trace_event__tp_format(const char *sys, const char *name)return tp_format (sys, name); } + +struct event_format *trace_event__tp_format_id (int id) +{ +if (!tevent_initialized &&trace_event__init2 ()) +return ERR_PTR (-ENOMEM ); + +return pevent_find_event (tevent.pevent, id); +}
tools/perf/util/trace-event.h +2 -0
@@ -23,6 +23,8 @@ int trace_event__register_resolver(struct machine *machine,struct event_format *trace_event__tp_format (const char *sys,const char *name); +struct event_format *trace_event__tp_format_id (int id); +int bigendian (void ); void event_format__fprintf(struct event_format *event,
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 59/66 perf python: Init perf_event_attr::size in perf.evsel constructor
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Currently 0 is passed as perf_event_attr::size, which could block usage of new features.
--- tools/perf/util/python.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/python.c +1 -0
@@ -653,6 +653,7 @@ static int pyrf_evsel__init(struct pyrf_evsel *pevsel, attr.precise_ip = precise_ip; attr.mmap_data = mmap_data; attr.sample_id_all = sample_id_all; + attr.size =sizeof (attr);perf_evsel__init (&pevsel->evsel, &attr, idx);return 0 ;
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 60/66 perf python: Fix pyrf_evlist__read_on_cpu event consuming
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
We can't consume the event before parsing it. Under heavy load we could get caught by kernel writer overwriting the event we're trying to parse.
--- tools/perf/util/python.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/python.c +4 -2
@@ -865,12 +865,14 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,PyObject *pyevent =pyrf_event__new (event);struct pyrf_event *pevent = (struct pyrf_event *)pyevent; -perf_evlist__mmap_consume (evlist, cpu); -if (pyevent ==NULL )return PyErr_NoMemory (); err =perf_evlist__parse_sample (evlist, event, &pevent->sample); + +/* Consume the even only after we parsed it out. */ +perf_evlist__mmap_consume (evlist, cpu); +if (err)return PyErr_Format (PyExc_OSError,"perf: can't parse sample, err=%d" , err);
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 61/66 perf python: Put perf.event objects into dictionary
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Make perf.event object parts of the perf module dictionary so we can address them by name.
The following objects/names are added:
mmap_event
lost_event
comm_event
task_event
throttle_event
task_event
read_event
sample_event
switch_event
We can now use it in python script like:
...
event = evlist.read_on_cpu(cpu)
...
if not isinstance(event, perf.sample_event):
--- tools/perf/util/python.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
tools/perf/util/python.c +27 -0
@@ -1103,6 +1103,33 @@ PyMODINIT_FUNC initperf(void)Py_INCREF (&pyrf_evsel__type);PyModule_AddObject (module,"evsel" , (PyObject *)&pyrf_evsel__type); +Py_INCREF (&pyrf_mmap_event__type); +PyModule_AddObject (module,"mmap_event" , (PyObject *)&pyrf_mmap_event__type); + +Py_INCREF (&pyrf_lost_event__type); +PyModule_AddObject (module,"lost_event" , (PyObject *)&pyrf_lost_event__type); + +Py_INCREF (&pyrf_comm_event__type); +PyModule_AddObject (module,"comm_event" , (PyObject *)&pyrf_comm_event__type); + +Py_INCREF (&pyrf_task_event__type); +PyModule_AddObject (module,"task_event" , (PyObject *)&pyrf_task_event__type); + +Py_INCREF (&pyrf_throttle_event__type); +PyModule_AddObject (module,"throttle_event" , (PyObject *)&pyrf_throttle_event__type); + +Py_INCREF (&pyrf_task_event__type); +PyModule_AddObject (module,"task_event" , (PyObject *)&pyrf_task_event__type); + +Py_INCREF (&pyrf_read_event__type); +PyModule_AddObject (module,"read_event" , (PyObject *)&pyrf_read_event__type); + +Py_INCREF (&pyrf_sample_event__type); +PyModule_AddObject (module,"sample_event" , (PyObject *)&pyrf_sample_event__type); + +Py_INCREF (&pyrf_context_switch_event__type); +PyModule_AddObject (module,"switch_event" , (PyObject *)&pyrf_context_switch_event__type); +Py_INCREF (&pyrf_thread_map__type);PyModule_AddObject (module,"thread_map" , (PyObject *)&pyrf_thread_map__type);
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 62/66 perf python: Add perf.tracepoint method
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
To get id of the tracepoint from subsystem and name strings. The interface is:
id = perf.tracepoint(sys, name)
In case of error -1 is returned.
It will be used to get python tracepoint event's config value for tracepoint event.
--- tools/perf/util/python.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
tools/perf/util/python.c +26 -0
@@ -2,6 +2,7 @@#include <structmember.h> #include <inttypes.h> #include <poll.h> +#include <linux/err.h> #include "evlist.h" #include "evsel.h" #include "event.h"
@@ -1076,7 +1077,32 @@ static struct { { .name = NULL, }, }; +static PyObject *pyrf__tracepoint (struct pyrf_evsel *pevsel, +PyObject *args,PyObject *kwargs) +{ +struct event_format *tp_format; +static char *kwlist[] = {"sys" ,"name" ,NULL }; +char *sys =NULL ; +char *name =NULL ; + +if (!PyArg_ParseTupleAndKeywords (args, kwargs,"|ss" , kwlist, + &sys, &name)) +return NULL ; + + tp_format =trace_event__tp_format (sys, name); +if (IS_ERR (tp_format)) +return PyInt_FromLong (-1 ); + +return PyInt_FromLong (tp_format->id); +} +static PyMethodDef perf__methods[] = { + { + .ml_name ="tracepoint" , + .ml_meth = (PyCFunction ) pyrf__tracepoint, + .ml_flags =METH_VARARGS |METH_KEYWORDS , + .ml_doc =PyDoc_STR ("Get tracepoint config." ) + }, { .ml_name =NULL , } };
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 63/66 perf python: Add struct evsel into struct pyrf_event
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
To be able to find out event configuration info during sample parsing.
--- tools/perf/util/python.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
tools/perf/util/python.c +9 -1
@@ -48,6 +48,7 @@ PyMODINIT_FUNC initperf(void);struct pyrf_event {PyObject_HEAD + struct perf_evsel *evsel;struct perf_sample sample;union perf_event event; };
@@ -865,11 +866,18 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,if (event !=NULL ) {PyObject *pyevent =pyrf_event__new (event);struct pyrf_event *pevent = (struct pyrf_event *)pyevent; +struct perf_evsel *evsel;if (pyevent ==NULL )return PyErr_NoMemory (); - err =perf_evlist__parse_sample (evlist, event, &pevent->sample); + evsel =perf_evlist__event2evsel (evlist, event); +if (!evsel) +return Py_None; + + pevent->evsel = evsel; + + err =perf_evsel__parse_sample (evsel, event, &pevent->sample);/* Consume the even only after we parsed it out. */ perf_evlist__mmap_consume (evlist, cpu);
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 64/66 perf python: Add support to resolve tracepoint fields
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding tp_getattro callback for sample event. It resolves tracepoint fields in runtime.
It's now possible to access tracepoint fields in normal fashion like hardcoded ones (see the example in the next patch).
--- tools/perf/util/python.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
tools/perf/util/python.c +92 -0
@@ -290,6 +290,97 @@ static PyObject *pyrf_sample_event__repr(struct pyrf_event *pevent)return ret; } +static bool is_tracepoint (struct pyrf_event *pevent) +{ +return pevent->evsel->attr.type ==PERF_TYPE_TRACEPOINT ; +} + +static int is_printable_array (char *p,unsigned int len) +{ +unsigned int i; + +for (i =0 ; i < len; i++) { +if (!isprint (p[i]) && !isspace (p[i])) +return 0 ; + } + +return 1 ; +} + +static PyObject * +tracepoint_field (struct pyrf_event *pe,struct format_field *field) +{ +struct pevent *pevent = field->event->pevent; +void *data = pe->sample.raw_data; +PyObject *ret =NULL ; +unsigned long long val; +unsigned int offset, len; + +if (field->flags &FIELD_IS_ARRAY ) { + offset = field->offset; + len = field->size; +if (field->flags &FIELD_IS_DYNAMIC ) { + val =pevent_read_number (pevent, data + offset, len); + offset = val; + len = offset >>16 ; + offset &=0xffff ; + } +if (field->flags &FIELD_IS_STRING && +is_printable_array (data + offset, len)) { + ret =PyString_FromString ((char *)data + offset); + }else { + ret =PyByteArray_FromStringAndSize ((const char *) data + offset, len); + field->flags &= ~FIELD_IS_STRING ; + } + }else { + val =pevent_read_number (pevent, data + field->offset, + field->size); +if (field->flags &FIELD_IS_POINTER ) + ret =PyLong_FromUnsignedLong ((unsigned long ) val); +else if (field->flags &FIELD_IS_SIGNED ) + ret =PyLong_FromLong ((long ) val); +else + ret =PyLong_FromUnsignedLong ((unsigned long ) val); + } + +return ret; +} + +static PyObject * +get_tracepoint_field (struct pyrf_event *pevent,PyObject *attr_name) +{ +const char *str =PyString_AsString (PyObject_Str (attr_name)); +struct perf_evsel *evsel = pevent->evsel; +struct format_field *field; + +if (!evsel->tp_format) { +struct event_format *tp_format; + + tp_format =trace_event__tp_format_id (evsel->attr.config); +if (!tp_format) +return NULL ; + + evsel->tp_format = tp_format; + } + + field =pevent_find_any_field (evsel->tp_format, str); +if (!field) +return NULL ; + +return tracepoint_field (pevent, field); +} + +static PyObject * +pyrf_sample_event__getattro (struct pyrf_event *pevent,PyObject *attr_name) +{ +PyObject *obj =NULL ; + +if (is_tracepoint (pevent)) + obj =get_tracepoint_field (pevent, attr_name); + +return obj ?:PyObject_GenericGetAttr ((PyObject *) pevent, attr_name); +} +static PyTypeObject pyrf_sample_event__type = {PyVarObject_HEAD_INIT (NULL ,0 ) .tp_name ="perf.sample_event" ,
@@ -298,6 +389,7 @@ static PyTypeObject pyrf_sample_event__type = { .tp_doc = pyrf_sample_event__doc, .tp_members = pyrf_sample_event__members, .tp_repr = (reprfunc)pyrf_sample_event__repr, + .tp_getattro = (getattrofunc) pyrf_sample_event__getattro, };static char pyrf_context_switch_event__doc[] =PyDoc_STR ("perf context_switch event object." );
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 65/66 perf python: Add tracepoint example
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
To show how to enable a tracepoint and access its fields.
Committer note:
Testing it:
# ls -l /tmp/build/perf/python/perf.so -rwxrwxr-x. 1 acme acme 1563256 Jul 12 16:19 /tmp/build/perf/python/perf.so # export PYTHONPATH=/tmp/build/perf/python/ # tools/perf/python/tracepoint.py 2> /dev/null | head -200 | tail -10 time 76345337296548 prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=tracepoint.py- next_pid=18479 next_prio=120 time 76345338520479 prev_comm=gnome-shelln-b prev_pid=2186 prev_prio=120 prev_state=0x1 ==> next_comm=swapper/1 next_pid=0 next_prio=120 time 76345337309942 prev_comm=tracepoint.py- prev_pid=18479 prev_prio=120 prev_state=0x1 ==> next_comm=swapper/0 next_pid=0 next_prio=120 time 76345337312302 prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=tracepoint.py- next_pid=18479 next_prio=120 time 76345337324927 prev_comm=tracepoint.py- prev_pid=18479 prev_prio=120 prev_state=0x1 ==> next_comm=swapper/0 next_pid=0 next_prio=120 time 76345337327115 prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=tracepoint.py- next_pid=18479 next_prio=120 time 76345338621750 prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=rcuos/2 next_pid=29 next_prio=120 time 76345338607922 prev_comm=swapper/3 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=rcu_sched next_pid=7 next_prio=120 time 76345337338817 prev_comm=tracepoint.py- prev_pid=18479 prev_prio=120 prev_state=0x1 ==> next_comm=swapper/0 next_pid=0 next_prio=120 time 76345338627156 prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=0x0 ==> next_comm=head-terminal- next_pid=18480 next_prio=120 # # strip /tmp/build/perf/python/perf.so # ls -l /tmp/build/perf/python/perf.so -rwxrwxr-x. 1 acme acme 319616 Jul 12 16:25 /tmp/build/perf/python/perf.so
--- tools/perf/python/tracepoint.py | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 tools/perf/python/tracepoint.py
tools/perf/python/tracepoint.py new file +47 -0
@@ -0,0 +1,47 @@ +#! /usr/bin/python +# -*- python -*- +# -*- coding: utf-8 -*- + +import perf + +class tracepoint(perf.evsel): + def __init__(self, sys, name): + config = perf.tracepoint(sys, name) + perf.evsel.__init__(self, + type = perf.TYPE_TRACEPOINT, + config = config, + freq = 0, sample_period = 1, wakeup_events = 1, + sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_RAW | perf.SAMPLE_TIME) + +def main(): + tp = tracepoint("sched", "sched_switch") + cpus = perf.cpu_map() + threads = perf.thread_map(-1) + + evlist = perf.evlist(cpus, threads) + evlist.add(tp) + evlist.open() + evlist.mmap() + + while True: + evlist.poll(timeout = -1) + for cpu in cpus: + event = evlist.read_on_cpu(cpu) + if not event: + continue + + if not isinstance(event, perf.sample_event): + continue + + print "time %u prev_comm=%s prev_pid=%d prev_prio=%d prev_state=0x%x ==> next_comm=%s next_pid=%d next_prio=%d" % ( + event.sample_time, + event.prev_comm, + event.prev_pid, + event.prev_prio, + event.prev_state, + event.next_comm, + event.next_pid, + event.next_prio) + +if __name__ == '__main__': + main()
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 66/66 tools lib traceevent: Add filter on task CPU id
In reply to Arnaldo Carvalho de MeloFrom: Steven Rostedt <[email protected]>
Add a 'CPU' special field to allow the filter in trace-cmd report to filter on the task's CPU.
By adding a special field 'CPU' (all caps) the user can now filter out tasks based on which CPU they are on. This is useful when filtering out (or in) a bunch of threads.
-F 'CPU == 0'
--- tools/lib/traceevent/parse-filter.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
tools/lib/traceevent/parse-filter.c +15 -3
@@ -28,11 +28,16 @@#include "event-utils.h" #define COMM "COMM" +#define CPU "CPU"static struct format_field comm = { .name ="COMM" , }; +static struct format_field cpu = { + .name ="CPU" , +}; +struct event_list {struct event_list *next;struct event_format *event;
@@ -382,14 +387,17 @@ create_arg_item(struct event_format *event, const char *token,/* Consider this a field */ field =pevent_find_any_field (event, token);if (!field) { -if (strcmp (token,COMM ) !=0 ) { +/* If token is 'COMM' or 'CPU' then it is special */ +if (strcmp (token,COMM ) ==0 ) { + field = &comm; + }else if (strcmp (token,CPU ) ==0 ) { + field = &cpu; + }else {/* not a field, Make it false */ arg->type =FILTER_ARG_BOOLEAN ; arg->boolean.value =FILTER_FALSE ;break ; } -/* If token is 'COMM' then it is special */ - field = &comm; } arg->type =FILTER_ARG_FIELD ; arg->field.field = field;
@@ -1718,6 +1726,10 @@ get_value(struct event_format *event,return (unsigned long )name; } +/* Handle our dummy "cpu" field */ +if (field == &cpu) +return record->cpu; +pevent_read_number_field (field, record->data, &val);if (!(field->flags &FIELD_IS_SIGNED ))
Signature · 1 line
2.7.4
Quoted 97 lines · Arnaldo Carvalho de Melo
Hi Ingo,
Please consider pulling, several more patches in my queue pending
review, this branch now builds in all of these systems, with Alpine Linux, that uses different versions of libelf, libc helping in keeping this codebase portable, soon I'll add containers for the Android SDK and Yocto:# perf stat dm alpine:3.4: Ok centos:5: Ok centos:6: Ok centos:7: Ok debian:7: Ok debian:8: Ok debian:experimental: Ok fedora:21: Ok fedora:22: Ok fedora:23: Ok fedora:24: Ok fedora:rawhide: Ok mageia:5: Ok opensuse:13.2: Ok opensuse:42.1: Ok ubuntu:12.04.5: Ok ubuntu:14.04.4: Ok ubuntu:15.10: Ok ubuntu:16.04: OkPerformance counter stats for 'dm': 1734.724897 task-clock (msec) # 0.003 CPUs utilized 70,156 context-switches # 0.040 M/sec 7,182 cpu-migrations # 0.004 M/sec 51,490 page-faults # 0.030 M/sec 5,093,434,618 cycles # 2.936 GHz 4,839,787,241 instructions # 0.95 insn per cycle 898,488,442 branches # 517.943 M/sec 16,155,791 branch-misses # 1.80% of all branches 684.926493347 seconds time elapsed#
- Arnaldo
The following changes since commit
44530d588e142a96cf0cd345a7cb8911c4f88720:Revert "perf/x86/intel, watchdog: Switch NMI watchdog to ref cycles on x86" (2016-07-10 20:58:36 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingo-20160712for you to fetch changes up to
6d248fbda59c51ef5f2e90e11551d9e17aeb226f:tools lib traceevent: Add filter on task CPU id (2016-07-12 16:27:39 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:User visible:
- Add demangling of symbols in programs written in the Rust language (David Tolnay)
- Add support for tracepoints in the python binding, including an example, that sets up and parses sched:sched_switch events,
tools/perf/python/tracepoint.py(Jiri Olsa)- Introduce --stdio-color to setup the color output mode selection in 'annotate' and 'report', allowing emit color escape sequences when redirecting the output of these tools (Arnaldo Carvalho de Melo)
Infrastructure:
- Various tweaks to allow the 'perf trace' beautifiers to build without using kernel headers and in a wider range of Linux distributions/releases (Arnaldo Carvalho de Melo)
- Stop using kernel source files, instead copy what is needed and check when the original kernel source file gets modified, warning the developers about it. This helps in building the tool in older systems and even in recent ones, for just added kernel features for which ABI details (struct changes, defines, etc) still are not available on system headers (Arnaldo Carvalho de Melo)
- Be consistent in how to use
strerror_r, adding a wrapper that makes sure that it returns a pointer to passed buffer, and using the XSI variant, that is available in more libc implementations (Arnaldo Carvalho de Melo)- Avoid checking code drift on busibox's diff perf intel-pt-decoder, as it doesn't have the '-I' command line switch to check for regexps (Arnaldo Carvalho de Melo)
- Add missing headers in various places (Arnaldo Carvalho de Melo)
- Remove unneeded headers from various other places (Arnaldo Carvalho de Melo)
- Add feature detection for
gelf_getnote(), disabling SDT support if not present (Arnaldo Carvalho de Melo)
Quoted 6 lines
- Fix oddities with gcc 5.3.0 by initializing some variables (Arnaldo Carvalho de Melo)
- With those changes in place perf now builds on Alpine Linux 3.4, in addition to on centos (5, 6, 7), debian (7, 8, experimental), fedora (21, 22, 23, 24, rawhide), mageia 5, opensuse (13.2, 42.1) and ubuntu (12.04.5, 14.04.4, 15.10, 16.04) and will be test build on those systems prior to future pull requests.
That's really impressive build coverage!
Pulled, thanks a lot Arnaldo!
Ingo
Hm, the objtool build broke:
GEN arch/x86/insn/inat-tables.c
CC arch/x86/decode.o
In file included from /home/mingo/tip/tools/include/linux/hashtable.h:12:0,
from arch/x86/../../elf.h:24,
from arch/x86/decode.c:26:/home/mingo/tip/tools/include/linux/bitops.h:12:0: error: "BITS_PER_LONG" redefined [-Werror]
#define BITS_PER_LONG __WORDSIZE
^
In file included from /usr/include/x86_64-linux-gnu/asm/bitsperlong.h:10:0,
from /usr/include/asm-generic/int-ll64.h:11,
from /usr/include/asm-generic/types.h:6,
from /usr/include/x86_64-linux-gnu/asm/types.h:4,
from /home/mingo/tip/tools/include/linux/types.h:9,
from /home/mingo/tip/tools/include/linux/list.h:4,
from arch/x86/../../elf.h:23,
from arch/x86/decode.c:26:/home/mingo/tip/tools/include/asm-generic/bitsperlong.h:10:0: note: this is the location of the previous definition
#define BITS_PER_LONG 32
^
and this breaks the x86 allyesconfig build.
Thanks,
Ingo
Quoted 20 lines · Ingo Molnar
Hm, the objtool build broke:
GEN
arch/x86/insn/inat-tables.c
CCarch/x86/decode.o
In file included from/home/mingo/tip/tools/include/linux/hashtable.h:12:0,from arch/x86/../../elf.h:24, from arch/x86/decode.c:26:
/home/mingo/tip/tools/include/linux/bitops.h:12:0: error: "BITS_PER_LONG" redefined [-Werror]
#defineBITS_PER_LONG__WORDSIZE
^
In file included from/usr/include/x86_64-linux-gnu/asm/bitsperlong.h:10:0,from /usr/include/asm-generic/int-ll64.h:11, from /usr/include/asm-generic/types.h:6, from /usr/include/x86_64-linux-gnu/asm/types.h:4, from /home/mingo/tip/tools/include/linux/types.h:9, from /home/mingo/tip/tools/include/linux/list.h:4, from arch/x86/../../elf.h:23, from arch/x86/decode.c:26:
Quoted 4 lines
/home/mingo/tip/tools/include/asm-generic/bitsperlong.h:10:0: note: this is the location of the previous definition
#defineBITS_PER_LONG32
^
Hi Ingo,
There's still another issue. Notice in the last line there that BITS_PER_LONG is getting incorrectly set to 32, at least for objtool.
That '#define BITS_PER_LONG 32' comes from the following code in tools/include/asm-generic/bitsperlong.h:
#ifdef CONFIG_64BIT #define BITS_PER_LONG 64 #else #define BITS_PER_LONG 32 #endif /* CONFIG_64BIT */
Because objtool doesn't have CONFIG_64BIT defined, it falls through to the '#else' condition. I think tools code shouldn't be relying on kernel config options.
Signature · 1 line
Josh
Peter Zijlstra
maintainerQuoted 9 lines · Josh Poimboeuf
That '#define
BITS_PER_LONG32' comes from the following code intools/include/asm-generic/bitsperlong.h:#ifdef CONFIG_64BIT #define BITS_PER_LONG 64 #else #define BITS_PER_LONG 32 #endif /* CONFIG_64BIT */
Quoted 3 lines
Because objtool doesn't have
CONFIG_64BITdefined, it falls through to the '#else' condition. I think tools code shouldn't be relying on kernel config options.
Right.. __LP64__ would work in general I think, or __SIZEOF_LONG__ * __CHAR_BIT__.
Arnaldo Carvalho de Melo
maintainerEm Wed, Jul 13, 2016 at 10:54:49PM +0200, Peter Zijlstra escreveu:
Quoted 10 lines · Josh Poimboeuf
Quoted 9 lines
That '#define
BITS_PER_LONG32' comes from the following code intools/include/asm-generic/bitsperlong.h:#ifdef CONFIG_64BIT #define BITS_PER_LONG 64 #else #define BITS_PER_LONG 32 #endif /* CONFIG_64BIT */
Quoted 6 lines
Quoted 3 lines
Because objtool doesn't have
CONFIG_64BITdefined, it falls through to the '#else' condition. I think tools code shouldn't be relying on kernel config options.Right..
__LP64__would work in general I think, or__SIZEOF_LONG__*__CHAR_BIT__.
Ok, to keep it close to the kernel counterpart, I ended up with the patch below, that builds for all the distros I have in my container set.
commit 2a00f026a15d161b47ba3d3417d0fec5193468c3
Author: Arnaldo Carvalho de Melo <[email protected]> Date: Wed Jul 13 15:04:04 2016 -0300
tools: Fix up BITS_PER_LONG setting
It was set based on CONFIG_64BIT, that is available only when using Kconfig, which we're working towards but not to the point of having this CONFIG variable set, so synthesize it from available compiler defined defines, __SIZEOF_LONG__ or, lacking that, __WORDSIZE.
tools/include/asm-generic/bitsperlong.h +19 -5
@@ -3,6 +3,24 @@#include <uapi/asm-generic/bitsperlong.h> +/* +* In the kernel, where this file comes from, we can rely on CONFIG_64BIT, +* here we have to make amends with what the various compilers provides us +* to figure out if we're on a 64-bit machine... +*/ +#ifdef __SIZEOF_LONG__ +# if __SIZEOF_LONG__ ==8 +# define CONFIG_64BIT +# endif +#else +# ifdef __WORDSIZE +# if __WORDSIZE ==64 +# define CONFIG_64BIT +# endif +# else +# error Failed to determine BITS_PER_LONG value +# endif +#endif #ifdef CONFIG_64BIT #define BITS_PER_LONG 64
@@ -10,11 +28,7 @@#define BITS_PER_LONG 32#endif /* CONFIG_64BIT */ -/* -* FIXME: The check currently breaks x86-64 build, so it's -* temporarily disabled. Please fix x86-64 and reenable -*/ -#if 0 &&BITS_PER_LONG != __BITS_PER_LONG +#if BITS_PER_LONG != __BITS_PER_LONG#error Inconsistent word size. Check asm/bitsperlong.h#endif
I have worked around the build failure for the time being via the patch below - but I guess there must be a better way.
Thanks,
Ingo
tools/include/linux/bitops.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/include/linux/bitops.h +3 -1
@@ -9,7 +9,9 @@#define __WORDSIZE (__SIZEOF_LONG__ * 8)#endif -#define BITS_PER_LONG __WORDSIZE +#ifndef BITS_PER_LONG +# define BITS_PER_LONG __WORDSIZE +#endif #define BIT_MASK (nr) (1UL << ((nr) % BITS_PER_LONG))#define BIT_WORD (nr) ((nr) / BITS_PER_LONG)
Quoted 3 lines · Arnaldo Carvalho de Melo
- Introduce --stdio-color to setup the color output mode selection in 'annotate' and 'report', allowing emit color escape sequences when redirecting the output of these tools (Arnaldo Carvalho de Melo)
That's a pretty neat trick, as doing:
perf report --stdio-color > tmp
... can now be used to put color coded output into Git logs!
Thanks,
Ingo