From 29e331176da121db22daa5dd9d72533b6a1efb33 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 22 Aug 2019 14:26:31 -0300 Subject: [PATCH 01/33] perf cpumap: No need to include perf.h, ditch it From a quick look this was never needed and just polluted the build, needlessly making things including cpumap.h to be rebuild if perf.h or anything it includes gets changed. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-x10p8slllqkn3fc3bntjx3n0@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cpumap.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h index d0c5bbfd91af8..c2519e7ea958e 100644 --- a/tools/perf/util/cpumap.h +++ b/tools/perf/util/cpumap.h @@ -7,8 +7,6 @@ #include #include -#include "perf.h" - struct cpu_map_data; struct perf_cpu_map *perf_cpu_map__empty_new(int nr); From 38b7b678fe989f9c403c001d96887939aaa1b68a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 22 Aug 2019 14:35:55 -0300 Subject: [PATCH 02/33] perf stat: Remove needless headers from stat.h Just a forward declaration for 'struct timespec' is needed, ditch the rest. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-6shdqw801oqe7ax6r307k27r@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/stat.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index bcb376e1b3a7f..9e425ecd82d94 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -5,13 +5,12 @@ #include #include #include -#include #include -#include #include "rblist.h" -#include "perf.h" #include "event.h" +struct timespec; + struct stats { double n, mean, M2; u64 max, min; From aeb00b1aeab6dadd72c24f93bea51a46e109c2ba Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 22 Aug 2019 15:40:29 -0300 Subject: [PATCH 03/33] perf record: Move record_opts and other record decls out of perf.h And into a separate util/record.h, to better isolate things and make sure that those who use record_opts and the other moved declarations are explicitly including the necessary header. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-31q8mei1qkh74qvkl9nwidfq@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm/util/cs-etm.c | 2 +- tools/perf/arch/arm64/util/arm-spe.c | 1 + tools/perf/arch/s390/util/auxtrace.c | 1 + tools/perf/arch/x86/tests/perf-time-to-tsc.c | 2 + tools/perf/arch/x86/util/intel-bts.c | 1 + tools/perf/arch/x86/util/intel-pt.c | 3 +- tools/perf/builtin-record.c | 4 +- tools/perf/builtin-script.c | 2 +- tools/perf/builtin-stat.c | 2 +- tools/perf/builtin-trace.c | 1 + tools/perf/perf.h | 62 ---------------- tools/perf/tests/backward-ring-buffer.c | 2 +- tools/perf/tests/bpf.c | 1 + tools/perf/tests/code-reading.c | 1 + tools/perf/tests/keep-tracking.c | 1 + tools/perf/tests/openat-syscall-tp-fields.c | 3 +- tools/perf/tests/perf-record.c | 2 +- tools/perf/tests/switch-tracking.c | 1 + tools/perf/tests/task-exit.c | 1 + tools/perf/util/auxtrace.c | 2 +- tools/perf/util/bpf-event.c | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/kvm-stat.h | 2 +- tools/perf/util/machine.c | 1 + tools/perf/util/machine.h | 1 + tools/perf/util/record.c | 1 + tools/perf/util/record.h | 74 ++++++++++++++++++++ tools/perf/util/stat.c | 1 + tools/perf/util/stat.h | 2 + tools/perf/util/top.h | 1 + 30 files changed, 107 insertions(+), 73 deletions(-) create mode 100644 tools/perf/util/record.h diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index c73da3245b671..a185dab2d9037 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -15,7 +15,7 @@ #include #include "cs-etm.h" -#include "../../perf.h" +#include "../../util/record.h" #include "../../util/auxtrace.h" #include "../../util/cpumap.h" #include "../../util/evlist.h" diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index 00915b8fd05b0..cdd5c0c841839 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -19,6 +19,7 @@ #include "../../util/pmu.h" #include "../../util/debug.h" #include "../../util/auxtrace.h" +#include "../../util/record.h" #include "../../util/arm-spe.h" #define KiB(x) ((x) * 1024) diff --git a/tools/perf/arch/s390/util/auxtrace.c b/tools/perf/arch/s390/util/auxtrace.c index cab46f517b839..f32d7a72d0398 100644 --- a/tools/perf/arch/s390/util/auxtrace.c +++ b/tools/perf/arch/s390/util/auxtrace.c @@ -8,6 +8,7 @@ #include "../../util/evlist.h" #include "../../util/auxtrace.h" #include "../../util/evsel.h" +#include "../../util/record.h" #define PERF_EVENT_CPUM_SF 0xB0000 /* Event: Basic-sampling */ #define PERF_EVENT_CPUM_SF_DIAG 0xBD000 /* Event: Combined-sampling */ diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c index 582182d98a7f4..02776109ba467 100644 --- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c +++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include #include @@ -13,6 +14,7 @@ #include "evsel.h" #include "thread_map.h" #include "cpumap.h" +#include "record.h" #include "tsc.h" #include "tests/tests.h" diff --git a/tools/perf/arch/x86/util/intel-bts.c b/tools/perf/arch/x86/util/intel-bts.c index 2d5d8a12dd1f4..1f2cf612bc9c6 100644 --- a/tools/perf/arch/x86/util/intel-bts.c +++ b/tools/perf/arch/x86/util/intel-bts.c @@ -17,6 +17,7 @@ #include "../../util/session.h" #include "../../util/pmu.h" #include "../../util/debug.h" +#include "../../util/record.h" #include "../../util/tsc.h" #include "../../util/auxtrace.h" #include "../../util/intel-bts.h" diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c index c72a77a82b396..44cfe72c1a4c6 100644 --- a/tools/perf/arch/x86/util/intel-pt.c +++ b/tools/perf/arch/x86/util/intel-pt.c @@ -13,7 +13,6 @@ #include #include -#include "../../perf.h" #include "../../util/session.h" #include "../../util/event.h" #include "../../util/evlist.h" @@ -24,6 +23,8 @@ #include "../../util/pmu.h" #include "../../util/debug.h" #include "../../util/auxtrace.h" +#include "../../util/record.h" +#include "../../util/target.h" #include "../../util/tsc.h" #include "../../util/intel-pt.h" diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index f71631f2bcb51..359bb8f33e578 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -8,8 +8,6 @@ */ #include "builtin.h" -#include "perf.h" - #include "util/build-id.h" #include #include "util/parse-events.h" @@ -22,9 +20,11 @@ #include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" +#include "util/target.h" #include "util/session.h" #include "util/tool.h" #include "util/symbol.h" +#include "util/record.h" #include "util/cpumap.h" #include "util/thread_map.h" #include "util/data.h" diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 9b93ddeaeafa7..ee05621d3bd69 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "builtin.h" -#include "perf.h" #include "util/cache.h" #include "util/counts.h" #include "util/debug.h" @@ -51,6 +50,7 @@ #include #include #include +#include "util/record.h" #include diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 8a4f1a7d0cba9..6ab13f466827a 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -40,7 +40,6 @@ * Jaswinder Singh Rajput */ -#include "perf.h" #include "builtin.h" #include "util/cgroup.h" #include @@ -62,6 +61,7 @@ #include "util/tool.h" #include "util/string2.h" #include "util/metricgroup.h" +#include "util/target.h" #include "util/top.h" #include "asm/bug.h" diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index de126258ca105..8ea62fd2591d0 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -14,6 +14,7 @@ * http://lwn.net/Articles/415728/ ("Announcing a new utility: 'trace'") */ +#include "util/record.h" #include #include #include diff --git a/tools/perf/perf.h b/tools/perf/perf.h index dc0a7a2378875..d9e6b8b957b64 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -35,63 +35,6 @@ extern const char perf_version_string[]; void pthread__unblock_sigwinch(void); -#include "util/target.h" - -struct record_opts { - struct target target; - bool group; - bool inherit_stat; - bool no_buffering; - bool no_inherit; - bool no_inherit_set; - bool no_samples; - bool raw_samples; - bool sample_address; - bool sample_phys_addr; - bool sample_weight; - bool sample_time; - bool sample_time_set; - bool sample_cpu; - bool period; - bool period_set; - bool running_time; - bool full_auxtrace; - bool auxtrace_snapshot_mode; - bool auxtrace_snapshot_on_exit; - bool record_namespaces; - bool record_switch_events; - bool all_kernel; - bool all_user; - bool kernel_callchains; - bool user_callchains; - bool tail_synthesize; - bool overwrite; - bool ignore_missing_thread; - bool strict_freq; - bool sample_id; - bool no_bpf_event; - unsigned int freq; - unsigned int mmap_pages; - unsigned int auxtrace_mmap_pages; - unsigned int user_freq; - u64 branch_stack; - u64 sample_intr_regs; - u64 sample_user_regs; - u64 default_interval; - u64 user_interval; - size_t auxtrace_snapshot_size; - const char *auxtrace_snapshot_opts; - bool sample_transaction; - unsigned initial_delay; - bool use_clockid; - clockid_t clockid; - u64 clockid_res_ns; - int nr_cblocks; - int affinity; - int mmap_flush; - unsigned int comp_level; -}; - enum perf_affinity { PERF_AFFINITY_SYS = 0, PERF_AFFINITY_NODE, @@ -99,10 +42,5 @@ enum perf_affinity { PERF_AFFINITY_MAX }; -struct option; -extern const char * const *record_usage; -extern struct option *record_options; extern int version_verbose; - -int record__parse_freq(const struct option *opt, const char *str, int unset); #endif diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c index 9bdf66139099a..b6f27ef9fb02f 100644 --- a/tools/perf/tests/backward-ring-buffer.c +++ b/tools/perf/tests/backward-ring-buffer.c @@ -4,9 +4,9 @@ * beginning */ -#include #include #include +#include "record.h" #include "tests.h" #include "debug.h" #include diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c index e16f927f38b6b..98642961fc63e 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index e45df0736261c..fe671b860086e 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -20,6 +20,7 @@ #include "map.h" #include "symbol.h" #include "event.h" +#include "record.h" #include "thread.h" #include "tests.h" diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c index 0ce5ce33bac4c..2af6faf1bbd64 100644 --- a/tools/perf/tests/keep-tracking.c +++ b/tools/perf/tests/keep-tracking.c @@ -8,6 +8,7 @@ #include "parse-events.h" #include "evlist.h" #include "evsel.h" +#include "record.h" #include "thread_map.h" #include "cpumap.h" #include "tests.h" diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c index 9c06130d37be7..62492106fb5e8 100644 --- a/tools/perf/tests/openat-syscall-tp-fields.c +++ b/tools/perf/tests/openat-syscall-tp-fields.c @@ -1,12 +1,13 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include #include #include #include -#include "perf.h" #include "evlist.h" #include "evsel.h" #include "thread_map.h" +#include "record.h" #include "tests.h" #include "debug.h" #include diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index 67b388e92cba8..3a205f6f93638 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c @@ -7,8 +7,8 @@ #include #include "evlist.h" #include "evsel.h" -#include "perf.h" #include "debug.h" +#include "record.h" #include "tests.h" static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp) diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c index e3cee69f6ea29..b63f027687245 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c @@ -13,6 +13,7 @@ #include "evsel.h" #include "thread_map.h" #include "cpumap.h" +#include "record.h" #include "tests.h" static int spin_sleep(void) diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index 4ca38fd0379a3..d79a22e2d8be3 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include "evlist.h" #include "evsel.h" +#include "target.h" #include "thread_map.h" #include "cpumap.h" #include "tests.h" diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 094e6ceb3cf2a..12e9b7acbb2ca 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -26,7 +26,6 @@ #include #include -#include "../perf.h" #include "evlist.h" #include "dso.h" #include "map.h" @@ -41,6 +40,7 @@ #include #include "event.h" +#include "record.h" #include "session.h" #include "debug.h" #include diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c index 5a5dcc6d8f858..5c634bcfea7e4 100644 --- a/tools/perf/util/bpf-event.c +++ b/tools/perf/util/bpf-event.c @@ -14,6 +14,7 @@ #include "session.h" #include "map.h" #include "evlist.h" +#include "record.h" #define ptr_to_u64(ptr) ((__u64)(unsigned long)(ptr)) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index e983e721becaa..9fadd5857cccd 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -34,6 +34,7 @@ #include "thread_map.h" #include "target.h" #include "perf_regs.h" +#include "record.h" #include "debug.h" #include "trace-event.h" #include "stat.h" diff --git a/tools/perf/util/kvm-stat.h b/tools/perf/util/kvm-stat.h index a09c495f866b8..46913637085ba 100644 --- a/tools/perf/util/kvm-stat.h +++ b/tools/perf/util/kvm-stat.h @@ -2,9 +2,9 @@ #ifndef __PERF_KVM_STAT_H #define __PERF_KVM_STAT_H -#include "../perf.h" #include "tool.h" #include "stat.h" +#include "record.h" struct evsel; struct evlist; diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 5734460fc89e8..f7c1a7e6c4bac 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -13,6 +13,7 @@ #include "symbol.h" #include "sort.h" #include "strlist.h" +#include "target.h" #include "thread.h" #include "vdso.h" #include diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 8b9d7157276d8..7d69119d0b5d1 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -14,6 +14,7 @@ struct branch_stack; struct evsel; struct perf_sample; struct symbol; +struct target; struct thread; union perf_event; diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 51bbd0714e6dd..574507d46c989 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -9,6 +9,7 @@ #include #include "util.h" #include "cloexec.h" +#include "record.h" typedef void (*setup_probe_fn_t)(struct evsel *evsel); diff --git a/tools/perf/util/record.h b/tools/perf/util/record.h new file mode 100644 index 0000000000000..00275afc524dc --- /dev/null +++ b/tools/perf/util/record.h @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _PERF_RECORD_H +#define _PERF_RECORD_H + +#include +#include +#include +#include +#include +#include "util/target.h" + +struct option; + +struct record_opts { + struct target target; + bool group; + bool inherit_stat; + bool no_buffering; + bool no_inherit; + bool no_inherit_set; + bool no_samples; + bool raw_samples; + bool sample_address; + bool sample_phys_addr; + bool sample_weight; + bool sample_time; + bool sample_time_set; + bool sample_cpu; + bool period; + bool period_set; + bool running_time; + bool full_auxtrace; + bool auxtrace_snapshot_mode; + bool auxtrace_snapshot_on_exit; + bool record_namespaces; + bool record_switch_events; + bool all_kernel; + bool all_user; + bool kernel_callchains; + bool user_callchains; + bool tail_synthesize; + bool overwrite; + bool ignore_missing_thread; + bool strict_freq; + bool sample_id; + bool no_bpf_event; + unsigned int freq; + unsigned int mmap_pages; + unsigned int auxtrace_mmap_pages; + unsigned int user_freq; + u64 branch_stack; + u64 sample_intr_regs; + u64 sample_user_regs; + u64 default_interval; + u64 user_interval; + size_t auxtrace_snapshot_size; + const char *auxtrace_snapshot_opts; + bool sample_transaction; + unsigned initial_delay; + bool use_clockid; + clockid_t clockid; + u64 clockid_res_ns; + int nr_cblocks; + int affinity; + int mmap_flush; + unsigned int comp_level; +}; + +extern const char * const *record_usage; +extern struct option *record_options; + +int record__parse_freq(const struct option *opt, const char *str, int unset); + +#endif // _PERF_RECORD_H diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 0cbfd1eca1dd1..f985336b3a228 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -4,6 +4,7 @@ #include #include "counts.h" #include "stat.h" +#include "target.h" #include "evlist.h" #include "evsel.h" #include "thread_map.h" diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 9e425ecd82d94..14fe3e548229f 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -198,6 +198,8 @@ int perf_stat_process_counter(struct perf_stat_config *config, struct perf_tool; union perf_event; struct perf_session; +struct target; + int perf_event__process_stat_event(struct perf_session *session, union perf_event *event); diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index dc4bb6e52a83a..7367433e767a4 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h @@ -5,6 +5,7 @@ #include "tool.h" #include "evswitch.h" #include "annotate.h" +#include "record.h" #include #include #include From 125009026bfc9ec929975d35344bf69d2c636e95 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 22 Aug 2019 16:58:29 -0300 Subject: [PATCH 04/33] perf cacheline: Move cacheline related routines to separate files To disentangle util/sort.h a bit more. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-6kbf2cauas06rbqp15pyter5@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-c2c.c | 1 + tools/perf/util/Build | 1 + tools/perf/util/cacheline.c | 26 ++++++++++++++++++++++++++ tools/perf/util/cacheline.h | 21 +++++++++++++++++++++ tools/perf/util/sort.c | 1 + tools/perf/util/sort.h | 12 ------------ tools/perf/util/util.c | 20 -------------------- tools/perf/util/util.h | 1 - 8 files changed, 50 insertions(+), 33 deletions(-) create mode 100644 tools/perf/util/cacheline.c create mode 100644 tools/perf/util/cacheline.h diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 2111437200781..73782d99ee5a0 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -26,6 +26,7 @@ #include "hist.h" #include "sort.h" #include "tool.h" +#include "cacheline.h" #include "data.h" #include "event.h" #include "evlist.h" diff --git a/tools/perf/util/Build b/tools/perf/util/Build index b922c8c297ca5..2e3856471e61c 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -1,6 +1,7 @@ perf-y += annotate.o perf-y += block-range.o perf-y += build-id.o +perf-y += cacheline.o perf-y += config.o perf-y += ctype.o perf-y += db-export.o diff --git a/tools/perf/util/cacheline.c b/tools/perf/util/cacheline.c new file mode 100644 index 0000000000000..9361d3f61f750 --- /dev/null +++ b/tools/perf/util/cacheline.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "cacheline.h" +#include "../perf.h" +#include + +#ifdef _SC_LEVEL1_DCACHE_LINESIZE +#define cache_line_size(cacheline_sizep) *cacheline_sizep = sysconf(_SC_LEVEL1_DCACHE_LINESIZE) +#else +#include +#include "debug.h" +static void cache_line_size(int *cacheline_sizep) +{ + if (sysfs__read_int("devices/system/cpu/cpu0/cache/index0/coherency_line_size", cacheline_sizep)) + pr_debug("cannot determine cache line size"); +} +#endif + +int cacheline_size(void) +{ + static int size; + + if (!size) + cache_line_size(&size); + + return size; +} diff --git a/tools/perf/util/cacheline.h b/tools/perf/util/cacheline.h new file mode 100644 index 0000000000000..dec8c0fb1f4a9 --- /dev/null +++ b/tools/perf/util/cacheline.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef PERF_CACHELINE_H +#define PERF_CACHELINE_H + +#include + +int __pure cacheline_size(void); + +static inline u64 cl_address(u64 address) +{ + /* return the cacheline of the address */ + return (address & ~(cacheline_size() - 1)); +} + +static inline u64 cl_offset(u64 address) +{ + /* return the cacheline of the address */ + return (address & (cacheline_size() - 1)); +} + +#endif // PERF_CACHELINE_H diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index f9a38a1dd4d1d..904ff4b2f57f6 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -6,6 +6,7 @@ #include #include "sort.h" #include "hist.h" +#include "cacheline.h" #include "comm.h" #include "map.h" #include "symbol.h" diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 5e34676a98e8e..4ae155c6a808e 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -204,18 +204,6 @@ static inline float hist_entry__get_percent_limit(struct hist_entry *he) return period * 100.0 / total_period; } -static inline u64 cl_address(u64 address) -{ - /* return the cacheline of the address */ - return (address & ~(cacheline_size() - 1)); -} - -static inline u64 cl_offset(u64 address) -{ - /* return the cacheline of the address */ - return (address & (cacheline_size() - 1)); -} - enum sort_mode { SORT_MODE__NORMAL, SORT_MODE__BRANCH, diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 6fd130a5d8f27..44211e483fbf2 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -43,26 +43,6 @@ void perf_set_multithreaded(void) unsigned int page_size; -#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)) - pr_debug("cannot determine cache line size"); -} -#endif - -int cacheline_size(void) -{ - static int size; - - if (!size) - cache_line_size(&size); - - return size; -} - int sysctl_perf_event_max_stack = PERF_MAX_STACK_DEPTH; int sysctl_perf_event_max_contexts_per_stack = PERF_MAX_CONTEXTS_PER_STACK; diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 0dab140c65170..45a5c6f201976 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -34,7 +34,6 @@ int copyfile_offset(int ifd, loff_t off_in, int ofd, loff_t off_out, u64 size); size_t hex_width(u64 v); extern unsigned int page_size; -int __pure cacheline_size(void); int sysctl__max_stack(void); From 97b9d866a66cf9884cea623cde3300073815873d Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 22 Aug 2019 17:10:08 -0300 Subject: [PATCH 05/33] perf srcline: Add missing srcline.h header to files needing its defs When srcline was introduced it wrongly added the include to util/sort.h, even with that header not needing the definitions it provides, fix it by adding it to the places that need it as a pre patch to remove srcline.h from sort.h. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-shuebppedtye8hrgxk15qe3x@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-diff.c | 2 ++ tools/perf/builtin-report.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/util/annotate.c | 2 ++ tools/perf/util/machine.c | 2 ++ tools/perf/util/sort.c | 1 + 6 files changed, 9 insertions(+) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index e91c0d7981816..51c37e53b3d8b 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -15,6 +15,7 @@ #include "util/session.h" #include "util/tool.h" #include "util/sort.h" +#include "util/srcline.h" #include "util/symbol.h" #include "util/data.h" #include "util/config.h" @@ -22,6 +23,7 @@ #include "util/annotate.h" #include "util/map.h" #include +#include #include #include diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 79dfb1139f949..318b0b95c14c7 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -28,6 +28,7 @@ #include "util/evswitch.h" #include "util/header.h" #include "util/session.h" +#include "util/srcline.h" #include "util/tool.h" #include diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index ee05621d3bd69..6f389b33fbe5f 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -11,6 +11,7 @@ #include "util/session.h" #include "util/tool.h" #include "util/map.h" +#include "util/srcline.h" #include "util/symbol.h" #include "util/thread.h" #include "util/trace-event.h" diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index e0518dc4c4d2b..3bd1691f0be7c 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -22,6 +22,7 @@ #include "cache.h" #include "map.h" #include "symbol.h" +#include "srcline.h" #include "units.h" #include "debug.h" #include "annotate.h" @@ -37,6 +38,7 @@ #include #include #include +#include /* FIXME: For the HE_COLORSET */ #include "ui/browser.h" diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index f7c1a7e6c4bac..47430afd3c2d0 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -10,11 +10,13 @@ #include "hist.h" #include "machine.h" #include "map.h" +#include "srcline.h" #include "symbol.h" #include "sort.h" #include "strlist.h" #include "target.h" #include "thread.h" +#include "util.h" #include "vdso.h" #include #include diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 904ff4b2f57f6..c522bdde3f716 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -13,6 +13,7 @@ #include "thread.h" #include "evsel.h" #include "evlist.h" +#include "srcline.h" #include "strlist.h" #include "strbuf.h" #include From 185bcb92c80eae2d85ec834ea76a144fd163e2af Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 22 Aug 2019 17:11:39 -0300 Subject: [PATCH 06/33] perf sort: Remove needless headers from sort.h, provide fwd struct decls Reducing the includes hell a bit more, speeding up the build and avoiding needless rebuilds when just one of those files gets updated. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-u63el2vqsovsmnhebx1rcixo@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/res_sample.c | 2 ++ tools/perf/ui/browsers/scripts.c | 2 ++ tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/callchain.c | 1 + tools/perf/util/sort.h | 15 ++------------- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/tools/perf/ui/browsers/res_sample.c b/tools/perf/ui/browsers/res_sample.c index 08897bd5eb0f9..41a9d8923ec43 100644 --- a/tools/perf/ui/browsers/res_sample.c +++ b/tools/perf/ui/browsers/res_sample.c @@ -6,6 +6,8 @@ #include "sort.h" #include "config.h" #include "time-utils.h" +#include "../util.h" +#include "../../util/util.h" #include #include diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index 04f9aff5621e7..f2fd9f0d7ab5e 100644 --- a/tools/perf/ui/browsers/scripts.c +++ b/tools/perf/ui/browsers/scripts.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 +#include "../../builtin.h" #include "../../util/sort.h" +#include "../../util/util.h" #include "../../util/hist.h" #include "../../util/debug.h" #include "../../util/symbol.h" diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index ee7ea6deed21c..51ed67548b839 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -3,6 +3,7 @@ #include #include "../../util/callchain.h" +#include "../../util/debug.h" #include "../../util/hist.h" #include "../../util/map.h" #include "../../util/map_groups.h" diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index d077704f9afa6..dd6e010003856 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -20,6 +20,7 @@ #include "asm/bug.h" +#include "debug.h" #include "hist.h" #include "sort.h" #include "machine.h" diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 4ae155c6a808e..3d7cef73924cc 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -1,29 +1,18 @@ /* SPDX-License-Identifier: GPL-2.0 */ #ifndef __PERF_SORT_H #define __PERF_SORT_H -#include "../builtin.h" - #include - -#include "color.h" +#include #include -#include "cache.h" #include #include "map_symbol.h" #include "symbol_conf.h" -#include "string.h" #include "callchain.h" #include "values.h" -#include "../perf.h" -#include "debug.h" -#include "header.h" - -#include -#include "parse-events.h" #include "hist.h" -#include "srcline.h" +struct option; struct thread; extern regex_t parent_regex; From d93fc7ac88c7347d1c31ca158d1466d1ce2097e1 Mon Sep 17 00:00:00 2001 From: James Clark Date: Thu, 22 Aug 2019 13:55:15 +0000 Subject: [PATCH 07/33] perf tests: Fixes hang in zstd compression test by changing the source of random data Running 'perf test' with zstd compression linked will hang at the test 'Zstd perf.data compression/decompression' because /dev/random blocks reads until there is enough entropy. This means that the test will appear to never complete unless the mouse is continually moved while running it. Signed-off-by: James Clark Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Jeremy Linton Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/3d8cc701-df4e-f949-1715-5118b530e990@arm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/shell/record+zstd_comp_decomp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/tests/shell/record+zstd_comp_decomp.sh b/tools/perf/tests/shell/record+zstd_comp_decomp.sh index 899604d17b85f..63a91ec473bb5 100755 --- a/tools/perf/tests/shell/record+zstd_comp_decomp.sh +++ b/tools/perf/tests/shell/record+zstd_comp_decomp.sh @@ -13,7 +13,7 @@ skip_if_no_z_record() { collect_z_record() { echo "Collecting compressed record file:" $perf_tool record -o $trace_file -g -z -F 5000 -- \ - dd count=500 if=/dev/random of=/dev/null + dd count=500 if=/dev/urandom of=/dev/null } check_compressed_stats() { From b92675f4a9c02dd78052645597dac9e270679ddf Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 22 Aug 2019 20:36:25 -0700 Subject: [PATCH 08/33] perf trace beauty ioctl: Fix off-by-one error in cmd->string table While tracing a program that calls isatty(3), I noticed that strace reported TCGETS for the request argument of the underlying ioctl(2) syscall while perf trace reported TCSETS. strace is corrrect. The bug in perf was due to the tty ioctl beauty table starting at 0x5400 rather than 0x5401. Committer testing: Using augmented_raw_syscalls.o and settings to make 'perf trace' use strace formatting, i.e. with this in ~/.perfconfig # cat ~/.perfconfig [trace] add_events = /home/acme/git/linux/tools/perf/examples/bpf/augmented_raw_syscalls.c show_zeros = yes show_duration = no no_inherit = yes show_timestamp = no show_arg_names = no args_alignment = 40 show_prefix = yes # strace -e ioctl stty > /dev/null ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, TIOCGWINSZ, 0x7fff8a9b0860) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(1, TCGETS, 0x7fff8a9b0540) = -1 ENOTTY (Inappropriate ioctl for device) +++ exited with 0 +++ # Before: # perf trace -e ioctl stty > /dev/null ioctl(0, TCSETS, 0x7fff2cf79f20) = 0 ioctl(1, TIOCSWINSZ, 0x7fff2cf79f40) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(1, TCSETS, 0x7fff2cf79c20) = -1 ENOTTY (Inappropriate ioctl for device) # After: # perf trace -e ioctl stty > /dev/null ioctl(0, TCGETS, 0x7ffed0763920) = 0 ioctl(1, TIOCGWINSZ, 0x7ffed0763940) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(1, TCGETS, 0x7ffed0763620) = -1 ENOTTY (Inappropriate ioctl for device) # Signed-off-by: Benjamin Peterson Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Fixes: 1cc47f2d46206d67285aea0ca7e8450af571da13 ("perf trace beauty ioctl: Improve 'cmd' beautifier") Link: http://lkml.kernel.org/r/20190823033625.18814-1-benjamin@python.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/trace/beauty/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/trace/beauty/ioctl.c b/tools/perf/trace/beauty/ioctl.c index 52242fa4072b0..e19eb6ea361d7 100644 --- a/tools/perf/trace/beauty/ioctl.c +++ b/tools/perf/trace/beauty/ioctl.c @@ -21,7 +21,7 @@ static size_t ioctl__scnprintf_tty_cmd(int nr, int dir, char *bf, size_t size) { static const char *ioctl_tty_cmd[] = { - "TCGETS", "TCSETS", "TCSETSW", "TCSETSF", "TCGETA", "TCSETA", "TCSETAW", + [_IOC_NR(TCGETS)] = "TCGETS", "TCSETS", "TCSETSW", "TCSETSF", "TCGETA", "TCSETA", "TCSETAW", "TCSETAF", "TCSBRK", "TCXONC", "TCFLSH", "TIOCEXCL", "TIOCNXCL", "TIOCSCTTY", "TIOCGPGRP", "TIOCSPGRP", "TIOCOUTQ", "TIOCSTI", "TIOCGWINSZ", "TIOCSWINSZ", "TIOCMGET", "TIOCMBIS", "TIOCMBIC", "TIOCMSET", "TIOCGSOFTCAR", "TIOCSSOFTCAR", From 2ad926db78777148b07fced1e4bc88e20ad00268 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 23 Aug 2019 10:37:47 -0300 Subject: [PATCH 09/33] perf augmented_raw_syscalls: Rename augmented_filename to augmented_arg Because it is not used only for strings, we already use it for sockaddr structs and will use it for all other types. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-w9nkt3tvmyn5i4qnwng3ap1k@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- .../examples/bpf/augmented_raw_syscalls.c | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/tools/perf/examples/bpf/augmented_raw_syscalls.c b/tools/perf/examples/bpf/augmented_raw_syscalls.c index 79787cf4fce92..b85b177c6726e 100644 --- a/tools/perf/examples/bpf/augmented_raw_syscalls.c +++ b/tools/perf/examples/bpf/augmented_raw_syscalls.c @@ -60,7 +60,7 @@ struct syscall_exit_args { long ret; }; -struct augmented_filename { +struct augmented_arg { unsigned int size; int err; char value[PATH_MAX]; @@ -72,8 +72,7 @@ struct augmented_args_payload { struct syscall_enter_args args; union { struct { - struct augmented_filename filename, - filename2; + struct augmented_arg arg, arg2; }; struct sockaddr_storage saddr; }; @@ -82,31 +81,30 @@ struct augmented_args_payload { bpf_map(augmented_args_tmp, PERCPU_ARRAY, int, struct augmented_args_payload, 1); static inline -unsigned int augmented_filename__read(struct augmented_filename *augmented_filename, - const void *filename_arg, unsigned int filename_len) +unsigned int augmented_arg__read_str(struct augmented_arg *augmented_arg, const void *arg, unsigned int arg_len) { - unsigned int len = sizeof(*augmented_filename); - int size = probe_read_str(&augmented_filename->value, filename_len, filename_arg); + unsigned int augmented_len = sizeof(*augmented_arg); + int string_len = probe_read_str(&augmented_arg->value, arg_len, arg); - augmented_filename->size = augmented_filename->err = 0; + augmented_arg->size = augmented_arg->err = 0; /* * probe_read_str may return < 0, e.g. -EFAULT - * So we leave that in the augmented_filename->size that userspace will + * So we leave that in the augmented_arg->size that userspace will */ - if (size > 0) { - len -= sizeof(augmented_filename->value) - size; - len &= sizeof(augmented_filename->value) - 1; - augmented_filename->size = size; + if (string_len > 0) { + augmented_len -= sizeof(augmented_arg->value) - string_len; + augmented_len &= sizeof(augmented_arg->value) - 1; + augmented_arg->size = string_len; } else { /* * So that username notice the error while still being able * to skip this augmented arg record */ - augmented_filename->err = size; - len = offsetof(struct augmented_filename, value); + augmented_arg->err = string_len; + augmented_len = offsetof(struct augmented_arg, value); } - return len; + return augmented_len; } SEC("!raw_syscalls:unaugmented") @@ -174,7 +172,7 @@ int sys_enter_open(struct syscall_enter_args *args) if (augmented_args == NULL) return 1; /* Failure: don't filter */ - len += augmented_filename__read(&augmented_args->filename, filename_arg, sizeof(augmented_args->filename.value)); + len += augmented_arg__read_str(&augmented_args->arg, filename_arg, sizeof(augmented_args->arg.value)); /* If perf_event_output fails, return non-zero so that it gets recorded unaugmented */ return perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, augmented_args, len); @@ -191,7 +189,7 @@ int sys_enter_openat(struct syscall_enter_args *args) if (augmented_args == NULL) return 1; /* Failure: don't filter */ - len += augmented_filename__read(&augmented_args->filename, filename_arg, sizeof(augmented_args->filename.value)); + len += augmented_arg__read_str(&augmented_args->arg, filename_arg, sizeof(augmented_args->arg.value)); /* If perf_event_output fails, return non-zero so that it gets recorded unaugmented */ return perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, augmented_args, len); @@ -209,8 +207,8 @@ int sys_enter_rename(struct syscall_enter_args *args) if (augmented_args == NULL) return 1; /* Failure: don't filter */ - oldpath_len = augmented_filename__read(&augmented_args->filename, oldpath_arg, sizeof(augmented_args->filename.value)); - len += oldpath_len + augmented_filename__read((void *)(&augmented_args->filename) + oldpath_len, newpath_arg, sizeof(augmented_args->filename.value)); + oldpath_len = augmented_arg__read_str(&augmented_args->arg, oldpath_arg, sizeof(augmented_args->arg.value)); + len += oldpath_len + augmented_arg__read_str((void *)(&augmented_args->arg) + oldpath_len, newpath_arg, sizeof(augmented_args->arg.value)); /* If perf_event_output fails, return non-zero so that it gets recorded unaugmented */ return perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, augmented_args, len); @@ -228,8 +226,8 @@ int sys_enter_renameat(struct syscall_enter_args *args) if (augmented_args == NULL) return 1; /* Failure: don't filter */ - oldpath_len = augmented_filename__read(&augmented_args->filename, oldpath_arg, sizeof(augmented_args->filename.value)); - len += oldpath_len + augmented_filename__read((void *)(&augmented_args->filename) + oldpath_len, newpath_arg, sizeof(augmented_args->filename.value)); + oldpath_len = augmented_arg__read_str(&augmented_args->arg, oldpath_arg, sizeof(augmented_args->arg.value)); + len += oldpath_len + augmented_arg__read_str((void *)(&augmented_args->arg) + oldpath_len, newpath_arg, sizeof(augmented_args->arg.value)); /* If perf_event_output fails, return non-zero so that it gets recorded unaugmented */ return perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, augmented_args, len); From 01128065ca5112123e6992dc0522484349c6ced7 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 23 Aug 2019 15:38:08 -0300 Subject: [PATCH 10/33] perf augmented_raw_syscalls: Postpone tmp map lookup to after pid_filter No sense in doing that lookup before figuring out if it will be used, i.e. if the pid is being filtered that tmp space lookup will be useless. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-o74yggieorucfg4j74tb6rta@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/examples/bpf/augmented_raw_syscalls.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/examples/bpf/augmented_raw_syscalls.c b/tools/perf/examples/bpf/augmented_raw_syscalls.c index b85b177c6726e..0a8d217d65c7c 100644 --- a/tools/perf/examples/bpf/augmented_raw_syscalls.c +++ b/tools/perf/examples/bpf/augmented_raw_syscalls.c @@ -250,13 +250,13 @@ int sys_enter(struct syscall_enter_args *args) struct syscall *syscall; int key = 0; + if (pid_filter__has(&pids_filtered, getpid())) + return 0; + augmented_args = bpf_map_lookup_elem(&augmented_args_tmp, &key); if (augmented_args == NULL) return 1; - if (pid_filter__has(&pids_filtered, getpid())) - return 0; - probe_read(&augmented_args->args, sizeof(augmented_args->args), args); /* From c265784de7adff9e07934b712204556fb0b3ba43 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 23 Aug 2019 15:45:54 -0300 Subject: [PATCH 11/33] perf augmented_raw_syscalls: Introduce helper to get the scratch space We need more than the BPF stack can give us to format the raw_syscalls:sys_enter augmented tracepoint, so we use a PERCPU_ARRAY map for that, use a helper to shorten the sequence to access that area. Signed-off-by: Arnaldo Carvalho de Melo --- .../examples/bpf/augmented_raw_syscalls.c | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/perf/examples/bpf/augmented_raw_syscalls.c b/tools/perf/examples/bpf/augmented_raw_syscalls.c index 0a8d217d65c7c..8fd5ea059903d 100644 --- a/tools/perf/examples/bpf/augmented_raw_syscalls.c +++ b/tools/perf/examples/bpf/augmented_raw_syscalls.c @@ -78,8 +78,15 @@ struct augmented_args_payload { }; }; +// We need more tmp space than the BPF stack can give us bpf_map(augmented_args_tmp, PERCPU_ARRAY, int, struct augmented_args_payload, 1); +static inline struct augmented_args_payload *augmented_args_payload(void) +{ + int key = 0; + return bpf_map_lookup_elem(&augmented_args_tmp, &key); +} + static inline unsigned int augmented_arg__read_str(struct augmented_arg *augmented_arg, const void *arg, unsigned int arg_len) { @@ -122,8 +129,7 @@ int syscall_unaugmented(struct syscall_enter_args *args) SEC("!syscalls:sys_enter_connect") int sys_enter_connect(struct syscall_enter_args *args) { - int key = 0; - struct augmented_args_payload *augmented_args = bpf_map_lookup_elem(&augmented_args_tmp, &key); + struct augmented_args_payload *augmented_args = augmented_args_payload(); const void *sockaddr_arg = (const void *)args->args[1]; unsigned int socklen = args->args[2]; unsigned int len = sizeof(augmented_args->args); @@ -143,8 +149,7 @@ int sys_enter_connect(struct syscall_enter_args *args) SEC("!syscalls:sys_enter_sendto") int sys_enter_sendto(struct syscall_enter_args *args) { - int key = 0; - struct augmented_args_payload *augmented_args = bpf_map_lookup_elem(&augmented_args_tmp, &key); + struct augmented_args_payload *augmented_args = augmented_args_payload(); const void *sockaddr_arg = (const void *)args->args[4]; unsigned int socklen = args->args[5]; unsigned int len = sizeof(augmented_args->args); @@ -164,8 +169,7 @@ int sys_enter_sendto(struct syscall_enter_args *args) SEC("!syscalls:sys_enter_open") int sys_enter_open(struct syscall_enter_args *args) { - int key = 0; - struct augmented_args_payload *augmented_args = bpf_map_lookup_elem(&augmented_args_tmp, &key); + struct augmented_args_payload *augmented_args = augmented_args_payload(); const void *filename_arg = (const void *)args->args[0]; unsigned int len = sizeof(augmented_args->args); @@ -181,8 +185,7 @@ int sys_enter_open(struct syscall_enter_args *args) SEC("!syscalls:sys_enter_openat") int sys_enter_openat(struct syscall_enter_args *args) { - int key = 0; - struct augmented_args_payload *augmented_args = bpf_map_lookup_elem(&augmented_args_tmp, &key); + struct augmented_args_payload *augmented_args = augmented_args_payload(); const void *filename_arg = (const void *)args->args[1]; unsigned int len = sizeof(augmented_args->args); @@ -198,8 +201,7 @@ int sys_enter_openat(struct syscall_enter_args *args) SEC("!syscalls:sys_enter_rename") int sys_enter_rename(struct syscall_enter_args *args) { - int key = 0; - struct augmented_args_payload *augmented_args = bpf_map_lookup_elem(&augmented_args_tmp, &key); + struct augmented_args_payload *augmented_args = augmented_args_payload(); const void *oldpath_arg = (const void *)args->args[0], *newpath_arg = (const void *)args->args[1]; unsigned int len = sizeof(augmented_args->args), oldpath_len; @@ -217,8 +219,7 @@ int sys_enter_rename(struct syscall_enter_args *args) SEC("!syscalls:sys_enter_renameat") int sys_enter_renameat(struct syscall_enter_args *args) { - int key = 0; - struct augmented_args_payload *augmented_args = bpf_map_lookup_elem(&augmented_args_tmp, &key); + struct augmented_args_payload *augmented_args = augmented_args_payload(); const void *oldpath_arg = (const void *)args->args[1], *newpath_arg = (const void *)args->args[3]; unsigned int len = sizeof(augmented_args->args), oldpath_len; @@ -248,14 +249,13 @@ int sys_enter(struct syscall_enter_args *args) */ unsigned int len = sizeof(augmented_args->args); struct syscall *syscall; - int key = 0; if (pid_filter__has(&pids_filtered, getpid())) return 0; - augmented_args = bpf_map_lookup_elem(&augmented_args_tmp, &key); - if (augmented_args == NULL) - return 1; + augmented_args = augmented_args_payload(); + if (augmented_args == NULL) + return 1; probe_read(&augmented_args->args, sizeof(augmented_args->args), args); From e051c2f69850e571cb408b555aaffb00c07dbb05 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 23 Aug 2019 15:54:02 -0300 Subject: [PATCH 12/33] perf augmented_raw_syscalls: Reduce perf_event_output() boilerplate Add a augmented__output() helper to reduce the boilerplate of sending the augmented tracepoint to the PERF_EVENT_ARRAY BPF map associated with the bpf-output event used to communicate with the userspace perf trace tool. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-ln99gt0j4fv0kw0778h6vphm@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- .../examples/bpf/augmented_raw_syscalls.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/perf/examples/bpf/augmented_raw_syscalls.c b/tools/perf/examples/bpf/augmented_raw_syscalls.c index 8fd5ea059903d..b80437971d802 100644 --- a/tools/perf/examples/bpf/augmented_raw_syscalls.c +++ b/tools/perf/examples/bpf/augmented_raw_syscalls.c @@ -87,6 +87,12 @@ static inline struct augmented_args_payload *augmented_args_payload(void) return bpf_map_lookup_elem(&augmented_args_tmp, &key); } +static inline int augmented__output(void *ctx, struct augmented_args_payload *args, int len) +{ + /* If perf_event_output fails, return non-zero so that it gets recorded unaugmented */ + return perf_event_output(ctx, &__augmented_syscalls__, BPF_F_CURRENT_CPU, args, len); +} + static inline unsigned int augmented_arg__read_str(struct augmented_arg *augmented_arg, const void *arg, unsigned int arg_len) { @@ -142,8 +148,7 @@ int sys_enter_connect(struct syscall_enter_args *args) probe_read(&augmented_args->saddr, socklen, sockaddr_arg); - /* If perf_event_output fails, return non-zero so that it gets recorded unaugmented */ - return perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, augmented_args, len + socklen); + return augmented__output(args, augmented_args, len + socklen); } SEC("!syscalls:sys_enter_sendto") @@ -162,8 +167,7 @@ int sys_enter_sendto(struct syscall_enter_args *args) probe_read(&augmented_args->saddr, socklen, sockaddr_arg); - /* If perf_event_output fails, return non-zero so that it gets recorded unaugmented */ - return perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, augmented_args, len + socklen); + return augmented__output(args, augmented_args, len + socklen); } SEC("!syscalls:sys_enter_open") @@ -178,8 +182,7 @@ int sys_enter_open(struct syscall_enter_args *args) len += augmented_arg__read_str(&augmented_args->arg, filename_arg, sizeof(augmented_args->arg.value)); - /* If perf_event_output fails, return non-zero so that it gets recorded unaugmented */ - return perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, augmented_args, len); + return augmented__output(args, augmented_args, len); } SEC("!syscalls:sys_enter_openat") @@ -194,8 +197,7 @@ int sys_enter_openat(struct syscall_enter_args *args) len += augmented_arg__read_str(&augmented_args->arg, filename_arg, sizeof(augmented_args->arg.value)); - /* If perf_event_output fails, return non-zero so that it gets recorded unaugmented */ - return perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, augmented_args, len); + return augmented__output(args, augmented_args, len); } SEC("!syscalls:sys_enter_rename") @@ -212,8 +214,7 @@ int sys_enter_rename(struct syscall_enter_args *args) oldpath_len = augmented_arg__read_str(&augmented_args->arg, oldpath_arg, sizeof(augmented_args->arg.value)); len += oldpath_len + augmented_arg__read_str((void *)(&augmented_args->arg) + oldpath_len, newpath_arg, sizeof(augmented_args->arg.value)); - /* If perf_event_output fails, return non-zero so that it gets recorded unaugmented */ - return perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, augmented_args, len); + return augmented__output(args, augmented_args, len); } SEC("!syscalls:sys_enter_renameat") @@ -230,8 +231,7 @@ int sys_enter_renameat(struct syscall_enter_args *args) oldpath_len = augmented_arg__read_str(&augmented_args->arg, oldpath_arg, sizeof(augmented_args->arg.value)); len += oldpath_len + augmented_arg__read_str((void *)(&augmented_args->arg) + oldpath_len, newpath_arg, sizeof(augmented_args->arg.value)); - /* If perf_event_output fails, return non-zero so that it gets recorded unaugmented */ - return perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, augmented_args, len); + return augmented__output(args, augmented_args, len); } SEC("raw_syscalls:sys_enter") From b4de344b25b9fbd4db7b84da43808a6b7daac887 Mon Sep 17 00:00:00 2001 From: Souptick Joarder Date: Sat, 24 Aug 2019 21:45:19 +0530 Subject: [PATCH 13/33] perf tools: Remove duplicate headers Removed headers which are included twice. Signed-off-by: Souptick Joarder Reviewed-by: Mukesh Ojha Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1566663319-4283-1-git-send-email-jrdr.linux@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/data.c | 1 - tools/perf/util/get_current_dir_name.c | 1 - tools/perf/util/stat-display.c | 1 - 3 files changed, 3 deletions(-) diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 1d1b97a92c3f7..74aafe0df5066 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include "data.h" diff --git a/tools/perf/util/get_current_dir_name.c b/tools/perf/util/get_current_dir_name.c index 01f32f26552d2..b205d929245f5 100644 --- a/tools/perf/util/get_current_dir_name.c +++ b/tools/perf/util/get_current_dir_name.c @@ -5,7 +5,6 @@ #include "get_current_dir_name.h" #include #include -#include /* Android's 'bionic' library, for one, doesn't have this */ diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 51d6781aa90d9..1461dac2322dd 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -14,7 +14,6 @@ #include "string2.h" #include #include "cgroup.h" -#include #include #define CNTR_NOT_SUPPORTED "" From 092804ae092fc6097348f5c09b62cde040717aa1 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Fri, 23 Aug 2019 14:03:37 -0700 Subject: [PATCH 14/33] perf report: Use timestamp__scnprintf_nsec() for time sort key Use timestamp__scnprintf_nsec() to print nanoseconds for the time sort key, instead of open coding. Signed-off-by: Andi Kleen Cc: Jiri Olsa Link: http://lkml.kernel.org/r/20190823210338.12360-1-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/sort.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index c522bdde3f716..83eb3fa6f9414 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -670,17 +670,11 @@ sort__time_cmp(struct hist_entry *left, struct hist_entry *right) static int hist_entry__time_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) { - unsigned long secs; - unsigned long long nsecs; char he_time[32]; - nsecs = he->time; - secs = nsecs / NSEC_PER_SEC; - nsecs -= secs * NSEC_PER_SEC; - if (symbol_conf.nanosecs) - snprintf(he_time, sizeof he_time, "%5lu.%09llu: ", - secs, nsecs); + timestamp__scnprintf_nsec(he->time, he_time, + sizeof(he_time)); else timestamp__scnprintf_usec(he->time, he_time, sizeof(he_time)); From 3dab6ac080dcd7f71cb9ceb84ad7dafecd6f7c07 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Fri, 23 Aug 2019 14:03:38 -0700 Subject: [PATCH 15/33] perf report: Fix --ns time sort key output If the user specified --ns, the column to print the sort time stamp wasn't wide enough to actually print the full nanoseconds. Widen the time key column width when --ns is specified. Before: % perf record -a sleep 1 % perf report --sort time,overhead,symbol --stdio --ns ... 2.39% 187851.10000 [k] smp_call_function_single - - 1.53% 187851.10000 [k] intel_idle - - 0.59% 187851.10000 [.] __wcscmp_ifunc - - 0.33% 187851.10000 [.] 0000000000000000 - - 0.28% 187851.10000 [k] cpuidle_enter_state - - After: % perf report --sort time,overhead,symbol --stdio --ns ... 2.39% 187851.100000000 [k] smp_call_function_single - - 1.53% 187851.100000000 [k] intel_idle - - 0.59% 187851.100000000 [.] __wcscmp_ifunc - - 0.33% 187851.100000000 [.] 0000000000000000 - - 0.28% 187851.100000000 [k] cpuidle_enter_state - - Signed-off-by: Andi Kleen Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Link: http://lkml.kernel.org/r/20190823210338.12360-2-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/hist.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 8efbf58dc3d06..33702675073c1 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -193,7 +193,10 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) hists__new_col_len(hists, HISTC_MEM_LVL, 21 + 3); hists__new_col_len(hists, HISTC_LOCAL_WEIGHT, 12); hists__new_col_len(hists, HISTC_GLOBAL_WEIGHT, 12); - hists__new_col_len(hists, HISTC_TIME, 12); + if (symbol_conf.nanosecs) + hists__new_col_len(hists, HISTC_TIME, 16); + else + hists__new_col_len(hists, HISTC_TIME, 12); if (h->srcline) { len = MAX(strlen(h->srcline), strlen(sort_srcline.se_header)); From 3b4acbb92dbda4829e021e5c6d5410658849fa1c Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 8 Apr 2019 11:27:48 -0500 Subject: [PATCH 16/33] perf script: Fix memory leaks in list_scripts() In case memory resources for *buf* and *paths* were allocated, jump to *out* and release them before return. Signed-off-by: Gustavo A. R. Silva Cc: Alexander Shishkin Cc: Andi Kleen Cc: Gustavo A. R. Silva Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Addresses-Coverity-ID: 1444328 ("Resource leak") Fixes: 6f3da20e151f ("perf report: Support builtin perf script in scripts menu") Link: http://lkml.kernel.org/r/20190408162748.GA21008@embeddedor Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/scripts.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index f2fd9f0d7ab5e..50e0c03171f21 100644 --- a/tools/perf/ui/browsers/scripts.c +++ b/tools/perf/ui/browsers/scripts.c @@ -133,8 +133,10 @@ static int list_scripts(char *script_name, bool *custom, int key = ui_browser__input_window("perf script command", "Enter perf script command line (without perf script prefix)", script_args, "", 0); - if (key != K_ENTER) - return -1; + if (key != K_ENTER) { + ret = -1; + goto out; + } sprintf(script_name, "%s script %s", perf, script_args); } else if (choice < num + max_std) { strcpy(script_name, paths[choice]); From 1345e2ee87a83c758f336f03f7fb305bc5e24490 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:41 +0200 Subject: [PATCH 17/33] libperf: Add PERF_RECORD_MMAP 'struct mmap_event' to perf/event.h Move the mmap_event event definition to libperf's event.h header include. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Perf added 'u*' types mainly to ease up printing __u64 values as stated in the linux/types.h comment: /* * We define u64 as uint64_t for every architecture * so that we can print it with "%"PRIx64 without getting warnings. * * typedef __u64 u64; * typedef __s64 s64; */ Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_' to ease up reading and differentiate them from standard PRI*64 macros. Committer notes: Fixup the PRI_l[ux]64 macros on 32-bit arches, conditionally defining it with that extra 'l' modifier only on arches where __u64 is long long, leaving it aside on 32-bit arches. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190825181752.722-2-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 18 ++++++++++++++++++ tools/perf/util/event.c | 2 +- tools/perf/util/event.h | 22 ++++++++++++++-------- tools/perf/util/python.c | 4 ++-- 4 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 tools/perf/lib/include/perf/event.h diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h new file mode 100644 index 0000000000000..13fe15a2fe7f1 --- /dev/null +++ b/tools/perf/lib/include/perf/event.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LIBPERF_EVENT_H +#define __LIBPERF_EVENT_H + +#include +#include +#include + +struct mmap_event { + struct perf_event_header header; + __u32 pid, tid; + __u64 start; + __u64 len; + __u64 pgoff; + char filename[PATH_MAX]; +}; + +#endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 332edef8d394d..43c86257e7fab 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1353,7 +1353,7 @@ int perf_event__process_bpf_event(struct perf_tool *tool __maybe_unused, size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp) { - return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %c %s\n", + return fprintf(fp, " %d/%d: [%#" PRI_lx64 "(%#" PRI_lx64 ") @ %#" PRI_lx64 "]: %c %s\n", event->mmap.pid, event->mmap.tid, event->mmap.start, event->mmap.len, event->mmap.pgoff, (event->header.misc & PERF_RECORD_MISC_MMAP_DATA) ? 'r' : 'x', diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 0e164e8ae28d6..f43eff2fba2dc 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -7,19 +7,25 @@ #include #include #include +#include #include "../perf.h" #include "build-id.h" #include "perf_regs.h" -struct mmap_event { - struct perf_event_header header; - u32 pid, tid; - u64 start; - u64 len; - u64 pgoff; - char filename[PATH_MAX]; -}; +#ifdef __LP64__ +/* + * /usr/include/inttypes.h uses just 'lu' for PRIu64, but we end up defining + * __u64 as long long unsigned int, and then -Werror=format= kicks in and + * complains of the mismatched types, so use these two special extra PRI + * macros to overcome that. + */ +#define PRI_lu64 "l" PRIu64 +#define PRI_lx64 "l" PRIx64 +#else +#define PRI_lu64 PRIu64 +#define PRI_lx64 PRIx64 +#endif struct mmap2_event { struct perf_event_header header; diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 75ecc32a4427b..55ff0c3182d6c 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -130,8 +130,8 @@ static PyObject *pyrf_mmap_event__repr(struct pyrf_event *pevent) PyObject *ret; char *s; - if (asprintf(&s, "{ type: mmap, pid: %u, tid: %u, start: %#" PRIx64 ", " - "length: %#" PRIx64 ", offset: %#" PRIx64 ", " + if (asprintf(&s, "{ type: mmap, pid: %u, tid: %u, start: %#" PRI_lx64 ", " + "length: %#" PRI_lx64 ", offset: %#" PRI_lx64 ", " "filename: %s }", pevent->event.mmap.pid, pevent->event.mmap.tid, pevent->event.mmap.start, pevent->event.mmap.len, From b66ced19c9f64dbe707cf318fae9fca82b999564 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:42 +0200 Subject: [PATCH 18/33] libperf: Add PERF_RECORD_MMAP2 'struct mmap2_event' to perf/event.h Moving mmap2_event event definition into libperf's event.h header include. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Perf added 'u*' types mainly to ease up printing __u64 values as stated in the linux/types.h comment: /* * We define u64 as uint64_t for every architecture * so that we can print it with "%"PRIx64 without getting warnings. * * typedef __u64 u64; * typedef __s64 s64; */ Adding and using new PRI_lu64 and PRI_lx64 macros to be used for that. Using extra '_' to ease up the reading and differentiate them from standard PRI*64 macros. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: https://lkml.kernel.org/n/tip-ufs9ityr5w2xqwtd5w3p6dm4@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 15 +++++++++++++++ tools/perf/util/event.c | 6 +++--- tools/perf/util/event.h | 15 --------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index 13fe15a2fe7f1..c82e0c2c004b8 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -15,4 +15,19 @@ struct mmap_event { char filename[PATH_MAX]; }; +struct mmap2_event { + struct perf_event_header header; + __u32 pid, tid; + __u64 start; + __u64 len; + __u64 pgoff; + __u32 maj; + __u32 min; + __u64 ino; + __u64 ino_generation; + __u32 prot; + __u32 flags; + char filename[PATH_MAX]; +}; + #endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 43c86257e7fab..0954f980574ff 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -387,7 +387,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool, strcpy(execname, ""); /* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */ - n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %x:%x %u %[^\n]\n", + n = sscanf(bf, "%"PRI_lx64"-%"PRI_lx64" %s %"PRI_lx64" %x:%x %u %[^\n]\n", &event->mmap2.start, &event->mmap2.len, prot, &event->mmap2.pgoff, &event->mmap2.maj, &event->mmap2.min, @@ -1362,8 +1362,8 @@ size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp) size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp) { - return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 - " %02x:%02x %"PRIu64" %"PRIu64"]: %c%c%c%c %s\n", + return fprintf(fp, " %d/%d: [%#" PRI_lx64 "(%#" PRI_lx64 ") @ %#" PRI_lx64 + " %02x:%02x %"PRI_lu64" %"PRI_lu64"]: %c%c%c%c %s\n", event->mmap2.pid, event->mmap2.tid, event->mmap2.start, event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj, event->mmap2.min, event->mmap2.ino, diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index f43eff2fba2dc..af252be8ca5ba 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -27,21 +27,6 @@ #define PRI_lx64 PRIx64 #endif -struct mmap2_event { - struct perf_event_header header; - u32 pid, tid; - u64 start; - u64 len; - u64 pgoff; - u32 maj; - u32 min; - u64 ino; - u64 ino_generation; - u32 prot; - u32 flags; - char filename[PATH_MAX]; -}; - struct comm_event { struct perf_event_header header; u32 pid, tid; From 002dda32a831b30d22a3620eb619a0d103e78e81 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:43 +0200 Subject: [PATCH 19/33] libperf: Add PERF_RECORD_COMM 'struct comm_event' to perf/event.h Moving comm_event event definition into libperf's event.h header include. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190825181752.722-4-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 6 ++++++ tools/perf/util/event.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index c82e0c2c004b8..3729a7d9253e8 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -30,4 +30,10 @@ struct mmap2_event { char filename[PATH_MAX]; }; +struct comm_event { + struct perf_event_header header; + __u32 pid, tid; + char comm[16]; +}; + #endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index af252be8ca5ba..e8973a7832679 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -27,12 +27,6 @@ #define PRI_lx64 PRIx64 #endif -struct comm_event { - struct perf_event_header header; - u32 pid, tid; - char comm[16]; -}; - struct namespaces_event { struct perf_event_header header; u32 pid, tid; From 19d1765a3ed9a8f78d93909120f6d39398809f75 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:44 +0200 Subject: [PATCH 20/33] libperf: Add PERF_RECORD_NAMESPACES 'struct namespaces_event' to perf/event.h Move the namespaces_event event definition into libperf's event.h header include. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190825181752.722-5-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 7 +++++++ tools/perf/util/event.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index 3729a7d9253e8..b90a8a21e613c 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -36,4 +36,11 @@ struct comm_event { char comm[16]; }; +struct namespaces_event { + struct perf_event_header header; + __u32 pid, tid; + __u64 nr_namespaces; + struct perf_ns_link_info link_info[]; +}; + #endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index e8973a7832679..0d3ac4fd3ecf1 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -27,13 +27,6 @@ #define PRI_lx64 PRIx64 #endif -struct namespaces_event { - struct perf_event_header header; - u32 pid, tid; - u64 nr_namespaces; - struct perf_ns_link_info link_info[]; -}; - struct fork_event { struct perf_event_header header; u32 pid, ppid; From bceb59b1f28d1ca812d816fd8f33c72b1a8378fb Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:45 +0200 Subject: [PATCH 21/33] libperf: Add PERF_RECORD_FORK 'struct fork_event' to perf/event.h Move the fork_event event definition into libperf's event.h header include. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Perf added 'u*' types mainly to ease up printing __u64 values as stated in the linux/types.h comment: /* * We define u64 as uint64_t for every architecture * so that we can print it with "%"PRIx64 without getting warnings. * * typedef __u64 u64; * typedef __s64 s64; */ Add and use new PRI_lu64 and PRI_lx64 macros for that. Using extra '_' to ease up the reading and differentiate them from standard PRI*64 macros. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190825181752.722-6-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 7 +++++++ tools/perf/util/event.h | 7 ------- tools/perf/util/python.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index b90a8a21e613c..c7cae58d25358 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -43,4 +43,11 @@ struct namespaces_event { struct perf_ns_link_info link_info[]; }; +struct fork_event { + struct perf_event_header header; + __u32 pid, ppid; + __u32 tid, ptid; + __u64 time; +}; + #endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 0d3ac4fd3ecf1..38b258cbbd906 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -27,13 +27,6 @@ #define PRI_lx64 PRIx64 #endif -struct fork_event { - struct perf_event_header header; - u32 pid, ppid; - u32 tid, ptid; - u64 time; -}; - struct lost_event { struct perf_event_header header; u64 id; diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 55ff0c3182d6c..8bdadb24f6ba7 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -170,7 +170,7 @@ static PyMemberDef pyrf_task_event__members[] = { static PyObject *pyrf_task_event__repr(struct pyrf_event *pevent) { return _PyUnicode_FromFormat("{ type: %s, pid: %u, ppid: %u, tid: %u, " - "ptid: %u, time: %" PRIu64 "}", + "ptid: %u, time: %" PRI_lu64 "}", pevent->event.header.type == PERF_RECORD_FORK ? "fork" : "exit", pevent->event.fork.pid, pevent->event.fork.ppid, From 5290ed6955ebc481d5cd62f7175e8514931058bc Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:46 +0200 Subject: [PATCH 22/33] libperf: Add PERF_RECORD_LOST 'struct lost_event' to perf/event.h Move the lost_event event definition to libperf's event.h header include. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Perf added 'u*' types mainly to ease up printing __u64 values as stated in the linux/types.h comment: /* * We define u64 as uint64_t for every architecture * so that we can print it with "%"PRIx64 without getting warnings. * * typedef __u64 u64; * typedef __s64 s64; */ Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_' to ease up the reading and differentiate them from standard PRI*64 macros. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190825181752.722-7-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-sched.c | 2 +- tools/perf/lib/include/perf/event.h | 6 ++++++ tools/perf/util/event.c | 2 +- tools/perf/util/event.h | 6 ------ tools/perf/util/machine.c | 2 +- tools/perf/util/python.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 0d6b4c3b1a511..025151dcb6518 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -2643,7 +2643,7 @@ static int process_lost(struct perf_tool *tool __maybe_unused, timestamp__scnprintf_usec(sample->time, tstr, sizeof(tstr)); printf("%15s ", tstr); - printf("lost %" PRIu64 " events on cpu %d\n", event->lost.lost, sample->cpu); + printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu); return 0; } diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index c7cae58d25358..71045ea8214c8 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -50,4 +50,10 @@ struct fork_event { __u64 time; }; +struct lost_event { + struct perf_event_header header; + __u64 id; + __u64 lost; +}; + #endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 0954f980574ff..3bd9fc2a3ae86 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1480,7 +1480,7 @@ size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp) static size_t perf_event__fprintf_lost(union perf_event *event, FILE *fp) { - return fprintf(fp, " lost %" PRIu64 "\n", event->lost.lost); + return fprintf(fp, " lost %" PRI_lu64 "\n", event->lost.lost); } size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp) diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 38b258cbbd906..4a3f50203d045 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -27,12 +27,6 @@ #define PRI_lx64 PRIx64 #endif -struct lost_event { - struct perf_event_header header; - u64 id; - u64 lost; -}; - struct lost_samples_event { struct perf_event_header header; u64 lost; diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 47430afd3c2d0..1ad6e984c2f56 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -645,7 +645,7 @@ int machine__process_namespaces_event(struct machine *machine __maybe_unused, int machine__process_lost_event(struct machine *machine __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused) { - dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n", + dump_printf(": id:%" PRI_lu64 ": lost:%" PRI_lu64 "\n", event->lost.id, event->lost.lost); return 0; } diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 8bdadb24f6ba7..5be85f50cd1c9 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -263,8 +263,8 @@ static PyObject *pyrf_lost_event__repr(struct pyrf_event *pevent) PyObject *ret; char *s; - if (asprintf(&s, "{ type: lost, id: %#" PRIx64 ", " - "lost: %#" PRIx64 " }", + if (asprintf(&s, "{ type: lost, id: %#" PRI_lx64 ", " + "lost: %#" PRI_lx64 " }", pevent->event.lost.id, pevent->event.lost.lost) < 0) { ret = PyErr_NoMemory(); } else { From a2e254d84172f7eb638261a83024d849f78c89e9 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:47 +0200 Subject: [PATCH 23/33] libperf: Add PERF_RECORD_LOST_SAMPLES 'struct lost_samples_event' to perf/event.h Move the PERF_RECORD_LOST_SAMPLES event definition into libperf's event.h header include. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Perf added 'u*' types mainly to ease up printing __u64 values as stated in the linux/types.h comment: /* * We define u64 as uint64_t for every architecture * so that we can print it with "%"PRIx64 without getting warnings. * * typedef __u64 u64; * typedef __s64 s64; */ Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_' to ease up the reading and differentiate them from standard PRI*64 macros. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190825181752.722-8-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 5 +++++ tools/perf/util/event.h | 5 ----- tools/perf/util/machine.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index 71045ea8214c8..86a7795934059 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -56,4 +56,9 @@ struct lost_event { __u64 lost; }; +struct lost_samples_event { + struct perf_event_header header; + __u64 lost; +}; + #endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 4a3f50203d045..976a8f00d2a29 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -27,11 +27,6 @@ #define PRI_lx64 PRIx64 #endif -struct lost_samples_event { - struct perf_event_header header; - u64 lost; -}; - /* * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID */ diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 1ad6e984c2f56..823aaf7b1b83b 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -653,7 +653,7 @@ int machine__process_lost_event(struct machine *machine __maybe_unused, int machine__process_lost_samples_event(struct machine *machine __maybe_unused, union perf_event *event, struct perf_sample *sample) { - dump_printf(": id:%" PRIu64 ": lost samples :%" PRIu64 "\n", + dump_printf(": id:%" PRIu64 ": lost samples :%" PRI_lu64 "\n", sample->id, event->lost_samples.lost); return 0; } From 213a6c1d20687d44acaa1cb4f77ce5bae4f1dd8f Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:48 +0200 Subject: [PATCH 24/33] libperf: Add PERF_RECORD_READ 'struct read_event' to perf/event.h Move the PERF_RECORD_READ event definition to libperf's event.h header include. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Perf added 'u*' types mainly to ease up printing __u64 values as stated in the linux/types.h comment: /* * We define u64 as uint64_t for every architecture * so that we can print it with "%"PRIx64 without getting warnings. * * typedef __u64 u64; * typedef __s64 s64; */ Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_' to ease up the reading and differentiate them from standard PRI*64 macros. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190825181752.722-9-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 12 ++++++++++++ tools/perf/util/event.h | 12 ------------ tools/perf/util/session.c | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index 86a7795934059..f1830702e49a4 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -61,4 +61,16 @@ struct lost_samples_event { __u64 lost; }; +/* + * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID + */ +struct read_event { + struct perf_event_header header; + __u32 pid, tid; + __u64 value; + __u64 time_enabled; + __u64 time_running; + __u64 id; +}; + #endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 976a8f00d2a29..008a2839d6673 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -27,18 +27,6 @@ #define PRI_lx64 PRIx64 #endif -/* - * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID - */ -struct read_event { - struct perf_event_header header; - u32 pid, tid; - u64 value; - u64 time_enabled; - u64 time_running; - u64 id; -}; - struct throttle_event { struct perf_event_header header; u64 time; diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 82e0438a91606..cb1d8dcd0c195 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1260,7 +1260,7 @@ static void dump_read(struct evsel *evsel, union perf_event *event) if (!dump_trace) return; - printf(": %d %d %s %" PRIu64 "\n", event->read.pid, event->read.tid, + printf(": %d %d %s %" PRI_lu64 "\n", event->read.pid, event->read.tid, perf_evsel__name(evsel), event->read.value); @@ -1270,13 +1270,13 @@ static void dump_read(struct evsel *evsel, union perf_event *event) read_format = evsel->core.attr.read_format; if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) - printf("... time enabled : %" PRIu64 "\n", read_event->time_enabled); + printf("... time enabled : %" PRI_lu64 "\n", read_event->time_enabled); if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) - printf("... time running : %" PRIu64 "\n", read_event->time_running); + printf("... time running : %" PRI_lu64 "\n", read_event->time_running); if (read_format & PERF_FORMAT_ID) - printf("... id : %" PRIu64 "\n", read_event->id); + printf("... id : %" PRI_lu64 "\n", read_event->id); } static struct machine *machines__find_for_cpumode(struct machines *machines, From 003c66fec28fea52825b60cad98af8cf11074d76 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:49 +0200 Subject: [PATCH 25/33] libperf: Add PERF_RECORD_THROTTLE 'struct throttle_event' to perf/event.h Move the PERF_RECORD_THROTTLE event definition into libperf's event.h header include. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Perf added 'u*' types mainly to ease up printing __u64 values as stated in the linux/types.h comment: /* * We define u64 as uint64_t for every architecture * so that we can print it with "%"PRIx64 without getting warnings. * * typedef __u64 u64; * typedef __s64 s64; */ Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_' to ease up the reading and differentiate them from standard PRI*64 macros. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190825181752.722-10-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 7 +++++++ tools/perf/util/event.h | 7 ------- tools/perf/util/python.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index f1830702e49a4..ef5ec66b566eb 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -73,4 +73,11 @@ struct read_event { __u64 id; }; +struct throttle_event { + struct perf_event_header header; + __u64 time; + __u64 id; + __u64 stream_id; +}; + #endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 008a2839d6673..40020f5b04841 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -27,13 +27,6 @@ #define PRI_lx64 PRIx64 #endif -struct throttle_event { - struct perf_event_header header; - u64 time; - u64 id; - u64 stream_id; -}; - #ifndef KSYM_NAME_LEN #define KSYM_NAME_LEN 256 #endif diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 5be85f50cd1c9..d21e270c7823c 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -233,8 +233,8 @@ static PyObject *pyrf_throttle_event__repr(struct pyrf_event *pevent) { struct throttle_event *te = (struct throttle_event *)(&pevent->event.header + 1); - return _PyUnicode_FromFormat("{ type: %sthrottle, time: %" PRIu64 ", id: %" PRIu64 - ", stream_id: %" PRIu64 " }", + return _PyUnicode_FromFormat("{ type: %sthrottle, time: %" PRI_lu64 ", id: %" PRI_lu64 + ", stream_id: %" PRI_lu64 " }", pevent->event.header.type == PERF_RECORD_THROTTLE ? "" : "un", te->time, te->id, te->stream_id); } From f15e3c25a1b40794a0ef2647360afe873fe34f54 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:50 +0200 Subject: [PATCH 26/33] libperf: Add PERF_RECORD_KSYMBOL 'struct ksymbol_event' to perf/event.h Move the PERF_RECORD_KSYMBOL event definition into libperf's event.h header include. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Perf added 'u*' types mainly to ease up printing __u64 values as stated in the linux/types.h comment: /* * We define u64 as uint64_t for every architecture * so that we can print it with "%"PRIx64 without getting warnings. * * typedef __u64 u64; * typedef __s64 s64; */ Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_' to ease up the reading and differentiate them from standard PRI*64 macros. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190825181752.722-11-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 13 +++++++++++++ tools/perf/util/event.c | 2 +- tools/perf/util/event.h | 13 ------------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index ef5ec66b566eb..8c367931cecc5 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -80,4 +80,17 @@ struct throttle_event { __u64 stream_id; }; +#ifndef KSYM_NAME_LEN +#define KSYM_NAME_LEN 256 +#endif + +struct ksymbol_event { + struct perf_event_header header; + __u64 addr; + __u32 len; + __u16 ksym_type; + __u16 flags; + char name[KSYM_NAME_LEN]; +}; + #endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 3bd9fc2a3ae86..4447cd25e3f2d 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1485,7 +1485,7 @@ static size_t perf_event__fprintf_lost(union perf_event *event, FILE *fp) size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp) { - return fprintf(fp, " addr %" PRIx64 " len %u type %u flags 0x%x name %s\n", + return fprintf(fp, " addr %" PRI_lx64 " len %u type %u flags 0x%x name %s\n", event->ksymbol_event.addr, event->ksymbol_event.len, event->ksymbol_event.ksym_type, event->ksymbol_event.flags, event->ksymbol_event.name); diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 40020f5b04841..c4eec1f164ba2 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -27,19 +27,6 @@ #define PRI_lx64 PRIx64 #endif -#ifndef KSYM_NAME_LEN -#define KSYM_NAME_LEN 256 -#endif - -struct ksymbol_event { - struct perf_event_header header; - u64 addr; - u32 len; - u16 ksym_type; - u16 flags; - char name[KSYM_NAME_LEN]; -}; - struct bpf_event { struct perf_event_header header; u16 type; From b1b510142283c02991f48b27d399852364f7d89b Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:51 +0200 Subject: [PATCH 27/33] libperf: Add PERF_RECORD_BPF_EVENT 'struct bpf_event' to perf/event.h Move the PERF_RECORD_BPF_EVENT event definition to libperf's event.h. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190825181752.722-12-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 11 +++++++++++ tools/perf/util/event.h | 10 ---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index 8c367931cecc5..585c9d82dba39 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -5,6 +5,7 @@ #include #include #include +#include struct mmap_event { struct perf_event_header header; @@ -93,4 +94,14 @@ struct ksymbol_event { char name[KSYM_NAME_LEN]; }; +struct bpf_event { + struct perf_event_header header; + __u16 type; + __u16 flags; + __u32 id; + + /* for bpf_prog types */ + __u8 tag[BPF_TAG_SIZE]; // prog tag +}; + #endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index c4eec1f164ba2..091a0690a2802 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -27,16 +27,6 @@ #define PRI_lx64 PRIx64 #endif -struct bpf_event { - struct perf_event_header header; - u16 type; - u16 flags; - u32 id; - - /* for bpf_prog types */ - u8 tag[BPF_TAG_SIZE]; // prog tag -}; - #define PERF_SAMPLE_MASK \ (PERF_SAMPLE_IP | PERF_SAMPLE_TID | \ PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \ From b1fcd190bb3fc1234dca60390d171a4cc75b21b2 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 25 Aug 2019 20:17:52 +0200 Subject: [PATCH 28/33] libperf: Add PERF_RECORD_SAMPLE 'struct sample_event' to perf/event.h Move the PERF_RECORD_SAMPLE event definition to libperf's event.h header include. In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used events to their generic '__u*' versions. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190825181752.722-13-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 5 +++++ tools/perf/util/event.h | 5 ----- tools/perf/util/evlist.c | 2 +- tools/perf/util/evsel.c | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index 585c9d82dba39..e768a2dfbe536 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -104,4 +104,9 @@ struct bpf_event { __u8 tag[BPF_TAG_SIZE]; // prog tag }; +struct sample_event { + struct perf_event_header header; + __u64 array[]; +}; + #endif /* __LIBPERF_EVENT_H */ diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 091a0690a2802..dee0ee57efc26 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -37,11 +37,6 @@ /* perf sample has 16 bits size limit */ #define PERF_SAMPLE_MAX_SIZE (1 << 16) -struct sample_event { - struct perf_event_header header; - u64 array[]; -}; - struct regs_dump { u64 abi; u64 mask; diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index ff415680fe0a3..47bc54111f57e 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -587,7 +587,7 @@ struct evsel *perf_evlist__id2evsel_strict(struct evlist *evlist, static int perf_evlist__event2id(struct evlist *evlist, union perf_event *event, u64 *id) { - const u64 *array = event->sample.array; + const __u64 *array = event->sample.array; ssize_t n; n = (event->header.size - sizeof(event->header)) >> 3; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 9fadd5857cccd..778262f68d5cf 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2009,7 +2009,7 @@ static int perf_evsel__parse_id_sample(const struct evsel *evsel, struct perf_sample *sample) { u64 type = evsel->core.attr.sample_type; - const u64 *array = event->sample.array; + const __u64 *array = event->sample.array; bool swapped = evsel->needs_swap; union u64_swap u; @@ -2099,7 +2099,7 @@ int perf_evsel__parse_sample(struct evsel *evsel, union perf_event *event, { u64 type = evsel->core.attr.sample_type; bool swapped = evsel->needs_swap; - const u64 *array; + const __u64 *array; u16 max_size = event->header.size; const void *endp = (void *)event + max_size; u64 sz; @@ -2378,7 +2378,7 @@ int perf_evsel__parse_sample_timestamp(struct evsel *evsel, u64 *timestamp) { u64 type = evsel->core.attr.sample_type; - const u64 *array; + const __u64 *array; if (!(type & PERF_SAMPLE_TIME)) return -1; @@ -2529,7 +2529,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 read_format, const struct perf_sample *sample) { - u64 *array; + __u64 *array; size_t sz; /* * used for cross-endian analysis. See git commit 65014ab3 From 69d81f09e1607b577346c0579bf938c1194bff3a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 26 Aug 2019 19:02:31 -0300 Subject: [PATCH 29/33] libperf: Rename the PERF_RECORD_ structs to have a "perf" suffix Even more, to have a "perf_record_" prefix, so that they match the PERF_RECORD_ enum they map to. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-qbabmcz2a0pkzt72liyuz3p8@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/include/perf/event.h | 24 ++++++------- tools/perf/tests/parse-no-sample-id-all.c | 4 +-- tools/perf/util/bpf-event.c | 12 +++---- tools/perf/util/event.h | 30 ++++++++-------- tools/perf/util/evsel.c | 4 +-- tools/perf/util/evsel.h | 2 +- tools/perf/util/intel-bts.c | 2 +- tools/perf/util/namespaces.c | 2 +- tools/perf/util/namespaces.h | 4 +-- tools/perf/util/python.c | 44 +++++++++++------------ tools/perf/util/session.c | 2 +- tools/perf/util/thread.c | 4 +-- tools/perf/util/thread.h | 4 +-- 13 files changed, 69 insertions(+), 69 deletions(-) diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h index e768a2dfbe536..36ad3a4a79e65 100644 --- a/tools/perf/lib/include/perf/event.h +++ b/tools/perf/lib/include/perf/event.h @@ -7,7 +7,7 @@ #include #include -struct mmap_event { +struct perf_record_mmap { struct perf_event_header header; __u32 pid, tid; __u64 start; @@ -16,7 +16,7 @@ struct mmap_event { char filename[PATH_MAX]; }; -struct mmap2_event { +struct perf_record_mmap2 { struct perf_event_header header; __u32 pid, tid; __u64 start; @@ -31,33 +31,33 @@ struct mmap2_event { char filename[PATH_MAX]; }; -struct comm_event { +struct perf_record_comm { struct perf_event_header header; __u32 pid, tid; char comm[16]; }; -struct namespaces_event { +struct perf_record_namespaces { struct perf_event_header header; __u32 pid, tid; __u64 nr_namespaces; struct perf_ns_link_info link_info[]; }; -struct fork_event { +struct perf_record_fork { struct perf_event_header header; __u32 pid, ppid; __u32 tid, ptid; __u64 time; }; -struct lost_event { +struct perf_record_lost { struct perf_event_header header; __u64 id; __u64 lost; }; -struct lost_samples_event { +struct perf_record_lost_samples { struct perf_event_header header; __u64 lost; }; @@ -65,7 +65,7 @@ struct lost_samples_event { /* * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID */ -struct read_event { +struct perf_record_read { struct perf_event_header header; __u32 pid, tid; __u64 value; @@ -74,7 +74,7 @@ struct read_event { __u64 id; }; -struct throttle_event { +struct perf_record_throttle { struct perf_event_header header; __u64 time; __u64 id; @@ -85,7 +85,7 @@ struct throttle_event { #define KSYM_NAME_LEN 256 #endif -struct ksymbol_event { +struct perf_record_ksymbol { struct perf_event_header header; __u64 addr; __u32 len; @@ -94,7 +94,7 @@ struct ksymbol_event { char name[KSYM_NAME_LEN]; }; -struct bpf_event { +struct perf_record_bpf_event { struct perf_event_header header; __u16 type; __u16 flags; @@ -104,7 +104,7 @@ struct bpf_event { __u8 tag[BPF_TAG_SIZE]; // prog tag }; -struct sample_event { +struct perf_record_sample { struct perf_event_header header; __u64 array[]; }; diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c index 396e40d68922f..8284752a60c83 100644 --- a/tools/perf/tests/parse-no-sample-id-all.c +++ b/tools/perf/tests/parse-no-sample-id-all.c @@ -87,10 +87,10 @@ int test__parse_no_sample_id_all(struct test *test __maybe_unused, int subtest _ }, .id = 2, }; - struct mmap_event event3 = { + struct perf_record_mmap event3 = { .header = { .type = PERF_RECORD_MMAP, - .size = sizeof(struct mmap_event), + .size = sizeof(struct perf_record_mmap), }, }; union perf_event *events[] = { diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c index 5c634bcfea7e4..3be8c480fa1f5 100644 --- a/tools/perf/util/bpf-event.c +++ b/tools/perf/util/bpf-event.c @@ -161,8 +161,8 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_session *session, union perf_event *event, struct record_opts *opts) { - struct ksymbol_event *ksymbol_event = &event->ksymbol_event; - struct bpf_event *bpf_event = &event->bpf_event; + struct perf_record_ksymbol *ksymbol_event = &event->ksymbol_event; + struct perf_record_bpf_event *bpf_event = &event->bpf_event; struct bpf_prog_info_linear *info_linear; struct perf_tool *tool = session->tool; struct bpf_prog_info_node *info_node; @@ -230,10 +230,10 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_session *session, __u64 *prog_addrs = (__u64 *)(uintptr_t)(info->jited_ksyms); int name_len; - *ksymbol_event = (struct ksymbol_event){ + *ksymbol_event = (struct perf_record_ksymbol) { .header = { .type = PERF_RECORD_KSYMBOL, - .size = offsetof(struct ksymbol_event, name), + .size = offsetof(struct perf_record_ksymbol, name), }, .addr = prog_addrs[i], .len = prog_lens[i], @@ -254,10 +254,10 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_session *session, if (!opts->no_bpf_event) { /* Synthesize PERF_RECORD_BPF_EVENT */ - *bpf_event = (struct bpf_event){ + *bpf_event = (struct perf_record_bpf_event) { .header = { .type = PERF_RECORD_BPF_EVENT, - .size = sizeof(struct bpf_event), + .size = sizeof(struct perf_record_bpf_event), }, .type = PERF_BPF_EVENT_PROG_LOAD, .flags = 0, diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index dee0ee57efc26..25f5309a34423 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -305,18 +305,18 @@ static inline void *perf_synth__raw_data(void *p) * when possible sends this number in a PERF_RECORD_LOST event. The number of * such "chunks" of lost events is stored in .nr_events[PERF_EVENT_LOST] while * total_lost tells exactly how many events the kernel in fact lost, i.e. it is - * the sum of all struct lost_event.lost fields reported. + * the sum of all struct perf_record_lost.lost fields reported. * * The kernel discards mixed up samples and sends the number in a * PERF_RECORD_LOST_SAMPLES event. The number of lost-samples events is stored * in .nr_events[PERF_RECORD_LOST_SAMPLES] while total_lost_samples tells * exactly how many samples the kernel in fact dropped, i.e. it is the sum of - * all struct lost_samples_event.lost fields reported. + * all struct perf_record_lost_samples.lost fields reported. * * The total_period is needed because by default auto-freq is used, so * multipling nr_events[PERF_EVENT_SAMPLE] by a frequency isn't possible to get * the total number of low level events, it is necessary to to sum all struct - * sample_event.period and stash the result in total_period. + * perf_record_sample.period and stash the result in total_period. */ struct events_stats { u64 total_period; @@ -550,16 +550,18 @@ struct compressed_event { union perf_event { struct perf_event_header header; - struct mmap_event mmap; - struct mmap2_event mmap2; - struct comm_event comm; - struct namespaces_event namespaces; - struct fork_event fork; - struct lost_event lost; - struct lost_samples_event lost_samples; - struct read_event read; - struct throttle_event throttle; - struct sample_event sample; + struct perf_record_mmap mmap; + struct perf_record_mmap2 mmap2; + struct perf_record_comm comm; + struct perf_record_namespaces namespaces; + struct perf_record_fork fork; + struct perf_record_lost lost; + struct perf_record_lost_samples lost_samples; + struct perf_record_read read; + struct perf_record_throttle throttle; + struct perf_record_sample sample; + struct perf_record_bpf_event bpf_event; + struct perf_record_ksymbol ksymbol_event; struct attr_event attr; struct event_update_event event_update; struct event_type_event event_type; @@ -579,8 +581,6 @@ union perf_event { struct stat_round_event stat_round; struct time_conv_event time_conv; struct feature_event feat; - struct ksymbol_event ksymbol_event; - struct bpf_event bpf_event; struct compressed_event pack; }; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 778262f68d5cf..b3cfe120d0975 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -117,7 +117,7 @@ int __perf_evsel__sample_size(u64 sample_type) * * This function returns the position of the event id (PERF_SAMPLE_ID or * PERF_SAMPLE_IDENTIFIER) in a sample event i.e. in the array of struct - * sample_event. + * perf_record_sample. */ static int __perf_evsel__calc_id_pos(u64 sample_type) { @@ -2420,7 +2420,7 @@ int perf_evsel__parse_sample_timestamp(struct evsel *evsel, size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, u64 read_format) { - size_t sz, result = sizeof(struct sample_event); + size_t sz, result = sizeof(struct perf_record_sample); if (type & PERF_SAMPLE_IDENTIFIER) result += sizeof(u64); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 5a351cae66df3..77e07f2486d3c 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -107,7 +107,7 @@ struct xyarray; * show the name used, not some alias. * @id_pos: the position of the event id (PERF_SAMPLE_ID or * PERF_SAMPLE_IDENTIFIER) in a sample event i.e. in the array of - * struct sample_event + * struct perf_record_sample * @is_pos: the position (counting backwards) of the event id (PERF_SAMPLE_ID or * PERF_SAMPLE_IDENTIFIER) in a non-sample event i.e. if sample_id_all * is used there is an id sample appended to non-sample events diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 7eb9e6dc27dd9..8dc6408206b9d 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -818,7 +818,7 @@ static int intel_bts_synth_events(struct intel_bts *bts, * We only use sample types from PERF_SAMPLE_MASK so we can use * __perf_evsel__sample_size() here. */ - bts->branches_event_size = sizeof(struct sample_event) + + bts->branches_event_size = sizeof(struct perf_record_sample) + __perf_evsel__sample_size(attr.sample_type); } diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c index 46d3a77548974..99be15dd2b6b6 100644 --- a/tools/perf/util/namespaces.c +++ b/tools/perf/util/namespaces.c @@ -19,7 +19,7 @@ #include #include -struct namespaces *namespaces__new(struct namespaces_event *event) +struct namespaces *namespaces__new(struct perf_record_namespaces *event) { struct namespaces *namespaces; u64 link_info_size = ((event ? event->nr_namespaces : NR_NAMESPACES) * diff --git a/tools/perf/util/namespaces.h b/tools/perf/util/namespaces.h index 004430c0de938..40edef56cb528 100644 --- a/tools/perf/util/namespaces.h +++ b/tools/perf/util/namespaces.h @@ -17,7 +17,7 @@ int setns(int fd, int nstype); #endif -struct namespaces_event; +struct perf_record_namespaces; struct namespaces { struct list_head list; @@ -25,7 +25,7 @@ struct namespaces { struct perf_ns_link_info link_info[]; }; -struct namespaces *namespaces__new(struct namespaces_event *event); +struct namespaces *namespaces__new(struct perf_record_namespaces *event); void namespaces__free(struct namespaces *namespaces); struct nsinfo { diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index d21e270c7823c..59974e901232f 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -116,12 +116,12 @@ static PyMemberDef pyrf_mmap_event__members[] = { sample_members member_def(perf_event_header, type, T_UINT, "event type"), member_def(perf_event_header, misc, T_UINT, "event misc"), - member_def(mmap_event, pid, T_UINT, "event pid"), - member_def(mmap_event, tid, T_UINT, "event tid"), - member_def(mmap_event, start, T_ULONGLONG, "start of the map"), - member_def(mmap_event, len, T_ULONGLONG, "map length"), - member_def(mmap_event, pgoff, T_ULONGLONG, "page offset"), - member_def(mmap_event, filename, T_STRING_INPLACE, "backing store"), + member_def(perf_record_mmap, pid, T_UINT, "event pid"), + member_def(perf_record_mmap, tid, T_UINT, "event tid"), + member_def(perf_record_mmap, start, T_ULONGLONG, "start of the map"), + member_def(perf_record_mmap, len, T_ULONGLONG, "map length"), + member_def(perf_record_mmap, pgoff, T_ULONGLONG, "page offset"), + member_def(perf_record_mmap, filename, T_STRING_INPLACE, "backing store"), { .name = NULL, }, }; @@ -159,11 +159,11 @@ static char pyrf_task_event__doc[] = PyDoc_STR("perf task (fork/exit) event obje static PyMemberDef pyrf_task_event__members[] = { sample_members member_def(perf_event_header, type, T_UINT, "event type"), - member_def(fork_event, pid, T_UINT, "event pid"), - member_def(fork_event, ppid, T_UINT, "event ppid"), - member_def(fork_event, tid, T_UINT, "event tid"), - member_def(fork_event, ptid, T_UINT, "event ptid"), - member_def(fork_event, time, T_ULONGLONG, "timestamp"), + member_def(perf_record_fork, pid, T_UINT, "event pid"), + member_def(perf_record_fork, ppid, T_UINT, "event ppid"), + member_def(perf_record_fork, tid, T_UINT, "event tid"), + member_def(perf_record_fork, ptid, T_UINT, "event ptid"), + member_def(perf_record_fork, time, T_ULONGLONG, "timestamp"), { .name = NULL, }, }; @@ -194,9 +194,9 @@ static char pyrf_comm_event__doc[] = PyDoc_STR("perf comm event object."); static PyMemberDef pyrf_comm_event__members[] = { sample_members member_def(perf_event_header, type, T_UINT, "event type"), - member_def(comm_event, pid, T_UINT, "event pid"), - member_def(comm_event, tid, T_UINT, "event tid"), - member_def(comm_event, comm, T_STRING_INPLACE, "process name"), + member_def(perf_record_comm, pid, T_UINT, "event pid"), + member_def(perf_record_comm, tid, T_UINT, "event tid"), + member_def(perf_record_comm, comm, T_STRING_INPLACE, "process name"), { .name = NULL, }, }; @@ -223,15 +223,15 @@ static char pyrf_throttle_event__doc[] = PyDoc_STR("perf throttle event object." static PyMemberDef pyrf_throttle_event__members[] = { sample_members member_def(perf_event_header, type, T_UINT, "event type"), - member_def(throttle_event, time, T_ULONGLONG, "timestamp"), - member_def(throttle_event, id, T_ULONGLONG, "event id"), - member_def(throttle_event, stream_id, T_ULONGLONG, "event stream id"), + member_def(perf_record_throttle, time, T_ULONGLONG, "timestamp"), + member_def(perf_record_throttle, id, T_ULONGLONG, "event id"), + member_def(perf_record_throttle, stream_id, T_ULONGLONG, "event stream id"), { .name = NULL, }, }; static PyObject *pyrf_throttle_event__repr(struct pyrf_event *pevent) { - struct throttle_event *te = (struct throttle_event *)(&pevent->event.header + 1); + struct perf_record_throttle *te = (struct perf_record_throttle *)(&pevent->event.header + 1); return _PyUnicode_FromFormat("{ type: %sthrottle, time: %" PRI_lu64 ", id: %" PRI_lu64 ", stream_id: %" PRI_lu64 " }", @@ -253,8 +253,8 @@ static char pyrf_lost_event__doc[] = PyDoc_STR("perf lost event object."); static PyMemberDef pyrf_lost_event__members[] = { sample_members - member_def(lost_event, id, T_ULONGLONG, "event id"), - member_def(lost_event, lost, T_ULONGLONG, "number of lost events"), + member_def(perf_record_lost, id, T_ULONGLONG, "event id"), + member_def(perf_record_lost, lost, T_ULONGLONG, "number of lost events"), { .name = NULL, }, }; @@ -288,8 +288,8 @@ static char pyrf_read_event__doc[] = PyDoc_STR("perf read event object."); static PyMemberDef pyrf_read_event__members[] = { sample_members - member_def(read_event, pid, T_UINT, "event pid"), - member_def(read_event, tid, T_UINT, "event tid"), + member_def(perf_record_read, pid, T_UINT, "event pid"), + member_def(perf_record_read, tid, T_UINT, "event tid"), { .name = NULL, }, }; diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index cb1d8dcd0c195..4bfec9db36d63 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1254,7 +1254,7 @@ static void dump_sample(struct evsel *evsel, union perf_event *event, static void dump_read(struct evsel *evsel, union perf_event *event) { - struct read_event *read_event = &event->read; + struct perf_record_read *read_event = &event->read; u64 read_format; if (!dump_trace) diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index bbf7816cba31c..dbcb9cfb0f2f5 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -169,7 +169,7 @@ struct namespaces *thread__namespaces(struct thread *thread) } static int __thread__set_namespaces(struct thread *thread, u64 timestamp, - struct namespaces_event *event) + struct perf_record_namespaces *event) { struct namespaces *new, *curr = __thread__namespaces(thread); @@ -193,7 +193,7 @@ static int __thread__set_namespaces(struct thread *thread, u64 timestamp, } int thread__set_namespaces(struct thread *thread, u64 timestamp, - struct namespaces_event *event) + struct perf_record_namespaces *event) { int ret; diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index bf06113be4f3f..51bdb9a7af7ff 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h @@ -16,7 +16,7 @@ struct addr_location; struct map; -struct namespaces_event; +struct perf_record_namespaces; struct thread_stack; struct unwind_libunwind_ops; @@ -74,7 +74,7 @@ static inline void thread__exited(struct thread *thread) struct namespaces *thread__namespaces(struct thread *thread); int thread__set_namespaces(struct thread *thread, u64 timestamp, - struct namespaces_event *event); + struct perf_record_namespaces *event); int __thread__set_comm(struct thread *thread, const char *comm, u64 timestamp, bool exec); From ebdba16e95f728e94dba07fe0f1221b0e8efdb9d Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 26 Aug 2019 19:15:18 -0300 Subject: [PATCH 30/33] perf tools: Rename perf_event::ksymbol_event to perf_event::ksymbol Just like all the other meta events, that extra _event suffix is just redundant, ditch it. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Song Liu Link: https://lkml.kernel.org/n/tip-0q8b2xnfs17q0g523oej75s0@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-event.c | 2 +- tools/perf/util/event.c | 6 +++--- tools/perf/util/event.h | 2 +- tools/perf/util/machine.c | 16 ++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c index 3be8c480fa1f5..69795c32ecf35 100644 --- a/tools/perf/util/bpf-event.c +++ b/tools/perf/util/bpf-event.c @@ -161,7 +161,7 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_session *session, union perf_event *event, struct record_opts *opts) { - struct perf_record_ksymbol *ksymbol_event = &event->ksymbol_event; + struct perf_record_ksymbol *ksymbol_event = &event->ksymbol; struct perf_record_bpf_event *bpf_event = &event->bpf_event; struct bpf_prog_info_linear *info_linear; struct perf_tool *tool = session->tool; diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 4447cd25e3f2d..bdeaad434e52c 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1486,9 +1486,9 @@ static size_t perf_event__fprintf_lost(union perf_event *event, FILE *fp) size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp) { return fprintf(fp, " addr %" PRI_lx64 " len %u type %u flags 0x%x name %s\n", - event->ksymbol_event.addr, event->ksymbol_event.len, - event->ksymbol_event.ksym_type, - event->ksymbol_event.flags, event->ksymbol_event.name); + event->ksymbol.addr, event->ksymbol.len, + event->ksymbol.ksym_type, + event->ksymbol.flags, event->ksymbol.name); } size_t perf_event__fprintf_bpf_event(union perf_event *event, FILE *fp) diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 25f5309a34423..34190e01f3077 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -561,7 +561,7 @@ union perf_event { struct perf_record_throttle throttle; struct perf_record_sample sample; struct perf_record_bpf_event bpf_event; - struct perf_record_ksymbol ksymbol_event; + struct perf_record_ksymbol ksymbol; struct attr_event attr; struct event_update_event event_update; struct event_type_event event_type; diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 823aaf7b1b83b..86b7fd24b1e12 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -713,20 +713,20 @@ static int machine__process_ksymbol_register(struct machine *machine, struct symbol *sym; struct map *map; - map = map_groups__find(&machine->kmaps, event->ksymbol_event.addr); + map = map_groups__find(&machine->kmaps, event->ksymbol.addr); if (!map) { - map = dso__new_map(event->ksymbol_event.name); + map = dso__new_map(event->ksymbol.name); if (!map) return -ENOMEM; - map->start = event->ksymbol_event.addr; - map->end = map->start + event->ksymbol_event.len; + map->start = event->ksymbol.addr; + map->end = map->start + event->ksymbol.len; map_groups__insert(&machine->kmaps, map); } sym = symbol__new(map->map_ip(map, map->start), - event->ksymbol_event.len, - 0, 0, event->ksymbol_event.name); + event->ksymbol.len, + 0, 0, event->ksymbol.name); if (!sym) return -ENOMEM; dso__insert_symbol(map->dso, sym); @@ -739,7 +739,7 @@ static int machine__process_ksymbol_unregister(struct machine *machine, { struct map *map; - map = map_groups__find(&machine->kmaps, event->ksymbol_event.addr); + map = map_groups__find(&machine->kmaps, event->ksymbol.addr); if (map) map_groups__remove(&machine->kmaps, map); @@ -753,7 +753,7 @@ int machine__process_ksymbol(struct machine *machine __maybe_unused, if (dump_trace) perf_event__fprintf_ksymbol(event, stdout); - if (event->ksymbol_event.flags & PERF_RECORD_KSYMBOL_FLAGS_UNREGISTER) + if (event->ksymbol.flags & PERF_RECORD_KSYMBOL_FLAGS_UNREGISTER) return machine__process_ksymbol_unregister(machine, event, sample); return machine__process_ksymbol_register(machine, event, sample); From 6a1b359821eb8d929c4dd9f53178da84888d79ec Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 26 Aug 2019 19:20:35 -0300 Subject: [PATCH 31/33] perf tools: Rename perf_event::bpf_event to perf_event::bpf Just like all the other meta events, that extra _event suffix is just redundant, ditch it. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Song Liu Link: https://lkml.kernel.org/n/tip-505qwpaizq1k0t6pk13v1ibd@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/bpf-event.c | 18 ++++++++---------- tools/perf/util/event.c | 3 +-- tools/perf/util/event.h | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c index 69795c32ecf35..28fa2b1ce66ee 100644 --- a/tools/perf/util/bpf-event.c +++ b/tools/perf/util/bpf-event.c @@ -35,7 +35,7 @@ static int machine__process_bpf_event_load(struct machine *machine, struct bpf_prog_info_linear *info_linear; struct bpf_prog_info_node *info_node; struct perf_env *env = machine->env; - int id = event->bpf_event.id; + int id = event->bpf.id; unsigned int i; /* perf-record, no need to handle bpf-event */ @@ -71,7 +71,7 @@ int machine__process_bpf_event(struct machine *machine __maybe_unused, if (dump_trace) perf_event__fprintf_bpf_event(event, stdout); - switch (event->bpf_event.type) { + switch (event->bpf.type) { case PERF_BPF_EVENT_PROG_LOAD: return machine__process_bpf_event_load(machine, event, sample); @@ -83,8 +83,7 @@ int machine__process_bpf_event(struct machine *machine __maybe_unused, */ break; default: - pr_debug("unexpected bpf_event type of %d\n", - event->bpf_event.type); + pr_debug("unexpected bpf_event type of %d\n", event->bpf.type); break; } return 0; @@ -162,7 +161,7 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_session *session, struct record_opts *opts) { struct perf_record_ksymbol *ksymbol_event = &event->ksymbol; - struct perf_record_bpf_event *bpf_event = &event->bpf_event; + struct perf_record_bpf_event *bpf_event = &event->bpf; struct bpf_prog_info_linear *info_linear; struct perf_tool *tool = session->tool; struct bpf_prog_info_node *info_node; @@ -302,7 +301,7 @@ int perf_event__synthesize_bpf_events(struct perf_session *session, int err; int fd; - event = malloc(sizeof(event->bpf_event) + KSYM_NAME_LEN + machine->id_hdr_size); + event = malloc(sizeof(event->bpf) + KSYM_NAME_LEN + machine->id_hdr_size); if (!event) return -1; while (true) { @@ -399,9 +398,9 @@ static int bpf_event__sb_cb(union perf_event *event, void *data) if (event->header.type != PERF_RECORD_BPF_EVENT) return -1; - switch (event->bpf_event.type) { + switch (event->bpf.type) { case PERF_BPF_EVENT_PROG_LOAD: - perf_env__add_bpf_info(env, event->bpf_event.id); + perf_env__add_bpf_info(env, event->bpf.id); case PERF_BPF_EVENT_PROG_UNLOAD: /* @@ -411,8 +410,7 @@ static int bpf_event__sb_cb(union perf_event *event, void *data) */ break; default: - pr_debug("unexpected bpf_event type of %d\n", - event->bpf_event.type); + pr_debug("unexpected bpf_event type of %d\n", event->bpf.type); break; } diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index bdeaad434e52c..17304df44fc20 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1494,8 +1494,7 @@ size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp) size_t perf_event__fprintf_bpf_event(union perf_event *event, FILE *fp) { return fprintf(fp, " type %u, flags %u, id %u\n", - event->bpf_event.type, event->bpf_event.flags, - event->bpf_event.id); + event->bpf.type, event->bpf.flags, event->bpf.id); } size_t perf_event__fprintf(union perf_event *event, FILE *fp) diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 34190e01f3077..7251e2eee4419 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -560,7 +560,7 @@ union perf_event { struct perf_record_read read; struct perf_record_throttle throttle; struct perf_record_sample sample; - struct perf_record_bpf_event bpf_event; + struct perf_record_bpf_event bpf; struct perf_record_ksymbol ksymbol; struct attr_event attr; struct event_update_event event_update; From 3f604b5f61dbff80725392c99827d6617f7bb180 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 26 Aug 2019 19:28:13 -0300 Subject: [PATCH 32/33] perf tool: Rename perf_tool::bpf_event to bpf No need for that _event suffix, do just like all the other meta event handlers and suppress that suffix. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Song Liu Link: https://lkml.kernel.org/n/tip-03spzxtqafbabbbmnm7y4xfx@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-script.c | 4 ++-- tools/perf/util/bpf-event.c | 11 +++++------ tools/perf/util/bpf-event.h | 10 +++++----- tools/perf/util/event.c | 14 +++++++------- tools/perf/util/event.h | 10 +++++----- tools/perf/util/machine.c | 2 +- tools/perf/util/session.c | 6 +++--- tools/perf/util/tool.h | 2 +- 8 files changed, 29 insertions(+), 30 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 6f389b33fbe5f..51e7e6d0eee6f 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2492,8 +2492,8 @@ static int __cmd_script(struct perf_script *script) script->tool.finished_round = process_finished_round_event; } if (script->show_bpf_events) { - script->tool.ksymbol = process_bpf_events; - script->tool.bpf_event = process_bpf_events; + script->tool.ksymbol = process_bpf_events; + script->tool.bpf = process_bpf_events; } if (perf_script__setup_per_event_dump(script)) { diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c index 28fa2b1ce66ee..2d6d500c9af72 100644 --- a/tools/perf/util/bpf-event.c +++ b/tools/perf/util/bpf-event.c @@ -64,12 +64,11 @@ static int machine__process_bpf_event_load(struct machine *machine, return 0; } -int machine__process_bpf_event(struct machine *machine __maybe_unused, - union perf_event *event, - struct perf_sample *sample __maybe_unused) +int machine__process_bpf(struct machine *machine, union perf_event *event, + struct perf_sample *sample) { if (dump_trace) - perf_event__fprintf_bpf_event(event, stdout); + perf_event__fprintf_bpf(event, stdout); switch (event->bpf.type) { case PERF_BPF_EVENT_PROG_LOAD: @@ -83,7 +82,7 @@ int machine__process_bpf_event(struct machine *machine __maybe_unused, */ break; default: - pr_debug("unexpected bpf_event type of %d\n", event->bpf.type); + pr_debug("unexpected bpf event type of %d\n", event->bpf.type); break; } return 0; @@ -410,7 +409,7 @@ static int bpf_event__sb_cb(union perf_event *event, void *data) */ break; default: - pr_debug("unexpected bpf_event type of %d\n", event->bpf.type); + pr_debug("unexpected bpf event type of %d\n", event->bpf.type); break; } diff --git a/tools/perf/util/bpf-event.h b/tools/perf/util/bpf-event.h index 26ab9239f9860..417b78835ea09 100644 --- a/tools/perf/util/bpf-event.h +++ b/tools/perf/util/bpf-event.h @@ -30,8 +30,8 @@ struct btf_node { }; #ifdef HAVE_LIBBPF_SUPPORT -int machine__process_bpf_event(struct machine *machine, union perf_event *event, - struct perf_sample *sample); +int machine__process_bpf(struct machine *machine, union perf_event *event, + struct perf_sample *sample); int perf_event__synthesize_bpf_events(struct perf_session *session, perf_event__handler_t process, @@ -43,9 +43,9 @@ void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info, struct perf_env *env, FILE *fp); #else -static inline int machine__process_bpf_event(struct machine *machine __maybe_unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused) +static inline int machine__process_bpf(struct machine *machine __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused) { return 0; } diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 17304df44fc20..33616ea62a479 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1343,12 +1343,12 @@ int perf_event__process_ksymbol(struct perf_tool *tool __maybe_unused, return machine__process_ksymbol(machine, event, sample); } -int perf_event__process_bpf_event(struct perf_tool *tool __maybe_unused, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine) +int perf_event__process_bpf(struct perf_tool *tool __maybe_unused, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine) { - return machine__process_bpf_event(machine, event, sample); + return machine__process_bpf(machine, event, sample); } size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp) @@ -1491,7 +1491,7 @@ size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp) event->ksymbol.flags, event->ksymbol.name); } -size_t perf_event__fprintf_bpf_event(union perf_event *event, FILE *fp) +size_t perf_event__fprintf_bpf(union perf_event *event, FILE *fp) { return fprintf(fp, " type %u, flags %u, id %u\n", event->bpf.type, event->bpf.flags, event->bpf.id); @@ -1536,7 +1536,7 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp) ret += perf_event__fprintf_ksymbol(event, fp); break; case PERF_RECORD_BPF_EVENT: - ret += perf_event__fprintf_bpf_event(event, fp); + ret += perf_event__fprintf_bpf(event, fp); break; default: ret += fprintf(fp, "\n"); diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 7251e2eee4419..429a3fe52d6c7 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -683,10 +683,10 @@ int perf_event__process_ksymbol(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_bpf_event(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample, - struct machine *machine); +int perf_event__process_bpf(struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine); int perf_tool__process_synth_event(struct perf_tool *tool, union perf_event *event, struct machine *machine, @@ -751,7 +751,7 @@ size_t perf_event__fprintf_thread_map(union perf_event *event, FILE *fp); size_t perf_event__fprintf_cpu_map(union perf_event *event, FILE *fp); size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp); size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp); -size_t perf_event__fprintf_bpf_event(union perf_event *event, FILE *fp); +size_t perf_event__fprintf_bpf(union perf_event *event, FILE *fp); size_t perf_event__fprintf(union perf_event *event, FILE *fp); int kallsyms__get_function_start(const char *kallsyms_filename, diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 86b7fd24b1e12..93483f1764d3e 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1922,7 +1922,7 @@ int machine__process_event(struct machine *machine, union perf_event *event, case PERF_RECORD_KSYMBOL: ret = machine__process_ksymbol(machine, event, sample); break; case PERF_RECORD_BPF_EVENT: - ret = machine__process_bpf_event(machine, event, sample); break; + ret = machine__process_bpf(machine, event, sample); break; default: ret = -1; break; diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 4bfec9db36d63..5786e9c807c54 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -473,8 +473,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool) tool->context_switch = perf_event__process_switch; if (tool->ksymbol == NULL) tool->ksymbol = perf_event__process_ksymbol; - if (tool->bpf_event == NULL) - tool->bpf_event = perf_event__process_bpf_event; + if (tool->bpf == NULL) + tool->bpf = perf_event__process_bpf; if (tool->read == NULL) tool->read = process_event_sample_stub; if (tool->throttle == NULL) @@ -1452,7 +1452,7 @@ static int machines__deliver_event(struct machines *machines, case PERF_RECORD_KSYMBOL: return tool->ksymbol(tool, event, sample, machine); case PERF_RECORD_BPF_EVENT: - return tool->bpf_event(tool, event, sample, machine); + return tool->bpf(tool, event, sample, machine); default: ++evlist->stats.nr_unknown_events; return -1; diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 7f95dd1d6883a..2abbf668b8dec 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -56,7 +56,7 @@ struct perf_tool { throttle, unthrottle, ksymbol, - bpf_event; + bpf; event_attr_op attr; event_attr_op event_update; From 74a1e863eb73dcc9f069b671dfb40650f3832116 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 26 Aug 2019 19:31:06 -0300 Subject: [PATCH 33/33] perf evsel: Rename perf_missing_features::bpf_event to ::bpf No need for that _event suffix, do just like all the other meta events and do away with that. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Song Liu Link: https://lkml.kernel.org/n/tip-bvc83f380dva83wlg52yd10t@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evsel.c | 9 ++++----- tools/perf/util/evsel.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index b3cfe120d0975..fa676355559e1 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1072,8 +1072,7 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts, attr->mmap2 = track && !perf_missing_features.mmap2; attr->comm = track; attr->ksymbol = track && !perf_missing_features.ksymbol; - attr->bpf_event = track && !opts->no_bpf_event && - !perf_missing_features.bpf_event; + attr->bpf_event = track && !opts->no_bpf_event && !perf_missing_features.bpf; if (opts->record_namespaces) attr->namespaces = track; @@ -1803,7 +1802,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus, evsel->core.attr.read_format &= ~(PERF_FORMAT_GROUP|PERF_FORMAT_ID); if (perf_missing_features.ksymbol) evsel->core.attr.ksymbol = 0; - if (perf_missing_features.bpf_event) + if (perf_missing_features.bpf) evsel->core.attr.bpf_event = 0; retry_sample_id: if (perf_missing_features.sample_id_all) @@ -1920,8 +1919,8 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus, perf_missing_features.aux_output = true; pr_debug2("Kernel has no attr.aux_output support, bailing out\n"); goto out_close; - } else if (!perf_missing_features.bpf_event && evsel->core.attr.bpf_event) { - perf_missing_features.bpf_event = true; + } else if (!perf_missing_features.bpf && evsel->core.attr.bpf_event) { + perf_missing_features.bpf = true; pr_debug2("switching off bpf_event\n"); goto fallback_missing_features; } else if (!perf_missing_features.ksymbol && evsel->core.attr.ksymbol) { diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 77e07f2486d3c..fd60caced4fc9 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -194,7 +194,7 @@ struct perf_missing_features { bool write_backward; bool group_read; bool ksymbol; - bool bpf_event; + bool bpf; bool aux_output; };