History

Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf updates from Thomas Gleixner: "Kernel: - Improve kallsyms coverage - Add x86 entry trampolines to kcore - Fix ARM SPE handling - Correct PPC event post processing Tools: - Make the build system more robust - Small fixes and enhancements all over the place - Update kernel ABI header copies - Preparatory work for converting libtraceevnt to a shared library - License cleanups" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (100 commits) tools arch: Update arch/x86/lib/memcpy_64.S copy used in 'perf bench mem memcpy' tools arch x86: Update tools's copy of cpufeatures.h perf python: Fix pyrf_evlist__read_on_cpu() interface perf mmap: Store real cpu number in 'struct perf_mmap' perf tools: Remove ext from struct kmod_path perf tools: Add gzip_is_compressed function perf tools: Add lzma_is_compressed function perf tools: Add is_compressed callback to compressions array perf tools: Move the temp file processing into decompress_kmodule perf tools: Use compression id in decompress_kmodule() perf tools: Store compression id into struct dso perf tools: Add compression id into 'struct kmod_path' perf tools: Make is_supported_compression() static perf tools: Make decompress_to_file() function static perf tools: Get rid of dso__needs_decompress() call in __open_dso() perf tools: Get rid of dso__needs_decompress() call in symbol__disassemble() perf tools: Get rid of dso__needs_decompress() call in read_object_code() tools lib traceevent: Change to SPDX License format perf llvm: Allow passing options to llc in addition to clang perf parser: Improve error message for PMU address filters ...

Linus Torvalds committed 8 years ago

Commit d207ea82 parents 2a8a2b7 66e5db493 files · +3259 −1628Browse files

Unified · Split

93 files
  1. arch/x86/mm/cpu_entry_area.c +33 −0
  2. fs/proc/kcore.c +5 −2
  3. include/linux/kcore.h +13 −0
  4. kernel/kallsyms.c +37 −14
  5. tools/arch/x86/include/asm/cpufeatures.h +2 −1
  6. tools/arch/x86/lib/memcpy_64.S +1 −1
  7. tools/lib/lockdep/Makefile +2 −2
  8. tools/lib/traceevent/Makefile +2 −2
  9. tools/lib/traceevent/event-parse.c +349 −363
  10. tools/lib/traceevent/event-parse.h +229 −229
  11. tools/lib/traceevent/event-plugin.c +36 −50
  12. tools/lib/traceevent/event-utils.h +1 −15
  13. tools/lib/traceevent/kbuffer-parse.c +1 −16
  14. tools/lib/traceevent/parse-filter.c +145 −159
  15. tools/lib/traceevent/parse-utils.c +1 −15
  16. tools/lib/traceevent/plugin_cfg80211.c +10 −10
  17. tools/lib/traceevent/plugin_function.c +17 −17
  18. tools/lib/traceevent/plugin_hrtimer.c +28 −28
  19. tools/lib/traceevent/plugin_jbd2.c +18 −18
  20. tools/lib/traceevent/plugin_kmem.c +33 −33
  21. tools/lib/traceevent/plugin_kvm.c +77 −77
  22. tools/lib/traceevent/plugin_mac80211.c +14 −14
  23. tools/lib/traceevent/plugin_sched_switch.c +30 −30
  24. tools/lib/traceevent/plugin_scsi.c +12 −12
  25. tools/lib/traceevent/plugin_xen.c +10 −10
  26. tools/lib/traceevent/trace-seq.c +1 −15
  27. tools/perf/Documentation/perf-annotate.txt +9 −0
  28. tools/perf/Documentation/perf-report.txt +9 −0
  29. tools/perf/Makefile +2 −2
  30. tools/perf/arch/arm64/util/arm-spe.c +1 −0
  31. tools/perf/arch/powerpc/util/sym-handling.c +3 −1
  32. tools/perf/arch/s390/util/auxtrace.c +1 −0
  33. tools/perf/arch/x86/Makefile +0 −3
  34. tools/perf/builtin-annotate.c +4 −0
  35. tools/perf/builtin-kmem.c +3 −3
  36. tools/perf/builtin-report.c +6 −3
  37. tools/perf/builtin-script.c +3 −3
  38. tools/perf/builtin-trace.c +165 −26
  39. tools/perf/check-headers.sh +14 −3
  40. tools/perf/examples/bpf/augmented_syscalls.c +55 −0
  41. tools/perf/examples/bpf/hello.c +9 −0
  42. tools/perf/examples/bpf/sys_enter_openat.c +33 −0
  43. tools/perf/include/bpf/bpf.h +20 −0
  44. tools/perf/include/bpf/stdio.h +19 −0
  45. tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json +32 −0
  46. tools/perf/pmu-events/arch/arm64/mapfile.csv +1 −0
  47. tools/perf/tests/bitmap.c +0 −2
  48. tools/perf/tests/code-reading.c +3 −1
  49. tools/perf/tests/kmod-path.c +65 −71
  50. tools/perf/tests/mem2node.c +0 −2
  51. tools/perf/ui/browsers/annotate.c +61 −15
  52. tools/perf/util/Build +1 −0
  53. tools/perf/util/annotate.c +183 −122
  54. tools/perf/util/annotate.h +40 −14
  55. tools/perf/util/auxtrace.c +6 −0
  56. tools/perf/util/auxtrace.h +1 −0
  57. tools/perf/util/bpf-loader.c +30 −18
  58. tools/perf/util/bpf-loader.h +17 −6
  59. tools/perf/util/compress.h +2 −0
  60. tools/perf/util/data-convert-bt.c +3 −3
  61. tools/perf/util/dso.c +53 −58
  62. tools/perf/util/dso.h +5 −8
  63. tools/perf/util/event.c +10 −3
  64. tools/perf/util/evlist.c +1 −1
  65. tools/perf/util/evsel.c +1 −1
  66. tools/perf/util/evsel.h +7 −0
  67. tools/perf/util/header.c +3 −6
  68. tools/perf/util/llvm-utils.c +29 −2
  69. tools/perf/util/llvm-utils.h +9 −0
  70. tools/perf/util/lzma.c +20 −0
  71. tools/perf/util/machine.c +3 −1
  72. tools/perf/util/machine.h +1 −1
  73. tools/perf/util/map.c +26 −18
  74. tools/perf/util/map.h +0 −1
  75. tools/perf/util/mmap.c +2 −1
  76. tools/perf/util/mmap.h +2 −1
  77. tools/perf/util/namespaces.c +3 −0
  78. tools/perf/util/parse-events.c +10 −10
  79. tools/perf/util/python.c +24 −6
  80. tools/perf/util/s390-cpumsf-kernel.h +71 −0
  81. tools/perf/util/s390-cpumsf.c +945 −0
  82. tools/perf/util/s390-cpumsf.h +21 −0
  83. tools/perf/util/scripting-engines/trace-event-perl.c +1 −1
  84. tools/perf/util/scripting-engines/trace-event-python.c +3 −3
  85. tools/perf/util/setup.py +9 −1
  86. tools/perf/util/sort.c +8 −8
  87. tools/perf/util/sort.h +1 −1
  88. tools/perf/util/trace-event-parse.c +17 −17
  89. tools/perf/util/trace-event-read.c +22 −22
  90. tools/perf/util/trace-event-scripting.c +2 −2
  91. tools/perf/util/trace-event.c +14 −14
  92. tools/perf/util/trace-event.h +10 −10
  93. tools/perf/util/zlib.c +18 −0
arch/x86/mm/cpu_entry_area.c+33−0
@@ -2,6 +2,8 @@ · 1 unmodified line
22
33 #include <linux/spinlock.h>
44 #include <linux/percpu.h>
5+#include <linux/kallsyms.h>
6+#include <linux/kcore.h>
57
68 #include <asm/cpu_entry_area.h>
79 #include <asm/pgtable.h>
@@ -13,6 +15,7 @@ static DEFINE_PER_CPU_PAGE_ALIGNED(struct entry_stack_page, entry_stack_storage) · 5 unmodified lines
1315 #ifdef CONFIG_X86_64
1416 static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks
1517 [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]);
18+static DEFINE_PER_CPU(struct kcore_list, kcore_entry_trampoline);
1619 #endif
1720
1821 struct cpu_entry_area *get_cpu_entry_area(int cpu)
@@ -146,10 +149,40 @@ static void __init setup_cpu_entry_area(int cpu) · 127 unmodified lines
146149
147150 cea_set_pte(&get_cpu_entry_area(cpu)->entry_trampoline,
148151 __pa_symbol(_entry_trampoline), PAGE_KERNEL_RX);
152+ /*
153+ * The cpu_entry_area alias addresses are not in the kernel binary
154+ * so they do not show up in /proc/kcore normally. This adds entries
155+ * for them manually.
156+ */
157+ kclist_add_remap(&per_cpu(kcore_entry_trampoline, cpu),
158+ _entry_trampoline,
159+ &get_cpu_entry_area(cpu)->entry_trampoline, PAGE_SIZE);
149160 #endif
150161 percpu_setup_debug_store(cpu);
151162 }
152163
164+#ifdef CONFIG_X86_64
165+int arch_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
166+ char *name)
167+{
168+ unsigned int cpu, ncpu = 0;
169+
170+ if (symnum >= num_possible_cpus())
171+ return -EINVAL;
172+
173+ for_each_possible_cpu(cpu) {
174+ if (ncpu++ >= symnum)
175+ break;
176+ }
177+
178+ *value = (unsigned long)&get_cpu_entry_area(cpu)->entry_trampoline;
179+ *type = 't';
180+ strlcpy(name, "__entry_SYSCALL_64_trampoline", KSYM_NAME_LEN);
181+
182+ return 0;
183+}
184+#endif
185+
153186 static __init void setup_cpu_entry_area_ptes(void)
154187 {
155188 #ifdef CONFIG_X86_32
fs/proc/kcore.c+5−2
@@ -359,8 +359,11 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) · 358 unmodified lines
359359 phdr->p_type = PT_LOAD;
360360 phdr->p_flags = PF_R | PF_W | PF_X;
361361 phdr->p_offset = kc_vaddr_to_offset(m->addr) + data_offset;
362− phdr->p_vaddr = (size_t)m->addr;
363− if (m->type == KCORE_RAM)
362+ if (m->type == KCORE_REMAP)
363+ phdr->p_vaddr = (size_t)m->vaddr;
364+ else
365+ phdr->p_vaddr = (size_t)m->addr;
366+ if (m->type == KCORE_RAM || m->type == KCORE_REMAP)
364367 phdr->p_paddr = __pa(m->addr);
365368 else if (m->type == KCORE_TEXT)
366369 phdr->p_paddr = __pa_symbol(m->addr);
include/linux/kcore.h+13−0
@@ -12,11 +12,13 @@ enum kcore_type { · 11 unmodified lines
1212 KCORE_VMEMMAP,
1313 KCORE_USER,
1414 KCORE_OTHER,
15+ KCORE_REMAP,
1516 };
1617
1718 struct kcore_list {
1819 struct list_head list;
1920 unsigned long addr;
21+ unsigned long vaddr;
2022 size_t size;
2123 int type;
2224 };
@@ -36,11 +38,22 @@ struct vmcoredd_node { · 13 unmodified lines
3638
3739 #ifdef CONFIG_PROC_KCORE
3840 void __init kclist_add(struct kcore_list *, void *, size_t, int type);
41+static inline
42+void kclist_add_remap(struct kcore_list *m, void *addr, void *vaddr, size_t sz)
43+{
44+ m->vaddr = (unsigned long)vaddr;
45+ kclist_add(m, addr, sz, KCORE_REMAP);
46+}
3947 #else
4048 static inline
4149 void kclist_add(struct kcore_list *new, void *addr, size_t size, int type)
4250 {
4351 }
52+
53+static inline
54+void kclist_add_remap(struct kcore_list *m, void *addr, void *vaddr, size_t sz)
55+{
56+}
4457 #endif
4558
4659 #endif /* _LINUX_KCORE_H */
kernel/kallsyms.c+37−14
@@ -432,6 +432,7 @@ int sprint_backtrace(char *buffer, unsigned long address) · 431 unmodified lines
432432 /* To avoid using get_symbol_offset for every symbol, we carry prefix along. */
433433 struct kallsym_iter {
434434 loff_t pos;
435+ loff_t pos_arch_end;
435436 loff_t pos_mod_end;
436437 loff_t pos_ftrace_mod_end;
437438 unsigned long value;
@@ -443,9 +444,29 @@ struct kallsym_iter { · 5 unmodified lines
443444 int show_value;
444445 };
445446
447+int __weak arch_get_kallsym(unsigned int symnum, unsigned long *value,
448+ char *type, char *name)
449+{
450+ return -EINVAL;
451+}
452+
453+static int get_ksymbol_arch(struct kallsym_iter *iter)
454+{
455+ int ret = arch_get_kallsym(iter->pos - kallsyms_num_syms,
456+ &iter->value, &iter->type,
457+ iter->name);
458+
459+ if (ret < 0) {
460+ iter->pos_arch_end = iter->pos;
461+ return 0;
462+ }
463+
464+ return 1;
465+}
466+
446467 static int get_ksymbol_mod(struct kallsym_iter *iter)
447468 {
448− int ret = module_get_kallsym(iter->pos - kallsyms_num_syms,
469+ int ret = module_get_kallsym(iter->pos - iter->pos_arch_end,
449470 &iter->value, &iter->type,
450471 iter->name, iter->module_name,
451472 &iter->exported);
@@ -501,32 +522,34 @@ static void reset_iter(struct kallsym_iter *iter, loff_t new_pos) · 49 unmodified lines
501522 iter->nameoff = get_symbol_offset(new_pos);
502523 iter->pos = new_pos;
503524 if (new_pos == 0) {
525+ iter->pos_arch_end = 0;
504526 iter->pos_mod_end = 0;
505527 iter->pos_ftrace_mod_end = 0;
506528 }
507529 }
508530
531+/*
532+ * The end position (last + 1) of each additional kallsyms section is recorded
533+ * in iter->pos_..._end as each section is added, and so can be used to
534+ * determine which get_ksymbol_...() function to call next.
535+ */
509536 static int update_iter_mod(struct kallsym_iter *iter, loff_t pos)
510537 {
511538 iter->pos = pos;
512539
513− if (iter->pos_ftrace_mod_end > 0 &&
514− iter->pos_ftrace_mod_end < iter->pos)
515− return get_ksymbol_bpf(iter);
540+ if ((!iter->pos_arch_end || iter->pos_arch_end > pos) &&
541+ get_ksymbol_arch(iter))
542+ return 1;
516543
517− if (iter->pos_mod_end > 0 &&
518− iter->pos_mod_end < iter->pos) {
519− if (!get_ksymbol_ftrace_mod(iter))
520− return get_ksymbol_bpf(iter);
544+ if ((!iter->pos_mod_end || iter->pos_mod_end > pos) &&
545+ get_ksymbol_mod(iter))
521546 return 1;
522− }
523547
524− if (!get_ksymbol_mod(iter)) {
525− if (!get_ksymbol_ftrace_mod(iter))
526− return get_ksymbol_bpf(iter);
527− }
548+ if ((!iter->pos_ftrace_mod_end || iter->pos_ftrace_mod_end > pos) &&
549+ get_ksymbol_ftrace_mod(iter))
550+ return 1;
528551
529− return 1;
552+ return get_ksymbol_bpf(iter);
530553 }
531554
532555 /* Returns false if pos at or past end of file. */
tools/arch/x86/include/asm/cpufeatures.h+2−1
@@ -220,6 +220,7 @@ · 219 unmodified lines
220220 #define X86_FEATURE_STIBP ( 7*32+27) /* Single Thread Indirect Branch Predictors */
221221 #define X86_FEATURE_ZEN ( 7*32+28) /* "" CPU is AMD family 0x17 (Zen) */
222222 #define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */
223+#define X86_FEATURE_IBRS_ENHANCED ( 7*32+30) /* Enhanced IBRS */
223224
224225 /* Virtualization flags: Linux defined, word 8 */
225226 #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
@@ -230,7 +231,7 @@ · 4 unmodified lines
230231
231232 #define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer VMMCALL to VMCALL */
232233 #define X86_FEATURE_XENPV ( 8*32+16) /* "" Xen paravirtual guest */
233−
234+#define X86_FEATURE_EPT_AD ( 8*32+17) /* Intel Extended Page Table access-dirty bit */
234235
235236 /* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
236237 #define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
tools/arch/x86/lib/memcpy_64.S+1−1
@@ -256,7 +256,7 @@ ENTRY(__memcpy_mcsafe) · 255 unmodified lines
256256
257257 /* Copy successful. Return zero */
258258 .L_done_memcpy_trap:
259− xorq %rax, %rax
259+ xorl %eax, %eax
260260 ret
261261 ENDPROC(__memcpy_mcsafe)
262262 EXPORT_SYMBOL_GPL(__memcpy_mcsafe)
tools/lib/lockdep/Makefile+2−2
@@ -129,12 +129,12 @@ $(OUTPUT)liblockdep.a: $(LIB_IN) · 128 unmodified lines
129129 tags: force
130130 $(RM) tags
131131 find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
132− --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
132+ --regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/'
133133
134134 TAGS: force
135135 $(RM) TAGS
136136 find . -name '*.[ch]' | xargs etags \
137− --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'
137+ --regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/'
138138
139139 define do_install
140140 $(print_install) \
tools/lib/traceevent/Makefile+2−2
@@ -233,12 +233,12 @@ endef · 232 unmodified lines
233233 tags: force
234234 $(RM) tags
235235 find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
236− --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
236+ --regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/'
237237
238238 TAGS: force
239239 $(RM) TAGS
240240 find . -name '*.[ch]' | xargs etags \
241− --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'
241+ --regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/'
242242
243243 define do_install_mkdir
244244 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \
tools/lib/traceevent/event-parse.c+349−363
@@ -1,21 +1,7 @@
1+// SPDX-License-Identifier: LGPL-2.1
12 /*
23 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
34 *
4− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU Lesser General Public
7− * License as published by the Free Software Foundation;
8− * version 2.1 of the License (not later!)
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU Lesser General Public License for more details.
14− *
15− * You should have received a copy of the GNU Lesser General Public
16− * License along with this program; if not, see <http://www.gnu.org/licenses>
17− *
18− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195 *
206 * The parts for function graph printing was taken and modified from the
217 * Linux Kernel that were written by
@@ -73,12 +59,12 @@ static void init_input_buf(const char *buf, unsigned long long size) · 51 unmodified lines
7359 input_buf_ptr = 0;
7460 }
7561
76−const char *pevent_get_input_buf(void)
62+const char *tep_get_input_buf(void)
7763 {
7864 return input_buf;
7965 }
8066
81−unsigned long long pevent_get_input_buf_ptr(void)
67+unsigned long long tep_get_input_buf_ptr(void)
8268 {
8369 return input_buf_ptr;
8470 }
@@ -88,21 +74,21 @@ struct event_handler { · 3 unmodified lines
8874 int id;
8975 const char *sys_name;
9076 const char *event_name;
91− pevent_event_handler_func func;
77+ tep_event_handler_func func;
9278 void *context;
9379 };
9480
95−struct pevent_func_params {
96− struct pevent_func_params *next;
97− enum pevent_func_arg_type type;
81+struct func_params {
82+ struct func_params *next;
83+ enum tep_func_arg_type type;
9884 };
9985
100−struct pevent_function_handler {
101− struct pevent_function_handler *next;
102− enum pevent_func_arg_type ret_type;
86+struct tep_function_handler {
87+ struct tep_function_handler *next;
88+ enum tep_func_arg_type ret_type;
10389 char *name;
104− pevent_func_handler func;
105− struct pevent_func_params *params;
90+ tep_func_handler func;
91+ struct func_params *params;
10692 int nr_args;
10793 };
10894
@@ -110,17 +96,17 @@ static unsigned long long · 1 unmodified line
11096 process_defined_func(struct trace_seq *s, void *data, int size,
11197 struct event_format *event, struct print_arg *arg);
11298
113−static void free_func_handle(struct pevent_function_handler *func);
99+static void free_func_handle(struct tep_function_handler *func);
114100
115101 /**
116− * pevent_buffer_init - init buffer for parsing
102+ * tep_buffer_init - init buffer for parsing
117103 * @buf: buffer to parse
118104 * @size: the size of the buffer
119105 *
120− * For use with pevent_read_token(), this initializes the internal
121− * buffer that pevent_read_token() will parse.
106+ * For use with tep_read_token(), this initializes the internal
107+ * buffer that tep_read_token() will parse.
122108 */
123−void pevent_buffer_init(const char *buf, unsigned long long size)
109+void tep_buffer_init(const char *buf, unsigned long long size)
124110 {
125111 init_input_buf(buf, size);
126112 }
@@ -160,7 +146,7 @@ struct cmdline_list { · 33 unmodified lines
160146 int pid;
161147 };
162148
163−static int cmdline_init(struct pevent *pevent)
149+static int cmdline_init(struct tep_handle *pevent)
164150 {
165151 struct cmdline_list *cmdlist = pevent->cmdlist;
166152 struct cmdline_list *item;
@@ -189,7 +175,7 @@ static int cmdline_init(struct pevent *pevent) · 22 unmodified lines
189175 return 0;
190176 }
191177
192−static const char *find_cmdline(struct pevent *pevent, int pid)
178+static const char *find_cmdline(struct tep_handle *pevent, int pid)
193179 {
194180 const struct cmdline *comm;
195181 struct cmdline key;
@@ -211,14 +197,14 @@ static const char *find_cmdline(struct pevent *pevent, int pid) · 15 unmodified lines
211197 }
212198
213199 /**
214− * pevent_pid_is_registered - return if a pid has a cmdline registered
200+ * tep_pid_is_registered - return if a pid has a cmdline registered
215201 * @pevent: handle for the pevent
216202 * @pid: The pid to check if it has a cmdline registered with.
217203 *
218204 * Returns 1 if the pid has a cmdline mapped to it
219205 * 0 otherwise.
220206 */
221−int pevent_pid_is_registered(struct pevent *pevent, int pid)
207+int tep_pid_is_registered(struct tep_handle *pevent, int pid)
222208 {
223209 const struct cmdline *comm;
224210 struct cmdline key;
@@ -244,7 +230,7 @@ int pevent_pid_is_registered(struct pevent *pevent, int pid) · 19 unmodified lines
244230 * we must add this pid. This is much slower than when cmdlines
245231 * are added before the array is initialized.
246232 */
247−static int add_new_comm(struct pevent *pevent, const char *comm, int pid)
233+static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid)
248234 {
249235 struct cmdline *cmdlines = pevent->cmdlines;
250236 const struct cmdline *cmdline;
@@ -288,7 +274,7 @@ static int add_new_comm(struct pevent *pevent, const char *comm, int pid) · 37 unmodified lines
288274 }
289275
290276 /**
291− * pevent_register_comm - register a pid / comm mapping
277+ * tep_register_comm - register a pid / comm mapping
292278 * @pevent: handle for the pevent
293279 * @comm: the command line to register
294280 * @pid: the pid to map the command line to
@@ -296,7 +282,7 @@ static int add_new_comm(struct pevent *pevent, const char *comm, int pid) · 1 unmodified line
296282 * This adds a mapping to search for command line names with
297283 * a given pid. The comm is duplicated.
298284 */
299−int pevent_register_comm(struct pevent *pevent, const char *comm, int pid)
285+int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid)
300286 {
301287 struct cmdline_list *item;
302288
@@ -324,7 +310,7 @@ int pevent_register_comm(struct pevent *pevent, const char *comm, int pid) · 21 unmodified lines
324310 return 0;
325311 }
326312
327−int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock)
313+int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock)
328314 {
329315 pevent->trace_clock = strdup(trace_clock);
330316 if (!pevent->trace_clock) {
@@ -381,7 +367,7 @@ static int func_bcmp(const void *a, const void *b) · 50 unmodified lines
381367 return 1;
382368 }
383369
384−static int func_map_init(struct pevent *pevent)
370+static int func_map_init(struct tep_handle *pevent)
385371 {
386372 struct func_list *funclist;
387373 struct func_list *item;
@@ -421,7 +407,7 @@ static int func_map_init(struct pevent *pevent) · 33 unmodified lines
421407 }
422408
423409 static struct func_map *
424−__find_func(struct pevent *pevent, unsigned long long addr)
410+__find_func(struct tep_handle *pevent, unsigned long long addr)
425411 {
426412 struct func_map *func;
427413 struct func_map key;
@@ -438,13 +424,13 @@ __find_func(struct pevent *pevent, unsigned long long addr) · 10 unmodified lines
438424 }
439425
440426 struct func_resolver {
441− pevent_func_resolver_t *func;
442− void *priv;
443− struct func_map map;
427+ tep_func_resolver_t *func;
428+ void *priv;
429+ struct func_map map;
444430 };
445431
446432 /**
447− * pevent_set_function_resolver - set an alternative function resolver
433+ * tep_set_function_resolver - set an alternative function resolver
448434 * @pevent: handle for the pevent
449435 * @resolver: function to be used
450436 * @priv: resolver function private state.
@@ -453,8 +439,8 @@ struct func_resolver { · 2 unmodified lines
453439 * keep using it instead of duplicating all the entries inside
454440 * pevent->funclist.
455441 */
456−int pevent_set_function_resolver(struct pevent *pevent,
457− pevent_func_resolver_t *func, void *priv)
442+int tep_set_function_resolver(struct tep_handle *pevent,
443+ tep_func_resolver_t *func, void *priv)
458444 {
459445 struct func_resolver *resolver = malloc(sizeof(*resolver));
460446
@@ -471,20 +457,20 @@ int pevent_set_function_resolver(struct pevent *pevent, · 10 unmodified lines
471457 }
472458
473459 /**
474− * pevent_reset_function_resolver - reset alternative function resolver
460+ * tep_reset_function_resolver - reset alternative function resolver
475461 * @pevent: handle for the pevent
476462 *
477463 * Stop using whatever alternative resolver was set, use the default
478464 * one instead.
479465 */
480−void pevent_reset_function_resolver(struct pevent *pevent)
466+void tep_reset_function_resolver(struct tep_handle *pevent)
481467 {
482468 free(pevent->func_resolver);
483469 pevent->func_resolver = NULL;
484470 }
485471
486472 static struct func_map *
487−find_func(struct pevent *pevent, unsigned long long addr)
473+find_func(struct tep_handle *pevent, unsigned long long addr)
488474 {
489475 struct func_map *map;
490476
@@ -503,7 +489,7 @@ find_func(struct pevent *pevent, unsigned long long addr) · 12 unmodified lines
503489 }
504490
505491 /**
506− * pevent_find_function - find a function by a given address
492+ * tep_find_function - find a function by a given address
507493 * @pevent: handle for the pevent
508494 * @addr: the address to find the function with
509495 *
@@ -511,7 +497,7 @@ find_func(struct pevent *pevent, unsigned long long addr) · 1 unmodified line
511497 * address. Note, the address does not have to be exact, it
512498 * will select the function that would contain the address.
513499 */
514−const char *pevent_find_function(struct pevent *pevent, unsigned long long addr)
500+const char *tep_find_function(struct tep_handle *pevent, unsigned long long addr)
515501 {
516502 struct func_map *map;
517503
@@ -523,16 +509,16 @@ const char *pevent_find_function(struct pevent *pevent, unsigned long long addr) · 5 unmodified lines
523509 }
524510
525511 /**
526− * pevent_find_function_address - find a function address by a given address
512+ * tep_find_function_address - find a function address by a given address
527513 * @pevent: handle for the pevent
528514 * @addr: the address to find the function with
529515 *
530516 * Returns the address the function starts at. This can be used in
531− * conjunction with pevent_find_function to print both the function
517+ * conjunction with tep_find_function to print both the function
532518 * name and the function offset.
533519 */
534520 unsigned long long
535−pevent_find_function_address(struct pevent *pevent, unsigned long long addr)
521+tep_find_function_address(struct tep_handle *pevent, unsigned long long addr)
536522 {
537523 struct func_map *map;
538524
@@ -544,7 +530,7 @@ pevent_find_function_address(struct pevent *pevent, unsigned long long addr) · 5 unmodified lines
544530 }
545531
546532 /**
547− * pevent_register_function - register a function with a given address
533+ * tep_register_function - register a function with a given address
548534 * @pevent: handle for the pevent
549535 * @function: the function name to register
550536 * @addr: the address the function starts at
@@ -553,8 +539,8 @@ pevent_find_function_address(struct pevent *pevent, unsigned long long addr) · 2 unmodified lines
553539 * This registers a function name with an address and module.
554540 * The @func passed in is duplicated.
555541 */
556−int pevent_register_function(struct pevent *pevent, char *func,
557− unsigned long long addr, char *mod)
542+int tep_register_function(struct tep_handle *pevent, char *func,
543+ unsigned long long addr, char *mod)
558544 {
559545 struct func_list *item = malloc(sizeof(*item));
560546
@@ -589,12 +575,12 @@ out_free: · 28 unmodified lines
589575 }
590576
591577 /**
592− * pevent_print_funcs - print out the stored functions
578+ * tep_print_funcs - print out the stored functions
593579 * @pevent: handle for the pevent
594580 *
595581 * This prints out the stored functions.
596582 */
597−void pevent_print_funcs(struct pevent *pevent)
583+void tep_print_funcs(struct tep_handle *pevent)
598584 {
599585 int i;
600586
@@ -636,7 +622,7 @@ static int printk_cmp(const void *a, const void *b) · 35 unmodified lines
636622 return 0;
637623 }
638624
639−static int printk_map_init(struct pevent *pevent)
625+static int printk_map_init(struct tep_handle *pevent)
640626 {
641627 struct printk_list *printklist;
642628 struct printk_list *item;
@@ -668,7 +654,7 @@ static int printk_map_init(struct pevent *pevent) · 25 unmodified lines
668654 }
669655
670656 static struct printk_map *
671−find_printk(struct pevent *pevent, unsigned long long addr)
657+find_printk(struct tep_handle *pevent, unsigned long long addr)
672658 {
673659 struct printk_map *printk;
674660 struct printk_map key;
@@ -685,7 +671,7 @@ find_printk(struct pevent *pevent, unsigned long long addr) · 10 unmodified lines
685671 }
686672
687673 /**
688− * pevent_register_print_string - register a string by its address
674+ * tep_register_print_string - register a string by its address
689675 * @pevent: handle for the pevent
690676 * @fmt: the string format to register
691677 * @addr: the address the string was located at
@@ -693,8 +679,8 @@ find_printk(struct pevent *pevent, unsigned long long addr) · 1 unmodified line
693679 * This registers a string by the address it was stored in the kernel.
694680 * The @fmt passed in is duplicated.
695681 */
696−int pevent_register_print_string(struct pevent *pevent, const char *fmt,
697− unsigned long long addr)
682+int tep_register_print_string(struct tep_handle *pevent, const char *fmt,
683+ unsigned long long addr)
698684 {
699685 struct printk_list *item = malloc(sizeof(*item));
700686 char *p;
@@ -732,12 +718,12 @@ out_free: · 31 unmodified lines
732718 }
733719
734720 /**
735− * pevent_print_printk - print out the stored strings
721+ * tep_print_printk - print out the stored strings
736722 * @pevent: handle for the pevent
737723 *
738724 * This prints the string formats that were stored.
739725 */
740−void pevent_print_printk(struct pevent *pevent)
726+void tep_print_printk(struct tep_handle *pevent)
741727 {
742728 int i;
743729
@@ -756,7 +742,7 @@ static struct event_format *alloc_event(void) · 12 unmodified lines
756742 return calloc(1, sizeof(struct event_format));
757743 }
758744
759−static int add_event(struct pevent *pevent, struct event_format *event)
745+static int add_event(struct tep_handle *pevent, struct event_format *event)
760746 {
761747 int i;
762748 struct event_format **events = realloc(pevent->events, sizeof(event) *
@@ -913,11 +899,11 @@ static int __peek_char(void) · 150 unmodified lines
913899 }
914900
915901 /**
916− * pevent_peek_char - peek at the next character that will be read
902+ * tep_peek_char - peek at the next character that will be read
917903 *
918904 * Returns the next character read, or -1 if end of buffer.
919905 */
920−int pevent_peek_char(void)
906+int tep_peek_char(void)
921907 {
922908 return __peek_char();
923909 }
@@ -1157,24 +1143,24 @@ static enum event_type read_token(char **tok) · 233 unmodified lines
11571143 }
11581144
11591145 /**
1160− * pevent_read_token - access to utilites to use the pevent parser
1146+ * tep_read_token - access to utilites to use the pevent parser
11611147 * @tok: The token to return
11621148 *
11631149 * This will parse tokens from the string given by
1164− * pevent_init_data().
1150+ * tep_init_data().
11651151 *
11661152 * Returns the token type.
11671153 */
1168−enum event_type pevent_read_token(char **tok)
1154+enum event_type tep_read_token(char **tok)
11691155 {
11701156 return read_token(tok);
11711157 }
11721158
11731159 /**
1174− * pevent_free_token - free a token returned by pevent_read_token
1160+ * tep_free_token - free a token returned by tep_read_token
11751161 * @token: the token to free
11761162 */
1177−void pevent_free_token(char *token)
1163+void tep_free_token(char *token)
11781164 {
11791165 free_token(token);
11801166 }
@@ -2101,11 +2087,11 @@ process_entry(struct event_format *event __maybe_unused, struct print_arg *arg, · 920 unmodified lines
21012087 arg->field.name = field;
21022088
21032089 if (is_flag_field) {
2104− arg->field.field = pevent_find_any_field(event, arg->field.name);
2090+ arg->field.field = tep_find_any_field(event, arg->field.name);
21052091 arg->field.field->flags |= FIELD_IS_FLAG;
21062092 is_flag_field = 0;
21072093 } else if (is_symbolic_field) {
2108− arg->field.field = pevent_find_any_field(event, arg->field.name);
2094+ arg->field.field = tep_find_any_field(event, arg->field.name);
21092095 arg->field.field->flags |= FIELD_IS_SYMBOLIC;
21102096 is_symbolic_field = 0;
21112097 }
@@ -2714,7 +2700,7 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char ** · 602 unmodified lines
27142700
27152701 /* Find the field */
27162702
2717− field = pevent_find_field(event, token);
2703+ field = tep_find_field(event, token);
27182704 if (!field)
27192705 goto out_free;
27202706
@@ -2771,7 +2757,7 @@ process_dynamic_array_len(struct event_format *event, struct print_arg *arg, · 50 unmodified lines
27712757 arg->type = PRINT_DYNAMIC_ARRAY_LEN;
27722758
27732759 /* Find the field */
2774− field = pevent_find_field(event, token);
2760+ field = tep_find_field(event, token);
27752761 if (!field)
27762762 goto out_free;
27772763
@@ -2914,10 +2900,10 @@ process_bitmask(struct event_format *event __maybe_unused, struct print_arg *arg · 136 unmodified lines
29142900 return EVENT_ERROR;
29152901 }
29162902
2917−static struct pevent_function_handler *
2918−find_func_handler(struct pevent *pevent, char *func_name)
2903+static struct tep_function_handler *
2904+find_func_handler(struct tep_handle *pevent, char *func_name)
29192905 {
2920− struct pevent_function_handler *func;
2906+ struct tep_function_handler *func;
29212907
29222908 if (!pevent)
29232909 return NULL;
@@ -2930,10 +2916,10 @@ find_func_handler(struct pevent *pevent, char *func_name) · 6 unmodified lines
29302916 return func;
29312917 }
29322918
2933−static void remove_func_handler(struct pevent *pevent, char *func_name)
2919+static void remove_func_handler(struct tep_handle *pevent, char *func_name)
29342920 {
2935− struct pevent_function_handler *func;
2936− struct pevent_function_handler **next;
2921+ struct tep_function_handler *func;
2922+ struct tep_function_handler **next;
29372923
29382924 next = &pevent->func_handlers;
29392925 while ((func = *next)) {
@@ -2947,7 +2933,7 @@ static void remove_func_handler(struct pevent *pevent, char *func_name) · 7 unmodified lines
29472933 }
29482934
29492935 static enum event_type
2950−process_func_handler(struct event_format *event, struct pevent_function_handler *func,
2936+process_func_handler(struct event_format *event, struct tep_function_handler *func,
29512937 struct print_arg *arg, char **tok)
29522938 {
29532939 struct print_arg **next_arg;
@@ -3008,7 +2994,7 @@ static enum event_type · 54 unmodified lines
30082994 process_function(struct event_format *event, struct print_arg *arg,
30092995 char *token, char **tok)
30102996 {
3011− struct pevent_function_handler *func;
2997+ struct tep_function_handler *func;
30122998
30132999 if (strcmp(token, "__print_flags") == 0) {
30143000 free_token(token);
@@ -3265,7 +3251,7 @@ static int event_read_print(struct event_format *event) · 250 unmodified lines
32653251 }
32663252
32673253 /**
3268− * pevent_find_common_field - return a common field by event
3254+ * tep_find_common_field - return a common field by event
32693255 * @event: handle for the event
32703256 * @name: the name of the common field to return
32713257 *
@@ -3273,7 +3259,7 @@ static int event_read_print(struct event_format *event) · 1 unmodified line
32733259 * This only searchs the common fields and not all field.
32743260 */
32753261 struct format_field *
3276−pevent_find_common_field(struct event_format *event, const char *name)
3262+tep_find_common_field(struct event_format *event, const char *name)
32773263 {
32783264 struct format_field *format;
32793265
@@ -3287,7 +3273,7 @@ pevent_find_common_field(struct event_format *event, const char *name) · 7 unmodified lines
32873273 }
32883274
32893275 /**
3290− * pevent_find_field - find a non-common field
3276+ * tep_find_field - find a non-common field
32913277 * @event: handle for the event
32923278 * @name: the name of the non-common field
32933279 *
@@ -3295,7 +3281,7 @@ pevent_find_common_field(struct event_format *event, const char *name) · 1 unmodified line
32953281 * This does not search common fields.
32963282 */
32973283 struct format_field *
3298−pevent_find_field(struct event_format *event, const char *name)
3284+tep_find_field(struct event_format *event, const char *name)
32993285 {
33003286 struct format_field *format;
33013287
@@ -3309,7 +3295,7 @@ pevent_find_field(struct event_format *event, const char *name) · 7 unmodified lines
33093295 }
33103296
33113297 /**
3312− * pevent_find_any_field - find any field by name
3298+ * tep_find_any_field - find any field by name
33133299 * @event: handle for the event
33143300 * @name: the name of the field
33153301 *
@@ -3318,18 +3304,18 @@ pevent_find_field(struct event_format *event, const char *name) · 2 unmodified lines
33183304 * the non-common ones if a common one was not found.
33193305 */
33203306 struct format_field *
3321−pevent_find_any_field(struct event_format *event, const char *name)
3307+tep_find_any_field(struct event_format *event, const char *name)
33223308 {
33233309 struct format_field *format;
33243310
3325− format = pevent_find_common_field(event, name);
3311+ format = tep_find_common_field(event, name);
33263312 if (format)
33273313 return format;
3328− return pevent_find_field(event, name);
3314+ return tep_find_field(event, name);
33293315 }
33303316
33313317 /**
3332− * pevent_read_number - read a number from data
3318+ * tep_read_number - read a number from data
33333319 * @pevent: handle for the pevent
33343320 * @ptr: the raw data
33353321 * @size: the size of the data that holds the number
@@ -3337,8 +3323,8 @@ pevent_find_any_field(struct event_format *event, const char *name) · 1 unmodified line
33373323 * Returns the number (converted to host) from the
33383324 * raw data.
33393325 */
3340−unsigned long long pevent_read_number(struct pevent *pevent,
3341− const void *ptr, int size)
3326+unsigned long long tep_read_number(struct tep_handle *pevent,
3327+ const void *ptr, int size)
33423328 {
33433329 switch (size) {
33443330 case 1:
@@ -3356,7 +3342,7 @@ unsigned long long pevent_read_number(struct pevent *pevent, · 11 unmodified lines
33563342 }
33573343
33583344 /**
3359− * pevent_read_number_field - read a number from data
3345+ * tep_read_number_field - read a number from data
33603346 * @field: a handle to the field
33613347 * @data: the raw data to read
33623348 * @value: the value to place the number in
@@ -3366,8 +3352,8 @@ unsigned long long pevent_read_number(struct pevent *pevent, · 3 unmodified lines
33663352 *
33673353 * Returns 0 on success, -1 otherwise.
33683354 */
3369−int pevent_read_number_field(struct format_field *field, const void *data,
3370− unsigned long long *value)
3355+int tep_read_number_field(struct format_field *field, const void *data,
3356+ unsigned long long *value)
33713357 {
33723358 if (!field)
33733359 return -1;
@@ -3376,15 +3362,15 @@ int pevent_read_number_field(struct format_field *field, const void *data, · 2 unmodified lines
33763362 case 2:
33773363 case 4:
33783364 case 8:
3379− *value = pevent_read_number(field->event->pevent,
3380− data + field->offset, field->size);
3365+ *value = tep_read_number(field->event->pevent,
3366+ data + field->offset, field->size);
33813367 return 0;
33823368 default:
33833369 return -1;
33843370 }
33853371 }
33863372
3387−static int get_common_info(struct pevent *pevent,
3373+static int get_common_info(struct tep_handle *pevent,
33883374 const char *type, int *offset, int *size)
33893375 {
33903376 struct event_format *event;
@@ -3400,7 +3386,7 @@ static int get_common_info(struct pevent *pevent, · 9 unmodified lines
34003386 }
34013387
34023388 event = pevent->events[0];
3403− field = pevent_find_common_field(event, type);
3389+ field = tep_find_common_field(event, type);
34043390 if (!field)
34053391 return -1;
34063392
@@ -3410,7 +3396,7 @@ static int get_common_info(struct pevent *pevent, · 3 unmodified lines
34103396 return 0;
34113397 }
34123398
3413−static int __parse_common(struct pevent *pevent, void *data,
3399+static int __parse_common(struct tep_handle *pevent, void *data,
34143400 int *size, int *offset, const char *name)
34153401 {
34163402 int ret;
@@ -3420,45 +3406,45 @@ static int __parse_common(struct pevent *pevent, void *data, · 3 unmodified lines
34203406 if (ret < 0)
34213407 return ret;
34223408 }
3423− return pevent_read_number(pevent, data + *offset, *size);
3409+ return tep_read_number(pevent, data + *offset, *size);
34243410 }
34253411
3426−static int trace_parse_common_type(struct pevent *pevent, void *data)
3412+static int trace_parse_common_type(struct tep_handle *pevent, void *data)
34273413 {
34283414 return __parse_common(pevent, data,
34293415 &pevent->type_size, &pevent->type_offset,
34303416 "common_type");
34313417 }
34323418
3433−static int parse_common_pid(struct pevent *pevent, void *data)
3419+static int parse_common_pid(struct tep_handle *pevent, void *data)
34343420 {
34353421 return __parse_common(pevent, data,
34363422 &pevent->pid_size, &pevent->pid_offset,
34373423 "common_pid");
34383424 }
34393425
3440−static int parse_common_pc(struct pevent *pevent, void *data)
3426+static int parse_common_pc(struct tep_handle *pevent, void *data)
34413427 {
34423428 return __parse_common(pevent, data,
34433429 &pevent->pc_size, &pevent->pc_offset,
34443430 "common_preempt_count");
34453431 }
34463432
3447−static int parse_common_flags(struct pevent *pevent, void *data)
3433+static int parse_common_flags(struct tep_handle *pevent, void *data)
34483434 {
34493435 return __parse_common(pevent, data,
34503436 &pevent->flags_size, &pevent->flags_offset,
34513437 "common_flags");
34523438 }
34533439
3454−static int parse_common_lock_depth(struct pevent *pevent, void *data)
3440+static int parse_common_lock_depth(struct tep_handle *pevent, void *data)
34553441 {
34563442 return __parse_common(pevent, data,
34573443 &pevent->ld_size, &pevent->ld_offset,
34583444 "common_lock_depth");
34593445 }
34603446
3461−static int parse_common_migrate_disable(struct pevent *pevent, void *data)
3447+static int parse_common_migrate_disable(struct tep_handle *pevent, void *data)
34623448 {
34633449 return __parse_common(pevent, data,
34643450 &pevent->ld_size, &pevent->ld_offset,
@@ -3468,13 +3454,13 @@ static int parse_common_migrate_disable(struct pevent *pevent, void *data) · 3 unmodified lines
34683454 static int events_id_cmp(const void *a, const void *b);
34693455
34703456 /**
3471− * pevent_find_event - find an event by given id
3457+ * tep_find_event - find an event by given id
34723458 * @pevent: a handle to the pevent
34733459 * @id: the id of the event
34743460 *
34753461 * Returns an event that has a given @id.
34763462 */
3477−struct event_format *pevent_find_event(struct pevent *pevent, int id)
3463+struct event_format *tep_find_event(struct tep_handle *pevent, int id)
34783464 {
34793465 struct event_format **eventptr;
34803466 struct event_format key;
@@ -3498,7 +3484,7 @@ struct event_format *pevent_find_event(struct pevent *pevent, int id) · 17 unmodified lines
34983484 }
34993485
35003486 /**
3501− * pevent_find_event_by_name - find an event by given name
3487+ * tep_find_event_by_name - find an event by given name
35023488 * @pevent: a handle to the pevent
35033489 * @sys: the system name to search for
35043490 * @name: the name of the event to search for
@@ -3507,8 +3493,8 @@ struct event_format *pevent_find_event(struct pevent *pevent, int id) · 2 unmodified lines
35073493 * @sys. If @sys is NULL the first event with @name is returned.
35083494 */
35093495 struct event_format *
3510−pevent_find_event_by_name(struct pevent *pevent,
3511− const char *sys, const char *name)
3496+tep_find_event_by_name(struct tep_handle *pevent,
3497+ const char *sys, const char *name)
35123498 {
35133499 struct event_format *event;
35143500 int i;
@@ -3537,7 +3523,7 @@ pevent_find_event_by_name(struct pevent *pevent, · 22 unmodified lines
35373523 static unsigned long long
35383524 eval_num_arg(void *data, int size, struct event_format *event, struct print_arg *arg)
35393525 {
3540− struct pevent *pevent = event->pevent;
3526+ struct tep_handle *pevent = event->pevent;
35413527 unsigned long long val = 0;
35423528 unsigned long long left, right;
35433529 struct print_arg *typearg = NULL;
@@ -3553,14 +3539,14 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg · 9 unmodified lines
35533539 return strtoull(arg->atom.atom, NULL, 0);
35543540 case PRINT_FIELD:
35553541 if (!arg->field.field) {
3556− arg->field.field = pevent_find_any_field(event, arg->field.name);
3542+ arg->field.field = tep_find_any_field(event, arg->field.name);
35573543 if (!arg->field.field)
35583544 goto out_warning_field;
35593545
35603546 }
35613547 /* must be a number */
3562− val = pevent_read_number(pevent, data + arg->field.field->offset,
3563− arg->field.field->size);
3548+ val = tep_read_number(pevent, data + arg->field.field->offset,
3549+ arg->field.field->size);
35643550 break;
35653551 case PRINT_FLAGS:
35663552 case PRINT_SYMBOL:
@@ -3603,7 +3589,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg · 36 unmodified lines
36033589
36043590 switch (larg->type) {
36053591 case PRINT_DYNAMIC_ARRAY:
3606− offset = pevent_read_number(pevent,
3592+ offset = tep_read_number(pevent,
36073593 data + larg->dynarray.field->offset,
36083594 larg->dynarray.field->size);
36093595 if (larg->dynarray.field->elementsize)
@@ -3619,7 +3605,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg · 9 unmodified lines
36193605 case PRINT_FIELD:
36203606 if (!larg->field.field) {
36213607 larg->field.field =
3622− pevent_find_any_field(event, larg->field.name);
3608+ tep_find_any_field(event, larg->field.name);
36233609 if (!larg->field.field) {
36243610 arg = larg;
36253611 goto out_warning_field;
@@ -3632,8 +3618,8 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg · 6 unmodified lines
36323618 default:
36333619 goto default_op; /* oops, all bets off */
36343620 }
3635− val = pevent_read_number(pevent,
3636− data + offset, field_size);
3621+ val = tep_read_number(pevent,
3622+ data + offset, field_size);
36373623 if (typearg)
36383624 val = eval_type(val, typearg, 1);
36393625 break;
@@ -3733,9 +3719,9 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg · 93 unmodified lines
37333719 }
37343720 break;
37353721 case PRINT_DYNAMIC_ARRAY_LEN:
3736− offset = pevent_read_number(pevent,
3737− data + arg->dynarray.field->offset,
3738− arg->dynarray.field->size);
3722+ offset = tep_read_number(pevent,
3723+ data + arg->dynarray.field->offset,
3724+ arg->dynarray.field->size);
37393725 /*
37403726 * The total allocated length of the dynamic array is
37413727 * stored in the top half of the field, and the offset
@@ -3745,9 +3731,9 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg · 3 unmodified lines
37453731 break;
37463732 case PRINT_DYNAMIC_ARRAY:
37473733 /* Without [], we pass the address to the dynamic data */
3748− offset = pevent_read_number(pevent,
3749− data + arg->dynarray.field->offset,
3750− arg->dynarray.field->size);
3734+ offset = tep_read_number(pevent,
3735+ data + arg->dynarray.field->offset,
3736+ arg->dynarray.field->size);
37513737 /*
37523738 * The total allocated length of the dynamic array is
37533739 * stored in the top half of the field, and the offset
@@ -3820,7 +3806,7 @@ static void print_str_to_seq(struct trace_seq *s, const char *format, · 66 unmodified lines
38203806 trace_seq_printf(s, format, str);
38213807 }
38223808
3823−static void print_bitmask_to_seq(struct pevent *pevent,
3809+static void print_bitmask_to_seq(struct tep_handle *pevent,
38243810 struct trace_seq *s, const char *format,
38253811 int len_arg, const void *data, int size)
38263812 {
@@ -3878,7 +3864,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, · 51 unmodified lines
38783864 struct event_format *event, const char *format,
38793865 int len_arg, struct print_arg *arg)
38803866 {
3881− struct pevent *pevent = event->pevent;
3867+ struct tep_handle *pevent = event->pevent;
38823868 struct print_flag_sym *flag;
38833869 struct format_field *field;
38843870 struct printk_map *printk;
@@ -3899,7 +3885,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, · 14 unmodified lines
38993885 case PRINT_FIELD:
39003886 field = arg->field.field;
39013887 if (!field) {
3902− field = pevent_find_any_field(event, arg->field.name);
3888+ field = tep_find_any_field(event, arg->field.name);
39033889 if (!field) {
39043890 str = arg->field.name;
39053891 goto out_warning_field;
@@ -3992,7 +3978,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, · 86 unmodified lines
39923978 case PRINT_HEX_STR:
39933979 if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) {
39943980 unsigned long offset;
3995− offset = pevent_read_number(pevent,
3981+ offset = tep_read_number(pevent,
39963982 data + arg->hex.field->dynarray.field->offset,
39973983 arg->hex.field->dynarray.field->size);
39983984 hex = data + (offset & 0xffff);
@@ -4000,7 +3986,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, · 1 unmodified line
40003986 field = arg->hex.field->field.field;
40013987 if (!field) {
40023988 str = arg->hex.field->field.name;
4003− field = pevent_find_any_field(event, str);
3989+ field = tep_find_any_field(event, str);
40043990 if (!field)
40053991 goto out_warning_field;
40063992 arg->hex.field->field.field = field;
@@ -4023,15 +4009,15 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, · 16 unmodified lines
40234009 unsigned long offset;
40244010 struct format_field *field =
40254011 arg->int_array.field->dynarray.field;
4026− offset = pevent_read_number(pevent,
4027− data + field->offset,
4028− field->size);
4012+ offset = tep_read_number(pevent,
4013+ data + field->offset,
4014+ field->size);
40294015 num = data + (offset & 0xffff);
40304016 } else {
40314017 field = arg->int_array.field->field.field;
40324018 if (!field) {
40334019 str = arg->int_array.field->field.name;
4034− field = pevent_find_any_field(event, str);
4020+ field = tep_find_any_field(event, str);
40354021 if (!field)
40364022 goto out_warning_field;
40374023 arg->int_array.field->field.field = field;
@@ -4071,7 +4057,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, · 33 unmodified lines
40714057 if (arg->string.offset == -1) {
40724058 struct format_field *f;
40734059
4074− f = pevent_find_any_field(event, arg->string.string);
4060+ f = tep_find_any_field(event, arg->string.string);
40754061 arg->string.offset = f->offset;
40764062 }
40774063 str_offset = data2host4(pevent, data + arg->string.offset);
@@ -4089,7 +4075,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, · 11 unmodified lines
40894075 if (arg->bitmask.offset == -1) {
40904076 struct format_field *f;
40914077
4092− f = pevent_find_any_field(event, arg->bitmask.bitmask);
4078+ f = tep_find_any_field(event, arg->bitmask.bitmask);
40934079 arg->bitmask.offset = f->offset;
40944080 }
40954081 bitmask_offset = data2host4(pevent, data + arg->bitmask.offset);
@@ -4132,8 +4118,8 @@ static unsigned long long · 36 unmodified lines
41324118 process_defined_func(struct trace_seq *s, void *data, int size,
41334119 struct event_format *event, struct print_arg *arg)
41344120 {
4135− struct pevent_function_handler *func_handle = arg->func.func;
4136− struct pevent_func_params *param;
4121+ struct tep_function_handler *func_handle = arg->func.func;
4122+ struct func_params *param;
41374123 unsigned long long *args;
41384124 unsigned long long ret;
41394125 struct print_arg *farg;
@@ -4159,12 +4145,12 @@ process_defined_func(struct trace_seq *s, void *data, int size, · 19 unmodified lines
41594145
41604146 for (i = 0; i < func_handle->nr_args; i++) {
41614147 switch (param->type) {
4162− case PEVENT_FUNC_ARG_INT:
4163− case PEVENT_FUNC_ARG_LONG:
4164− case PEVENT_FUNC_ARG_PTR:
4148+ case TEP_FUNC_ARG_INT:
4149+ case TEP_FUNC_ARG_LONG:
4150+ case TEP_FUNC_ARG_PTR:
41654151 args[i] = eval_num_arg(data, size, event, farg);
41664152 break;
4167− case PEVENT_FUNC_ARG_STRING:
4153+ case TEP_FUNC_ARG_STRING:
41684154 trace_seq_init(&str);
41694155 print_str_arg(&str, data, size, event, "%s", -1, farg);
41704156 trace_seq_terminate(&str);
@@ -4227,7 +4213,7 @@ static void free_args(struct print_arg *args) · 56 unmodified lines
42274213
42284214 static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struct event_format *event)
42294215 {
4230− struct pevent *pevent = event->pevent;
4216+ struct tep_handle *pevent = event->pevent;
42314217 struct format_field *field, *ip_field;
42324218 struct print_arg *args, *arg, **next;
42334219 unsigned long long ip, val;
@@ -4239,12 +4225,12 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc · 5 unmodified lines
42394225 ip_field = pevent->bprint_ip_field;
42404226
42414227 if (!field) {
4242− field = pevent_find_field(event, "buf");
4228+ field = tep_find_field(event, "buf");
42434229 if (!field) {
42444230 do_warning_event(event, "can't find buffer field for binary printk");
42454231 return NULL;
42464232 }
4247− ip_field = pevent_find_field(event, "ip");
4233+ ip_field = tep_find_field(event, "ip");
42484234 if (!ip_field) {
42494235 do_warning_event(event, "can't find ip field for binary printk");
42504236 return NULL;
@@ -4253,7 +4239,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc · 2 unmodified lines
42534239 pevent->bprint_ip_field = ip_field;
42544240 }
42554241
4256− ip = pevent_read_number(pevent, data + ip_field->offset, ip_field->size);
4242+ ip = tep_read_number(pevent, data + ip_field->offset, ip_field->size);
42574243
42584244 /*
42594245 * The first arg is the IP pointer.
@@ -4347,7 +4333,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc · 87 unmodified lines
43474333 /* the pointers are always 4 bytes aligned */
43484334 bptr = (void *)(((unsigned long)bptr + 3) &
43494335 ~3);
4350− val = pevent_read_number(pevent, bptr, vsize);
4336+ val = tep_read_number(pevent, bptr, vsize);
43514337 bptr += vsize;
43524338 arg = alloc_arg();
43534339 if (!arg) {
@@ -4404,7 +4390,7 @@ static char * · 50 unmodified lines
44044390 get_bprint_format(void *data, int size __maybe_unused,
44054391 struct event_format *event)
44064392 {
4407− struct pevent *pevent = event->pevent;
4393+ struct tep_handle *pevent = event->pevent;
44084394 unsigned long long addr;
44094395 struct format_field *field;
44104396 struct printk_map *printk;
@@ -4413,7 +4399,7 @@ get_bprint_format(void *data, int size __maybe_unused, · 2 unmodified lines
44134399 field = pevent->bprint_fmt_field;
44144400
44154401 if (!field) {
4416− field = pevent_find_field(event, "fmt");
4402+ field = tep_find_field(event, "fmt");
44174403 if (!field) {
44184404 do_warning_event(event, "can't find format field for binary printk");
44194405 return NULL;
@@ -4421,7 +4407,7 @@ get_bprint_format(void *data, int size __maybe_unused, · 1 unmodified line
44214407 pevent->bprint_fmt_field = field;
44224408 }
44234409
4424− addr = pevent_read_number(pevent, data + field->offset, field->size);
4410+ addr = tep_read_number(pevent, data + field->offset, field->size);
44254411
44264412 printk = find_printk(pevent, addr);
44274413 if (!printk) {
@@ -4457,7 +4443,7 @@ static void print_mac_arg(struct trace_seq *s, int mac, void *data, int size, · 29 unmodified lines
44574443 fmt = "%.2x%.2x%.2x%.2x%.2x%.2x";
44584444 if (!arg->field.field) {
44594445 arg->field.field =
4460− pevent_find_any_field(event, arg->field.name);
4446+ tep_find_any_field(event, arg->field.name);
44614447 if (!arg->field.field) {
44624448 do_warning_event(event, "%s: field %s not found",
44634449 __func__, arg->field.name);
@@ -4607,7 +4593,7 @@ static int print_ipv4_arg(struct trace_seq *s, const char *ptr, char i, · 143 unmodified lines
46074593
46084594 if (!arg->field.field) {
46094595 arg->field.field =
4610− pevent_find_any_field(event, arg->field.name);
4596+ tep_find_any_field(event, arg->field.name);
46114597 if (!arg->field.field) {
46124598 do_warning("%s: field %s not found",
46134599 __func__, arg->field.name);
@@ -4653,7 +4639,7 @@ static int print_ipv6_arg(struct trace_seq *s, const char *ptr, char i, · 39 unmodified lines
46534639
46544640 if (!arg->field.field) {
46554641 arg->field.field =
4656− pevent_find_any_field(event, arg->field.name);
4642+ tep_find_any_field(event, arg->field.name);
46574643 if (!arg->field.field) {
46584644 do_warning("%s: field %s not found",
46594645 __func__, arg->field.name);
@@ -4711,7 +4697,7 @@ static int print_ipsa_arg(struct trace_seq *s, const char *ptr, char i, · 51 unmodified lines
47114697
47124698 if (!arg->field.field) {
47134699 arg->field.field =
4714− pevent_find_any_field(event, arg->field.name);
4700+ tep_find_any_field(event, arg->field.name);
47154701 if (!arg->field.field) {
47164702 do_warning("%s: field %s not found",
47174703 __func__, arg->field.name);
@@ -4800,18 +4786,18 @@ static int is_printable_array(char *p, unsigned int len) · 82 unmodified lines
48004786 return 1;
48014787 }
48024788
4803−void pevent_print_field(struct trace_seq *s, void *data,
4804− struct format_field *field)
4789+void tep_print_field(struct trace_seq *s, void *data,
4790+ struct format_field *field)
48054791 {
48064792 unsigned long long val;
48074793 unsigned int offset, len, i;
4808− struct pevent *pevent = field->event->pevent;
4794+ struct tep_handle *pevent = field->event->pevent;
48094795
48104796 if (field->flags & FIELD_IS_ARRAY) {
48114797 offset = field->offset;
48124798 len = field->size;
48134799 if (field->flags & FIELD_IS_DYNAMIC) {
4814− val = pevent_read_number(pevent, data + offset, len);
4800+ val = tep_read_number(pevent, data + offset, len);
48154801 offset = val;
48164802 len = offset >> 16;
48174803 offset &= 0xffff;
@@ -4831,8 +4817,8 @@ void pevent_print_field(struct trace_seq *s, void *data, · 13 unmodified lines
48314817 field->flags &= ~FIELD_IS_STRING;
48324818 }
48334819 } else {
4834− val = pevent_read_number(pevent, data + field->offset,
4835− field->size);
4820+ val = tep_read_number(pevent, data + field->offset,
4821+ field->size);
48364822 if (field->flags & FIELD_IS_POINTER) {
48374823 trace_seq_printf(s, "0x%llx", val);
48384824 } else if (field->flags & FIELD_IS_SIGNED) {
@@ -4865,22 +4851,22 @@ void pevent_print_field(struct trace_seq *s, void *data, · 26 unmodified lines
48654851 }
48664852 }
48674853
4868−void pevent_print_fields(struct trace_seq *s, void *data,
4869− int size __maybe_unused, struct event_format *event)
4854+void tep_print_fields(struct trace_seq *s, void *data,
4855+ int size __maybe_unused, struct event_format *event)
48704856 {
48714857 struct format_field *field;
48724858
48734859 field = event->format.fields;
48744860 while (field) {
48754861 trace_seq_printf(s, " %s=", field->name);
4876− pevent_print_field(s, data, field);
4862+ tep_print_field(s, data, field);
48774863 field = field->next;
48784864 }
48794865 }
48804866
48814867 static void pretty_print(struct trace_seq *s, void *data, int size, struct event_format *event)
48824868 {
4883− struct pevent *pevent = event->pevent;
4869+ struct tep_handle *pevent = event->pevent;
48844870 struct print_fmt *print_fmt = &event->print_fmt;
48854871 struct print_arg *arg = print_fmt->args;
48864872 struct print_arg *args = NULL;
@@ -4899,7 +4885,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event · 12 unmodified lines
48994885
49004886 if (event->flags & EVENT_FL_FAILED) {
49014887 trace_seq_printf(s, "[FAILED TO PARSE]");
4902− pevent_print_fields(s, data, size, event);
4888+ tep_print_fields(s, data, size, event);
49034889 return;
49044890 }
49054891
@@ -5140,7 +5126,7 @@ out_failed: · 234 unmodified lines
51405126 }
51415127
51425128 /**
5143− * pevent_data_lat_fmt - parse the data for the latency format
5129+ * tep_data_lat_fmt - parse the data for the latency format
51445130 * @pevent: a handle to the pevent
51455131 * @s: the trace_seq to write to
51465132 * @record: the record to read from
@@ -5149,8 +5135,8 @@ out_failed: · 2 unmodified lines
51495135 * need rescheduling, in hard/soft interrupt, preempt count
51505136 * and lock depth) and places it into the trace_seq.
51515137 */
5152−void pevent_data_lat_fmt(struct pevent *pevent,
5153− struct trace_seq *s, struct pevent_record *record)
5138+void tep_data_lat_fmt(struct tep_handle *pevent,
5139+ struct trace_seq *s, struct tep_record *record)
51545140 {
51555141 static int check_lock_depth = 1;
51565142 static int check_migrate_disable = 1;
@@ -5223,55 +5209,55 @@ void pevent_data_lat_fmt(struct pevent *pevent, · 66 unmodified lines
52235209 }
52245210
52255211 /**
5226− * pevent_data_type - parse out the given event type
5212+ * tep_data_type - parse out the given event type
52275213 * @pevent: a handle to the pevent
52285214 * @rec: the record to read from
52295215 *
52305216 * This returns the event id from the @rec.
52315217 */
5232−int pevent_data_type(struct pevent *pevent, struct pevent_record *rec)
5218+int tep_data_type(struct tep_handle *pevent, struct tep_record *rec)
52335219 {
52345220 return trace_parse_common_type(pevent, rec->data);
52355221 }
52365222
52375223 /**
5238− * pevent_data_event_from_type - find the event by a given type
5224+ * tep_data_event_from_type - find the event by a given type
52395225 * @pevent: a handle to the pevent
52405226 * @type: the type of the event.
52415227 *
52425228 * This returns the event form a given @type;
52435229 */
5244−struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type)
5230+struct event_format *tep_data_event_from_type(struct tep_handle *pevent, int type)
52455231 {
5246− return pevent_find_event(pevent, type);
5232+ return tep_find_event(pevent, type);
52475233 }
52485234
52495235 /**
5250− * pevent_data_pid - parse the PID from record
5236+ * tep_data_pid - parse the PID from record
52515237 * @pevent: a handle to the pevent
52525238 * @rec: the record to parse
52535239 *
52545240 * This returns the PID from a record.
52555241 */
5256−int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec)
5242+int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec)
52575243 {
52585244 return parse_common_pid(pevent, rec->data);
52595245 }
52605246
52615247 /**
5262− * pevent_data_preempt_count - parse the preempt count from the record
5248+ * tep_data_preempt_count - parse the preempt count from the record
52635249 * @pevent: a handle to the pevent
52645250 * @rec: the record to parse
52655251 *
52665252 * This returns the preempt count from a record.
52675253 */
5268−int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec)
5254+int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec)
52695255 {
52705256 return parse_common_pc(pevent, rec->data);
52715257 }
52725258
52735259 /**
5274− * pevent_data_flags - parse the latency flags from the record
5260+ * tep_data_flags - parse the latency flags from the record
52755261 * @pevent: a handle to the pevent
52765262 * @rec: the record to parse
52775263 *
@@ -5279,20 +5265,20 @@ int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec) · 1 unmodified line
52795265 *
52805266 * Use trace_flag_type enum for the flags (see event-parse.h).
52815267 */
5282−int pevent_data_flags(struct pevent *pevent, struct pevent_record *rec)
5268+int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec)
52835269 {
52845270 return parse_common_flags(pevent, rec->data);
52855271 }
52865272
52875273 /**
5288− * pevent_data_comm_from_pid - return the command line from PID
5274+ * tep_data_comm_from_pid - return the command line from PID
52895275 * @pevent: a handle to the pevent
52905276 * @pid: the PID of the task to search for
52915277 *
52925278 * This returns a pointer to the command line that has the given
52935279 * @pid.
52945280 */
5295−const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid)
5281+const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid)
52965282 {
52975283 const char *comm;
52985284
@@ -5301,7 +5287,7 @@ const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid) · 2 unmodified lines
53015287 }
53025288
53035289 static struct cmdline *
5304−pid_from_cmdlist(struct pevent *pevent, const char *comm, struct cmdline *next)
5290+pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *next)
53055291 {
53065292 struct cmdline_list *cmdlist = (struct cmdline_list *)next;
53075293
@@ -5317,7 +5303,7 @@ pid_from_cmdlist(struct pevent *pevent, const char *comm, struct cmdline *next) · 9 unmodified lines
53175303 }
53185304
53195305 /**
5320− * pevent_data_pid_from_comm - return the pid from a given comm
5306+ * tep_data_pid_from_comm - return the pid from a given comm
53215307 * @pevent: a handle to the pevent
53225308 * @comm: the cmdline to find the pid from
53235309 * @next: the cmdline structure to find the next comm
@@ -5329,8 +5315,8 @@ pid_from_cmdlist(struct pevent *pevent, const char *comm, struct cmdline *next) · 5 unmodified lines
53295315 * next pid.
53305316 * Also, it does a linear seach, so it may be slow.
53315317 */
5332−struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *comm,
5333− struct cmdline *next)
5318+struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
5319+ struct cmdline *next)
53345320 {
53355321 struct cmdline *cmdline;
53365322
@@ -5365,13 +5351,13 @@ struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *com · 28 unmodified lines
53655351 }
53665352
53675353 /**
5368− * pevent_cmdline_pid - return the pid associated to a given cmdline
5354+ * tep_cmdline_pid - return the pid associated to a given cmdline
53695355 * @cmdline: The cmdline structure to get the pid from
53705356 *
53715357 * Returns the pid for a give cmdline. If @cmdline is NULL, then
53725358 * -1 is returned.
53735359 */
5374−int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline)
5360+int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline)
53755361 {
53765362 struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline;
53775363
@@ -5391,7 +5377,7 @@ int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline) · 13 unmodified lines
53915377 }
53925378
53935379 /**
5394− * pevent_data_comm_from_pid - parse the data into the print format
5380+ * tep_event_info - parse the data into the print format
53955381 * @s: the trace_seq to write to
53965382 * @event: the handle to the event
53975383 * @record: the record to read from
@@ -5399,13 +5385,13 @@ int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline) · 1 unmodified line
53995385 * This parses the raw @data using the given @event information and
54005386 * writes the print format into the trace_seq.
54015387 */
5402−void pevent_event_info(struct trace_seq *s, struct event_format *event,
5403− struct pevent_record *record)
5388+void tep_event_info(struct trace_seq *s, struct event_format *event,
5389+ struct tep_record *record)
54045390 {
54055391 int print_pretty = 1;
54065392
54075393 if (event->pevent->print_raw || (event->flags & EVENT_FL_PRINTRAW))
5408− pevent_print_fields(s, record->data, record->size, event);
5394+ tep_print_fields(s, record->data, record->size, event);
54095395 else {
54105396
54115397 if (event->handler && !(event->flags & EVENT_FL_NOHANDLE))
@@ -5433,7 +5419,7 @@ static bool is_timestamp_in_us(char *trace_clock, bool use_trace_clock) · 21 unmodified lines
54335419 }
54345420
54355421 /**
5436− * pevent_find_event_by_record - return the event from a given record
5422+ * tep_find_event_by_record - return the event from a given record
54375423 * @pevent: a handle to the pevent
54385424 * @record: The record to get the event from
54395425 *
@@ -5441,7 +5427,7 @@ static bool is_timestamp_in_us(char *trace_clock, bool use_trace_clock) · 1 unmodified line
54415427 * is found.
54425428 */
54435429 struct event_format *
5444−pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record)
5430+tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record)
54455431 {
54465432 int type;
54475433
@@ -5452,11 +5438,11 @@ pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record) · 4 unmodified lines
54525438
54535439 type = trace_parse_common_type(pevent, record->data);
54545440
5455− return pevent_find_event(pevent, type);
5441+ return tep_find_event(pevent, type);
54565442 }
54575443
54585444 /**
5459− * pevent_print_event_task - Write the event task comm, pid and CPU
5445+ * tep_print_event_task - Write the event task comm, pid and CPU
54605446 * @pevent: a handle to the pevent
54615447 * @s: the trace_seq to write to
54625448 * @event: the handle to the record's event
@@ -5464,9 +5450,9 @@ pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record) · 1 unmodified line
54645450 *
54655451 * Writes the tasks comm, pid and CPU to @s.
54665452 */
5467−void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s,
5468− struct event_format *event,
5469− struct pevent_record *record)
5453+void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s,
5454+ struct event_format *event,
5455+ struct tep_record *record)
54705456 {
54715457 void *data = record->data;
54725458 const char *comm;
@@ -5483,7 +5469,7 @@ void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s, · 10 unmodified lines
54835469 }
54845470
54855471 /**
5486− * pevent_print_event_time - Write the event timestamp
5472+ * tep_print_event_time - Write the event timestamp
54875473 * @pevent: a handle to the pevent
54885474 * @s: the trace_seq to write to
54895475 * @event: the handle to the record's event
@@ -5492,10 +5478,10 @@ void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s, · 2 unmodified lines
54925478 *
54935479 * Writes the timestamp of the record into @s.
54945480 */
5495−void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
5496− struct event_format *event,
5497− struct pevent_record *record,
5498− bool use_trace_clock)
5481+void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s,
5482+ struct event_format *event,
5483+ struct tep_record *record,
5484+ bool use_trace_clock)
54995485 {
55005486 unsigned long secs;
55015487 unsigned long usecs;
@@ -5511,11 +5497,11 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, · 9 unmodified lines
55115497 }
55125498
55135499 if (pevent->latency_format) {
5514− pevent_data_lat_fmt(pevent, s, record);
5500+ tep_data_lat_fmt(pevent, s, record);
55155501 }
55165502
55175503 if (use_usec_format) {
5518− if (pevent->flags & PEVENT_NSEC_OUTPUT) {
5504+ if (pevent->flags & TEP_NSEC_OUTPUT) {
55195505 usecs = nsecs;
55205506 p = 9;
55215507 } else {
@@ -5534,7 +5520,7 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, · 12 unmodified lines
55345520 }
55355521
55365522 /**
5537− * pevent_print_event_data - Write the event data section
5523+ * tep_print_event_data - Write the event data section
55385524 * @pevent: a handle to the pevent
55395525 * @s: the trace_seq to write to
55405526 * @event: the handle to the record's event
@@ -5542,9 +5528,9 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, · 1 unmodified line
55425528 *
55435529 * Writes the parsing of the record's data to @s.
55445530 */
5545−void pevent_print_event_data(struct pevent *pevent, struct trace_seq *s,
5546− struct event_format *event,
5547− struct pevent_record *record)
5531+void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s,
5532+ struct event_format *event,
5533+ struct tep_record *record)
55485534 {
55495535 static const char *spaces = " "; /* 20 spaces */
55505536 int len;
@@ -5556,15 +5542,15 @@ void pevent_print_event_data(struct pevent *pevent, struct trace_seq *s, · 5 unmodified lines
55565542 if (len < 20)
55575543 trace_seq_printf(s, "%.*s", 20 - len, spaces);
55585544
5559− pevent_event_info(s, event, record);
5545+ tep_event_info(s, event, record);
55605546 }
55615547
5562−void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
5563− struct pevent_record *record, bool use_trace_clock)
5548+void tep_print_event(struct tep_handle *pevent, struct trace_seq *s,
5549+ struct tep_record *record, bool use_trace_clock)
55645550 {
55655551 struct event_format *event;
55665552
5567− event = pevent_find_event_by_record(pevent, record);
5553+ event = tep_find_event_by_record(pevent, record);
55685554 if (!event) {
55695555 int i;
55705556 int type = trace_parse_common_type(pevent, record->data);
@@ -5577,9 +5563,9 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s, · 6 unmodified lines
55775563 return;
55785564 }
55795565
5580− pevent_print_event_task(pevent, s, event, record);
5581− pevent_print_event_time(pevent, s, event, record, use_trace_clock);
5582− pevent_print_event_data(pevent, s, event, record);
5566+ tep_print_event_task(pevent, s, event, record);
5567+ tep_print_event_time(pevent, s, event, record, use_trace_clock);
5568+ tep_print_event_data(pevent, s, event, record);
55835569 }
55845570
55855571 static int events_id_cmp(const void *a, const void *b)
@@ -5630,7 +5616,7 @@ static int events_system_cmp(const void *a, const void *b) · 44 unmodified lines
56305616 return events_id_cmp(a, b);
56315617 }
56325618
5633−struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type sort_type)
5619+struct event_format **tep_list_events(struct tep_handle *pevent, enum event_sort_type sort_type)
56345620 {
56355621 struct event_format **events;
56365622 int (*sort)(const void *a, const void *b);
@@ -5709,13 +5695,13 @@ get_event_fields(const char *type, const char *name, · 72 unmodified lines
57095695 }
57105696
57115697 /**
5712− * pevent_event_common_fields - return a list of common fields for an event
5698+ * tep_event_common_fields - return a list of common fields for an event
57135699 * @event: the event to return the common fields of.
57145700 *
57155701 * Returns an allocated array of fields. The last item in the array is NULL.
57165702 * The array must be freed with free().
57175703 */
5718−struct format_field **pevent_event_common_fields(struct event_format *event)
5704+struct format_field **tep_event_common_fields(struct event_format *event)
57195705 {
57205706 return get_event_fields("common", event->name,
57215707 event->format.nr_common,
@@ -5723,13 +5709,13 @@ struct format_field **pevent_event_common_fields(struct event_format *event) · 1 unmodified line
57235709 }
57245710
57255711 /**
5726− * pevent_event_fields - return a list of event specific fields for an event
5712+ * tep_event_fields - return a list of event specific fields for an event
57275713 * @event: the event to return the fields of.
57285714 *
57295715 * Returns an allocated array of fields. The last item in the array is NULL.
57305716 * The array must be freed with free().
57315717 */
5732−struct format_field **pevent_event_fields(struct event_format *event)
5718+struct format_field **tep_event_fields(struct event_format *event)
57335719 {
57345720 return get_event_fields("event", event->name,
57355721 event->format.nr_fields,
@@ -5930,7 +5916,7 @@ static void parse_header_field(const char *field, · 194 unmodified lines
59305916 }
59315917
59325918 /**
5933− * pevent_parse_header_page - parse the data stored in the header page
5919+ * tep_parse_header_page - parse the data stored in the header page
59345920 * @pevent: the handle to the pevent
59355921 * @buf: the buffer storing the header page format string
59365922 * @size: the size of @buf
@@ -5941,8 +5927,8 @@ static void parse_header_field(const char *field, · 4 unmodified lines
59415927 *
59425928 * /sys/kernel/debug/tracing/events/header_page
59435929 */
5944−int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long size,
5945− int long_size)
5930+int tep_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size,
5931+ int long_size)
59465932 {
59475933 int ignore;
59485934
@@ -5994,7 +5980,7 @@ static void free_handler(struct event_handler *handle) · 45 unmodified lines
59945980 free(handle);
59955981 }
59965982
5997−static int find_event_handle(struct pevent *pevent, struct event_format *event)
5983+static int find_event_handle(struct tep_handle *pevent, struct event_format *event)
59985984 {
59995985 struct event_handler *handle, **next;
60005986
@@ -6023,7 +6009,7 @@ static int find_event_handle(struct pevent *pevent, struct event_format *event) · 22 unmodified lines
60236009 }
60246010
60256011 /**
6026− * __pevent_parse_format - parse the event format
6012+ * __tep_parse_format - parse the event format
60276013 * @buf: the buffer storing the event format string
60286014 * @size: the size of @buf
60296015 * @sys: the system the event belongs to
@@ -6035,9 +6021,9 @@ static int find_event_handle(struct pevent *pevent, struct event_format *event) · 5 unmodified lines
60356021 *
60366022 * /sys/kernel/debug/tracing/events/.../.../format
60376023 */
6038−enum pevent_errno __pevent_parse_format(struct event_format **eventp,
6039− struct pevent *pevent, const char *buf,
6040− unsigned long size, const char *sys)
6024+enum tep_errno __tep_parse_format(struct event_format **eventp,
6025+ struct tep_handle *pevent, const char *buf,
6026+ unsigned long size, const char *sys)
60416027 {
60426028 struct event_format *event;
60436029 int ret;
@@ -6046,12 +6032,12 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, · 2 unmodified lines
60466032
60476033 *eventp = event = alloc_event();
60486034 if (!event)
6049− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
6035+ return TEP_ERRNO__MEM_ALLOC_FAILED;
60506036
60516037 event->name = event_read_name();
60526038 if (!event->name) {
60536039 /* Bad event? */
6054− ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
6040+ ret = TEP_ERRNO__MEM_ALLOC_FAILED;
60556041 goto event_alloc_failed;
60566042 }
60576043
@@ -6064,7 +6050,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, · 6 unmodified lines
60646050
60656051 event->id = event_read_id();
60666052 if (event->id < 0) {
6067− ret = PEVENT_ERRNO__READ_ID_FAILED;
6053+ ret = TEP_ERRNO__READ_ID_FAILED;
60686054 /*
60696055 * This isn't an allocation error actually.
60706056 * But as the ID is critical, just bail out.
@@ -6074,7 +6060,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, · 3 unmodified lines
60746060
60756061 event->system = strdup(sys);
60766062 if (!event->system) {
6077− ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
6063+ ret = TEP_ERRNO__MEM_ALLOC_FAILED;
60786064 goto event_alloc_failed;
60796065 }
60806066
@@ -6083,7 +6069,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, · 2 unmodified lines
60836069
60846070 ret = event_read_format(event);
60856071 if (ret < 0) {
6086− ret = PEVENT_ERRNO__READ_FORMAT_FAILED;
6072+ ret = TEP_ERRNO__READ_FORMAT_FAILED;
60876073 goto event_parse_failed;
60886074 }
60896075
@@ -6098,7 +6084,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, · 8 unmodified lines
60986084 show_warning = 1;
60996085
61006086 if (ret < 0) {
6101− ret = PEVENT_ERRNO__READ_PRINT_FAILED;
6087+ ret = TEP_ERRNO__READ_PRINT_FAILED;
61026088 goto event_parse_failed;
61036089 }
61046090
@@ -6112,14 +6098,14 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, · 7 unmodified lines
61126098 arg = alloc_arg();
61136099 if (!arg) {
61146100 event->flags |= EVENT_FL_FAILED;
6115− return PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED;
6101+ return TEP_ERRNO__OLD_FTRACE_ARG_FAILED;
61166102 }
61176103 arg->type = PRINT_FIELD;
61186104 arg->field.name = strdup(field->name);
61196105 if (!arg->field.name) {
61206106 event->flags |= EVENT_FL_FAILED;
61216107 free_arg(arg);
6122− return PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED;
6108+ return TEP_ERRNO__OLD_FTRACE_ARG_FAILED;
61236109 }
61246110 arg->field.field = field;
61256111 *list = arg;
@@ -6142,20 +6128,20 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, · 16 unmodified lines
61426128 return ret;
61436129 }
61446130
6145−static enum pevent_errno
6146−__pevent_parse_event(struct pevent *pevent,
6147− struct event_format **eventp,
6148− const char *buf, unsigned long size,
6149− const char *sys)
6131+static enum tep_errno
6132+__parse_event(struct tep_handle *pevent,
6133+ struct event_format **eventp,
6134+ const char *buf, unsigned long size,
6135+ const char *sys)
61506136 {
6151− int ret = __pevent_parse_format(eventp, pevent, buf, size, sys);
6137+ int ret = __tep_parse_format(eventp, pevent, buf, size, sys);
61526138 struct event_format *event = *eventp;
61536139
61546140 if (event == NULL)
61556141 return ret;
61566142
61576143 if (pevent && add_event(pevent, event)) {
6158− ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
6144+ ret = TEP_ERRNO__MEM_ALLOC_FAILED;
61596145 goto event_add_failed;
61606146 }
61616147
@@ -6166,12 +6152,12 @@ __pevent_parse_event(struct pevent *pevent, · 4 unmodified lines
61666152 return 0;
61676153
61686154 event_add_failed:
6169− pevent_free_format(event);
6155+ tep_free_format(event);
61706156 return ret;
61716157 }
61726158
61736159 /**
6174− * pevent_parse_format - parse the event format
6160+ * tep_parse_format - parse the event format
61756161 * @pevent: the handle to the pevent
61766162 * @eventp: returned format
61776163 * @buf: the buffer storing the event format string
@@ -6185,16 +6171,16 @@ event_add_failed: · 7 unmodified lines
61856171 *
61866172 * /sys/kernel/debug/tracing/events/.../.../format
61876173 */
6188−enum pevent_errno pevent_parse_format(struct pevent *pevent,
6189− struct event_format **eventp,
6190− const char *buf,
6191− unsigned long size, const char *sys)
6174+enum tep_errno tep_parse_format(struct tep_handle *pevent,
6175+ struct event_format **eventp,
6176+ const char *buf,
6177+ unsigned long size, const char *sys)
61926178 {
6193− return __pevent_parse_event(pevent, eventp, buf, size, sys);
6179+ return __parse_event(pevent, eventp, buf, size, sys);
61946180 }
61956181
61966182 /**
6197− * pevent_parse_event - parse the event format
6183+ * tep_parse_event - parse the event format
61986184 * @pevent: the handle to the pevent
61996185 * @buf: the buffer storing the event format string
62006186 * @size: the size of @buf
@@ -6207,22 +6193,22 @@ enum pevent_errno pevent_parse_format(struct pevent *pevent, · 6 unmodified lines
62076193 *
62086194 * /sys/kernel/debug/tracing/events/.../.../format
62096195 */
6210−enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
6211− unsigned long size, const char *sys)
6196+enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf,
6197+ unsigned long size, const char *sys)
62126198 {
62136199 struct event_format *event = NULL;
6214− return __pevent_parse_event(pevent, &event, buf, size, sys);
6200+ return __parse_event(pevent, &event, buf, size, sys);
62156201 }
62166202
62176203 #undef _PE
62186204 #define _PE(code, str) str
6219−static const char * const pevent_error_str[] = {
6220− PEVENT_ERRORS
6205+static const char * const tep_error_str[] = {
6206+ TEP_ERRORS
62216207 };
62226208 #undef _PE
62236209
6224−int pevent_strerror(struct pevent *pevent __maybe_unused,
6225− enum pevent_errno errnum, char *buf, size_t buflen)
6210+int tep_strerror(struct tep_handle *pevent __maybe_unused,
6211+ enum tep_errno errnum, char *buf, size_t buflen)
62266212 {
62276213 int idx;
62286214 const char *msg;
@@ -6232,19 +6218,19 @@ int pevent_strerror(struct pevent *pevent __maybe_unused, · 3 unmodified lines
62326218 return 0;
62336219 }
62346220
6235− if (errnum <= __PEVENT_ERRNO__START ||
6236− errnum >= __PEVENT_ERRNO__END)
6221+ if (errnum <= __TEP_ERRNO__START ||
6222+ errnum >= __TEP_ERRNO__END)
62376223 return -1;
62386224
6239− idx = errnum - __PEVENT_ERRNO__START - 1;
6240− msg = pevent_error_str[idx];
6225+ idx = errnum - __TEP_ERRNO__START - 1;
6226+ msg = tep_error_str[idx];
62416227 snprintf(buf, buflen, "%s", msg);
62426228
62436229 return 0;
62446230 }
62456231
62466232 int get_field_val(struct trace_seq *s, struct format_field *field,
6247− const char *name, struct pevent_record *record,
6233+ const char *name, struct tep_record *record,
62486234 unsigned long long *val, int err)
62496235 {
62506236 if (!field) {
@@ -6253,7 +6239,7 @@ int get_field_val(struct trace_seq *s, struct format_field *field, · 2 unmodified lines
62536239 return -1;
62546240 }
62556241
6256− if (pevent_read_number_field(field, record->data, val)) {
6242+ if (tep_read_number_field(field, record->data, val)) {
62576243 if (err)
62586244 trace_seq_printf(s, " %s=INVALID", name);
62596245 return -1;
@@ -6263,7 +6249,7 @@ int get_field_val(struct trace_seq *s, struct format_field *field, · 3 unmodified lines
62636249 }
62646250
62656251 /**
6266− * pevent_get_field_raw - return the raw pointer into the data field
6252+ * tep_get_field_raw - return the raw pointer into the data field
62676253 * @s: The seq to print to on error
62686254 * @event: the event that the field is for
62696255 * @name: The name of the field
@@ -6276,9 +6262,9 @@ int get_field_val(struct trace_seq *s, struct format_field *field, · 6 unmodified lines
62766262 *
62776263 * On failure, it returns NULL.
62786264 */
6279−void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
6280− const char *name, struct pevent_record *record,
6281− int *len, int err)
6265+void *tep_get_field_raw(struct trace_seq *s, struct event_format *event,
6266+ const char *name, struct tep_record *record,
6267+ int *len, int err)
62826268 {
62836269 struct format_field *field;
62846270 void *data = record->data;
@@ -6288,7 +6274,7 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, · 3 unmodified lines
62886274 if (!event)
62896275 return NULL;
62906276
6291− field = pevent_find_field(event, name);
6277+ field = tep_find_field(event, name);
62926278
62936279 if (!field) {
62946280 if (err)
@@ -6302,7 +6288,7 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, · 7 unmodified lines
63026288
63036289 offset = field->offset;
63046290 if (field->flags & FIELD_IS_DYNAMIC) {
6305− offset = pevent_read_number(event->pevent,
6291+ offset = tep_read_number(event->pevent,
63066292 data + offset, field->size);
63076293 *len = offset >> 16;
63086294 offset &= 0xffff;
@@ -6313,7 +6299,7 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, · 4 unmodified lines
63136299 }
63146300
63156301 /**
6316− * pevent_get_field_val - find a field and return its value
6302+ * tep_get_field_val - find a field and return its value
63176303 * @s: The seq to print to on error
63186304 * @event: the event that the field is for
63196305 * @name: The name of the field
@@ -6323,22 +6309,22 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, · 3 unmodified lines
63236309 *
63246310 * Returns 0 on success -1 on field not found.
63256311 */
6326−int pevent_get_field_val(struct trace_seq *s, struct event_format *event,
6327− const char *name, struct pevent_record *record,
6328− unsigned long long *val, int err)
6312+int tep_get_field_val(struct trace_seq *s, struct event_format *event,
6313+ const char *name, struct tep_record *record,
6314+ unsigned long long *val, int err)
63296315 {
63306316 struct format_field *field;
63316317
63326318 if (!event)
63336319 return -1;
63346320
6335− field = pevent_find_field(event, name);
6321+ field = tep_find_field(event, name);
63366322
63376323 return get_field_val(s, field, name, record, val, err);
63386324 }
63396325
63406326 /**
6341− * pevent_get_common_field_val - find a common field and return its value
6327+ * tep_get_common_field_val - find a common field and return its value
63426328 * @s: The seq to print to on error
63436329 * @event: the event that the field is for
63446330 * @name: The name of the field
@@ -6348,22 +6334,22 @@ int pevent_get_field_val(struct trace_seq *s, struct event_format *event, · 3 unmodified lines
63486334 *
63496335 * Returns 0 on success -1 on field not found.
63506336 */
6351−int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event,
6352− const char *name, struct pevent_record *record,
6353− unsigned long long *val, int err)
6337+int tep_get_common_field_val(struct trace_seq *s, struct event_format *event,
6338+ const char *name, struct tep_record *record,
6339+ unsigned long long *val, int err)
63546340 {
63556341 struct format_field *field;
63566342
63576343 if (!event)
63586344 return -1;
63596345
6360− field = pevent_find_common_field(event, name);
6346+ field = tep_find_common_field(event, name);
63616347
63626348 return get_field_val(s, field, name, record, val, err);
63636349 }
63646350
63656351 /**
6366− * pevent_get_any_field_val - find a any field and return its value
6352+ * tep_get_any_field_val - find a any field and return its value
63676353 * @s: The seq to print to on error
63686354 * @event: the event that the field is for
63696355 * @name: The name of the field
@@ -6373,22 +6359,22 @@ int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event, · 3 unmodified lines
63736359 *
63746360 * Returns 0 on success -1 on field not found.
63756361 */
6376−int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event,
6377− const char *name, struct pevent_record *record,
6378− unsigned long long *val, int err)
6362+int tep_get_any_field_val(struct trace_seq *s, struct event_format *event,
6363+ const char *name, struct tep_record *record,
6364+ unsigned long long *val, int err)
63796365 {
63806366 struct format_field *field;
63816367
63826368 if (!event)
63836369 return -1;
63846370
6385− field = pevent_find_any_field(event, name);
6371+ field = tep_find_any_field(event, name);
63866372
63876373 return get_field_val(s, field, name, record, val, err);
63886374 }
63896375
63906376 /**
6391− * pevent_print_num_field - print a field and a format
6377+ * tep_print_num_field - print a field and a format
63926378 * @s: The seq to print to
63936379 * @fmt: The printf format to print the field with.
63946380 * @event: the event that the field is for
@@ -6398,17 +6384,17 @@ int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event, · 3 unmodified lines
63986384 *
63996385 * Returns: 0 on success, -1 field not found, or 1 if buffer is full.
64006386 */
6401−int pevent_print_num_field(struct trace_seq *s, const char *fmt,
6402− struct event_format *event, const char *name,
6403− struct pevent_record *record, int err)
6387+int tep_print_num_field(struct trace_seq *s, const char *fmt,
6388+ struct event_format *event, const char *name,
6389+ struct tep_record *record, int err)
64046390 {
6405− struct format_field *field = pevent_find_field(event, name);
6391+ struct format_field *field = tep_find_field(event, name);
64066392 unsigned long long val;
64076393
64086394 if (!field)
64096395 goto failed;
64106396
6411− if (pevent_read_number_field(field, record->data, &val))
6397+ if (tep_read_number_field(field, record->data, &val))
64126398 goto failed;
64136399
64146400 return trace_seq_printf(s, fmt, val);
@@ -6420,7 +6406,7 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt, · 5 unmodified lines
64206406 }
64216407
64226408 /**
6423− * pevent_print_func_field - print a field and a format for function pointers
6409+ * tep_print_func_field - print a field and a format for function pointers
64246410 * @s: The seq to print to
64256411 * @fmt: The printf format to print the field with.
64266412 * @event: the event that the field is for
@@ -6430,12 +6416,12 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt, · 3 unmodified lines
64306416 *
64316417 * Returns: 0 on success, -1 field not found, or 1 if buffer is full.
64326418 */
6433−int pevent_print_func_field(struct trace_seq *s, const char *fmt,
6434− struct event_format *event, const char *name,
6435− struct pevent_record *record, int err)
6419+int tep_print_func_field(struct trace_seq *s, const char *fmt,
6420+ struct event_format *event, const char *name,
6421+ struct tep_record *record, int err)
64366422 {
6437− struct format_field *field = pevent_find_field(event, name);
6438− struct pevent *pevent = event->pevent;
6423+ struct format_field *field = tep_find_field(event, name);
6424+ struct tep_handle *pevent = event->pevent;
64396425 unsigned long long val;
64406426 struct func_map *func;
64416427 char tmp[128];
@@ -6443,7 +6429,7 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt, · 1 unmodified line
64436429 if (!field)
64446430 goto failed;
64456431
6446− if (pevent_read_number_field(field, record->data, &val))
6432+ if (tep_read_number_field(field, record->data, &val))
64476433 goto failed;
64486434
64496435 func = find_func(pevent, val);
@@ -6461,9 +6447,9 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt, · 11 unmodified lines
64616447 return -1;
64626448 }
64636449
6464−static void free_func_handle(struct pevent_function_handler *func)
6450+static void free_func_handle(struct tep_function_handler *func)
64656451 {
6466− struct pevent_func_params *params;
6452+ struct func_params *params;
64676453
64686454 free(func->name);
64696455
@@ -6477,29 +6463,29 @@ static void free_func_handle(struct pevent_function_handler *func) · 7 unmodified lines
64776463 }
64786464
64796465 /**
6480− * pevent_register_print_function - register a helper function
6466+ * tep_register_print_function - register a helper function
64816467 * @pevent: the handle to the pevent
64826468 * @func: the function to process the helper function
64836469 * @ret_type: the return type of the helper function
64846470 * @name: the name of the helper function
6485− * @parameters: A list of enum pevent_func_arg_type
6471+ * @parameters: A list of enum tep_func_arg_type
64866472 *
64876473 * Some events may have helper functions in the print format arguments.
64886474 * This allows a plugin to dynamically create a way to process one
64896475 * of these functions.
64906476 *
6491− * The @parameters is a variable list of pevent_func_arg_type enums that
6492− * must end with PEVENT_FUNC_ARG_VOID.
6477+ * The @parameters is a variable list of tep_func_arg_type enums that
6478+ * must end with TEP_FUNC_ARG_VOID.
64936479 */
6494−int pevent_register_print_function(struct pevent *pevent,
6495− pevent_func_handler func,
6496− enum pevent_func_arg_type ret_type,
6497− char *name, ...)
6498−{
6499− struct pevent_function_handler *func_handle;
6500− struct pevent_func_params **next_param;
6501− struct pevent_func_params *param;
6502− enum pevent_func_arg_type type;
6480+int tep_register_print_function(struct tep_handle *pevent,
6481+ tep_func_handler func,
6482+ enum tep_func_arg_type ret_type,
6483+ char *name, ...)
6484+{
6485+ struct tep_function_handler *func_handle;
6486+ struct func_params **next_param;
6487+ struct func_params *param;
6488+ enum tep_func_arg_type type;
65036489 va_list ap;
65046490 int ret;
65056491
@@ -6517,7 +6503,7 @@ int pevent_register_print_function(struct pevent *pevent, · 11 unmodified lines
65176503 func_handle = calloc(1, sizeof(*func_handle));
65186504 if (!func_handle) {
65196505 do_warning("Failed to allocate function handler");
6520− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
6506+ return TEP_ERRNO__MEM_ALLOC_FAILED;
65216507 }
65226508
65236509 func_handle->ret_type = ret_type;
@@ -6526,26 +6512,26 @@ int pevent_register_print_function(struct pevent *pevent, · 2 unmodified lines
65266512 if (!func_handle->name) {
65276513 do_warning("Failed to allocate function name");
65286514 free(func_handle);
6529− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
6515+ return TEP_ERRNO__MEM_ALLOC_FAILED;
65306516 }
65316517
65326518 next_param = &(func_handle->params);
65336519 va_start(ap, name);
65346520 for (;;) {
6535− type = va_arg(ap, enum pevent_func_arg_type);
6536− if (type == PEVENT_FUNC_ARG_VOID)
6521+ type = va_arg(ap, enum tep_func_arg_type);
6522+ if (type == TEP_FUNC_ARG_VOID)
65376523 break;
65386524
6539− if (type >= PEVENT_FUNC_ARG_MAX_TYPES) {
6525+ if (type >= TEP_FUNC_ARG_MAX_TYPES) {
65406526 do_warning("Invalid argument type %d", type);
6541− ret = PEVENT_ERRNO__INVALID_ARG_TYPE;
6527+ ret = TEP_ERRNO__INVALID_ARG_TYPE;
65426528 goto out_free;
65436529 }
65446530
65456531 param = malloc(sizeof(*param));
65466532 if (!param) {
65476533 do_warning("Failed to allocate function param");
6548− ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
6534+ ret = TEP_ERRNO__MEM_ALLOC_FAILED;
65496535 goto out_free;
65506536 }
65516537 param->type = type;
@@ -6569,7 +6555,7 @@ int pevent_register_print_function(struct pevent *pevent, · 17 unmodified lines
65696555 }
65706556
65716557 /**
6572− * pevent_unregister_print_function - unregister a helper function
6558+ * tep_unregister_print_function - unregister a helper function
65736559 * @pevent: the handle to the pevent
65746560 * @func: the function to process the helper function
65756561 * @name: the name of the helper function
@@ -6578,10 +6564,10 @@ int pevent_register_print_function(struct pevent *pevent, · 2 unmodified lines
65786564 *
65796565 * Returns 0 if the handler was removed successully, -1 otherwise.
65806566 */
6581−int pevent_unregister_print_function(struct pevent *pevent,
6582− pevent_func_handler func, char *name)
6567+int tep_unregister_print_function(struct tep_handle *pevent,
6568+ tep_func_handler func, char *name)
65836569 {
6584− struct pevent_function_handler *func_handle;
6570+ struct tep_function_handler *func_handle;
65856571
65866572 func_handle = find_func_handler(pevent, name);
65876573 if (func_handle && func_handle->func == func) {
@@ -6591,15 +6577,15 @@ int pevent_unregister_print_function(struct pevent *pevent, · 3 unmodified lines
65916577 return -1;
65926578 }
65936579
6594−static struct event_format *pevent_search_event(struct pevent *pevent, int id,
6595− const char *sys_name,
6596− const char *event_name)
6580+static struct event_format *search_event(struct tep_handle *pevent, int id,
6581+ const char *sys_name,
6582+ const char *event_name)
65976583 {
65986584 struct event_format *event;
65996585
66006586 if (id >= 0) {
66016587 /* search by id */
6602− event = pevent_find_event(pevent, id);
6588+ event = tep_find_event(pevent, id);
66036589 if (!event)
66046590 return NULL;
66056591 if (event_name && (strcmp(event_name, event->name) != 0))
@@ -6607,7 +6593,7 @@ static struct event_format *pevent_search_event(struct pevent *pevent, int id, · 1 unmodified line
66076593 if (sys_name && (strcmp(sys_name, event->system) != 0))
66086594 return NULL;
66096595 } else {
6610− event = pevent_find_event_by_name(pevent, sys_name, event_name);
6596+ event = tep_find_event_by_name(pevent, sys_name, event_name);
66116597 if (!event)
66126598 return NULL;
66136599 }
@@ -6615,7 +6601,7 @@ static struct event_format *pevent_search_event(struct pevent *pevent, int id, · 1 unmodified line
66156601 }
66166602
66176603 /**
6618− * pevent_register_event_handler - register a way to parse an event
6604+ * tep_register_event_handler - register a way to parse an event
66196605 * @pevent: the handle to the pevent
66206606 * @id: the id of the event to register
66216607 * @sys_name: the system name the event belongs to
@@ -6631,14 +6617,14 @@ static struct event_format *pevent_search_event(struct pevent *pevent, int id, · 9 unmodified lines
66316617 * If @id is >= 0, then it is used to find the event.
66326618 * else @sys_name and @event_name are used.
66336619 */
6634−int pevent_register_event_handler(struct pevent *pevent, int id,
6635− const char *sys_name, const char *event_name,
6636− pevent_event_handler_func func, void *context)
6620+int tep_register_event_handler(struct tep_handle *pevent, int id,
6621+ const char *sys_name, const char *event_name,
6622+ tep_event_handler_func func, void *context)
66376623 {
66386624 struct event_format *event;
66396625 struct event_handler *handle;
66406626
6641− event = pevent_search_event(pevent, id, sys_name, event_name);
6627+ event = search_event(pevent, id, sys_name, event_name);
66426628 if (event == NULL)
66436629 goto not_found;
66446630
@@ -6654,7 +6640,7 @@ int pevent_register_event_handler(struct pevent *pevent, int id, · 9 unmodified lines
66546640 handle = calloc(1, sizeof(*handle));
66556641 if (!handle) {
66566642 do_warning("Failed to allocate event handler");
6657− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
6643+ return TEP_ERRNO__MEM_ALLOC_FAILED;
66586644 }
66596645
66606646 handle->id = id;
@@ -6669,7 +6655,7 @@ int pevent_register_event_handler(struct pevent *pevent, int id, · 8 unmodified lines
66696655 free((void *)handle->event_name);
66706656 free((void *)handle->sys_name);
66716657 free(handle);
6672− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
6658+ return TEP_ERRNO__MEM_ALLOC_FAILED;
66736659 }
66746660
66756661 handle->func = func;
@@ -6682,7 +6668,7 @@ int pevent_register_event_handler(struct pevent *pevent, int id, · 6 unmodified lines
66826668
66836669 static int handle_matches(struct event_handler *handler, int id,
66846670 const char *sys_name, const char *event_name,
6685− pevent_event_handler_func func, void *context)
6671+ tep_event_handler_func func, void *context)
66866672 {
66876673 if (id >= 0 && id != handler->id)
66886674 return 0;
@@ -6700,7 +6686,7 @@ static int handle_matches(struct event_handler *handler, int id, · 11 unmodified lines
67006686 }
67016687
67026688 /**
6703− * pevent_unregister_event_handler - unregister an existing event handler
6689+ * tep_unregister_event_handler - unregister an existing event handler
67046690 * @pevent: the handle to the pevent
67056691 * @id: the id of the event to unregister
67066692 * @sys_name: the system name the handler belongs to
@@ -6715,15 +6701,15 @@ static int handle_matches(struct event_handler *handler, int id, · 8 unmodified lines
67156701 *
67166702 * Returns 0 if handler was removed successfully, -1 if event was not found.
67176703 */
6718−int pevent_unregister_event_handler(struct pevent *pevent, int id,
6719− const char *sys_name, const char *event_name,
6720− pevent_event_handler_func func, void *context)
6704+int tep_unregister_event_handler(struct tep_handle *pevent, int id,
6705+ const char *sys_name, const char *event_name,
6706+ tep_event_handler_func func, void *context)
67216707 {
67226708 struct event_format *event;
67236709 struct event_handler *handle;
67246710 struct event_handler **next;
67256711
6726− event = pevent_search_event(pevent, id, sys_name, event_name);
6712+ event = search_event(pevent, id, sys_name, event_name);
67276713 if (event == NULL)
67286714 goto not_found;
67296715
@@ -6754,11 +6740,11 @@ not_found: · 24 unmodified lines
67546740 }
67556741
67566742 /**
6757− * pevent_alloc - create a pevent handle
6743+ * tep_alloc - create a pevent handle
67586744 */
6759−struct pevent *pevent_alloc(void)
6745+struct tep_handle *tep_alloc(void)
67606746 {
6761− struct pevent *pevent = calloc(1, sizeof(*pevent));
6747+ struct tep_handle *pevent = calloc(1, sizeof(*pevent));
67626748
67636749 if (pevent)
67646750 pevent->ref_count = 1;
@@ -6766,12 +6752,12 @@ struct pevent *pevent_alloc(void) · 1 unmodified line
67666752 return pevent;
67676753 }
67686754
6769−void pevent_ref(struct pevent *pevent)
6755+void tep_ref(struct tep_handle *pevent)
67706756 {
67716757 pevent->ref_count++;
67726758 }
67736759
6774−void pevent_free_format_field(struct format_field *field)
6760+void tep_free_format_field(struct format_field *field)
67756761 {
67766762 free(field->type);
67776763 if (field->alias != field->name)
@@ -6786,7 +6772,7 @@ static void free_format_fields(struct format_field *field) · 8 unmodified lines
67866772
67876773 while (field) {
67886774 next = field->next;
6789− pevent_free_format_field(field);
6775+ tep_free_format_field(field);
67906776 field = next;
67916777 }
67926778 }
@@ -6797,7 +6783,7 @@ static void free_formats(struct format *format) · 4 unmodified lines
67976783 free_format_fields(format->fields);
67986784 }
67996785
6800−void pevent_free_format(struct event_format *event)
6786+void tep_free_format(struct event_format *event)
68016787 {
68026788 free(event->name);
68036789 free(event->system);
@@ -6811,15 +6797,15 @@ void pevent_free_format(struct event_format *event) · 7 unmodified lines
68116797 }
68126798
68136799 /**
6814− * pevent_free - free a pevent handle
6800+ * tep_free - free a pevent handle
68156801 * @pevent: the pevent handle to free
68166802 */
6817−void pevent_free(struct pevent *pevent)
6803+void tep_free(struct tep_handle *pevent)
68186804 {
68196805 struct cmdline_list *cmdlist, *cmdnext;
68206806 struct func_list *funclist, *funcnext;
68216807 struct printk_list *printklist, *printknext;
6822− struct pevent_function_handler *func_handler;
6808+ struct tep_function_handler *func_handler;
68236809 struct event_handler *handle;
68246810 int i;
68256811
@@ -6883,7 +6869,7 @@ void pevent_free(struct pevent *pevent) · 57 unmodified lines
68836869 }
68846870
68856871 for (i = 0; i < pevent->nr_events; i++)
6886− pevent_free_format(pevent->events[i]);
6872+ tep_free_format(pevent->events[i]);
68876873
68886874 while (pevent->handlers) {
68896875 handle = pevent->handlers;
@@ -6899,7 +6885,7 @@ void pevent_free(struct pevent *pevent) · 9 unmodified lines
68996885 free(pevent);
69006886 }
69016887
6902−void pevent_unref(struct pevent *pevent)
6888+void tep_unref(struct tep_handle *pevent)
69036889 {
6904− pevent_free(pevent);
6890+ tep_free(pevent);
69056891 }
tools/lib/traceevent/event-parse.h+229−229
@@ -41,7 +41,7 @@ · 40 unmodified lines
4141 #define DEBUG_RECORD 0
4242 #endif
4343
44−struct pevent_record {
44+struct tep_record {
4545 unsigned long long ts;
4646 unsigned long long offset;
4747 long long missed_events; /* buffer dropped events before */
@@ -53,8 +53,8 @@ struct pevent_record { · 5 unmodified lines
5353 int locked; /* Do not free, even if ref_count is zero */
5454 void *priv;
5555 #if DEBUG_RECORD
56− struct pevent_record *prev;
57− struct pevent_record *next;
56+ struct tep_record *prev;
57+ struct tep_record *next;
5858 long alloc_addr;
5959 #endif
6060 };
@@ -98,19 +98,19 @@ extern int trace_seq_do_printf(struct trace_seq *s); · 37 unmodified lines
9898
9999 /* ----------------------- pevent ----------------------- */
100100
101−struct pevent;
101+struct tep_handle;
102102 struct event_format;
103103
104−typedef int (*pevent_event_handler_func)(struct trace_seq *s,
105− struct pevent_record *record,
106− struct event_format *event,
107− void *context);
104+typedef int (*tep_event_handler_func)(struct trace_seq *s,
105+ struct tep_record *record,
106+ struct event_format *event,
107+ void *context);
108108
109−typedef int (*pevent_plugin_load_func)(struct pevent *pevent);
110−typedef int (*pevent_plugin_unload_func)(struct pevent *pevent);
109+typedef int (*tep_plugin_load_func)(struct tep_handle *pevent);
110+typedef int (*tep_plugin_unload_func)(struct tep_handle *pevent);
111111
112−struct pevent_plugin_option {
113− struct pevent_plugin_option *next;
112+struct tep_plugin_option {
113+ struct tep_plugin_option *next;
114114 void *handle;
115115 char *file;
116116 char *name;
@@ -124,20 +124,20 @@ struct pevent_plugin_option { · 7 unmodified lines
124124 /*
125125 * Plugin hooks that can be called:
126126 *
127− * PEVENT_PLUGIN_LOADER: (required)
127+ * TEP_PLUGIN_LOADER: (required)
128128 * The function name to initialized the plugin.
129129 *
130− * int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
130+ * int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
131131 *
132− * PEVENT_PLUGIN_UNLOADER: (optional)
132+ * TEP_PLUGIN_UNLOADER: (optional)
133133 * The function called just before unloading
134134 *
135− * int PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
135+ * int TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
136136 *
137− * PEVENT_PLUGIN_OPTIONS: (optional)
137+ * TEP_PLUGIN_OPTIONS: (optional)
138138 * Plugin options that can be set before loading
139139 *
140− * struct pevent_plugin_option PEVENT_PLUGIN_OPTIONS[] = {
140+ * struct tep_plugin_option TEP_PLUGIN_OPTIONS[] = {
141141 * {
142142 * .name = "option-name",
143143 * .plugin_alias = "override-file-name", (optional)
@@ -158,19 +158,19 @@ struct pevent_plugin_option { · 14 unmodified lines
158158 * .set will be processed. If .value is defined, then it is considered
159159 * a string option and .set will be ignored.
160160 *
161− * PEVENT_PLUGIN_ALIAS: (optional)
161+ * TEP_PLUGIN_ALIAS: (optional)
162162 * The name to use for finding options (uses filename if not defined)
163163 */
164−#define PEVENT_PLUGIN_LOADER pevent_plugin_loader
165−#define PEVENT_PLUGIN_UNLOADER pevent_plugin_unloader
166−#define PEVENT_PLUGIN_OPTIONS pevent_plugin_options
167−#define PEVENT_PLUGIN_ALIAS pevent_plugin_alias
164+#define TEP_PLUGIN_LOADER tep_plugin_loader
165+#define TEP_PLUGIN_UNLOADER tep_plugin_unloader
166+#define TEP_PLUGIN_OPTIONS tep_plugin_options
167+#define TEP_PLUGIN_ALIAS tep_plugin_alias
168168 #define _MAKE_STR(x) #x
169169 #define MAKE_STR(x) _MAKE_STR(x)
170−#define PEVENT_PLUGIN_LOADER_NAME MAKE_STR(PEVENT_PLUGIN_LOADER)
171−#define PEVENT_PLUGIN_UNLOADER_NAME MAKE_STR(PEVENT_PLUGIN_UNLOADER)
172−#define PEVENT_PLUGIN_OPTIONS_NAME MAKE_STR(PEVENT_PLUGIN_OPTIONS)
173−#define PEVENT_PLUGIN_ALIAS_NAME MAKE_STR(PEVENT_PLUGIN_ALIAS)
170+#define TEP_PLUGIN_LOADER_NAME MAKE_STR(TEP_PLUGIN_LOADER)
171+#define TEP_PLUGIN_UNLOADER_NAME MAKE_STR(TEP_PLUGIN_UNLOADER)
172+#define TEP_PLUGIN_OPTIONS_NAME MAKE_STR(TEP_PLUGIN_OPTIONS)
173+#define TEP_PLUGIN_ALIAS_NAME MAKE_STR(TEP_PLUGIN_ALIAS)
174174
175175 enum format_flags {
176176 FIELD_IS_ARRAY = 1,
@@ -269,10 +269,10 @@ struct print_arg_op { · 92 unmodified lines
269269 struct print_arg *right;
270270 };
271271
272−struct pevent_function_handler;
272+struct tep_function_handler;
273273
274274 struct print_arg_func {
275− struct pevent_function_handler *func;
275+ struct tep_function_handler *func;
276276 struct print_arg *args;
277277 };
278278
@@ -320,14 +320,14 @@ struct print_fmt { · 41 unmodified lines
320320 };
321321
322322 struct event_format {
323− struct pevent *pevent;
323+ struct tep_handle *pevent;
324324 char *name;
325325 int id;
326326 int flags;
327327 struct format format;
328328 struct print_fmt print_fmt;
329329 char *system;
330− pevent_event_handler_func handler;
330+ tep_event_handler_func handler;
331331 void *context;
332332 };
333333
@@ -361,25 +361,25 @@ enum event_type { · 27 unmodified lines
361361 EVENT_SQUOTE,
362362 };
363363
364−typedef unsigned long long (*pevent_func_handler)(struct trace_seq *s,
365− unsigned long long *args);
364+typedef unsigned long long (*tep_func_handler)(struct trace_seq *s,
365+ unsigned long long *args);
366366
367−enum pevent_func_arg_type {
368− PEVENT_FUNC_ARG_VOID,
369− PEVENT_FUNC_ARG_INT,
370− PEVENT_FUNC_ARG_LONG,
371− PEVENT_FUNC_ARG_STRING,
372− PEVENT_FUNC_ARG_PTR,
373− PEVENT_FUNC_ARG_MAX_TYPES
367+enum tep_func_arg_type {
368+ TEP_FUNC_ARG_VOID,
369+ TEP_FUNC_ARG_INT,
370+ TEP_FUNC_ARG_LONG,
371+ TEP_FUNC_ARG_STRING,
372+ TEP_FUNC_ARG_PTR,
373+ TEP_FUNC_ARG_MAX_TYPES
374374 };
375375
376−enum pevent_flag {
377− PEVENT_NSEC_OUTPUT = 1, /* output in NSECS */
378− PEVENT_DISABLE_SYS_PLUGINS = 1 << 1,
379− PEVENT_DISABLE_PLUGINS = 1 << 2,
376+enum tep_flag {
377+ TEP_NSEC_OUTPUT = 1, /* output in NSECS */
378+ TEP_DISABLE_SYS_PLUGINS = 1 << 1,
379+ TEP_DISABLE_PLUGINS = 1 << 2,
380380 };
381381
382−#define PEVENT_ERRORS \
382+#define TEP_ERRORS \
383383 _PE(MEM_ALLOC_FAILED, "failed to allocate memory"), \
384384 _PE(PARSE_EVENT_FAILED, "failed to parse event"), \
385385 _PE(READ_ID_FAILED, "failed to read event id"), \
@@ -411,10 +411,10 @@ enum pevent_flag { · 25 unmodified lines
411411 _PE(FILTER_MISS, "record does not match to filter")
412412
413413 #undef _PE
414−#define _PE(__code, __str) PEVENT_ERRNO__ ## __code
415−enum pevent_errno {
416− PEVENT_ERRNO__SUCCESS = 0,
417− PEVENT_ERRNO__FILTER_MATCH = PEVENT_ERRNO__SUCCESS,
414+#define _PE(__code, __str) TEP_ERRNO__ ## __code
415+enum tep_errno {
416+ TEP_ERRNO__SUCCESS = 0,
417+ TEP_ERRNO__FILTER_MATCH = TEP_ERRNO__SUCCESS,
418418
419419 /*
420420 * Choose an arbitrary negative big number not to clash with standard
@@ -423,11 +423,11 @@ enum pevent_errno { · 2 unmodified lines
423423 *
424424 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
425425 */
426− __PEVENT_ERRNO__START = -100000,
426+ __TEP_ERRNO__START = -100000,
427427
428− PEVENT_ERRORS,
428+ TEP_ERRORS,
429429
430− __PEVENT_ERRNO__END,
430+ __TEP_ERRNO__END,
431431 };
432432 #undef _PE
433433
@@ -435,17 +435,17 @@ struct plugin_list; · 1 unmodified line
435435
436436 #define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1))
437437
438−struct plugin_list *traceevent_load_plugins(struct pevent *pevent);
439−void traceevent_unload_plugins(struct plugin_list *plugin_list,
440− struct pevent *pevent);
441−char **traceevent_plugin_list_options(void);
442−void traceevent_plugin_free_options_list(char **list);
443−int traceevent_plugin_add_options(const char *name,
444− struct pevent_plugin_option *options);
445−void traceevent_plugin_remove_options(struct pevent_plugin_option *options);
446−void traceevent_print_plugins(struct trace_seq *s,
447− const char *prefix, const char *suffix,
448− const struct plugin_list *list);
438+struct plugin_list *tep_load_plugins(struct tep_handle *pevent);
439+void tep_unload_plugins(struct plugin_list *plugin_list,
440+ struct tep_handle *pevent);
441+char **tep_plugin_list_options(void);
442+void tep_plugin_free_options_list(char **list);
443+int tep_plugin_add_options(const char *name,
444+ struct tep_plugin_option *options);
445+void tep_plugin_remove_options(struct tep_plugin_option *options);
446+void tep_print_plugins(struct trace_seq *s,
447+ const char *prefix, const char *suffix,
448+ const struct plugin_list *list);
449449
450450 struct cmdline;
451451 struct cmdline_list;
@@ -454,10 +454,10 @@ struct func_list; · 2 unmodified lines
454454 struct event_handler;
455455 struct func_resolver;
456456
457−typedef char *(pevent_func_resolver_t)(void *priv,
458− unsigned long long *addrp, char **modp);
457+typedef char *(tep_func_resolver_t)(void *priv,
458+ unsigned long long *addrp, char **modp);
459459
460−struct pevent {
460+struct tep_handle {
461461 int ref_count;
462462
463463 int header_page_ts_offset;
@@ -524,7 +524,7 @@ struct pevent { · 60 unmodified lines
524524 struct format_field *bprint_buf_field;
525525
526526 struct event_handler *handlers;
527− struct pevent_function_handler *func_handlers;
527+ struct tep_function_handler *func_handlers;
528528
529529 /* cache */
530530 struct event_format *last_event;
@@ -532,13 +532,13 @@ struct pevent { · 1 unmodified line
532532 char *trace_clock;
533533 };
534534
535−static inline void pevent_set_flag(struct pevent *pevent, int flag)
535+static inline void tep_set_flag(struct tep_handle *pevent, int flag)
536536 {
537537 pevent->flags |= flag;
538538 }
539539
540540 static inline unsigned short
541−__data2host2(struct pevent *pevent, unsigned short data)
541+__data2host2(struct tep_handle *pevent, unsigned short data)
542542 {
543543 unsigned short swap;
544544
@@ -552,7 +552,7 @@ __data2host2(struct pevent *pevent, unsigned short data) · 7 unmodified lines
552552 }
553553
554554 static inline unsigned int
555−__data2host4(struct pevent *pevent, unsigned int data)
555+__data2host4(struct tep_handle *pevent, unsigned int data)
556556 {
557557 unsigned int swap;
558558
@@ -568,7 +568,7 @@ __data2host4(struct pevent *pevent, unsigned int data) · 9 unmodified lines
568568 }
569569
570570 static inline unsigned long long
571−__data2host8(struct pevent *pevent, unsigned long long data)
571+__data2host8(struct tep_handle *pevent, unsigned long long data)
572572 {
573573 unsigned long long swap;
574574
@@ -597,7 +597,7 @@ __data2host8(struct pevent *pevent, unsigned long long data) · 22 unmodified lines
597597 __data2host8(pevent, __val); \
598598 })
599599
600−static inline int traceevent_host_bigendian(void)
600+static inline int tep_host_bigendian(void)
601601 {
602602 unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
603603 unsigned int val;
@@ -615,198 +615,198 @@ enum trace_flag_type { · 11 unmodified lines
615615 TRACE_FLAG_SOFTIRQ = 0x10,
616616 };
617617
618−int pevent_set_function_resolver(struct pevent *pevent,
619− pevent_func_resolver_t *func, void *priv);
620−void pevent_reset_function_resolver(struct pevent *pevent);
621−int pevent_register_comm(struct pevent *pevent, const char *comm, int pid);
622−int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock);
623−int pevent_register_function(struct pevent *pevent, char *name,
624− unsigned long long addr, char *mod);
625−int pevent_register_print_string(struct pevent *pevent, const char *fmt,
626− unsigned long long addr);
627−int pevent_pid_is_registered(struct pevent *pevent, int pid);
628−
629−void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s,
630− struct event_format *event,
631− struct pevent_record *record);
632−void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
633− struct event_format *event,
634− struct pevent_record *record,
635− bool use_trace_clock);
636−void pevent_print_event_data(struct pevent *pevent, struct trace_seq *s,
637− struct event_format *event,
638− struct pevent_record *record);
639−void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
640− struct pevent_record *record, bool use_trace_clock);
641−
642−int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long size,
643− int long_size);
644−
645−enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
646− unsigned long size, const char *sys);
647−enum pevent_errno pevent_parse_format(struct pevent *pevent,
648− struct event_format **eventp,
649− const char *buf,
650− unsigned long size, const char *sys);
651−void pevent_free_format(struct event_format *event);
652−void pevent_free_format_field(struct format_field *field);
653−
654−void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
655− const char *name, struct pevent_record *record,
656− int *len, int err);
657−
658−int pevent_get_field_val(struct trace_seq *s, struct event_format *event,
659− const char *name, struct pevent_record *record,
660− unsigned long long *val, int err);
661−int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event,
662− const char *name, struct pevent_record *record,
663− unsigned long long *val, int err);
664−int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event,
665− const char *name, struct pevent_record *record,
618+int tep_set_function_resolver(struct tep_handle *pevent,
619+ tep_func_resolver_t *func, void *priv);
620+void tep_reset_function_resolver(struct tep_handle *pevent);
621+int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid);
622+int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock);
623+int tep_register_function(struct tep_handle *pevent, char *name,
624+ unsigned long long addr, char *mod);
625+int tep_register_print_string(struct tep_handle *pevent, const char *fmt,
626+ unsigned long long addr);
627+int tep_pid_is_registered(struct tep_handle *pevent, int pid);
628+
629+void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s,
630+ struct event_format *event,
631+ struct tep_record *record);
632+void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s,
633+ struct event_format *event,
634+ struct tep_record *record,
635+ bool use_trace_clock);
636+void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s,
637+ struct event_format *event,
638+ struct tep_record *record);
639+void tep_print_event(struct tep_handle *pevent, struct trace_seq *s,
640+ struct tep_record *record, bool use_trace_clock);
641+
642+int tep_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size,
643+ int long_size);
644+
645+enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf,
646+ unsigned long size, const char *sys);
647+enum tep_errno tep_parse_format(struct tep_handle *pevent,
648+ struct event_format **eventp,
649+ const char *buf,
650+ unsigned long size, const char *sys);
651+void tep_free_format(struct event_format *event);
652+void tep_free_format_field(struct format_field *field);
653+
654+void *tep_get_field_raw(struct trace_seq *s, struct event_format *event,
655+ const char *name, struct tep_record *record,
656+ int *len, int err);
657+
658+int tep_get_field_val(struct trace_seq *s, struct event_format *event,
659+ const char *name, struct tep_record *record,
660+ unsigned long long *val, int err);
661+int tep_get_common_field_val(struct trace_seq *s, struct event_format *event,
662+ const char *name, struct tep_record *record,
666663 unsigned long long *val, int err);
664+int tep_get_any_field_val(struct trace_seq *s, struct event_format *event,
665+ const char *name, struct tep_record *record,
666+ unsigned long long *val, int err);
667667
668−int pevent_print_num_field(struct trace_seq *s, const char *fmt,
668+int tep_print_num_field(struct trace_seq *s, const char *fmt,
669669 struct event_format *event, const char *name,
670− struct pevent_record *record, int err);
671−
672−int pevent_print_func_field(struct trace_seq *s, const char *fmt,
673− struct event_format *event, const char *name,
674− struct pevent_record *record, int err);
675−
676−int pevent_register_event_handler(struct pevent *pevent, int id,
677− const char *sys_name, const char *event_name,
678− pevent_event_handler_func func, void *context);
679−int pevent_unregister_event_handler(struct pevent *pevent, int id,
680− const char *sys_name, const char *event_name,
681− pevent_event_handler_func func, void *context);
682−int pevent_register_print_function(struct pevent *pevent,
683− pevent_func_handler func,
684− enum pevent_func_arg_type ret_type,
685− char *name, ...);
686−int pevent_unregister_print_function(struct pevent *pevent,
687− pevent_func_handler func, char *name);
688−
689−struct format_field *pevent_find_common_field(struct event_format *event, const char *name);
690−struct format_field *pevent_find_field(struct event_format *event, const char *name);
691−struct format_field *pevent_find_any_field(struct event_format *event, const char *name);
692−
693−const char *pevent_find_function(struct pevent *pevent, unsigned long long addr);
670+ struct tep_record *record, int err);
671+
672+int tep_print_func_field(struct trace_seq *s, const char *fmt,
673+ struct event_format *event, const char *name,
674+ struct tep_record *record, int err);
675+
676+int tep_register_event_handler(struct tep_handle *pevent, int id,
677+ const char *sys_name, const char *event_name,
678+ tep_event_handler_func func, void *context);
679+int tep_unregister_event_handler(struct tep_handle *pevent, int id,
680+ const char *sys_name, const char *event_name,
681+ tep_event_handler_func func, void *context);
682+int tep_register_print_function(struct tep_handle *pevent,
683+ tep_func_handler func,
684+ enum tep_func_arg_type ret_type,
685+ char *name, ...);
686+int tep_unregister_print_function(struct tep_handle *pevent,
687+ tep_func_handler func, char *name);
688+
689+struct format_field *tep_find_common_field(struct event_format *event, const char *name);
690+struct format_field *tep_find_field(struct event_format *event, const char *name);
691+struct format_field *tep_find_any_field(struct event_format *event, const char *name);
692+
693+const char *tep_find_function(struct tep_handle *pevent, unsigned long long addr);
694694 unsigned long long
695−pevent_find_function_address(struct pevent *pevent, unsigned long long addr);
696−unsigned long long pevent_read_number(struct pevent *pevent, const void *ptr, int size);
697−int pevent_read_number_field(struct format_field *field, const void *data,
698− unsigned long long *value);
695+tep_find_function_address(struct tep_handle *pevent, unsigned long long addr);
696+unsigned long long tep_read_number(struct tep_handle *pevent, const void *ptr, int size);
697+int tep_read_number_field(struct format_field *field, const void *data,
698+ unsigned long long *value);
699699
700−struct event_format *pevent_find_event(struct pevent *pevent, int id);
700+struct event_format *tep_find_event(struct tep_handle *pevent, int id);
701701
702702 struct event_format *
703−pevent_find_event_by_name(struct pevent *pevent, const char *sys, const char *name);
703+tep_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *name);
704704
705705 struct event_format *
706−pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record);
707−
708−void pevent_data_lat_fmt(struct pevent *pevent,
709− struct trace_seq *s, struct pevent_record *record);
710−int pevent_data_type(struct pevent *pevent, struct pevent_record *rec);
711−struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type);
712−int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec);
713−int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec);
714−int pevent_data_flags(struct pevent *pevent, struct pevent_record *rec);
715−const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid);
706+tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record);
707+
708+void tep_data_lat_fmt(struct tep_handle *pevent,
709+ struct trace_seq *s, struct tep_record *record);
710+int tep_data_type(struct tep_handle *pevent, struct tep_record *rec);
711+struct event_format *tep_data_event_from_type(struct tep_handle *pevent, int type);
712+int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec);
713+int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec);
714+int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec);
715+const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid);
716716 struct cmdline;
717−struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *comm,
718− struct cmdline *next);
719−int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline);
720−
721−void pevent_print_field(struct trace_seq *s, void *data,
722− struct format_field *field);
723−void pevent_print_fields(struct trace_seq *s, void *data,
724− int size __maybe_unused, struct event_format *event);
725−void pevent_event_info(struct trace_seq *s, struct event_format *event,
726− struct pevent_record *record);
727−int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
717+struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
718+ struct cmdline *next);
719+int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline);
720+
721+void tep_print_field(struct trace_seq *s, void *data,
722+ struct format_field *field);
723+void tep_print_fields(struct trace_seq *s, void *data,
724+ int size __maybe_unused, struct event_format *event);
725+void tep_event_info(struct trace_seq *s, struct event_format *event,
726+ struct tep_record *record);
727+int tep_strerror(struct tep_handle *pevent, enum tep_errno errnum,
728728 char *buf, size_t buflen);
729729
730−struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type);
731−struct format_field **pevent_event_common_fields(struct event_format *event);
732−struct format_field **pevent_event_fields(struct event_format *event);
730+struct event_format **tep_list_events(struct tep_handle *pevent, enum event_sort_type);
731+struct format_field **tep_event_common_fields(struct event_format *event);
732+struct format_field **tep_event_fields(struct event_format *event);
733733
734−static inline int pevent_get_cpus(struct pevent *pevent)
734+static inline int tep_get_cpus(struct tep_handle *pevent)
735735 {
736736 return pevent->cpus;
737737 }
738738
739−static inline void pevent_set_cpus(struct pevent *pevent, int cpus)
739+static inline void tep_set_cpus(struct tep_handle *pevent, int cpus)
740740 {
741741 pevent->cpus = cpus;
742742 }
743743
744−static inline int pevent_get_long_size(struct pevent *pevent)
744+static inline int tep_get_long_size(struct tep_handle *pevent)
745745 {
746746 return pevent->long_size;
747747 }
748748
749−static inline void pevent_set_long_size(struct pevent *pevent, int long_size)
749+static inline void tep_set_long_size(struct tep_handle *pevent, int long_size)
750750 {
751751 pevent->long_size = long_size;
752752 }
753753
754−static inline int pevent_get_page_size(struct pevent *pevent)
754+static inline int tep_get_page_size(struct tep_handle *pevent)
755755 {
756756 return pevent->page_size;
757757 }
758758
759−static inline void pevent_set_page_size(struct pevent *pevent, int _page_size)
759+static inline void tep_set_page_size(struct tep_handle *pevent, int _page_size)
760760 {
761761 pevent->page_size = _page_size;
762762 }
763763
764−static inline int pevent_is_file_bigendian(struct pevent *pevent)
764+static inline int tep_is_file_bigendian(struct tep_handle *pevent)
765765 {
766766 return pevent->file_bigendian;
767767 }
768768
769−static inline void pevent_set_file_bigendian(struct pevent *pevent, int endian)
769+static inline void tep_set_file_bigendian(struct tep_handle *pevent, int endian)
770770 {
771771 pevent->file_bigendian = endian;
772772 }
773773
774−static inline int pevent_is_host_bigendian(struct pevent *pevent)
774+static inline int tep_is_host_bigendian(struct tep_handle *pevent)
775775 {
776776 return pevent->host_bigendian;
777777 }
778778
779−static inline void pevent_set_host_bigendian(struct pevent *pevent, int endian)
779+static inline void tep_set_host_bigendian(struct tep_handle *pevent, int endian)
780780 {
781781 pevent->host_bigendian = endian;
782782 }
783783
784−static inline int pevent_is_latency_format(struct pevent *pevent)
784+static inline int tep_is_latency_format(struct tep_handle *pevent)
785785 {
786786 return pevent->latency_format;
787787 }
788788
789−static inline void pevent_set_latency_format(struct pevent *pevent, int lat)
789+static inline void tep_set_latency_format(struct tep_handle *pevent, int lat)
790790 {
791791 pevent->latency_format = lat;
792792 }
793793
794−struct pevent *pevent_alloc(void);
795−void pevent_free(struct pevent *pevent);
796−void pevent_ref(struct pevent *pevent);
797−void pevent_unref(struct pevent *pevent);
794+struct tep_handle *tep_alloc(void);
795+void tep_free(struct tep_handle *pevent);
796+void tep_ref(struct tep_handle *pevent);
797+void tep_unref(struct tep_handle *pevent);
798798
799799 /* access to the internal parser */
800−void pevent_buffer_init(const char *buf, unsigned long long size);
801−enum event_type pevent_read_token(char **tok);
802−void pevent_free_token(char *token);
803−int pevent_peek_char(void);
804−const char *pevent_get_input_buf(void);
805−unsigned long long pevent_get_input_buf_ptr(void);
800+void tep_buffer_init(const char *buf, unsigned long long size);
801+enum event_type tep_read_token(char **tok);
802+void tep_free_token(char *token);
803+int tep_peek_char(void);
804+const char *tep_get_input_buf(void);
805+unsigned long long tep_get_input_buf_ptr(void);
806806
807807 /* for debugging */
808−void pevent_print_funcs(struct pevent *pevent);
809−void pevent_print_printk(struct pevent *pevent);
808+void tep_print_funcs(struct tep_handle *pevent);
809+void tep_print_printk(struct tep_handle *pevent);
810810
811811 /* ----------------------- filtering ----------------------- */
812812
@@ -930,22 +930,22 @@ struct filter_type { · 117 unmodified lines
930930 struct filter_arg *filter;
931931 };
932932
933−#define PEVENT_FILTER_ERROR_BUFSZ 1024
933+#define TEP_FILTER_ERROR_BUFSZ 1024
934934
935935 struct event_filter {
936− struct pevent *pevent;
936+ struct tep_handle *pevent;
937937 int filters;
938938 struct filter_type *event_filters;
939− char error_buffer[PEVENT_FILTER_ERROR_BUFSZ];
939+ char error_buffer[TEP_FILTER_ERROR_BUFSZ];
940940 };
941941
942−struct event_filter *pevent_filter_alloc(struct pevent *pevent);
942+struct event_filter *tep_filter_alloc(struct tep_handle *pevent);
943943
944944 /* for backward compatibility */
945−#define FILTER_NONE PEVENT_ERRNO__NO_FILTER
946−#define FILTER_NOEXIST PEVENT_ERRNO__FILTER_NOT_FOUND
947−#define FILTER_MISS PEVENT_ERRNO__FILTER_MISS
948−#define FILTER_MATCH PEVENT_ERRNO__FILTER_MATCH
945+#define FILTER_NONE TEP_ERRNO__NO_FILTER
946+#define FILTER_NOEXIST TEP_ERRNO__FILTER_NOT_FOUND
947+#define FILTER_MISS TEP_ERRNO__FILTER_MISS
948+#define FILTER_MATCH TEP_ERRNO__FILTER_MATCH
949949
950950 enum filter_trivial_type {
951951 FILTER_TRIVIAL_FALSE,
@@ -953,39 +953,39 @@ enum filter_trivial_type { · 1 unmodified line
953953 FILTER_TRIVIAL_BOTH,
954954 };
955955
956−enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
957− const char *filter_str);
956+enum tep_errno tep_filter_add_filter_str(struct event_filter *filter,
957+ const char *filter_str);
958958
959−enum pevent_errno pevent_filter_match(struct event_filter *filter,
960− struct pevent_record *record);
959+enum tep_errno tep_filter_match(struct event_filter *filter,
960+ struct tep_record *record);
961961
962−int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err,
963− char *buf, size_t buflen);
962+int tep_filter_strerror(struct event_filter *filter, enum tep_errno err,
963+ char *buf, size_t buflen);
964964
965−int pevent_event_filtered(struct event_filter *filter,
966− int event_id);
965+int tep_event_filtered(struct event_filter *filter,
966+ int event_id);
967967
968−void pevent_filter_reset(struct event_filter *filter);
968+void tep_filter_reset(struct event_filter *filter);
969969
970−int pevent_filter_clear_trivial(struct event_filter *filter,
971− enum filter_trivial_type type);
970+int tep_filter_clear_trivial(struct event_filter *filter,
971+ enum filter_trivial_type type);
972972
973−void pevent_filter_free(struct event_filter *filter);
973+void tep_filter_free(struct event_filter *filter);
974974
975−char *pevent_filter_make_string(struct event_filter *filter, int event_id);
975+char *tep_filter_make_string(struct event_filter *filter, int event_id);
976976
977−int pevent_filter_remove_event(struct event_filter *filter,
978− int event_id);
977+int tep_filter_remove_event(struct event_filter *filter,
978+ int event_id);
979979
980−int pevent_filter_event_has_trivial(struct event_filter *filter,
981− int event_id,
982− enum filter_trivial_type type);
980+int tep_filter_event_has_trivial(struct event_filter *filter,
981+ int event_id,
982+ enum filter_trivial_type type);
983983
984−int pevent_filter_copy(struct event_filter *dest, struct event_filter *source);
984+int tep_filter_copy(struct event_filter *dest, struct event_filter *source);
985985
986−int pevent_update_trivial(struct event_filter *dest, struct event_filter *source,
987− enum filter_trivial_type type);
986+int tep_update_trivial(struct event_filter *dest, struct event_filter *source,
987+ enum filter_trivial_type type);
988988
989−int pevent_filter_compare(struct event_filter *filter1, struct event_filter *filter2);
989+int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2);
990990
991991 #endif /* _PARSE_EVENTS_H */
tools/lib/traceevent/event-plugin.c+36−50
@@ -1,21 +1,7 @@
1+// SPDX-License-Identifier: LGPL-2.1
12 /*
23 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
34 *
4− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU Lesser General Public
7− * License as published by the Free Software Foundation;
8− * version 2.1 of the License (not later!)
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU Lesser General Public License for more details.
14− *
15− * You should have received a copy of the GNU Lesser General Public
16− * License along with this program; if not, see <http://www.gnu.org/licenses>
17− *
18− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195 */
206
217 #include <ctype.h>
@@ -34,7 +20,7 @@ · 12 unmodified lines
3420
3521 static struct registered_plugin_options {
3622 struct registered_plugin_options *next;
37− struct pevent_plugin_option *options;
23+ struct tep_plugin_option *options;
3824 } *registered_options;
3925
4026 static struct trace_plugin_options {
@@ -58,7 +44,7 @@ static void lower_case(char *str) · 17 unmodified lines
5844 *str = tolower(*str);
5945 }
6046
61−static int update_option_value(struct pevent_plugin_option *op, const char *val)
47+static int update_option_value(struct tep_plugin_option *op, const char *val)
6248 {
6349 char *op_val;
6450
@@ -97,7 +83,7 @@ static int update_option_value(struct pevent_plugin_option *op, const char *val) · 32 unmodified lines
9783 }
9884
9985 /**
100− * traceevent_plugin_list_options - get list of plugin options
86+ * tep_plugin_list_options - get list of plugin options
10187 *
10288 * Returns an array of char strings that list the currently registered
10389 * plugin options in the format of <plugin>:<option>. This list can be
@@ -106,12 +92,12 @@ static int update_option_value(struct pevent_plugin_option *op, const char *val) · 2 unmodified lines
10692 * Returns NULL if there's no options registered. On error it returns
10793 * INVALID_PLUGIN_LIST_OPTION
10894 *
109− * Must be freed with traceevent_plugin_free_options_list().
95+ * Must be freed with tep_plugin_free_options_list().
11096 */
111−char **traceevent_plugin_list_options(void)
97+char **tep_plugin_list_options(void)
11298 {
11399 struct registered_plugin_options *reg;
114− struct pevent_plugin_option *op;
100+ struct tep_plugin_option *op;
115101 char **list = NULL;
116102 char *name;
117103 int count = 0;
@@ -146,7 +132,7 @@ char **traceevent_plugin_list_options(void) · 28 unmodified lines
146132 return INVALID_PLUGIN_LIST_OPTION;
147133 }
148134
149−void traceevent_plugin_free_options_list(char **list)
135+void tep_plugin_free_options_list(char **list)
150136 {
151137 int i;
152138
@@ -163,7 +149,7 @@ void traceevent_plugin_free_options_list(char **list) · 10 unmodified lines
163149 }
164150
165151 static int
166−update_option(const char *file, struct pevent_plugin_option *option)
152+update_option(const char *file, struct tep_plugin_option *option)
167153 {
168154 struct trace_plugin_options *op;
169155 char *plugin;
@@ -215,14 +201,14 @@ update_option(const char *file, struct pevent_plugin_option *option) · 45 unmodified lines
215201 }
216202
217203 /**
218− * traceevent_plugin_add_options - Add a set of options by a plugin
204+ * tep_plugin_add_options - Add a set of options by a plugin
219205 * @name: The name of the plugin adding the options
220206 * @options: The set of options being loaded
221207 *
222208 * Sets the options with the values that have been added by user.
223209 */
224−int traceevent_plugin_add_options(const char *name,
225− struct pevent_plugin_option *options)
210+int tep_plugin_add_options(const char *name,
211+ struct tep_plugin_option *options)
226212 {
227213 struct registered_plugin_options *reg;
228214
@@ -241,10 +227,10 @@ int traceevent_plugin_add_options(const char *name, · 12 unmodified lines
241227 }
242228
243229 /**
244− * traceevent_plugin_remove_options - remove plugin options that were registered
245− * @options: Options to removed that were registered with traceevent_plugin_add_options
230+ * tep_plugin_remove_options - remove plugin options that were registered
231+ * @options: Options to removed that were registered with tep_plugin_add_options
246232 */
247−void traceevent_plugin_remove_options(struct pevent_plugin_option *options)
233+void tep_plugin_remove_options(struct tep_plugin_option *options)
248234 {
249235 struct registered_plugin_options **last;
250236 struct registered_plugin_options *reg;
@@ -260,19 +246,19 @@ void traceevent_plugin_remove_options(struct pevent_plugin_option *options) · 9 unmodified lines
260246 }
261247
262248 /**
263− * traceevent_print_plugins - print out the list of plugins loaded
249+ * tep_print_plugins - print out the list of plugins loaded
264250 * @s: the trace_seq descripter to write to
265251 * @prefix: The prefix string to add before listing the option name
266252 * @suffix: The suffix string ot append after the option name
267− * @list: The list of plugins (usually returned by traceevent_load_plugins()
253+ * @list: The list of plugins (usually returned by tep_load_plugins()
268254 *
269255 * Writes to the trace_seq @s the list of plugins (files) that is
270− * returned by traceevent_load_plugins(). Use @prefix and @suffix for formating:
256+ * returned by tep_load_plugins(). Use @prefix and @suffix for formating:
271257 * @prefix = " ", @suffix = "\n".
272258 */
273−void traceevent_print_plugins(struct trace_seq *s,
274− const char *prefix, const char *suffix,
275− const struct plugin_list *list)
259+void tep_print_plugins(struct trace_seq *s,
260+ const char *prefix, const char *suffix,
261+ const struct plugin_list *list)
276262 {
277263 while (list) {
278264 trace_seq_printf(s, "%s%s%s", prefix, list->name, suffix);
@@ -281,11 +267,11 @@ void traceevent_print_plugins(struct trace_seq *s, · 2 unmodified lines
281267 }
282268
283269 static void
284−load_plugin(struct pevent *pevent, const char *path,
270+load_plugin(struct tep_handle *pevent, const char *path,
285271 const char *file, void *data)
286272 {
287273 struct plugin_list **plugin_list = data;
288− pevent_plugin_load_func func;
274+ tep_plugin_load_func func;
289275 struct plugin_list *list;
290276 const char *alias;
291277 char *plugin;
@@ -305,14 +291,14 @@ load_plugin(struct pevent *pevent, const char *path, · 13 unmodified lines
305291 goto out_free;
306292 }
307293
308− alias = dlsym(handle, PEVENT_PLUGIN_ALIAS_NAME);
294+ alias = dlsym(handle, TEP_PLUGIN_ALIAS_NAME);
309295 if (!alias)
310296 alias = file;
311297
312− func = dlsym(handle, PEVENT_PLUGIN_LOADER_NAME);
298+ func = dlsym(handle, TEP_PLUGIN_LOADER_NAME);
313299 if (!func) {
314300 warning("could not find func '%s' in plugin '%s'\n%s\n",
315− PEVENT_PLUGIN_LOADER_NAME, plugin, dlerror());
301+ TEP_PLUGIN_LOADER_NAME, plugin, dlerror());
316302 goto out_free;
317303 }
318304
@@ -336,9 +322,9 @@ load_plugin(struct pevent *pevent, const char *path, · 17 unmodified lines
336322 }
337323
338324 static void
339−load_plugins_dir(struct pevent *pevent, const char *suffix,
325+load_plugins_dir(struct tep_handle *pevent, const char *suffix,
340326 const char *path,
341− void (*load_plugin)(struct pevent *pevent,
327+ void (*load_plugin)(struct tep_handle *pevent,
342328 const char *path,
343329 const char *name,
344330 void *data),
@@ -378,8 +364,8 @@ load_plugins_dir(struct pevent *pevent, const char *suffix, · 33 unmodified lines
378364 }
379365
380366 static void
381−load_plugins(struct pevent *pevent, const char *suffix,
382− void (*load_plugin)(struct pevent *pevent,
367+load_plugins(struct tep_handle *pevent, const char *suffix,
368+ void (*load_plugin)(struct tep_handle *pevent,
383369 const char *path,
384370 const char *name,
385371 void *data),
@@ -390,7 +376,7 @@ load_plugins(struct pevent *pevent, const char *suffix, · 4 unmodified lines
390376 char *envdir;
391377 int ret;
392378
393− if (pevent->flags & PEVENT_DISABLE_PLUGINS)
379+ if (pevent->flags & TEP_DISABLE_PLUGINS)
394380 return;
395381
396382 /*
@@ -398,7 +384,7 @@ load_plugins(struct pevent *pevent, const char *suffix, · 1 unmodified line
398384 * check that first.
399385 */
400386 #ifdef PLUGIN_DIR
401− if (!(pevent->flags & PEVENT_DISABLE_SYS_PLUGINS))
387+ if (!(pevent->flags & TEP_DISABLE_SYS_PLUGINS))
402388 load_plugins_dir(pevent, suffix, PLUGIN_DIR,
403389 load_plugin, data);
404390 #endif
@@ -431,7 +417,7 @@ load_plugins(struct pevent *pevent, const char *suffix, · 26 unmodified lines
431417 }
432418
433419 struct plugin_list*
434−traceevent_load_plugins(struct pevent *pevent)
420+tep_load_plugins(struct tep_handle *pevent)
435421 {
436422 struct plugin_list *list = NULL;
437423
@@ -440,15 +426,15 @@ traceevent_load_plugins(struct pevent *pevent) · 2 unmodified lines
440426 }
441427
442428 void
443−traceevent_unload_plugins(struct plugin_list *plugin_list, struct pevent *pevent)
429+tep_unload_plugins(struct plugin_list *plugin_list, struct tep_handle *pevent)
444430 {
445− pevent_plugin_unload_func func;
431+ tep_plugin_unload_func func;
446432 struct plugin_list *list;
447433
448434 while (plugin_list) {
449435 list = plugin_list;
450436 plugin_list = list->next;
451− func = dlsym(list->handle, PEVENT_PLUGIN_UNLOADER_NAME);
437+ func = dlsym(list->handle, TEP_PLUGIN_UNLOADER_NAME);
452438 if (func)
453439 func(pevent);
454440 dlclose(list->handle);
tools/lib/traceevent/event-utils.h+1−15
@@ -1,21 +1,7 @@
1+/* SPDX-License-Identifier: LGPL-2.1 */
12 /*
23 * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
34 *
4− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU Lesser General Public
7− * License as published by the Free Software Foundation;
8− * version 2.1 of the License (not later!)
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU Lesser General Public License for more details.
14− *
15− * You should have received a copy of the GNU Lesser General Public
16− * License along with this program; if not, see <http://www.gnu.org/licenses>
17− *
18− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195 */
206 #ifndef __UTIL_H
217 #define __UTIL_H
tools/lib/traceevent/kbuffer-parse.c+1−16
@@ -1,22 +1,7 @@
1+// SPDX-License-Identifier: LGPL-2.1
12 /*
23 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
34 *
4− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU Lesser General Public
7− * License as published by the Free Software Foundation;
8− * version 2.1 of the License (not later!)
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU Lesser General Public License for more details.
14− *
15− * You should have received a copy of the GNU Lesser General Public
16− * License along with this program; if not, write to the Free Software
17− * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18− *
19− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205 */
216 #include <stdio.h>
227 #include <stdlib.h>
tools/lib/traceevent/parse-filter.c+145−159
@@ -1,21 +1,7 @@
1+// SPDX-License-Identifier: LGPL-2.1
12 /*
23 * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
34 *
4− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU Lesser General Public
7− * License as published by the Free Software Foundation;
8− * version 2.1 of the License (not later!)
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU Lesser General Public License for more details.
14− *
15− * You should have received a copy of the GNU Lesser General Public
16− * License along with this program; if not, see <http://www.gnu.org/licenses>
17− *
18− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195 */
206 #include <stdio.h>
217 #include <stdlib.h>
@@ -51,8 +37,8 @@ static void show_error(char *error_buf, const char *fmt, ...) · 29 unmodified lines
5137 int len;
5238 int i;
5339
54− input = pevent_get_input_buf();
55− index = pevent_get_input_buf_ptr();
40+ input = tep_get_input_buf();
41+ index = tep_get_input_buf_ptr();
5642 len = input ? strlen(input) : 0;
5743
5844 if (len) {
@@ -66,13 +52,13 @@ static void show_error(char *error_buf, const char *fmt, ...) · 7 unmodified lines
6652 }
6753
6854 va_start(ap, fmt);
69− vsnprintf(error_buf + len, PEVENT_FILTER_ERROR_BUFSZ - len, fmt, ap);
55+ vsnprintf(error_buf + len, TEP_FILTER_ERROR_BUFSZ - len, fmt, ap);
7056 va_end(ap);
7157 }
7258
7359 static void free_token(char *token)
7460 {
75− pevent_free_token(token);
61+ tep_free_token(token);
7662 }
7763
7864 static enum event_type read_token(char **tok)
@@ -82,13 +68,13 @@ static enum event_type read_token(char **tok) · 3 unmodified lines
8268
8369 do {
8470 free_token(token);
85− type = pevent_read_token(&token);
71+ type = tep_read_token(&token);
8672 } while (type == EVENT_NEWLINE || type == EVENT_SPACE);
8773
8874 /* If token is = or ! check to see if the next char is ~ */
8975 if (token &&
9076 (strcmp(token, "=") == 0 || strcmp(token, "!") == 0) &&
91− pevent_peek_char() == '~') {
77+ tep_peek_char() == '~') {
9278 /* append it */
9379 *tok = malloc(3);
9480 if (*tok == NULL) {
@@ -98,7 +84,7 @@ static enum event_type read_token(char **tok) · 3 unmodified lines
9884 sprintf(*tok, "%c%c", *token, '~');
9985 free_token(token);
10086 /* Now remove the '~' from the buffer */
101− pevent_read_token(&token);
87+ tep_read_token(&token);
10288 free_token(token);
10389 } else
10490 *tok = token;
@@ -167,7 +153,7 @@ add_filter_type(struct event_filter *filter, int id) · 62 unmodified lines
167153
168154 filter_type = &filter->event_filters[i];
169155 filter_type->event_id = id;
170− filter_type->event = pevent_find_event(filter->pevent, id);
156+ filter_type->event = tep_find_event(filter->pevent, id);
171157 filter_type->filter = NULL;
172158
173159 filter->filters++;
@@ -176,10 +162,10 @@ add_filter_type(struct event_filter *filter, int id) · 2 unmodified lines
176162 }
177163
178164 /**
179− * pevent_filter_alloc - create a new event filter
165+ * tep_filter_alloc - create a new event filter
180166 * @pevent: The pevent that this filter is associated with
181167 */
182−struct event_filter *pevent_filter_alloc(struct pevent *pevent)
168+struct event_filter *tep_filter_alloc(struct tep_handle *pevent)
183169 {
184170 struct event_filter *filter;
185171
@@ -189,7 +175,7 @@ struct event_filter *pevent_filter_alloc(struct pevent *pevent) · 3 unmodified lines
189175
190176 memset(filter, 0, sizeof(*filter));
191177 filter->pevent = pevent;
192− pevent_ref(pevent);
178+ tep_ref(pevent);
193179
194180 return filter;
195181 }
@@ -268,8 +254,8 @@ static int event_match(struct event_format *event, · 72 unmodified lines
268254 !regexec(ereg, event->name, 0, NULL, 0);
269255 }
270256
271−static enum pevent_errno
272−find_event(struct pevent *pevent, struct event_list **events,
257+static enum tep_errno
258+find_event(struct tep_handle *pevent, struct event_list **events,
273259 char *sys_name, char *event_name)
274260 {
275261 struct event_format *event;
@@ -289,26 +275,26 @@ find_event(struct pevent *pevent, struct event_list **events, · 13 unmodified lines
289275
290276 ret = asprintf(&reg, "^%s$", event_name);
291277 if (ret < 0)
292− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
278+ return TEP_ERRNO__MEM_ALLOC_FAILED;
293279
294280 ret = regcomp(&ereg, reg, REG_ICASE|REG_NOSUB);
295281 free(reg);
296282
297283 if (ret)
298− return PEVENT_ERRNO__INVALID_EVENT_NAME;
284+ return TEP_ERRNO__INVALID_EVENT_NAME;
299285
300286 if (sys_name) {
301287 ret = asprintf(&reg, "^%s$", sys_name);
302288 if (ret < 0) {
303289 regfree(&ereg);
304− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
290+ return TEP_ERRNO__MEM_ALLOC_FAILED;
305291 }
306292
307293 ret = regcomp(&sreg, reg, REG_ICASE|REG_NOSUB);
308294 free(reg);
309295 if (ret) {
310296 regfree(&ereg);
311− return PEVENT_ERRNO__INVALID_EVENT_NAME;
297+ return TEP_ERRNO__INVALID_EVENT_NAME;
312298 }
313299 }
314300
@@ -328,9 +314,9 @@ find_event(struct pevent *pevent, struct event_list **events, · 13 unmodified lines
328314 regfree(&sreg);
329315
330316 if (!match)
331− return PEVENT_ERRNO__EVENT_NOT_FOUND;
317+ return TEP_ERRNO__EVENT_NOT_FOUND;
332318 if (fail)
333− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
319+ return TEP_ERRNO__MEM_ALLOC_FAILED;
334320
335321 return 0;
336322 }
@@ -346,7 +332,7 @@ static void free_events(struct event_list *events) · 9 unmodified lines
346332 }
347333 }
348334
349−static enum pevent_errno
335+static enum tep_errno
350336 create_arg_item(struct event_format *event, const char *token,
351337 enum event_type type, struct filter_arg **parg, char *error_str)
352338 {
@@ -356,7 +342,7 @@ create_arg_item(struct event_format *event, const char *token, · 3 unmodified lines
356342 arg = allocate_arg();
357343 if (arg == NULL) {
358344 show_error(error_str, "failed to allocate filter arg");
359− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
345+ return TEP_ERRNO__MEM_ALLOC_FAILED;
360346 }
361347
362348 switch (type) {
@@ -370,7 +356,7 @@ create_arg_item(struct event_format *event, const char *token, · 7 unmodified lines
370356 if (!arg->value.str) {
371357 free_arg(arg);
372358 show_error(error_str, "failed to allocate string filter arg");
373− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
359+ return TEP_ERRNO__MEM_ALLOC_FAILED;
374360 }
375361 break;
376362 case EVENT_ITEM:
@@ -382,7 +368,7 @@ create_arg_item(struct event_format *event, const char *token, · 5 unmodified lines
382368 break;
383369 }
384370 /* Consider this a field */
385− field = pevent_find_any_field(event, token);
371+ field = tep_find_any_field(event, token);
386372 if (!field) {
387373 /* If token is 'COMM' or 'CPU' then it is special */
388374 if (strcmp(token, COMM) == 0) {
@@ -402,7 +388,7 @@ create_arg_item(struct event_format *event, const char *token, · 13 unmodified lines
402388 default:
403389 free_arg(arg);
404390 show_error(error_str, "expected a value but found %s", token);
405− return PEVENT_ERRNO__UNEXPECTED_TYPE;
391+ return TEP_ERRNO__UNEXPECTED_TYPE;
406392 }
407393 *parg = arg;
408394 return 0;
@@ -454,7 +440,7 @@ create_arg_cmp(enum filter_cmp_type ctype) · 45 unmodified lines
454440 return arg;
455441 }
456442
457−static enum pevent_errno
443+static enum tep_errno
458444 add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
459445 {
460446 struct filter_arg *left;
@@ -487,7 +473,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) · 26 unmodified lines
487473 break;
488474 default:
489475 show_error(error_str, "Illegal rvalue");
490− return PEVENT_ERRNO__ILLEGAL_RVALUE;
476+ return TEP_ERRNO__ILLEGAL_RVALUE;
491477 }
492478
493479 /*
@@ -534,7 +520,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) · 40 unmodified lines
534520 if (left->type != FILTER_ARG_FIELD) {
535521 show_error(error_str,
536522 "Illegal lvalue for string comparison");
537− return PEVENT_ERRNO__ILLEGAL_LVALUE;
523+ return TEP_ERRNO__ILLEGAL_LVALUE;
538524 }
539525
540526 /* Make sure this is a valid string compare */
@@ -553,13 +539,13 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) · 12 unmodified lines
553539 show_error(error_str,
554540 "RegEx '%s' did not compute",
555541 str);
556− return PEVENT_ERRNO__INVALID_REGEX;
542+ return TEP_ERRNO__INVALID_REGEX;
557543 }
558544 break;
559545 default:
560546 show_error(error_str,
561547 "Illegal comparison for string");
562− return PEVENT_ERRNO__ILLEGAL_STRING_CMP;
548+ return TEP_ERRNO__ILLEGAL_STRING_CMP;
563549 }
564550
565551 op->type = FILTER_ARG_STR;
@@ -568,7 +554,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) · 2 unmodified lines
568554 op->str.val = strdup(str);
569555 if (!op->str.val) {
570556 show_error(error_str, "Failed to allocate string filter");
571− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
557+ return TEP_ERRNO__MEM_ALLOC_FAILED;
572558 }
573559 /*
574560 * Need a buffer to copy data for tests
@@ -576,7 +562,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) · 1 unmodified line
576562 op->str.buffer = malloc(op->str.field->size + 1);
577563 if (!op->str.buffer) {
578564 show_error(error_str, "Failed to allocate string filter");
579− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
565+ return TEP_ERRNO__MEM_ALLOC_FAILED;
580566 }
581567 /* Null terminate this buffer */
582568 op->str.buffer[op->str.field->size] = 0;
@@ -595,7 +581,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) · 12 unmodified lines
595581 case FILTER_CMP_NOT_REGEX:
596582 show_error(error_str,
597583 "Op not allowed with integers");
598− return PEVENT_ERRNO__ILLEGAL_INTEGER_CMP;
584+ return TEP_ERRNO__ILLEGAL_INTEGER_CMP;
599585
600586 default:
601587 break;
@@ -616,7 +602,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) · 14 unmodified lines
616602
617603 out_fail:
618604 show_error(error_str, "Syntax error");
619− return PEVENT_ERRNO__SYNTAX_ERROR;
605+ return TEP_ERRNO__SYNTAX_ERROR;
620606 }
621607
622608 static struct filter_arg *
@@ -629,7 +615,7 @@ rotate_op_right(struct filter_arg *a, struct filter_arg *b) · 6 unmodified lines
629615 return arg;
630616 }
631617
632−static enum pevent_errno add_left(struct filter_arg *op, struct filter_arg *arg)
618+static enum tep_errno add_left(struct filter_arg *op, struct filter_arg *arg)
633619 {
634620 switch (op->type) {
635621 case FILTER_ARG_EXP:
@@ -648,11 +634,11 @@ static enum pevent_errno add_left(struct filter_arg *op, struct filter_arg *arg) · 12 unmodified lines
648634 /* left arg of compares must be a field */
649635 if (arg->type != FILTER_ARG_FIELD &&
650636 arg->type != FILTER_ARG_BOOLEAN)
651− return PEVENT_ERRNO__INVALID_ARG_TYPE;
637+ return TEP_ERRNO__INVALID_ARG_TYPE;
652638 op->num.left = arg;
653639 break;
654640 default:
655− return PEVENT_ERRNO__INVALID_ARG_TYPE;
641+ return TEP_ERRNO__INVALID_ARG_TYPE;
656642 }
657643 return 0;
658644 }
@@ -765,7 +751,7 @@ enum filter_vals { · 106 unmodified lines
765751 FILTER_VAL_TRUE,
766752 };
767753
768−static enum pevent_errno
754+static enum tep_errno
769755 reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child,
770756 struct filter_arg *arg, char *error_str)
771757 {
@@ -775,7 +761,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, · 3 unmodified lines
775761 if (parent->type != FILTER_ARG_OP &&
776762 arg->type != FILTER_ARG_OP) {
777763 show_error(error_str, "can not reparent other than OP");
778− return PEVENT_ERRNO__REPARENT_NOT_OP;
764+ return TEP_ERRNO__REPARENT_NOT_OP;
779765 }
780766
781767 /* Get the sibling */
@@ -787,7 +773,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, · 5 unmodified lines
787773 other_child = old_child->op.right;
788774 } else {
789775 show_error(error_str, "Error in reparent op, find other child");
790− return PEVENT_ERRNO__REPARENT_FAILED;
776+ return TEP_ERRNO__REPARENT_FAILED;
791777 }
792778
793779 /* Detach arg from old_child */
@@ -808,7 +794,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, · 14 unmodified lines
808794 ptr = &parent->op.left;
809795 else {
810796 show_error(error_str, "Error in reparent op");
811− return PEVENT_ERRNO__REPARENT_FAILED;
797+ return TEP_ERRNO__REPARENT_FAILED;
812798 }
813799
814800 *ptr = arg;
@@ -817,7 +803,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, · 2 unmodified lines
817803 return 0;
818804 }
819805
820−/* Returns either filter_vals (success) or pevent_errno (failfure) */
806+/* Returns either filter_vals (success) or tep_errno (failfure) */
821807 static int test_arg(struct filter_arg *parent, struct filter_arg *arg,
822808 char *error_str)
823809 {
@@ -912,7 +898,7 @@ static int test_arg(struct filter_arg *parent, struct filter_arg *arg, · 88 unmodified lines
912898 return rval;
913899 default:
914900 show_error(error_str, "bad arg in filter tree");
915− return PEVENT_ERRNO__BAD_FILTER_ARG;
901+ return TEP_ERRNO__BAD_FILTER_ARG;
916902 }
917903 return FILTER_VAL_NORM;
918904 }
@@ -937,7 +923,7 @@ static int collapse_tree(struct filter_arg *arg, · 18 unmodified lines
937923 arg->boolean.value = ret == FILTER_VAL_TRUE;
938924 } else {
939925 show_error(error_str, "Failed to allocate filter arg");
940− ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
926+ ret = TEP_ERRNO__MEM_ALLOC_FAILED;
941927 }
942928 break;
943929
@@ -952,7 +938,7 @@ static int collapse_tree(struct filter_arg *arg, · 8 unmodified lines
952938 return ret;
953939 }
954940
955−static enum pevent_errno
941+static enum tep_errno
956942 process_filter(struct event_format *event, struct filter_arg **parg,
957943 char *error_str, int not)
958944 {
@@ -966,7 +952,7 @@ process_filter(struct event_format *event, struct filter_arg **parg, · 7 unmodified lines
966952 enum filter_op_type btype;
967953 enum filter_exp_type etype;
968954 enum filter_cmp_type ctype;
969− enum pevent_errno ret;
955+ enum tep_errno ret;
970956
971957 *parg = NULL;
972958
@@ -1004,7 +990,7 @@ process_filter(struct event_format *event, struct filter_arg **parg, · 31 unmodified lines
1004990 case EVENT_DELIM:
1005991 if (*token == ',') {
1006992 show_error(error_str, "Illegal token ','");
1007− ret = PEVENT_ERRNO__ILLEGAL_TOKEN;
993+ ret = TEP_ERRNO__ILLEGAL_TOKEN;
1008994 goto fail;
1009995 }
1010996
@@ -1012,22 +998,22 @@ process_filter(struct event_format *event, struct filter_arg **parg, · 1 unmodified line
1012998 if (left_item) {
1013999 show_error(error_str,
10141000 "Open paren can not come after item");
1015− ret = PEVENT_ERRNO__INVALID_PAREN;
1001+ ret = TEP_ERRNO__INVALID_PAREN;
10161002 goto fail;
10171003 }
10181004 if (current_exp) {
10191005 show_error(error_str,
10201006 "Open paren can not come after expression");
1021− ret = PEVENT_ERRNO__INVALID_PAREN;
1007+ ret = TEP_ERRNO__INVALID_PAREN;
10221008 goto fail;
10231009 }
10241010
10251011 ret = process_filter(event, &arg, error_str, 0);
1026− if (ret != PEVENT_ERRNO__UNBALANCED_PAREN) {
1012+ if (ret != TEP_ERRNO__UNBALANCED_PAREN) {
10271013 if (ret == 0) {
10281014 show_error(error_str,
10291015 "Unbalanced number of '('");
1030− ret = PEVENT_ERRNO__UNBALANCED_PAREN;
1016+ ret = TEP_ERRNO__UNBALANCED_PAREN;
10311017 }
10321018 goto fail;
10331019 }
@@ -1064,7 +1050,7 @@ process_filter(struct event_format *event, struct filter_arg **parg, · 30 unmodified lines
10641050 else
10651051 *parg = current_exp;
10661052 free(token);
1067− return PEVENT_ERRNO__UNBALANCED_PAREN;
1053+ return TEP_ERRNO__UNBALANCED_PAREN;
10681054 }
10691055 break;
10701056
@@ -1091,7 +1077,7 @@ process_filter(struct event_format *event, struct filter_arg **parg, · 20 unmodified lines
10911077 case OP_NONE:
10921078 show_error(error_str,
10931079 "Unknown op token %s", token);
1094− ret = PEVENT_ERRNO__UNKNOWN_TOKEN;
1080+ ret = TEP_ERRNO__UNKNOWN_TOKEN;
10951081 goto fail;
10961082 }
10971083
@@ -1179,11 +1165,11 @@ process_filter(struct event_format *event, struct filter_arg **parg, · 81 unmodified lines
11791165
11801166 fail_alloc:
11811167 show_error(error_str, "failed to allocate filter arg");
1182− ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
1168+ ret = TEP_ERRNO__MEM_ALLOC_FAILED;
11831169 goto fail;
11841170 fail_syntax:
11851171 show_error(error_str, "Syntax error");
1186− ret = PEVENT_ERRNO__SYNTAX_ERROR;
1172+ ret = TEP_ERRNO__SYNTAX_ERROR;
11871173 fail:
11881174 free_arg(current_op);
11891175 free_arg(current_exp);
@@ -1192,13 +1178,13 @@ process_filter(struct event_format *event, struct filter_arg **parg, · 2 unmodified lines
11921178 return ret;
11931179 }
11941180
1195−static enum pevent_errno
1181+static enum tep_errno
11961182 process_event(struct event_format *event, const char *filter_str,
11971183 struct filter_arg **parg, char *error_str)
11981184 {
11991185 int ret;
12001186
1201− pevent_buffer_init(filter_str, strlen(filter_str));
1187+ tep_buffer_init(filter_str, strlen(filter_str));
12021188
12031189 ret = process_filter(event, parg, error_str, 0);
12041190 if (ret < 0)
@@ -1208,7 +1194,7 @@ process_event(struct event_format *event, const char *filter_str, · 3 unmodified lines
12081194 if (!*parg) {
12091195 *parg = allocate_arg();
12101196 if (*parg == NULL)
1211− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
1197+ return TEP_ERRNO__MEM_ALLOC_FAILED;
12121198
12131199 (*parg)->type = FILTER_ARG_BOOLEAN;
12141200 (*parg)->boolean.value = FILTER_FALSE;
@@ -1217,13 +1203,13 @@ process_event(struct event_format *event, const char *filter_str, · 2 unmodified lines
12171203 return 0;
12181204 }
12191205
1220−static enum pevent_errno
1206+static enum tep_errno
12211207 filter_event(struct event_filter *filter, struct event_format *event,
12221208 const char *filter_str, char *error_str)
12231209 {
12241210 struct filter_type *filter_type;
12251211 struct filter_arg *arg;
1226− enum pevent_errno ret;
1212+ enum tep_errno ret;
12271213
12281214 if (filter_str) {
12291215 ret = process_event(event, filter_str, &arg, error_str);
@@ -1234,7 +1220,7 @@ filter_event(struct event_filter *filter, struct event_format *event, · 4 unmodified lines
12341220 /* just add a TRUE arg */
12351221 arg = allocate_arg();
12361222 if (arg == NULL)
1237− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
1223+ return TEP_ERRNO__MEM_ALLOC_FAILED;
12381224
12391225 arg->type = FILTER_ARG_BOOLEAN;
12401226 arg->boolean.value = FILTER_TRUE;
@@ -1242,7 +1228,7 @@ filter_event(struct event_filter *filter, struct event_format *event, · 1 unmodified line
12421228
12431229 filter_type = add_filter_type(filter, event->id);
12441230 if (filter_type == NULL)
1245− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
1231+ return TEP_ERRNO__MEM_ALLOC_FAILED;
12461232
12471233 if (filter_type->filter)
12481234 free_arg(filter_type->filter);
@@ -1254,23 +1240,23 @@ filter_event(struct event_filter *filter, struct event_format *event, · 5 unmodified lines
12541240 static void filter_init_error_buf(struct event_filter *filter)
12551241 {
12561242 /* clear buffer to reset show error */
1257− pevent_buffer_init("", 0);
1243+ tep_buffer_init("", 0);
12581244 filter->error_buffer[0] = '\0';
12591245 }
12601246
12611247 /**
1262− * pevent_filter_add_filter_str - add a new filter
1248+ * tep_filter_add_filter_str - add a new filter
12631249 * @filter: the event filter to add to
12641250 * @filter_str: the filter string that contains the filter
12651251 *
12661252 * Returns 0 if the filter was successfully added or a
1267− * negative error code. Use pevent_filter_strerror() to see
1253+ * negative error code. Use tep_filter_strerror() to see
12681254 * actual error message in case of error.
12691255 */
1270−enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
1271− const char *filter_str)
1256+enum tep_errno tep_filter_add_filter_str(struct event_filter *filter,
1257+ const char *filter_str)
12721258 {
1273− struct pevent *pevent = filter->pevent;
1259+ struct tep_handle *pevent = filter->pevent;
12741260 struct event_list *event;
12751261 struct event_list *events = NULL;
12761262 const char *filter_start;
@@ -1279,7 +1265,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, · 2 unmodified lines
12791265 char *event_name = NULL;
12801266 char *sys_name = NULL;
12811267 char *sp;
1282− enum pevent_errno rtn = 0; /* PEVENT_ERRNO__SUCCESS */
1268+ enum tep_errno rtn = 0; /* TEP_ERRNO__SUCCESS */
12831269 int len;
12841270 int ret;
12851271
@@ -1305,7 +1291,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, · 19 unmodified lines
13051291 if (this_event == NULL) {
13061292 /* This can only happen when events is NULL, but still */
13071293 free_events(events);
1308− return PEVENT_ERRNO__MEM_ALLOC_FAILED;
1294+ return TEP_ERRNO__MEM_ALLOC_FAILED;
13091295 }
13101296 memcpy(this_event, filter_str, len);
13111297 this_event[len] = 0;
@@ -1322,7 +1308,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, · 10 unmodified lines
13221308 /* This can only happen when events is NULL, but still */
13231309 free_events(events);
13241310 free(this_event);
1325− return PEVENT_ERRNO__FILTER_NOT_FOUND;
1311+ return TEP_ERRNO__FILTER_NOT_FOUND;
13261312 }
13271313
13281314 /* Find this event */
@@ -1349,7 +1335,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, · 20 unmodified lines
13491335
13501336 if (ret >= 0 && pevent->test_filters) {
13511337 char *test;
1352− test = pevent_filter_make_string(filter, event->event->id);
1338+ test = tep_filter_make_string(filter, event->event->id);
13531339 if (test) {
13541340 printf(" '%s: %s'\n", event->event->name, test);
13551341 free(test);
@@ -1371,7 +1357,7 @@ static void free_filter_type(struct filter_type *filter_type) · 15 unmodified lines
13711357 }
13721358
13731359 /**
1374− * pevent_filter_strerror - fill error message in a buffer
1360+ * tep_filter_strerror - fill error message in a buffer
13751361 * @filter: the event filter contains error
13761362 * @err: the error code
13771363 * @buf: the buffer to be filled in
@@ -1379,10 +1365,10 @@ static void free_filter_type(struct filter_type *filter_type) · 1 unmodified line
13791365 *
13801366 * Returns 0 if message was filled successfully, -1 if error
13811367 */
1382−int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err,
1383− char *buf, size_t buflen)
1368+int tep_filter_strerror(struct event_filter *filter, enum tep_errno err,
1369+ char *buf, size_t buflen)
13841370 {
1385− if (err <= __PEVENT_ERRNO__START || err >= __PEVENT_ERRNO__END)
1371+ if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END)
13861372 return -1;
13871373
13881374 if (strlen(filter->error_buffer) > 0) {
@@ -1393,11 +1379,11 @@ int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err, · 4 unmodified lines
13931379 return 0;
13941380 }
13951381
1396− return pevent_strerror(filter->pevent, err, buf, buflen);
1382+ return tep_strerror(filter->pevent, err, buf, buflen);
13971383 }
13981384
13991385 /**
1400− * pevent_filter_remove_event - remove a filter for an event
1386+ * tep_filter_remove_event - remove a filter for an event
14011387 * @filter: the event filter to remove from
14021388 * @event_id: the event to remove a filter for
14031389 *
@@ -1407,8 +1393,8 @@ int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err, · 3 unmodified lines
14071393 * Returns 1: if an event was removed
14081394 * 0: if the event was not found
14091395 */
1410−int pevent_filter_remove_event(struct event_filter *filter,
1411− int event_id)
1396+int tep_filter_remove_event(struct event_filter *filter,
1397+ int event_id)
14121398 {
14131399 struct filter_type *filter_type;
14141400 unsigned long len;
@@ -1437,12 +1423,12 @@ int pevent_filter_remove_event(struct event_filter *filter, · 22 unmodified lines
14371423 }
14381424
14391425 /**
1440− * pevent_filter_reset - clear all filters in a filter
1426+ * tep_filter_reset - clear all filters in a filter
14411427 * @filter: the event filter to reset
14421428 *
14431429 * Removes all filters from a filter and resets it.
14441430 */
1445−void pevent_filter_reset(struct event_filter *filter)
1431+void tep_filter_reset(struct event_filter *filter)
14461432 {
14471433 int i;
14481434
@@ -1454,11 +1440,11 @@ void pevent_filter_reset(struct event_filter *filter) · 5 unmodified lines
14541440 filter->event_filters = NULL;
14551441 }
14561442
1457−void pevent_filter_free(struct event_filter *filter)
1443+void tep_filter_free(struct event_filter *filter)
14581444 {
1459− pevent_unref(filter->pevent);
1445+ tep_unref(filter->pevent);
14601446
1461− pevent_filter_reset(filter);
1447+ tep_filter_reset(filter);
14621448
14631449 free(filter);
14641450 }
@@ -1478,7 +1464,7 @@ static int copy_filter_type(struct event_filter *filter, · 13 unmodified lines
14781464 /* Can't assume that the pevent's are the same */
14791465 sys = filter_type->event->system;
14801466 name = filter_type->event->name;
1481− event = pevent_find_event_by_name(filter->pevent, sys, name);
1467+ event = tep_find_event_by_name(filter->pevent, sys, name);
14821468 if (!event)
14831469 return -1;
14841470
@@ -1515,18 +1501,18 @@ static int copy_filter_type(struct event_filter *filter, · 30 unmodified lines
15151501 }
15161502
15171503 /**
1518− * pevent_filter_copy - copy a filter using another filter
1504+ * tep_filter_copy - copy a filter using another filter
15191505 * @dest - the filter to copy to
15201506 * @source - the filter to copy from
15211507 *
15221508 * Returns 0 on success and -1 if not all filters were copied
15231509 */
1524−int pevent_filter_copy(struct event_filter *dest, struct event_filter *source)
1510+int tep_filter_copy(struct event_filter *dest, struct event_filter *source)
15251511 {
15261512 int ret = 0;
15271513 int i;
15281514
1529− pevent_filter_reset(dest);
1515+ tep_filter_reset(dest);
15301516
15311517 for (i = 0; i < source->filters; i++) {
15321518 if (copy_filter_type(dest, source, &source->event_filters[i]))
@@ -1537,7 +1523,7 @@ int pevent_filter_copy(struct event_filter *dest, struct event_filter *source) · 4 unmodified lines
15371523
15381524
15391525 /**
1540− * pevent_update_trivial - update the trivial filters with the given filter
1526+ * tep_update_trivial - update the trivial filters with the given filter
15411527 * @dest - the filter to update
15421528 * @source - the filter as the source of the update
15431529 * @type - the type of trivial filter to update.
@@ -1547,11 +1533,11 @@ int pevent_filter_copy(struct event_filter *dest, struct event_filter *source) · 3 unmodified lines
15471533 * Returns 0 on success and -1 if there was a problem updating, but
15481534 * events may have still been updated on error.
15491535 */
1550−int pevent_update_trivial(struct event_filter *dest, struct event_filter *source,
1551− enum filter_trivial_type type)
1536+int tep_update_trivial(struct event_filter *dest, struct event_filter *source,
1537+ enum filter_trivial_type type)
15521538 {
1553− struct pevent *src_pevent;
1554− struct pevent *dest_pevent;
1539+ struct tep_handle *src_pevent;
1540+ struct tep_handle *dest_pevent;
15551541 struct event_format *event;
15561542 struct filter_type *filter_type;
15571543 struct filter_arg *arg;
@@ -1578,14 +1564,14 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source · 20 unmodified lines
15781564
15791565 if (src_pevent != dest_pevent) {
15801566 /* do a look up */
1581− event = pevent_find_event_by_name(src_pevent,
1582− event->system,
1583− event->name);
1567+ event = tep_find_event_by_name(src_pevent,
1568+ event->system,
1569+ event->name);
15841570 if (!event)
15851571 return -1;
15861572 }
15871573
1588− str = pevent_filter_make_string(source, event->id);
1574+ str = tep_filter_make_string(source, event->id);
15891575 if (!str)
15901576 continue;
15911577
@@ -1598,7 +1584,7 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source · 6 unmodified lines
15981584 }
15991585
16001586 /**
1601− * pevent_filter_clear_trivial - clear TRUE and FALSE filters
1587+ * tep_filter_clear_trivial - clear TRUE and FALSE filters
16021588 * @filter: the filter to remove trivial filters from
16031589 * @type: remove only true, false, or both
16041590 *
@@ -1606,8 +1592,8 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source · 1 unmodified line
16061592 *
16071593 * Returns 0 on success and -1 if there was a problem.
16081594 */
1609−int pevent_filter_clear_trivial(struct event_filter *filter,
1610− enum filter_trivial_type type)
1595+int tep_filter_clear_trivial(struct event_filter *filter,
1596+ enum filter_trivial_type type)
16111597 {
16121598 struct filter_type *filter_type;
16131599 int count = 0;
@@ -1653,14 +1639,14 @@ int pevent_filter_clear_trivial(struct event_filter *filter, · 39 unmodified lines
16531639 return 0;
16541640
16551641 for (i = 0; i < count; i++)
1656− pevent_filter_remove_event(filter, ids[i]);
1642+ tep_filter_remove_event(filter, ids[i]);
16571643
16581644 free(ids);
16591645 return 0;
16601646 }
16611647
16621648 /**
1663− * pevent_filter_event_has_trivial - return true event contains trivial filter
1649+ * tep_filter_event_has_trivial - return true event contains trivial filter
16641650 * @filter: the filter with the information
16651651 * @event_id: the id of the event to test
16661652 * @type: trivial type to test for (TRUE, FALSE, EITHER)
@@ -1668,9 +1654,9 @@ int pevent_filter_clear_trivial(struct event_filter *filter, · 1 unmodified line
16681654 * Returns 1 if the event contains a matching trivial type
16691655 * otherwise 0.
16701656 */
1671−int pevent_filter_event_has_trivial(struct event_filter *filter,
1672− int event_id,
1673− enum filter_trivial_type type)
1657+int tep_filter_event_has_trivial(struct event_filter *filter,
1658+ int event_id,
1659+ enum filter_trivial_type type)
16741660 {
16751661 struct filter_type *filter_type;
16761662
@@ -1697,22 +1683,22 @@ int pevent_filter_event_has_trivial(struct event_filter *filter, · 20 unmodified lines
16971683 }
16981684
16991685 static int test_filter(struct event_format *event, struct filter_arg *arg,
1700− struct pevent_record *record, enum pevent_errno *err);
1686+ struct tep_record *record, enum tep_errno *err);
17011687
17021688 static const char *
1703−get_comm(struct event_format *event, struct pevent_record *record)
1689+get_comm(struct event_format *event, struct tep_record *record)
17041690 {
17051691 const char *comm;
17061692 int pid;
17071693
1708− pid = pevent_data_pid(event->pevent, record);
1709− comm = pevent_data_comm_from_pid(event->pevent, pid);
1694+ pid = tep_data_pid(event->pevent, record);
1695+ comm = tep_data_comm_from_pid(event->pevent, pid);
17101696 return comm;
17111697 }
17121698
17131699 static unsigned long long
17141700 get_value(struct event_format *event,
1715− struct format_field *field, struct pevent_record *record)
1701+ struct format_field *field, struct tep_record *record)
17161702 {
17171703 unsigned long long val;
17181704
@@ -1728,7 +1714,7 @@ get_value(struct event_format *event, · 9 unmodified lines
17281714 if (field == &cpu)
17291715 return record->cpu;
17301716
1731− pevent_read_number_field(field, record->data, &val);
1717+ tep_read_number_field(field, record->data, &val);
17321718
17331719 if (!(field->flags & FIELD_IS_SIGNED))
17341720 return val;
@@ -1748,11 +1734,11 @@ get_value(struct event_format *event, · 13 unmodified lines
17481734
17491735 static unsigned long long
17501736 get_arg_value(struct event_format *event, struct filter_arg *arg,
1751− struct pevent_record *record, enum pevent_errno *err);
1737+ struct tep_record *record, enum tep_errno *err);
17521738
17531739 static unsigned long long
17541740 get_exp_value(struct event_format *event, struct filter_arg *arg,
1755− struct pevent_record *record, enum pevent_errno *err)
1741+ struct tep_record *record, enum tep_errno *err)
17561742 {
17571743 unsigned long long lval, rval;
17581744
@@ -1800,14 +1786,14 @@ get_exp_value(struct event_format *event, struct filter_arg *arg, · 41 unmodified lines
18001786 case FILTER_EXP_NOT:
18011787 default:
18021788 if (!*err)
1803− *err = PEVENT_ERRNO__INVALID_EXP_TYPE;
1789+ *err = TEP_ERRNO__INVALID_EXP_TYPE;
18041790 }
18051791 return 0;
18061792 }
18071793
18081794 static unsigned long long
18091795 get_arg_value(struct event_format *event, struct filter_arg *arg,
1810− struct pevent_record *record, enum pevent_errno *err)
1796+ struct tep_record *record, enum tep_errno *err)
18111797 {
18121798 switch (arg->type) {
18131799 case FILTER_ARG_FIELD:
@@ -1816,7 +1802,7 @@ get_arg_value(struct event_format *event, struct filter_arg *arg, · 2 unmodified lines
18161802 case FILTER_ARG_VALUE:
18171803 if (arg->value.type != FILTER_NUMBER) {
18181804 if (!*err)
1819− *err = PEVENT_ERRNO__NOT_A_NUMBER;
1805+ *err = TEP_ERRNO__NOT_A_NUMBER;
18201806 }
18211807 return arg->value.val;
18221808
@@ -1825,13 +1811,13 @@ get_arg_value(struct event_format *event, struct filter_arg *arg, · 2 unmodified lines
18251811
18261812 default:
18271813 if (!*err)
1828− *err = PEVENT_ERRNO__INVALID_ARG_TYPE;
1814+ *err = TEP_ERRNO__INVALID_ARG_TYPE;
18291815 }
18301816 return 0;
18311817 }
18321818
18331819 static int test_num(struct event_format *event, struct filter_arg *arg,
1834− struct pevent_record *record, enum pevent_errno *err)
1820+ struct tep_record *record, enum tep_errno *err)
18351821 {
18361822 unsigned long long lval, rval;
18371823
@@ -1866,15 +1852,15 @@ static int test_num(struct event_format *event, struct filter_arg *arg, · 28 unmodified lines
18661852
18671853 default:
18681854 if (!*err)
1869− *err = PEVENT_ERRNO__ILLEGAL_INTEGER_CMP;
1855+ *err = TEP_ERRNO__ILLEGAL_INTEGER_CMP;
18701856 return 0;
18711857 }
18721858 }
18731859
1874−static const char *get_field_str(struct filter_arg *arg, struct pevent_record *record)
1860+static const char *get_field_str(struct filter_arg *arg, struct tep_record *record)
18751861 {
18761862 struct event_format *event;
1877− struct pevent *pevent;
1863+ struct tep_handle *pevent;
18781864 unsigned long long addr;
18791865 const char *val = NULL;
18801866 unsigned int size;
@@ -1909,7 +1895,7 @@ static const char *get_field_str(struct filter_arg *arg, struct pevent_record *r · 28 unmodified lines
19091895
19101896 if (arg->str.field->flags & (FIELD_IS_POINTER | FIELD_IS_LONG))
19111897 /* convert to a kernel symbol */
1912− val = pevent_find_function(pevent, addr);
1898+ val = tep_find_function(pevent, addr);
19131899
19141900 if (val == NULL) {
19151901 /* just use the hex of the string name */
@@ -1922,7 +1908,7 @@ static const char *get_field_str(struct filter_arg *arg, struct pevent_record *r · 6 unmodified lines
19221908 }
19231909
19241910 static int test_str(struct event_format *event, struct filter_arg *arg,
1925− struct pevent_record *record, enum pevent_errno *err)
1911+ struct tep_record *record, enum tep_errno *err)
19261912 {
19271913 const char *val;
19281914
@@ -1947,13 +1933,13 @@ static int test_str(struct event_format *event, struct filter_arg *arg, · 18 unmodified lines
19471933
19481934 default:
19491935 if (!*err)
1950− *err = PEVENT_ERRNO__ILLEGAL_STRING_CMP;
1936+ *err = TEP_ERRNO__ILLEGAL_STRING_CMP;
19511937 return 0;
19521938 }
19531939 }
19541940
19551941 static int test_op(struct event_format *event, struct filter_arg *arg,
1956− struct pevent_record *record, enum pevent_errno *err)
1942+ struct tep_record *record, enum tep_errno *err)
19571943 {
19581944 switch (arg->op.type) {
19591945 case FILTER_OP_AND:
@@ -1969,13 +1955,13 @@ static int test_op(struct event_format *event, struct filter_arg *arg, · 9 unmodified lines
19691955
19701956 default:
19711957 if (!*err)
1972− *err = PEVENT_ERRNO__INVALID_OP_TYPE;
1958+ *err = TEP_ERRNO__INVALID_OP_TYPE;
19731959 return 0;
19741960 }
19751961 }
19761962
19771963 static int test_filter(struct event_format *event, struct filter_arg *arg,
1978− struct pevent_record *record, enum pevent_errno *err)
1964+ struct tep_record *record, enum tep_errno *err)
19791965 {
19801966 if (*err) {
19811967 /*
@@ -2009,20 +1995,20 @@ static int test_filter(struct event_format *event, struct filter_arg *arg, · 27 unmodified lines
20091995
20101996 default:
20111997 if (!*err)
2012− *err = PEVENT_ERRNO__INVALID_ARG_TYPE;
1998+ *err = TEP_ERRNO__INVALID_ARG_TYPE;
20131999 return 0;
20142000 }
20152001 }
20162002
20172003 /**
2018− * pevent_event_filtered - return true if event has filter
2004+ * tep_event_filtered - return true if event has filter
20192005 * @filter: filter struct with filter information
20202006 * @event_id: event id to test if filter exists
20212007 *
20222008 * Returns 1 if filter found for @event_id
20232009 * otherwise 0;
20242010 */
2025−int pevent_event_filtered(struct event_filter *filter, int event_id)
2011+int tep_event_filtered(struct event_filter *filter, int event_id)
20262012 {
20272013 struct filter_type *filter_type;
20282014
@@ -2035,42 +2021,42 @@ int pevent_event_filtered(struct event_filter *filter, int event_id) · 6 unmodified lines
20352021 }
20362022
20372023 /**
2038− * pevent_filter_match - test if a record matches a filter
2024+ * tep_filter_match - test if a record matches a filter
20392025 * @filter: filter struct with filter information
20402026 * @record: the record to test against the filter
20412027 *
2042− * Returns: match result or error code (prefixed with PEVENT_ERRNO__)
2028+ * Returns: match result or error code (prefixed with TEP_ERRNO__)
20432029 * FILTER_MATCH - filter found for event and @record matches
20442030 * FILTER_MISS - filter found for event and @record does not match
20452031 * FILTER_NOT_FOUND - no filter found for @record's event
20462032 * NO_FILTER - if no filters exist
20472033 * otherwise - error occurred during test
20482034 */
2049−enum pevent_errno pevent_filter_match(struct event_filter *filter,
2050− struct pevent_record *record)
2035+enum tep_errno tep_filter_match(struct event_filter *filter,
2036+ struct tep_record *record)
20512037 {
2052− struct pevent *pevent = filter->pevent;
2038+ struct tep_handle *pevent = filter->pevent;
20532039 struct filter_type *filter_type;
20542040 int event_id;
20552041 int ret;
2056− enum pevent_errno err = 0;
2042+ enum tep_errno err = 0;
20572043
20582044 filter_init_error_buf(filter);
20592045
20602046 if (!filter->filters)
2061− return PEVENT_ERRNO__NO_FILTER;
2047+ return TEP_ERRNO__NO_FILTER;
20622048
2063− event_id = pevent_data_type(pevent, record);
2049+ event_id = tep_data_type(pevent, record);
20642050
20652051 filter_type = find_filter_type(filter, event_id);
20662052 if (!filter_type)
2067− return PEVENT_ERRNO__FILTER_NOT_FOUND;
2053+ return TEP_ERRNO__FILTER_NOT_FOUND;
20682054
20692055 ret = test_filter(filter_type->event, filter_type->filter, record, &err);
20702056 if (err)
20712057 return err;
20722058
2073− return ret ? PEVENT_ERRNO__FILTER_MATCH : PEVENT_ERRNO__FILTER_MISS;
2059+ return ret ? TEP_ERRNO__FILTER_MATCH : TEP_ERRNO__FILTER_MISS;
20742060 }
20752061
20762062 static char *op_to_str(struct event_filter *filter, struct filter_arg *arg)
@@ -2364,7 +2350,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg) · 287 unmodified lines
23642350 }
23652351
23662352 /**
2367− * pevent_filter_make_string - return a string showing the filter
2353+ * tep_filter_make_string - return a string showing the filter
23682354 * @filter: filter struct with filter information
23692355 * @event_id: the event id to return the filter string with
23702356 *
@@ -2373,7 +2359,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg) · 2 unmodified lines
23732359 * NULL is returned if no filter is found or allocation failed.
23742360 */
23752361 char *
2376−pevent_filter_make_string(struct event_filter *filter, int event_id)
2362+tep_filter_make_string(struct event_filter *filter, int event_id)
23772363 {
23782364 struct filter_type *filter_type;
23792365
@@ -2389,7 +2375,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id) · 9 unmodified lines
23892375 }
23902376
23912377 /**
2392− * pevent_filter_compare - compare two filters and return if they are the same
2378+ * tep_filter_compare - compare two filters and return if they are the same
23932379 * @filter1: Filter to compare with @filter2
23942380 * @filter2: Filter to compare with @filter1
23952381 *
@@ -2397,7 +2383,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id) · 1 unmodified line
23972383 * 1 if the two filters hold the same content.
23982384 * 0 if they do not.
23992385 */
2400−int pevent_filter_compare(struct event_filter *filter1, struct event_filter *filter2)
2386+int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2)
24012387 {
24022388 struct filter_type *filter_type1;
24032389 struct filter_type *filter_type2;
tools/lib/traceevent/parse-utils.c+1−15
@@ -1,21 +1,7 @@
1+// SPDX-License-Identifier: LGPL-2.1
12 /*
23 * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
34 *
4− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU Lesser General Public
7− * License as published by the Free Software Foundation;
8− * version 2.1 of the License (not later!)
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU Lesser General Public License for more details.
14− *
15− * You should have received a copy of the GNU Lesser General Public
16− * License along with this program; if not, see <http://www.gnu.org/licenses>
17− *
18− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195 */
206 #include <stdio.h>
217 #include <stdlib.h>
tools/lib/traceevent/plugin_cfg80211.c+10−10
@@ -25,19 +25,19 @@ process___le16_to_cpup(struct trace_seq *s, unsigned long long *args) · 24 unmodified lines
2525 return val ? (long long) le16toh(*val) : 0;
2626 }
2727
28−int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
28+int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
2929 {
30− pevent_register_print_function(pevent,
31− process___le16_to_cpup,
32− PEVENT_FUNC_ARG_INT,
33− "__le16_to_cpup",
34− PEVENT_FUNC_ARG_PTR,
35− PEVENT_FUNC_ARG_VOID);
30+ tep_register_print_function(pevent,
31+ process___le16_to_cpup,
32+ TEP_FUNC_ARG_INT,
33+ "__le16_to_cpup",
34+ TEP_FUNC_ARG_PTR,
35+ TEP_FUNC_ARG_VOID);
3636 return 0;
3737 }
3838
39−void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
39+void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
4040 {
41− pevent_unregister_print_function(pevent, process___le16_to_cpup,
42− "__le16_to_cpup");
41+ tep_unregister_print_function(pevent, process___le16_to_cpup,
42+ "__le16_to_cpup");
4343 }
tools/lib/traceevent/plugin_function.c+17−17
@@ -33,7 +33,7 @@ static int cpus = -1; · 32 unmodified lines
3333
3434 #define STK_BLK 10
3535
36−struct pevent_plugin_option plugin_options[] =
36+struct tep_plugin_option plugin_options[] =
3737 {
3838 {
3939 .name = "parent",
@@ -53,8 +53,8 @@ struct pevent_plugin_option plugin_options[] = · 13 unmodified lines
5353 }
5454 };
5555
56−static struct pevent_plugin_option *ftrace_parent = &plugin_options[0];
57−static struct pevent_plugin_option *ftrace_indent = &plugin_options[1];
56+static struct tep_plugin_option *ftrace_parent = &plugin_options[0];
57+static struct tep_plugin_option *ftrace_indent = &plugin_options[1];
5858
5959 static void add_child(struct func_stack *stack, const char *child, int pos)
6060 {
@@ -122,25 +122,25 @@ static int add_and_get_index(const char *parent, const char *child, int cpu) · 61 unmodified lines
122122 return 0;
123123 }
124124
125−static int function_handler(struct trace_seq *s, struct pevent_record *record,
125+static int function_handler(struct trace_seq *s, struct tep_record *record,
126126 struct event_format *event, void *context)
127127 {
128− struct pevent *pevent = event->pevent;
128+ struct tep_handle *pevent = event->pevent;
129129 unsigned long long function;
130130 unsigned long long pfunction;
131131 const char *func;
132132 const char *parent;
133133 int index = 0;
134134
135− if (pevent_get_field_val(s, event, "ip", record, &function, 1))
135+ if (tep_get_field_val(s, event, "ip", record, &function, 1))
136136 return trace_seq_putc(s, '!');
137137
138− func = pevent_find_function(pevent, function);
138+ func = tep_find_function(pevent, function);
139139
140− if (pevent_get_field_val(s, event, "parent_ip", record, &pfunction, 1))
140+ if (tep_get_field_val(s, event, "parent_ip", record, &pfunction, 1))
141141 return trace_seq_putc(s, '!');
142142
143− parent = pevent_find_function(pevent, pfunction);
143+ parent = tep_find_function(pevent, pfunction);
144144
145145 if (parent && ftrace_indent->set)
146146 index = add_and_get_index(parent, func, record->cpu);
@@ -163,22 +163,22 @@ static int function_handler(struct trace_seq *s, struct pevent_record *record, · 16 unmodified lines
163163 return 0;
164164 }
165165
166−int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
166+int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
167167 {
168− pevent_register_event_handler(pevent, -1, "ftrace", "function",
169− function_handler, NULL);
168+ tep_register_event_handler(pevent, -1, "ftrace", "function",
169+ function_handler, NULL);
170170
171− traceevent_plugin_add_options("ftrace", plugin_options);
171+ tep_plugin_add_options("ftrace", plugin_options);
172172
173173 return 0;
174174 }
175175
176−void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
176+void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
177177 {
178178 int i, x;
179179
180− pevent_unregister_event_handler(pevent, -1, "ftrace", "function",
181− function_handler, NULL);
180+ tep_unregister_event_handler(pevent, -1, "ftrace", "function",
181+ function_handler, NULL);
182182
183183 for (i = 0; i <= cpus; i++) {
184184 for (x = 0; x < fstack[i].size && fstack[i].stack[x]; x++)
@@ -186,7 +186,7 @@ void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) · 1 unmodified line
186186 free(fstack[i].stack);
187187 }
188188
189− traceevent_plugin_remove_options(plugin_options);
189+ tep_plugin_remove_options(plugin_options);
190190
191191 free(fstack);
192192 fstack = NULL;
tools/lib/traceevent/plugin_hrtimer.c+28−28
@@ -25,64 +25,64 @@ · 24 unmodified lines
2525 #include "event-parse.h"
2626
2727 static int timer_expire_handler(struct trace_seq *s,
28− struct pevent_record *record,
28+ struct tep_record *record,
2929 struct event_format *event, void *context)
3030 {
3131 trace_seq_printf(s, "hrtimer=");
3232
33− if (pevent_print_num_field(s, "0x%llx", event, "timer",
34− record, 0) == -1)
35− pevent_print_num_field(s, "0x%llx", event, "hrtimer",
36− record, 1);
33+ if (tep_print_num_field(s, "0x%llx", event, "timer",
34+ record, 0) == -1)
35+ tep_print_num_field(s, "0x%llx", event, "hrtimer",
36+ record, 1);
3737
3838 trace_seq_printf(s, " now=");
3939
40− pevent_print_num_field(s, "%llu", event, "now", record, 1);
40+ tep_print_num_field(s, "%llu", event, "now", record, 1);
4141
42− pevent_print_func_field(s, " function=%s", event, "function",
42+ tep_print_func_field(s, " function=%s", event, "function",
4343 record, 0);
4444 return 0;
4545 }
4646
4747 static int timer_start_handler(struct trace_seq *s,
48− struct pevent_record *record,
48+ struct tep_record *record,
4949 struct event_format *event, void *context)
5050 {
5151 trace_seq_printf(s, "hrtimer=");
5252
53− if (pevent_print_num_field(s, "0x%llx", event, "timer",
54− record, 0) == -1)
55− pevent_print_num_field(s, "0x%llx", event, "hrtimer",
56− record, 1);
53+ if (tep_print_num_field(s, "0x%llx", event, "timer",
54+ record, 0) == -1)
55+ tep_print_num_field(s, "0x%llx", event, "hrtimer",
56+ record, 1);
5757
58− pevent_print_func_field(s, " function=%s", event, "function",
59− record, 0);
58+ tep_print_func_field(s, " function=%s", event, "function",
59+ record, 0);
6060
6161 trace_seq_printf(s, " expires=");
62− pevent_print_num_field(s, "%llu", event, "expires", record, 1);
62+ tep_print_num_field(s, "%llu", event, "expires", record, 1);
6363
6464 trace_seq_printf(s, " softexpires=");
65− pevent_print_num_field(s, "%llu", event, "softexpires", record, 1);
65+ tep_print_num_field(s, "%llu", event, "softexpires", record, 1);
6666 return 0;
6767 }
6868
69−int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
69+int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
7070 {
71− pevent_register_event_handler(pevent, -1,
72− "timer", "hrtimer_expire_entry",
73− timer_expire_handler, NULL);
71+ tep_register_event_handler(pevent, -1,
72+ "timer", "hrtimer_expire_entry",
73+ timer_expire_handler, NULL);
7474
75− pevent_register_event_handler(pevent, -1, "timer", "hrtimer_start",
76− timer_start_handler, NULL);
75+ tep_register_event_handler(pevent, -1, "timer", "hrtimer_start",
76+ timer_start_handler, NULL);
7777 return 0;
7878 }
7979
80−void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
80+void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
8181 {
82− pevent_unregister_event_handler(pevent, -1,
83− "timer", "hrtimer_expire_entry",
84− timer_expire_handler, NULL);
82+ tep_unregister_event_handler(pevent, -1,
83+ "timer", "hrtimer_expire_entry",
84+ timer_expire_handler, NULL);
8585
86− pevent_unregister_event_handler(pevent, -1, "timer", "hrtimer_start",
87− timer_start_handler, NULL);
86+ tep_unregister_event_handler(pevent, -1, "timer", "hrtimer_start",
87+ timer_start_handler, NULL);
8888 }
tools/lib/traceevent/plugin_jbd2.c+18−18
@@ -47,29 +47,29 @@ process_jiffies_to_msecs(struct trace_seq *s, unsigned long long *args) · 46 unmodified lines
4747 return jiffies;
4848 }
4949
50−int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
50+int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
5151 {
52− pevent_register_print_function(pevent,
53− process_jbd2_dev_to_name,
54− PEVENT_FUNC_ARG_STRING,
55− "jbd2_dev_to_name",
56− PEVENT_FUNC_ARG_INT,
57− PEVENT_FUNC_ARG_VOID);
52+ tep_register_print_function(pevent,
53+ process_jbd2_dev_to_name,
54+ TEP_FUNC_ARG_STRING,
55+ "jbd2_dev_to_name",
56+ TEP_FUNC_ARG_INT,
57+ TEP_FUNC_ARG_VOID);
5858
59− pevent_register_print_function(pevent,
60− process_jiffies_to_msecs,
61− PEVENT_FUNC_ARG_LONG,
62− "jiffies_to_msecs",
63− PEVENT_FUNC_ARG_LONG,
64− PEVENT_FUNC_ARG_VOID);
59+ tep_register_print_function(pevent,
60+ process_jiffies_to_msecs,
61+ TEP_FUNC_ARG_LONG,
62+ "jiffies_to_msecs",
63+ TEP_FUNC_ARG_LONG,
64+ TEP_FUNC_ARG_VOID);
6565 return 0;
6666 }
6767
68−void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
68+void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
6969 {
70− pevent_unregister_print_function(pevent, process_jbd2_dev_to_name,
71− "jbd2_dev_to_name");
70+ tep_unregister_print_function(pevent, process_jbd2_dev_to_name,
71+ "jbd2_dev_to_name");
7272
73− pevent_unregister_print_function(pevent, process_jiffies_to_msecs,
74− "jiffies_to_msecs");
73+ tep_unregister_print_function(pevent, process_jiffies_to_msecs,
74+ "jiffies_to_msecs");
7575 }
tools/lib/traceevent/plugin_kmem.c+33−33
@@ -23,7 +23,7 @@ · 22 unmodified lines
2323
2424 #include "event-parse.h"
2525
26−static int call_site_handler(struct trace_seq *s, struct pevent_record *record,
26+static int call_site_handler(struct trace_seq *s, struct tep_record *record,
2727 struct event_format *event, void *context)
2828 {
2929 struct format_field *field;
@@ -31,64 +31,64 @@ static int call_site_handler(struct trace_seq *s, struct pevent_record *record, · 1 unmodified line
3131 void *data = record->data;
3232 const char *func;
3333
34− field = pevent_find_field(event, "call_site");
34+ field = tep_find_field(event, "call_site");
3535 if (!field)
3636 return 1;
3737
38− if (pevent_read_number_field(field, data, &val))
38+ if (tep_read_number_field(field, data, &val))
3939 return 1;
4040
41− func = pevent_find_function(event->pevent, val);
41+ func = tep_find_function(event->pevent, val);
4242 if (!func)
4343 return 1;
4444
45− addr = pevent_find_function_address(event->pevent, val);
45+ addr = tep_find_function_address(event->pevent, val);
4646
4747 trace_seq_printf(s, "(%s+0x%x) ", func, (int)(val - addr));
4848 return 1;
4949 }
5050
51−int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
51+int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
5252 {
53− pevent_register_event_handler(pevent, -1, "kmem", "kfree",
54− call_site_handler, NULL);
53+ tep_register_event_handler(pevent, -1, "kmem", "kfree",
54+ call_site_handler, NULL);
5555
56− pevent_register_event_handler(pevent, -1, "kmem", "kmalloc",
57− call_site_handler, NULL);
56+ tep_register_event_handler(pevent, -1, "kmem", "kmalloc",
57+ call_site_handler, NULL);
5858
59− pevent_register_event_handler(pevent, -1, "kmem", "kmalloc_node",
60− call_site_handler, NULL);
59+ tep_register_event_handler(pevent, -1, "kmem", "kmalloc_node",
60+ call_site_handler, NULL);
6161
62− pevent_register_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
63− call_site_handler, NULL);
62+ tep_register_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
63+ call_site_handler, NULL);
6464
65− pevent_register_event_handler(pevent, -1, "kmem",
66− "kmem_cache_alloc_node",
67− call_site_handler, NULL);
65+ tep_register_event_handler(pevent, -1, "kmem",
66+ "kmem_cache_alloc_node",
67+ call_site_handler, NULL);
6868
69− pevent_register_event_handler(pevent, -1, "kmem", "kmem_cache_free",
70− call_site_handler, NULL);
69+ tep_register_event_handler(pevent, -1, "kmem", "kmem_cache_free",
70+ call_site_handler, NULL);
7171 return 0;
7272 }
7373
74−void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
74+void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
7575 {
76− pevent_unregister_event_handler(pevent, -1, "kmem", "kfree",
77− call_site_handler, NULL);
76+ tep_unregister_event_handler(pevent, -1, "kmem", "kfree",
77+ call_site_handler, NULL);
7878
79− pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc",
80− call_site_handler, NULL);
79+ tep_unregister_event_handler(pevent, -1, "kmem", "kmalloc",
80+ call_site_handler, NULL);
8181
82− pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc_node",
83− call_site_handler, NULL);
82+ tep_unregister_event_handler(pevent, -1, "kmem", "kmalloc_node",
83+ call_site_handler, NULL);
8484
85− pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
86− call_site_handler, NULL);
85+ tep_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
86+ call_site_handler, NULL);
8787
88− pevent_unregister_event_handler(pevent, -1, "kmem",
89− "kmem_cache_alloc_node",
90− call_site_handler, NULL);
88+ tep_unregister_event_handler(pevent, -1, "kmem",
89+ "kmem_cache_alloc_node",
90+ call_site_handler, NULL);
9191
92− pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_free",
93− call_site_handler, NULL);
92+ tep_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_free",
93+ call_site_handler, NULL);
9494 }
tools/lib/traceevent/plugin_kvm.c+77−77
@@ -247,17 +247,17 @@ static const char *find_exit_reason(unsigned isa, int val) · 246 unmodified lines
247247 return strings[i].str;
248248 }
249249
250−static int print_exit_reason(struct trace_seq *s, struct pevent_record *record,
250+static int print_exit_reason(struct trace_seq *s, struct tep_record *record,
251251 struct event_format *event, const char *field)
252252 {
253253 unsigned long long isa;
254254 unsigned long long val;
255255 const char *reason;
256256
257− if (pevent_get_field_val(s, event, field, record, &val, 1) < 0)
257+ if (tep_get_field_val(s, event, field, record, &val, 1) < 0)
258258 return -1;
259259
260− if (pevent_get_field_val(s, event, "isa", record, &isa, 0) < 0)
260+ if (tep_get_field_val(s, event, "isa", record, &isa, 0) < 0)
261261 isa = 1;
262262
263263 reason = find_exit_reason(isa, val);
@@ -268,7 +268,7 @@ static int print_exit_reason(struct trace_seq *s, struct pevent_record *record, · 4 unmodified lines
268268 return 0;
269269 }
270270
271−static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record,
271+static int kvm_exit_handler(struct trace_seq *s, struct tep_record *record,
272272 struct event_format *event, void *context)
273273 {
274274 unsigned long long info1 = 0, info2 = 0;
@@ -276,10 +276,10 @@ static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, · 1 unmodified line
276276 if (print_exit_reason(s, record, event, "exit_reason") < 0)
277277 return -1;
278278
279− pevent_print_num_field(s, " rip 0x%lx", event, "guest_rip", record, 1);
279+ tep_print_num_field(s, " rip 0x%lx", event, "guest_rip", record, 1);
280280
281− if (pevent_get_field_val(s, event, "info1", record, &info1, 0) >= 0
282− && pevent_get_field_val(s, event, "info2", record, &info2, 0) >= 0)
281+ if (tep_get_field_val(s, event, "info1", record, &info1, 0) >= 0
282+ && tep_get_field_val(s, event, "info2", record, &info2, 0) >= 0)
283283 trace_seq_printf(s, " info %llx %llx", info1, info2);
284284
285285 return 0;
@@ -291,7 +291,7 @@ static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, · 5 unmodified lines
291291 #define KVM_EMUL_INSN_F_CS_L (1 << 3)
292292
293293 static int kvm_emulate_insn_handler(struct trace_seq *s,
294− struct pevent_record *record,
294+ struct tep_record *record,
295295 struct event_format *event, void *context)
296296 {
297297 unsigned long long rip, csbase, len, flags, failed;
@@ -299,22 +299,22 @@ static int kvm_emulate_insn_handler(struct trace_seq *s, · 1 unmodified line
299299 uint8_t *insn;
300300 const char *disasm;
301301
302− if (pevent_get_field_val(s, event, "rip", record, &rip, 1) < 0)
302+ if (tep_get_field_val(s, event, "rip", record, &rip, 1) < 0)
303303 return -1;
304304
305− if (pevent_get_field_val(s, event, "csbase", record, &csbase, 1) < 0)
305+ if (tep_get_field_val(s, event, "csbase", record, &csbase, 1) < 0)
306306 return -1;
307307
308− if (pevent_get_field_val(s, event, "len", record, &len, 1) < 0)
308+ if (tep_get_field_val(s, event, "len", record, &len, 1) < 0)
309309 return -1;
310310
311− if (pevent_get_field_val(s, event, "flags", record, &flags, 1) < 0)
311+ if (tep_get_field_val(s, event, "flags", record, &flags, 1) < 0)
312312 return -1;
313313
314− if (pevent_get_field_val(s, event, "failed", record, &failed, 1) < 0)
314+ if (tep_get_field_val(s, event, "failed", record, &failed, 1) < 0)
315315 return -1;
316316
317− insn = pevent_get_field_raw(s, event, "insn", record, &llen, 1);
317+ insn = tep_get_field_raw(s, event, "insn", record, &llen, 1);
318318 if (!insn)
319319 return -1;
320320
@@ -330,24 +330,24 @@ static int kvm_emulate_insn_handler(struct trace_seq *s, · 9 unmodified lines
330330 }
331331
332332
333−static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct pevent_record *record,
333+static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct tep_record *record,
334334 struct event_format *event, void *context)
335335 {
336336 if (print_exit_reason(s, record, event, "exit_code") < 0)
337337 return -1;
338338
339− pevent_print_num_field(s, " info1 %llx", event, "exit_info1", record, 1);
340− pevent_print_num_field(s, " info2 %llx", event, "exit_info2", record, 1);
341− pevent_print_num_field(s, " int_info %llx", event, "exit_int_info", record, 1);
342− pevent_print_num_field(s, " int_info_err %llx", event, "exit_int_info_err", record, 1);
339+ tep_print_num_field(s, " info1 %llx", event, "exit_info1", record, 1);
340+ tep_print_num_field(s, " info2 %llx", event, "exit_info2", record, 1);
341+ tep_print_num_field(s, " int_info %llx", event, "exit_int_info", record, 1);
342+ tep_print_num_field(s, " int_info_err %llx", event, "exit_int_info_err", record, 1);
343343
344344 return 0;
345345 }
346346
347−static int kvm_nested_vmexit_handler(struct trace_seq *s, struct pevent_record *record,
347+static int kvm_nested_vmexit_handler(struct trace_seq *s, struct tep_record *record,
348348 struct event_format *event, void *context)
349349 {
350− pevent_print_num_field(s, "rip %llx ", event, "rip", record, 1);
350+ tep_print_num_field(s, "rip %llx ", event, "rip", record, 1);
351351
352352 return kvm_nested_vmexit_inject_handler(s, record, event, context);
353353 }
@@ -370,7 +370,7 @@ union kvm_mmu_page_role { · 16 unmodified lines
370370 };
371371 };
372372
373−static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record,
373+static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record,
374374 struct event_format *event, void *context)
375375 {
376376 unsigned long long val;
@@ -379,7 +379,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record, · 2 unmodified lines
379379 };
380380 union kvm_mmu_page_role role;
381381
382− if (pevent_get_field_val(s, event, "role", record, &val, 1) < 0)
382+ if (tep_get_field_val(s, event, "role", record, &val, 1) < 0)
383383 return -1;
384384
385385 role.word = (int)val;
@@ -388,8 +388,8 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record, · 2 unmodified lines
388388 * We can only use the structure if file is of the same
389389 * endianess.
390390 */
391− if (pevent_is_file_bigendian(event->pevent) ==
392− pevent_is_host_bigendian(event->pevent)) {
391+ if (tep_is_file_bigendian(event->pevent) ==
392+ tep_is_host_bigendian(event->pevent)) {
393393
394394 trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s",
395395 role.level,
@@ -406,10 +406,10 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record, · 10 unmodified lines
406406 } else
407407 trace_seq_printf(s, "WORD: %08x", role.word);
408408
409− pevent_print_num_field(s, " root %u ", event,
410− "root_count", record, 1);
409+ tep_print_num_field(s, " root %u ", event,
410+ "root_count", record, 1);
411411
412− if (pevent_get_field_val(s, event, "unsync", record, &val, 1) < 0)
412+ if (tep_get_field_val(s, event, "unsync", record, &val, 1) < 0)
413413 return -1;
414414
415415 trace_seq_printf(s, "%s%c", val ? "unsync" : "sync", 0);
@@ -417,17 +417,17 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record, · 1 unmodified line
417417 }
418418
419419 static int kvm_mmu_get_page_handler(struct trace_seq *s,
420− struct pevent_record *record,
420+ struct tep_record *record,
421421 struct event_format *event, void *context)
422422 {
423423 unsigned long long val;
424424
425− if (pevent_get_field_val(s, event, "created", record, &val, 1) < 0)
425+ if (tep_get_field_val(s, event, "created", record, &val, 1) < 0)
426426 return -1;
427427
428428 trace_seq_printf(s, "%s ", val ? "new" : "existing");
429429
430− if (pevent_get_field_val(s, event, "gfn", record, &val, 1) < 0)
430+ if (tep_get_field_val(s, event, "gfn", record, &val, 1) < 0)
431431 return -1;
432432
433433 trace_seq_printf(s, "sp gfn %llx ", val);
@@ -444,79 +444,79 @@ process_is_writable_pte(struct trace_seq *s, unsigned long long *args) · 10 unmodified lines
444444 return pte & PT_WRITABLE_MASK;
445445 }
446446
447−int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
447+int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
448448 {
449449 init_disassembler();
450450
451− pevent_register_event_handler(pevent, -1, "kvm", "kvm_exit",
452− kvm_exit_handler, NULL);
451+ tep_register_event_handler(pevent, -1, "kvm", "kvm_exit",
452+ kvm_exit_handler, NULL);
453453
454− pevent_register_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
455− kvm_emulate_insn_handler, NULL);
454+ tep_register_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
455+ kvm_emulate_insn_handler, NULL);
456456
457− pevent_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit",
458− kvm_nested_vmexit_handler, NULL);
457+ tep_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit",
458+ kvm_nested_vmexit_handler, NULL);
459459
460− pevent_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject",
461− kvm_nested_vmexit_inject_handler, NULL);
460+ tep_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject",
461+ kvm_nested_vmexit_inject_handler, NULL);
462462
463− pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
464− kvm_mmu_get_page_handler, NULL);
463+ tep_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
464+ kvm_mmu_get_page_handler, NULL);
465465
466− pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
467− kvm_mmu_print_role, NULL);
466+ tep_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
467+ kvm_mmu_print_role, NULL);
468468
469− pevent_register_event_handler(pevent, -1,
470− "kvmmmu", "kvm_mmu_unsync_page",
471− kvm_mmu_print_role, NULL);
469+ tep_register_event_handler(pevent, -1,
470+ "kvmmmu", "kvm_mmu_unsync_page",
471+ kvm_mmu_print_role, NULL);
472472
473− pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
474− kvm_mmu_print_role, NULL);
473+ tep_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
474+ kvm_mmu_print_role, NULL);
475475
476− pevent_register_event_handler(pevent, -1, "kvmmmu",
476+ tep_register_event_handler(pevent, -1, "kvmmmu",
477477 "kvm_mmu_prepare_zap_page", kvm_mmu_print_role,
478478 NULL);
479479
480− pevent_register_print_function(pevent,
481− process_is_writable_pte,
482− PEVENT_FUNC_ARG_INT,
483− "is_writable_pte",
484− PEVENT_FUNC_ARG_LONG,
485− PEVENT_FUNC_ARG_VOID);
480+ tep_register_print_function(pevent,
481+ process_is_writable_pte,
482+ TEP_FUNC_ARG_INT,
483+ "is_writable_pte",
484+ TEP_FUNC_ARG_LONG,
485+ TEP_FUNC_ARG_VOID);
486486 return 0;
487487 }
488488
489−void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
489+void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
490490 {
491− pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_exit",
492− kvm_exit_handler, NULL);
491+ tep_unregister_event_handler(pevent, -1, "kvm", "kvm_exit",
492+ kvm_exit_handler, NULL);
493493
494− pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
495− kvm_emulate_insn_handler, NULL);
494+ tep_unregister_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
495+ kvm_emulate_insn_handler, NULL);
496496
497− pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit",
498− kvm_nested_vmexit_handler, NULL);
497+ tep_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit",
498+ kvm_nested_vmexit_handler, NULL);
499499
500− pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject",
501− kvm_nested_vmexit_inject_handler, NULL);
500+ tep_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject",
501+ kvm_nested_vmexit_inject_handler, NULL);
502502
503− pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
504− kvm_mmu_get_page_handler, NULL);
503+ tep_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
504+ kvm_mmu_get_page_handler, NULL);
505505
506− pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
507− kvm_mmu_print_role, NULL);
506+ tep_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
507+ kvm_mmu_print_role, NULL);
508508
509− pevent_unregister_event_handler(pevent, -1,
510− "kvmmmu", "kvm_mmu_unsync_page",
511− kvm_mmu_print_role, NULL);
509+ tep_unregister_event_handler(pevent, -1,
510+ "kvmmmu", "kvm_mmu_unsync_page",
511+ kvm_mmu_print_role, NULL);
512512
513− pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
514− kvm_mmu_print_role, NULL);
513+ tep_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
514+ kvm_mmu_print_role, NULL);
515515
516− pevent_unregister_event_handler(pevent, -1, "kvmmmu",
516+ tep_unregister_event_handler(pevent, -1, "kvmmmu",
517517 "kvm_mmu_prepare_zap_page", kvm_mmu_print_role,
518518 NULL);
519519
520− pevent_unregister_print_function(pevent, process_is_writable_pte,
521− "is_writable_pte");
520+ tep_unregister_print_function(pevent, process_is_writable_pte,
521+ "is_writable_pte");
522522 }
tools/lib/traceevent/plugin_mac80211.c+14−14
@@ -28,7 +28,7 @@ · 27 unmodified lines
2828 static void print_string(struct trace_seq *s, struct event_format *event,
2929 const char *name, const void *data)
3030 {
31− struct format_field *f = pevent_find_field(event, name);
31+ struct format_field *f = tep_find_field(event, name);
3232 int offset;
3333 int length;
3434
@@ -42,7 +42,7 @@ static void print_string(struct trace_seq *s, struct event_format *event, · 7 unmodified lines
4242
4343 if (!strncmp(f->type, "__data_loc", 10)) {
4444 unsigned long long v;
45− if (pevent_read_number_field(f, data, &v)) {
45+ if (tep_read_number_field(f, data, &v)) {
4646 trace_seq_printf(s, "invalid_data_loc");
4747 return;
4848 }
@@ -53,12 +53,12 @@ static void print_string(struct trace_seq *s, struct event_format *event, · 4 unmodified lines
5353 trace_seq_printf(s, "%.*s", length, (char *)data + offset);
5454 }
5555
56−#define SF(fn) pevent_print_num_field(s, fn ":%d", event, fn, record, 0)
57−#define SFX(fn) pevent_print_num_field(s, fn ":%#x", event, fn, record, 0)
56+#define SF(fn) tep_print_num_field(s, fn ":%d", event, fn, record, 0)
57+#define SFX(fn) tep_print_num_field(s, fn ":%#x", event, fn, record, 0)
5858 #define SP() trace_seq_putc(s, ' ')
5959
6060 static int drv_bss_info_changed(struct trace_seq *s,
61− struct pevent_record *record,
61+ struct tep_record *record,
6262 struct event_format *event, void *context)
6363 {
6464 void *data = record->data;
@@ -66,7 +66,7 @@ static int drv_bss_info_changed(struct trace_seq *s, · 1 unmodified line
6666 print_string(s, event, "wiphy_name", data);
6767 trace_seq_printf(s, " vif:");
6868 print_string(s, event, "vif_name", data);
69− pevent_print_num_field(s, "(%d)", event, "vif_type", record, 1);
69+ tep_print_num_field(s, "(%d)", event, "vif_type", record, 1);
7070
7171 trace_seq_printf(s, "\n%*s", INDENT, "");
7272 SF("assoc"); SP();
@@ -86,17 +86,17 @@ static int drv_bss_info_changed(struct trace_seq *s, · 13 unmodified lines
8686 return 0;
8787 }
8888
89−int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
89+int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
9090 {
91− pevent_register_event_handler(pevent, -1, "mac80211",
92− "drv_bss_info_changed",
93− drv_bss_info_changed, NULL);
91+ tep_register_event_handler(pevent, -1, "mac80211",
92+ "drv_bss_info_changed",
93+ drv_bss_info_changed, NULL);
9494 return 0;
9595 }
9696
97−void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
97+void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
9898 {
99− pevent_unregister_event_handler(pevent, -1, "mac80211",
100− "drv_bss_info_changed",
101− drv_bss_info_changed, NULL);
99+ tep_unregister_event_handler(pevent, -1, "mac80211",
100+ "drv_bss_info_changed",
101+ drv_bss_info_changed, NULL);
102102 }
tools/lib/traceevent/plugin_sched_switch.c+30−30
@@ -45,7 +45,7 @@ static void write_state(struct trace_seq *s, int val) · 44 unmodified lines
4545 }
4646
4747 static void write_and_save_comm(struct format_field *field,
48− struct pevent_record *record,
48+ struct tep_record *record,
4949 struct trace_seq *s, int pid)
5050 {
5151 const char *comm;
@@ -61,100 +61,100 @@ static void write_and_save_comm(struct format_field *field, · 9 unmodified lines
6161 comm = &s->buffer[len];
6262
6363 /* Help out the comm to ids. This will handle dups */
64− pevent_register_comm(field->event->pevent, comm, pid);
64+ tep_register_comm(field->event->pevent, comm, pid);
6565 }
6666
6767 static int sched_wakeup_handler(struct trace_seq *s,
68− struct pevent_record *record,
68+ struct tep_record *record,
6969 struct event_format *event, void *context)
7070 {
7171 struct format_field *field;
7272 unsigned long long val;
7373
74− if (pevent_get_field_val(s, event, "pid", record, &val, 1))
74+ if (tep_get_field_val(s, event, "pid", record, &val, 1))
7575 return trace_seq_putc(s, '!');
7676
77− field = pevent_find_any_field(event, "comm");
77+ field = tep_find_any_field(event, "comm");
7878 if (field) {
7979 write_and_save_comm(field, record, s, val);
8080 trace_seq_putc(s, ':');
8181 }
8282 trace_seq_printf(s, "%lld", val);
8383
84− if (pevent_get_field_val(s, event, "prio", record, &val, 0) == 0)
84+ if (tep_get_field_val(s, event, "prio", record, &val, 0) == 0)
8585 trace_seq_printf(s, " [%lld]", val);
8686
87− if (pevent_get_field_val(s, event, "success", record, &val, 1) == 0)
87+ if (tep_get_field_val(s, event, "success", record, &val, 1) == 0)
8888 trace_seq_printf(s, " success=%lld", val);
8989
90− if (pevent_get_field_val(s, event, "target_cpu", record, &val, 0) == 0)
90+ if (tep_get_field_val(s, event, "target_cpu", record, &val, 0) == 0)
9191 trace_seq_printf(s, " CPU:%03llu", val);
9292
9393 return 0;
9494 }
9595
9696 static int sched_switch_handler(struct trace_seq *s,
97− struct pevent_record *record,
97+ struct tep_record *record,
9898 struct event_format *event, void *context)
9999 {
100100 struct format_field *field;
101101 unsigned long long val;
102102
103− if (pevent_get_field_val(s, event, "prev_pid", record, &val, 1))
103+ if (tep_get_field_val(s, event, "prev_pid", record, &val, 1))
104104 return trace_seq_putc(s, '!');
105105
106− field = pevent_find_any_field(event, "prev_comm");
106+ field = tep_find_any_field(event, "prev_comm");
107107 if (field) {
108108 write_and_save_comm(field, record, s, val);
109109 trace_seq_putc(s, ':');
110110 }
111111 trace_seq_printf(s, "%lld ", val);
112112
113− if (pevent_get_field_val(s, event, "prev_prio", record, &val, 0) == 0)
113+ if (tep_get_field_val(s, event, "prev_prio", record, &val, 0) == 0)
114114 trace_seq_printf(s, "[%d] ", (int) val);
115115
116− if (pevent_get_field_val(s, event, "prev_state", record, &val, 0) == 0)
116+ if (tep_get_field_val(s, event, "prev_state", record, &val, 0) == 0)
117117 write_state(s, val);
118118
119119 trace_seq_puts(s, " ==> ");
120120
121− if (pevent_get_field_val(s, event, "next_pid", record, &val, 1))
121+ if (tep_get_field_val(s, event, "next_pid", record, &val, 1))
122122 return trace_seq_putc(s, '!');
123123
124− field = pevent_find_any_field(event, "next_comm");
124+ field = tep_find_any_field(event, "next_comm");
125125 if (field) {
126126 write_and_save_comm(field, record, s, val);
127127 trace_seq_putc(s, ':');
128128 }
129129 trace_seq_printf(s, "%lld", val);
130130
131− if (pevent_get_field_val(s, event, "next_prio", record, &val, 0) == 0)
131+ if (tep_get_field_val(s, event, "next_prio", record, &val, 0) == 0)
132132 trace_seq_printf(s, " [%d]", (int) val);
133133
134134 return 0;
135135 }
136136
137−int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
137+int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
138138 {
139− pevent_register_event_handler(pevent, -1, "sched", "sched_switch",
140− sched_switch_handler, NULL);
139+ tep_register_event_handler(pevent, -1, "sched", "sched_switch",
140+ sched_switch_handler, NULL);
141141
142− pevent_register_event_handler(pevent, -1, "sched", "sched_wakeup",
143− sched_wakeup_handler, NULL);
142+ tep_register_event_handler(pevent, -1, "sched", "sched_wakeup",
143+ sched_wakeup_handler, NULL);
144144
145− pevent_register_event_handler(pevent, -1, "sched", "sched_wakeup_new",
146− sched_wakeup_handler, NULL);
145+ tep_register_event_handler(pevent, -1, "sched", "sched_wakeup_new",
146+ sched_wakeup_handler, NULL);
147147 return 0;
148148 }
149149
150−void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
150+void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
151151 {
152− pevent_unregister_event_handler(pevent, -1, "sched", "sched_switch",
153− sched_switch_handler, NULL);
152+ tep_unregister_event_handler(pevent, -1, "sched", "sched_switch",
153+ sched_switch_handler, NULL);
154154
155− pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup",
156− sched_wakeup_handler, NULL);
155+ tep_unregister_event_handler(pevent, -1, "sched", "sched_wakeup",
156+ sched_wakeup_handler, NULL);
157157
158− pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup_new",
159− sched_wakeup_handler, NULL);
158+ tep_unregister_event_handler(pevent, -1, "sched", "sched_wakeup_new",
159+ sched_wakeup_handler, NULL);
160160 }
tools/lib/traceevent/plugin_scsi.c+12−12
@@ -413,21 +413,21 @@ unsigned long long process_scsi_trace_parse_cdb(struct trace_seq *s, · 412 unmodified lines
413413 return 0;
414414 }
415415
416−int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
416+int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
417417 {
418− pevent_register_print_function(pevent,
419− process_scsi_trace_parse_cdb,
420− PEVENT_FUNC_ARG_STRING,
421− "scsi_trace_parse_cdb",
422− PEVENT_FUNC_ARG_PTR,
423− PEVENT_FUNC_ARG_PTR,
424− PEVENT_FUNC_ARG_INT,
425− PEVENT_FUNC_ARG_VOID);
418+ tep_register_print_function(pevent,
419+ process_scsi_trace_parse_cdb,
420+ TEP_FUNC_ARG_STRING,
421+ "scsi_trace_parse_cdb",
422+ TEP_FUNC_ARG_PTR,
423+ TEP_FUNC_ARG_PTR,
424+ TEP_FUNC_ARG_INT,
425+ TEP_FUNC_ARG_VOID);
426426 return 0;
427427 }
428428
429−void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
429+void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
430430 {
431− pevent_unregister_print_function(pevent, process_scsi_trace_parse_cdb,
432− "scsi_trace_parse_cdb");
431+ tep_unregister_print_function(pevent, process_scsi_trace_parse_cdb,
432+ "scsi_trace_parse_cdb");
433433 }
tools/lib/traceevent/plugin_xen.c+10−10
@@ -119,19 +119,19 @@ unsigned long long process_xen_hypercall_name(struct trace_seq *s, · 118 unmodified lines
119119 return 0;
120120 }
121121
122−int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
122+int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
123123 {
124− pevent_register_print_function(pevent,
125− process_xen_hypercall_name,
126− PEVENT_FUNC_ARG_STRING,
127− "xen_hypercall_name",
128− PEVENT_FUNC_ARG_INT,
129− PEVENT_FUNC_ARG_VOID);
124+ tep_register_print_function(pevent,
125+ process_xen_hypercall_name,
126+ TEP_FUNC_ARG_STRING,
127+ "xen_hypercall_name",
128+ TEP_FUNC_ARG_INT,
129+ TEP_FUNC_ARG_VOID);
130130 return 0;
131131 }
132132
133−void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
133+void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
134134 {
135− pevent_unregister_print_function(pevent, process_xen_hypercall_name,
136− "xen_hypercall_name");
135+ tep_unregister_print_function(pevent, process_xen_hypercall_name,
136+ "xen_hypercall_name");
137137 }
tools/lib/traceevent/trace-seq.c+1−15
@@ -1,21 +1,7 @@
1+// SPDX-License-Identifier: LGPL-2.1
12 /*
23 * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
34 *
4− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU Lesser General Public
7− * License as published by the Free Software Foundation;
8− * version 2.1 of the License (not later!)
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU Lesser General Public License for more details.
14− *
15− * You should have received a copy of the GNU Lesser General Public
16− * License along with this program; if not, see <http://www.gnu.org/licenses>
17− *
18− * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195 */
206 #include <stdio.h>
217 #include <stdlib.h>
tools/perf/Documentation/perf-annotate.txt+9−0
@@ -118,6 +118,15 @@ OPTIONS · 117 unmodified lines
118118 --group::
119119 Show event group information together
120120
121+--percent-type::
122+ Set annotation percent type from following choices:
123+ global-period, local-period, global-hits, local-hits
124+
125+ The local/global keywords set if the percentage is computed
126+ in the scope of the function (local) or the whole data (global).
127+ The period/hits keywords set the base the percentage is computed
128+ on - the samples period or the number of samples (hits).
129+
121130 SEE ALSO
122131 --------
123132 linkperf:perf-record[1], linkperf:perf-report[1]
tools/perf/Documentation/perf-report.txt+9−0
@@ -477,6 +477,15 @@ include::itrace.txt[] · 476 unmodified lines
477477 Display monitored tasks stored in perf data. Displaying pid/tid/ppid
478478 plus the command string aligned to distinguish parent and child tasks.
479479
480+--percent-type::
481+ Set annotation percent type from following choices:
482+ global-period, local-period, global-hits, local-hits
483+
484+ The local/global keywords set if the percentage is computed
485+ in the scope of the function (local) or the whole data (global).
486+ The period/hits keywords set the base the percentage is computed
487+ on - the samples period or the number of samples (hits).
488+
480489 include::callchain-overhead-calculation.txt[]
481490
482491 SEE ALSO
tools/perf/Makefile+2−2
@@ -84,10 +84,10 @@ endif # has_clean · 83 unmodified lines
8484 endif # MAKECMDGOALS
8585
8686 #
87−# The clean target is not really parallel, don't print the jobs info:
87+# Explicitly disable parallelism for the clean target.
8888 #
8989 clean:
90− $(make)
90+ $(make) -j1
9191
9292 #
9393 # The build-test target is not really parallel, don't print the jobs info,
tools/perf/arch/arm64/util/arm-spe.c+1−0
@@ -194,6 +194,7 @@ struct auxtrace_record *arm_spe_recording_init(int *err, · 193 unmodified lines
194194 sper->itr.read_finish = arm_spe_read_finish;
195195 sper->itr.alignment = 0;
196196
197+ *err = 0;
197198 return &sper->itr;
198199 }
199200
tools/perf/arch/powerpc/util/sym-handling.c+3−1
@@ -141,8 +141,10 @@ void arch__post_process_probe_trace_events(struct perf_probe_event *pev, · 140 unmodified lines
141141 for (i = 0; i < ntevs; i++) {
142142 tev = &pev->tevs[i];
143143 map__for_each_symbol(map, sym, tmp) {
144− if (map->unmap_ip(map, sym->start) == tev->point.address)
144+ if (map->unmap_ip(map, sym->start) == tev->point.address) {
145145 arch__fix_tev_from_maps(pev, tev, map, sym);
146+ break;
147+ }
146148 }
147149 }
148150 }
tools/perf/arch/s390/util/auxtrace.c+1−0
@@ -30,6 +30,7 @@ cpumsf_info_fill(struct auxtrace_record *itr __maybe_unused, · 29 unmodified lines
3030 struct auxtrace_info_event *auxtrace_info __maybe_unused,
3131 size_t priv_size __maybe_unused)
3232 {
33+ auxtrace_info->type = PERF_AUXTRACE_S390_CPUMSF;
3334 return 0;
3435 }
3536
tools/perf/arch/x86/Makefile+0−3
@@ -19,9 +19,6 @@ systbl := $(sys)/syscalltbl.sh · 18 unmodified lines
1919 _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
2020
2121 $(header): $(sys)/syscall_64.tbl $(systbl)
22− @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
23− (diff -B arch/x86/entry/syscalls/syscall_64.tbl ../../arch/x86/entry/syscalls/syscall_64.tbl >/dev/null) \
24− || echo "Warning: Kernel ABI header at 'tools/perf/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl'" >&2 )) || true
2522 $(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@
2623
2724 clean::
tools/perf/builtin-annotate.c+4−0
@@ -542,6 +542,10 @@ int cmd_annotate(int argc, const char **argv) · 541 unmodified lines
542542 OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
543543 "'always' (default), 'never' or 'auto' only applicable to --stdio mode",
544544 stdio__config_color, "always"),
545+ OPT_CALLBACK(0, "percent-type", &annotate.opts, "local-period",
546+ "Set percent type local/global-period/hits",
547+ annotate_parse_percent_type),
548+
545549 OPT_END()
546550 };
547551 int ret;
tools/perf/builtin-kmem.c+3−3
@@ -729,7 +729,7 @@ static char *compact_gfp_string(unsigned long gfp_flags) · 728 unmodified lines
729729 static int parse_gfp_flags(struct perf_evsel *evsel, struct perf_sample *sample,
730730 unsigned int gfp_flags)
731731 {
732− struct pevent_record record = {
732+ struct tep_record record = {
733733 .cpu = sample->cpu,
734734 .data = sample->raw_data,
735735 .size = sample->raw_size,
@@ -747,7 +747,7 @@ static int parse_gfp_flags(struct perf_evsel *evsel, struct perf_sample *sample, · 11 unmodified lines
747747 }
748748
749749 trace_seq_init(&seq);
750− pevent_event_info(&seq, evsel->tp_format, &record);
750+ tep_event_info(&seq, evsel->tp_format, &record);
751751
752752 str = strtok_r(seq.buffer, " ", &pos);
753753 while (str) {
@@ -1974,7 +1974,7 @@ int cmd_kmem(int argc, const char **argv) · 1220 unmodified lines
19741974 goto out_delete;
19751975 }
19761976
1977− kmem_page_size = pevent_get_page_size(evsel->tp_format->pevent);
1977+ kmem_page_size = tep_get_page_size(evsel->tp_format->pevent);
19781978 symbol_conf.use_callchain = true;
19791979 }
19801980
tools/perf/builtin-report.c+6−3
@@ -1124,6 +1124,9 @@ int cmd_report(int argc, const char **argv) · 1123 unmodified lines
11241124 "Time span of interest (start,stop)"),
11251125 OPT_BOOLEAN(0, "inline", &symbol_conf.inline_name,
11261126 "Show inline function"),
1127+ OPT_CALLBACK(0, "percent-type", &report.annotation_opts, "local-period",
1128+ "Set percent type local/global-period/hits",
1129+ annotate_parse_percent_type),
11271130 OPT_END()
11281131 };
11291132 struct perf_data data = {
@@ -1366,9 +1369,9 @@ repeat: · 236 unmodified lines
13661369 }
13671370
13681371 if (session->tevent.pevent &&
1369− pevent_set_function_resolver(session->tevent.pevent,
1370− machine__resolve_kernel_addr,
1371− &session->machines.host) < 0) {
1372+ tep_set_function_resolver(session->tevent.pevent,
1373+ machine__resolve_kernel_addr,
1374+ &session->machines.host) < 0) {
13721375 pr_err("%s: failed to set libtraceevent function resolver\n",
13731376 __func__);
13741377 return -1;
tools/perf/builtin-script.c+3−3
@@ -3429,9 +3429,9 @@ int cmd_script(int argc, const char **argv) · 3428 unmodified lines
34293429 symbol_conf.use_callchain = false;
34303430
34313431 if (session->tevent.pevent &&
3432− pevent_set_function_resolver(session->tevent.pevent,
3433− machine__resolve_kernel_addr,
3434− &session->machines.host) < 0) {
3432+ tep_set_function_resolver(session->tevent.pevent,
3433+ machine__resolve_kernel_addr,
3434+ &session->machines.host) < 0) {
34353435 pr_err("%s: failed to set libtraceevent function resolver\n", __func__);
34363436 err = -1;
34373437 goto out_delete;
tools/perf/builtin-trace.c+165−26
@@ -77,7 +77,8 @@ struct trace { · 76 unmodified lines
7777 struct syscall *table;
7878 struct {
7979 struct perf_evsel *sys_enter,
80− *sys_exit;
80+ *sys_exit,
81+ *augmented;
8182 } events;
8283 } syscalls;
8384 struct record_opts opts;
@@ -121,7 +122,6 @@ struct trace { · 37 unmodified lines
121122 bool force;
122123 bool vfs_getname;
123124 int trace_pgfaults;
124− int open_id;
125125 };
126126
127127 struct tp_field {
@@ -157,13 +157,11 @@ TP_UINT_FIELD__SWAPPED(16); · 29 unmodified lines
157157 TP_UINT_FIELD__SWAPPED(32);
158158 TP_UINT_FIELD__SWAPPED(64);
159159
160−static int tp_field__init_uint(struct tp_field *field,
161− struct format_field *format_field,
162− bool needs_swap)
160+static int __tp_field__init_uint(struct tp_field *field, int size, int offset, bool needs_swap)
163161 {
164− field->offset = format_field->offset;
162+ field->offset = offset;
165163
166− switch (format_field->size) {
164+ switch (size) {
167165 case 1:
168166 field->integer = tp_field__u8;
169167 break;
@@ -183,18 +181,28 @@ static int tp_field__init_uint(struct tp_field *field, · 13 unmodified lines
183181 return 0;
184182 }
185183
184+static int tp_field__init_uint(struct tp_field *field, struct format_field *format_field, bool needs_swap)
185+{
186+ return __tp_field__init_uint(field, format_field->size, format_field->offset, needs_swap);
187+}
188+
186189 static void *tp_field__ptr(struct tp_field *field, struct perf_sample *sample)
187190 {
188191 return sample->raw_data + field->offset;
189192 }
190193
191−static int tp_field__init_ptr(struct tp_field *field, struct format_field *format_field)
194+static int __tp_field__init_ptr(struct tp_field *field, int offset)
192195 {
193− field->offset = format_field->offset;
196+ field->offset = offset;
194197 field->pointer = tp_field__ptr;
195198 return 0;
196199 }
197200
201+static int tp_field__init_ptr(struct tp_field *field, struct format_field *format_field)
202+{
203+ return __tp_field__init_ptr(field, format_field->offset);
204+}
205+
198206 struct syscall_tp {
199207 struct tp_field id;
200208 union {
@@ -240,7 +248,47 @@ static void perf_evsel__delete_priv(struct perf_evsel *evsel) · 39 unmodified lines
240248 perf_evsel__delete(evsel);
241249 }
242250
243−static int perf_evsel__init_syscall_tp(struct perf_evsel *evsel, void *handler)
251+static int perf_evsel__init_syscall_tp(struct perf_evsel *evsel)
252+{
253+ struct syscall_tp *sc = evsel->priv = malloc(sizeof(struct syscall_tp));
254+
255+ if (evsel->priv != NULL) {
256+ if (perf_evsel__init_tp_uint_field(evsel, &sc->id, "__syscall_nr"))
257+ goto out_delete;
258+ return 0;
259+ }
260+
261+ return -ENOMEM;
262+out_delete:
263+ zfree(&evsel->priv);
264+ return -ENOENT;
265+}
266+
267+static int perf_evsel__init_augmented_syscall_tp(struct perf_evsel *evsel)
268+{
269+ struct syscall_tp *sc = evsel->priv = malloc(sizeof(struct syscall_tp));
270+
271+ if (evsel->priv != NULL) { /* field, sizeof_field, offsetof_field */
272+ if (__tp_field__init_uint(&sc->id, sizeof(long), sizeof(long long), evsel->needs_swap))
273+ goto out_delete;
274+
275+ return 0;
276+ }
277+
278+ return -ENOMEM;
279+out_delete:
280+ zfree(&evsel->priv);
281+ return -EINVAL;
282+}
283+
284+static int perf_evsel__init_augmented_syscall_tp_args(struct perf_evsel *evsel)
285+{
286+ struct syscall_tp *sc = evsel->priv;
287+
288+ return __tp_field__init_ptr(&sc->args, sc->id.offset + sizeof(u64));
289+}
290+
291+static int perf_evsel__init_raw_syscall_tp(struct perf_evsel *evsel, void *handler)
244292 {
245293 evsel->priv = malloc(sizeof(struct syscall_tp));
246294 if (evsel->priv != NULL) {
@@ -258,7 +306,7 @@ out_delete: · 11 unmodified lines
258306 return -ENOENT;
259307 }
260308
261−static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void *handler)
309+static struct perf_evsel *perf_evsel__raw_syscall_newtp(const char *direction, void *handler)
262310 {
263311 struct perf_evsel *evsel = perf_evsel__newtp("raw_syscalls", direction);
264312
@@ -269,7 +317,7 @@ static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void · 4 unmodified lines
269317 if (IS_ERR(evsel))
270318 return NULL;
271319
272− if (perf_evsel__init_syscall_tp(evsel, handler))
320+ if (perf_evsel__init_raw_syscall_tp(evsel, handler))
273321 goto out_delete;
274322
275323 return evsel;
@@ -805,12 +853,17 @@ static struct syscall_fmt *syscall_fmt__find(const char *name) · 529 unmodified lines
805853 return bsearch(name, syscall_fmts, nmemb, sizeof(struct syscall_fmt), syscall_fmt__cmp);
806854 }
807855
856+/*
857+ * is_exit: is this "exit" or "exit_group"?
858+ * is_open: is this "open" or "openat"? To associate the fd returned in sys_exit with the pathname in sys_enter.
859+ */
808860 struct syscall {
809861 struct event_format *tp_format;
810862 int nr_args;
863+ bool is_exit;
864+ bool is_open;
811865 struct format_field *args;
812866 const char *name;
813− bool is_exit;
814867 struct syscall_fmt *fmt;
815868 struct syscall_arg_fmt *arg_fmt;
816869 };
@@ -1299,6 +1352,7 @@ static int trace__read_syscall_info(struct trace *trace, int id) · 482 unmodified lines
12991352 }
13001353
13011354 sc->is_exit = !strcmp(name, "exit_group") || !strcmp(name, "exit");
1355+ sc->is_open = !strcmp(name, "open") || !strcmp(name, "openat");
13021356
13031357 return syscall__set_arg_fmts(sc);
13041358 }
@@ -1661,6 +1715,37 @@ out_put: · 356 unmodified lines
16611715 return err;
16621716 }
16631717
1718+static int trace__fprintf_sys_enter(struct trace *trace, struct perf_evsel *evsel,
1719+ struct perf_sample *sample)
1720+{
1721+ struct thread_trace *ttrace;
1722+ struct thread *thread;
1723+ int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
1724+ struct syscall *sc = trace__syscall_info(trace, evsel, id);
1725+ char msg[1024];
1726+ void *args;
1727+
1728+ if (sc == NULL)
1729+ return -1;
1730+
1731+ thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
1732+ ttrace = thread__trace(thread, trace->output);
1733+ /*
1734+ * We need to get ttrace just to make sure it is there when syscall__scnprintf_args()
1735+ * and the rest of the beautifiers accessing it via struct syscall_arg touches it.
1736+ */
1737+ if (ttrace == NULL)
1738+ goto out_put;
1739+
1740+ args = perf_evsel__sc_tp_ptr(evsel, args, sample);
1741+ syscall__scnprintf_args(sc, msg, sizeof(msg), args, trace, thread);
1742+ fprintf(trace->output, "%s", msg);
1743+ err = 0;
1744+out_put:
1745+ thread__put(thread);
1746+ return err;
1747+}
1748+
16641749 static int trace__resolve_callchain(struct trace *trace, struct perf_evsel *evsel,
16651750 struct perf_sample *sample,
16661751 struct callchain_cursor *cursor)
@@ -1722,7 +1807,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel, · 55 unmodified lines
17221807
17231808 ret = perf_evsel__sc_tp_uint(evsel, ret, sample);
17241809
1725− if (id == trace->open_id && ret >= 0 && ttrace->filename.pending_open) {
1810+ if (sc->is_open && ret >= 0 && ttrace->filename.pending_open) {
17261811 trace__set_fd_pathname(thread, ret, ttrace->filename.name);
17271812 ttrace->filename.pending_open = false;
17281813 ++trace->stats.vfs_getname;
@@ -1957,11 +2042,17 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, · 228 unmodified lines
19572042 fprintf(trace->output, "%s:", evsel->name);
19582043
19592044 if (perf_evsel__is_bpf_output(evsel)) {
1960− bpf_output__fprintf(trace, sample);
2045+ if (evsel == trace->syscalls.events.augmented)
2046+ trace__fprintf_sys_enter(trace, evsel, sample);
2047+ else
2048+ bpf_output__fprintf(trace, sample);
19612049 } else if (evsel->tp_format) {
1962− event_format__fprintf(evsel->tp_format, sample->cpu,
1963− sample->raw_data, sample->raw_size,
1964− trace->output);
2050+ if (strncmp(evsel->tp_format->name, "sys_enter_", 10) ||
2051+ trace__fprintf_sys_enter(trace, evsel, sample)) {
2052+ event_format__fprintf(evsel->tp_format, sample->cpu,
2053+ sample->raw_data, sample->raw_size,
2054+ trace->output);
2055+ }
19652056 }
19662057
19672058 fprintf(trace->output, "\n");
@@ -2242,14 +2333,14 @@ static int trace__add_syscall_newtp(struct trace *trace) · 274 unmodified lines
22422333 struct perf_evlist *evlist = trace->evlist;
22432334 struct perf_evsel *sys_enter, *sys_exit;
22442335
2245− sys_enter = perf_evsel__syscall_newtp("sys_enter", trace__sys_enter);
2336+ sys_enter = perf_evsel__raw_syscall_newtp("sys_enter", trace__sys_enter);
22462337 if (sys_enter == NULL)
22472338 goto out;
22482339
22492340 if (perf_evsel__init_sc_tp_ptr_field(sys_enter, args))
22502341 goto out_delete_sys_enter;
22512342
2252− sys_exit = perf_evsel__syscall_newtp("sys_exit", trace__sys_exit);
2343+ sys_exit = perf_evsel__raw_syscall_newtp("sys_exit", trace__sys_exit);
22532344 if (sys_exit == NULL)
22542345 goto out_delete_sys_enter;
22552346
@@ -2671,7 +2762,7 @@ static int trace__replay(struct trace *trace) · 415 unmodified lines
26712762 "syscalls:sys_enter");
26722763
26732764 if (evsel &&
2674− (perf_evsel__init_syscall_tp(evsel, trace__sys_enter) < 0 ||
2765+ (perf_evsel__init_raw_syscall_tp(evsel, trace__sys_enter) < 0 ||
26752766 perf_evsel__init_sc_tp_ptr_field(evsel, args))) {
26762767 pr_err("Error during initialize raw_syscalls:sys_enter event\n");
26772768 goto out;
@@ -2683,7 +2774,7 @@ static int trace__replay(struct trace *trace) · 5 unmodified lines
26832774 evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
26842775 "syscalls:sys_exit");
26852776 if (evsel &&
2686− (perf_evsel__init_syscall_tp(evsel, trace__sys_exit) < 0 ||
2777+ (perf_evsel__init_raw_syscall_tp(evsel, trace__sys_exit) < 0 ||
26872778 perf_evsel__init_sc_tp_uint_field(evsel, ret))) {
26882779 pr_err("Error during initialize raw_syscalls:sys_exit event\n");
26892780 goto out;
@@ -2923,6 +3014,36 @@ static void evlist__set_evsel_handler(struct perf_evlist *evlist, void *handler) · 233 unmodified lines
29233014 evsel->handler = handler;
29243015 }
29253016
3017+static int evlist__set_syscall_tp_fields(struct perf_evlist *evlist)
3018+{
3019+ struct perf_evsel *evsel;
3020+
3021+ evlist__for_each_entry(evlist, evsel) {
3022+ if (evsel->priv || !evsel->tp_format)
3023+ continue;
3024+
3025+ if (strcmp(evsel->tp_format->system, "syscalls"))
3026+ continue;
3027+
3028+ if (perf_evsel__init_syscall_tp(evsel))
3029+ return -1;
3030+
3031+ if (!strncmp(evsel->tp_format->name, "sys_enter_", 10)) {
3032+ struct syscall_tp *sc = evsel->priv;
3033+
3034+ if (__tp_field__init_ptr(&sc->args, sc->id.offset + sizeof(u64)))
3035+ return -1;
3036+ } else if (!strncmp(evsel->tp_format->name, "sys_exit_", 9)) {
3037+ struct syscall_tp *sc = evsel->priv;
3038+
3039+ if (__tp_field__init_uint(&sc->ret, sizeof(u64), sc->id.offset + sizeof(u64), evsel->needs_swap))
3040+ return -1;
3041+ }
3042+ }
3043+
3044+ return 0;
3045+}
3046+
29263047 /*
29273048 * XXX: Hackish, just splitting the combined -e+--event (syscalls
29283049 * (raw_syscalls:{sys_{enter,exit}} + events (tracepoints, HW, SW, etc) to use
@@ -3123,8 +3244,9 @@ int cmd_trace(int argc, const char **argv) · 194 unmodified lines
31233244 };
31243245 bool __maybe_unused max_stack_user_set = true;
31253246 bool mmap_pages_user_set = true;
3247+ struct perf_evsel *evsel;
31263248 const char * const trace_subcommands[] = { "record", NULL };
3127− int err;
3249+ int err = -1;
31283250 char bf[BUFSIZ];
31293251
31303252 signal(SIGSEGV, sighandler_dump_stack);
@@ -3147,6 +3269,20 @@ int cmd_trace(int argc, const char **argv) · 16 unmodified lines
31473269 "cgroup monitoring only available in system-wide mode");
31483270 }
31493271
3272+ evsel = bpf__setup_output_event(trace.evlist, "__augmented_syscalls__");
3273+ if (IS_ERR(evsel)) {
3274+ bpf__strerror_setup_output_event(trace.evlist, PTR_ERR(evsel), bf, sizeof(bf));
3275+ pr_err("ERROR: Setup trace syscalls enter failed: %s\n", bf);
3276+ goto out;
3277+ }
3278+
3279+ if (evsel) {
3280+ if (perf_evsel__init_augmented_syscall_tp(evsel) ||
3281+ perf_evsel__init_augmented_syscall_tp_args(evsel))
3282+ goto out;
3283+ trace.syscalls.events.augmented = evsel;
3284+ }
3285+
31503286 err = bpf__setup_stdout(trace.evlist);
31513287 if (err) {
31523288 bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf));
@@ -3182,8 +3318,13 @@ int cmd_trace(int argc, const char **argv) · 29 unmodified lines
31823318 symbol_conf.use_callchain = true;
31833319 }
31843320
3185− if (trace.evlist->nr_entries > 0)
3321+ if (trace.evlist->nr_entries > 0) {
31863322 evlist__set_evsel_handler(trace.evlist, trace__event_handler);
3323+ if (evlist__set_syscall_tp_fields(trace.evlist)) {
3324+ perror("failed to set syscalls:* tracepoint fields");
3325+ goto out;
3326+ }
3327+ }
31873328
31883329 if ((argc >= 1) && (strcmp(argv[0], "record") == 0))
31893330 return trace__record(&trace, argc-1, &argv[1]);
@@ -3205,8 +3346,6 @@ int cmd_trace(int argc, const char **argv) · 15 unmodified lines
32053346 }
32063347 }
32073348
3208− trace.open_id = syscalltbl__id(trace.sctbl, "open");
3209−
32103349 err = target__validate(&trace.opts.target);
32113350 if (err) {
32123351 target__strerror(&trace.opts.target, err, bf, sizeof(bf));
tools/perf/check-headers.sh+14−3
@@ -67,8 +67,12 @@ check_2 () { · 66 unmodified lines
6767
6868 cmd="diff $* $file1 $file2 > /dev/null"
6969
70− test -f $file2 &&
71− eval $cmd || echo "Warning: Kernel ABI header at 'tools/$file' differs from latest version at '$file'" >&2
70+ test -f $file2 && {
71+ eval $cmd || {
72+ echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
73+ echo diff -u $file1 $file2
74+ }
75+ }
7276 }
7377
7478 check () {
@@ -76,7 +80,7 @@ check () { · 1 unmodified line
7680
7781 shift
7882
79− check_2 ../$file ../../$file $*
83+ check_2 tools/$file $file $*
8084 }
8185
8286 # Check if we have the kernel headers (tools/perf/../../include), else
@@ -84,6 +88,8 @@ check () { · 1 unmodified line
8488 # differences.
8589 test -d ../../include || exit 0
8690
91+cd ../..
92+
8793 # simple diff check
8894 for i in $HEADERS; do
8995 check $i -B
@@ -94,3 +100,8 @@ check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/ex · 4 unmodified lines
94100 check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"'
95101 check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common.h>"'
96102 check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"'
103+
104+# diff non-symmetric files
105+check_2 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
106+
107+cd tools/perf
tools/perf/examples/bpf/augmented_syscalls.c+55−0
@@ -0,0 +1,55 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Augment the openat syscall with the contents of the filename pointer argument.
4+ *
5+ * Test it with:
6+ *
7+ * perf trace -e tools/perf/examples/bpf/augmented_syscalls.c cat /etc/passwd > /dev/null
8+ *
9+ * It'll catch some openat syscalls related to the dynamic linked and
10+ * the last one should be the one for '/etc/passwd'.
11+ *
12+ * This matches what is marshalled into the raw_syscall:sys_enter payload
13+ * expected by the 'perf trace' beautifiers, and can be used by them unmodified,
14+ * which will be done as that feature is implemented in the next csets, for now
15+ * it will appear in a dump done by the default tracepoint handler in 'perf trace',
16+ * that uses bpf_output__fprintf() to just dump those contents, as done with
17+ * the bpf-output event associated with the __bpf_output__ map declared in
18+ * tools/perf/include/bpf/stdio.h.
19+ */
20+
21+#include <stdio.h>
22+
23+struct bpf_map SEC("maps") __augmented_syscalls__ = {
24+ .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
25+ .key_size = sizeof(int),
26+ .value_size = sizeof(u32),
27+ .max_entries = __NR_CPUS__,
28+};
29+
30+struct syscall_enter_openat_args {
31+ unsigned long long common_tp_fields;
32+ long syscall_nr;
33+ long dfd;
34+ char *filename_ptr;
35+ long flags;
36+ long mode;
37+};
38+
39+struct augmented_enter_openat_args {
40+ struct syscall_enter_openat_args args;
41+ char filename[64];
42+};
43+
44+int syscall_enter(openat)(struct syscall_enter_openat_args *args)
45+{
46+ struct augmented_enter_openat_args augmented_args;
47+
48+ probe_read(&augmented_args.args, sizeof(augmented_args.args), args);
49+ probe_read_str(&augmented_args.filename, sizeof(augmented_args.filename), args->filename_ptr);
50+ perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU,
51+ &augmented_args, sizeof(augmented_args));
52+ return 1;
53+}
54+
55+license(GPL);
tools/perf/examples/bpf/hello.c+9−0
@@ -0,0 +1,9 @@
1+#include <stdio.h>
2+
3+int syscall_enter(openat)(void *args)
4+{
5+ puts("Hello, world\n");
6+ return 0;
7+}
8+
9+license(GPL);
tools/perf/examples/bpf/sys_enter_openat.c+33−0
@@ -0,0 +1,33 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Hook into 'openat' syscall entry tracepoint
4+ *
5+ * Test it with:
6+ *
7+ * perf trace -e tools/perf/examples/bpf/sys_enter_openat.c cat /etc/passwd > /dev/null
8+ *
9+ * It'll catch some openat syscalls related to the dynamic linked and
10+ * the last one should be the one for '/etc/passwd'.
11+ *
12+ * The syscall_enter_openat_args can be used to get the syscall fields
13+ * and use them for filtering calls, i.e. use in expressions for
14+ * the return value.
15+ */
16+
17+#include <bpf.h>
18+
19+struct syscall_enter_openat_args {
20+ unsigned long long unused;
21+ long syscall_nr;
22+ long dfd;
23+ char *filename_ptr;
24+ long flags;
25+ long mode;
26+};
27+
28+int syscall_enter(openat)(struct syscall_enter_openat_args *args)
29+{
30+ return 1;
31+}
32+
33+license(GPL);
tools/perf/include/bpf/bpf.h+20−0
@@ -4,13 +4,33 @@ · 3 unmodified lines
44
55 #include <uapi/linux/bpf.h>
66
7+/*
8+ * A helper structure used by eBPF C program to describe map attributes to
9+ * elf_bpf loader, taken from tools/testing/selftests/bpf/bpf_helpers.h:
10+ */
11+struct bpf_map {
12+ unsigned int type;
13+ unsigned int key_size;
14+ unsigned int value_size;
15+ unsigned int max_entries;
16+ unsigned int map_flags;
17+ unsigned int inner_map_idx;
18+ unsigned int numa_node;
19+};
20+
721 #define SEC(NAME) __attribute__((section(NAME), used))
822
923 #define probe(function, vars) \
1024 SEC(#function "=" #function " " #vars) function
1125
26+#define syscall_enter(name) \
27+ SEC("syscalls:sys_enter_" #name) syscall_enter_ ## name
28+
1229 #define license(name) \
1330 char _license[] SEC("license") = #name; \
1431 int _version SEC("version") = LINUX_VERSION_CODE;
1532
33+static int (*probe_read)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read;
34+static int (*probe_read_str)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read_str;
35+
1636 #endif /* _PERF_BPF_H */
tools/perf/include/bpf/stdio.h+19−0
@@ -0,0 +1,19 @@
1+// SPDX-License-Identifier: GPL-2.0
2+
3+#include <bpf.h>
4+
5+struct bpf_map SEC("maps") __bpf_stdout__ = {
6+ .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
7+ .key_size = sizeof(int),
8+ .value_size = sizeof(u32),
9+ .max_entries = __NR_CPUS__,
10+};
11+
12+static int (*perf_event_output)(void *, struct bpf_map *, int, void *, unsigned long) =
13+ (void *)BPF_FUNC_perf_event_output;
14+
15+#define puts(from) \
16+ ({ const int __len = sizeof(from); \
17+ char __from[__len] = from; \
18+ perf_event_output(args, &__bpf_stdout__, BPF_F_CURRENT_CPU, \
19+ &__from, __len & (sizeof(from) - 1)); })
tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json+32−0
@@ -0,0 +1,32 @@
1+[
2+ {
3+ "ArchStdEvent": "L1D_CACHE_RD",
4+ },
5+ {
6+ "ArchStdEvent": "L1D_CACHE_WR",
7+ },
8+ {
9+ "ArchStdEvent": "L1D_CACHE_REFILL_RD",
10+ },
11+ {
12+ "ArchStdEvent": "L1D_CACHE_REFILL_WR",
13+ },
14+ {
15+ "ArchStdEvent": "L1D_TLB_REFILL_RD",
16+ },
17+ {
18+ "ArchStdEvent": "L1D_TLB_REFILL_WR",
19+ },
20+ {
21+ "ArchStdEvent": "L1D_TLB_RD",
22+ },
23+ {
24+ "ArchStdEvent": "L1D_TLB_WR",
25+ },
26+ {
27+ "ArchStdEvent": "BUS_ACCESS_RD",
28+ },
29+ {
30+ "ArchStdEvent": "BUS_ACCESS_WR",
31+ }
32+]
tools/perf/pmu-events/arch/arm64/mapfile.csv+1−0
@@ -16,3 +16,4 @@ · 15 unmodified lines
1616 0x00000000420f5160,v1,cavium/thunderx2,core
1717 0x00000000430f0af0,v1,cavium/thunderx2,core
1818 0x00000000480fd010,v1,hisilicon/hip08,core
19+0x00000000500f0000,v1,ampere/emag,core
tools/perf/tests/bitmap.c+0−2
@@ -16,8 +16,6 @@ static unsigned long *get_bitmap(const char *str, int nbits) · 15 unmodified lines
1616 bm = bitmap_alloc(nbits);
1717
1818 if (map && bm) {
19− bitmap_zero(bm, nbits);
20−
2119 for (i = 0; i < map->nr; i++)
2220 set_bit(map->map[i], bm);
2321 }
tools/perf/tests/code-reading.c+3−1
@@ -232,6 +232,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode, · 231 unmodified lines
232232 u64 objdump_addr;
233233 const char *objdump_name;
234234 char decomp_name[KMOD_DECOMP_LEN];
235+ bool decomp = false;
235236 int ret;
236237
237238 pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr);
@@ -305,6 +306,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode, · 67 unmodified lines
305306 return -1;
306307 }
307308
309+ decomp = true;
308310 objdump_name = decomp_name;
309311 }
310312
@@ -312,7 +314,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode, · 1 unmodified line
312314 objdump_addr = map__rip_2objdump(al.map, al.addr);
313315 ret = read_via_objdump(objdump_name, objdump_addr, buf2, len);
314316
315− if (dso__needs_decompress(al.map->dso))
317+ if (decomp)
316318 unlink(objdump_name);
317319
318320 if (ret > 0) {
tools/perf/tests/kmod-path.c+65−71
@@ -5,34 +5,28 @@ · 4 unmodified lines
55 #include "dso.h"
66 #include "debug.h"
77
8−static int test(const char *path, bool alloc_name, bool alloc_ext,
9− bool kmod, bool comp, const char *name, const char *ext)
8+static int test(const char *path, bool alloc_name, bool kmod,
9+ int comp, const char *name)
1010 {
1111 struct kmod_path m;
1212
1313 memset(&m, 0x0, sizeof(m));
1414
1515 TEST_ASSERT_VAL("kmod_path__parse",
16− !__kmod_path__parse(&m, path, alloc_name, alloc_ext));
16+ !__kmod_path__parse(&m, path, alloc_name));
1717
18− pr_debug("%s - alloc name %d, alloc ext %d, kmod %d, comp %d, name '%s', ext '%s'\n",
19− path, alloc_name, alloc_ext, m.kmod, m.comp, m.name, m.ext);
18+ pr_debug("%s - alloc name %d, kmod %d, comp %d, name '%s'\n",
19+ path, alloc_name, m.kmod, m.comp, m.name);
2020
2121 TEST_ASSERT_VAL("wrong kmod", m.kmod == kmod);
2222 TEST_ASSERT_VAL("wrong comp", m.comp == comp);
2323
24− if (ext)
25− TEST_ASSERT_VAL("wrong ext", m.ext && !strcmp(ext, m.ext));
26− else
27− TEST_ASSERT_VAL("wrong ext", !m.ext);
28−
2924 if (name)
3025 TEST_ASSERT_VAL("wrong name", m.name && !strcmp(name, m.name));
3126 else
3227 TEST_ASSERT_VAL("wrong name", !m.name);
3328
3429 free(m.name);
35− free(m.ext);
3630 return 0;
3731 }
3832
@@ -45,118 +39,118 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect) · 6 unmodified lines
4539 return 0;
4640 }
4741
48−#define T(path, an, ae, k, c, n, e) \
49− TEST_ASSERT_VAL("failed", !test(path, an, ae, k, c, n, e))
42+#define T(path, an, k, c, n) \
43+ TEST_ASSERT_VAL("failed", !test(path, an, k, c, n))
5044
5145 #define M(path, c, e) \
5246 TEST_ASSERT_VAL("failed", !test_is_kernel_module(path, c, e))
5347
5448 int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
5549 {
56− /* path alloc_name alloc_ext kmod comp name ext */
57− T("/xxxx/xxxx/x-x.ko", true , true , true, false, "[x_x]", NULL);
58− T("/xxxx/xxxx/x-x.ko", false , true , true, false, NULL , NULL);
59− T("/xxxx/xxxx/x-x.ko", true , false , true, false, "[x_x]", NULL);
60− T("/xxxx/xxxx/x-x.ko", false , false , true, false, NULL , NULL);
50+ /* path alloc_name kmod comp name */
51+ T("/xxxx/xxxx/x-x.ko", true , true, 0 , "[x_x]");
52+ T("/xxxx/xxxx/x-x.ko", false , true, 0 , NULL );
53+ T("/xxxx/xxxx/x-x.ko", true , true, 0 , "[x_x]");
54+ T("/xxxx/xxxx/x-x.ko", false , true, 0 , NULL );
6155 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
6256 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true);
6357 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false);
6458
6559 #ifdef HAVE_ZLIB_SUPPORT
66− /* path alloc_name alloc_ext kmod comp name ext */
67− T("/xxxx/xxxx/x.ko.gz", true , true , true, true, "[x]", "gz");
68− T("/xxxx/xxxx/x.ko.gz", false , true , true, true, NULL , "gz");
69− T("/xxxx/xxxx/x.ko.gz", true , false , true, true, "[x]", NULL);
70− T("/xxxx/xxxx/x.ko.gz", false , false , true, true, NULL , NULL);
60+ /* path alloc_name kmod comp name */
61+ T("/xxxx/xxxx/x.ko.gz", true , true, 1 , "[x]");
62+ T("/xxxx/xxxx/x.ko.gz", false , true, 1 , NULL );
63+ T("/xxxx/xxxx/x.ko.gz", true , true, 1 , "[x]");
64+ T("/xxxx/xxxx/x.ko.gz", false , true, 1 , NULL );
7165 M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
7266 M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
7367 M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_USER, false);
7468
75− /* path alloc_name alloc_ext kmod comp name ext */
76− T("/xxxx/xxxx/x.gz", true , true , false, true, "x.gz" ,"gz");
77− T("/xxxx/xxxx/x.gz", false , true , false, true, NULL ,"gz");
78− T("/xxxx/xxxx/x.gz", true , false , false, true, "x.gz" , NULL);
79− T("/xxxx/xxxx/x.gz", false , false , false, true, NULL , NULL);
69+ /* path alloc_name kmod comp name */
70+ T("/xxxx/xxxx/x.gz", true , false, 1 , "x.gz");
71+ T("/xxxx/xxxx/x.gz", false , false, 1 , NULL );
72+ T("/xxxx/xxxx/x.gz", true , false, 1 , "x.gz");
73+ T("/xxxx/xxxx/x.gz", false , false, 1 , NULL );
8074 M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
8175 M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_KERNEL, false);
8276 M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_USER, false);
8377
84− /* path alloc_name alloc_ext kmod comp name ext */
85− T("x.gz", true , true , false, true, "x.gz", "gz");
86− T("x.gz", false , true , false, true, NULL , "gz");
87− T("x.gz", true , false , false, true, "x.gz", NULL);
88− T("x.gz", false , false , false, true, NULL , NULL);
78+ /* path alloc_name kmod comp name */
79+ T("x.gz", true , false, 1 , "x.gz");
80+ T("x.gz", false , false, 1 , NULL );
81+ T("x.gz", true , false, 1 , "x.gz");
82+ T("x.gz", false , false, 1 , NULL );
8983 M("x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
9084 M("x.gz", PERF_RECORD_MISC_KERNEL, false);
9185 M("x.gz", PERF_RECORD_MISC_USER, false);
9286
93− /* path alloc_name alloc_ext kmod comp name ext */
94− T("x.ko.gz", true , true , true, true, "[x]", "gz");
95− T("x.ko.gz", false , true , true, true, NULL , "gz");
96− T("x.ko.gz", true , false , true, true, "[x]", NULL);
97− T("x.ko.gz", false , false , true, true, NULL , NULL);
87+ /* path alloc_name kmod comp name */
88+ T("x.ko.gz", true , true, 1 , "[x]");
89+ T("x.ko.gz", false , true, 1 , NULL );
90+ T("x.ko.gz", true , true, 1 , "[x]");
91+ T("x.ko.gz", false , true, 1 , NULL );
9892 M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
9993 M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
10094 M("x.ko.gz", PERF_RECORD_MISC_USER, false);
10195 #endif
10296
103− /* path alloc_name alloc_ext kmod comp name ext */
104− T("[test_module]", true , true , true, false, "[test_module]", NULL);
105− T("[test_module]", false , true , true, false, NULL , NULL);
106− T("[test_module]", true , false , true, false, "[test_module]", NULL);
107− T("[test_module]", false , false , true, false, NULL , NULL);
97+ /* path alloc_name kmod comp name */
98+ T("[test_module]", true , true, false, "[test_module]");
99+ T("[test_module]", false , true, false, NULL );
100+ T("[test_module]", true , true, false, "[test_module]");
101+ T("[test_module]", false , true, false, NULL );
108102 M("[test_module]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
109103 M("[test_module]", PERF_RECORD_MISC_KERNEL, true);
110104 M("[test_module]", PERF_RECORD_MISC_USER, false);
111105
112− /* path alloc_name alloc_ext kmod comp name ext */
113− T("[test.module]", true , true , true, false, "[test.module]", NULL);
114− T("[test.module]", false , true , true, false, NULL , NULL);
115− T("[test.module]", true , false , true, false, "[test.module]", NULL);
116− T("[test.module]", false , false , true, false, NULL , NULL);
106+ /* path alloc_name kmod comp name */
107+ T("[test.module]", true , true, false, "[test.module]");
108+ T("[test.module]", false , true, false, NULL );
109+ T("[test.module]", true , true, false, "[test.module]");
110+ T("[test.module]", false , true, false, NULL );
117111 M("[test.module]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
118112 M("[test.module]", PERF_RECORD_MISC_KERNEL, true);
119113 M("[test.module]", PERF_RECORD_MISC_USER, false);
120114
121− /* path alloc_name alloc_ext kmod comp name ext */
122− T("[vdso]", true , true , false, false, "[vdso]", NULL);
123− T("[vdso]", false , true , false, false, NULL , NULL);
124− T("[vdso]", true , false , false, false, "[vdso]", NULL);
125− T("[vdso]", false , false , false, false, NULL , NULL);
115+ /* path alloc_name kmod comp name */
116+ T("[vdso]", true , false, false, "[vdso]");
117+ T("[vdso]", false , false, false, NULL );
118+ T("[vdso]", true , false, false, "[vdso]");
119+ T("[vdso]", false , false, false, NULL );
126120 M("[vdso]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
127121 M("[vdso]", PERF_RECORD_MISC_KERNEL, false);
128122 M("[vdso]", PERF_RECORD_MISC_USER, false);
129123
130− T("[vdso32]", true , true , false, false, "[vdso32]", NULL);
131− T("[vdso32]", false , true , false, false, NULL , NULL);
132− T("[vdso32]", true , false , false, false, "[vdso32]", NULL);
133− T("[vdso32]", false , false , false, false, NULL , NULL);
124+ T("[vdso32]", true , false, false, "[vdso32]");
125+ T("[vdso32]", false , false, false, NULL );
126+ T("[vdso32]", true , false, false, "[vdso32]");
127+ T("[vdso32]", false , false, false, NULL );
134128 M("[vdso32]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
135129 M("[vdso32]", PERF_RECORD_MISC_KERNEL, false);
136130 M("[vdso32]", PERF_RECORD_MISC_USER, false);
137131
138− T("[vdsox32]", true , true , false, false, "[vdsox32]", NULL);
139− T("[vdsox32]", false , true , false, false, NULL , NULL);
140− T("[vdsox32]", true , false , false, false, "[vdsox32]", NULL);
141− T("[vdsox32]", false , false , false, false, NULL , NULL);
132+ T("[vdsox32]", true , false, false, "[vdsox32]");
133+ T("[vdsox32]", false , false, false, NULL );
134+ T("[vdsox32]", true , false, false, "[vdsox32]");
135+ T("[vdsox32]", false , false, false, NULL );
142136 M("[vdsox32]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
143137 M("[vdsox32]", PERF_RECORD_MISC_KERNEL, false);
144138 M("[vdsox32]", PERF_RECORD_MISC_USER, false);
145139
146− /* path alloc_name alloc_ext kmod comp name ext */
147− T("[vsyscall]", true , true , false, false, "[vsyscall]", NULL);
148− T("[vsyscall]", false , true , false, false, NULL , NULL);
149− T("[vsyscall]", true , false , false, false, "[vsyscall]", NULL);
150− T("[vsyscall]", false , false , false, false, NULL , NULL);
140+ /* path alloc_name kmod comp name */
141+ T("[vsyscall]", true , false, false, "[vsyscall]");
142+ T("[vsyscall]", false , false, false, NULL );
143+ T("[vsyscall]", true , false, false, "[vsyscall]");
144+ T("[vsyscall]", false , false, false, NULL );
151145 M("[vsyscall]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
152146 M("[vsyscall]", PERF_RECORD_MISC_KERNEL, false);
153147 M("[vsyscall]", PERF_RECORD_MISC_USER, false);
154148
155− /* path alloc_name alloc_ext kmod comp name ext */
156− T("[kernel.kallsyms]", true , true , false, false, "[kernel.kallsyms]", NULL);
157− T("[kernel.kallsyms]", false , true , false, false, NULL , NULL);
158− T("[kernel.kallsyms]", true , false , false, false, "[kernel.kallsyms]", NULL);
159− T("[kernel.kallsyms]", false , false , false, false, NULL , NULL);
149+ /* path alloc_name kmod comp name */
150+ T("[kernel.kallsyms]", true , false, false, "[kernel.kallsyms]");
151+ T("[kernel.kallsyms]", false , false, false, NULL );
152+ T("[kernel.kallsyms]", true , false, false, "[kernel.kallsyms]");
153+ T("[kernel.kallsyms]", false , false, false, NULL );
160154 M("[kernel.kallsyms]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
161155 M("[kernel.kallsyms]", PERF_RECORD_MISC_KERNEL, false);
162156 M("[kernel.kallsyms]", PERF_RECORD_MISC_USER, false);
tools/perf/tests/mem2node.c+0−2
@@ -24,8 +24,6 @@ static unsigned long *get_bitmap(const char *str, int nbits) · 23 unmodified lines
2424 bm = bitmap_alloc(nbits);
2525
2626 if (map && bm) {
27− bitmap_zero(bm, nbits);
28−
2927 for (i = 0; i < map->nr; i++) {
3028 set_bit(map->map[i], bm);
3129 }
tools/perf/ui/browsers/annotate.c+61−15
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include <linux/kernel.h>
1616 #include <linux/string.h>
1717 #include <sys/ttydefaults.h>
18+#include <asm/bug.h>
1819
1920 struct disasm_line_samples {
2021 double percent;
@@ -115,7 +116,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int · 94 unmodified lines
115116 if (!browser->navkeypressed)
116117 ops.width += 1;
117118
118− annotation_line__write(al, notes, &ops);
119+ annotation_line__write(al, notes, &ops, ab->opts);
119120
120121 if (ops.current_entry)
121122 ab->selection = al;
@@ -227,10 +228,10 @@ static int disasm__cmp(struct annotation_line *a, struct annotation_line *b) · 105 unmodified lines
227228 {
228229 int i;
229230
230− for (i = 0; i < a->samples_nr; i++) {
231− if (a->samples[i].percent == b->samples[i].percent)
231+ for (i = 0; i < a->data_nr; i++) {
232+ if (a->data[i].percent == b->data[i].percent)
232233 continue;
233− return a->samples[i].percent < b->samples[i].percent;
234+ return a->data[i].percent < b->data[i].percent;
234235 }
235236 return 0;
236237 }
@@ -314,11 +315,14 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, · 77 unmodified lines
314315 continue;
315316 }
316317
317− for (i = 0; i < pos->al.samples_nr; i++) {
318− struct annotation_data *sample = &pos->al.samples[i];
318+ for (i = 0; i < pos->al.data_nr; i++) {
319+ double percent;
319320
320− if (max_percent < sample->percent)
321− max_percent = sample->percent;
321+ percent = annotation_data__percent(&pos->al.data[i],
322+ browser->opts->percent_type);
323+
324+ if (max_percent < percent)
325+ max_percent = percent;
322326 }
323327
324328 if (max_percent < 0.01 && pos->al.ipc == 0) {
@@ -380,9 +384,10 @@ static void ui_browser__init_asm_mode(struct ui_browser *browser) · 55 unmodified lines
380384 #define SYM_TITLE_MAX_SIZE (PATH_MAX + 64)
381385
382386 static int sym_title(struct symbol *sym, struct map *map, char *title,
383− size_t sz)
387+ size_t sz, int percent_type)
384388 {
385− return snprintf(title, sz, "%s %s", sym->name, map->dso->long_name);
389+ return snprintf(title, sz, "%s %s [Percent: %s]", sym->name, map->dso->long_name,
390+ percent_type_str(percent_type));
386391 }
387392
388393 /*
@@ -420,7 +425,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, · 31 unmodified lines
420425
421426 pthread_mutex_unlock(&notes->lock);
422427 symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, browser->opts);
423− sym_title(ms->sym, ms->map, title, sizeof(title));
428+ sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type);
424429 ui_browser__show_title(&browser->b, title);
425430 return true;
426431 }
@@ -595,6 +600,7 @@ bool annotate_browser__continue_search_reverse(struct annotate_browser *browser, · 168 unmodified lines
595600
596601 static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help)
597602 {
603+ struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
598604 struct map_symbol *ms = browser->priv;
599605 struct symbol *sym = ms->sym;
600606 char symbol_dso[SYM_TITLE_MAX_SIZE];
@@ -602,7 +608,7 @@ static int annotate_browser__show(struct ui_browser *browser, char *title, const · 1 unmodified line
602608 if (ui_browser__show(browser, title, help) < 0)
603609 return -1;
604610
605− sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso));
611+ sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso), ab->opts->percent_type);
606612
607613 ui_browser__gotorc_title(browser, 0, 0);
608614 ui_browser__set_color(browser, HE_COLORSET_ROOT);
@@ -610,6 +616,39 @@ static int annotate_browser__show(struct ui_browser *browser, char *title, const · 1 unmodified line
610616 return 0;
611617 }
612618
619+static void
620+switch_percent_type(struct annotation_options *opts, bool base)
621+{
622+ switch (opts->percent_type) {
623+ case PERCENT_HITS_LOCAL:
624+ if (base)
625+ opts->percent_type = PERCENT_PERIOD_LOCAL;
626+ else
627+ opts->percent_type = PERCENT_HITS_GLOBAL;
628+ break;
629+ case PERCENT_HITS_GLOBAL:
630+ if (base)
631+ opts->percent_type = PERCENT_PERIOD_GLOBAL;
632+ else
633+ opts->percent_type = PERCENT_HITS_LOCAL;
634+ break;
635+ case PERCENT_PERIOD_LOCAL:
636+ if (base)
637+ opts->percent_type = PERCENT_HITS_LOCAL;
638+ else
639+ opts->percent_type = PERCENT_PERIOD_GLOBAL;
640+ break;
641+ case PERCENT_PERIOD_GLOBAL:
642+ if (base)
643+ opts->percent_type = PERCENT_HITS_GLOBAL;
644+ else
645+ opts->percent_type = PERCENT_PERIOD_LOCAL;
646+ break;
647+ default:
648+ WARN_ON(1);
649+ }
650+}
651+
613652 static int annotate_browser__run(struct annotate_browser *browser,
614653 struct perf_evsel *evsel,
615654 struct hist_browser_timer *hbt)
@@ -624,8 +663,7 @@ static int annotate_browser__run(struct annotate_browser *browser, · 8 unmodified lines
624663 char title[256];
625664 int key;
626665
627− annotation__scnprintf_samples_period(notes, title, sizeof(title), evsel);
628−
666+ hists__scnprintf_title(hists, title, sizeof(title));
629667 if (annotate_browser__show(&browser->b, title, help) < 0)
630668 return -1;
631669
@@ -701,6 +739,8 @@ static int annotate_browser__run(struct annotate_browser *browser, · 69 unmodified lines
701739 "k Toggle line numbers\n"
702740 "P Print to [symbol_name].annotation file.\n"
703741 "r Run available scripts\n"
742+ "p Toggle percent type [local/global]\n"
743+ "b Toggle percent base [period/hits]\n"
704744 "? Search string backwards\n");
705745 continue;
706746 case 'r':
@@ -781,7 +821,7 @@ show_sup_ins: · 74 unmodified lines
781821 continue;
782822 }
783823 case 'P':
784− map_symbol__annotation_dump(ms, evsel);
824+ map_symbol__annotation_dump(ms, evsel, browser->opts);
785825 continue;
786826 case 't':
787827 if (notes->options->show_total_period) {
@@ -800,6 +840,12 @@ show_sup_ins: · 12 unmodified lines
800840 notes->options->show_minmax_cycle = true;
801841 annotation__update_column_widths(notes);
802842 continue;
843+ case 'p':
844+ case 'b':
845+ switch_percent_type(browser->opts, key == 'b');
846+ hists__scnprintf_title(hists, title, sizeof(title));
847+ annotate_browser__show(&browser->b, title, help);
848+ continue;
803849 case K_LEFT:
804850 case K_ESC:
805851 case 'q':
tools/perf/util/Build+1−0
@@ -87,6 +87,7 @@ libperf-$(CONFIG_AUXTRACE) += intel-pt.o · 86 unmodified lines
8787 libperf-$(CONFIG_AUXTRACE) += intel-bts.o
8888 libperf-$(CONFIG_AUXTRACE) += arm-spe.o
8989 libperf-$(CONFIG_AUXTRACE) += arm-spe-pkt-decoder.o
90+libperf-$(CONFIG_AUXTRACE) += s390-cpumsf.o
9091
9192 ifdef CONFIG_LIBOPENCSD
9293 libperf-$(CONFIG_AUXTRACE) += cs-etm.o
tools/perf/util/annotate.c+183−122
@@ -49,6 +49,7 @@ struct annotation_options annotation__default_options = { · 48 unmodified lines
4949 .jump_arrows = true,
5050 .annotate_src = true,
5151 .offset_level = ANNOTATION__OFFSET_JUMP_TARGETS,
52+ .percent_type = PERCENT_PERIOD_LOCAL,
5253 };
5354
5455 static regex_t file_lineno;
@@ -1108,7 +1109,7 @@ annotation_line__new(struct annotate_args *args, size_t privsize) · 1053 unmodified lines
11081109 if (perf_evsel__is_group_event(evsel))
11091110 nr = evsel->nr_members;
11101111
1111− size += sizeof(al->samples[0]) * nr;
1112+ size += sizeof(al->data[0]) * nr;
11121113
11131114 al = zalloc(size);
11141115 if (al) {
@@ -1117,7 +1118,7 @@ annotation_line__new(struct annotate_args *args, size_t privsize) · 2 unmodified lines
11171118 al->offset = args->offset;
11181119 al->line = strdup(args->line);
11191120 al->line_nr = args->line_nr;
1120− al->samples_nr = nr;
1121+ al->data_nr = nr;
11211122 }
11221123
11231124 return al;
@@ -1297,7 +1298,8 @@ static int disasm_line__print(struct disasm_line *dl, u64 start, int addr_fmt_wi · 173 unmodified lines
12971298 static int
12981299 annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start,
12991300 struct perf_evsel *evsel, u64 len, int min_pcnt, int printed,
1300− int max_lines, struct annotation_line *queue, int addr_fmt_width)
1301+ int max_lines, struct annotation_line *queue, int addr_fmt_width,
1302+ int percent_type)
13011303 {
13021304 struct disasm_line *dl = container_of(al, struct disasm_line, al);
13031305 static const char *prev_line;
@@ -1309,15 +1311,18 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start · 5 unmodified lines
13091311 const char *color;
13101312 struct annotation *notes = symbol__annotation(sym);
13111313
1312− for (i = 0; i < al->samples_nr; i++) {
1313− struct annotation_data *sample = &al->samples[i];
1314+ for (i = 0; i < al->data_nr; i++) {
1315+ double percent;
13141316
1315− if (sample->percent > max_percent)
1316− max_percent = sample->percent;
1317+ percent = annotation_data__percent(&al->data[i],
1318+ percent_type);
1319+
1320+ if (percent > max_percent)
1321+ max_percent = percent;
13171322 }
13181323
1319− if (al->samples_nr > nr_percent)
1320− nr_percent = al->samples_nr;
1324+ if (al->data_nr > nr_percent)
1325+ nr_percent = al->data_nr;
13211326
13221327 if (max_percent < min_pcnt)
13231328 return -1;
@@ -1330,7 +1335,8 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start · 6 unmodified lines
13301335 if (queue == al)
13311336 break;
13321337 annotation_line__print(queue, sym, start, evsel, len,
1333− 0, 0, 1, NULL, addr_fmt_width);
1338+ 0, 0, 1, NULL, addr_fmt_width,
1339+ percent_type);
13341340 }
13351341 }
13361342
@@ -1351,18 +1357,20 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start · 14 unmodified lines
13511357 }
13521358
13531359 for (i = 0; i < nr_percent; i++) {
1354− struct annotation_data *sample = &al->samples[i];
1360+ struct annotation_data *data = &al->data[i];
1361+ double percent;
13551362
1356− color = get_percent_color(sample->percent);
1363+ percent = annotation_data__percent(data, percent_type);
1364+ color = get_percent_color(percent);
13571365
13581366 if (symbol_conf.show_total_period)
13591367 color_fprintf(stdout, color, " %11" PRIu64,
1360− sample->he.period);
1368+ data->he.period);
13611369 else if (symbol_conf.show_nr_samples)
13621370 color_fprintf(stdout, color, " %7" PRIu64,
1363− sample->he.nr_samples);
1371+ data->he.nr_samples);
13641372 else
1365− color_fprintf(stdout, color, " %7.2f", sample->percent);
1373+ color_fprintf(stdout, color, " %7.2f", percent);
13661374 }
13671375
13681376 printf(" : ");
@@ -1621,6 +1629,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args) · 252 unmodified lines
16211629 char symfs_filename[PATH_MAX];
16221630 struct kcore_extract kce;
16231631 bool delete_extract = false;
1632+ bool decomp = false;
16241633 int stdout_fd[2];
16251634 int lineno = 0;
16261635 int nline;
@@ -1654,6 +1663,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args) · 27 unmodified lines
16541663 tmp, sizeof(tmp)) < 0)
16551664 goto out;
16561665
1666+ decomp = true;
16571667 strcpy(symfs_filename, tmp);
16581668 }
16591669
@@ -1740,7 +1750,7 @@ out_free_command: · 80 unmodified lines
17401750 out_remove_tmp:
17411751 close(stdout_fd[0]);
17421752
1743− if (dso__needs_decompress(dso))
1753+ if (decomp)
17441754 unlink(symfs_filename);
17451755
17461756 if (delete_extract)
@@ -1753,34 +1763,45 @@ out_close_stdout: · 6 unmodified lines
17531763 goto out_free_command;
17541764 }
17551765
1756−static void calc_percent(struct sym_hist *hist,
1757− struct annotation_data *sample,
1766+static void calc_percent(struct sym_hist *sym_hist,
1767+ struct hists *hists,
1768+ struct annotation_data *data,
17581769 s64 offset, s64 end)
17591770 {
17601771 unsigned int hits = 0;
17611772 u64 period = 0;
17621773
17631774 while (offset < end) {
1764− hits += hist->addr[offset].nr_samples;
1765− period += hist->addr[offset].period;
1775+ hits += sym_hist->addr[offset].nr_samples;
1776+ period += sym_hist->addr[offset].period;
17661777 ++offset;
17671778 }
17681779
1769− if (hist->nr_samples) {
1770− sample->he.period = period;
1771− sample->he.nr_samples = hits;
1772− sample->percent = 100.0 * hits / hist->nr_samples;
1780+ if (sym_hist->nr_samples) {
1781+ data->he.period = period;
1782+ data->he.nr_samples = hits;
1783+ data->percent[PERCENT_HITS_LOCAL] = 100.0 * hits / sym_hist->nr_samples;
17731784 }
1785+
1786+ if (hists->stats.nr_non_filtered_samples)
1787+ data->percent[PERCENT_HITS_GLOBAL] = 100.0 * hits / hists->stats.nr_non_filtered_samples;
1788+
1789+ if (sym_hist->period)
1790+ data->percent[PERCENT_PERIOD_LOCAL] = 100.0 * period / sym_hist->period;
1791+
1792+ if (hists->stats.total_period)
1793+ data->percent[PERCENT_PERIOD_GLOBAL] = 100.0 * period / hists->stats.total_period;
17741794 }
17751795
17761796 static void annotation__calc_percent(struct annotation *notes,
1777− struct perf_evsel *evsel, s64 len)
1797+ struct perf_evsel *leader, s64 len)
17781798 {
17791799 struct annotation_line *al, *next;
1800+ struct perf_evsel *evsel;
17801801
17811802 list_for_each_entry(al, &notes->src->source, node) {
17821803 s64 end;
1783− int i;
1804+ int i = 0;
17841805
17851806 if (al->offset == -1)
17861807 continue;
@@ -1788,14 +1809,17 @@ static void annotation__calc_percent(struct annotation *notes, · 1 unmodified line
17881809 next = annotation_line__next(al, &notes->src->source);
17891810 end = next ? next->offset : len;
17901811
1791− for (i = 0; i < al->samples_nr; i++) {
1792− struct annotation_data *sample;
1793− struct sym_hist *hist;
1812+ for_each_group_evsel(evsel, leader) {
1813+ struct hists *hists = evsel__hists(evsel);
1814+ struct annotation_data *data;
1815+ struct sym_hist *sym_hist;
1816+
1817+ BUG_ON(i >= al->data_nr);
17941818
1795− hist = annotation__histogram(notes, evsel->idx + i);
1796− sample = &al->samples[i];
1819+ sym_hist = annotation__histogram(notes, evsel->idx);
1820+ data = &al->data[i++];
17971821
1798− calc_percent(hist, sample, al->offset, end);
1822+ calc_percent(sym_hist, hists, data, al->offset, end);
17991823 }
18001824 }
18011825 }
@@ -1846,7 +1870,8 @@ int symbol__annotate(struct symbol *sym, struct map *map, · 44 unmodified lines
18461870 return symbol__disassemble(sym, &args);
18471871 }
18481872
1849−static void insert_source_line(struct rb_root *root, struct annotation_line *al)
1873+static void insert_source_line(struct rb_root *root, struct annotation_line *al,
1874+ struct annotation_options *opts)
18501875 {
18511876 struct annotation_line *iter;
18521877 struct rb_node **p = &root->rb_node;
@@ -1859,8 +1884,10 @@ static void insert_source_line(struct rb_root *root, struct annotation_line *al) · 6 unmodified lines
18591884
18601885 ret = strcmp(iter->path, al->path);
18611886 if (ret == 0) {
1862− for (i = 0; i < al->samples_nr; i++)
1863− iter->samples[i].percent_sum += al->samples[i].percent;
1887+ for (i = 0; i < al->data_nr; i++) {
1888+ iter->data[i].percent_sum += annotation_data__percent(&al->data[i],
1889+ opts->percent_type);
1890+ }
18641891 return;
18651892 }
18661893
@@ -1870,8 +1897,10 @@ static void insert_source_line(struct rb_root *root, struct annotation_line *al) · 3 unmodified lines
18701897 p = &(*p)->rb_right;
18711898 }
18721899
1873− for (i = 0; i < al->samples_nr; i++)
1874− al->samples[i].percent_sum = al->samples[i].percent;
1900+ for (i = 0; i < al->data_nr; i++) {
1901+ al->data[i].percent_sum = annotation_data__percent(&al->data[i],
1902+ opts->percent_type);
1903+ }
18751904
18761905 rb_link_node(&al->rb_node, parent, p);
18771906 rb_insert_color(&al->rb_node, root);
@@ -1881,10 +1910,10 @@ static int cmp_source_line(struct annotation_line *a, struct annotation_line *b) · 3 unmodified lines
18811910 {
18821911 int i;
18831912
1884− for (i = 0; i < a->samples_nr; i++) {
1885− if (a->samples[i].percent_sum == b->samples[i].percent_sum)
1913+ for (i = 0; i < a->data_nr; i++) {
1914+ if (a->data[i].percent_sum == b->data[i].percent_sum)
18861915 continue;
1887− return a->samples[i].percent_sum > b->samples[i].percent_sum;
1916+ return a->data[i].percent_sum > b->data[i].percent_sum;
18881917 }
18891918
18901919 return 0;
@@ -1949,8 +1978,8 @@ static void print_summary(struct rb_root *root, const char *filename) · 58 unmodified lines
19491978 int i;
19501979
19511980 al = rb_entry(node, struct annotation_line, rb_node);
1952− for (i = 0; i < al->samples_nr; i++) {
1953− percent = al->samples[i].percent_sum;
1981+ for (i = 0; i < al->data_nr; i++) {
1982+ percent = al->data[i].percent_sum;
19541983 color = get_percent_color(percent);
19551984 color_fprintf(stdout, color, " %7.2f", percent);
19561985
@@ -2029,10 +2058,12 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, · 72 unmodified lines
20292058 evsel_name = buf;
20302059 }
20312060
2032− graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",
2061+ graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples, "
2062+ "percent: %s)\n",
20332063 width, width, symbol_conf.show_total_period ? "Period" :
20342064 symbol_conf.show_nr_samples ? "Samples" : "Percent",
2035− d_filename, evsel_name, h->nr_samples);
2065+ d_filename, evsel_name, h->nr_samples,
2066+ percent_type_str(opts->percent_type));
20362067
20372068 printf("%-*.*s----\n",
20382069 graph_dotted_len, graph_dotted_len, graph_dotted_line);
@@ -2052,7 +2083,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, · 13 unmodified lines
20522083
20532084 err = annotation_line__print(pos, sym, start, evsel, len,
20542085 opts->min_pcnt, printed, opts->max_lines,
2055− queue, addr_fmt_width);
2086+ queue, addr_fmt_width, opts->percent_type);
20562087
20572088 switch (err) {
20582089 case 0:
@@ -2129,10 +2160,11 @@ static void FILE__write_graph(void *fp, int graph) · 70 unmodified lines
21292160 fputs(s, fp);
21302161 }
21312162
2132−int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp)
2163+static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp,
2164+ struct annotation_options *opts)
21332165 {
21342166 struct annotation *notes = symbol__annotation(sym);
2135− struct annotation_write_ops ops = {
2167+ struct annotation_write_ops wops = {
21362168 .first_line = true,
21372169 .obj = fp,
21382170 .set_color = FILE__set_color,
@@ -2146,15 +2178,16 @@ int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp) · 7 unmodified lines
21462178 list_for_each_entry(al, &notes->src->source, node) {
21472179 if (annotation_line__filter(al, notes))
21482180 continue;
2149− annotation_line__write(al, notes, &ops);
2181+ annotation_line__write(al, notes, &wops, opts);
21502182 fputc('\n', fp);
2151− ops.first_line = false;
2183+ wops.first_line = false;
21522184 }
21532185
21542186 return 0;
21552187 }
21562188
2157−int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel)
2189+int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel,
2190+ struct annotation_options *opts)
21582191 {
21592192 const char *ev_name = perf_evsel__name(evsel);
21602193 char buf[1024];
@@ -2176,7 +2209,7 @@ int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel) · 15 unmodified lines
21762209
21772210 fprintf(fp, "%s() %s\nEvent: %s\n\n",
21782211 ms->sym->name, ms->map->dso->long_name, ev_name);
2179− symbol__annotate_fprintf2(ms->sym, fp);
2212+ symbol__annotate_fprintf2(ms->sym, fp, opts);
21802213
21812214 fclose(fp);
21822215 err = 0;
@@ -2346,7 +2379,8 @@ void annotation__update_column_widths(struct annotation *notes) · 163 unmodified lines
23462379 }
23472380
23482381 static void annotation__calc_lines(struct annotation *notes, struct map *map,
2349− struct rb_root *root)
2382+ struct rb_root *root,
2383+ struct annotation_options *opts)
23502384 {
23512385 struct annotation_line *al;
23522386 struct rb_root tmp_root = RB_ROOT;
@@ -2355,13 +2389,14 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map, · 2 unmodified lines
23552389 double percent_max = 0.0;
23562390 int i;
23572391
2358− for (i = 0; i < al->samples_nr; i++) {
2359− struct annotation_data *sample;
2392+ for (i = 0; i < al->data_nr; i++) {
2393+ double percent;
23602394
2361− sample = &al->samples[i];
2395+ percent = annotation_data__percent(&al->data[i],
2396+ opts->percent_type);
23622397
2363− if (sample->percent > percent_max)
2364− percent_max = sample->percent;
2398+ if (percent > percent_max)
2399+ percent_max = percent;
23652400 }
23662401
23672402 if (percent_max <= 0.5)
@@ -2369,18 +2404,19 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map, · 1 unmodified line
23692404
23702405 al->path = get_srcline(map->dso, notes->start + al->offset, NULL,
23712406 false, true, notes->start + al->offset);
2372− insert_source_line(&tmp_root, al);
2407+ insert_source_line(&tmp_root, al, opts);
23732408 }
23742409
23752410 resort_source_line(root, &tmp_root);
23762411 }
23772412
23782413 static void symbol__calc_lines(struct symbol *sym, struct map *map,
2379− struct rb_root *root)
2414+ struct rb_root *root,
2415+ struct annotation_options *opts)
23802416 {
23812417 struct annotation *notes = symbol__annotation(sym);
23822418
2383− annotation__calc_lines(notes, map, root);
2419+ annotation__calc_lines(notes, map, root, opts);
23842420 }
23852421
23862422 int symbol__tty_annotate2(struct symbol *sym, struct map *map,
@@ -2389,7 +2425,7 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map, · 2 unmodified lines
23892425 {
23902426 struct dso *dso = map->dso;
23912427 struct rb_root source_line = RB_ROOT;
2392− struct annotation *notes = symbol__annotation(sym);
2428+ struct hists *hists = evsel__hists(evsel);
23932429 char buf[1024];
23942430
23952431 if (symbol__annotate2(sym, map, evsel, opts, NULL) < 0)
@@ -2397,13 +2433,14 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map, · 1 unmodified line
23972433
23982434 if (opts->print_lines) {
23992435 srcline_full_filename = opts->full_path;
2400− symbol__calc_lines(sym, map, &source_line);
2436+ symbol__calc_lines(sym, map, &source_line, opts);
24012437 print_summary(&source_line, dso->long_name);
24022438 }
24032439
2404− annotation__scnprintf_samples_period(notes, buf, sizeof(buf), evsel);
2405− fprintf(stdout, "%s\n%s() %s\n", buf, sym->name, dso->long_name);
2406− symbol__annotate_fprintf2(sym, stdout);
2440+ hists__scnprintf_title(hists, buf, sizeof(buf));
2441+ fprintf(stdout, "%s, [percent: %s]\n%s() %s\n",
2442+ buf, percent_type_str(opts->percent_type), sym->name, dso->long_name);
2443+ symbol__annotate_fprintf2(sym, stdout, opts);
24072444
24082445 annotated_source__purge(symbol__annotation(sym)->src);
24092446
@@ -2424,7 +2461,7 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, · 14 unmodified lines
24242461
24252462 if (opts->print_lines) {
24262463 srcline_full_filename = opts->full_path;
2427− symbol__calc_lines(sym, map, &source_line);
2464+ symbol__calc_lines(sym, map, &source_line, opts);
24282465 print_summary(&source_line, dso->long_name);
24292466 }
24302467
@@ -2441,14 +2478,21 @@ bool ui__has_annotation(void) · 10 unmodified lines
24412478 }
24422479
24432480
2444−double annotation_line__max_percent(struct annotation_line *al, struct annotation *notes)
2481+static double annotation_line__max_percent(struct annotation_line *al,
2482+ struct annotation *notes,
2483+ unsigned int percent_type)
24452484 {
24462485 double percent_max = 0.0;
24472486 int i;
24482487
24492488 for (i = 0; i < notes->nr_events; i++) {
2450− if (al->samples[i].percent > percent_max)
2451− percent_max = al->samples[i].percent;
2489+ double percent;
2490+
2491+ percent = annotation_data__percent(&al->data[i],
2492+ percent_type);
2493+
2494+ if (percent > percent_max)
2495+ percent_max = percent;
24522496 }
24532497
24542498 return percent_max;
@@ -2487,7 +2531,7 @@ call_like: · 32 unmodified lines
24872531
24882532 static void __annotation_line__write(struct annotation_line *al, struct annotation *notes,
24892533 bool first_line, bool current_entry, bool change_color, int width,
2490− void *obj,
2534+ void *obj, unsigned int percent_type,
24912535 int (*obj__set_color)(void *obj, int color),
24922536 void (*obj__set_percent_color)(void *obj, double percent, bool current),
24932537 int (*obj__set_jumps_percent_color)(void *obj, int nr, bool current),
@@ -2495,7 +2539,7 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati · 1 unmodified line
24952539 void (*obj__write_graph)(void *obj, int graph))
24962540
24972541 {
2498− double percent_max = annotation_line__max_percent(al, notes);
2542+ double percent_max = annotation_line__max_percent(al, notes, percent_type);
24992543 int pcnt_width = annotation__pcnt_width(notes),
25002544 cycles_width = annotation__cycles_width(notes);
25012545 bool show_title = false;
@@ -2514,15 +2558,18 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati · 12 unmodified lines
25142558 int i;
25152559
25162560 for (i = 0; i < notes->nr_events; i++) {
2517− obj__set_percent_color(obj, al->samples[i].percent, current_entry);
2561+ double percent;
2562+
2563+ percent = annotation_data__percent(&al->data[i], percent_type);
2564+
2565+ obj__set_percent_color(obj, percent, current_entry);
25182566 if (notes->options->show_total_period) {
2519− obj__printf(obj, "%11" PRIu64 " ", al->samples[i].he.period);
2567+ obj__printf(obj, "%11" PRIu64 " ", al->data[i].he.period);
25202568 } else if (notes->options->show_nr_samples) {
25212569 obj__printf(obj, "%6" PRIu64 " ",
2522− al->samples[i].he.nr_samples);
2570+ al->data[i].he.nr_samples);
25232571 } else {
2524− obj__printf(obj, "%6.2f ",
2525− al->samples[i].percent);
2572+ obj__printf(obj, "%6.2f ", percent);
25262573 }
25272574 }
25282575 } else {
@@ -2640,13 +2687,15 @@ print_addr: · 111 unmodified lines
26402687 }
26412688
26422689 void annotation_line__write(struct annotation_line *al, struct annotation *notes,
2643− struct annotation_write_ops *ops)
2690+ struct annotation_write_ops *wops,
2691+ struct annotation_options *opts)
26442692 {
2645− __annotation_line__write(al, notes, ops->first_line, ops->current_entry,
2646− ops->change_color, ops->width, ops->obj,
2647− ops->set_color, ops->set_percent_color,
2648− ops->set_jumps_percent_color, ops->printf,
2649− ops->write_graph);
2693+ __annotation_line__write(al, notes, wops->first_line, wops->current_entry,
2694+ wops->change_color, wops->width, wops->obj,
2695+ opts->percent_type,
2696+ wops->set_color, wops->set_percent_color,
2697+ wops->set_jumps_percent_color, wops->printf,
2698+ wops->write_graph);
26502699 }
26512700
26522701 int symbol__annotate2(struct symbol *sym, struct map *map, struct perf_evsel *evsel,
@@ -2688,46 +2737,6 @@ out_free_offsets: · 35 unmodified lines
26882737 return -1;
26892738 }
26902739
2691−int __annotation__scnprintf_samples_period(struct annotation *notes,
2692− char *bf, size_t size,
2693− struct perf_evsel *evsel,
2694− bool show_freq)
2695−{
2696− const char *ev_name = perf_evsel__name(evsel);
2697− char buf[1024], ref[30] = " show reference callgraph, ";
2698− char sample_freq_str[64] = "";
2699− unsigned long nr_samples = 0;
2700− int nr_members = 1;
2701− bool enable_ref = false;
2702− u64 nr_events = 0;
2703− char unit;
2704− int i;
2705−
2706− if (perf_evsel__is_group_event(evsel)) {
2707− perf_evsel__group_desc(evsel, buf, sizeof(buf));
2708− ev_name = buf;
2709− nr_members = evsel->nr_members;
2710− }
2711−
2712− for (i = 0; i < nr_members; i++) {
2713− struct sym_hist *ah = annotation__histogram(notes, evsel->idx + i);
2714−
2715− nr_samples += ah->nr_samples;
2716− nr_events += ah->period;
2717− }
2718−
2719− if (symbol_conf.show_ref_callgraph && strstr(ev_name, "call-graph=no"))
2720− enable_ref = true;
2721−
2722− if (show_freq)
2723− scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", evsel->attr.sample_freq);
2724−
2725− nr_samples = convert_unit(nr_samples, &unit);
2726− return scnprintf(bf, size, "Samples: %lu%c of event%s '%s',%s%sEvent count (approx.): %" PRIu64,
2727− nr_samples, unit, evsel->nr_members > 1 ? "s" : "",
2728− ev_name, sample_freq_str, enable_ref ? ref : " ", nr_events);
2729−}
2730−
27312740 #define ANNOTATION__CFG(n) \
27322741 { .name = #n, .value = &annotation__default_options.n, }
27332742
@@ -2792,3 +2801,55 @@ void annotation_config__init(void) · 58 unmodified lines
27922801 annotation__default_options.show_total_period = symbol_conf.show_total_period;
27932802 annotation__default_options.show_nr_samples = symbol_conf.show_nr_samples;
27942803 }
2804+
2805+static unsigned int parse_percent_type(char *str1, char *str2)
2806+{
2807+ unsigned int type = (unsigned int) -1;
2808+
2809+ if (!strcmp("period", str1)) {
2810+ if (!strcmp("local", str2))
2811+ type = PERCENT_PERIOD_LOCAL;
2812+ else if (!strcmp("global", str2))
2813+ type = PERCENT_PERIOD_GLOBAL;
2814+ }
2815+
2816+ if (!strcmp("hits", str1)) {
2817+ if (!strcmp("local", str2))
2818+ type = PERCENT_HITS_LOCAL;
2819+ else if (!strcmp("global", str2))
2820+ type = PERCENT_HITS_GLOBAL;
2821+ }
2822+
2823+ return type;
2824+}
2825+
2826+int annotate_parse_percent_type(const struct option *opt, const char *_str,
2827+ int unset __maybe_unused)
2828+{
2829+ struct annotation_options *opts = opt->value;
2830+ unsigned int type;
2831+ char *str1, *str2;
2832+ int err = -1;
2833+
2834+ str1 = strdup(_str);
2835+ if (!str1)
2836+ return -ENOMEM;
2837+
2838+ str2 = strchr(str1, '-');
2839+ if (!str2)
2840+ goto out;
2841+
2842+ *str2++ = 0;
2843+
2844+ type = parse_percent_type(str1, str2);
2845+ if (type == (unsigned int) -1)
2846+ type = parse_percent_type(str2, str1);
2847+ if (type != (unsigned int) -1) {
2848+ opts->percent_type = type;
2849+ err = 0;
2850+ }
2851+
2852+out:
2853+ free(str1);
2854+ return err;
2855+}
tools/perf/util/annotate.h+40−14
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #include <linux/list.h>
1212 #include <linux/rbtree.h>
1313 #include <pthread.h>
14+#include <asm/bug.h>
1415
1516 struct ins_ops;
1617
@@ -82,6 +83,7 @@ struct annotation_options { · 65 unmodified lines
8283 int context;
8384 const char *objdump_path;
8485 const char *disassembler_style;
86+ unsigned int percent_type;
8587 };
8688
8789 enum {
@@ -101,8 +103,16 @@ struct sym_hist_entry { · 13 unmodified lines
101103 u64 period;
102104 };
103105
106+enum {
107+ PERCENT_HITS_LOCAL,
108+ PERCENT_HITS_GLOBAL,
109+ PERCENT_PERIOD_LOCAL,
110+ PERCENT_PERIOD_GLOBAL,
111+ PERCENT_MAX,
112+};
113+
104114 struct annotation_data {
105− double percent;
115+ double percent[PERCENT_MAX];
106116 double percent_sum;
107117 struct sym_hist_entry he;
108118 };
@@ -122,8 +132,8 @@ struct annotation_line { · 13 unmodified lines
122132 char *path;
123133 u32 idx;
124134 int idx_asm;
125− int samples_nr;
126− struct annotation_data samples[0];
135+ int data_nr;
136+ struct annotation_data data[0];
127137 };
128138
129139 struct disasm_line {
@@ -134,6 +144,27 @@ struct disasm_line { · 4 unmodified lines
134144 struct annotation_line al;
135145 };
136146
147+static inline double annotation_data__percent(struct annotation_data *data,
148+ unsigned int which)
149+{
150+ return which < PERCENT_MAX ? data->percent[which] : -1;
151+}
152+
153+static inline const char *percent_type_str(unsigned int type)
154+{
155+ static const char *str[PERCENT_MAX] = {
156+ "local hits",
157+ "global hits",
158+ "local period",
159+ "global period",
160+ };
161+
162+ if (WARN_ON(type >= PERCENT_MAX))
163+ return "N/A";
164+
165+ return str[type];
166+}
167+
137168 static inline struct disasm_line *disasm_line(struct annotation_line *al)
138169 {
139170 return al ? container_of(al, struct disasm_line, al) : NULL;
@@ -169,22 +200,15 @@ struct annotation_write_ops { · 29 unmodified lines
169200 void (*write_graph)(void *obj, int graph);
170201 };
171202
172−double annotation_line__max_percent(struct annotation_line *al, struct annotation *notes);
173203 void annotation_line__write(struct annotation_line *al, struct annotation *notes,
174− struct annotation_write_ops *ops);
204+ struct annotation_write_ops *ops,
205+ struct annotation_options *opts);
175206
176207 int __annotation__scnprintf_samples_period(struct annotation *notes,
177208 char *bf, size_t size,
178209 struct perf_evsel *evsel,
179210 bool show_freq);
180211
181−static inline int annotation__scnprintf_samples_period(struct annotation *notes,
182− char *bf, size_t size,
183− struct perf_evsel *evsel)
184−{
185− return __annotation__scnprintf_samples_period(notes, bf, size, evsel, true);
186−}
187−
188212 int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw);
189213 size_t disasm__fprintf(struct list_head *head, FILE *fp);
190214 void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel);
@@ -340,12 +364,12 @@ int symbol__strerror_disassemble(struct symbol *sym, struct map *map, · 149 unmodified lines
340364 int symbol__annotate_printf(struct symbol *sym, struct map *map,
341365 struct perf_evsel *evsel,
342366 struct annotation_options *options);
343−int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp);
344367 void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
345368 void symbol__annotate_decay_histogram(struct symbol *sym, int evidx);
346369 void annotated_source__purge(struct annotated_source *as);
347370
348−int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel);
371+int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel,
372+ struct annotation_options *opts);
349373
350374 bool ui__has_annotation(void);
351375
@@ -373,4 +397,6 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, · 21 unmodified lines
373397
374398 void annotation_config__init(void);
375399
400+int annotate_parse_percent_type(const struct option *opt, const char *_str,
401+ int unset);
376402 #endif /* __PERF_ANNOTATE_H */
tools/perf/util/auxtrace.c+6−0
@@ -56,6 +56,7 @@ · 55 unmodified lines
5656 #include "intel-pt.h"
5757 #include "intel-bts.h"
5858 #include "arm-spe.h"
59+#include "s390-cpumsf.h"
5960
6061 #include "sane_ctype.h"
6162 #include "symbol/kallsyms.h"
@@ -202,6 +203,9 @@ static int auxtrace_queues__grow(struct auxtrace_queues *queues, · 140 unmodified lines
202203 for (i = 0; i < queues->nr_queues; i++) {
203204 list_splice_tail(&queues->queue_array[i].head,
204205 &queue_array[i].head);
206+ queue_array[i].tid = queues->queue_array[i].tid;
207+ queue_array[i].cpu = queues->queue_array[i].cpu;
208+ queue_array[i].set = queues->queue_array[i].set;
205209 queue_array[i].priv = queues->queue_array[i].priv;
206210 }
207211
@@ -920,6 +924,8 @@ int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused, · 712 unmodified lines
920924 return arm_spe_process_auxtrace_info(event, session);
921925 case PERF_AUXTRACE_CS_ETM:
922926 return cs_etm__process_auxtrace_info(event, session);
927+ case PERF_AUXTRACE_S390_CPUMSF:
928+ return s390_cpumsf_process_auxtrace_info(event, session);
923929 case PERF_AUXTRACE_UNKNOWN:
924930 default:
925931 return -EINVAL;
tools/perf/util/auxtrace.h+1−0
@@ -44,6 +44,7 @@ enum auxtrace_type { · 43 unmodified lines
4444 PERF_AUXTRACE_INTEL_BTS,
4545 PERF_AUXTRACE_CS_ETM,
4646 PERF_AUXTRACE_ARM_SPE,
47+ PERF_AUXTRACE_S390_CPUMSF,
4748 };
4849
4950 enum itrace_period_type {
tools/perf/util/bpf-loader.c+30−18
@@ -1529,13 +1529,13 @@ int bpf__apply_obj_config(void) · 1528 unmodified lines
15291529 bpf_object__for_each_safe(obj, objtmp) \
15301530 bpf_map__for_each(pos, obj)
15311531
1532−#define bpf__for_each_stdout_map(pos, obj, objtmp) \
1532+#define bpf__for_each_map_named(pos, obj, objtmp, name) \
15331533 bpf__for_each_map(pos, obj, objtmp) \
15341534 if (bpf_map__name(pos) && \
1535− (strcmp("__bpf_stdout__", \
1535+ (strcmp(name, \
15361536 bpf_map__name(pos)) == 0))
15371537
1538−int bpf__setup_stdout(struct perf_evlist *evlist)
1538+struct perf_evsel *bpf__setup_output_event(struct perf_evlist *evlist, const char *name)
15391539 {
15401540 struct bpf_map_priv *tmpl_priv = NULL;
15411541 struct bpf_object *obj, *tmp;
@@ -1544,11 +1544,11 @@ int bpf__setup_stdout(struct perf_evlist *evlist) · 2 unmodified lines
15441544 int err;
15451545 bool need_init = false;
15461546
1547− bpf__for_each_stdout_map(map, obj, tmp) {
1547+ bpf__for_each_map_named(map, obj, tmp, name) {
15481548 struct bpf_map_priv *priv = bpf_map__priv(map);
15491549
15501550 if (IS_ERR(priv))
1551− return -BPF_LOADER_ERRNO__INTERNAL;
1551+ return ERR_PTR(-BPF_LOADER_ERRNO__INTERNAL);
15521552
15531553 /*
15541554 * No need to check map type: type should have been
@@ -1561,49 +1561,61 @@ int bpf__setup_stdout(struct perf_evlist *evlist) · 6 unmodified lines
15611561 }
15621562
15631563 if (!need_init)
1564− return 0;
1564+ return NULL;
15651565
15661566 if (!tmpl_priv) {
1567− err = parse_events(evlist, "bpf-output/no-inherit=1,name=__bpf_stdout__/",
1568− NULL);
1567+ char *event_definition = NULL;
1568+
1569+ if (asprintf(&event_definition, "bpf-output/no-inherit=1,name=%s/", name) < 0)
1570+ return ERR_PTR(-ENOMEM);
1571+
1572+ err = parse_events(evlist, event_definition, NULL);
1573+ free(event_definition);
1574+
15691575 if (err) {
1570− pr_debug("ERROR: failed to create bpf-output event\n");
1571− return -err;
1576+ pr_debug("ERROR: failed to create the \"%s\" bpf-output event\n", name);
1577+ return ERR_PTR(-err);
15721578 }
15731579
15741580 evsel = perf_evlist__last(evlist);
15751581 }
15761582
1577− bpf__for_each_stdout_map(map, obj, tmp) {
1583+ bpf__for_each_map_named(map, obj, tmp, name) {
15781584 struct bpf_map_priv *priv = bpf_map__priv(map);
15791585
15801586 if (IS_ERR(priv))
1581− return -BPF_LOADER_ERRNO__INTERNAL;
1587+ return ERR_PTR(-BPF_LOADER_ERRNO__INTERNAL);
15821588 if (priv)
15831589 continue;
15841590
15851591 if (tmpl_priv) {
15861592 priv = bpf_map_priv__clone(tmpl_priv);
15871593 if (!priv)
1588− return -ENOMEM;
1594+ return ERR_PTR(-ENOMEM);
15891595
15901596 err = bpf_map__set_priv(map, priv, bpf_map_priv__clear);
15911597 if (err) {
15921598 bpf_map_priv__clear(map, priv);
1593− return err;
1599+ return ERR_PTR(err);
15941600 }
15951601 } else if (evsel) {
15961602 struct bpf_map_op *op;
15971603
15981604 op = bpf_map__add_newop(map, NULL);
15991605 if (IS_ERR(op))
1600− return PTR_ERR(op);
1606+ return ERR_PTR(PTR_ERR(op));
16011607 op->op_type = BPF_MAP_OP_SET_EVSEL;
16021608 op->v.evsel = evsel;
16031609 }
16041610 }
16051611
1606− return 0;
1612+ return evsel;
1613+}
1614+
1615+int bpf__setup_stdout(struct perf_evlist *evlist)
1616+{
1617+ struct perf_evsel *evsel = bpf__setup_output_event(evlist, "__bpf_stdout__");
1618+ return IS_ERR(evsel) ? PTR_ERR(evsel) : 0;
16071619 }
16081620
16091621 #define ERRNO_OFFSET(e) ((e) - __BPF_LOADER_ERRNO__START)
@@ -1780,8 +1792,8 @@ int bpf__strerror_apply_obj_config(int err, char *buf, size_t size) · 170 unmodified lines
17801792 return 0;
17811793 }
17821794
1783−int bpf__strerror_setup_stdout(struct perf_evlist *evlist __maybe_unused,
1784− int err, char *buf, size_t size)
1795+int bpf__strerror_setup_output_event(struct perf_evlist *evlist __maybe_unused,
1796+ int err, char *buf, size_t size)
17851797 {
17861798 bpf__strerror_head(err, buf, size);
17871799 bpf__strerror_end(buf, size);
tools/perf/util/bpf-loader.h+17−6
@@ -43,6 +43,7 @@ enum bpf_loader_errno { · 42 unmodified lines
4343 __BPF_LOADER_ERRNO__END,
4444 };
4545
46+struct perf_evsel;
4647 struct bpf_object;
4748 struct parse_events_term;
4849 #define PERF_BPF_PROBE_GROUP "perf_bpf_probe"
@@ -82,9 +83,8 @@ int bpf__apply_obj_config(void); · 33 unmodified lines
8283 int bpf__strerror_apply_obj_config(int err, char *buf, size_t size);
8384
8485 int bpf__setup_stdout(struct perf_evlist *evlist);
85−int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err,
86− char *buf, size_t size);
87−
86+struct perf_evsel *bpf__setup_output_event(struct perf_evlist *evlist, const char *name);
87+int bpf__strerror_setup_output_event(struct perf_evlist *evlist, int err, char *buf, size_t size);
8888 #else
8989 #include <errno.h>
9090
@@ -138,6 +138,12 @@ bpf__setup_stdout(struct perf_evlist *evlist __maybe_unused) · 47 unmodified lines
138138 return 0;
139139 }
140140
141+static inline struct perf_evsel *
142+bpf__setup_output_event(struct perf_evlist *evlist __maybe_unused, const char *name __maybe_unused)
143+{
144+ return NULL;
145+}
146+
141147 static inline int
142148 __bpf_strerror(char *buf, size_t size)
143149 {
@@ -193,11 +199,16 @@ bpf__strerror_apply_obj_config(int err __maybe_unused, · 49 unmodified lines
193199 }
194200
195201 static inline int
196−bpf__strerror_setup_stdout(struct perf_evlist *evlist __maybe_unused,
197− int err __maybe_unused, char *buf,
198− size_t size)
202+bpf__strerror_setup_output_event(struct perf_evlist *evlist __maybe_unused,
203+ int err __maybe_unused, char *buf, size_t size)
199204 {
200205 return __bpf_strerror(buf, size);
201206 }
207+
202208 #endif
209+
210+static inline int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err, char *buf, size_t size)
211+{
212+ return bpf__strerror_setup_output_event(evlist, err, buf, size);
213+}
203214 #endif
tools/perf/util/compress.h+2−0
@@ -4,10 +4,12 @@ · 3 unmodified lines
44
55 #ifdef HAVE_ZLIB_SUPPORT
66 int gzip_decompress_to_file(const char *input, int output_fd);
7+bool gzip_is_compressed(const char *input);
78 #endif
89
910 #ifdef HAVE_LZMA_SUPPORT
1011 int lzma_decompress_to_file(const char *input, int output_fd);
12+bool lzma_is_compressed(const char *input);
1113 #endif
1214
1315 #endif /* PERF_COMPRESS_H */
tools/perf/util/data-convert-bt.c+3−3
@@ -310,8 +310,8 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, · 309 unmodified lines
310310 if (flags & FIELD_IS_DYNAMIC) {
311311 unsigned long long tmp_val;
312312
313− tmp_val = pevent_read_number(fmtf->event->pevent,
314− data + offset, len);
313+ tmp_val = tep_read_number(fmtf->event->pevent,
314+ data + offset, len);
315315 offset = tmp_val;
316316 len = offset >> 16;
317317 offset &= 0xffff;
@@ -353,7 +353,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, · 35 unmodified lines
353353 else {
354354 unsigned long long value_int;
355355
356− value_int = pevent_read_number(
356+ value_int = tep_read_number(
357357 fmtf->event->pevent,
358358 data + offset + i * len, len);
359359
tools/perf/util/dso.c+53−58
@@ -189,28 +189,34 @@ int dso__read_binary_type_filename(const struct dso *dso, · 188 unmodified lines
189189 return ret;
190190 }
191191
192+enum {
193+ COMP_ID__NONE = 0,
194+};
195+
192196 static const struct {
193197 const char *fmt;
194198 int (*decompress)(const char *input, int output);
199+ bool (*is_compressed)(const char *input);
195200 } compressions[] = {
201+ [COMP_ID__NONE] = { .fmt = NULL, },
196202 #ifdef HAVE_ZLIB_SUPPORT
197− { "gz", gzip_decompress_to_file },
203+ { "gz", gzip_decompress_to_file, gzip_is_compressed },
198204 #endif
199205 #ifdef HAVE_LZMA_SUPPORT
200− { "xz", lzma_decompress_to_file },
206+ { "xz", lzma_decompress_to_file, lzma_is_compressed },
201207 #endif
202− { NULL, NULL },
208+ { NULL, NULL, NULL },
203209 };
204210
205−bool is_supported_compression(const char *ext)
211+static int is_supported_compression(const char *ext)
206212 {
207213 unsigned i;
208214
209− for (i = 0; compressions[i].fmt; i++) {
215+ for (i = 1; compressions[i].fmt; i++) {
210216 if (!strcmp(ext, compressions[i].fmt))
211− return true;
217+ return i;
212218 }
213− return false;
219+ return COMP_ID__NONE;
214220 }
215221
216222 bool is_kernel_module(const char *pathname, int cpumode)
@@ -239,80 +245,73 @@ bool is_kernel_module(const char *pathname, int cpumode) · 22 unmodified lines
239245 return m.kmod;
240246 }
241247
242−bool decompress_to_file(const char *ext, const char *filename, int output_fd)
243−{
244− unsigned i;
245−
246− for (i = 0; compressions[i].fmt; i++) {
247− if (!strcmp(ext, compressions[i].fmt))
248− return !compressions[i].decompress(filename,
249− output_fd);
250− }
251− return false;
252−}
253−
254248 bool dso__needs_decompress(struct dso *dso)
255249 {
256250 return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
257251 dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
258252 }
259253
260−static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf)
254+static int decompress_kmodule(struct dso *dso, const char *name,
255+ char *pathname, size_t len)
261256 {
257+ char tmpbuf[] = KMOD_DECOMP_NAME;
262258 int fd = -1;
263− struct kmod_path m;
264259
265260 if (!dso__needs_decompress(dso))
266261 return -1;
267262
268− if (kmod_path__parse_ext(&m, dso->long_name))
263+ if (dso->comp == COMP_ID__NONE)
269264 return -1;
270265
271− if (!m.comp)
272− goto out;
266+ /*
267+ * We have proper compression id for DSO and yet the file
268+ * behind the 'name' can still be plain uncompressed object.
269+ *
270+ * The reason is behind the logic we open the DSO object files,
271+ * when we try all possible 'debug' objects until we find the
272+ * data. So even if the DSO is represented by 'krava.xz' module,
273+ * we can end up here opening ~/.debug/....23432432/debug' file
274+ * which is not compressed.
275+ *
276+ * To keep this transparent, we detect this and return the file
277+ * descriptor to the uncompressed file.
278+ */
279+ if (!compressions[dso->comp].is_compressed(name))
280+ return open(name, O_RDONLY);
273281
274282 fd = mkstemp(tmpbuf);
275283 if (fd < 0) {
276284 dso->load_errno = errno;
277− goto out;
285+ return -1;
278286 }
279287
280− if (!decompress_to_file(m.ext, name, fd)) {
288+ if (compressions[dso->comp].decompress(name, fd)) {
281289 dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE;
282290 close(fd);
283291 fd = -1;
284292 }
285293
286−out:
287− free(m.ext);
294+ if (!pathname || (fd < 0))
295+ unlink(tmpbuf);
296+
297+ if (pathname && (fd >= 0))
298+ strncpy(pathname, tmpbuf, len);
299+
288300 return fd;
289301 }
290302
291303 int dso__decompress_kmodule_fd(struct dso *dso, const char *name)
292304 {
293− char tmpbuf[] = KMOD_DECOMP_NAME;
294− int fd;
295−
296− fd = decompress_kmodule(dso, name, tmpbuf);
297− unlink(tmpbuf);
298− return fd;
305+ return decompress_kmodule(dso, name, NULL, 0);
299306 }
300307
301308 int dso__decompress_kmodule_path(struct dso *dso, const char *name,
302309 char *pathname, size_t len)
303310 {
304− char tmpbuf[] = KMOD_DECOMP_NAME;
305− int fd;
311+ int fd = decompress_kmodule(dso, name, pathname, len);
306312
307− fd = decompress_kmodule(dso, name, tmpbuf);
308− if (fd < 0) {
309− unlink(tmpbuf);
310− return -1;
311− }
312−
313− strncpy(pathname, tmpbuf, len);
314313 close(fd);
315− return 0;
314+ return fd >= 0 ? 0 : -1;
316315 }
317316
318317 /*
@@ -332,7 +331,7 @@ int dso__decompress_kmodule_path(struct dso *dso, const char *name, · 13 unmodified lines
332331 * Returns 0 if there's no strdup error, -ENOMEM otherwise.
333332 */
334333 int __kmod_path__parse(struct kmod_path *m, const char *path,
335− bool alloc_name, bool alloc_ext)
334+ bool alloc_name)
336335 {
337336 const char *name = strrchr(path, '/');
338337 const char *ext = strrchr(path, '.');
@@ -372,10 +371,9 @@ int __kmod_path__parse(struct kmod_path *m, const char *path, · 33 unmodified lines
372371 return 0;
373372 }
374373
375− if (is_supported_compression(ext + 1)) {
376− m->comp = true;
374+ m->comp = is_supported_compression(ext + 1);
375+ if (m->comp > COMP_ID__NONE)
377376 ext -= 3;
378− }
379377
380378 /* Check .ko extension only if there's enough name left. */
381379 if (ext > name)
@@ -393,14 +391,6 @@ int __kmod_path__parse(struct kmod_path *m, const char *path, · 11 unmodified lines
393391 strxfrchar(m->name, '-', '_');
394392 }
395393
396− if (alloc_ext && m->comp) {
397− m->ext = strdup(ext + 4);
398− if (!m->ext) {
399− free((void *) m->name);
400− return -ENOMEM;
401− }
402− }
403−
404394 return 0;
405395 }
406396
@@ -413,8 +403,10 @@ void dso__set_module_info(struct dso *dso, struct kmod_path *m, · 6 unmodified lines
413403 dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
414404
415405 /* _KMODULE_COMP should be next to _KMODULE */
416− if (m->kmod && m->comp)
406+ if (m->kmod && m->comp) {
417407 dso->symtab_type++;
408+ dso->comp = m->comp;
409+ }
418410
419411 dso__set_short_name(dso, strdup(m->name), true);
420412 }
@@ -468,6 +460,7 @@ static int __open_dso(struct dso *dso, struct machine *machine) · 47 unmodified lines
468460 int fd = -EINVAL;
469461 char *root_dir = (char *)"";
470462 char *name = malloc(PATH_MAX);
463+ bool decomp = false;
471464
472465 if (!name)
473466 return -ENOMEM;
@@ -491,12 +484,13 @@ static int __open_dso(struct dso *dso, struct machine *machine) · 17 unmodified lines
491484 goto out;
492485 }
493486
487+ decomp = true;
494488 strcpy(name, newpath);
495489 }
496490
497491 fd = do_open(name);
498492
499− if (dso__needs_decompress(dso))
493+ if (decomp)
500494 unlink(name);
501495
502496 out:
@@ -1218,6 +1212,7 @@ struct dso *dso__new(const char *name) · 715 unmodified lines
12181212 dso->a2l_fails = 1;
12191213 dso->kernel = DSO_TYPE_USER;
12201214 dso->needs_swap = DSO_SWAP__UNSET;
1215+ dso->comp = COMP_ID__NONE;
12211216 RB_CLEAR_NODE(&dso->rb_node);
12221217 dso->root = NULL;
12231218 INIT_LIST_HEAD(&dso->node);
tools/perf/util/dso.h+5−8
@@ -175,6 +175,7 @@ struct dso { · 174 unmodified lines
175175 u16 short_name_len;
176176 void *dwfl; /* DWARF debug info */
177177 struct auxtrace_cache *auxtrace_cache;
178+ int comp;
178179
179180 /* dso data file */
180181 struct {
@@ -250,9 +251,7 @@ int dso__kernel_module_get_build_id(struct dso *dso, const char *root_dir); · 69 unmodified lines
250251 char dso__symtab_origin(const struct dso *dso);
251252 int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type type,
252253 char *root_dir, char *filename, size_t size);
253−bool is_supported_compression(const char *ext);
254254 bool is_kernel_module(const char *pathname, int cpumode);
255−bool decompress_to_file(const char *ext, const char *filename, int output_fd);
256255 bool dso__needs_decompress(struct dso *dso);
257256 int dso__decompress_kmodule_fd(struct dso *dso, const char *name);
258257 int dso__decompress_kmodule_path(struct dso *dso, const char *name,
@@ -263,17 +262,15 @@ int dso__decompress_kmodule_path(struct dso *dso, const char *name, · 4 unmodified lines
263262
264263 struct kmod_path {
265264 char *name;
266− char *ext;
267− bool comp;
265+ int comp;
268266 bool kmod;
269267 };
270268
271269 int __kmod_path__parse(struct kmod_path *m, const char *path,
272− bool alloc_name, bool alloc_ext);
270+ bool alloc_name);
273271
274−#define kmod_path__parse(__m, __p) __kmod_path__parse(__m, __p, false, false)
275−#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false)
276−#define kmod_path__parse_ext(__m, __p) __kmod_path__parse(__m, __p, false, true)
272+#define kmod_path__parse(__m, __p) __kmod_path__parse(__m, __p, false)
273+#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true)
277274
278275 void dso__set_module_info(struct dso *dso, struct kmod_path *m,
279276 struct machine *machine);
tools/perf/util/event.c+10−3
@@ -541,10 +541,17 @@ static int __event__synthesize_thread(union perf_event *comm_event, · 540 unmodified lines
541541 tgid, process, machine) < 0)
542542 return -1;
543543
544+ /*
545+ * send mmap only for thread group leader
546+ * see thread__init_map_groups
547+ */
548+ if (pid == tgid &&
549+ perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid,
550+ process, machine, mmap_data,
551+ proc_map_timeout))
552+ return -1;
544553
545− return perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid,
546− process, machine, mmap_data,
547− proc_map_timeout);
554+ return 0;
548555 }
549556
550557 if (machine__is_default_guest(machine))
tools/perf/util/evlist.c+1−1
@@ -803,7 +803,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, · 802 unmodified lines
803803 if (*output == -1) {
804804 *output = fd;
805805
806− if (perf_mmap__mmap(&maps[idx], mp, *output) < 0)
806+ if (perf_mmap__mmap(&maps[idx], mp, *output, evlist_cpu) < 0)
807807 return -1;
808808 } else {
809809 if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
tools/perf/util/evsel.c+1−1
@@ -2683,7 +2683,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, · 2682 unmodified lines
26832683
26842684 struct format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name)
26852685 {
2686− return pevent_find_field(evsel->tp_format, name);
2686+ return tep_find_field(evsel->tp_format, name);
26872687 }
26882688
26892689 void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample,
tools/perf/util/evsel.h+7−0
@@ -452,11 +452,18 @@ static inline int perf_evsel__group_idx(struct perf_evsel *evsel) · 451 unmodified lines
452452 return evsel->idx - evsel->leader->idx;
453453 }
454454
455+/* Iterates group WITHOUT the leader. */
455456 #define for_each_group_member(_evsel, _leader) \
456457 for ((_evsel) = list_entry((_leader)->node.next, struct perf_evsel, node); \
457458 (_evsel) && (_evsel)->leader == (_leader); \
458459 (_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node))
459460
461+/* Iterates group WITH the leader. */
462+#define for_each_group_evsel(_evsel, _leader) \
463+for ((_evsel) = _leader; \
464+ (_evsel) && (_evsel)->leader == (_leader); \
465+ (_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node))
466+
460467 static inline bool perf_evsel__has_branch_callstack(const struct perf_evsel *evsel)
461468 {
462469 return evsel->attr.branch_sample_type & PERF_SAMPLE_BRANCH_CALL_STACK;
tools/perf/util/header.c+3−6
@@ -279,8 +279,6 @@ static int do_read_bitmap(struct feat_fd *ff, unsigned long **pset, u64 *psize) · 278 unmodified lines
279279 if (!set)
280280 return -ENOMEM;
281281
282− bitmap_zero(set, size);
283−
284282 p = (u64 *) set;
285283
286284 for (i = 0; (u64) i < BITS_TO_U64(size); i++) {
@@ -1285,7 +1283,6 @@ static int memory_node__read(struct memory_node *n, unsigned long idx) · 998 unmodified lines
12851283 return -ENOMEM;
12861284 }
12871285
1288− bitmap_zero(n->set, size);
12891286 n->node = idx;
12901287 n->size = size;
12911288
@@ -3207,7 +3204,7 @@ static int read_attr(int fd, struct perf_header *ph, · 1915 unmodified lines
32073204 }
32083205
32093206 static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel,
3210− struct pevent *pevent)
3207+ struct tep_handle *pevent)
32113208 {
32123209 struct event_format *event;
32133210 char bf[128];
@@ -3221,7 +3218,7 @@ static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel, · 7 unmodified lines
32213218 return -1;
32223219 }
32233220
3224− event = pevent_find_event(pevent, evsel->attr.config);
3221+ event = tep_find_event(pevent, evsel->attr.config);
32253222 if (event == NULL) {
32263223 pr_debug("cannot find event format for %d\n", (int)evsel->attr.config);
32273224 return -1;
@@ -3239,7 +3236,7 @@ static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel, · 11 unmodified lines
32393236 }
32403237
32413238 static int perf_evlist__prepare_tracepoint_events(struct perf_evlist *evlist,
3242− struct pevent *pevent)
3239+ struct tep_handle *pevent)
32433240 {
32443241 struct perf_evsel *pos;
32453242
tools/perf/util/llvm-utils.c+29−2
@@ -22,12 +22,14 @@ · 21 unmodified lines
2222 "$CLANG_OPTIONS $KERNEL_INC_OPTIONS $PERF_BPF_INC_OPTIONS " \
2323 "-Wno-unused-value -Wno-pointer-sign " \
2424 "-working-directory $WORKING_DIR " \
25− "-c \"$CLANG_SOURCE\" -target bpf -O2 -o -"
25+ "-c \"$CLANG_SOURCE\" -target bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE"
2626
2727 struct llvm_param llvm_param = {
2828 .clang_path = "clang",
29+ .llc_path = "llc",
2930 .clang_bpf_cmd_template = CLANG_BPF_CMD_DEFAULT_TEMPLATE,
3031 .clang_opt = NULL,
32+ .opts = NULL,
3133 .kbuild_dir = NULL,
3234 .kbuild_opts = NULL,
3335 .user_set_param = false,
@@ -51,6 +53,8 @@ int perf_llvm_config(const char *var, const char *value) · 17 unmodified lines
5153 llvm_param.kbuild_opts = strdup(value);
5254 else if (!strcmp(var, "dump-obj"))
5355 llvm_param.dump_obj = !!perf_config_bool(var, value);
56+ else if (!strcmp(var, "opts"))
57+ llvm_param.opts = strdup(value);
5458 else {
5559 pr_debug("Invalid LLVM config option: %s\n", value);
5660 return -1;
@@ -430,11 +434,13 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf, · 373 unmodified lines
430434 unsigned int kernel_version;
431435 char linux_version_code_str[64];
432436 const char *clang_opt = llvm_param.clang_opt;
433− char clang_path[PATH_MAX], abspath[PATH_MAX], nr_cpus_avail_str[64];
437+ char clang_path[PATH_MAX], llc_path[PATH_MAX], abspath[PATH_MAX], nr_cpus_avail_str[64];
434438 char serr[STRERR_BUFSIZE];
435439 char *kbuild_dir = NULL, *kbuild_include_opts = NULL,
436440 *perf_bpf_include_opts = NULL;
437441 const char *template = llvm_param.clang_bpf_cmd_template;
442+ char *pipe_template = NULL;
443+ const char *opts = llvm_param.opts;
438444 char *command_echo = NULL, *command_out;
439445 char *perf_include_dir = system_path(PERF_INCLUDE_DIR);
440446
@@ -484,6 +490,26 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf, · 43 unmodified lines
484490 force_set_env("PERF_BPF_INC_OPTIONS", perf_bpf_include_opts);
485491 force_set_env("WORKING_DIR", kbuild_dir ? : ".");
486492
493+ if (opts) {
494+ err = search_program(llvm_param.llc_path, "llc", llc_path);
495+ if (err) {
496+ pr_err("ERROR:\tunable to find llc.\n"
497+ "Hint:\tTry to install latest clang/llvm to support BPF. Check your $PATH\n"
498+ " \tand 'llc-path' option in [llvm] section of ~/.perfconfig.\n");
499+ version_notice();
500+ goto errout;
501+ }
502+
503+ if (asprintf(&pipe_template, "%s -emit-llvm | %s -march=bpf %s -filetype=obj -o -",
504+ template, llc_path, opts) < 0) {
505+ pr_err("ERROR:\tnot enough memory to setup command line\n");
506+ goto errout;
507+ }
508+
509+ template = pipe_template;
510+
511+ }
512+
487513 /*
488514 * Since we may reset clang's working dir, path of source file
489515 * should be transferred into absolute path, except we want
@@ -535,6 +561,7 @@ errout: · 45 unmodified lines
535561 free(obj_buf);
536562 free(perf_bpf_include_opts);
537563 free(perf_include_dir);
564+ free(pipe_template);
538565 if (p_obj_buf)
539566 *p_obj_buf = NULL;
540567 if (p_obj_buf_sz)
tools/perf/util/llvm-utils.h+9−0
@@ -11,6 +11,8 @@ · 10 unmodified lines
1111 struct llvm_param {
1212 /* Path of clang executable */
1313 const char *clang_path;
14+ /* Path of llc executable */
15+ const char *llc_path;
1416 /*
1517 * Template of clang bpf compiling. 5 env variables
1618 * can be used:
@@ -23,6 +25,13 @@ struct llvm_param { · 6 unmodified lines
2325 const char *clang_bpf_cmd_template;
2426 /* Will be filled in $CLANG_OPTIONS */
2527 const char *clang_opt;
28+ /*
29+ * If present it'll add -emit-llvm to $CLANG_OPTIONS to pipe
30+ * the clang output to llc, useful for new llvm options not
31+ * yet selectable via 'clang -mllvm option', such as -mattr=dwarfris
32+ * in clang 6.0/llvm 7
33+ */
34+ const char *opts;
2635 /* Where to find kbuild system */
2736 const char *kbuild_dir;
2837 /*
tools/perf/util/lzma.c+20−0
@@ -3,9 +3,13 @@ · 2 unmodified lines
33 #include <lzma.h>
44 #include <stdio.h>
55 #include <linux/compiler.h>
6+#include <sys/types.h>
7+#include <sys/stat.h>
8+#include <fcntl.h>
69 #include "compress.h"
710 #include "util.h"
811 #include "debug.h"
12+#include <unistd.h>
913
1014 #define BUFSIZE 8192
1115
@@ -99,3 +103,19 @@ err_fclose: · 87 unmodified lines
99103 fclose(infile);
100104 return err;
101105 }
106+
107+bool lzma_is_compressed(const char *input)
108+{
109+ int fd = open(input, O_RDONLY);
110+ const uint8_t magic[6] = { 0xFD, '7', 'z', 'X', 'Z', 0x00 };
111+ char buf[6] = { 0 };
112+ ssize_t rc;
113+
114+ if (fd < 0)
115+ return -1;
116+
117+ rc = read(fd, buf, sizeof(buf));
118+ close(fd);
119+ return rc == sizeof(buf) ?
120+ memcmp(buf, magic, sizeof(buf)) == 0 : false;
121+}
tools/perf/util/machine.c+3−1
@@ -1212,8 +1212,10 @@ static int map_groups__set_module_path(struct map_groups *mg, const char *path, · 1211 unmodified lines
12121212 * Full name could reveal us kmod compression, so
12131213 * we need to update the symtab_type if needed.
12141214 */
1215− if (m->comp && is_kmod_dso(map->dso))
1215+ if (m->comp && is_kmod_dso(map->dso)) {
12161216 map->dso->symtab_type++;
1217+ map->dso->comp = m->comp;
1218+ }
12171219
12181220 return 0;
12191221 }
tools/perf/util/machine.h+1−1
@@ -265,7 +265,7 @@ pid_t machine__get_current_tid(struct machine *machine, int cpu); · 264 unmodified lines
265265 int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
266266 pid_t tid);
267267 /*
268− * For use with libtraceevent's pevent_set_function_resolver()
268+ * For use with libtraceevent's tep_set_function_resolver()
269269 */
270270 char *machine__resolve_kernel_addr(void *vmachine, unsigned long long *addrp, char **modp);
271271
tools/perf/util/map.c+26−18
@@ -381,20 +381,6 @@ struct map *map__clone(struct map *from) · 380 unmodified lines
381381 return map;
382382 }
383383
384−int map__overlap(struct map *l, struct map *r)
385−{
386− if (l->start > r->start) {
387− struct map *t = l;
388− l = r;
389− r = t;
390− }
391−
392− if (l->end > r->start)
393− return 1;
394−
395− return 0;
396−}
397−
398384 size_t map__fprintf(struct map *map, FILE *fp)
399385 {
400386 return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n",
@@ -675,20 +661,42 @@ static void __map_groups__insert(struct map_groups *mg, struct map *map) · 274 unmodified lines
675661 static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
676662 {
677663 struct rb_root *root;
678− struct rb_node *next;
664+ struct rb_node *next, *first;
679665 int err = 0;
680666
681667 down_write(&maps->lock);
682668
683669 root = &maps->entries;
684− next = rb_first(root);
685670
671+ /*
672+ * Find first map where end > map->start.
673+ * Same as find_vma() in kernel.
674+ */
675+ next = root->rb_node;
676+ first = NULL;
677+ while (next) {
678+ struct map *pos = rb_entry(next, struct map, rb_node);
679+
680+ if (pos->end > map->start) {
681+ first = next;
682+ if (pos->start <= map->start)
683+ break;
684+ next = next->rb_left;
685+ } else
686+ next = next->rb_right;
687+ }
688+
689+ next = first;
686690 while (next) {
687691 struct map *pos = rb_entry(next, struct map, rb_node);
688692 next = rb_next(&pos->rb_node);
689693
690− if (!map__overlap(pos, map))
691− continue;
694+ /*
695+ * Stop if current map starts after map->end.
696+ * Maps are ordered by start: next will not overlap for sure.
697+ */
698+ if (pos->start >= map->end)
699+ break;
692700
693701 if (verbose >= 2) {
694702
tools/perf/util/map.h+0−1
@@ -166,7 +166,6 @@ static inline void __map__zput(struct map **map) · 165 unmodified lines
166166
167167 #define map__zput(map) __map__zput(&map)
168168
169−int map__overlap(struct map *l, struct map *r);
170169 size_t map__fprintf(struct map *map, FILE *fp);
171170 size_t map__fprintf_dsoname(struct map *map, FILE *fp);
172171 char *map__srcline(struct map *map, u64 addr, struct symbol *sym);
tools/perf/util/mmap.c+2−1
@@ -164,7 +164,7 @@ void perf_mmap__munmap(struct perf_mmap *map) · 163 unmodified lines
164164 auxtrace_mmap__munmap(&map->auxtrace_mmap);
165165 }
166166
167−int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd)
167+int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int cpu)
168168 {
169169 /*
170170 * The last one will be done at perf_mmap__consume(), so that we
@@ -191,6 +191,7 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd) · 20 unmodified lines
191191 return -1;
192192 }
193193 map->fd = fd;
194+ map->cpu = cpu;
194195
195196 if (auxtrace_mmap__mmap(&map->auxtrace_mmap,
196197 &mp->auxtrace_mp, map->base, fd))
tools/perf/util/mmap.h+2−1
@@ -18,6 +18,7 @@ struct perf_mmap { · 17 unmodified lines
1818 void *base;
1919 int mask;
2020 int fd;
21+ int cpu;
2122 refcount_t refcnt;
2223 u64 prev;
2324 u64 start;
@@ -60,7 +61,7 @@ struct mmap_params { · 36 unmodified lines
6061 struct auxtrace_mmap_params auxtrace_mp;
6162 };
6263
63−int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd);
64+int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int cpu);
6465 void perf_mmap__munmap(struct perf_mmap *map);
6566
6667 void perf_mmap__get(struct perf_mmap *map);
tools/perf/util/namespaces.c+3−0
@@ -139,6 +139,9 @@ struct nsinfo *nsinfo__copy(struct nsinfo *nsi) · 138 unmodified lines
139139 {
140140 struct nsinfo *nnsi;
141141
142+ if (nsi == NULL)
143+ return NULL;
144+
142145 nnsi = calloc(1, sizeof(*nnsi));
143146 if (nnsi != NULL) {
144147 nnsi->pid = nsi->pid;
tools/perf/util/parse-events.c+10−10
@@ -1991,8 +1991,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg) · 1990 unmodified lines
19911991 int nr_addr_filters = 0;
19921992 struct perf_pmu *pmu = NULL;
19931993
1994− if (evsel == NULL)
1995− goto err;
1994+ if (evsel == NULL) {
1995+ fprintf(stderr,
1996+ "--filter option should follow a -e tracepoint or HW tracer option\n");
1997+ return -1;
1998+ }
19961999
19972000 if (evsel->attr.type == PERF_TYPE_TRACEPOINT) {
19982001 if (perf_evsel__append_tp_filter(evsel, str) < 0) {
@@ -2014,8 +2017,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg) · 15 unmodified lines
20142017 perf_pmu__scan_file(pmu, "nr_addr_filters",
20152018 "%d", &nr_addr_filters);
20162019
2017− if (!nr_addr_filters)
2018− goto err;
2020+ if (!nr_addr_filters) {
2021+ fprintf(stderr,
2022+ "This CPU does not support address filtering\n");
2023+ return -1;
2024+ }
20192025
20202026 if (perf_evsel__append_addr_filter(evsel, str) < 0) {
20212027 fprintf(stderr,
@@ -2024,12 +2030,6 @@ static int set_filter(struct perf_evsel *evsel, const void *arg) · 2 unmodified lines
20242030 }
20252031
20262032 return 0;
2027−
2028−err:
2029− fprintf(stderr,
2030− "--filter option should follow a -e tracepoint or HW tracer option\n");
2031−
2032− return -1;
20332033 }
20342034
20352035 int parse_filter(const struct option *opt, const char *str,
tools/perf/util/python.c+24−6
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #include "cpumap.h"
1212 #include "print_binary.h"
1313 #include "thread_map.h"
14+#include "mmap.h"
1415
1516 #if PY_MAJOR_VERSION < 3
1617 #define _PyUnicode_FromString(arg) \
@@ -341,7 +342,7 @@ static bool is_tracepoint(struct pyrf_event *pevent) · 324 unmodified lines
341342 static PyObject*
342343 tracepoint_field(struct pyrf_event *pe, struct format_field *field)
343344 {
344− struct pevent *pevent = field->event->pevent;
345+ struct tep_handle *pevent = field->event->pevent;
345346 void *data = pe->sample.raw_data;
346347 PyObject *ret = NULL;
347348 unsigned long long val;
@@ -351,7 +352,7 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field) · 3 unmodified lines
351352 offset = field->offset;
352353 len = field->size;
353354 if (field->flags & FIELD_IS_DYNAMIC) {
354− val = pevent_read_number(pevent, data + offset, len);
355+ val = tep_read_number(pevent, data + offset, len);
355356 offset = val;
356357 len = offset >> 16;
357358 offset &= 0xffff;
@@ -364,8 +365,8 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field) · 6 unmodified lines
364365 field->flags &= ~FIELD_IS_STRING;
365366 }
366367 } else {
367− val = pevent_read_number(pevent, data + field->offset,
368− field->size);
368+ val = tep_read_number(pevent, data + field->offset,
369+ field->size);
369370 if (field->flags & FIELD_IS_POINTER)
370371 ret = PyLong_FromUnsignedLong((unsigned long) val);
371372 else if (field->flags & FIELD_IS_SIGNED)
@@ -394,7 +395,7 @@ get_tracepoint_field(struct pyrf_event *pevent, PyObject *attr_name) · 22 unmodified lines
394395 evsel->tp_format = tp_format;
395396 }
396397
397− field = pevent_find_any_field(evsel->tp_format, str);
398+ field = tep_find_any_field(evsel->tp_format, str);
398399 if (!field)
399400 return NULL;
400401
@@ -976,6 +977,20 @@ static PyObject *pyrf_evlist__add(struct pyrf_evlist *pevlist, · 575 unmodified lines
976977 return Py_BuildValue("i", evlist->nr_entries);
977978 }
978979
980+static struct perf_mmap *get_md(struct perf_evlist *evlist, int cpu)
981+{
982+ int i;
983+
984+ for (i = 0; i < evlist->nr_mmaps; i++) {
985+ struct perf_mmap *md = &evlist->mmap[i];
986+
987+ if (md->cpu == cpu)
988+ return md;
989+ }
990+
991+ return NULL;
992+}
993+
979994 static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
980995 PyObject *args, PyObject *kwargs)
981996 {
@@ -990,7 +1005,10 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, · 8 unmodified lines
9901005 &cpu, &sample_id_all))
9911006 return NULL;
9921007
993− md = &evlist->mmap[cpu];
1008+ md = get_md(evlist, cpu);
1009+ if (!md)
1010+ return NULL;
1011+
9941012 if (perf_mmap__read_init(md) < 0)
9951013 goto end;
9961014
tools/perf/util/s390-cpumsf-kernel.h+71−0
@@ -0,0 +1,71 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
2+/*
3+ * Auxtrace support for s390 CPU measurement sampling facility
4+ *
5+ * Copyright IBM Corp. 2018
6+ * Author(s): Hendrik Brueckner <brueckner@linux.ibm.com>
7+ * Thomas Richter <tmricht@linux.ibm.com>
8+ */
9+#ifndef S390_CPUMSF_KERNEL_H
10+#define S390_CPUMSF_KERNEL_H
11+
12+#define S390_CPUMSF_PAGESZ 4096 /* Size of sample block units */
13+#define S390_CPUMSF_DIAG_DEF_FIRST 0x8001 /* Diagnostic entry lowest id */
14+
15+struct hws_basic_entry {
16+ unsigned int def:16; /* 0-15 Data Entry Format */
17+ unsigned int R:4; /* 16-19 reserved */
18+ unsigned int U:4; /* 20-23 Number of unique instruct. */
19+ unsigned int z:2; /* zeros */
20+ unsigned int T:1; /* 26 PSW DAT mode */
21+ unsigned int W:1; /* 27 PSW wait state */
22+ unsigned int P:1; /* 28 PSW Problem state */
23+ unsigned int AS:2; /* 29-30 PSW address-space control */
24+ unsigned int I:1; /* 31 entry valid or invalid */
25+ unsigned int CL:2; /* 32-33 Configuration Level */
26+ unsigned int:14;
27+ unsigned int prim_asn:16; /* primary ASN */
28+ unsigned long long ia; /* Instruction Address */
29+ unsigned long long gpp; /* Guest Program Parameter */
30+ unsigned long long hpp; /* Host Program Parameter */
31+};
32+
33+struct hws_diag_entry {
34+ unsigned int def:16; /* 0-15 Data Entry Format */
35+ unsigned int R:15; /* 16-19 and 20-30 reserved */
36+ unsigned int I:1; /* 31 entry valid or invalid */
37+ u8 data[]; /* Machine-dependent sample data */
38+};
39+
40+struct hws_combined_entry {
41+ struct hws_basic_entry basic; /* Basic-sampling data entry */
42+ struct hws_diag_entry diag; /* Diagnostic-sampling data entry */
43+};
44+
45+struct hws_trailer_entry {
46+ union {
47+ struct {
48+ unsigned int f:1; /* 0 - Block Full Indicator */
49+ unsigned int a:1; /* 1 - Alert request control */
50+ unsigned int t:1; /* 2 - Timestamp format */
51+ unsigned int:29; /* 3 - 31: Reserved */
52+ unsigned int bsdes:16; /* 32-47: size of basic SDE */
53+ unsigned int dsdes:16; /* 48-63: size of diagnostic SDE */
54+ };
55+ unsigned long long flags; /* 0 - 64: All indicators */
56+ };
57+ unsigned long long overflow; /* 64 - sample Overflow count */
58+ unsigned char timestamp[16]; /* 16 - 31 timestamp */
59+ unsigned long long reserved1; /* 32 -Reserved */
60+ unsigned long long reserved2; /* */
61+ union { /* 48 - reserved for programming use */
62+ struct {
63+ unsigned long long clock_base:1; /* in progusage2 */
64+ unsigned long long progusage1:63;
65+ unsigned long long progusage2;
66+ };
67+ unsigned long long progusage[2];
68+ };
69+};
70+
71+#endif
tools/perf/util/s390-cpumsf.c+945−0
@@ -0,0 +1,945 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Copyright IBM Corp. 2018
4+ * Auxtrace support for s390 CPU-Measurement Sampling Facility
5+ *
6+ * Author(s): Thomas Richter <tmricht@linux.ibm.com>
7+ *
8+ * Auxiliary traces are collected during 'perf record' using rbd000 event.
9+ * Several PERF_RECORD_XXX are generated during recording:
10+ *
11+ * PERF_RECORD_AUX:
12+ * Records that new data landed in the AUX buffer part.
13+ * PERF_RECORD_AUXTRACE:
14+ * Defines auxtrace data. Followed by the actual data. The contents of
15+ * the auxtrace data is dependent on the event and the CPU.
16+ * This record is generated by perf record command. For details
17+ * see Documentation/perf.data-file-format.txt.
18+ * PERF_RECORD_AUXTRACE_INFO:
19+ * Defines a table of contains for PERF_RECORD_AUXTRACE records. This
20+ * record is generated during 'perf record' command. Each record contains up
21+ * to 256 entries describing offset and size of the AUXTRACE data in the
22+ * perf.data file.
23+ * PERF_RECORD_AUXTRACE_ERROR:
24+ * Indicates an error during AUXTRACE collection such as buffer overflow.
25+ * PERF_RECORD_FINISHED_ROUND:
26+ * Perf events are not necessarily in time stamp order, as they can be
27+ * collected in parallel on different CPUs. If the events should be
28+ * processed in time order they need to be sorted first.
29+ * Perf report guarantees that there is no reordering over a
30+ * PERF_RECORD_FINISHED_ROUND boundary event. All perf records with a
31+ * time stamp lower than this record are processed (and displayed) before
32+ * the succeeding perf record are processed.
33+ *
34+ * These records are evaluated during perf report command.
35+ *
36+ * 1. PERF_RECORD_AUXTRACE_INFO is used to set up the infrastructure for
37+ * auxiliary trace data processing. See s390_cpumsf_process_auxtrace_info()
38+ * below.
39+ * Auxiliary trace data is collected per CPU. To merge the data into the report
40+ * an auxtrace_queue is created for each CPU. It is assumed that the auxtrace
41+ * data is in ascending order.
42+ *
43+ * Each queue has a double linked list of auxtrace_buffers. This list contains
44+ * the offset and size of a CPU's auxtrace data. During auxtrace processing
45+ * the data portion is mmap()'ed.
46+ *
47+ * To sort the queues in chronological order, all queue access is controlled
48+ * by the auxtrace_heap. This is basicly a stack, each stack element has two
49+ * entries, the queue number and a time stamp. However the stack is sorted by
50+ * the time stamps. The highest time stamp is at the bottom the lowest
51+ * (nearest) time stamp is at the top. That sort order is maintained at all
52+ * times!
53+ *
54+ * After the auxtrace infrastructure has been setup, the auxtrace queues are
55+ * filled with data (offset/size pairs) and the auxtrace_heap is populated.
56+ *
57+ * 2. PERF_RECORD_XXX processing triggers access to the auxtrace_queues.
58+ * Each record is handled by s390_cpumsf_process_event(). The time stamp of
59+ * the perf record is compared with the time stamp located on the auxtrace_heap
60+ * top element. If that time stamp is lower than the time stamp from the
61+ * record sample, the auxtrace queues will be processed. As auxtrace queues
62+ * control many auxtrace_buffers and each buffer can be quite large, the
63+ * auxtrace buffer might be processed only partially. In this case the
64+ * position in the auxtrace_buffer of that queue is remembered and the time
65+ * stamp of the last processed entry of the auxtrace_buffer replaces the
66+ * current auxtrace_heap top.
67+ *
68+ * 3. Auxtrace_queues might run of out data and are feeded by the
69+ * PERF_RECORD_AUXTRACE handling, see s390_cpumsf_process_auxtrace_event().
70+ *
71+ * Event Generation
72+ * Each sampling-data entry in the auxilary trace data generates a perf sample.
73+ * This sample is filled
74+ * with data from the auxtrace such as PID/TID, instruction address, CPU state,
75+ * etc. This sample is processed with perf_session__deliver_synth_event() to
76+ * be included into the GUI.
77+ *
78+ * 4. PERF_RECORD_FINISHED_ROUND event is used to process all the remaining
79+ * auxiliary traces entries until the time stamp of this record is reached
80+ * auxtrace_heap top. This is triggered by ordered_event->deliver().
81+ *
82+ *
83+ * Perf event processing.
84+ * Event processing of PERF_RECORD_XXX entries relies on time stamp entries.
85+ * This is the function call sequence:
86+ *
87+ * __cmd_report()
88+ * |
89+ * perf_session__process_events()
90+ * |
91+ * __perf_session__process_events()
92+ * |
93+ * perf_session__process_event()
94+ * | This functions splits the PERF_RECORD_XXX records.
95+ * | - Those generated by perf record command (type number equal or higher
96+ * | than PERF_RECORD_USER_TYPE_START) are handled by
97+ * | perf_session__process_user_event(see below)
98+ * | - Those generated by the kernel are handled by
99+ * | perf_evlist__parse_sample_timestamp()
100+ * |
101+ * perf_evlist__parse_sample_timestamp()
102+ * | Extract time stamp from sample data.
103+ * |
104+ * perf_session__queue_event()
105+ * | If timestamp is positive the sample is entered into an ordered_event
106+ * | list, sort order is the timestamp. The event processing is deferred until
107+ * | later (see perf_session__process_user_event()).
108+ * | Other timestamps (0 or -1) are handled immediately by
109+ * | perf_session__deliver_event(). These are events generated at start up
110+ * | of command perf record. They create PERF_RECORD_COMM and PERF_RECORD_MMAP*
111+ * | records. They are needed to create a list of running processes and its
112+ * | memory mappings and layout. They are needed at the beginning to enable
113+ * | command perf report to create process trees and memory mappings.
114+ * |
115+ * perf_session__deliver_event()
116+ * | Delivers a PERF_RECORD_XXX entry for handling.
117+ * |
118+ * auxtrace__process_event()
119+ * | The timestamp of the PERF_RECORD_XXX entry is taken to correlate with
120+ * | time stamps from the auxiliary trace buffers. This enables
121+ * | synchronization between auxiliary trace data and the events on the
122+ * | perf.data file.
123+ * |
124+ * machine__deliver_event()
125+ * | Handles the PERF_RECORD_XXX event. This depends on the record type.
126+ * It might update the process tree, update a process memory map or enter
127+ * a sample with IP and call back chain data into GUI data pool.
128+ *
129+ *
130+ * Deferred processing determined by perf_session__process_user_event() is
131+ * finally processed when a PERF_RECORD_FINISHED_ROUND is encountered. These
132+ * are generated during command perf record.
133+ * The timestamp of PERF_RECORD_FINISHED_ROUND event is taken to process all
134+ * PERF_RECORD_XXX entries stored in the ordered_event list. This list was
135+ * built up while reading the perf.data file.
136+ * Each event is now processed by calling perf_session__deliver_event().
137+ * This enables time synchronization between the data in the perf.data file and
138+ * the data in the auxiliary trace buffers.
139+ */
140+
141+#include <endian.h>
142+#include <errno.h>
143+#include <byteswap.h>
144+#include <inttypes.h>
145+#include <linux/kernel.h>
146+#include <linux/types.h>
147+#include <linux/bitops.h>
148+#include <linux/log2.h>
149+
150+#include "cpumap.h"
151+#include "color.h"
152+#include "evsel.h"
153+#include "evlist.h"
154+#include "machine.h"
155+#include "session.h"
156+#include "util.h"
157+#include "thread.h"
158+#include "debug.h"
159+#include "auxtrace.h"
160+#include "s390-cpumsf.h"
161+#include "s390-cpumsf-kernel.h"
162+
163+struct s390_cpumsf {
164+ struct auxtrace auxtrace;
165+ struct auxtrace_queues queues;
166+ struct auxtrace_heap heap;
167+ struct perf_session *session;
168+ struct machine *machine;
169+ u32 auxtrace_type;
170+ u32 pmu_type;
171+ u16 machine_type;
172+ bool data_queued;
173+};
174+
175+struct s390_cpumsf_queue {
176+ struct s390_cpumsf *sf;
177+ unsigned int queue_nr;
178+ struct auxtrace_buffer *buffer;
179+ int cpu;
180+};
181+
182+/* Display s390 CPU measurement facility basic-sampling data entry */
183+static bool s390_cpumsf_basic_show(const char *color, size_t pos,
184+ struct hws_basic_entry *basic)
185+{
186+ if (basic->def != 1) {
187+ pr_err("Invalid AUX trace basic entry [%#08zx]\n", pos);
188+ return false;
189+ }
190+ color_fprintf(stdout, color, " [%#08zx] Basic Def:%04x Inst:%#04x"
191+ " %c%c%c%c AS:%d ASN:%#04x IA:%#018llx\n"
192+ "\t\tCL:%d HPP:%#018llx GPP:%#018llx\n",
193+ pos, basic->def, basic->U,
194+ basic->T ? 'T' : ' ',
195+ basic->W ? 'W' : ' ',
196+ basic->P ? 'P' : ' ',
197+ basic->I ? 'I' : ' ',
198+ basic->AS, basic->prim_asn, basic->ia, basic->CL,
199+ basic->hpp, basic->gpp);
200+ return true;
201+}
202+
203+/* Display s390 CPU measurement facility diagnostic-sampling data entry */
204+static bool s390_cpumsf_diag_show(const char *color, size_t pos,
205+ struct hws_diag_entry *diag)
206+{
207+ if (diag->def < S390_CPUMSF_DIAG_DEF_FIRST) {
208+ pr_err("Invalid AUX trace diagnostic entry [%#08zx]\n", pos);
209+ return false;
210+ }
211+ color_fprintf(stdout, color, " [%#08zx] Diag Def:%04x %c\n",
212+ pos, diag->def, diag->I ? 'I' : ' ');
213+ return true;
214+}
215+
216+/* Return TOD timestamp contained in an trailer entry */
217+static unsigned long long trailer_timestamp(struct hws_trailer_entry *te)
218+{
219+ /* te->t set: TOD in STCKE format, bytes 8-15
220+ * to->t not set: TOD in STCK format, bytes 0-7
221+ */
222+ unsigned long long ts;
223+
224+ memcpy(&ts, &te->timestamp[te->t], sizeof(ts));
225+ return ts;
226+}
227+
228+/* Display s390 CPU measurement facility trailer entry */
229+static bool s390_cpumsf_trailer_show(const char *color, size_t pos,
230+ struct hws_trailer_entry *te)
231+{
232+ if (te->bsdes != sizeof(struct hws_basic_entry)) {
233+ pr_err("Invalid AUX trace trailer entry [%#08zx]\n", pos);
234+ return false;
235+ }
236+ color_fprintf(stdout, color, " [%#08zx] Trailer %c%c%c bsdes:%d"
237+ " dsdes:%d Overflow:%lld Time:%#llx\n"
238+ "\t\tC:%d TOD:%#lx 1:%#llx 2:%#llx\n",
239+ pos,
240+ te->f ? 'F' : ' ',
241+ te->a ? 'A' : ' ',
242+ te->t ? 'T' : ' ',
243+ te->bsdes, te->dsdes, te->overflow,
244+ trailer_timestamp(te), te->clock_base, te->progusage2,
245+ te->progusage[0], te->progusage[1]);
246+ return true;
247+}
248+
249+/* Test a sample data block. It must be 4KB or a multiple thereof in size and
250+ * 4KB page aligned. Each sample data page has a trailer entry at the
251+ * end which contains the sample entry data sizes.
252+ *
253+ * Return true if the sample data block passes the checks and set the
254+ * basic set entry size and diagnostic set entry size.
255+ *
256+ * Return false on failure.
257+ *
258+ * Note: Old hardware does not set the basic or diagnostic entry sizes
259+ * in the trailer entry. Use the type number instead.
260+ */
261+static bool s390_cpumsf_validate(int machine_type,
262+ unsigned char *buf, size_t len,
263+ unsigned short *bsdes,
264+ unsigned short *dsdes)
265+{
266+ struct hws_basic_entry *basic = (struct hws_basic_entry *)buf;
267+ struct hws_trailer_entry *te;
268+
269+ *dsdes = *bsdes = 0;
270+ if (len & (S390_CPUMSF_PAGESZ - 1)) /* Illegal size */
271+ return false;
272+ if (basic->def != 1) /* No basic set entry, must be first */
273+ return false;
274+ /* Check for trailer entry at end of SDB */
275+ te = (struct hws_trailer_entry *)(buf + S390_CPUMSF_PAGESZ
276+ - sizeof(*te));
277+ *bsdes = te->bsdes;
278+ *dsdes = te->dsdes;
279+ if (!te->bsdes && !te->dsdes) {
280+ /* Very old hardware, use CPUID */
281+ switch (machine_type) {
282+ case 2097:
283+ case 2098:
284+ *dsdes = 64;
285+ *bsdes = 32;
286+ break;
287+ case 2817:
288+ case 2818:
289+ *dsdes = 74;
290+ *bsdes = 32;
291+ break;
292+ case 2827:
293+ case 2828:
294+ *dsdes = 85;
295+ *bsdes = 32;
296+ break;
297+ default:
298+ /* Illegal trailer entry */
299+ return false;
300+ }
301+ }
302+ return true;
303+}
304+
305+/* Return true if there is room for another entry */
306+static bool s390_cpumsf_reached_trailer(size_t entry_sz, size_t pos)
307+{
308+ size_t payload = S390_CPUMSF_PAGESZ - sizeof(struct hws_trailer_entry);
309+
310+ if (payload - (pos & (S390_CPUMSF_PAGESZ - 1)) < entry_sz)
311+ return false;
312+ return true;
313+}
314+
315+/* Dump an auxiliary buffer. These buffers are multiple of
316+ * 4KB SDB pages.
317+ */
318+static void s390_cpumsf_dump(struct s390_cpumsf *sf,
319+ unsigned char *buf, size_t len)
320+{
321+ const char *color = PERF_COLOR_BLUE;
322+ struct hws_basic_entry *basic;
323+ struct hws_diag_entry *diag;
324+ unsigned short bsdes, dsdes;
325+ size_t pos = 0;
326+
327+ color_fprintf(stdout, color,
328+ ". ... s390 AUX data: size %zu bytes\n",
329+ len);
330+
331+ if (!s390_cpumsf_validate(sf->machine_type, buf, len, &bsdes,
332+ &dsdes)) {
333+ pr_err("Invalid AUX trace data block size:%zu"
334+ " (type:%d bsdes:%hd dsdes:%hd)\n",
335+ len, sf->machine_type, bsdes, dsdes);
336+ return;
337+ }
338+
339+ /* s390 kernel always returns 4KB blocks fully occupied,
340+ * no partially filled SDBs.
341+ */
342+ while (pos < len) {
343+ /* Handle Basic entry */
344+ basic = (struct hws_basic_entry *)(buf + pos);
345+ if (s390_cpumsf_basic_show(color, pos, basic))
346+ pos += bsdes;
347+ else
348+ return;
349+
350+ /* Handle Diagnostic entry */
351+ diag = (struct hws_diag_entry *)(buf + pos);
352+ if (s390_cpumsf_diag_show(color, pos, diag))
353+ pos += dsdes;
354+ else
355+ return;
356+
357+ /* Check for trailer entry */
358+ if (!s390_cpumsf_reached_trailer(bsdes + dsdes, pos)) {
359+ /* Show trailer entry */
360+ struct hws_trailer_entry te;
361+
362+ pos = (pos + S390_CPUMSF_PAGESZ)
363+ & ~(S390_CPUMSF_PAGESZ - 1);
364+ pos -= sizeof(te);
365+ memcpy(&te, buf + pos, sizeof(te));
366+ /* Set descriptor sizes in case of old hardware
367+ * where these values are not set.
368+ */
369+ te.bsdes = bsdes;
370+ te.dsdes = dsdes;
371+ if (s390_cpumsf_trailer_show(color, pos, &te))
372+ pos += sizeof(te);
373+ else
374+ return;
375+ }
376+ }
377+}
378+
379+static void s390_cpumsf_dump_event(struct s390_cpumsf *sf, unsigned char *buf,
380+ size_t len)
381+{
382+ printf(".\n");
383+ s390_cpumsf_dump(sf, buf, len);
384+}
385+
386+#define S390_LPP_PID_MASK 0xffffffff
387+
388+static bool s390_cpumsf_make_event(size_t pos,
389+ struct hws_basic_entry *basic,
390+ struct s390_cpumsf_queue *sfq)
391+{
392+ struct perf_sample sample = {
393+ .ip = basic->ia,
394+ .pid = basic->hpp & S390_LPP_PID_MASK,
395+ .tid = basic->hpp & S390_LPP_PID_MASK,
396+ .cpumode = PERF_RECORD_MISC_CPUMODE_UNKNOWN,
397+ .cpu = sfq->cpu,
398+ .period = 1
399+ };
400+ union perf_event event;
401+
402+ memset(&event, 0, sizeof(event));
403+ if (basic->CL == 1) /* Native LPAR mode */
404+ sample.cpumode = basic->P ? PERF_RECORD_MISC_USER
405+ : PERF_RECORD_MISC_KERNEL;
406+ else if (basic->CL == 2) /* Guest kernel/user space */
407+ sample.cpumode = basic->P ? PERF_RECORD_MISC_GUEST_USER
408+ : PERF_RECORD_MISC_GUEST_KERNEL;
409+ else if (basic->gpp || basic->prim_asn != 0xffff)
410+ /* Use heuristics on old hardware */
411+ sample.cpumode = basic->P ? PERF_RECORD_MISC_GUEST_USER
412+ : PERF_RECORD_MISC_GUEST_KERNEL;
413+ else
414+ sample.cpumode = basic->P ? PERF_RECORD_MISC_USER
415+ : PERF_RECORD_MISC_KERNEL;
416+
417+ event.sample.header.type = PERF_RECORD_SAMPLE;
418+ event.sample.header.misc = sample.cpumode;
419+ event.sample.header.size = sizeof(struct perf_event_header);
420+
421+ pr_debug4("%s pos:%#zx ip:%#" PRIx64 " P:%d CL:%d pid:%d.%d cpumode:%d cpu:%d\n",
422+ __func__, pos, sample.ip, basic->P, basic->CL, sample.pid,
423+ sample.tid, sample.cpumode, sample.cpu);
424+ if (perf_session__deliver_synth_event(sfq->sf->session, &event,
425+ &sample)) {
426+ pr_err("s390 Auxiliary Trace: failed to deliver event\n");
427+ return false;
428+ }
429+ return true;
430+}
431+
432+static unsigned long long get_trailer_time(const unsigned char *buf)
433+{
434+ struct hws_trailer_entry *te;
435+ unsigned long long aux_time;
436+
437+ te = (struct hws_trailer_entry *)(buf + S390_CPUMSF_PAGESZ
438+ - sizeof(*te));
439+
440+ if (!te->clock_base) /* TOD_CLOCK_BASE value missing */
441+ return 0;
442+
443+ /* Correct calculation to convert time stamp in trailer entry to
444+ * nano seconds (taken from arch/s390 function tod_to_ns()).
445+ * TOD_CLOCK_BASE is stored in trailer entry member progusage2.
446+ */
447+ aux_time = trailer_timestamp(te) - te->progusage2;
448+ aux_time = (aux_time >> 9) * 125 + (((aux_time & 0x1ff) * 125) >> 9);
449+ return aux_time;
450+}
451+
452+/* Process the data samples of a single queue. The first parameter is a
453+ * pointer to the queue, the second parameter is the time stamp. This
454+ * is the time stamp:
455+ * - of the event that triggered this processing.
456+ * - or the time stamp when the last proccesing of this queue stopped.
457+ * In this case it stopped at a 4KB page boundary and record the
458+ * position on where to continue processing on the next invocation
459+ * (see buffer->use_data and buffer->use_size).
460+ *
461+ * When this function returns the second parameter is updated to
462+ * reflect the time stamp of the last processed auxiliary data entry
463+ * (taken from the trailer entry of that page). The caller uses this
464+ * returned time stamp to record the last processed entry in this
465+ * queue.
466+ *
467+ * The function returns:
468+ * 0: Processing successful. The second parameter returns the
469+ * time stamp from the trailer entry until which position
470+ * processing took place. Subsequent calls resume from this
471+ * position.
472+ * <0: An error occurred during processing. The second parameter
473+ * returns the maximum time stamp.
474+ * >0: Done on this queue. The second parameter returns the
475+ * maximum time stamp.
476+ */
477+static int s390_cpumsf_samples(struct s390_cpumsf_queue *sfq, u64 *ts)
478+{
479+ struct s390_cpumsf *sf = sfq->sf;
480+ unsigned char *buf = sfq->buffer->use_data;
481+ size_t len = sfq->buffer->use_size;
482+ struct hws_basic_entry *basic;
483+ unsigned short bsdes, dsdes;
484+ size_t pos = 0;
485+ int err = 1;
486+ u64 aux_ts;
487+
488+ if (!s390_cpumsf_validate(sf->machine_type, buf, len, &bsdes,
489+ &dsdes)) {
490+ *ts = ~0ULL;
491+ return -1;
492+ }
493+
494+ /* Get trailer entry time stamp and check if entries in
495+ * this auxiliary page are ready for processing. If the
496+ * time stamp of the first entry is too high, whole buffer
497+ * can be skipped. In this case return time stamp.
498+ */
499+ aux_ts = get_trailer_time(buf);
500+ if (!aux_ts) {
501+ pr_err("[%#08" PRIx64 "] Invalid AUX trailer entry TOD clock base\n",
502+ sfq->buffer->data_offset);
503+ aux_ts = ~0ULL;
504+ goto out;
505+ }
506+ if (aux_ts > *ts) {
507+ *ts = aux_ts;
508+ return 0;
509+ }
510+
511+ while (pos < len) {
512+ /* Handle Basic entry */
513+ basic = (struct hws_basic_entry *)(buf + pos);
514+ if (s390_cpumsf_make_event(pos, basic, sfq))
515+ pos += bsdes;
516+ else {
517+ err = -EBADF;
518+ goto out;
519+ }
520+
521+ pos += dsdes; /* Skip diagnositic entry */
522+
523+ /* Check for trailer entry */
524+ if (!s390_cpumsf_reached_trailer(bsdes + dsdes, pos)) {
525+ pos = (pos + S390_CPUMSF_PAGESZ)
526+ & ~(S390_CPUMSF_PAGESZ - 1);
527+ /* Check existence of next page */
528+ if (pos >= len)
529+ break;
530+ aux_ts = get_trailer_time(buf + pos);
531+ if (!aux_ts) {
532+ aux_ts = ~0ULL;
533+ goto out;
534+ }
535+ if (aux_ts > *ts) {
536+ *ts = aux_ts;
537+ sfq->buffer->use_data += pos;
538+ sfq->buffer->use_size -= pos;
539+ return 0;
540+ }
541+ }
542+ }
543+out:
544+ *ts = aux_ts;
545+ sfq->buffer->use_size = 0;
546+ sfq->buffer->use_data = NULL;
547+ return err; /* Buffer completely scanned or error */
548+}
549+
550+/* Run the s390 auxiliary trace decoder.
551+ * Select the queue buffer to operate on, the caller already selected
552+ * the proper queue, depending on second parameter 'ts'.
553+ * This is the time stamp until which the auxiliary entries should
554+ * be processed. This value is updated by called functions and
555+ * returned to the caller.
556+ *
557+ * Resume processing in the current buffer. If there is no buffer
558+ * get a new buffer from the queue and setup start position for
559+ * processing.
560+ * When a buffer is completely processed remove it from the queue
561+ * before returning.
562+ *
563+ * This function returns
564+ * 1: When the queue is empty. Second parameter will be set to
565+ * maximum time stamp.
566+ * 0: Normal processing done.
567+ * <0: Error during queue buffer setup. This causes the caller
568+ * to stop processing completely.
569+ */
570+static int s390_cpumsf_run_decoder(struct s390_cpumsf_queue *sfq,
571+ u64 *ts)
572+{
573+
574+ struct auxtrace_buffer *buffer;
575+ struct auxtrace_queue *queue;
576+ int err;
577+
578+ queue = &sfq->sf->queues.queue_array[sfq->queue_nr];
579+
580+ /* Get buffer and last position in buffer to resume
581+ * decoding the auxiliary entries. One buffer might be large
582+ * and decoding might stop in between. This depends on the time
583+ * stamp of the trailer entry in each page of the auxiliary
584+ * data and the time stamp of the event triggering the decoding.
585+ */
586+ if (sfq->buffer == NULL) {
587+ sfq->buffer = buffer = auxtrace_buffer__next(queue,
588+ sfq->buffer);
589+ if (!buffer) {
590+ *ts = ~0ULL;
591+ return 1; /* Processing done on this queue */
592+ }
593+ /* Start with a new buffer on this queue */
594+ if (buffer->data) {
595+ buffer->use_size = buffer->size;
596+ buffer->use_data = buffer->data;
597+ }
598+ } else
599+ buffer = sfq->buffer;
600+
601+ if (!buffer->data) {
602+ int fd = perf_data__fd(sfq->sf->session->data);
603+
604+ buffer->data = auxtrace_buffer__get_data(buffer, fd);
605+ if (!buffer->data)
606+ return -ENOMEM;
607+ buffer->use_size = buffer->size;
608+ buffer->use_data = buffer->data;
609+ }
610+ pr_debug4("%s queue_nr:%d buffer:%" PRId64 " offset:%#" PRIx64 " size:%#zx rest:%#zx\n",
611+ __func__, sfq->queue_nr, buffer->buffer_nr, buffer->offset,
612+ buffer->size, buffer->use_size);
613+ err = s390_cpumsf_samples(sfq, ts);
614+
615+ /* If non-zero, there is either an error (err < 0) or the buffer is
616+ * completely done (err > 0). The error is unrecoverable, usually
617+ * some descriptors could not be read successfully, so continue with
618+ * the next buffer.
619+ * In both cases the parameter 'ts' has been updated.
620+ */
621+ if (err) {
622+ sfq->buffer = NULL;
623+ list_del(&buffer->list);
624+ auxtrace_buffer__free(buffer);
625+ if (err > 0) /* Buffer done, no error */
626+ err = 0;
627+ }
628+ return err;
629+}
630+
631+static struct s390_cpumsf_queue *
632+s390_cpumsf_alloc_queue(struct s390_cpumsf *sf, unsigned int queue_nr)
633+{
634+ struct s390_cpumsf_queue *sfq;
635+
636+ sfq = zalloc(sizeof(struct s390_cpumsf_queue));
637+ if (sfq == NULL)
638+ return NULL;
639+
640+ sfq->sf = sf;
641+ sfq->queue_nr = queue_nr;
642+ sfq->cpu = -1;
643+ return sfq;
644+}
645+
646+static int s390_cpumsf_setup_queue(struct s390_cpumsf *sf,
647+ struct auxtrace_queue *queue,
648+ unsigned int queue_nr, u64 ts)
649+{
650+ struct s390_cpumsf_queue *sfq = queue->priv;
651+
652+ if (list_empty(&queue->head))
653+ return 0;
654+
655+ if (sfq == NULL) {
656+ sfq = s390_cpumsf_alloc_queue(sf, queue_nr);
657+ if (!sfq)
658+ return -ENOMEM;
659+ queue->priv = sfq;
660+
661+ if (queue->cpu != -1)
662+ sfq->cpu = queue->cpu;
663+ }
664+ return auxtrace_heap__add(&sf->heap, queue_nr, ts);
665+}
666+
667+static int s390_cpumsf_setup_queues(struct s390_cpumsf *sf, u64 ts)
668+{
669+ unsigned int i;
670+ int ret = 0;
671+
672+ for (i = 0; i < sf->queues.nr_queues; i++) {
673+ ret = s390_cpumsf_setup_queue(sf, &sf->queues.queue_array[i],
674+ i, ts);
675+ if (ret)
676+ break;
677+ }
678+ return ret;
679+}
680+
681+static int s390_cpumsf_update_queues(struct s390_cpumsf *sf, u64 ts)
682+{
683+ if (!sf->queues.new_data)
684+ return 0;
685+
686+ sf->queues.new_data = false;
687+ return s390_cpumsf_setup_queues(sf, ts);
688+}
689+
690+static int s390_cpumsf_process_queues(struct s390_cpumsf *sf, u64 timestamp)
691+{
692+ unsigned int queue_nr;
693+ u64 ts;
694+ int ret;
695+
696+ while (1) {
697+ struct auxtrace_queue *queue;
698+ struct s390_cpumsf_queue *sfq;
699+
700+ if (!sf->heap.heap_cnt)
701+ return 0;
702+
703+ if (sf->heap.heap_array[0].ordinal >= timestamp)
704+ return 0;
705+
706+ queue_nr = sf->heap.heap_array[0].queue_nr;
707+ queue = &sf->queues.queue_array[queue_nr];
708+ sfq = queue->priv;
709+
710+ auxtrace_heap__pop(&sf->heap);
711+ if (sf->heap.heap_cnt) {
712+ ts = sf->heap.heap_array[0].ordinal + 1;
713+ if (ts > timestamp)
714+ ts = timestamp;
715+ } else {
716+ ts = timestamp;
717+ }
718+
719+ ret = s390_cpumsf_run_decoder(sfq, &ts);
720+ if (ret < 0) {
721+ auxtrace_heap__add(&sf->heap, queue_nr, ts);
722+ return ret;
723+ }
724+ if (!ret) {
725+ ret = auxtrace_heap__add(&sf->heap, queue_nr, ts);
726+ if (ret < 0)
727+ return ret;
728+ }
729+ }
730+ return 0;
731+}
732+
733+static int s390_cpumsf_synth_error(struct s390_cpumsf *sf, int code, int cpu,
734+ pid_t pid, pid_t tid, u64 ip)
735+{
736+ char msg[MAX_AUXTRACE_ERROR_MSG];
737+ union perf_event event;
738+ int err;
739+
740+ strncpy(msg, "Lost Auxiliary Trace Buffer", sizeof(msg) - 1);
741+ auxtrace_synth_error(&event.auxtrace_error, PERF_AUXTRACE_ERROR_ITRACE,
742+ code, cpu, pid, tid, ip, msg);
743+
744+ err = perf_session__deliver_synth_event(sf->session, &event, NULL);
745+ if (err)
746+ pr_err("s390 Auxiliary Trace: failed to deliver error event,"
747+ "error %d\n", err);
748+ return err;
749+}
750+
751+static int s390_cpumsf_lost(struct s390_cpumsf *sf, struct perf_sample *sample)
752+{
753+ return s390_cpumsf_synth_error(sf, 1, sample->cpu,
754+ sample->pid, sample->tid, 0);
755+}
756+
757+static int
758+s390_cpumsf_process_event(struct perf_session *session __maybe_unused,
759+ union perf_event *event,
760+ struct perf_sample *sample,
761+ struct perf_tool *tool)
762+{
763+ struct s390_cpumsf *sf = container_of(session->auxtrace,
764+ struct s390_cpumsf,
765+ auxtrace);
766+ u64 timestamp = sample->time;
767+ int err = 0;
768+
769+ if (dump_trace)
770+ return 0;
771+
772+ if (!tool->ordered_events) {
773+ pr_err("s390 Auxiliary Trace requires ordered events\n");
774+ return -EINVAL;
775+ }
776+
777+ if (event->header.type == PERF_RECORD_AUX &&
778+ event->aux.flags & PERF_AUX_FLAG_TRUNCATED)
779+ return s390_cpumsf_lost(sf, sample);
780+
781+ if (timestamp) {
782+ err = s390_cpumsf_update_queues(sf, timestamp);
783+ if (!err)
784+ err = s390_cpumsf_process_queues(sf, timestamp);
785+ }
786+ return err;
787+}
788+
789+struct s390_cpumsf_synth {
790+ struct perf_tool cpumsf_tool;
791+ struct perf_session *session;
792+};
793+
794+static int
795+s390_cpumsf_process_auxtrace_event(struct perf_session *session,
796+ union perf_event *event __maybe_unused,
797+ struct perf_tool *tool __maybe_unused)
798+{
799+ struct s390_cpumsf *sf = container_of(session->auxtrace,
800+ struct s390_cpumsf,
801+ auxtrace);
802+
803+ int fd = perf_data__fd(session->data);
804+ struct auxtrace_buffer *buffer;
805+ off_t data_offset;
806+ int err;
807+
808+ if (sf->data_queued)
809+ return 0;
810+
811+ if (perf_data__is_pipe(session->data)) {
812+ data_offset = 0;
813+ } else {
814+ data_offset = lseek(fd, 0, SEEK_CUR);
815+ if (data_offset == -1)
816+ return -errno;
817+ }
818+
819+ err = auxtrace_queues__add_event(&sf->queues, session, event,
820+ data_offset, &buffer);
821+ if (err)
822+ return err;
823+
824+ /* Dump here after copying piped trace out of the pipe */
825+ if (dump_trace) {
826+ if (auxtrace_buffer__get_data(buffer, fd)) {
827+ s390_cpumsf_dump_event(sf, buffer->data,
828+ buffer->size);
829+ auxtrace_buffer__put_data(buffer);
830+ }
831+ }
832+ return 0;
833+}
834+
835+static void s390_cpumsf_free_events(struct perf_session *session __maybe_unused)
836+{
837+}
838+
839+static int s390_cpumsf_flush(struct perf_session *session __maybe_unused,
840+ struct perf_tool *tool __maybe_unused)
841+{
842+ return 0;
843+}
844+
845+static void s390_cpumsf_free_queues(struct perf_session *session)
846+{
847+ struct s390_cpumsf *sf = container_of(session->auxtrace,
848+ struct s390_cpumsf,
849+ auxtrace);
850+ struct auxtrace_queues *queues = &sf->queues;
851+ unsigned int i;
852+
853+ for (i = 0; i < queues->nr_queues; i++)
854+ zfree(&queues->queue_array[i].priv);
855+ auxtrace_queues__free(queues);
856+}
857+
858+static void s390_cpumsf_free(struct perf_session *session)
859+{
860+ struct s390_cpumsf *sf = container_of(session->auxtrace,
861+ struct s390_cpumsf,
862+ auxtrace);
863+
864+ auxtrace_heap__free(&sf->heap);
865+ s390_cpumsf_free_queues(session);
866+ session->auxtrace = NULL;
867+ free(sf);
868+}
869+
870+static int s390_cpumsf_get_type(const char *cpuid)
871+{
872+ int ret, family = 0;
873+
874+ ret = sscanf(cpuid, "%*[^,],%u", &family);
875+ return (ret == 1) ? family : 0;
876+}
877+
878+/* Check itrace options set on perf report command.
879+ * Return true, if none are set or all options specified can be
880+ * handled on s390.
881+ * Return false otherwise.
882+ */
883+static bool check_auxtrace_itrace(struct itrace_synth_opts *itops)
884+{
885+ if (!itops || !itops->set)
886+ return true;
887+ pr_err("No --itrace options supported\n");
888+ return false;
889+}
890+
891+int s390_cpumsf_process_auxtrace_info(union perf_event *event,
892+ struct perf_session *session)
893+{
894+ struct auxtrace_info_event *auxtrace_info = &event->auxtrace_info;
895+ struct s390_cpumsf *sf;
896+ int err;
897+
898+ if (auxtrace_info->header.size < sizeof(struct auxtrace_info_event))
899+ return -EINVAL;
900+
901+ sf = zalloc(sizeof(struct s390_cpumsf));
902+ if (sf == NULL)
903+ return -ENOMEM;
904+
905+ if (!check_auxtrace_itrace(session->itrace_synth_opts)) {
906+ err = -EINVAL;
907+ goto err_free;
908+ }
909+
910+ err = auxtrace_queues__init(&sf->queues);
911+ if (err)
912+ goto err_free;
913+
914+ sf->session = session;
915+ sf->machine = &session->machines.host; /* No kvm support */
916+ sf->auxtrace_type = auxtrace_info->type;
917+ sf->pmu_type = PERF_TYPE_RAW;
918+ sf->machine_type = s390_cpumsf_get_type(session->evlist->env->cpuid);
919+
920+ sf->auxtrace.process_event = s390_cpumsf_process_event;
921+ sf->auxtrace.process_auxtrace_event = s390_cpumsf_process_auxtrace_event;
922+ sf->auxtrace.flush_events = s390_cpumsf_flush;
923+ sf->auxtrace.free_events = s390_cpumsf_free_events;
924+ sf->auxtrace.free = s390_cpumsf_free;
925+ session->auxtrace = &sf->auxtrace;
926+
927+ if (dump_trace)
928+ return 0;
929+
930+ err = auxtrace_queues__process_index(&sf->queues, session);
931+ if (err)
932+ goto err_free_queues;
933+
934+ if (sf->queues.populated)
935+ sf->data_queued = true;
936+
937+ return 0;
938+
939+err_free_queues:
940+ auxtrace_queues__free(&sf->queues);
941+ session->auxtrace = NULL;
942+err_free:
943+ free(sf);
944+ return err;
945+}
tools/perf/util/s390-cpumsf.h+21−0
@@ -0,0 +1,21 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
2+/*
3+ * Copyright IBM Corp. 2018
4+ * Auxtrace support for s390 CPU-Measurement Sampling Facility
5+ *
6+ * Author(s): Thomas Richter <tmricht@linux.ibm.com>
7+ */
8+
9+#ifndef INCLUDE__PERF_S390_CPUMSF_H
10+#define INCLUDE__PERF_S390_CPUMSF_H
11+
12+union perf_event;
13+struct perf_session;
14+struct perf_pmu;
15+
16+struct auxtrace_record *
17+s390_cpumsf_recording_init(int *err, struct perf_pmu *s390_cpumsf_pmu);
18+
19+int s390_cpumsf_process_auxtrace_info(union perf_event *event,
20+ struct perf_session *session);
21+#endif
tools/perf/util/scripting-engines/trace-event-perl.c+1−1
@@ -535,7 +535,7 @@ static int perl_stop_script(void) · 534 unmodified lines
535535 return 0;
536536 }
537537
538−static int perl_generate_script(struct pevent *pevent, const char *outfile)
538+static int perl_generate_script(struct tep_handle *pevent, const char *outfile)
539539 {
540540 struct event_format *event = NULL;
541541 struct format_field *f;
tools/perf/util/scripting-engines/trace-event-python.c+3−3
@@ -871,8 +871,8 @@ static void python_process_tracepoint(struct perf_sample *sample, · 870 unmodified lines
871871 offset = field->offset;
872872 len = field->size;
873873 if (field->flags & FIELD_IS_DYNAMIC) {
874− val = pevent_read_number(scripting_context->pevent,
875− data + offset, len);
874+ val = tep_read_number(scripting_context->pevent,
875+ data + offset, len);
876876 offset = val;
877877 len = offset >> 16;
878878 offset &= 0xffff;
@@ -1588,7 +1588,7 @@ static int python_stop_script(void) · 709 unmodified lines
15881588 return 0;
15891589 }
15901590
1591−static int python_generate_script(struct pevent *pevent, const char *outfile)
1591+static int python_generate_script(struct tep_handle *pevent, const char *outfile)
15921592 {
15931593 struct event_format *event = NULL;
15941594 struct format_field *f;
tools/perf/util/setup.py+9−1
@@ -1,12 +1,20 @@
11 #!/usr/bin/python
22
33 from os import getenv
4+from subprocess import Popen, PIPE
5+from re import sub
6+
7+def clang_has_option(option):
8+ return [o for o in Popen(['clang', option], stderr=PIPE).stderr.readlines() if "unknown argument" in o] == [ ]
49
510 cc = getenv("CC")
611 if cc == "clang":
712 from _sysconfigdata import build_time_vars
8− from re import sub
913 build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", build_time_vars["CFLAGS"])
14+ if not clang_has_option("-mcet"):
15+ build_time_vars["CFLAGS"] = sub("-mcet", "", build_time_vars["CFLAGS"])
16+ if not clang_has_option("-fcf-protection"):
17+ build_time_vars["CFLAGS"] = sub("-fcf-protection", "", build_time_vars["CFLAGS"])
1018
1119 from distutils.core import setup, Extension
1220
tools/perf/util/sort.c+8−8
@@ -601,7 +601,7 @@ static char *get_trace_output(struct hist_entry *he) · 600 unmodified lines
601601 {
602602 struct trace_seq seq;
603603 struct perf_evsel *evsel;
604− struct pevent_record rec = {
604+ struct tep_record rec = {
605605 .data = he->raw_data,
606606 .size = he->raw_size,
607607 };
@@ -610,10 +610,10 @@ static char *get_trace_output(struct hist_entry *he) · 2 unmodified lines
610610
611611 trace_seq_init(&seq);
612612 if (symbol_conf.raw_trace) {
613− pevent_print_fields(&seq, he->raw_data, he->raw_size,
614− evsel->tp_format);
613+ tep_print_fields(&seq, he->raw_data, he->raw_size,
614+ evsel->tp_format);
615615 } else {
616− pevent_event_info(&seq, evsel->tp_format, &rec);
616+ tep_event_info(&seq, evsel->tp_format, &rec);
617617 }
618618 /*
619619 * Trim the buffer, it starts at 4KB and we're not going to
@@ -2047,7 +2047,7 @@ static int __sort__hde_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, · 1427 unmodified lines
20472047 struct trace_seq seq;
20482048 raw_field:
20492049 trace_seq_init(&seq);
2050− pevent_print_field(&seq, he->raw_data, hde->field);
2050+ tep_print_field(&seq, he->raw_data, hde->field);
20512051 str = seq.buffer;
20522052 }
20532053
@@ -2074,7 +2074,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, · 20 unmodified lines
20742074 if (field->flags & FIELD_IS_DYNAMIC) {
20752075 unsigned long long dyn;
20762076
2077− pevent_read_number_field(field, a->raw_data, &dyn);
2077+ tep_read_number_field(field, a->raw_data, &dyn);
20782078 offset = dyn & 0xffff;
20792079 size = (dyn >> 16) & 0xffff;
20802080
@@ -2311,7 +2311,7 @@ static int add_all_matching_fields(struct perf_evlist *evlist, · 230 unmodified lines
23112311 if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
23122312 continue;
23132313
2314− field = pevent_find_any_field(evsel->tp_format, field_name);
2314+ field = tep_find_any_field(evsel->tp_format, field_name);
23152315 if (field == NULL)
23162316 continue;
23172317
@@ -2378,7 +2378,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok, · 60 unmodified lines
23782378 if (!strcmp(field_name, "*")) {
23792379 ret = add_evsel_fields(evsel, raw_trace, level);
23802380 } else {
2381− field = pevent_find_any_field(evsel->tp_format, field_name);
2381+ field = tep_find_any_field(evsel->tp_format, field_name);
23822382 if (field == NULL) {
23832383 pr_debug("Cannot find event field for %s.%s\n",
23842384 event_name, field_name);
tools/perf/util/sort.h+1−1
@@ -276,7 +276,7 @@ extern struct sort_entry sort_thread; · 275 unmodified lines
276276 extern struct list_head hist_entry__sort_list;
277277
278278 struct perf_evlist;
279−struct pevent;
279+struct tep_handle;
280280 int setup_sorting(struct perf_evlist *evlist);
281281 int setup_output_field(void);
282282 void reset_output_field(void);
tools/perf/util/trace-event-parse.c+17−17
@@ -32,7 +32,7 @@ · 31 unmodified lines
3232 static int get_common_field(struct scripting_context *context,
3333 int *offset, int *size, const char *type)
3434 {
35− struct pevent *pevent = context->pevent;
35+ struct tep_handle *pevent = context->pevent;
3636 struct event_format *event;
3737 struct format_field *field;
3838
@@ -41,14 +41,14 @@ static int get_common_field(struct scripting_context *context, · 2 unmodified lines
4141 return 0;
4242
4343 event = pevent->events[0];
44− field = pevent_find_common_field(event, type);
44+ field = tep_find_common_field(event, type);
4545 if (!field)
4646 return 0;
4747 *offset = field->offset;
4848 *size = field->size;
4949 }
5050
51− return pevent_read_number(pevent, context->event_data + *offset, *size);
51+ return tep_read_number(pevent, context->event_data + *offset, *size);
5252 }
5353
5454 int common_lock_depth(struct scripting_context *context)
@@ -99,24 +99,24 @@ raw_field_value(struct event_format *event, const char *name, void *data) · 44 unmodified lines
9999 struct format_field *field;
100100 unsigned long long val;
101101
102− field = pevent_find_any_field(event, name);
102+ field = tep_find_any_field(event, name);
103103 if (!field)
104104 return 0ULL;
105105
106− pevent_read_number_field(field, data, &val);
106+ tep_read_number_field(field, data, &val);
107107
108108 return val;
109109 }
110110
111111 unsigned long long read_size(struct event_format *event, void *ptr, int size)
112112 {
113− return pevent_read_number(event->pevent, ptr, size);
113+ return tep_read_number(event->pevent, ptr, size);
114114 }
115115
116116 void event_format__fprintf(struct event_format *event,
117117 int cpu, void *data, int size, FILE *fp)
118118 {
119− struct pevent_record record;
119+ struct tep_record record;
120120 struct trace_seq s;
121121
122122 memset(&record, 0, sizeof(record));
@@ -125,7 +125,7 @@ void event_format__fprintf(struct event_format *event, · 2 unmodified lines
125125 record.data = data;
126126
127127 trace_seq_init(&s);
128− pevent_event_info(&s, event, &record);
128+ tep_event_info(&s, event, &record);
129129 trace_seq_do_fprintf(&s, fp);
130130 trace_seq_destroy(&s);
131131 }
@@ -136,7 +136,7 @@ void event_format__print(struct event_format *event, · 4 unmodified lines
136136 return event_format__fprintf(event, cpu, data, size, stdout);
137137 }
138138
139−void parse_ftrace_printk(struct pevent *pevent,
139+void parse_ftrace_printk(struct tep_handle *pevent,
140140 char *file, unsigned int size __maybe_unused)
141141 {
142142 unsigned long long addr;
@@ -157,11 +157,11 @@ void parse_ftrace_printk(struct pevent *pevent, · 14 unmodified lines
157157 /* fmt still has a space, skip it */
158158 printk = strdup(fmt+1);
159159 line = strtok_r(NULL, "\n", &next);
160− pevent_register_print_string(pevent, printk, addr);
160+ tep_register_print_string(pevent, printk, addr);
161161 }
162162 }
163163
164−void parse_saved_cmdline(struct pevent *pevent,
164+void parse_saved_cmdline(struct tep_handle *pevent,
165165 char *file, unsigned int size __maybe_unused)
166166 {
167167 char *comm;
@@ -172,24 +172,24 @@ void parse_saved_cmdline(struct pevent *pevent, · 4 unmodified lines
172172 line = strtok_r(file, "\n", &next);
173173 while (line) {
174174 sscanf(line, "%d %ms", &pid, &comm);
175− pevent_register_comm(pevent, comm, pid);
175+ tep_register_comm(pevent, comm, pid);
176176 free(comm);
177177 line = strtok_r(NULL, "\n", &next);
178178 }
179179 }
180180
181−int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size)
181+int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size)
182182 {
183− return pevent_parse_event(pevent, buf, size, "ftrace");
183+ return tep_parse_event(pevent, buf, size, "ftrace");
184184 }
185185
186−int parse_event_file(struct pevent *pevent,
186+int parse_event_file(struct tep_handle *pevent,
187187 char *buf, unsigned long size, char *sys)
188188 {
189− return pevent_parse_event(pevent, buf, size, sys);
189+ return tep_parse_event(pevent, buf, size, sys);
190190 }
191191
192−struct event_format *trace_find_next_event(struct pevent *pevent,
192+struct event_format *trace_find_next_event(struct tep_handle *pevent,
193193 struct event_format *event)
194194 {
195195 static int idx;
tools/perf/util/trace-event-read.c+22−22
@@ -96,7 +96,7 @@ static void skip(int size) · 95 unmodified lines
9696 };
9797 }
9898
99−static unsigned int read4(struct pevent *pevent)
99+static unsigned int read4(struct tep_handle *pevent)
100100 {
101101 unsigned int data;
102102
@@ -105,7 +105,7 @@ static unsigned int read4(struct pevent *pevent) · 2 unmodified lines
105105 return __data2host4(pevent, data);
106106 }
107107
108−static unsigned long long read8(struct pevent *pevent)
108+static unsigned long long read8(struct tep_handle *pevent)
109109 {
110110 unsigned long long data;
111111
@@ -158,7 +158,7 @@ out: · 46 unmodified lines
158158 return str;
159159 }
160160
161−static int read_proc_kallsyms(struct pevent *pevent)
161+static int read_proc_kallsyms(struct tep_handle *pevent)
162162 {
163163 unsigned int size;
164164
@@ -181,7 +181,7 @@ static int read_proc_kallsyms(struct pevent *pevent) · 16 unmodified lines
181181 return 0;
182182 }
183183
184−static int read_ftrace_printk(struct pevent *pevent)
184+static int read_ftrace_printk(struct tep_handle *pevent)
185185 {
186186 unsigned int size;
187187 char *buf;
@@ -208,7 +208,7 @@ static int read_ftrace_printk(struct pevent *pevent) · 20 unmodified lines
208208 return 0;
209209 }
210210
211−static int read_header_files(struct pevent *pevent)
211+static int read_header_files(struct tep_handle *pevent)
212212 {
213213 unsigned long long size;
214214 char *header_page;
@@ -235,13 +235,13 @@ static int read_header_files(struct pevent *pevent) · 20 unmodified lines
235235 return -1;
236236 }
237237
238− if (!pevent_parse_header_page(pevent, header_page, size,
239− pevent_get_long_size(pevent))) {
238+ if (!tep_parse_header_page(pevent, header_page, size,
239+ tep_get_long_size(pevent))) {
240240 /*
241241 * The commit field in the page is of type long,
242242 * use that instead, since it represents the kernel.
243243 */
244− pevent_set_long_size(pevent, pevent->header_page_size_size);
244+ tep_set_long_size(pevent, pevent->header_page_size_size);
245245 }
246246 free(header_page);
247247
@@ -259,7 +259,7 @@ static int read_header_files(struct pevent *pevent) · 11 unmodified lines
259259 return ret;
260260 }
261261
262−static int read_ftrace_file(struct pevent *pevent, unsigned long long size)
262+static int read_ftrace_file(struct tep_handle *pevent, unsigned long long size)
263263 {
264264 int ret;
265265 char *buf;
@@ -284,8 +284,8 @@ out: · 18 unmodified lines
284284 return ret;
285285 }
286286
287−static int read_event_file(struct pevent *pevent, char *sys,
288− unsigned long long size)
287+static int read_event_file(struct tep_handle *pevent, char *sys,
288+ unsigned long long size)
289289 {
290290 int ret;
291291 char *buf;
@@ -310,7 +310,7 @@ out: · 18 unmodified lines
310310 return ret;
311311 }
312312
313−static int read_ftrace_files(struct pevent *pevent)
313+static int read_ftrace_files(struct tep_handle *pevent)
314314 {
315315 unsigned long long size;
316316 int count;
@@ -328,7 +328,7 @@ static int read_ftrace_files(struct pevent *pevent) · 11 unmodified lines
328328 return 0;
329329 }
330330
331−static int read_event_files(struct pevent *pevent)
331+static int read_event_files(struct tep_handle *pevent)
332332 {
333333 unsigned long long size;
334334 char *sys;
@@ -356,7 +356,7 @@ static int read_event_files(struct pevent *pevent) · 21 unmodified lines
356356 return 0;
357357 }
358358
359−static int read_saved_cmdline(struct pevent *pevent)
359+static int read_saved_cmdline(struct tep_handle *pevent)
360360 {
361361 unsigned long long size;
362362 char *buf;
@@ -399,7 +399,7 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe) · 36 unmodified lines
399399 int host_bigendian;
400400 int file_long_size;
401401 int file_page_size;
402− struct pevent *pevent = NULL;
402+ struct tep_handle *pevent = NULL;
403403 int err;
404404
405405 repipe = __repipe;
@@ -439,9 +439,9 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe) · 33 unmodified lines
439439
440440 pevent = tevent->pevent;
441441
442− pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT);
443− pevent_set_file_bigendian(pevent, file_bigendian);
444− pevent_set_host_bigendian(pevent, host_bigendian);
442+ tep_set_flag(pevent, TEP_NSEC_OUTPUT);
443+ tep_set_file_bigendian(pevent, file_bigendian);
444+ tep_set_host_bigendian(pevent, host_bigendian);
445445
446446 if (do_read(buf, 1) < 0)
447447 goto out;
@@ -451,8 +451,8 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe) · 3 unmodified lines
451451 if (!file_page_size)
452452 goto out;
453453
454− pevent_set_long_size(pevent, file_long_size);
455− pevent_set_page_size(pevent, file_page_size);
454+ tep_set_long_size(pevent, file_long_size);
455+ tep_set_page_size(pevent, file_page_size);
456456
457457 err = read_header_files(pevent);
458458 if (err)
@@ -479,9 +479,9 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe) · 20 unmodified lines
479479 repipe = false;
480480
481481 if (show_funcs) {
482− pevent_print_funcs(pevent);
482+ tep_print_funcs(pevent);
483483 } else if (show_printk) {
484− pevent_print_printk(pevent);
484+ tep_print_printk(pevent);
485485 }
486486
487487 pevent = NULL;
tools/perf/util/trace-event-scripting.c+2−2
@@ -66,7 +66,7 @@ static int python_start_script_unsupported(const char *script __maybe_unused, · 65 unmodified lines
6666 return -1;
6767 }
6868
69−static int python_generate_script_unsupported(struct pevent *pevent
69+static int python_generate_script_unsupported(struct tep_handle *pevent
7070 __maybe_unused,
7171 const char *outfile
7272 __maybe_unused)
@@ -130,7 +130,7 @@ static int perl_start_script_unsupported(const char *script __maybe_unused, · 57 unmodified lines
130130 return -1;
131131 }
132132
133−static int perl_generate_script_unsupported(struct pevent *pevent
133+static int perl_generate_script_unsupported(struct tep_handle *pevent
134134 __maybe_unused,
135135 const char *outfile __maybe_unused)
136136 {
tools/perf/util/trace-event.c+14−14
@@ -28,10 +28,10 @@ static bool tevent_initialized; · 27 unmodified lines
2828
2929 int trace_event__init(struct trace_event *t)
3030 {
31− struct pevent *pevent = pevent_alloc();
31+ struct tep_handle *pevent = tep_alloc();
3232
3333 if (pevent) {
34− t->plugin_list = traceevent_load_plugins(pevent);
34+ t->plugin_list = tep_load_plugins(pevent);
3535 t->pevent = pevent;
3636 }
3737
@@ -40,33 +40,33 @@ int trace_event__init(struct trace_event *t) · 2 unmodified lines
4040
4141 static int trace_event__init2(void)
4242 {
43− int be = traceevent_host_bigendian();
44− struct pevent *pevent;
43+ int be = tep_host_bigendian();
44+ struct tep_handle *pevent;
4545
4646 if (trace_event__init(&tevent))
4747 return -1;
4848
4949 pevent = tevent.pevent;
50− pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT);
51− pevent_set_file_bigendian(pevent, be);
52− pevent_set_host_bigendian(pevent, be);
50+ tep_set_flag(pevent, TEP_NSEC_OUTPUT);
51+ tep_set_file_bigendian(pevent, be);
52+ tep_set_host_bigendian(pevent, be);
5353 tevent_initialized = true;
5454 return 0;
5555 }
5656
5757 int trace_event__register_resolver(struct machine *machine,
58− pevent_func_resolver_t *func)
58+ tep_func_resolver_t *func)
5959 {
6060 if (!tevent_initialized && trace_event__init2())
6161 return -1;
6262
63− return pevent_set_function_resolver(tevent.pevent, func, machine);
63+ return tep_set_function_resolver(tevent.pevent, func, machine);
6464 }
6565
6666 void trace_event__cleanup(struct trace_event *t)
6767 {
68− traceevent_unload_plugins(t->plugin_list, t->pevent);
69− pevent_free(t->pevent);
68+ tep_unload_plugins(t->plugin_list, t->pevent);
69+ tep_free(t->pevent);
7070 }
7171
7272 /*
@@ -76,7 +76,7 @@ static struct event_format* · 3 unmodified lines
7676 tp_format(const char *sys, const char *name)
7777 {
7878 char *tp_dir = get_events_file(sys);
79− struct pevent *pevent = tevent.pevent;
79+ struct tep_handle *pevent = tevent.pevent;
8080 struct event_format *event = NULL;
8181 char path[PATH_MAX];
8282 size_t size;
@@ -93,7 +93,7 @@ tp_format(const char *sys, const char *name) · 10 unmodified lines
9393 if (err)
9494 return ERR_PTR(err);
9595
96− pevent_parse_format(pevent, &event, data, size, sys);
96+ tep_parse_format(pevent, &event, data, size, sys);
9797
9898 free(data);
9999 return event;
@@ -116,5 +116,5 @@ struct event_format *trace_event__tp_format_id(int id) · 16 unmodified lines
116116 if (!tevent_initialized && trace_event__init2())
117117 return ERR_PTR(-ENOMEM);
118118
119− return pevent_find_event(tevent.pevent, id);
119+ return tep_find_event(tevent.pevent, id);
120120 }
tools/perf/util/trace-event.h+10−10
@@ -13,14 +13,14 @@ struct thread; · 12 unmodified lines
1313 struct plugin_list;
1414
1515 struct trace_event {
16− struct pevent *pevent;
16+ struct tep_handle *pevent;
1717 struct plugin_list *plugin_list;
1818 };
1919
2020 int trace_event__init(struct trace_event *t);
2121 void trace_event__cleanup(struct trace_event *t);
2222 int trace_event__register_resolver(struct machine *machine,
23− pevent_func_resolver_t *func);
23+ tep_func_resolver_t *func);
2424 struct event_format*
2525 trace_event__tp_format(const char *sys, const char *name);
2626
@@ -34,20 +34,20 @@ void event_format__fprintf(struct event_format *event, · 7 unmodified lines
3434 void event_format__print(struct event_format *event,
3535 int cpu, void *data, int size);
3636
37−int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size);
38−int parse_event_file(struct pevent *pevent,
37+int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size);
38+int parse_event_file(struct tep_handle *pevent,
3939 char *buf, unsigned long size, char *sys);
4040
4141 unsigned long long
4242 raw_field_value(struct event_format *event, const char *name, void *data);
4343
44−void parse_proc_kallsyms(struct pevent *pevent, char *file, unsigned int size);
45−void parse_ftrace_printk(struct pevent *pevent, char *file, unsigned int size);
46−void parse_saved_cmdline(struct pevent *pevent, char *file, unsigned int size);
44+void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size);
45+void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size);
46+void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int size);
4747
4848 ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe);
4949
50−struct event_format *trace_find_next_event(struct pevent *pevent,
50+struct event_format *trace_find_next_event(struct tep_handle *pevent,
5151 struct event_format *event);
5252 unsigned long long read_size(struct event_format *event, void *ptr, int size);
5353 unsigned long long eval_flag(const char *flag);
@@ -83,7 +83,7 @@ struct scripting_ops { · 29 unmodified lines
8383 void (*process_stat)(struct perf_stat_config *config,
8484 struct perf_evsel *evsel, u64 tstamp);
8585 void (*process_stat_interval)(u64 tstamp);
86− int (*generate_script) (struct pevent *pevent, const char *outfile);
86+ int (*generate_script) (struct tep_handle *pevent, const char *outfile);
8787 };
8888
8989 extern unsigned int scripting_max_stack;
@@ -94,7 +94,7 @@ void setup_perl_scripting(void); · 4 unmodified lines
9494 void setup_python_scripting(void);
9595
9696 struct scripting_context {
97− struct pevent *pevent;
97+ struct tep_handle *pevent;
9898 void *event_data;
9999 };
100100
tools/perf/util/zlib.c+18−0
@@ -5,6 +5,8 @@ · 4 unmodified lines
55 #include <sys/stat.h>
66 #include <sys/mman.h>
77 #include <zlib.h>
8+#include <linux/compiler.h>
9+#include <unistd.h>
810
911 #include "util/compress.h"
1012 #include "util/util.h"
@@ -79,3 +81,19 @@ out_close: · 68 unmodified lines
7981
8082 return ret == Z_STREAM_END ? 0 : -1;
8183 }
84+
85+bool gzip_is_compressed(const char *input)
86+{
87+ int fd = open(input, O_RDONLY);
88+ const uint8_t magic[2] = { 0x1f, 0x8b };
89+ char buf[2] = { 0 };
90+ ssize_t rc;
91+
92+ if (fd < 0)
93+ return -1;
94+
95+ rc = read(fd, buf, sizeof(buf));
96+ close(fd);
97+ return rc == sizeof(buf) ?
98+ memcmp(buf, magic, sizeof(buf)) == 0 : false;
99+}