aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2018-10-23 07:16:33 -0400
committerJiri Kosina <jkosina@suse.cz>2018-10-23 07:16:33 -0400
commit472475000979a156bc32cd75caa59737f5a1caa5 (patch)
tree6a98319244f7954237cf866c8862ffe3f6128d2d /tools
parent712fca63f50a87780ca6dc105370557a945a7ee8 (diff)
parent9d7b18668956c411a422d04c712994c5fdb23a4b (diff)
Merge branch 'for-4.20/apple' into for-linus
Support for Apple Magic Trackpad 2
Diffstat (limited to 'tools')
-rw-r--r--tools/arch/x86/include/asm/cpufeatures.h3
-rw-r--r--tools/arch/x86/lib/memcpy_64.S2
-rw-r--r--tools/bpf/bpftool/map.c1
-rw-r--r--tools/bpf/bpftool/map_perf_ring.c5
-rw-r--r--tools/include/linux/bitmap.h17
-rwxr-xr-xtools/kvm/kvm_stat/kvm_stat59
-rw-r--r--tools/lib/lockdep/Makefile4
-rw-r--r--tools/lib/traceevent/Makefile4
-rw-r--r--tools/lib/traceevent/event-parse.c712
-rw-r--r--tools/lib/traceevent/event-parse.h458
-rw-r--r--tools/lib/traceevent/event-plugin.c86
-rw-r--r--tools/lib/traceevent/event-utils.h16
-rw-r--r--tools/lib/traceevent/kbuffer-parse.c17
-rw-r--r--tools/lib/traceevent/parse-filter.c304
-rw-r--r--tools/lib/traceevent/parse-utils.c16
-rw-r--r--tools/lib/traceevent/plugin_cfg80211.c20
-rw-r--r--tools/lib/traceevent/plugin_function.c34
-rw-r--r--tools/lib/traceevent/plugin_hrtimer.c56
-rw-r--r--tools/lib/traceevent/plugin_jbd2.c36
-rw-r--r--tools/lib/traceevent/plugin_kmem.c66
-rw-r--r--tools/lib/traceevent/plugin_kvm.c154
-rw-r--r--tools/lib/traceevent/plugin_mac80211.c28
-rw-r--r--tools/lib/traceevent/plugin_sched_switch.c60
-rw-r--r--tools/lib/traceevent/plugin_scsi.c24
-rw-r--r--tools/lib/traceevent/plugin_xen.c20
-rw-r--r--tools/lib/traceevent/trace-seq.c16
-rw-r--r--tools/perf/Documentation/perf-annotate.txt9
-rw-r--r--tools/perf/Documentation/perf-report.txt9
-rw-r--r--tools/perf/Makefile4
-rw-r--r--tools/perf/arch/arm64/util/arm-spe.c1
-rw-r--r--tools/perf/arch/powerpc/util/sym-handling.c4
-rw-r--r--tools/perf/arch/s390/util/auxtrace.c1
-rw-r--r--tools/perf/arch/x86/Makefile3
-rw-r--r--tools/perf/builtin-annotate.c4
-rw-r--r--tools/perf/builtin-kmem.c6
-rw-r--r--tools/perf/builtin-report.c9
-rw-r--r--tools/perf/builtin-script.c6
-rw-r--r--tools/perf/builtin-trace.c191
-rwxr-xr-xtools/perf/check-headers.sh17
-rw-r--r--tools/perf/examples/bpf/augmented_syscalls.c55
-rw-r--r--tools/perf/examples/bpf/hello.c9
-rw-r--r--tools/perf/examples/bpf/sys_enter_openat.c33
-rw-r--r--tools/perf/include/bpf/bpf.h20
-rw-r--r--tools/perf/include/bpf/stdio.h19
-rw-r--r--tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json32
-rw-r--r--tools/perf/pmu-events/arch/arm64/mapfile.csv1
-rw-r--r--tools/perf/tests/bitmap.c2
-rw-r--r--tools/perf/tests/code-reading.c4
-rw-r--r--tools/perf/tests/kmod-path.c136
-rw-r--r--tools/perf/tests/mem2node.c2
-rw-r--r--tools/perf/ui/browsers/annotate.c76
-rw-r--r--tools/perf/util/Build1
-rw-r--r--tools/perf/util/annotate.c305
-rw-r--r--tools/perf/util/annotate.h54
-rw-r--r--tools/perf/util/auxtrace.c6
-rw-r--r--tools/perf/util/auxtrace.h1
-rw-r--r--tools/perf/util/bpf-loader.c48
-rw-r--r--tools/perf/util/bpf-loader.h23
-rw-r--r--tools/perf/util/compress.h2
-rw-r--r--tools/perf/util/data-convert-bt.c6
-rw-r--r--tools/perf/util/dso.c111
-rw-r--r--tools/perf/util/dso.h13
-rw-r--r--tools/perf/util/event.c13
-rw-r--r--tools/perf/util/evlist.c2
-rw-r--r--tools/perf/util/evsel.c2
-rw-r--r--tools/perf/util/evsel.h7
-rw-r--r--tools/perf/util/header.c9
-rw-r--r--tools/perf/util/llvm-utils.c31
-rw-r--r--tools/perf/util/llvm-utils.h9
-rw-r--r--tools/perf/util/lzma.c20
-rw-r--r--tools/perf/util/machine.c4
-rw-r--r--tools/perf/util/machine.h2
-rw-r--r--tools/perf/util/map.c44
-rw-r--r--tools/perf/util/map.h1
-rw-r--r--tools/perf/util/mmap.c3
-rw-r--r--tools/perf/util/mmap.h3
-rw-r--r--tools/perf/util/namespaces.c3
-rw-r--r--tools/perf/util/parse-events.c20
-rw-r--r--tools/perf/util/python.c30
-rw-r--r--tools/perf/util/s390-cpumsf-kernel.h71
-rw-r--r--tools/perf/util/s390-cpumsf.c945
-rw-r--r--tools/perf/util/s390-cpumsf.h21
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c2
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c6
-rw-r--r--tools/perf/util/setup.py10
-rw-r--r--tools/perf/util/sort.c16
-rw-r--r--tools/perf/util/sort.h2
-rw-r--r--tools/perf/util/trace-event-parse.c34
-rw-r--r--tools/perf/util/trace-event-read.c44
-rw-r--r--tools/perf/util/trace-event-scripting.c4
-rw-r--r--tools/perf/util/trace-event.c28
-rw-r--r--tools/perf/util/trace-event.h20
-rw-r--r--tools/perf/util/zlib.c18
-rw-r--r--tools/power/cpupower/po/de.po44
-rw-r--r--tools/power/cpupower/po/fr.po120
-rw-r--r--tools/testing/nvdimm/pmem-dax.c12
-rw-r--r--tools/testing/nvdimm/test/nfit.c126
-rw-r--r--tools/testing/radix-tree/Makefile6
-rw-r--r--tools/testing/radix-tree/idr-test.c214
-rw-r--r--tools/testing/radix-tree/linux/xarray.h2
-rw-r--r--tools/testing/radix-tree/main.c23
-rw-r--r--tools/testing/radix-tree/test.h3
-rw-r--r--tools/testing/selftests/android/ion/ionapp_export.c1
-rw-r--r--tools/testing/selftests/cgroup/.gitignore1
-rw-r--r--tools/testing/selftests/cgroup/Makefile2
-rw-r--r--tools/testing/selftests/cgroup/cgroup_util.c8
-rw-r--r--tools/testing/selftests/cgroup/cgroup_util.h1
-rw-r--r--tools/testing/selftests/cgroup/test_core.c395
-rw-r--r--tools/testing/selftests/ftrace/config3
-rw-r--r--tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc30
-rw-r--r--tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc2
-rw-r--r--tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc73
-rw-r--r--tools/testing/selftests/kvm/Makefile5
-rw-r--r--tools/testing/selftests/kvm/cr4_cpuid_sync_test.c32
-rw-r--r--tools/testing/selftests/kvm/dirty_log_test.c308
-rw-r--r--tools/testing/selftests/kvm/include/kvm_util.h45
-rw-r--r--tools/testing/selftests/kvm/include/test_util.h2
-rw-r--r--tools/testing/selftests/kvm/lib/kvm_util.c58
-rw-r--r--tools/testing/selftests/kvm/lib/x86.c18
-rw-r--r--tools/testing/selftests/kvm/set_sregs_test.c2
-rw-r--r--tools/testing/selftests/kvm/state_test.c32
-rw-r--r--tools/testing/selftests/kvm/sync_regs_test.c21
-rw-r--r--tools/testing/selftests/kvm/vmx_tsc_adjust_test.c43
-rw-r--r--tools/testing/selftests/mount/config1
-rwxr-xr-xtools/testing/selftests/net/pmtu.sh7
-rw-r--r--tools/testing/selftests/proc/.gitignore2
-rw-r--r--tools/testing/selftests/proc/Makefile3
-rw-r--r--tools/testing/selftests/proc/proc.h12
-rw-r--r--tools/testing/selftests/proc/self.c39
-rw-r--r--tools/testing/selftests/proc/thread-self.c64
-rw-r--r--tools/testing/selftests/tc-testing/tc-tests/actions/police.json48
-rw-r--r--tools/testing/selftests/vDSO/Makefile13
-rw-r--r--tools/testing/selftests/vDSO/vdso_test.c7
-rw-r--r--tools/testing/selftests/vm/.gitignore1
-rw-r--r--tools/testing/selftests/vm/Makefile1
-rw-r--r--tools/testing/selftests/vm/map_populate.c113
-rwxr-xr-xtools/testing/selftests/vm/run_vmtests11
-rw-r--r--tools/vm/page-types.c6
-rw-r--r--tools/vm/slabinfo.c4
139 files changed, 4741 insertions, 2088 deletions
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index 64aaa3f5f36c..89a048c2faec 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -220,6 +220,7 @@
220#define X86_FEATURE_STIBP ( 7*32+27) /* Single Thread Indirect Branch Predictors */ 220#define X86_FEATURE_STIBP ( 7*32+27) /* Single Thread Indirect Branch Predictors */
221#define X86_FEATURE_ZEN ( 7*32+28) /* "" CPU is AMD family 0x17 (Zen) */ 221#define X86_FEATURE_ZEN ( 7*32+28) /* "" CPU is AMD family 0x17 (Zen) */
222#define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */ 222#define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */
223#define X86_FEATURE_IBRS_ENHANCED ( 7*32+30) /* Enhanced IBRS */
223 224
224/* Virtualization flags: Linux defined, word 8 */ 225/* Virtualization flags: Linux defined, word 8 */
225#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ 226#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
@@ -230,7 +231,7 @@
230 231
231#define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer VMMCALL to VMCALL */ 232#define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer VMMCALL to VMCALL */
232#define X86_FEATURE_XENPV ( 8*32+16) /* "" Xen paravirtual guest */ 233#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 */
234 235
235/* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */ 236/* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
236#define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/ 237#define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
diff --git a/tools/arch/x86/lib/memcpy_64.S b/tools/arch/x86/lib/memcpy_64.S
index 298ef1479240..3b24dc05251c 100644
--- a/tools/arch/x86/lib/memcpy_64.S
+++ b/tools/arch/x86/lib/memcpy_64.S
@@ -256,7 +256,7 @@ ENTRY(__memcpy_mcsafe)
256 256
257 /* Copy successful. Return zero */ 257 /* Copy successful. Return zero */
258.L_done_memcpy_trap: 258.L_done_memcpy_trap:
259 xorq %rax, %rax 259 xorl %eax, %eax
260 ret 260 ret
261ENDPROC(__memcpy_mcsafe) 261ENDPROC(__memcpy_mcsafe)
262EXPORT_SYMBOL_GPL(__memcpy_mcsafe) 262EXPORT_SYMBOL_GPL(__memcpy_mcsafe)
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index b2ec20e562bd..b455930a3eaf 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -68,6 +68,7 @@ static const char * const map_type_name[] = {
68 [BPF_MAP_TYPE_DEVMAP] = "devmap", 68 [BPF_MAP_TYPE_DEVMAP] = "devmap",
69 [BPF_MAP_TYPE_SOCKMAP] = "sockmap", 69 [BPF_MAP_TYPE_SOCKMAP] = "sockmap",
70 [BPF_MAP_TYPE_CPUMAP] = "cpumap", 70 [BPF_MAP_TYPE_CPUMAP] = "cpumap",
71 [BPF_MAP_TYPE_XSKMAP] = "xskmap",
71 [BPF_MAP_TYPE_SOCKHASH] = "sockhash", 72 [BPF_MAP_TYPE_SOCKHASH] = "sockhash",
72 [BPF_MAP_TYPE_CGROUP_STORAGE] = "cgroup_storage", 73 [BPF_MAP_TYPE_CGROUP_STORAGE] = "cgroup_storage",
73}; 74};
diff --git a/tools/bpf/bpftool/map_perf_ring.c b/tools/bpf/bpftool/map_perf_ring.c
index 1832100d1b27..6d41323be291 100644
--- a/tools/bpf/bpftool/map_perf_ring.c
+++ b/tools/bpf/bpftool/map_perf_ring.c
@@ -194,8 +194,10 @@ int do_event_pipe(int argc, char **argv)
194 } 194 }
195 195
196 while (argc) { 196 while (argc) {
197 if (argc < 2) 197 if (argc < 2) {
198 BAD_ARG(); 198 BAD_ARG();
199 goto err_close_map;
200 }
199 201
200 if (is_prefix(*argv, "cpu")) { 202 if (is_prefix(*argv, "cpu")) {
201 char *endptr; 203 char *endptr;
@@ -221,6 +223,7 @@ int do_event_pipe(int argc, char **argv)
221 NEXT_ARG(); 223 NEXT_ARG();
222 } else { 224 } else {
223 BAD_ARG(); 225 BAD_ARG();
226 goto err_close_map;
224 } 227 }
225 228
226 do_all = false; 229 do_all = false;
diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h
index 63440cc8d618..e63662db131b 100644
--- a/tools/include/linux/bitmap.h
+++ b/tools/include/linux/bitmap.h
@@ -97,6 +97,23 @@ static inline int test_and_set_bit(int nr, unsigned long *addr)
97} 97}
98 98
99/** 99/**
100 * test_and_clear_bit - Clear a bit and return its old value
101 * @nr: Bit to clear
102 * @addr: Address to count from
103 */
104static inline int test_and_clear_bit(int nr, unsigned long *addr)
105{
106 unsigned long mask = BIT_MASK(nr);
107 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
108 unsigned long old;
109
110 old = *p;
111 *p = old & ~mask;
112
113 return (old & mask) != 0;
114}
115
116/**
100 * bitmap_alloc - Allocate bitmap 117 * bitmap_alloc - Allocate bitmap
101 * @nbits: Number of bits 118 * @nbits: Number of bits
102 */ 119 */
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index 56c4b3f8a01b..439b8a27488d 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -759,12 +759,18 @@ class DebugfsProvider(Provider):
759 if len(vms) == 0: 759 if len(vms) == 0:
760 self.do_read = False 760 self.do_read = False
761 761
762 self.paths = filter(lambda x: "{}-".format(pid) in x, vms) 762 self.paths = list(filter(lambda x: "{}-".format(pid) in x, vms))
763 763
764 else: 764 else:
765 self.paths = [] 765 self.paths = []
766 self.do_read = True 766 self.do_read = True
767 self.reset() 767
768 def _verify_paths(self):
769 """Remove invalid paths"""
770 for path in self.paths:
771 if not os.path.exists(os.path.join(PATH_DEBUGFS_KVM, path)):
772 self.paths.remove(path)
773 continue
768 774
769 def read(self, reset=0, by_guest=0): 775 def read(self, reset=0, by_guest=0):
770 """Returns a dict with format:'file name / field -> current value'. 776 """Returns a dict with format:'file name / field -> current value'.
@@ -780,6 +786,7 @@ class DebugfsProvider(Provider):
780 # If no debugfs filtering support is available, then don't read. 786 # If no debugfs filtering support is available, then don't read.
781 if not self.do_read: 787 if not self.do_read:
782 return results 788 return results
789 self._verify_paths()
783 790
784 paths = self.paths 791 paths = self.paths
785 if self._pid == 0: 792 if self._pid == 0:
@@ -1096,15 +1103,16 @@ class Tui(object):
1096 pid = self.stats.pid_filter 1103 pid = self.stats.pid_filter
1097 self.screen.erase() 1104 self.screen.erase()
1098 gname = self.get_gname_from_pid(pid) 1105 gname = self.get_gname_from_pid(pid)
1106 self._gname = gname
1099 if gname: 1107 if gname:
1100 gname = ('({})'.format(gname[:MAX_GUEST_NAME_LEN] + '...' 1108 gname = ('({})'.format(gname[:MAX_GUEST_NAME_LEN] + '...'
1101 if len(gname) > MAX_GUEST_NAME_LEN 1109 if len(gname) > MAX_GUEST_NAME_LEN
1102 else gname)) 1110 else gname))
1103 if pid > 0: 1111 if pid > 0:
1104 self.screen.addstr(0, 0, 'kvm statistics - pid {0} {1}' 1112 self._headline = 'kvm statistics - pid {0} {1}'.format(pid, gname)
1105 .format(pid, gname), curses.A_BOLD)
1106 else: 1113 else:
1107 self.screen.addstr(0, 0, 'kvm statistics - summary', curses.A_BOLD) 1114 self._headline = 'kvm statistics - summary'
1115 self.screen.addstr(0, 0, self._headline, curses.A_BOLD)
1108 if self.stats.fields_filter: 1116 if self.stats.fields_filter:
1109 regex = self.stats.fields_filter 1117 regex = self.stats.fields_filter
1110 if len(regex) > MAX_REGEX_LEN: 1118 if len(regex) > MAX_REGEX_LEN:
@@ -1162,6 +1170,19 @@ class Tui(object):
1162 1170
1163 return sorted_items 1171 return sorted_items
1164 1172
1173 if not self._is_running_guest(self.stats.pid_filter):
1174 if self._gname:
1175 try: # ...to identify the guest by name in case it's back
1176 pids = self.get_pid_from_gname(self._gname)
1177 if len(pids) == 1:
1178 self._refresh_header(pids[0])
1179 self._update_pid(pids[0])
1180 return
1181 except:
1182 pass
1183 self._display_guest_dead()
1184 # leave final data on screen
1185 return
1165 row = 3 1186 row = 3
1166 self.screen.move(row, 0) 1187 self.screen.move(row, 0)
1167 self.screen.clrtobot() 1188 self.screen.clrtobot()
@@ -1184,6 +1205,7 @@ class Tui(object):
1184 # print events 1205 # print events
1185 tavg = 0 1206 tavg = 0
1186 tcur = 0 1207 tcur = 0
1208 guest_removed = False
1187 for key, values in get_sorted_events(self, stats): 1209 for key, values in get_sorted_events(self, stats):
1188 if row >= self.screen.getmaxyx()[0] - 1 or values == (0, 0): 1210 if row >= self.screen.getmaxyx()[0] - 1 or values == (0, 0):
1189 break 1211 break
@@ -1191,7 +1213,10 @@ class Tui(object):
1191 key = self.get_gname_from_pid(key) 1213 key = self.get_gname_from_pid(key)
1192 if not key: 1214 if not key:
1193 continue 1215 continue
1194 cur = int(round(values.delta / sleeptime)) if values.delta else '' 1216 cur = int(round(values.delta / sleeptime)) if values.delta else 0
1217 if cur < 0:
1218 guest_removed = True
1219 continue
1195 if key[0] != ' ': 1220 if key[0] != ' ':
1196 if values.delta: 1221 if values.delta:
1197 tcur += values.delta 1222 tcur += values.delta
@@ -1204,13 +1229,21 @@ class Tui(object):
1204 values.value * 100 / float(ltotal), cur)) 1229 values.value * 100 / float(ltotal), cur))
1205 row += 1 1230 row += 1
1206 if row == 3: 1231 if row == 3:
1207 self.screen.addstr(4, 1, 'No matching events reported yet') 1232 if guest_removed:
1233 self.screen.addstr(4, 1, 'Guest removed, updating...')
1234 else:
1235 self.screen.addstr(4, 1, 'No matching events reported yet')
1208 if row > 4: 1236 if row > 4:
1209 tavg = int(round(tcur / sleeptime)) if tcur > 0 else '' 1237 tavg = int(round(tcur / sleeptime)) if tcur > 0 else ''
1210 self.screen.addstr(row, 1, '%-40s %10d %8s' % 1238 self.screen.addstr(row, 1, '%-40s %10d %8s' %
1211 ('Total', total, tavg), curses.A_BOLD) 1239 ('Total', total, tavg), curses.A_BOLD)
1212 self.screen.refresh() 1240 self.screen.refresh()
1213 1241
1242 def _display_guest_dead(self):
1243 marker = ' Guest is DEAD '
1244 y = min(len(self._headline), 80 - len(marker))
1245 self.screen.addstr(0, y, marker, curses.A_BLINK | curses.A_STANDOUT)
1246
1214 def _show_msg(self, text): 1247 def _show_msg(self, text):
1215 """Display message centered text and exit on key press""" 1248 """Display message centered text and exit on key press"""
1216 hint = 'Press any key to continue' 1249 hint = 'Press any key to continue'
@@ -1219,10 +1252,10 @@ class Tui(object):
1219 (x, term_width) = self.screen.getmaxyx() 1252 (x, term_width) = self.screen.getmaxyx()
1220 row = 2 1253 row = 2
1221 for line in text: 1254 for line in text:
1222 start = (term_width - len(line)) / 2 1255 start = (term_width - len(line)) // 2
1223 self.screen.addstr(row, start, line) 1256 self.screen.addstr(row, start, line)
1224 row += 1 1257 row += 1
1225 self.screen.addstr(row + 1, (term_width - len(hint)) / 2, hint, 1258 self.screen.addstr(row + 1, (term_width - len(hint)) // 2, hint,
1226 curses.A_STANDOUT) 1259 curses.A_STANDOUT)
1227 self.screen.getkey() 1260 self.screen.getkey()
1228 1261
@@ -1319,6 +1352,12 @@ class Tui(object):
1319 msg = '"' + str(val) + '": Invalid value' 1352 msg = '"' + str(val) + '": Invalid value'
1320 self._refresh_header() 1353 self._refresh_header()
1321 1354
1355 def _is_running_guest(self, pid):
1356 """Check if pid is still a running process."""
1357 if not pid:
1358 return True
1359 return os.path.isdir(os.path.join('/proc/', str(pid)))
1360
1322 def _show_vm_selection_by_guest(self): 1361 def _show_vm_selection_by_guest(self):
1323 """Draws guest selection mask. 1362 """Draws guest selection mask.
1324 1363
@@ -1346,7 +1385,7 @@ class Tui(object):
1346 if not guest or guest == '0': 1385 if not guest or guest == '0':
1347 break 1386 break
1348 if guest.isdigit(): 1387 if guest.isdigit():
1349 if not os.path.isdir(os.path.join('/proc/', guest)): 1388 if not self._is_running_guest(guest):
1350 msg = '"' + guest + '": Not a running process' 1389 msg = '"' + guest + '": Not a running process'
1351 continue 1390 continue
1352 pid = int(guest) 1391 pid = int(guest)
diff --git a/tools/lib/lockdep/Makefile b/tools/lib/lockdep/Makefile
index 9b0ca3ad1ef3..9dafb8cb752f 100644
--- a/tools/lib/lockdep/Makefile
+++ b/tools/lib/lockdep/Makefile
@@ -129,12 +129,12 @@ $(OUTPUT)liblockdep.a: $(LIB_IN)
129tags: force 129tags: force
130 $(RM) tags 130 $(RM) tags
131 find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \ 131 find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
132 --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' 132 --regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/'
133 133
134TAGS: force 134TAGS: force
135 $(RM) TAGS 135 $(RM) TAGS
136 find . -name '*.[ch]' | xargs etags \ 136 find . -name '*.[ch]' | xargs etags \
137 --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/' 137 --regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/'
138 138
139define do_install 139define do_install
140 $(print_install) \ 140 $(print_install) \
diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 46cd5f871ad7..0b4e833088a4 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -233,12 +233,12 @@ endef
233tags: force 233tags: force
234 $(RM) tags 234 $(RM) tags
235 find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \ 235 find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
236 --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' 236 --regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/'
237 237
238TAGS: force 238TAGS: force
239 $(RM) TAGS 239 $(RM) TAGS
240 find . -name '*.[ch]' | xargs etags \ 240 find . -name '*.[ch]' | xargs etags \
241 --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/' 241 --regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/'
242 242
243define do_install_mkdir 243define do_install_mkdir
244 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ 244 if [ ! -d '$(DESTDIR_SQ)$1' ]; then \
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index e5f2acbb70cc..ce1e20227c64 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -1,21 +1,7 @@
1// SPDX-License-Identifier: LGPL-2.1
1/* 2/*
2 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> 3 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3 * 4 *
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 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 * 5 *
20 * The parts for function graph printing was taken and modified from the 6 * The parts for function graph printing was taken and modified from the
21 * Linux Kernel that were written by 7 * Linux Kernel that were written by
@@ -73,12 +59,12 @@ static void init_input_buf(const char *buf, unsigned long long size)
73 input_buf_ptr = 0; 59 input_buf_ptr = 0;
74} 60}
75 61
76const char *pevent_get_input_buf(void) 62const char *tep_get_input_buf(void)
77{ 63{
78 return input_buf; 64 return input_buf;
79} 65}
80 66
81unsigned long long pevent_get_input_buf_ptr(void) 67unsigned long long tep_get_input_buf_ptr(void)
82{ 68{
83 return input_buf_ptr; 69 return input_buf_ptr;
84} 70}
@@ -88,21 +74,21 @@ struct event_handler {
88 int id; 74 int id;
89 const char *sys_name; 75 const char *sys_name;
90 const char *event_name; 76 const char *event_name;
91 pevent_event_handler_func func; 77 tep_event_handler_func func;
92 void *context; 78 void *context;
93}; 79};
94 80
95struct pevent_func_params { 81struct func_params {
96 struct pevent_func_params *next; 82 struct func_params *next;
97 enum pevent_func_arg_type type; 83 enum tep_func_arg_type type;
98}; 84};
99 85
100struct pevent_function_handler { 86struct tep_function_handler {
101 struct pevent_function_handler *next; 87 struct tep_function_handler *next;
102 enum pevent_func_arg_type ret_type; 88 enum tep_func_arg_type ret_type;
103 char *name; 89 char *name;
104 pevent_func_handler func; 90 tep_func_handler func;
105 struct pevent_func_params *params; 91 struct func_params *params;
106 int nr_args; 92 int nr_args;
107}; 93};
108 94
@@ -110,17 +96,17 @@ static unsigned long long
110process_defined_func(struct trace_seq *s, void *data, int size, 96process_defined_func(struct trace_seq *s, void *data, int size,
111 struct event_format *event, struct print_arg *arg); 97 struct event_format *event, struct print_arg *arg);
112 98
113static void free_func_handle(struct pevent_function_handler *func); 99static void free_func_handle(struct tep_function_handler *func);
114 100
115/** 101/**
116 * pevent_buffer_init - init buffer for parsing 102 * tep_buffer_init - init buffer for parsing
117 * @buf: buffer to parse 103 * @buf: buffer to parse
118 * @size: the size of the buffer 104 * @size: the size of the buffer
119 * 105 *
120 * For use with pevent_read_token(), this initializes the internal 106 * For use with tep_read_token(), this initializes the internal
121 * buffer that pevent_read_token() will parse. 107 * buffer that tep_read_token() will parse.
122 */ 108 */
123void pevent_buffer_init(const char *buf, unsigned long long size) 109void tep_buffer_init(const char *buf, unsigned long long size)
124{ 110{
125 init_input_buf(buf, size); 111 init_input_buf(buf, size);
126} 112}
@@ -160,7 +146,7 @@ struct cmdline_list {
160 int pid; 146 int pid;
161}; 147};
162 148
163static int cmdline_init(struct pevent *pevent) 149static int cmdline_init(struct tep_handle *pevent)
164{ 150{
165 struct cmdline_list *cmdlist = pevent->cmdlist; 151 struct cmdline_list *cmdlist = pevent->cmdlist;
166 struct cmdline_list *item; 152 struct cmdline_list *item;
@@ -189,7 +175,7 @@ static int cmdline_init(struct pevent *pevent)
189 return 0; 175 return 0;
190} 176}
191 177
192static const char *find_cmdline(struct pevent *pevent, int pid) 178static const char *find_cmdline(struct tep_handle *pevent, int pid)
193{ 179{
194 const struct cmdline *comm; 180 const struct cmdline *comm;
195 struct cmdline key; 181 struct cmdline key;
@@ -211,14 +197,14 @@ static const char *find_cmdline(struct pevent *pevent, int pid)
211} 197}
212 198
213/** 199/**
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
215 * @pevent: handle for the pevent 201 * @pevent: handle for the pevent
216 * @pid: The pid to check if it has a cmdline registered with. 202 * @pid: The pid to check if it has a cmdline registered with.
217 * 203 *
218 * Returns 1 if the pid has a cmdline mapped to it 204 * Returns 1 if the pid has a cmdline mapped to it
219 * 0 otherwise. 205 * 0 otherwise.
220 */ 206 */
221int pevent_pid_is_registered(struct pevent *pevent, int pid) 207int tep_pid_is_registered(struct tep_handle *pevent, int pid)
222{ 208{
223 const struct cmdline *comm; 209 const struct cmdline *comm;
224 struct cmdline key; 210 struct cmdline key;
@@ -244,7 +230,7 @@ int pevent_pid_is_registered(struct pevent *pevent, int pid)
244 * we must add this pid. This is much slower than when cmdlines 230 * we must add this pid. This is much slower than when cmdlines
245 * are added before the array is initialized. 231 * are added before the array is initialized.
246 */ 232 */
247static int add_new_comm(struct pevent *pevent, const char *comm, int pid) 233static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid)
248{ 234{
249 struct cmdline *cmdlines = pevent->cmdlines; 235 struct cmdline *cmdlines = pevent->cmdlines;
250 const struct cmdline *cmdline; 236 const struct cmdline *cmdline;
@@ -288,7 +274,7 @@ static int add_new_comm(struct pevent *pevent, const char *comm, int pid)
288} 274}
289 275
290/** 276/**
291 * pevent_register_comm - register a pid / comm mapping 277 * tep_register_comm - register a pid / comm mapping
292 * @pevent: handle for the pevent 278 * @pevent: handle for the pevent
293 * @comm: the command line to register 279 * @comm: the command line to register
294 * @pid: the pid to map the command line to 280 * @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)
296 * This adds a mapping to search for command line names with 282 * This adds a mapping to search for command line names with
297 * a given pid. The comm is duplicated. 283 * a given pid. The comm is duplicated.
298 */ 284 */
299int pevent_register_comm(struct pevent *pevent, const char *comm, int pid) 285int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid)
300{ 286{
301 struct cmdline_list *item; 287 struct cmdline_list *item;
302 288
@@ -324,7 +310,7 @@ int pevent_register_comm(struct pevent *pevent, const char *comm, int pid)
324 return 0; 310 return 0;
325} 311}
326 312
327int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock) 313int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock)
328{ 314{
329 pevent->trace_clock = strdup(trace_clock); 315 pevent->trace_clock = strdup(trace_clock);
330 if (!pevent->trace_clock) { 316 if (!pevent->trace_clock) {
@@ -381,7 +367,7 @@ static int func_bcmp(const void *a, const void *b)
381 return 1; 367 return 1;
382} 368}
383 369
384static int func_map_init(struct pevent *pevent) 370static int func_map_init(struct tep_handle *pevent)
385{ 371{
386 struct func_list *funclist; 372 struct func_list *funclist;
387 struct func_list *item; 373 struct func_list *item;
@@ -421,7 +407,7 @@ static int func_map_init(struct pevent *pevent)
421} 407}
422 408
423static struct func_map * 409static struct func_map *
424__find_func(struct pevent *pevent, unsigned long long addr) 410__find_func(struct tep_handle *pevent, unsigned long long addr)
425{ 411{
426 struct func_map *func; 412 struct func_map *func;
427 struct func_map key; 413 struct func_map key;
@@ -438,13 +424,13 @@ __find_func(struct pevent *pevent, unsigned long long addr)
438} 424}
439 425
440struct func_resolver { 426struct func_resolver {
441 pevent_func_resolver_t *func; 427 tep_func_resolver_t *func;
442 void *priv; 428 void *priv;
443 struct func_map map; 429 struct func_map map;
444}; 430};
445 431
446/** 432/**
447 * pevent_set_function_resolver - set an alternative function resolver 433 * tep_set_function_resolver - set an alternative function resolver
448 * @pevent: handle for the pevent 434 * @pevent: handle for the pevent
449 * @resolver: function to be used 435 * @resolver: function to be used
450 * @priv: resolver function private state. 436 * @priv: resolver function private state.
@@ -453,8 +439,8 @@ struct func_resolver {
453 * keep using it instead of duplicating all the entries inside 439 * keep using it instead of duplicating all the entries inside
454 * pevent->funclist. 440 * pevent->funclist.
455 */ 441 */
456int pevent_set_function_resolver(struct pevent *pevent, 442int tep_set_function_resolver(struct tep_handle *pevent,
457 pevent_func_resolver_t *func, void *priv) 443 tep_func_resolver_t *func, void *priv)
458{ 444{
459 struct func_resolver *resolver = malloc(sizeof(*resolver)); 445 struct func_resolver *resolver = malloc(sizeof(*resolver));
460 446
@@ -471,20 +457,20 @@ int pevent_set_function_resolver(struct pevent *pevent,
471} 457}
472 458
473/** 459/**
474 * pevent_reset_function_resolver - reset alternative function resolver 460 * tep_reset_function_resolver - reset alternative function resolver
475 * @pevent: handle for the pevent 461 * @pevent: handle for the pevent
476 * 462 *
477 * Stop using whatever alternative resolver was set, use the default 463 * Stop using whatever alternative resolver was set, use the default
478 * one instead. 464 * one instead.
479 */ 465 */
480void pevent_reset_function_resolver(struct pevent *pevent) 466void tep_reset_function_resolver(struct tep_handle *pevent)
481{ 467{
482 free(pevent->func_resolver); 468 free(pevent->func_resolver);
483 pevent->func_resolver = NULL; 469 pevent->func_resolver = NULL;
484} 470}
485 471
486static struct func_map * 472static struct func_map *
487find_func(struct pevent *pevent, unsigned long long addr) 473find_func(struct tep_handle *pevent, unsigned long long addr)
488{ 474{
489 struct func_map *map; 475 struct func_map *map;
490 476
@@ -503,7 +489,7 @@ find_func(struct pevent *pevent, unsigned long long addr)
503} 489}
504 490
505/** 491/**
506 * pevent_find_function - find a function by a given address 492 * tep_find_function - find a function by a given address
507 * @pevent: handle for the pevent 493 * @pevent: handle for the pevent
508 * @addr: the address to find the function with 494 * @addr: the address to find the function with
509 * 495 *
@@ -511,7 +497,7 @@ find_func(struct pevent *pevent, unsigned long long addr)
511 * address. Note, the address does not have to be exact, it 497 * address. Note, the address does not have to be exact, it
512 * will select the function that would contain the address. 498 * will select the function that would contain the address.
513 */ 499 */
514const char *pevent_find_function(struct pevent *pevent, unsigned long long addr) 500const char *tep_find_function(struct tep_handle *pevent, unsigned long long addr)
515{ 501{
516 struct func_map *map; 502 struct func_map *map;
517 503
@@ -523,16 +509,16 @@ const char *pevent_find_function(struct pevent *pevent, unsigned long long addr)
523} 509}
524 510
525/** 511/**
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
527 * @pevent: handle for the pevent 513 * @pevent: handle for the pevent
528 * @addr: the address to find the function with 514 * @addr: the address to find the function with
529 * 515 *
530 * Returns the address the function starts at. This can be used in 516 * 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
532 * name and the function offset. 518 * name and the function offset.
533 */ 519 */
534unsigned long long 520unsigned long long
535pevent_find_function_address(struct pevent *pevent, unsigned long long addr) 521tep_find_function_address(struct tep_handle *pevent, unsigned long long addr)
536{ 522{
537 struct func_map *map; 523 struct func_map *map;
538 524
@@ -544,7 +530,7 @@ pevent_find_function_address(struct pevent *pevent, unsigned long long addr)
544} 530}
545 531
546/** 532/**
547 * pevent_register_function - register a function with a given address 533 * tep_register_function - register a function with a given address
548 * @pevent: handle for the pevent 534 * @pevent: handle for the pevent
549 * @function: the function name to register 535 * @function: the function name to register
550 * @addr: the address the function starts at 536 * @addr: the address the function starts at
@@ -553,8 +539,8 @@ pevent_find_function_address(struct pevent *pevent, unsigned long long addr)
553 * This registers a function name with an address and module. 539 * This registers a function name with an address and module.
554 * The @func passed in is duplicated. 540 * The @func passed in is duplicated.
555 */ 541 */
556int pevent_register_function(struct pevent *pevent, char *func, 542int tep_register_function(struct tep_handle *pevent, char *func,
557 unsigned long long addr, char *mod) 543 unsigned long long addr, char *mod)
558{ 544{
559 struct func_list *item = malloc(sizeof(*item)); 545 struct func_list *item = malloc(sizeof(*item));
560 546
@@ -589,12 +575,12 @@ out_free:
589} 575}
590 576
591/** 577/**
592 * pevent_print_funcs - print out the stored functions 578 * tep_print_funcs - print out the stored functions
593 * @pevent: handle for the pevent 579 * @pevent: handle for the pevent
594 * 580 *
595 * This prints out the stored functions. 581 * This prints out the stored functions.
596 */ 582 */
597void pevent_print_funcs(struct pevent *pevent) 583void tep_print_funcs(struct tep_handle *pevent)
598{ 584{
599 int i; 585 int i;
600 586
@@ -636,7 +622,7 @@ static int printk_cmp(const void *a, const void *b)
636 return 0; 622 return 0;
637} 623}
638 624
639static int printk_map_init(struct pevent *pevent) 625static int printk_map_init(struct tep_handle *pevent)
640{ 626{
641 struct printk_list *printklist; 627 struct printk_list *printklist;
642 struct printk_list *item; 628 struct printk_list *item;
@@ -668,7 +654,7 @@ static int printk_map_init(struct pevent *pevent)
668} 654}
669 655
670static struct printk_map * 656static struct printk_map *
671find_printk(struct pevent *pevent, unsigned long long addr) 657find_printk(struct tep_handle *pevent, unsigned long long addr)
672{ 658{
673 struct printk_map *printk; 659 struct printk_map *printk;
674 struct printk_map key; 660 struct printk_map key;
@@ -685,7 +671,7 @@ find_printk(struct pevent *pevent, unsigned long long addr)
685} 671}
686 672
687/** 673/**
688 * pevent_register_print_string - register a string by its address 674 * tep_register_print_string - register a string by its address
689 * @pevent: handle for the pevent 675 * @pevent: handle for the pevent
690 * @fmt: the string format to register 676 * @fmt: the string format to register
691 * @addr: the address the string was located at 677 * @addr: the address the string was located at
@@ -693,8 +679,8 @@ find_printk(struct pevent *pevent, unsigned long long addr)
693 * This registers a string by the address it was stored in the kernel. 679 * This registers a string by the address it was stored in the kernel.
694 * The @fmt passed in is duplicated. 680 * The @fmt passed in is duplicated.
695 */ 681 */
696int pevent_register_print_string(struct pevent *pevent, const char *fmt, 682int tep_register_print_string(struct tep_handle *pevent, const char *fmt,
697 unsigned long long addr) 683 unsigned long long addr)
698{ 684{
699 struct printk_list *item = malloc(sizeof(*item)); 685 struct printk_list *item = malloc(sizeof(*item));
700 char *p; 686 char *p;
@@ -732,12 +718,12 @@ out_free:
732} 718}
733 719
734/** 720/**
735 * pevent_print_printk - print out the stored strings 721 * tep_print_printk - print out the stored strings
736 * @pevent: handle for the pevent 722 * @pevent: handle for the pevent
737 * 723 *
738 * This prints the string formats that were stored. 724 * This prints the string formats that were stored.
739 */ 725 */
740void pevent_print_printk(struct pevent *pevent) 726void tep_print_printk(struct tep_handle *pevent)
741{ 727{
742 int i; 728 int i;
743 729
@@ -756,7 +742,7 @@ static struct event_format *alloc_event(void)
756 return calloc(1, sizeof(struct event_format)); 742 return calloc(1, sizeof(struct event_format));
757} 743}
758 744
759static int add_event(struct pevent *pevent, struct event_format *event) 745static int add_event(struct tep_handle *pevent, struct event_format *event)
760{ 746{
761 int i; 747 int i;
762 struct event_format **events = realloc(pevent->events, sizeof(event) * 748 struct event_format **events = realloc(pevent->events, sizeof(event) *
@@ -913,11 +899,11 @@ static int __peek_char(void)
913} 899}
914 900
915/** 901/**
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
917 * 903 *
918 * Returns the next character read, or -1 if end of buffer. 904 * Returns the next character read, or -1 if end of buffer.
919 */ 905 */
920int pevent_peek_char(void) 906int tep_peek_char(void)
921{ 907{
922 return __peek_char(); 908 return __peek_char();
923} 909}
@@ -1157,24 +1143,24 @@ static enum event_type read_token(char **tok)
1157} 1143}
1158 1144
1159/** 1145/**
1160 * pevent_read_token - access to utilites to use the pevent parser 1146 * tep_read_token - access to utilites to use the pevent parser
1161 * @tok: The token to return 1147 * @tok: The token to return
1162 * 1148 *
1163 * This will parse tokens from the string given by 1149 * This will parse tokens from the string given by
1164 * pevent_init_data(). 1150 * tep_init_data().
1165 * 1151 *
1166 * Returns the token type. 1152 * Returns the token type.
1167 */ 1153 */
1168enum event_type pevent_read_token(char **tok) 1154enum event_type tep_read_token(char **tok)
1169{ 1155{
1170 return read_token(tok); 1156 return read_token(tok);
1171} 1157}
1172 1158
1173/** 1159/**
1174 * pevent_free_token - free a token returned by pevent_read_token 1160 * tep_free_token - free a token returned by tep_read_token
1175 * @token: the token to free 1161 * @token: the token to free
1176 */ 1162 */
1177void pevent_free_token(char *token) 1163void tep_free_token(char *token)
1178{ 1164{
1179 free_token(token); 1165 free_token(token);
1180} 1166}
@@ -2101,11 +2087,11 @@ process_entry(struct event_format *event __maybe_unused, struct print_arg *arg,
2101 arg->field.name = field; 2087 arg->field.name = field;
2102 2088
2103 if (is_flag_field) { 2089 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);
2105 arg->field.field->flags |= FIELD_IS_FLAG; 2091 arg->field.field->flags |= FIELD_IS_FLAG;
2106 is_flag_field = 0; 2092 is_flag_field = 0;
2107 } else if (is_symbolic_field) { 2093 } 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);
2109 arg->field.field->flags |= FIELD_IS_SYMBOLIC; 2095 arg->field.field->flags |= FIELD_IS_SYMBOLIC;
2110 is_symbolic_field = 0; 2096 is_symbolic_field = 0;
2111 } 2097 }
@@ -2714,7 +2700,7 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char **
2714 2700
2715 /* Find the field */ 2701 /* Find the field */
2716 2702
2717 field = pevent_find_field(event, token); 2703 field = tep_find_field(event, token);
2718 if (!field) 2704 if (!field)
2719 goto out_free; 2705 goto out_free;
2720 2706
@@ -2771,7 +2757,7 @@ process_dynamic_array_len(struct event_format *event, struct print_arg *arg,
2771 arg->type = PRINT_DYNAMIC_ARRAY_LEN; 2757 arg->type = PRINT_DYNAMIC_ARRAY_LEN;
2772 2758
2773 /* Find the field */ 2759 /* Find the field */
2774 field = pevent_find_field(event, token); 2760 field = tep_find_field(event, token);
2775 if (!field) 2761 if (!field)
2776 goto out_free; 2762 goto out_free;
2777 2763
@@ -2914,10 +2900,10 @@ process_bitmask(struct event_format *event __maybe_unused, struct print_arg *arg
2914 return EVENT_ERROR; 2900 return EVENT_ERROR;
2915} 2901}
2916 2902
2917static struct pevent_function_handler * 2903static struct tep_function_handler *
2918find_func_handler(struct pevent *pevent, char *func_name) 2904find_func_handler(struct tep_handle *pevent, char *func_name)
2919{ 2905{
2920 struct pevent_function_handler *func; 2906 struct tep_function_handler *func;
2921 2907
2922 if (!pevent) 2908 if (!pevent)
2923 return NULL; 2909 return NULL;
@@ -2930,10 +2916,10 @@ find_func_handler(struct pevent *pevent, char *func_name)
2930 return func; 2916 return func;
2931} 2917}
2932 2918
2933static void remove_func_handler(struct pevent *pevent, char *func_name) 2919static void remove_func_handler(struct tep_handle *pevent, char *func_name)
2934{ 2920{
2935 struct pevent_function_handler *func; 2921 struct tep_function_handler *func;
2936 struct pevent_function_handler **next; 2922 struct tep_function_handler **next;
2937 2923
2938 next = &pevent->func_handlers; 2924 next = &pevent->func_handlers;
2939 while ((func = *next)) { 2925 while ((func = *next)) {
@@ -2947,7 +2933,7 @@ static void remove_func_handler(struct pevent *pevent, char *func_name)
2947} 2933}
2948 2934
2949static enum event_type 2935static enum event_type
2950process_func_handler(struct event_format *event, struct pevent_function_handler *func, 2936process_func_handler(struct event_format *event, struct tep_function_handler *func,
2951 struct print_arg *arg, char **tok) 2937 struct print_arg *arg, char **tok)
2952{ 2938{
2953 struct print_arg **next_arg; 2939 struct print_arg **next_arg;
@@ -3008,7 +2994,7 @@ static enum event_type
3008process_function(struct event_format *event, struct print_arg *arg, 2994process_function(struct event_format *event, struct print_arg *arg,
3009 char *token, char **tok) 2995 char *token, char **tok)
3010{ 2996{
3011 struct pevent_function_handler *func; 2997 struct tep_function_handler *func;
3012 2998
3013 if (strcmp(token, "__print_flags") == 0) { 2999 if (strcmp(token, "__print_flags") == 0) {
3014 free_token(token); 3000 free_token(token);
@@ -3265,7 +3251,7 @@ static int event_read_print(struct event_format *event)
3265} 3251}
3266 3252
3267/** 3253/**
3268 * pevent_find_common_field - return a common field by event 3254 * tep_find_common_field - return a common field by event
3269 * @event: handle for the event 3255 * @event: handle for the event
3270 * @name: the name of the common field to return 3256 * @name: the name of the common field to return
3271 * 3257 *
@@ -3273,7 +3259,7 @@ static int event_read_print(struct event_format *event)
3273 * This only searchs the common fields and not all field. 3259 * This only searchs the common fields and not all field.
3274 */ 3260 */
3275struct format_field * 3261struct format_field *
3276pevent_find_common_field(struct event_format *event, const char *name) 3262tep_find_common_field(struct event_format *event, const char *name)
3277{ 3263{
3278 struct format_field *format; 3264 struct format_field *format;
3279 3265
@@ -3287,7 +3273,7 @@ pevent_find_common_field(struct event_format *event, const char *name)
3287} 3273}
3288 3274
3289/** 3275/**
3290 * pevent_find_field - find a non-common field 3276 * tep_find_field - find a non-common field
3291 * @event: handle for the event 3277 * @event: handle for the event
3292 * @name: the name of the non-common field 3278 * @name: the name of the non-common field
3293 * 3279 *
@@ -3295,7 +3281,7 @@ pevent_find_common_field(struct event_format *event, const char *name)
3295 * This does not search common fields. 3281 * This does not search common fields.
3296 */ 3282 */
3297struct format_field * 3283struct format_field *
3298pevent_find_field(struct event_format *event, const char *name) 3284tep_find_field(struct event_format *event, const char *name)
3299{ 3285{
3300 struct format_field *format; 3286 struct format_field *format;
3301 3287
@@ -3309,7 +3295,7 @@ pevent_find_field(struct event_format *event, const char *name)
3309} 3295}
3310 3296
3311/** 3297/**
3312 * pevent_find_any_field - find any field by name 3298 * tep_find_any_field - find any field by name
3313 * @event: handle for the event 3299 * @event: handle for the event
3314 * @name: the name of the field 3300 * @name: the name of the field
3315 * 3301 *
@@ -3318,18 +3304,18 @@ pevent_find_field(struct event_format *event, const char *name)
3318 * the non-common ones if a common one was not found. 3304 * the non-common ones if a common one was not found.
3319 */ 3305 */
3320struct format_field * 3306struct format_field *
3321pevent_find_any_field(struct event_format *event, const char *name) 3307tep_find_any_field(struct event_format *event, const char *name)
3322{ 3308{
3323 struct format_field *format; 3309 struct format_field *format;
3324 3310
3325 format = pevent_find_common_field(event, name); 3311 format = tep_find_common_field(event, name);
3326 if (format) 3312 if (format)
3327 return format; 3313 return format;
3328 return pevent_find_field(event, name); 3314 return tep_find_field(event, name);
3329} 3315}
3330 3316
3331/** 3317/**
3332 * pevent_read_number - read a number from data 3318 * tep_read_number - read a number from data
3333 * @pevent: handle for the pevent 3319 * @pevent: handle for the pevent
3334 * @ptr: the raw data 3320 * @ptr: the raw data
3335 * @size: the size of the data that holds the number 3321 * @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)
3337 * Returns the number (converted to host) from the 3323 * Returns the number (converted to host) from the
3338 * raw data. 3324 * raw data.
3339 */ 3325 */
3340unsigned long long pevent_read_number(struct pevent *pevent, 3326unsigned long long tep_read_number(struct tep_handle *pevent,
3341 const void *ptr, int size) 3327 const void *ptr, int size)
3342{ 3328{
3343 switch (size) { 3329 switch (size) {
3344 case 1: 3330 case 1:
@@ -3356,7 +3342,7 @@ unsigned long long pevent_read_number(struct pevent *pevent,
3356} 3342}
3357 3343
3358/** 3344/**
3359 * pevent_read_number_field - read a number from data 3345 * tep_read_number_field - read a number from data
3360 * @field: a handle to the field 3346 * @field: a handle to the field
3361 * @data: the raw data to read 3347 * @data: the raw data to read
3362 * @value: the value to place the number in 3348 * @value: the value to place the number in
@@ -3366,8 +3352,8 @@ unsigned long long pevent_read_number(struct pevent *pevent,
3366 * 3352 *
3367 * Returns 0 on success, -1 otherwise. 3353 * Returns 0 on success, -1 otherwise.
3368 */ 3354 */
3369int pevent_read_number_field(struct format_field *field, const void *data, 3355int tep_read_number_field(struct format_field *field, const void *data,
3370 unsigned long long *value) 3356 unsigned long long *value)
3371{ 3357{
3372 if (!field) 3358 if (!field)
3373 return -1; 3359 return -1;
@@ -3376,15 +3362,15 @@ int pevent_read_number_field(struct format_field *field, const void *data,
3376 case 2: 3362 case 2:
3377 case 4: 3363 case 4:
3378 case 8: 3364 case 8:
3379 *value = pevent_read_number(field->event->pevent, 3365 *value = tep_read_number(field->event->pevent,
3380 data + field->offset, field->size); 3366 data + field->offset, field->size);
3381 return 0; 3367 return 0;
3382 default: 3368 default:
3383 return -1; 3369 return -1;
3384 } 3370 }
3385} 3371}
3386 3372
3387static int get_common_info(struct pevent *pevent, 3373static int get_common_info(struct tep_handle *pevent,
3388 const char *type, int *offset, int *size) 3374 const char *type, int *offset, int *size)
3389{ 3375{
3390 struct event_format *event; 3376 struct event_format *event;
@@ -3400,7 +3386,7 @@ static int get_common_info(struct pevent *pevent,
3400 } 3386 }
3401 3387
3402 event = pevent->events[0]; 3388 event = pevent->events[0];
3403 field = pevent_find_common_field(event, type); 3389 field = tep_find_common_field(event, type);
3404 if (!field) 3390 if (!field)
3405 return -1; 3391 return -1;
3406 3392
@@ -3410,7 +3396,7 @@ static int get_common_info(struct pevent *pevent,
3410 return 0; 3396 return 0;
3411} 3397}
3412 3398
3413static int __parse_common(struct pevent *pevent, void *data, 3399static int __parse_common(struct tep_handle *pevent, void *data,
3414 int *size, int *offset, const char *name) 3400 int *size, int *offset, const char *name)
3415{ 3401{
3416 int ret; 3402 int ret;
@@ -3420,45 +3406,45 @@ static int __parse_common(struct pevent *pevent, void *data,
3420 if (ret < 0) 3406 if (ret < 0)
3421 return ret; 3407 return ret;
3422 } 3408 }
3423 return pevent_read_number(pevent, data + *offset, *size); 3409 return tep_read_number(pevent, data + *offset, *size);
3424} 3410}
3425 3411
3426static int trace_parse_common_type(struct pevent *pevent, void *data) 3412static int trace_parse_common_type(struct tep_handle *pevent, void *data)
3427{ 3413{
3428 return __parse_common(pevent, data, 3414 return __parse_common(pevent, data,
3429 &pevent->type_size, &pevent->type_offset, 3415 &pevent->type_size, &pevent->type_offset,
3430 "common_type"); 3416 "common_type");
3431} 3417}
3432 3418
3433static int parse_common_pid(struct pevent *pevent, void *data) 3419static int parse_common_pid(struct tep_handle *pevent, void *data)
3434{ 3420{
3435 return __parse_common(pevent, data, 3421 return __parse_common(pevent, data,
3436 &pevent->pid_size, &pevent->pid_offset, 3422 &pevent->pid_size, &pevent->pid_offset,
3437 "common_pid"); 3423 "common_pid");
3438} 3424}
3439 3425
3440static int parse_common_pc(struct pevent *pevent, void *data) 3426static int parse_common_pc(struct tep_handle *pevent, void *data)
3441{ 3427{
3442 return __parse_common(pevent, data, 3428 return __parse_common(pevent, data,
3443 &pevent->pc_size, &pevent->pc_offset, 3429 &pevent->pc_size, &pevent->pc_offset,
3444 "common_preempt_count"); 3430 "common_preempt_count");
3445} 3431}
3446 3432
3447static int parse_common_flags(struct pevent *pevent, void *data) 3433static int parse_common_flags(struct tep_handle *pevent, void *data)
3448{ 3434{
3449 return __parse_common(pevent, data, 3435 return __parse_common(pevent, data,
3450 &pevent->flags_size, &pevent->flags_offset, 3436 &pevent->flags_size, &pevent->flags_offset,
3451 "common_flags"); 3437 "common_flags");
3452} 3438}
3453 3439
3454static int parse_common_lock_depth(struct pevent *pevent, void *data) 3440static int parse_common_lock_depth(struct tep_handle *pevent, void *data)
3455{ 3441{
3456 return __parse_common(pevent, data, 3442 return __parse_common(pevent, data,
3457 &pevent->ld_size, &pevent->ld_offset, 3443 &pevent->ld_size, &pevent->ld_offset,
3458 "common_lock_depth"); 3444 "common_lock_depth");
3459} 3445}
3460 3446
3461static int parse_common_migrate_disable(struct pevent *pevent, void *data) 3447static int parse_common_migrate_disable(struct tep_handle *pevent, void *data)
3462{ 3448{
3463 return __parse_common(pevent, data, 3449 return __parse_common(pevent, data,
3464 &pevent->ld_size, &pevent->ld_offset, 3450 &pevent->ld_size, &pevent->ld_offset,
@@ -3468,13 +3454,13 @@ static int parse_common_migrate_disable(struct pevent *pevent, void *data)
3468static int events_id_cmp(const void *a, const void *b); 3454static int events_id_cmp(const void *a, const void *b);
3469 3455
3470/** 3456/**
3471 * pevent_find_event - find an event by given id 3457 * tep_find_event - find an event by given id
3472 * @pevent: a handle to the pevent 3458 * @pevent: a handle to the pevent
3473 * @id: the id of the event 3459 * @id: the id of the event
3474 * 3460 *
3475 * Returns an event that has a given @id. 3461 * Returns an event that has a given @id.
3476 */ 3462 */
3477struct event_format *pevent_find_event(struct pevent *pevent, int id) 3463struct event_format *tep_find_event(struct tep_handle *pevent, int id)
3478{ 3464{
3479 struct event_format **eventptr; 3465 struct event_format **eventptr;
3480 struct event_format key; 3466 struct event_format key;
@@ -3498,7 +3484,7 @@ struct event_format *pevent_find_event(struct pevent *pevent, int id)
3498} 3484}
3499 3485
3500/** 3486/**
3501 * pevent_find_event_by_name - find an event by given name 3487 * tep_find_event_by_name - find an event by given name
3502 * @pevent: a handle to the pevent 3488 * @pevent: a handle to the pevent
3503 * @sys: the system name to search for 3489 * @sys: the system name to search for
3504 * @name: the name of the event to search for 3490 * @name: the name of the event to search for
@@ -3507,8 +3493,8 @@ struct event_format *pevent_find_event(struct pevent *pevent, int id)
3507 * @sys. If @sys is NULL the first event with @name is returned. 3493 * @sys. If @sys is NULL the first event with @name is returned.
3508 */ 3494 */
3509struct event_format * 3495struct event_format *
3510pevent_find_event_by_name(struct pevent *pevent, 3496tep_find_event_by_name(struct tep_handle *pevent,
3511 const char *sys, const char *name) 3497 const char *sys, const char *name)
3512{ 3498{
3513 struct event_format *event; 3499 struct event_format *event;
3514 int i; 3500 int i;
@@ -3537,7 +3523,7 @@ pevent_find_event_by_name(struct pevent *pevent,
3537static unsigned long long 3523static unsigned long long
3538eval_num_arg(void *data, int size, struct event_format *event, struct print_arg *arg) 3524eval_num_arg(void *data, int size, struct event_format *event, struct print_arg *arg)
3539{ 3525{
3540 struct pevent *pevent = event->pevent; 3526 struct tep_handle *pevent = event->pevent;
3541 unsigned long long val = 0; 3527 unsigned long long val = 0;
3542 unsigned long long left, right; 3528 unsigned long long left, right;
3543 struct print_arg *typearg = NULL; 3529 struct print_arg *typearg = NULL;
@@ -3553,14 +3539,14 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
3553 return strtoull(arg->atom.atom, NULL, 0); 3539 return strtoull(arg->atom.atom, NULL, 0);
3554 case PRINT_FIELD: 3540 case PRINT_FIELD:
3555 if (!arg->field.field) { 3541 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);
3557 if (!arg->field.field) 3543 if (!arg->field.field)
3558 goto out_warning_field; 3544 goto out_warning_field;
3559 3545
3560 } 3546 }
3561 /* must be a number */ 3547 /* must be a number */
3562 val = pevent_read_number(pevent, data + arg->field.field->offset, 3548 val = tep_read_number(pevent, data + arg->field.field->offset,
3563 arg->field.field->size); 3549 arg->field.field->size);
3564 break; 3550 break;
3565 case PRINT_FLAGS: 3551 case PRINT_FLAGS:
3566 case PRINT_SYMBOL: 3552 case PRINT_SYMBOL:
@@ -3603,7 +3589,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
3603 3589
3604 switch (larg->type) { 3590 switch (larg->type) {
3605 case PRINT_DYNAMIC_ARRAY: 3591 case PRINT_DYNAMIC_ARRAY:
3606 offset = pevent_read_number(pevent, 3592 offset = tep_read_number(pevent,
3607 data + larg->dynarray.field->offset, 3593 data + larg->dynarray.field->offset,
3608 larg->dynarray.field->size); 3594 larg->dynarray.field->size);
3609 if (larg->dynarray.field->elementsize) 3595 if (larg->dynarray.field->elementsize)
@@ -3619,7 +3605,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
3619 case PRINT_FIELD: 3605 case PRINT_FIELD:
3620 if (!larg->field.field) { 3606 if (!larg->field.field) {
3621 larg->field.field = 3607 larg->field.field =
3622 pevent_find_any_field(event, larg->field.name); 3608 tep_find_any_field(event, larg->field.name);
3623 if (!larg->field.field) { 3609 if (!larg->field.field) {
3624 arg = larg; 3610 arg = larg;
3625 goto out_warning_field; 3611 goto out_warning_field;
@@ -3632,8 +3618,8 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
3632 default: 3618 default:
3633 goto default_op; /* oops, all bets off */ 3619 goto default_op; /* oops, all bets off */
3634 } 3620 }
3635 val = pevent_read_number(pevent, 3621 val = tep_read_number(pevent,
3636 data + offset, field_size); 3622 data + offset, field_size);
3637 if (typearg) 3623 if (typearg)
3638 val = eval_type(val, typearg, 1); 3624 val = eval_type(val, typearg, 1);
3639 break; 3625 break;
@@ -3733,9 +3719,9 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
3733 } 3719 }
3734 break; 3720 break;
3735 case PRINT_DYNAMIC_ARRAY_LEN: 3721 case PRINT_DYNAMIC_ARRAY_LEN:
3736 offset = pevent_read_number(pevent, 3722 offset = tep_read_number(pevent,
3737 data + arg->dynarray.field->offset, 3723 data + arg->dynarray.field->offset,
3738 arg->dynarray.field->size); 3724 arg->dynarray.field->size);
3739 /* 3725 /*
3740 * The total allocated length of the dynamic array is 3726 * The total allocated length of the dynamic array is
3741 * stored in the top half of the field, and the offset 3727 * 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
3745 break; 3731 break;
3746 case PRINT_DYNAMIC_ARRAY: 3732 case PRINT_DYNAMIC_ARRAY:
3747 /* Without [], we pass the address to the dynamic data */ 3733 /* Without [], we pass the address to the dynamic data */
3748 offset = pevent_read_number(pevent, 3734 offset = tep_read_number(pevent,
3749 data + arg->dynarray.field->offset, 3735 data + arg->dynarray.field->offset,
3750 arg->dynarray.field->size); 3736 arg->dynarray.field->size);
3751 /* 3737 /*
3752 * The total allocated length of the dynamic array is 3738 * The total allocated length of the dynamic array is
3753 * stored in the top half of the field, and the offset 3739 * 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,
3820 trace_seq_printf(s, format, str); 3806 trace_seq_printf(s, format, str);
3821} 3807}
3822 3808
3823static void print_bitmask_to_seq(struct pevent *pevent, 3809static void print_bitmask_to_seq(struct tep_handle *pevent,
3824 struct trace_seq *s, const char *format, 3810 struct trace_seq *s, const char *format,
3825 int len_arg, const void *data, int size) 3811 int len_arg, const void *data, int size)
3826{ 3812{
@@ -3878,7 +3864,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
3878 struct event_format *event, const char *format, 3864 struct event_format *event, const char *format,
3879 int len_arg, struct print_arg *arg) 3865 int len_arg, struct print_arg *arg)
3880{ 3866{
3881 struct pevent *pevent = event->pevent; 3867 struct tep_handle *pevent = event->pevent;
3882 struct print_flag_sym *flag; 3868 struct print_flag_sym *flag;
3883 struct format_field *field; 3869 struct format_field *field;
3884 struct printk_map *printk; 3870 struct printk_map *printk;
@@ -3899,7 +3885,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
3899 case PRINT_FIELD: 3885 case PRINT_FIELD:
3900 field = arg->field.field; 3886 field = arg->field.field;
3901 if (!field) { 3887 if (!field) {
3902 field = pevent_find_any_field(event, arg->field.name); 3888 field = tep_find_any_field(event, arg->field.name);
3903 if (!field) { 3889 if (!field) {
3904 str = arg->field.name; 3890 str = arg->field.name;
3905 goto out_warning_field; 3891 goto out_warning_field;
@@ -3992,7 +3978,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
3992 case PRINT_HEX_STR: 3978 case PRINT_HEX_STR:
3993 if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) { 3979 if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) {
3994 unsigned long offset; 3980 unsigned long offset;
3995 offset = pevent_read_number(pevent, 3981 offset = tep_read_number(pevent,
3996 data + arg->hex.field->dynarray.field->offset, 3982 data + arg->hex.field->dynarray.field->offset,
3997 arg->hex.field->dynarray.field->size); 3983 arg->hex.field->dynarray.field->size);
3998 hex = data + (offset & 0xffff); 3984 hex = data + (offset & 0xffff);
@@ -4000,7 +3986,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
4000 field = arg->hex.field->field.field; 3986 field = arg->hex.field->field.field;
4001 if (!field) { 3987 if (!field) {
4002 str = arg->hex.field->field.name; 3988 str = arg->hex.field->field.name;
4003 field = pevent_find_any_field(event, str); 3989 field = tep_find_any_field(event, str);
4004 if (!field) 3990 if (!field)
4005 goto out_warning_field; 3991 goto out_warning_field;
4006 arg->hex.field->field.field = field; 3992 arg->hex.field->field.field = field;
@@ -4023,15 +4009,15 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
4023 unsigned long offset; 4009 unsigned long offset;
4024 struct format_field *field = 4010 struct format_field *field =
4025 arg->int_array.field->dynarray.field; 4011 arg->int_array.field->dynarray.field;
4026 offset = pevent_read_number(pevent, 4012 offset = tep_read_number(pevent,
4027 data + field->offset, 4013 data + field->offset,
4028 field->size); 4014 field->size);
4029 num = data + (offset & 0xffff); 4015 num = data + (offset & 0xffff);
4030 } else { 4016 } else {
4031 field = arg->int_array.field->field.field; 4017 field = arg->int_array.field->field.field;
4032 if (!field) { 4018 if (!field) {
4033 str = arg->int_array.field->field.name; 4019 str = arg->int_array.field->field.name;
4034 field = pevent_find_any_field(event, str); 4020 field = tep_find_any_field(event, str);
4035 if (!field) 4021 if (!field)
4036 goto out_warning_field; 4022 goto out_warning_field;
4037 arg->int_array.field->field.field = field; 4023 arg->int_array.field->field.field = field;
@@ -4071,7 +4057,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
4071 if (arg->string.offset == -1) { 4057 if (arg->string.offset == -1) {
4072 struct format_field *f; 4058 struct format_field *f;
4073 4059
4074 f = pevent_find_any_field(event, arg->string.string); 4060 f = tep_find_any_field(event, arg->string.string);
4075 arg->string.offset = f->offset; 4061 arg->string.offset = f->offset;
4076 } 4062 }
4077 str_offset = data2host4(pevent, data + arg->string.offset); 4063 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,
4089 if (arg->bitmask.offset == -1) { 4075 if (arg->bitmask.offset == -1) {
4090 struct format_field *f; 4076 struct format_field *f;
4091 4077
4092 f = pevent_find_any_field(event, arg->bitmask.bitmask); 4078 f = tep_find_any_field(event, arg->bitmask.bitmask);
4093 arg->bitmask.offset = f->offset; 4079 arg->bitmask.offset = f->offset;
4094 } 4080 }
4095 bitmask_offset = data2host4(pevent, data + arg->bitmask.offset); 4081 bitmask_offset = data2host4(pevent, data + arg->bitmask.offset);
@@ -4132,8 +4118,8 @@ static unsigned long long
4132process_defined_func(struct trace_seq *s, void *data, int size, 4118process_defined_func(struct trace_seq *s, void *data, int size,
4133 struct event_format *event, struct print_arg *arg) 4119 struct event_format *event, struct print_arg *arg)
4134{ 4120{
4135 struct pevent_function_handler *func_handle = arg->func.func; 4121 struct tep_function_handler *func_handle = arg->func.func;
4136 struct pevent_func_params *param; 4122 struct func_params *param;
4137 unsigned long long *args; 4123 unsigned long long *args;
4138 unsigned long long ret; 4124 unsigned long long ret;
4139 struct print_arg *farg; 4125 struct print_arg *farg;
@@ -4159,12 +4145,12 @@ process_defined_func(struct trace_seq *s, void *data, int size,
4159 4145
4160 for (i = 0; i < func_handle->nr_args; i++) { 4146 for (i = 0; i < func_handle->nr_args; i++) {
4161 switch (param->type) { 4147 switch (param->type) {
4162 case PEVENT_FUNC_ARG_INT: 4148 case TEP_FUNC_ARG_INT:
4163 case PEVENT_FUNC_ARG_LONG: 4149 case TEP_FUNC_ARG_LONG:
4164 case PEVENT_FUNC_ARG_PTR: 4150 case TEP_FUNC_ARG_PTR:
4165 args[i] = eval_num_arg(data, size, event, farg); 4151 args[i] = eval_num_arg(data, size, event, farg);
4166 break; 4152 break;
4167 case PEVENT_FUNC_ARG_STRING: 4153 case TEP_FUNC_ARG_STRING:
4168 trace_seq_init(&str); 4154 trace_seq_init(&str);
4169 print_str_arg(&str, data, size, event, "%s", -1, farg); 4155 print_str_arg(&str, data, size, event, "%s", -1, farg);
4170 trace_seq_terminate(&str); 4156 trace_seq_terminate(&str);
@@ -4227,7 +4213,7 @@ static void free_args(struct print_arg *args)
4227 4213
4228static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struct event_format *event) 4214static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struct event_format *event)
4229{ 4215{
4230 struct pevent *pevent = event->pevent; 4216 struct tep_handle *pevent = event->pevent;
4231 struct format_field *field, *ip_field; 4217 struct format_field *field, *ip_field;
4232 struct print_arg *args, *arg, **next; 4218 struct print_arg *args, *arg, **next;
4233 unsigned long long ip, val; 4219 unsigned long long ip, val;
@@ -4239,12 +4225,12 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
4239 ip_field = pevent->bprint_ip_field; 4225 ip_field = pevent->bprint_ip_field;
4240 4226
4241 if (!field) { 4227 if (!field) {
4242 field = pevent_find_field(event, "buf"); 4228 field = tep_find_field(event, "buf");
4243 if (!field) { 4229 if (!field) {
4244 do_warning_event(event, "can't find buffer field for binary printk"); 4230 do_warning_event(event, "can't find buffer field for binary printk");
4245 return NULL; 4231 return NULL;
4246 } 4232 }
4247 ip_field = pevent_find_field(event, "ip"); 4233 ip_field = tep_find_field(event, "ip");
4248 if (!ip_field) { 4234 if (!ip_field) {
4249 do_warning_event(event, "can't find ip field for binary printk"); 4235 do_warning_event(event, "can't find ip field for binary printk");
4250 return NULL; 4236 return NULL;
@@ -4253,7 +4239,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
4253 pevent->bprint_ip_field = ip_field; 4239 pevent->bprint_ip_field = ip_field;
4254 } 4240 }
4255 4241
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);
4257 4243
4258 /* 4244 /*
4259 * The first arg is the IP pointer. 4245 * 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
4347 /* the pointers are always 4 bytes aligned */ 4333 /* the pointers are always 4 bytes aligned */
4348 bptr = (void *)(((unsigned long)bptr + 3) & 4334 bptr = (void *)(((unsigned long)bptr + 3) &
4349 ~3); 4335 ~3);
4350 val = pevent_read_number(pevent, bptr, vsize); 4336 val = tep_read_number(pevent, bptr, vsize);
4351 bptr += vsize; 4337 bptr += vsize;
4352 arg = alloc_arg(); 4338 arg = alloc_arg();
4353 if (!arg) { 4339 if (!arg) {
@@ -4404,7 +4390,7 @@ static char *
4404get_bprint_format(void *data, int size __maybe_unused, 4390get_bprint_format(void *data, int size __maybe_unused,
4405 struct event_format *event) 4391 struct event_format *event)
4406{ 4392{
4407 struct pevent *pevent = event->pevent; 4393 struct tep_handle *pevent = event->pevent;
4408 unsigned long long addr; 4394 unsigned long long addr;
4409 struct format_field *field; 4395 struct format_field *field;
4410 struct printk_map *printk; 4396 struct printk_map *printk;
@@ -4413,7 +4399,7 @@ get_bprint_format(void *data, int size __maybe_unused,
4413 field = pevent->bprint_fmt_field; 4399 field = pevent->bprint_fmt_field;
4414 4400
4415 if (!field) { 4401 if (!field) {
4416 field = pevent_find_field(event, "fmt"); 4402 field = tep_find_field(event, "fmt");
4417 if (!field) { 4403 if (!field) {
4418 do_warning_event(event, "can't find format field for binary printk"); 4404 do_warning_event(event, "can't find format field for binary printk");
4419 return NULL; 4405 return NULL;
@@ -4421,7 +4407,7 @@ get_bprint_format(void *data, int size __maybe_unused,
4421 pevent->bprint_fmt_field = field; 4407 pevent->bprint_fmt_field = field;
4422 } 4408 }
4423 4409
4424 addr = pevent_read_number(pevent, data + field->offset, field->size); 4410 addr = tep_read_number(pevent, data + field->offset, field->size);
4425 4411
4426 printk = find_printk(pevent, addr); 4412 printk = find_printk(pevent, addr);
4427 if (!printk) { 4413 if (!printk) {
@@ -4457,7 +4443,7 @@ static void print_mac_arg(struct trace_seq *s, int mac, void *data, int size,
4457 fmt = "%.2x%.2x%.2x%.2x%.2x%.2x"; 4443 fmt = "%.2x%.2x%.2x%.2x%.2x%.2x";
4458 if (!arg->field.field) { 4444 if (!arg->field.field) {
4459 arg->field.field = 4445 arg->field.field =
4460 pevent_find_any_field(event, arg->field.name); 4446 tep_find_any_field(event, arg->field.name);
4461 if (!arg->field.field) { 4447 if (!arg->field.field) {
4462 do_warning_event(event, "%s: field %s not found", 4448 do_warning_event(event, "%s: field %s not found",
4463 __func__, arg->field.name); 4449 __func__, arg->field.name);
@@ -4607,7 +4593,7 @@ static int print_ipv4_arg(struct trace_seq *s, const char *ptr, char i,
4607 4593
4608 if (!arg->field.field) { 4594 if (!arg->field.field) {
4609 arg->field.field = 4595 arg->field.field =
4610 pevent_find_any_field(event, arg->field.name); 4596 tep_find_any_field(event, arg->field.name);
4611 if (!arg->field.field) { 4597 if (!arg->field.field) {
4612 do_warning("%s: field %s not found", 4598 do_warning("%s: field %s not found",
4613 __func__, arg->field.name); 4599 __func__, arg->field.name);
@@ -4653,7 +4639,7 @@ static int print_ipv6_arg(struct trace_seq *s, const char *ptr, char i,
4653 4639
4654 if (!arg->field.field) { 4640 if (!arg->field.field) {
4655 arg->field.field = 4641 arg->field.field =
4656 pevent_find_any_field(event, arg->field.name); 4642 tep_find_any_field(event, arg->field.name);
4657 if (!arg->field.field) { 4643 if (!arg->field.field) {
4658 do_warning("%s: field %s not found", 4644 do_warning("%s: field %s not found",
4659 __func__, arg->field.name); 4645 __func__, arg->field.name);
@@ -4711,7 +4697,7 @@ static int print_ipsa_arg(struct trace_seq *s, const char *ptr, char i,
4711 4697
4712 if (!arg->field.field) { 4698 if (!arg->field.field) {
4713 arg->field.field = 4699 arg->field.field =
4714 pevent_find_any_field(event, arg->field.name); 4700 tep_find_any_field(event, arg->field.name);
4715 if (!arg->field.field) { 4701 if (!arg->field.field) {
4716 do_warning("%s: field %s not found", 4702 do_warning("%s: field %s not found",
4717 __func__, arg->field.name); 4703 __func__, arg->field.name);
@@ -4800,18 +4786,18 @@ static int is_printable_array(char *p, unsigned int len)
4800 return 1; 4786 return 1;
4801} 4787}
4802 4788
4803void pevent_print_field(struct trace_seq *s, void *data, 4789void tep_print_field(struct trace_seq *s, void *data,
4804 struct format_field *field) 4790 struct format_field *field)
4805{ 4791{
4806 unsigned long long val; 4792 unsigned long long val;
4807 unsigned int offset, len, i; 4793 unsigned int offset, len, i;
4808 struct pevent *pevent = field->event->pevent; 4794 struct tep_handle *pevent = field->event->pevent;
4809 4795
4810 if (field->flags & FIELD_IS_ARRAY) { 4796 if (field->flags & FIELD_IS_ARRAY) {
4811 offset = field->offset; 4797 offset = field->offset;
4812 len = field->size; 4798 len = field->size;
4813 if (field->flags & FIELD_IS_DYNAMIC) { 4799 if (field->flags & FIELD_IS_DYNAMIC) {
4814 val = pevent_read_number(pevent, data + offset, len); 4800 val = tep_read_number(pevent, data + offset, len);
4815 offset = val; 4801 offset = val;
4816 len = offset >> 16; 4802 len = offset >> 16;
4817 offset &= 0xffff; 4803 offset &= 0xffff;
@@ -4831,8 +4817,8 @@ void pevent_print_field(struct trace_seq *s, void *data,
4831 field->flags &= ~FIELD_IS_STRING; 4817 field->flags &= ~FIELD_IS_STRING;
4832 } 4818 }
4833 } else { 4819 } else {
4834 val = pevent_read_number(pevent, data + field->offset, 4820 val = tep_read_number(pevent, data + field->offset,
4835 field->size); 4821 field->size);
4836 if (field->flags & FIELD_IS_POINTER) { 4822 if (field->flags & FIELD_IS_POINTER) {
4837 trace_seq_printf(s, "0x%llx", val); 4823 trace_seq_printf(s, "0x%llx", val);
4838 } else if (field->flags & FIELD_IS_SIGNED) { 4824 } else if (field->flags & FIELD_IS_SIGNED) {
@@ -4865,22 +4851,22 @@ void pevent_print_field(struct trace_seq *s, void *data,
4865 } 4851 }
4866} 4852}
4867 4853
4868void pevent_print_fields(struct trace_seq *s, void *data, 4854void tep_print_fields(struct trace_seq *s, void *data,
4869 int size __maybe_unused, struct event_format *event) 4855 int size __maybe_unused, struct event_format *event)
4870{ 4856{
4871 struct format_field *field; 4857 struct format_field *field;
4872 4858
4873 field = event->format.fields; 4859 field = event->format.fields;
4874 while (field) { 4860 while (field) {
4875 trace_seq_printf(s, " %s=", field->name); 4861 trace_seq_printf(s, " %s=", field->name);
4876 pevent_print_field(s, data, field); 4862 tep_print_field(s, data, field);
4877 field = field->next; 4863 field = field->next;
4878 } 4864 }
4879} 4865}
4880 4866
4881static void pretty_print(struct trace_seq *s, void *data, int size, struct event_format *event) 4867static void pretty_print(struct trace_seq *s, void *data, int size, struct event_format *event)
4882{ 4868{
4883 struct pevent *pevent = event->pevent; 4869 struct tep_handle *pevent = event->pevent;
4884 struct print_fmt *print_fmt = &event->print_fmt; 4870 struct print_fmt *print_fmt = &event->print_fmt;
4885 struct print_arg *arg = print_fmt->args; 4871 struct print_arg *arg = print_fmt->args;
4886 struct print_arg *args = NULL; 4872 struct print_arg *args = NULL;
@@ -4899,7 +4885,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
4899 4885
4900 if (event->flags & EVENT_FL_FAILED) { 4886 if (event->flags & EVENT_FL_FAILED) {
4901 trace_seq_printf(s, "[FAILED TO PARSE]"); 4887 trace_seq_printf(s, "[FAILED TO PARSE]");
4902 pevent_print_fields(s, data, size, event); 4888 tep_print_fields(s, data, size, event);
4903 return; 4889 return;
4904 } 4890 }
4905 4891
@@ -5140,7 +5126,7 @@ out_failed:
5140} 5126}
5141 5127
5142/** 5128/**
5143 * pevent_data_lat_fmt - parse the data for the latency format 5129 * tep_data_lat_fmt - parse the data for the latency format
5144 * @pevent: a handle to the pevent 5130 * @pevent: a handle to the pevent
5145 * @s: the trace_seq to write to 5131 * @s: the trace_seq to write to
5146 * @record: the record to read from 5132 * @record: the record to read from
@@ -5149,8 +5135,8 @@ out_failed:
5149 * need rescheduling, in hard/soft interrupt, preempt count 5135 * need rescheduling, in hard/soft interrupt, preempt count
5150 * and lock depth) and places it into the trace_seq. 5136 * and lock depth) and places it into the trace_seq.
5151 */ 5137 */
5152void pevent_data_lat_fmt(struct pevent *pevent, 5138void tep_data_lat_fmt(struct tep_handle *pevent,
5153 struct trace_seq *s, struct pevent_record *record) 5139 struct trace_seq *s, struct tep_record *record)
5154{ 5140{
5155 static int check_lock_depth = 1; 5141 static int check_lock_depth = 1;
5156 static int check_migrate_disable = 1; 5142 static int check_migrate_disable = 1;
@@ -5223,55 +5209,55 @@ void pevent_data_lat_fmt(struct pevent *pevent,
5223} 5209}
5224 5210
5225/** 5211/**
5226 * pevent_data_type - parse out the given event type 5212 * tep_data_type - parse out the given event type
5227 * @pevent: a handle to the pevent 5213 * @pevent: a handle to the pevent
5228 * @rec: the record to read from 5214 * @rec: the record to read from
5229 * 5215 *
5230 * This returns the event id from the @rec. 5216 * This returns the event id from the @rec.
5231 */ 5217 */
5232int pevent_data_type(struct pevent *pevent, struct pevent_record *rec) 5218int tep_data_type(struct tep_handle *pevent, struct tep_record *rec)
5233{ 5219{
5234 return trace_parse_common_type(pevent, rec->data); 5220 return trace_parse_common_type(pevent, rec->data);
5235} 5221}
5236 5222
5237/** 5223/**
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
5239 * @pevent: a handle to the pevent 5225 * @pevent: a handle to the pevent
5240 * @type: the type of the event. 5226 * @type: the type of the event.
5241 * 5227 *
5242 * This returns the event form a given @type; 5228 * This returns the event form a given @type;
5243 */ 5229 */
5244struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type) 5230struct event_format *tep_data_event_from_type(struct tep_handle *pevent, int type)
5245{ 5231{
5246 return pevent_find_event(pevent, type); 5232 return tep_find_event(pevent, type);
5247} 5233}
5248 5234
5249/** 5235/**
5250 * pevent_data_pid - parse the PID from record 5236 * tep_data_pid - parse the PID from record
5251 * @pevent: a handle to the pevent 5237 * @pevent: a handle to the pevent
5252 * @rec: the record to parse 5238 * @rec: the record to parse
5253 * 5239 *
5254 * This returns the PID from a record. 5240 * This returns the PID from a record.
5255 */ 5241 */
5256int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec) 5242int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec)
5257{ 5243{
5258 return parse_common_pid(pevent, rec->data); 5244 return parse_common_pid(pevent, rec->data);
5259} 5245}
5260 5246
5261/** 5247/**
5262 * pevent_data_preempt_count - parse the preempt count from the record 5248 * tep_data_preempt_count - parse the preempt count from the record
5263 * @pevent: a handle to the pevent 5249 * @pevent: a handle to the pevent
5264 * @rec: the record to parse 5250 * @rec: the record to parse
5265 * 5251 *
5266 * This returns the preempt count from a record. 5252 * This returns the preempt count from a record.
5267 */ 5253 */
5268int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec) 5254int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec)
5269{ 5255{
5270 return parse_common_pc(pevent, rec->data); 5256 return parse_common_pc(pevent, rec->data);
5271} 5257}
5272 5258
5273/** 5259/**
5274 * pevent_data_flags - parse the latency flags from the record 5260 * tep_data_flags - parse the latency flags from the record
5275 * @pevent: a handle to the pevent 5261 * @pevent: a handle to the pevent
5276 * @rec: the record to parse 5262 * @rec: the record to parse
5277 * 5263 *
@@ -5279,20 +5265,20 @@ int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec)
5279 * 5265 *
5280 * Use trace_flag_type enum for the flags (see event-parse.h). 5266 * Use trace_flag_type enum for the flags (see event-parse.h).
5281 */ 5267 */
5282int pevent_data_flags(struct pevent *pevent, struct pevent_record *rec) 5268int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec)
5283{ 5269{
5284 return parse_common_flags(pevent, rec->data); 5270 return parse_common_flags(pevent, rec->data);
5285} 5271}
5286 5272
5287/** 5273/**
5288 * pevent_data_comm_from_pid - return the command line from PID 5274 * tep_data_comm_from_pid - return the command line from PID
5289 * @pevent: a handle to the pevent 5275 * @pevent: a handle to the pevent
5290 * @pid: the PID of the task to search for 5276 * @pid: the PID of the task to search for
5291 * 5277 *
5292 * This returns a pointer to the command line that has the given 5278 * This returns a pointer to the command line that has the given
5293 * @pid. 5279 * @pid.
5294 */ 5280 */
5295const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid) 5281const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid)
5296{ 5282{
5297 const char *comm; 5283 const char *comm;
5298 5284
@@ -5301,7 +5287,7 @@ const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid)
5301} 5287}
5302 5288
5303static struct cmdline * 5289static struct cmdline *
5304pid_from_cmdlist(struct pevent *pevent, const char *comm, struct cmdline *next) 5290pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *next)
5305{ 5291{
5306 struct cmdline_list *cmdlist = (struct cmdline_list *)next; 5292 struct cmdline_list *cmdlist = (struct cmdline_list *)next;
5307 5293
@@ -5317,7 +5303,7 @@ pid_from_cmdlist(struct pevent *pevent, const char *comm, struct cmdline *next)
5317} 5303}
5318 5304
5319/** 5305/**
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
5321 * @pevent: a handle to the pevent 5307 * @pevent: a handle to the pevent
5322 * @comm: the cmdline to find the pid from 5308 * @comm: the cmdline to find the pid from
5323 * @next: the cmdline structure to find the next comm 5309 * @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)
5329 * next pid. 5315 * next pid.
5330 * Also, it does a linear seach, so it may be slow. 5316 * Also, it does a linear seach, so it may be slow.
5331 */ 5317 */
5332struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *comm, 5318struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
5333 struct cmdline *next) 5319 struct cmdline *next)
5334{ 5320{
5335 struct cmdline *cmdline; 5321 struct cmdline *cmdline;
5336 5322
@@ -5365,13 +5351,13 @@ struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *com
5365} 5351}
5366 5352
5367/** 5353/**
5368 * pevent_cmdline_pid - return the pid associated to a given cmdline 5354 * tep_cmdline_pid - return the pid associated to a given cmdline
5369 * @cmdline: The cmdline structure to get the pid from 5355 * @cmdline: The cmdline structure to get the pid from
5370 * 5356 *
5371 * Returns the pid for a give cmdline. If @cmdline is NULL, then 5357 * Returns the pid for a give cmdline. If @cmdline is NULL, then
5372 * -1 is returned. 5358 * -1 is returned.
5373 */ 5359 */
5374int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline) 5360int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline)
5375{ 5361{
5376 struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline; 5362 struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline;
5377 5363
@@ -5391,7 +5377,7 @@ int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline)
5391} 5377}
5392 5378
5393/** 5379/**
5394 * pevent_data_comm_from_pid - parse the data into the print format 5380 * tep_event_info - parse the data into the print format
5395 * @s: the trace_seq to write to 5381 * @s: the trace_seq to write to
5396 * @event: the handle to the event 5382 * @event: the handle to the event
5397 * @record: the record to read from 5383 * @record: the record to read from
@@ -5399,13 +5385,13 @@ int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline)
5399 * This parses the raw @data using the given @event information and 5385 * This parses the raw @data using the given @event information and
5400 * writes the print format into the trace_seq. 5386 * writes the print format into the trace_seq.
5401 */ 5387 */
5402void pevent_event_info(struct trace_seq *s, struct event_format *event, 5388void tep_event_info(struct trace_seq *s, struct event_format *event,
5403 struct pevent_record *record) 5389 struct tep_record *record)
5404{ 5390{
5405 int print_pretty = 1; 5391 int print_pretty = 1;
5406 5392
5407 if (event->pevent->print_raw || (event->flags & EVENT_FL_PRINTRAW)) 5393 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);
5409 else { 5395 else {
5410 5396
5411 if (event->handler && !(event->flags & EVENT_FL_NOHANDLE)) 5397 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)
5433} 5419}
5434 5420
5435/** 5421/**
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
5437 * @pevent: a handle to the pevent 5423 * @pevent: a handle to the pevent
5438 * @record: The record to get the event from 5424 * @record: The record to get the event from
5439 * 5425 *
@@ -5441,7 +5427,7 @@ static bool is_timestamp_in_us(char *trace_clock, bool use_trace_clock)
5441 * is found. 5427 * is found.
5442 */ 5428 */
5443struct event_format * 5429struct event_format *
5444pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record) 5430tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record)
5445{ 5431{
5446 int type; 5432 int type;
5447 5433
@@ -5452,11 +5438,11 @@ pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record)
5452 5438
5453 type = trace_parse_common_type(pevent, record->data); 5439 type = trace_parse_common_type(pevent, record->data);
5454 5440
5455 return pevent_find_event(pevent, type); 5441 return tep_find_event(pevent, type);
5456} 5442}
5457 5443
5458/** 5444/**
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
5460 * @pevent: a handle to the pevent 5446 * @pevent: a handle to the pevent
5461 * @s: the trace_seq to write to 5447 * @s: the trace_seq to write to
5462 * @event: the handle to the record's event 5448 * @event: the handle to the record's event
@@ -5464,9 +5450,9 @@ pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record)
5464 * 5450 *
5465 * Writes the tasks comm, pid and CPU to @s. 5451 * Writes the tasks comm, pid and CPU to @s.
5466 */ 5452 */
5467void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s, 5453void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s,
5468 struct event_format *event, 5454 struct event_format *event,
5469 struct pevent_record *record) 5455 struct tep_record *record)
5470{ 5456{
5471 void *data = record->data; 5457 void *data = record->data;
5472 const char *comm; 5458 const char *comm;
@@ -5483,7 +5469,7 @@ void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s,
5483} 5469}
5484 5470
5485/** 5471/**
5486 * pevent_print_event_time - Write the event timestamp 5472 * tep_print_event_time - Write the event timestamp
5487 * @pevent: a handle to the pevent 5473 * @pevent: a handle to the pevent
5488 * @s: the trace_seq to write to 5474 * @s: the trace_seq to write to
5489 * @event: the handle to the record's event 5475 * @event: the handle to the record's event
@@ -5492,10 +5478,10 @@ void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s,
5492 * 5478 *
5493 * Writes the timestamp of the record into @s. 5479 * Writes the timestamp of the record into @s.
5494 */ 5480 */
5495void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, 5481void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s,
5496 struct event_format *event, 5482 struct event_format *event,
5497 struct pevent_record *record, 5483 struct tep_record *record,
5498 bool use_trace_clock) 5484 bool use_trace_clock)
5499{ 5485{
5500 unsigned long secs; 5486 unsigned long secs;
5501 unsigned long usecs; 5487 unsigned long usecs;
@@ -5511,11 +5497,11 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
5511 } 5497 }
5512 5498
5513 if (pevent->latency_format) { 5499 if (pevent->latency_format) {
5514 pevent_data_lat_fmt(pevent, s, record); 5500 tep_data_lat_fmt(pevent, s, record);
5515 } 5501 }
5516 5502
5517 if (use_usec_format) { 5503 if (use_usec_format) {
5518 if (pevent->flags & PEVENT_NSEC_OUTPUT) { 5504 if (pevent->flags & TEP_NSEC_OUTPUT) {
5519 usecs = nsecs; 5505 usecs = nsecs;
5520 p = 9; 5506 p = 9;
5521 } else { 5507 } else {
@@ -5534,7 +5520,7 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
5534} 5520}
5535 5521
5536/** 5522/**
5537 * pevent_print_event_data - Write the event data section 5523 * tep_print_event_data - Write the event data section
5538 * @pevent: a handle to the pevent 5524 * @pevent: a handle to the pevent
5539 * @s: the trace_seq to write to 5525 * @s: the trace_seq to write to
5540 * @event: the handle to the record's event 5526 * @event: the handle to the record's event
@@ -5542,9 +5528,9 @@ void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
5542 * 5528 *
5543 * Writes the parsing of the record's data to @s. 5529 * Writes the parsing of the record's data to @s.
5544 */ 5530 */
5545void pevent_print_event_data(struct pevent *pevent, struct trace_seq *s, 5531void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s,
5546 struct event_format *event, 5532 struct event_format *event,
5547 struct pevent_record *record) 5533 struct tep_record *record)
5548{ 5534{
5549 static const char *spaces = " "; /* 20 spaces */ 5535 static const char *spaces = " "; /* 20 spaces */
5550 int len; 5536 int len;
@@ -5556,15 +5542,15 @@ void pevent_print_event_data(struct pevent *pevent, struct trace_seq *s,
5556 if (len < 20) 5542 if (len < 20)
5557 trace_seq_printf(s, "%.*s", 20 - len, spaces); 5543 trace_seq_printf(s, "%.*s", 20 - len, spaces);
5558 5544
5559 pevent_event_info(s, event, record); 5545 tep_event_info(s, event, record);
5560} 5546}
5561 5547
5562void pevent_print_event(struct pevent *pevent, struct trace_seq *s, 5548void tep_print_event(struct tep_handle *pevent, struct trace_seq *s,
5563 struct pevent_record *record, bool use_trace_clock) 5549 struct tep_record *record, bool use_trace_clock)
5564{ 5550{
5565 struct event_format *event; 5551 struct event_format *event;
5566 5552
5567 event = pevent_find_event_by_record(pevent, record); 5553 event = tep_find_event_by_record(pevent, record);
5568 if (!event) { 5554 if (!event) {
5569 int i; 5555 int i;
5570 int type = trace_parse_common_type(pevent, record->data); 5556 int type = trace_parse_common_type(pevent, record->data);
@@ -5577,9 +5563,9 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
5577 return; 5563 return;
5578 } 5564 }
5579 5565
5580 pevent_print_event_task(pevent, s, event, record); 5566 tep_print_event_task(pevent, s, event, record);
5581 pevent_print_event_time(pevent, s, event, record, use_trace_clock); 5567 tep_print_event_time(pevent, s, event, record, use_trace_clock);
5582 pevent_print_event_data(pevent, s, event, record); 5568 tep_print_event_data(pevent, s, event, record);
5583} 5569}
5584 5570
5585static int events_id_cmp(const void *a, const void *b) 5571static 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)
5630 return events_id_cmp(a, b); 5616 return events_id_cmp(a, b);
5631} 5617}
5632 5618
5633struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type sort_type) 5619struct event_format **tep_list_events(struct tep_handle *pevent, enum event_sort_type sort_type)
5634{ 5620{
5635 struct event_format **events; 5621 struct event_format **events;
5636 int (*sort)(const void *a, const void *b); 5622 int (*sort)(const void *a, const void *b);
@@ -5709,13 +5695,13 @@ get_event_fields(const char *type, const char *name,
5709} 5695}
5710 5696
5711/** 5697/**
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
5713 * @event: the event to return the common fields of. 5699 * @event: the event to return the common fields of.
5714 * 5700 *
5715 * Returns an allocated array of fields. The last item in the array is NULL. 5701 * Returns an allocated array of fields. The last item in the array is NULL.
5716 * The array must be freed with free(). 5702 * The array must be freed with free().
5717 */ 5703 */
5718struct format_field **pevent_event_common_fields(struct event_format *event) 5704struct format_field **tep_event_common_fields(struct event_format *event)
5719{ 5705{
5720 return get_event_fields("common", event->name, 5706 return get_event_fields("common", event->name,
5721 event->format.nr_common, 5707 event->format.nr_common,
@@ -5723,13 +5709,13 @@ struct format_field **pevent_event_common_fields(struct event_format *event)
5723} 5709}
5724 5710
5725/** 5711/**
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
5727 * @event: the event to return the fields of. 5713 * @event: the event to return the fields of.
5728 * 5714 *
5729 * Returns an allocated array of fields. The last item in the array is NULL. 5715 * Returns an allocated array of fields. The last item in the array is NULL.
5730 * The array must be freed with free(). 5716 * The array must be freed with free().
5731 */ 5717 */
5732struct format_field **pevent_event_fields(struct event_format *event) 5718struct format_field **tep_event_fields(struct event_format *event)
5733{ 5719{
5734 return get_event_fields("event", event->name, 5720 return get_event_fields("event", event->name,
5735 event->format.nr_fields, 5721 event->format.nr_fields,
@@ -5930,7 +5916,7 @@ static void parse_header_field(const char *field,
5930} 5916}
5931 5917
5932/** 5918/**
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
5934 * @pevent: the handle to the pevent 5920 * @pevent: the handle to the pevent
5935 * @buf: the buffer storing the header page format string 5921 * @buf: the buffer storing the header page format string
5936 * @size: the size of @buf 5922 * @size: the size of @buf
@@ -5941,8 +5927,8 @@ static void parse_header_field(const char *field,
5941 * 5927 *
5942 * /sys/kernel/debug/tracing/events/header_page 5928 * /sys/kernel/debug/tracing/events/header_page
5943 */ 5929 */
5944int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long size, 5930int tep_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size,
5945 int long_size) 5931 int long_size)
5946{ 5932{
5947 int ignore; 5933 int ignore;
5948 5934
@@ -5994,7 +5980,7 @@ static void free_handler(struct event_handler *handle)
5994 free(handle); 5980 free(handle);
5995} 5981}
5996 5982
5997static int find_event_handle(struct pevent *pevent, struct event_format *event) 5983static int find_event_handle(struct tep_handle *pevent, struct event_format *event)
5998{ 5984{
5999 struct event_handler *handle, **next; 5985 struct event_handler *handle, **next;
6000 5986
@@ -6023,7 +6009,7 @@ static int find_event_handle(struct pevent *pevent, struct event_format *event)
6023} 6009}
6024 6010
6025/** 6011/**
6026 * __pevent_parse_format - parse the event format 6012 * __tep_parse_format - parse the event format
6027 * @buf: the buffer storing the event format string 6013 * @buf: the buffer storing the event format string
6028 * @size: the size of @buf 6014 * @size: the size of @buf
6029 * @sys: the system the event belongs to 6015 * @sys: the system the event belongs to
@@ -6035,9 +6021,9 @@ static int find_event_handle(struct pevent *pevent, struct event_format *event)
6035 * 6021 *
6036 * /sys/kernel/debug/tracing/events/.../.../format 6022 * /sys/kernel/debug/tracing/events/.../.../format
6037 */ 6023 */
6038enum pevent_errno __pevent_parse_format(struct event_format **eventp, 6024enum tep_errno __tep_parse_format(struct event_format **eventp,
6039 struct pevent *pevent, const char *buf, 6025 struct tep_handle *pevent, const char *buf,
6040 unsigned long size, const char *sys) 6026 unsigned long size, const char *sys)
6041{ 6027{
6042 struct event_format *event; 6028 struct event_format *event;
6043 int ret; 6029 int ret;
@@ -6046,12 +6032,12 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp,
6046 6032
6047 *eventp = event = alloc_event(); 6033 *eventp = event = alloc_event();
6048 if (!event) 6034 if (!event)
6049 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 6035 return TEP_ERRNO__MEM_ALLOC_FAILED;
6050 6036
6051 event->name = event_read_name(); 6037 event->name = event_read_name();
6052 if (!event->name) { 6038 if (!event->name) {
6053 /* Bad event? */ 6039 /* Bad event? */
6054 ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; 6040 ret = TEP_ERRNO__MEM_ALLOC_FAILED;
6055 goto event_alloc_failed; 6041 goto event_alloc_failed;
6056 } 6042 }
6057 6043
@@ -6064,7 +6050,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp,
6064 6050
6065 event->id = event_read_id(); 6051 event->id = event_read_id();
6066 if (event->id < 0) { 6052 if (event->id < 0) {
6067 ret = PEVENT_ERRNO__READ_ID_FAILED; 6053 ret = TEP_ERRNO__READ_ID_FAILED;
6068 /* 6054 /*
6069 * This isn't an allocation error actually. 6055 * This isn't an allocation error actually.
6070 * But as the ID is critical, just bail out. 6056 * But as the ID is critical, just bail out.
@@ -6074,7 +6060,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp,
6074 6060
6075 event->system = strdup(sys); 6061 event->system = strdup(sys);
6076 if (!event->system) { 6062 if (!event->system) {
6077 ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; 6063 ret = TEP_ERRNO__MEM_ALLOC_FAILED;
6078 goto event_alloc_failed; 6064 goto event_alloc_failed;
6079 } 6065 }
6080 6066
@@ -6083,7 +6069,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp,
6083 6069
6084 ret = event_read_format(event); 6070 ret = event_read_format(event);
6085 if (ret < 0) { 6071 if (ret < 0) {
6086 ret = PEVENT_ERRNO__READ_FORMAT_FAILED; 6072 ret = TEP_ERRNO__READ_FORMAT_FAILED;
6087 goto event_parse_failed; 6073 goto event_parse_failed;
6088 } 6074 }
6089 6075
@@ -6098,7 +6084,7 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp,
6098 show_warning = 1; 6084 show_warning = 1;
6099 6085
6100 if (ret < 0) { 6086 if (ret < 0) {
6101 ret = PEVENT_ERRNO__READ_PRINT_FAILED; 6087 ret = TEP_ERRNO__READ_PRINT_FAILED;
6102 goto event_parse_failed; 6088 goto event_parse_failed;
6103 } 6089 }
6104 6090
@@ -6112,14 +6098,14 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp,
6112 arg = alloc_arg(); 6098 arg = alloc_arg();
6113 if (!arg) { 6099 if (!arg) {
6114 event->flags |= EVENT_FL_FAILED; 6100 event->flags |= EVENT_FL_FAILED;
6115 return PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED; 6101 return TEP_ERRNO__OLD_FTRACE_ARG_FAILED;
6116 } 6102 }
6117 arg->type = PRINT_FIELD; 6103 arg->type = PRINT_FIELD;
6118 arg->field.name = strdup(field->name); 6104 arg->field.name = strdup(field->name);
6119 if (!arg->field.name) { 6105 if (!arg->field.name) {
6120 event->flags |= EVENT_FL_FAILED; 6106 event->flags |= EVENT_FL_FAILED;
6121 free_arg(arg); 6107 free_arg(arg);
6122 return PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED; 6108 return TEP_ERRNO__OLD_FTRACE_ARG_FAILED;
6123 } 6109 }
6124 arg->field.field = field; 6110 arg->field.field = field;
6125 *list = arg; 6111 *list = arg;
@@ -6142,20 +6128,20 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp,
6142 return ret; 6128 return ret;
6143} 6129}
6144 6130
6145static enum pevent_errno 6131static enum tep_errno
6146__pevent_parse_event(struct pevent *pevent, 6132__parse_event(struct tep_handle *pevent,
6147 struct event_format **eventp, 6133 struct event_format **eventp,
6148 const char *buf, unsigned long size, 6134 const char *buf, unsigned long size,
6149 const char *sys) 6135 const char *sys)
6150{ 6136{
6151 int ret = __pevent_parse_format(eventp, pevent, buf, size, sys); 6137 int ret = __tep_parse_format(eventp, pevent, buf, size, sys);
6152 struct event_format *event = *eventp; 6138 struct event_format *event = *eventp;
6153 6139
6154 if (event == NULL) 6140 if (event == NULL)
6155 return ret; 6141 return ret;
6156 6142
6157 if (pevent && add_event(pevent, event)) { 6143 if (pevent && add_event(pevent, event)) {
6158 ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; 6144 ret = TEP_ERRNO__MEM_ALLOC_FAILED;
6159 goto event_add_failed; 6145 goto event_add_failed;
6160 } 6146 }
6161 6147
@@ -6166,12 +6152,12 @@ __pevent_parse_event(struct pevent *pevent,
6166 return 0; 6152 return 0;
6167 6153
6168event_add_failed: 6154event_add_failed:
6169 pevent_free_format(event); 6155 tep_free_format(event);
6170 return ret; 6156 return ret;
6171} 6157}
6172 6158
6173/** 6159/**
6174 * pevent_parse_format - parse the event format 6160 * tep_parse_format - parse the event format
6175 * @pevent: the handle to the pevent 6161 * @pevent: the handle to the pevent
6176 * @eventp: returned format 6162 * @eventp: returned format
6177 * @buf: the buffer storing the event format string 6163 * @buf: the buffer storing the event format string
@@ -6185,16 +6171,16 @@ event_add_failed:
6185 * 6171 *
6186 * /sys/kernel/debug/tracing/events/.../.../format 6172 * /sys/kernel/debug/tracing/events/.../.../format
6187 */ 6173 */
6188enum pevent_errno pevent_parse_format(struct pevent *pevent, 6174enum tep_errno tep_parse_format(struct tep_handle *pevent,
6189 struct event_format **eventp, 6175 struct event_format **eventp,
6190 const char *buf, 6176 const char *buf,
6191 unsigned long size, const char *sys) 6177 unsigned long size, const char *sys)
6192{ 6178{
6193 return __pevent_parse_event(pevent, eventp, buf, size, sys); 6179 return __parse_event(pevent, eventp, buf, size, sys);
6194} 6180}
6195 6181
6196/** 6182/**
6197 * pevent_parse_event - parse the event format 6183 * tep_parse_event - parse the event format
6198 * @pevent: the handle to the pevent 6184 * @pevent: the handle to the pevent
6199 * @buf: the buffer storing the event format string 6185 * @buf: the buffer storing the event format string
6200 * @size: the size of @buf 6186 * @size: the size of @buf
@@ -6207,22 +6193,22 @@ enum pevent_errno pevent_parse_format(struct pevent *pevent,
6207 * 6193 *
6208 * /sys/kernel/debug/tracing/events/.../.../format 6194 * /sys/kernel/debug/tracing/events/.../.../format
6209 */ 6195 */
6210enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf, 6196enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf,
6211 unsigned long size, const char *sys) 6197 unsigned long size, const char *sys)
6212{ 6198{
6213 struct event_format *event = NULL; 6199 struct event_format *event = NULL;
6214 return __pevent_parse_event(pevent, &event, buf, size, sys); 6200 return __parse_event(pevent, &event, buf, size, sys);
6215} 6201}
6216 6202
6217#undef _PE 6203#undef _PE
6218#define _PE(code, str) str 6204#define _PE(code, str) str
6219static const char * const pevent_error_str[] = { 6205static const char * const tep_error_str[] = {
6220 PEVENT_ERRORS 6206 TEP_ERRORS
6221}; 6207};
6222#undef _PE 6208#undef _PE
6223 6209
6224int pevent_strerror(struct pevent *pevent __maybe_unused, 6210int tep_strerror(struct tep_handle *pevent __maybe_unused,
6225 enum pevent_errno errnum, char *buf, size_t buflen) 6211 enum tep_errno errnum, char *buf, size_t buflen)
6226{ 6212{
6227 int idx; 6213 int idx;
6228 const char *msg; 6214 const char *msg;
@@ -6232,19 +6218,19 @@ int pevent_strerror(struct pevent *pevent __maybe_unused,
6232 return 0; 6218 return 0;
6233 } 6219 }
6234 6220
6235 if (errnum <= __PEVENT_ERRNO__START || 6221 if (errnum <= __TEP_ERRNO__START ||
6236 errnum >= __PEVENT_ERRNO__END) 6222 errnum >= __TEP_ERRNO__END)
6237 return -1; 6223 return -1;
6238 6224
6239 idx = errnum - __PEVENT_ERRNO__START - 1; 6225 idx = errnum - __TEP_ERRNO__START - 1;
6240 msg = pevent_error_str[idx]; 6226 msg = tep_error_str[idx];
6241 snprintf(buf, buflen, "%s", msg); 6227 snprintf(buf, buflen, "%s", msg);
6242 6228
6243 return 0; 6229 return 0;
6244} 6230}
6245 6231
6246int get_field_val(struct trace_seq *s, struct format_field *field, 6232int 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,
6248 unsigned long long *val, int err) 6234 unsigned long long *val, int err)
6249{ 6235{
6250 if (!field) { 6236 if (!field) {
@@ -6253,7 +6239,7 @@ int get_field_val(struct trace_seq *s, struct format_field *field,
6253 return -1; 6239 return -1;
6254 } 6240 }
6255 6241
6256 if (pevent_read_number_field(field, record->data, val)) { 6242 if (tep_read_number_field(field, record->data, val)) {
6257 if (err) 6243 if (err)
6258 trace_seq_printf(s, " %s=INVALID", name); 6244 trace_seq_printf(s, " %s=INVALID", name);
6259 return -1; 6245 return -1;
@@ -6263,7 +6249,7 @@ int get_field_val(struct trace_seq *s, struct format_field *field,
6263} 6249}
6264 6250
6265/** 6251/**
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
6267 * @s: The seq to print to on error 6253 * @s: The seq to print to on error
6268 * @event: the event that the field is for 6254 * @event: the event that the field is for
6269 * @name: The name of the field 6255 * @name: The name of the field
@@ -6276,9 +6262,9 @@ int get_field_val(struct trace_seq *s, struct format_field *field,
6276 * 6262 *
6277 * On failure, it returns NULL. 6263 * On failure, it returns NULL.
6278 */ 6264 */
6279void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, 6265void *tep_get_field_raw(struct trace_seq *s, struct event_format *event,
6280 const char *name, struct pevent_record *record, 6266 const char *name, struct tep_record *record,
6281 int *len, int err) 6267 int *len, int err)
6282{ 6268{
6283 struct format_field *field; 6269 struct format_field *field;
6284 void *data = record->data; 6270 void *data = record->data;
@@ -6288,7 +6274,7 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
6288 if (!event) 6274 if (!event)
6289 return NULL; 6275 return NULL;
6290 6276
6291 field = pevent_find_field(event, name); 6277 field = tep_find_field(event, name);
6292 6278
6293 if (!field) { 6279 if (!field) {
6294 if (err) 6280 if (err)
@@ -6302,7 +6288,7 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
6302 6288
6303 offset = field->offset; 6289 offset = field->offset;
6304 if (field->flags & FIELD_IS_DYNAMIC) { 6290 if (field->flags & FIELD_IS_DYNAMIC) {
6305 offset = pevent_read_number(event->pevent, 6291 offset = tep_read_number(event->pevent,
6306 data + offset, field->size); 6292 data + offset, field->size);
6307 *len = offset >> 16; 6293 *len = offset >> 16;
6308 offset &= 0xffff; 6294 offset &= 0xffff;
@@ -6313,7 +6299,7 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
6313} 6299}
6314 6300
6315/** 6301/**
6316 * pevent_get_field_val - find a field and return its value 6302 * tep_get_field_val - find a field and return its value
6317 * @s: The seq to print to on error 6303 * @s: The seq to print to on error
6318 * @event: the event that the field is for 6304 * @event: the event that the field is for
6319 * @name: The name of the field 6305 * @name: The name of the field
@@ -6323,22 +6309,22 @@ void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
6323 * 6309 *
6324 * Returns 0 on success -1 on field not found. 6310 * Returns 0 on success -1 on field not found.
6325 */ 6311 */
6326int pevent_get_field_val(struct trace_seq *s, struct event_format *event, 6312int tep_get_field_val(struct trace_seq *s, struct event_format *event,
6327 const char *name, struct pevent_record *record, 6313 const char *name, struct tep_record *record,
6328 unsigned long long *val, int err) 6314 unsigned long long *val, int err)
6329{ 6315{
6330 struct format_field *field; 6316 struct format_field *field;
6331 6317
6332 if (!event) 6318 if (!event)
6333 return -1; 6319 return -1;
6334 6320
6335 field = pevent_find_field(event, name); 6321 field = tep_find_field(event, name);
6336 6322
6337 return get_field_val(s, field, name, record, val, err); 6323 return get_field_val(s, field, name, record, val, err);
6338} 6324}
6339 6325
6340/** 6326/**
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
6342 * @s: The seq to print to on error 6328 * @s: The seq to print to on error
6343 * @event: the event that the field is for 6329 * @event: the event that the field is for
6344 * @name: The name of the field 6330 * @name: The name of the field
@@ -6348,22 +6334,22 @@ int pevent_get_field_val(struct trace_seq *s, struct event_format *event,
6348 * 6334 *
6349 * Returns 0 on success -1 on field not found. 6335 * Returns 0 on success -1 on field not found.
6350 */ 6336 */
6351int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event, 6337int tep_get_common_field_val(struct trace_seq *s, struct event_format *event,
6352 const char *name, struct pevent_record *record, 6338 const char *name, struct tep_record *record,
6353 unsigned long long *val, int err) 6339 unsigned long long *val, int err)
6354{ 6340{
6355 struct format_field *field; 6341 struct format_field *field;
6356 6342
6357 if (!event) 6343 if (!event)
6358 return -1; 6344 return -1;
6359 6345
6360 field = pevent_find_common_field(event, name); 6346 field = tep_find_common_field(event, name);
6361 6347
6362 return get_field_val(s, field, name, record, val, err); 6348 return get_field_val(s, field, name, record, val, err);
6363} 6349}
6364 6350
6365/** 6351/**
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
6367 * @s: The seq to print to on error 6353 * @s: The seq to print to on error
6368 * @event: the event that the field is for 6354 * @event: the event that the field is for
6369 * @name: The name of the field 6355 * @name: The name of the field
@@ -6373,22 +6359,22 @@ int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event,
6373 * 6359 *
6374 * Returns 0 on success -1 on field not found. 6360 * Returns 0 on success -1 on field not found.
6375 */ 6361 */
6376int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event, 6362int tep_get_any_field_val(struct trace_seq *s, struct event_format *event,
6377 const char *name, struct pevent_record *record, 6363 const char *name, struct tep_record *record,
6378 unsigned long long *val, int err) 6364 unsigned long long *val, int err)
6379{ 6365{
6380 struct format_field *field; 6366 struct format_field *field;
6381 6367
6382 if (!event) 6368 if (!event)
6383 return -1; 6369 return -1;
6384 6370
6385 field = pevent_find_any_field(event, name); 6371 field = tep_find_any_field(event, name);
6386 6372
6387 return get_field_val(s, field, name, record, val, err); 6373 return get_field_val(s, field, name, record, val, err);
6388} 6374}
6389 6375
6390/** 6376/**
6391 * pevent_print_num_field - print a field and a format 6377 * tep_print_num_field - print a field and a format
6392 * @s: The seq to print to 6378 * @s: The seq to print to
6393 * @fmt: The printf format to print the field with. 6379 * @fmt: The printf format to print the field with.
6394 * @event: the event that the field is for 6380 * @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,
6398 * 6384 *
6399 * Returns: 0 on success, -1 field not found, or 1 if buffer is full. 6385 * Returns: 0 on success, -1 field not found, or 1 if buffer is full.
6400 */ 6386 */
6401int pevent_print_num_field(struct trace_seq *s, const char *fmt, 6387int tep_print_num_field(struct trace_seq *s, const char *fmt,
6402 struct event_format *event, const char *name, 6388 struct event_format *event, const char *name,
6403 struct pevent_record *record, int err) 6389 struct tep_record *record, int err)
6404{ 6390{
6405 struct format_field *field = pevent_find_field(event, name); 6391 struct format_field *field = tep_find_field(event, name);
6406 unsigned long long val; 6392 unsigned long long val;
6407 6393
6408 if (!field) 6394 if (!field)
6409 goto failed; 6395 goto failed;
6410 6396
6411 if (pevent_read_number_field(field, record->data, &val)) 6397 if (tep_read_number_field(field, record->data, &val))
6412 goto failed; 6398 goto failed;
6413 6399
6414 return trace_seq_printf(s, fmt, val); 6400 return trace_seq_printf(s, fmt, val);
@@ -6420,7 +6406,7 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt,
6420} 6406}
6421 6407
6422/** 6408/**
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
6424 * @s: The seq to print to 6410 * @s: The seq to print to
6425 * @fmt: The printf format to print the field with. 6411 * @fmt: The printf format to print the field with.
6426 * @event: the event that the field is for 6412 * @event: the event that the field is for
@@ -6430,12 +6416,12 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt,
6430 * 6416 *
6431 * Returns: 0 on success, -1 field not found, or 1 if buffer is full. 6417 * Returns: 0 on success, -1 field not found, or 1 if buffer is full.
6432 */ 6418 */
6433int pevent_print_func_field(struct trace_seq *s, const char *fmt, 6419int tep_print_func_field(struct trace_seq *s, const char *fmt,
6434 struct event_format *event, const char *name, 6420 struct event_format *event, const char *name,
6435 struct pevent_record *record, int err) 6421 struct tep_record *record, int err)
6436{ 6422{
6437 struct format_field *field = pevent_find_field(event, name); 6423 struct format_field *field = tep_find_field(event, name);
6438 struct pevent *pevent = event->pevent; 6424 struct tep_handle *pevent = event->pevent;
6439 unsigned long long val; 6425 unsigned long long val;
6440 struct func_map *func; 6426 struct func_map *func;
6441 char tmp[128]; 6427 char tmp[128];
@@ -6443,7 +6429,7 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt,
6443 if (!field) 6429 if (!field)
6444 goto failed; 6430 goto failed;
6445 6431
6446 if (pevent_read_number_field(field, record->data, &val)) 6432 if (tep_read_number_field(field, record->data, &val))
6447 goto failed; 6433 goto failed;
6448 6434
6449 func = find_func(pevent, val); 6435 func = find_func(pevent, val);
@@ -6461,9 +6447,9 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt,
6461 return -1; 6447 return -1;
6462} 6448}
6463 6449
6464static void free_func_handle(struct pevent_function_handler *func) 6450static void free_func_handle(struct tep_function_handler *func)
6465{ 6451{
6466 struct pevent_func_params *params; 6452 struct func_params *params;
6467 6453
6468 free(func->name); 6454 free(func->name);
6469 6455
@@ -6477,29 +6463,29 @@ static void free_func_handle(struct pevent_function_handler *func)
6477} 6463}
6478 6464
6479/** 6465/**
6480 * pevent_register_print_function - register a helper function 6466 * tep_register_print_function - register a helper function
6481 * @pevent: the handle to the pevent 6467 * @pevent: the handle to the pevent
6482 * @func: the function to process the helper function 6468 * @func: the function to process the helper function
6483 * @ret_type: the return type of the helper function 6469 * @ret_type: the return type of the helper function
6484 * @name: the name of the helper function 6470 * @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
6486 * 6472 *
6487 * Some events may have helper functions in the print format arguments. 6473 * Some events may have helper functions in the print format arguments.
6488 * This allows a plugin to dynamically create a way to process one 6474 * This allows a plugin to dynamically create a way to process one
6489 * of these functions. 6475 * of these functions.
6490 * 6476 *
6491 * The @parameters is a variable list of pevent_func_arg_type enums that 6477 * The @parameters is a variable list of tep_func_arg_type enums that
6492 * must end with PEVENT_FUNC_ARG_VOID. 6478 * must end with TEP_FUNC_ARG_VOID.
6493 */ 6479 */
6494int pevent_register_print_function(struct pevent *pevent, 6480int tep_register_print_function(struct tep_handle *pevent,
6495 pevent_func_handler func, 6481 tep_func_handler func,
6496 enum pevent_func_arg_type ret_type, 6482 enum tep_func_arg_type ret_type,
6497 char *name, ...) 6483 char *name, ...)
6498{ 6484{
6499 struct pevent_function_handler *func_handle; 6485 struct tep_function_handler *func_handle;
6500 struct pevent_func_params **next_param; 6486 struct func_params **next_param;
6501 struct pevent_func_params *param; 6487 struct func_params *param;
6502 enum pevent_func_arg_type type; 6488 enum tep_func_arg_type type;
6503 va_list ap; 6489 va_list ap;
6504 int ret; 6490 int ret;
6505 6491
@@ -6517,7 +6503,7 @@ int pevent_register_print_function(struct pevent *pevent,
6517 func_handle = calloc(1, sizeof(*func_handle)); 6503 func_handle = calloc(1, sizeof(*func_handle));
6518 if (!func_handle) { 6504 if (!func_handle) {
6519 do_warning("Failed to allocate function handler"); 6505 do_warning("Failed to allocate function handler");
6520 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 6506 return TEP_ERRNO__MEM_ALLOC_FAILED;
6521 } 6507 }
6522 6508
6523 func_handle->ret_type = ret_type; 6509 func_handle->ret_type = ret_type;
@@ -6526,26 +6512,26 @@ int pevent_register_print_function(struct pevent *pevent,
6526 if (!func_handle->name) { 6512 if (!func_handle->name) {
6527 do_warning("Failed to allocate function name"); 6513 do_warning("Failed to allocate function name");
6528 free(func_handle); 6514 free(func_handle);
6529 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 6515 return TEP_ERRNO__MEM_ALLOC_FAILED;
6530 } 6516 }
6531 6517
6532 next_param = &(func_handle->params); 6518 next_param = &(func_handle->params);
6533 va_start(ap, name); 6519 va_start(ap, name);
6534 for (;;) { 6520 for (;;) {
6535 type = va_arg(ap, enum pevent_func_arg_type); 6521 type = va_arg(ap, enum tep_func_arg_type);
6536 if (type == PEVENT_FUNC_ARG_VOID) 6522 if (type == TEP_FUNC_ARG_VOID)
6537 break; 6523 break;
6538 6524
6539 if (type >= PEVENT_FUNC_ARG_MAX_TYPES) { 6525 if (type >= TEP_FUNC_ARG_MAX_TYPES) {
6540 do_warning("Invalid argument type %d", type); 6526 do_warning("Invalid argument type %d", type);
6541 ret = PEVENT_ERRNO__INVALID_ARG_TYPE; 6527 ret = TEP_ERRNO__INVALID_ARG_TYPE;
6542 goto out_free; 6528 goto out_free;
6543 } 6529 }
6544 6530
6545 param = malloc(sizeof(*param)); 6531 param = malloc(sizeof(*param));
6546 if (!param) { 6532 if (!param) {
6547 do_warning("Failed to allocate function param"); 6533 do_warning("Failed to allocate function param");
6548 ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; 6534 ret = TEP_ERRNO__MEM_ALLOC_FAILED;
6549 goto out_free; 6535 goto out_free;
6550 } 6536 }
6551 param->type = type; 6537 param->type = type;
@@ -6569,7 +6555,7 @@ int pevent_register_print_function(struct pevent *pevent,
6569} 6555}
6570 6556
6571/** 6557/**
6572 * pevent_unregister_print_function - unregister a helper function 6558 * tep_unregister_print_function - unregister a helper function
6573 * @pevent: the handle to the pevent 6559 * @pevent: the handle to the pevent
6574 * @func: the function to process the helper function 6560 * @func: the function to process the helper function
6575 * @name: the name of the helper function 6561 * @name: the name of the helper function
@@ -6578,10 +6564,10 @@ int pevent_register_print_function(struct pevent *pevent,
6578 * 6564 *
6579 * Returns 0 if the handler was removed successully, -1 otherwise. 6565 * Returns 0 if the handler was removed successully, -1 otherwise.
6580 */ 6566 */
6581int pevent_unregister_print_function(struct pevent *pevent, 6567int tep_unregister_print_function(struct tep_handle *pevent,
6582 pevent_func_handler func, char *name) 6568 tep_func_handler func, char *name)
6583{ 6569{
6584 struct pevent_function_handler *func_handle; 6570 struct tep_function_handler *func_handle;
6585 6571
6586 func_handle = find_func_handler(pevent, name); 6572 func_handle = find_func_handler(pevent, name);
6587 if (func_handle && func_handle->func == func) { 6573 if (func_handle && func_handle->func == func) {
@@ -6591,15 +6577,15 @@ int pevent_unregister_print_function(struct pevent *pevent,
6591 return -1; 6577 return -1;
6592} 6578}
6593 6579
6594static struct event_format *pevent_search_event(struct pevent *pevent, int id, 6580static struct event_format *search_event(struct tep_handle *pevent, int id,
6595 const char *sys_name, 6581 const char *sys_name,
6596 const char *event_name) 6582 const char *event_name)
6597{ 6583{
6598 struct event_format *event; 6584 struct event_format *event;
6599 6585
6600 if (id >= 0) { 6586 if (id >= 0) {
6601 /* search by id */ 6587 /* search by id */
6602 event = pevent_find_event(pevent, id); 6588 event = tep_find_event(pevent, id);
6603 if (!event) 6589 if (!event)
6604 return NULL; 6590 return NULL;
6605 if (event_name && (strcmp(event_name, event->name) != 0)) 6591 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,
6607 if (sys_name && (strcmp(sys_name, event->system) != 0)) 6593 if (sys_name && (strcmp(sys_name, event->system) != 0))
6608 return NULL; 6594 return NULL;
6609 } else { 6595 } 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);
6611 if (!event) 6597 if (!event)
6612 return NULL; 6598 return NULL;
6613 } 6599 }
@@ -6615,7 +6601,7 @@ static struct event_format *pevent_search_event(struct pevent *pevent, int id,
6615} 6601}
6616 6602
6617/** 6603/**
6618 * pevent_register_event_handler - register a way to parse an event 6604 * tep_register_event_handler - register a way to parse an event
6619 * @pevent: the handle to the pevent 6605 * @pevent: the handle to the pevent
6620 * @id: the id of the event to register 6606 * @id: the id of the event to register
6621 * @sys_name: the system name the event belongs to 6607 * @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,
6631 * If @id is >= 0, then it is used to find the event. 6617 * If @id is >= 0, then it is used to find the event.
6632 * else @sys_name and @event_name are used. 6618 * else @sys_name and @event_name are used.
6633 */ 6619 */
6634int pevent_register_event_handler(struct pevent *pevent, int id, 6620int tep_register_event_handler(struct tep_handle *pevent, int id,
6635 const char *sys_name, const char *event_name, 6621 const char *sys_name, const char *event_name,
6636 pevent_event_handler_func func, void *context) 6622 tep_event_handler_func func, void *context)
6637{ 6623{
6638 struct event_format *event; 6624 struct event_format *event;
6639 struct event_handler *handle; 6625 struct event_handler *handle;
6640 6626
6641 event = pevent_search_event(pevent, id, sys_name, event_name); 6627 event = search_event(pevent, id, sys_name, event_name);
6642 if (event == NULL) 6628 if (event == NULL)
6643 goto not_found; 6629 goto not_found;
6644 6630
@@ -6654,7 +6640,7 @@ int pevent_register_event_handler(struct pevent *pevent, int id,
6654 handle = calloc(1, sizeof(*handle)); 6640 handle = calloc(1, sizeof(*handle));
6655 if (!handle) { 6641 if (!handle) {
6656 do_warning("Failed to allocate event handler"); 6642 do_warning("Failed to allocate event handler");
6657 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 6643 return TEP_ERRNO__MEM_ALLOC_FAILED;
6658 } 6644 }
6659 6645
6660 handle->id = id; 6646 handle->id = id;
@@ -6669,7 +6655,7 @@ int pevent_register_event_handler(struct pevent *pevent, int id,
6669 free((void *)handle->event_name); 6655 free((void *)handle->event_name);
6670 free((void *)handle->sys_name); 6656 free((void *)handle->sys_name);
6671 free(handle); 6657 free(handle);
6672 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 6658 return TEP_ERRNO__MEM_ALLOC_FAILED;
6673 } 6659 }
6674 6660
6675 handle->func = func; 6661 handle->func = func;
@@ -6682,7 +6668,7 @@ int pevent_register_event_handler(struct pevent *pevent, int id,
6682 6668
6683static int handle_matches(struct event_handler *handler, int id, 6669static int handle_matches(struct event_handler *handler, int id,
6684 const char *sys_name, const char *event_name, 6670 const char *sys_name, const char *event_name,
6685 pevent_event_handler_func func, void *context) 6671 tep_event_handler_func func, void *context)
6686{ 6672{
6687 if (id >= 0 && id != handler->id) 6673 if (id >= 0 && id != handler->id)
6688 return 0; 6674 return 0;
@@ -6700,7 +6686,7 @@ static int handle_matches(struct event_handler *handler, int id,
6700} 6686}
6701 6687
6702/** 6688/**
6703 * pevent_unregister_event_handler - unregister an existing event handler 6689 * tep_unregister_event_handler - unregister an existing event handler
6704 * @pevent: the handle to the pevent 6690 * @pevent: the handle to the pevent
6705 * @id: the id of the event to unregister 6691 * @id: the id of the event to unregister
6706 * @sys_name: the system name the handler belongs to 6692 * @sys_name: the system name the handler belongs to
@@ -6715,15 +6701,15 @@ static int handle_matches(struct event_handler *handler, int id,
6715 * 6701 *
6716 * Returns 0 if handler was removed successfully, -1 if event was not found. 6702 * Returns 0 if handler was removed successfully, -1 if event was not found.
6717 */ 6703 */
6718int pevent_unregister_event_handler(struct pevent *pevent, int id, 6704int tep_unregister_event_handler(struct tep_handle *pevent, int id,
6719 const char *sys_name, const char *event_name, 6705 const char *sys_name, const char *event_name,
6720 pevent_event_handler_func func, void *context) 6706 tep_event_handler_func func, void *context)
6721{ 6707{
6722 struct event_format *event; 6708 struct event_format *event;
6723 struct event_handler *handle; 6709 struct event_handler *handle;
6724 struct event_handler **next; 6710 struct event_handler **next;
6725 6711
6726 event = pevent_search_event(pevent, id, sys_name, event_name); 6712 event = search_event(pevent, id, sys_name, event_name);
6727 if (event == NULL) 6713 if (event == NULL)
6728 goto not_found; 6714 goto not_found;
6729 6715
@@ -6754,11 +6740,11 @@ not_found:
6754} 6740}
6755 6741
6756/** 6742/**
6757 * pevent_alloc - create a pevent handle 6743 * tep_alloc - create a pevent handle
6758 */ 6744 */
6759struct pevent *pevent_alloc(void) 6745struct tep_handle *tep_alloc(void)
6760{ 6746{
6761 struct pevent *pevent = calloc(1, sizeof(*pevent)); 6747 struct tep_handle *pevent = calloc(1, sizeof(*pevent));
6762 6748
6763 if (pevent) 6749 if (pevent)
6764 pevent->ref_count = 1; 6750 pevent->ref_count = 1;
@@ -6766,12 +6752,12 @@ struct pevent *pevent_alloc(void)
6766 return pevent; 6752 return pevent;
6767} 6753}
6768 6754
6769void pevent_ref(struct pevent *pevent) 6755void tep_ref(struct tep_handle *pevent)
6770{ 6756{
6771 pevent->ref_count++; 6757 pevent->ref_count++;
6772} 6758}
6773 6759
6774void pevent_free_format_field(struct format_field *field) 6760void tep_free_format_field(struct format_field *field)
6775{ 6761{
6776 free(field->type); 6762 free(field->type);
6777 if (field->alias != field->name) 6763 if (field->alias != field->name)
@@ -6786,7 +6772,7 @@ static void free_format_fields(struct format_field *field)
6786 6772
6787 while (field) { 6773 while (field) {
6788 next = field->next; 6774 next = field->next;
6789 pevent_free_format_field(field); 6775 tep_free_format_field(field);
6790 field = next; 6776 field = next;
6791 } 6777 }
6792} 6778}
@@ -6797,7 +6783,7 @@ static void free_formats(struct format *format)
6797 free_format_fields(format->fields); 6783 free_format_fields(format->fields);
6798} 6784}
6799 6785
6800void pevent_free_format(struct event_format *event) 6786void tep_free_format(struct event_format *event)
6801{ 6787{
6802 free(event->name); 6788 free(event->name);
6803 free(event->system); 6789 free(event->system);
@@ -6811,15 +6797,15 @@ void pevent_free_format(struct event_format *event)
6811} 6797}
6812 6798
6813/** 6799/**
6814 * pevent_free - free a pevent handle 6800 * tep_free - free a pevent handle
6815 * @pevent: the pevent handle to free 6801 * @pevent: the pevent handle to free
6816 */ 6802 */
6817void pevent_free(struct pevent *pevent) 6803void tep_free(struct tep_handle *pevent)
6818{ 6804{
6819 struct cmdline_list *cmdlist, *cmdnext; 6805 struct cmdline_list *cmdlist, *cmdnext;
6820 struct func_list *funclist, *funcnext; 6806 struct func_list *funclist, *funcnext;
6821 struct printk_list *printklist, *printknext; 6807 struct printk_list *printklist, *printknext;
6822 struct pevent_function_handler *func_handler; 6808 struct tep_function_handler *func_handler;
6823 struct event_handler *handle; 6809 struct event_handler *handle;
6824 int i; 6810 int i;
6825 6811
@@ -6883,7 +6869,7 @@ void pevent_free(struct pevent *pevent)
6883 } 6869 }
6884 6870
6885 for (i = 0; i < pevent->nr_events; i++) 6871 for (i = 0; i < pevent->nr_events; i++)
6886 pevent_free_format(pevent->events[i]); 6872 tep_free_format(pevent->events[i]);
6887 6873
6888 while (pevent->handlers) { 6874 while (pevent->handlers) {
6889 handle = pevent->handlers; 6875 handle = pevent->handlers;
@@ -6899,7 +6885,7 @@ void pevent_free(struct pevent *pevent)
6899 free(pevent); 6885 free(pevent);
6900} 6886}
6901 6887
6902void pevent_unref(struct pevent *pevent) 6888void tep_unref(struct tep_handle *pevent)
6903{ 6889{
6904 pevent_free(pevent); 6890 tep_free(pevent);
6905} 6891}
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 0c03538df74c..44b7c2d41f9f 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -41,7 +41,7 @@
41#define DEBUG_RECORD 0 41#define DEBUG_RECORD 0
42#endif 42#endif
43 43
44struct pevent_record { 44struct tep_record {
45 unsigned long long ts; 45 unsigned long long ts;
46 unsigned long long offset; 46 unsigned long long offset;
47 long long missed_events; /* buffer dropped events before */ 47 long long missed_events; /* buffer dropped events before */
@@ -53,8 +53,8 @@ struct pevent_record {
53 int locked; /* Do not free, even if ref_count is zero */ 53 int locked; /* Do not free, even if ref_count is zero */
54 void *priv; 54 void *priv;
55#if DEBUG_RECORD 55#if DEBUG_RECORD
56 struct pevent_record *prev; 56 struct tep_record *prev;
57 struct pevent_record *next; 57 struct tep_record *next;
58 long alloc_addr; 58 long alloc_addr;
59#endif 59#endif
60}; 60};
@@ -98,19 +98,19 @@ extern int trace_seq_do_printf(struct trace_seq *s);
98 98
99/* ----------------------- pevent ----------------------- */ 99/* ----------------------- pevent ----------------------- */
100 100
101struct pevent; 101struct tep_handle;
102struct event_format; 102struct event_format;
103 103
104typedef int (*pevent_event_handler_func)(struct trace_seq *s, 104typedef int (*tep_event_handler_func)(struct trace_seq *s,
105 struct pevent_record *record, 105 struct tep_record *record,
106 struct event_format *event, 106 struct event_format *event,
107 void *context); 107 void *context);
108 108
109typedef int (*pevent_plugin_load_func)(struct pevent *pevent); 109typedef int (*tep_plugin_load_func)(struct tep_handle *pevent);
110typedef int (*pevent_plugin_unload_func)(struct pevent *pevent); 110typedef int (*tep_plugin_unload_func)(struct tep_handle *pevent);
111 111
112struct pevent_plugin_option { 112struct tep_plugin_option {
113 struct pevent_plugin_option *next; 113 struct tep_plugin_option *next;
114 void *handle; 114 void *handle;
115 char *file; 115 char *file;
116 char *name; 116 char *name;
@@ -124,20 +124,20 @@ struct pevent_plugin_option {
124/* 124/*
125 * Plugin hooks that can be called: 125 * Plugin hooks that can be called:
126 * 126 *
127 * PEVENT_PLUGIN_LOADER: (required) 127 * TEP_PLUGIN_LOADER: (required)
128 * The function name to initialized the plugin. 128 * The function name to initialized the plugin.
129 * 129 *
130 * int PEVENT_PLUGIN_LOADER(struct pevent *pevent) 130 * int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
131 * 131 *
132 * PEVENT_PLUGIN_UNLOADER: (optional) 132 * TEP_PLUGIN_UNLOADER: (optional)
133 * The function called just before unloading 133 * The function called just before unloading
134 * 134 *
135 * int PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) 135 * int TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
136 * 136 *
137 * PEVENT_PLUGIN_OPTIONS: (optional) 137 * TEP_PLUGIN_OPTIONS: (optional)
138 * Plugin options that can be set before loading 138 * Plugin options that can be set before loading
139 * 139 *
140 * struct pevent_plugin_option PEVENT_PLUGIN_OPTIONS[] = { 140 * struct tep_plugin_option TEP_PLUGIN_OPTIONS[] = {
141 * { 141 * {
142 * .name = "option-name", 142 * .name = "option-name",
143 * .plugin_alias = "override-file-name", (optional) 143 * .plugin_alias = "override-file-name", (optional)
@@ -158,19 +158,19 @@ struct pevent_plugin_option {
158 * .set will be processed. If .value is defined, then it is considered 158 * .set will be processed. If .value is defined, then it is considered
159 * a string option and .set will be ignored. 159 * a string option and .set will be ignored.
160 * 160 *
161 * PEVENT_PLUGIN_ALIAS: (optional) 161 * TEP_PLUGIN_ALIAS: (optional)
162 * The name to use for finding options (uses filename if not defined) 162 * The name to use for finding options (uses filename if not defined)
163 */ 163 */
164#define PEVENT_PLUGIN_LOADER pevent_plugin_loader 164#define TEP_PLUGIN_LOADER tep_plugin_loader
165#define PEVENT_PLUGIN_UNLOADER pevent_plugin_unloader 165#define TEP_PLUGIN_UNLOADER tep_plugin_unloader
166#define PEVENT_PLUGIN_OPTIONS pevent_plugin_options 166#define TEP_PLUGIN_OPTIONS tep_plugin_options
167#define PEVENT_PLUGIN_ALIAS pevent_plugin_alias 167#define TEP_PLUGIN_ALIAS tep_plugin_alias
168#define _MAKE_STR(x) #x 168#define _MAKE_STR(x) #x
169#define MAKE_STR(x) _MAKE_STR(x) 169#define MAKE_STR(x) _MAKE_STR(x)
170#define PEVENT_PLUGIN_LOADER_NAME MAKE_STR(PEVENT_PLUGIN_LOADER) 170#define TEP_PLUGIN_LOADER_NAME MAKE_STR(TEP_PLUGIN_LOADER)
171#define PEVENT_PLUGIN_UNLOADER_NAME MAKE_STR(PEVENT_PLUGIN_UNLOADER) 171#define TEP_PLUGIN_UNLOADER_NAME MAKE_STR(TEP_PLUGIN_UNLOADER)
172#define PEVENT_PLUGIN_OPTIONS_NAME MAKE_STR(PEVENT_PLUGIN_OPTIONS) 172#define TEP_PLUGIN_OPTIONS_NAME MAKE_STR(TEP_PLUGIN_OPTIONS)
173#define PEVENT_PLUGIN_ALIAS_NAME MAKE_STR(PEVENT_PLUGIN_ALIAS) 173#define TEP_PLUGIN_ALIAS_NAME MAKE_STR(TEP_PLUGIN_ALIAS)
174 174
175enum format_flags { 175enum format_flags {
176 FIELD_IS_ARRAY = 1, 176 FIELD_IS_ARRAY = 1,
@@ -269,10 +269,10 @@ struct print_arg_op {
269 struct print_arg *right; 269 struct print_arg *right;
270}; 270};
271 271
272struct pevent_function_handler; 272struct tep_function_handler;
273 273
274struct print_arg_func { 274struct print_arg_func {
275 struct pevent_function_handler *func; 275 struct tep_function_handler *func;
276 struct print_arg *args; 276 struct print_arg *args;
277}; 277};
278 278
@@ -320,14 +320,14 @@ struct print_fmt {
320}; 320};
321 321
322struct event_format { 322struct event_format {
323 struct pevent *pevent; 323 struct tep_handle *pevent;
324 char *name; 324 char *name;
325 int id; 325 int id;
326 int flags; 326 int flags;
327 struct format format; 327 struct format format;
328 struct print_fmt print_fmt; 328 struct print_fmt print_fmt;
329 char *system; 329 char *system;
330 pevent_event_handler_func handler; 330 tep_event_handler_func handler;
331 void *context; 331 void *context;
332}; 332};
333 333
@@ -361,25 +361,25 @@ enum event_type {
361 EVENT_SQUOTE, 361 EVENT_SQUOTE,
362}; 362};
363 363
364typedef unsigned long long (*pevent_func_handler)(struct trace_seq *s, 364typedef unsigned long long (*tep_func_handler)(struct trace_seq *s,
365 unsigned long long *args); 365 unsigned long long *args);
366 366
367enum pevent_func_arg_type { 367enum tep_func_arg_type {
368 PEVENT_FUNC_ARG_VOID, 368 TEP_FUNC_ARG_VOID,
369 PEVENT_FUNC_ARG_INT, 369 TEP_FUNC_ARG_INT,
370 PEVENT_FUNC_ARG_LONG, 370 TEP_FUNC_ARG_LONG,
371 PEVENT_FUNC_ARG_STRING, 371 TEP_FUNC_ARG_STRING,
372 PEVENT_FUNC_ARG_PTR, 372 TEP_FUNC_ARG_PTR,
373 PEVENT_FUNC_ARG_MAX_TYPES 373 TEP_FUNC_ARG_MAX_TYPES
374}; 374};
375 375
376enum pevent_flag { 376enum tep_flag {
377 PEVENT_NSEC_OUTPUT = 1, /* output in NSECS */ 377 TEP_NSEC_OUTPUT = 1, /* output in NSECS */
378 PEVENT_DISABLE_SYS_PLUGINS = 1 << 1, 378 TEP_DISABLE_SYS_PLUGINS = 1 << 1,
379 PEVENT_DISABLE_PLUGINS = 1 << 2, 379 TEP_DISABLE_PLUGINS = 1 << 2,
380}; 380};
381 381
382#define PEVENT_ERRORS \ 382#define TEP_ERRORS \
383 _PE(MEM_ALLOC_FAILED, "failed to allocate memory"), \ 383 _PE(MEM_ALLOC_FAILED, "failed to allocate memory"), \
384 _PE(PARSE_EVENT_FAILED, "failed to parse event"), \ 384 _PE(PARSE_EVENT_FAILED, "failed to parse event"), \
385 _PE(READ_ID_FAILED, "failed to read event id"), \ 385 _PE(READ_ID_FAILED, "failed to read event id"), \
@@ -411,10 +411,10 @@ enum pevent_flag {
411 _PE(FILTER_MISS, "record does not match to filter") 411 _PE(FILTER_MISS, "record does not match to filter")
412 412
413#undef _PE 413#undef _PE
414#define _PE(__code, __str) PEVENT_ERRNO__ ## __code 414#define _PE(__code, __str) TEP_ERRNO__ ## __code
415enum pevent_errno { 415enum tep_errno {
416 PEVENT_ERRNO__SUCCESS = 0, 416 TEP_ERRNO__SUCCESS = 0,
417 PEVENT_ERRNO__FILTER_MATCH = PEVENT_ERRNO__SUCCESS, 417 TEP_ERRNO__FILTER_MATCH = TEP_ERRNO__SUCCESS,
418 418
419 /* 419 /*
420 * Choose an arbitrary negative big number not to clash with standard 420 * Choose an arbitrary negative big number not to clash with standard
@@ -423,11 +423,11 @@ enum pevent_errno {
423 * 423 *
424 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html 424 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
425 */ 425 */
426 __PEVENT_ERRNO__START = -100000, 426 __TEP_ERRNO__START = -100000,
427 427
428 PEVENT_ERRORS, 428 TEP_ERRORS,
429 429
430 __PEVENT_ERRNO__END, 430 __TEP_ERRNO__END,
431}; 431};
432#undef _PE 432#undef _PE
433 433
@@ -435,17 +435,17 @@ struct plugin_list;
435 435
436#define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1)) 436#define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1))
437 437
438struct plugin_list *traceevent_load_plugins(struct pevent *pevent); 438struct plugin_list *tep_load_plugins(struct tep_handle *pevent);
439void traceevent_unload_plugins(struct plugin_list *plugin_list, 439void tep_unload_plugins(struct plugin_list *plugin_list,
440 struct pevent *pevent); 440 struct tep_handle *pevent);
441char **traceevent_plugin_list_options(void); 441char **tep_plugin_list_options(void);
442void traceevent_plugin_free_options_list(char **list); 442void tep_plugin_free_options_list(char **list);
443int traceevent_plugin_add_options(const char *name, 443int tep_plugin_add_options(const char *name,
444 struct pevent_plugin_option *options); 444 struct tep_plugin_option *options);
445void traceevent_plugin_remove_options(struct pevent_plugin_option *options); 445void tep_plugin_remove_options(struct tep_plugin_option *options);
446void traceevent_print_plugins(struct trace_seq *s, 446void tep_print_plugins(struct trace_seq *s,
447 const char *prefix, const char *suffix, 447 const char *prefix, const char *suffix,
448 const struct plugin_list *list); 448 const struct plugin_list *list);
449 449
450struct cmdline; 450struct cmdline;
451struct cmdline_list; 451struct cmdline_list;
@@ -454,10 +454,10 @@ struct func_list;
454struct event_handler; 454struct event_handler;
455struct func_resolver; 455struct func_resolver;
456 456
457typedef char *(pevent_func_resolver_t)(void *priv, 457typedef char *(tep_func_resolver_t)(void *priv,
458 unsigned long long *addrp, char **modp); 458 unsigned long long *addrp, char **modp);
459 459
460struct pevent { 460struct tep_handle {
461 int ref_count; 461 int ref_count;
462 462
463 int header_page_ts_offset; 463 int header_page_ts_offset;
@@ -524,7 +524,7 @@ struct pevent {
524 struct format_field *bprint_buf_field; 524 struct format_field *bprint_buf_field;
525 525
526 struct event_handler *handlers; 526 struct event_handler *handlers;
527 struct pevent_function_handler *func_handlers; 527 struct tep_function_handler *func_handlers;
528 528
529 /* cache */ 529 /* cache */
530 struct event_format *last_event; 530 struct event_format *last_event;
@@ -532,13 +532,13 @@ struct pevent {
532 char *trace_clock; 532 char *trace_clock;
533}; 533};
534 534
535static inline void pevent_set_flag(struct pevent *pevent, int flag) 535static inline void tep_set_flag(struct tep_handle *pevent, int flag)
536{ 536{
537 pevent->flags |= flag; 537 pevent->flags |= flag;
538} 538}
539 539
540static inline unsigned short 540static inline unsigned short
541__data2host2(struct pevent *pevent, unsigned short data) 541__data2host2(struct tep_handle *pevent, unsigned short data)
542{ 542{
543 unsigned short swap; 543 unsigned short swap;
544 544
@@ -552,7 +552,7 @@ __data2host2(struct pevent *pevent, unsigned short data)
552} 552}
553 553
554static inline unsigned int 554static inline unsigned int
555__data2host4(struct pevent *pevent, unsigned int data) 555__data2host4(struct tep_handle *pevent, unsigned int data)
556{ 556{
557 unsigned int swap; 557 unsigned int swap;
558 558
@@ -568,7 +568,7 @@ __data2host4(struct pevent *pevent, unsigned int data)
568} 568}
569 569
570static inline unsigned long long 570static inline unsigned long long
571__data2host8(struct pevent *pevent, unsigned long long data) 571__data2host8(struct tep_handle *pevent, unsigned long long data)
572{ 572{
573 unsigned long long swap; 573 unsigned long long swap;
574 574
@@ -597,7 +597,7 @@ __data2host8(struct pevent *pevent, unsigned long long data)
597 __data2host8(pevent, __val); \ 597 __data2host8(pevent, __val); \
598}) 598})
599 599
600static inline int traceevent_host_bigendian(void) 600static inline int tep_host_bigendian(void)
601{ 601{
602 unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 }; 602 unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
603 unsigned int val; 603 unsigned int val;
@@ -615,198 +615,198 @@ enum trace_flag_type {
615 TRACE_FLAG_SOFTIRQ = 0x10, 615 TRACE_FLAG_SOFTIRQ = 0x10,
616}; 616};
617 617
618int pevent_set_function_resolver(struct pevent *pevent, 618int tep_set_function_resolver(struct tep_handle *pevent,
619 pevent_func_resolver_t *func, void *priv); 619 tep_func_resolver_t *func, void *priv);
620void pevent_reset_function_resolver(struct pevent *pevent); 620void tep_reset_function_resolver(struct tep_handle *pevent);
621int pevent_register_comm(struct pevent *pevent, const char *comm, int pid); 621int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid);
622int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock); 622int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock);
623int pevent_register_function(struct pevent *pevent, char *name, 623int tep_register_function(struct tep_handle *pevent, char *name,
624 unsigned long long addr, char *mod); 624 unsigned long long addr, char *mod);
625int pevent_register_print_string(struct pevent *pevent, const char *fmt, 625int tep_register_print_string(struct tep_handle *pevent, const char *fmt,
626 unsigned long long addr); 626 unsigned long long addr);
627int pevent_pid_is_registered(struct pevent *pevent, int pid); 627int tep_pid_is_registered(struct tep_handle *pevent, int pid);
628 628
629void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s, 629void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s,
630 struct event_format *event, 630 struct event_format *event,
631 struct pevent_record *record); 631 struct tep_record *record);
632void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s, 632void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s,
633 struct event_format *event, 633 struct event_format *event,
634 struct pevent_record *record, 634 struct tep_record *record,
635 bool use_trace_clock); 635 bool use_trace_clock);
636void pevent_print_event_data(struct pevent *pevent, struct trace_seq *s, 636void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s,
637 struct event_format *event, 637 struct event_format *event,
638 struct pevent_record *record); 638 struct tep_record *record);
639void pevent_print_event(struct pevent *pevent, struct trace_seq *s, 639void tep_print_event(struct tep_handle *pevent, struct trace_seq *s,
640 struct pevent_record *record, bool use_trace_clock); 640 struct tep_record *record, bool use_trace_clock);
641 641
642int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long size, 642int tep_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size,
643 int long_size); 643 int long_size);
644 644
645enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf, 645enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf,
646 unsigned long size, const char *sys); 646 unsigned long size, const char *sys);
647enum pevent_errno pevent_parse_format(struct pevent *pevent, 647enum tep_errno tep_parse_format(struct tep_handle *pevent,
648 struct event_format **eventp, 648 struct event_format **eventp,
649 const char *buf, 649 const char *buf,
650 unsigned long size, const char *sys); 650 unsigned long size, const char *sys);
651void pevent_free_format(struct event_format *event); 651void tep_free_format(struct event_format *event);
652void pevent_free_format_field(struct format_field *field); 652void tep_free_format_field(struct format_field *field);
653 653
654void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event, 654void *tep_get_field_raw(struct trace_seq *s, struct event_format *event,
655 const char *name, struct pevent_record *record, 655 const char *name, struct tep_record *record,
656 int *len, int err); 656 int *len, int err);
657 657
658int pevent_get_field_val(struct trace_seq *s, struct event_format *event, 658int tep_get_field_val(struct trace_seq *s, struct event_format *event,
659 const char *name, struct pevent_record *record, 659 const char *name, struct tep_record *record,
660 unsigned long long *val, int err); 660 unsigned long long *val, int err);
661int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event, 661int tep_get_common_field_val(struct trace_seq *s, struct event_format *event,
662 const char *name, struct pevent_record *record, 662 const char *name, struct tep_record *record,
663 unsigned long long *val, int err);
664int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event,
665 const char *name, struct pevent_record *record,
666 unsigned long long *val, int err); 663 unsigned long long *val, int err);
664int 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);
667 667
668int pevent_print_num_field(struct trace_seq *s, const char *fmt, 668int tep_print_num_field(struct trace_seq *s, const char *fmt,
669 struct event_format *event, const char *name, 669 struct event_format *event, const char *name,
670 struct pevent_record *record, int err); 670 struct tep_record *record, int err);
671 671
672int pevent_print_func_field(struct trace_seq *s, const char *fmt, 672int tep_print_func_field(struct trace_seq *s, const char *fmt,
673 struct event_format *event, const char *name, 673 struct event_format *event, const char *name,
674 struct pevent_record *record, int err); 674 struct tep_record *record, int err);
675 675
676int pevent_register_event_handler(struct pevent *pevent, int id, 676int tep_register_event_handler(struct tep_handle *pevent, int id,
677 const char *sys_name, const char *event_name, 677 const char *sys_name, const char *event_name,
678 pevent_event_handler_func func, void *context); 678 tep_event_handler_func func, void *context);
679int pevent_unregister_event_handler(struct pevent *pevent, int id, 679int tep_unregister_event_handler(struct tep_handle *pevent, int id,
680 const char *sys_name, const char *event_name, 680 const char *sys_name, const char *event_name,
681 pevent_event_handler_func func, void *context); 681 tep_event_handler_func func, void *context);
682int pevent_register_print_function(struct pevent *pevent, 682int tep_register_print_function(struct tep_handle *pevent,
683 pevent_func_handler func, 683 tep_func_handler func,
684 enum pevent_func_arg_type ret_type, 684 enum tep_func_arg_type ret_type,
685 char *name, ...); 685 char *name, ...);
686int pevent_unregister_print_function(struct pevent *pevent, 686int tep_unregister_print_function(struct tep_handle *pevent,
687 pevent_func_handler func, char *name); 687 tep_func_handler func, char *name);
688 688
689struct format_field *pevent_find_common_field(struct event_format *event, const char *name); 689struct format_field *tep_find_common_field(struct event_format *event, const char *name);
690struct format_field *pevent_find_field(struct event_format *event, const char *name); 690struct format_field *tep_find_field(struct event_format *event, const char *name);
691struct format_field *pevent_find_any_field(struct event_format *event, const char *name); 691struct format_field *tep_find_any_field(struct event_format *event, const char *name);
692 692
693const char *pevent_find_function(struct pevent *pevent, unsigned long long addr); 693const char *tep_find_function(struct tep_handle *pevent, unsigned long long addr);
694unsigned long long 694unsigned long long
695pevent_find_function_address(struct pevent *pevent, unsigned long long addr); 695tep_find_function_address(struct tep_handle *pevent, unsigned long long addr);
696unsigned long long pevent_read_number(struct pevent *pevent, const void *ptr, int size); 696unsigned long long tep_read_number(struct tep_handle *pevent, const void *ptr, int size);
697int pevent_read_number_field(struct format_field *field, const void *data, 697int tep_read_number_field(struct format_field *field, const void *data,
698 unsigned long long *value); 698 unsigned long long *value);
699 699
700struct event_format *pevent_find_event(struct pevent *pevent, int id); 700struct event_format *tep_find_event(struct tep_handle *pevent, int id);
701 701
702struct event_format * 702struct event_format *
703pevent_find_event_by_name(struct pevent *pevent, const char *sys, const char *name); 703tep_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *name);
704 704
705struct event_format * 705struct event_format *
706pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record); 706tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record);
707 707
708void pevent_data_lat_fmt(struct pevent *pevent, 708void tep_data_lat_fmt(struct tep_handle *pevent,
709 struct trace_seq *s, struct pevent_record *record); 709 struct trace_seq *s, struct tep_record *record);
710int pevent_data_type(struct pevent *pevent, struct pevent_record *rec); 710int tep_data_type(struct tep_handle *pevent, struct tep_record *rec);
711struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type); 711struct event_format *tep_data_event_from_type(struct tep_handle *pevent, int type);
712int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec); 712int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec);
713int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec); 713int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec);
714int pevent_data_flags(struct pevent *pevent, struct pevent_record *rec); 714int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec);
715const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid); 715const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid);
716struct cmdline; 716struct cmdline;
717struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *comm, 717struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
718 struct cmdline *next); 718 struct cmdline *next);
719int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline); 719int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline);
720 720
721void pevent_print_field(struct trace_seq *s, void *data, 721void tep_print_field(struct trace_seq *s, void *data,
722 struct format_field *field); 722 struct format_field *field);
723void pevent_print_fields(struct trace_seq *s, void *data, 723void tep_print_fields(struct trace_seq *s, void *data,
724 int size __maybe_unused, struct event_format *event); 724 int size __maybe_unused, struct event_format *event);
725void pevent_event_info(struct trace_seq *s, struct event_format *event, 725void tep_event_info(struct trace_seq *s, struct event_format *event,
726 struct pevent_record *record); 726 struct tep_record *record);
727int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum, 727int tep_strerror(struct tep_handle *pevent, enum tep_errno errnum,
728 char *buf, size_t buflen); 728 char *buf, size_t buflen);
729 729
730struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type); 730struct event_format **tep_list_events(struct tep_handle *pevent, enum event_sort_type);
731struct format_field **pevent_event_common_fields(struct event_format *event); 731struct format_field **tep_event_common_fields(struct event_format *event);
732struct format_field **pevent_event_fields(struct event_format *event); 732struct format_field **tep_event_fields(struct event_format *event);
733 733
734static inline int pevent_get_cpus(struct pevent *pevent) 734static inline int tep_get_cpus(struct tep_handle *pevent)
735{ 735{
736 return pevent->cpus; 736 return pevent->cpus;
737} 737}
738 738
739static inline void pevent_set_cpus(struct pevent *pevent, int cpus) 739static inline void tep_set_cpus(struct tep_handle *pevent, int cpus)
740{ 740{
741 pevent->cpus = cpus; 741 pevent->cpus = cpus;
742} 742}
743 743
744static inline int pevent_get_long_size(struct pevent *pevent) 744static inline int tep_get_long_size(struct tep_handle *pevent)
745{ 745{
746 return pevent->long_size; 746 return pevent->long_size;
747} 747}
748 748
749static inline void pevent_set_long_size(struct pevent *pevent, int long_size) 749static inline void tep_set_long_size(struct tep_handle *pevent, int long_size)
750{ 750{
751 pevent->long_size = long_size; 751 pevent->long_size = long_size;
752} 752}
753 753
754static inline int pevent_get_page_size(struct pevent *pevent) 754static inline int tep_get_page_size(struct tep_handle *pevent)
755{ 755{
756 return pevent->page_size; 756 return pevent->page_size;
757} 757}
758 758
759static inline void pevent_set_page_size(struct pevent *pevent, int _page_size) 759static inline void tep_set_page_size(struct tep_handle *pevent, int _page_size)
760{ 760{
761 pevent->page_size = _page_size; 761 pevent->page_size = _page_size;
762} 762}
763 763
764static inline int pevent_is_file_bigendian(struct pevent *pevent) 764static inline int tep_is_file_bigendian(struct tep_handle *pevent)
765{ 765{
766 return pevent->file_bigendian; 766 return pevent->file_bigendian;
767} 767}
768 768
769static inline void pevent_set_file_bigendian(struct pevent *pevent, int endian) 769static inline void tep_set_file_bigendian(struct tep_handle *pevent, int endian)
770{ 770{
771 pevent->file_bigendian = endian; 771 pevent->file_bigendian = endian;
772} 772}
773 773
774static inline int pevent_is_host_bigendian(struct pevent *pevent) 774static inline int tep_is_host_bigendian(struct tep_handle *pevent)
775{ 775{
776 return pevent->host_bigendian; 776 return pevent->host_bigendian;
777} 777}
778 778
779static inline void pevent_set_host_bigendian(struct pevent *pevent, int endian) 779static inline void tep_set_host_bigendian(struct tep_handle *pevent, int endian)
780{ 780{
781 pevent->host_bigendian = endian; 781 pevent->host_bigendian = endian;
782} 782}
783 783
784static inline int pevent_is_latency_format(struct pevent *pevent) 784static inline int tep_is_latency_format(struct tep_handle *pevent)
785{ 785{
786 return pevent->latency_format; 786 return pevent->latency_format;
787} 787}
788 788
789static inline void pevent_set_latency_format(struct pevent *pevent, int lat) 789static inline void tep_set_latency_format(struct tep_handle *pevent, int lat)
790{ 790{
791 pevent->latency_format = lat; 791 pevent->latency_format = lat;
792} 792}
793 793
794struct pevent *pevent_alloc(void); 794struct tep_handle *tep_alloc(void);
795void pevent_free(struct pevent *pevent); 795void tep_free(struct tep_handle *pevent);
796void pevent_ref(struct pevent *pevent); 796void tep_ref(struct tep_handle *pevent);
797void pevent_unref(struct pevent *pevent); 797void tep_unref(struct tep_handle *pevent);
798 798
799/* access to the internal parser */ 799/* access to the internal parser */
800void pevent_buffer_init(const char *buf, unsigned long long size); 800void tep_buffer_init(const char *buf, unsigned long long size);
801enum event_type pevent_read_token(char **tok); 801enum event_type tep_read_token(char **tok);
802void pevent_free_token(char *token); 802void tep_free_token(char *token);
803int pevent_peek_char(void); 803int tep_peek_char(void);
804const char *pevent_get_input_buf(void); 804const char *tep_get_input_buf(void);
805unsigned long long pevent_get_input_buf_ptr(void); 805unsigned long long tep_get_input_buf_ptr(void);
806 806
807/* for debugging */ 807/* for debugging */
808void pevent_print_funcs(struct pevent *pevent); 808void tep_print_funcs(struct tep_handle *pevent);
809void pevent_print_printk(struct pevent *pevent); 809void tep_print_printk(struct tep_handle *pevent);
810 810
811/* ----------------------- filtering ----------------------- */ 811/* ----------------------- filtering ----------------------- */
812 812
@@ -930,22 +930,22 @@ struct filter_type {
930 struct filter_arg *filter; 930 struct filter_arg *filter;
931}; 931};
932 932
933#define PEVENT_FILTER_ERROR_BUFSZ 1024 933#define TEP_FILTER_ERROR_BUFSZ 1024
934 934
935struct event_filter { 935struct event_filter {
936 struct pevent *pevent; 936 struct tep_handle *pevent;
937 int filters; 937 int filters;
938 struct filter_type *event_filters; 938 struct filter_type *event_filters;
939 char error_buffer[PEVENT_FILTER_ERROR_BUFSZ]; 939 char error_buffer[TEP_FILTER_ERROR_BUFSZ];
940}; 940};
941 941
942struct event_filter *pevent_filter_alloc(struct pevent *pevent); 942struct event_filter *tep_filter_alloc(struct tep_handle *pevent);
943 943
944/* for backward compatibility */ 944/* for backward compatibility */
945#define FILTER_NONE PEVENT_ERRNO__NO_FILTER 945#define FILTER_NONE TEP_ERRNO__NO_FILTER
946#define FILTER_NOEXIST PEVENT_ERRNO__FILTER_NOT_FOUND 946#define FILTER_NOEXIST TEP_ERRNO__FILTER_NOT_FOUND
947#define FILTER_MISS PEVENT_ERRNO__FILTER_MISS 947#define FILTER_MISS TEP_ERRNO__FILTER_MISS
948#define FILTER_MATCH PEVENT_ERRNO__FILTER_MATCH 948#define FILTER_MATCH TEP_ERRNO__FILTER_MATCH
949 949
950enum filter_trivial_type { 950enum filter_trivial_type {
951 FILTER_TRIVIAL_FALSE, 951 FILTER_TRIVIAL_FALSE,
@@ -953,39 +953,39 @@ enum filter_trivial_type {
953 FILTER_TRIVIAL_BOTH, 953 FILTER_TRIVIAL_BOTH,
954}; 954};
955 955
956enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, 956enum tep_errno tep_filter_add_filter_str(struct event_filter *filter,
957 const char *filter_str); 957 const char *filter_str);
958 958
959enum pevent_errno pevent_filter_match(struct event_filter *filter, 959enum tep_errno tep_filter_match(struct event_filter *filter,
960 struct pevent_record *record); 960 struct tep_record *record);
961 961
962int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err, 962int tep_filter_strerror(struct event_filter *filter, enum tep_errno err,
963 char *buf, size_t buflen); 963 char *buf, size_t buflen);
964 964
965int pevent_event_filtered(struct event_filter *filter, 965int tep_event_filtered(struct event_filter *filter,
966 int event_id); 966 int event_id);
967 967
968void pevent_filter_reset(struct event_filter *filter); 968void tep_filter_reset(struct event_filter *filter);
969 969
970int pevent_filter_clear_trivial(struct event_filter *filter, 970int tep_filter_clear_trivial(struct event_filter *filter,
971 enum filter_trivial_type type); 971 enum filter_trivial_type type);
972 972
973void pevent_filter_free(struct event_filter *filter); 973void tep_filter_free(struct event_filter *filter);
974 974
975char *pevent_filter_make_string(struct event_filter *filter, int event_id); 975char *tep_filter_make_string(struct event_filter *filter, int event_id);
976 976
977int pevent_filter_remove_event(struct event_filter *filter, 977int tep_filter_remove_event(struct event_filter *filter,
978 int event_id); 978 int event_id);
979 979
980int pevent_filter_event_has_trivial(struct event_filter *filter, 980int tep_filter_event_has_trivial(struct event_filter *filter,
981 int event_id, 981 int event_id,
982 enum filter_trivial_type type); 982 enum filter_trivial_type type);
983 983
984int pevent_filter_copy(struct event_filter *dest, struct event_filter *source); 984int tep_filter_copy(struct event_filter *dest, struct event_filter *source);
985 985
986int pevent_update_trivial(struct event_filter *dest, struct event_filter *source, 986int tep_update_trivial(struct event_filter *dest, struct event_filter *source,
987 enum filter_trivial_type type); 987 enum filter_trivial_type type);
988 988
989int pevent_filter_compare(struct event_filter *filter1, struct event_filter *filter2); 989int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2);
990 990
991#endif /* _PARSE_EVENTS_H */ 991#endif /* _PARSE_EVENTS_H */
diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c
index d542cb60ca1a..f17e25097e1e 100644
--- a/tools/lib/traceevent/event-plugin.c
+++ b/tools/lib/traceevent/event-plugin.c
@@ -1,21 +1,7 @@
1// SPDX-License-Identifier: LGPL-2.1
1/* 2/*
2 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> 3 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3 * 4 *
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 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */ 5 */
20 6
21#include <ctype.h> 7#include <ctype.h>
@@ -34,7 +20,7 @@
34 20
35static struct registered_plugin_options { 21static struct registered_plugin_options {
36 struct registered_plugin_options *next; 22 struct registered_plugin_options *next;
37 struct pevent_plugin_option *options; 23 struct tep_plugin_option *options;
38} *registered_options; 24} *registered_options;
39 25
40static struct trace_plugin_options { 26static struct trace_plugin_options {
@@ -58,7 +44,7 @@ static void lower_case(char *str)
58 *str = tolower(*str); 44 *str = tolower(*str);
59} 45}
60 46
61static int update_option_value(struct pevent_plugin_option *op, const char *val) 47static int update_option_value(struct tep_plugin_option *op, const char *val)
62{ 48{
63 char *op_val; 49 char *op_val;
64 50
@@ -97,7 +83,7 @@ static int update_option_value(struct pevent_plugin_option *op, const char *val)
97} 83}
98 84
99/** 85/**
100 * traceevent_plugin_list_options - get list of plugin options 86 * tep_plugin_list_options - get list of plugin options
101 * 87 *
102 * Returns an array of char strings that list the currently registered 88 * Returns an array of char strings that list the currently registered
103 * plugin options in the format of <plugin>:<option>. This list can be 89 * 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)
106 * Returns NULL if there's no options registered. On error it returns 92 * Returns NULL if there's no options registered. On error it returns
107 * INVALID_PLUGIN_LIST_OPTION 93 * INVALID_PLUGIN_LIST_OPTION
108 * 94 *
109 * Must be freed with traceevent_plugin_free_options_list(). 95 * Must be freed with tep_plugin_free_options_list().
110 */ 96 */
111char **traceevent_plugin_list_options(void) 97char **tep_plugin_list_options(void)
112{ 98{
113 struct registered_plugin_options *reg; 99 struct registered_plugin_options *reg;
114 struct pevent_plugin_option *op; 100 struct tep_plugin_option *op;
115 char **list = NULL; 101 char **list = NULL;
116 char *name; 102 char *name;
117 int count = 0; 103 int count = 0;
@@ -146,7 +132,7 @@ char **traceevent_plugin_list_options(void)
146 return INVALID_PLUGIN_LIST_OPTION; 132 return INVALID_PLUGIN_LIST_OPTION;
147} 133}
148 134
149void traceevent_plugin_free_options_list(char **list) 135void tep_plugin_free_options_list(char **list)
150{ 136{
151 int i; 137 int i;
152 138
@@ -163,7 +149,7 @@ void traceevent_plugin_free_options_list(char **list)
163} 149}
164 150
165static int 151static int
166update_option(const char *file, struct pevent_plugin_option *option) 152update_option(const char *file, struct tep_plugin_option *option)
167{ 153{
168 struct trace_plugin_options *op; 154 struct trace_plugin_options *op;
169 char *plugin; 155 char *plugin;
@@ -215,14 +201,14 @@ update_option(const char *file, struct pevent_plugin_option *option)
215} 201}
216 202
217/** 203/**
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
219 * @name: The name of the plugin adding the options 205 * @name: The name of the plugin adding the options
220 * @options: The set of options being loaded 206 * @options: The set of options being loaded
221 * 207 *
222 * Sets the options with the values that have been added by user. 208 * Sets the options with the values that have been added by user.
223 */ 209 */
224int traceevent_plugin_add_options(const char *name, 210int tep_plugin_add_options(const char *name,
225 struct pevent_plugin_option *options) 211 struct tep_plugin_option *options)
226{ 212{
227 struct registered_plugin_options *reg; 213 struct registered_plugin_options *reg;
228 214
@@ -241,10 +227,10 @@ int traceevent_plugin_add_options(const char *name,
241} 227}
242 228
243/** 229/**
244 * traceevent_plugin_remove_options - remove plugin options that were registered 230 * tep_plugin_remove_options - remove plugin options that were registered
245 * @options: Options to removed that were registered with traceevent_plugin_add_options 231 * @options: Options to removed that were registered with tep_plugin_add_options
246 */ 232 */
247void traceevent_plugin_remove_options(struct pevent_plugin_option *options) 233void tep_plugin_remove_options(struct tep_plugin_option *options)
248{ 234{
249 struct registered_plugin_options **last; 235 struct registered_plugin_options **last;
250 struct registered_plugin_options *reg; 236 struct registered_plugin_options *reg;
@@ -260,19 +246,19 @@ void traceevent_plugin_remove_options(struct pevent_plugin_option *options)
260} 246}
261 247
262/** 248/**
263 * traceevent_print_plugins - print out the list of plugins loaded 249 * tep_print_plugins - print out the list of plugins loaded
264 * @s: the trace_seq descripter to write to 250 * @s: the trace_seq descripter to write to
265 * @prefix: The prefix string to add before listing the option name 251 * @prefix: The prefix string to add before listing the option name
266 * @suffix: The suffix string ot append after the option name 252 * @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()
268 * 254 *
269 * Writes to the trace_seq @s the list of plugins (files) that is 255 * 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:
271 * @prefix = " ", @suffix = "\n". 257 * @prefix = " ", @suffix = "\n".
272 */ 258 */
273void traceevent_print_plugins(struct trace_seq *s, 259void tep_print_plugins(struct trace_seq *s,
274 const char *prefix, const char *suffix, 260 const char *prefix, const char *suffix,
275 const struct plugin_list *list) 261 const struct plugin_list *list)
276{ 262{
277 while (list) { 263 while (list) {
278 trace_seq_printf(s, "%s%s%s", prefix, list->name, suffix); 264 trace_seq_printf(s, "%s%s%s", prefix, list->name, suffix);
@@ -281,11 +267,11 @@ void traceevent_print_plugins(struct trace_seq *s,
281} 267}
282 268
283static void 269static void
284load_plugin(struct pevent *pevent, const char *path, 270load_plugin(struct tep_handle *pevent, const char *path,
285 const char *file, void *data) 271 const char *file, void *data)
286{ 272{
287 struct plugin_list **plugin_list = data; 273 struct plugin_list **plugin_list = data;
288 pevent_plugin_load_func func; 274 tep_plugin_load_func func;
289 struct plugin_list *list; 275 struct plugin_list *list;
290 const char *alias; 276 const char *alias;
291 char *plugin; 277 char *plugin;
@@ -305,14 +291,14 @@ load_plugin(struct pevent *pevent, const char *path,
305 goto out_free; 291 goto out_free;
306 } 292 }
307 293
308 alias = dlsym(handle, PEVENT_PLUGIN_ALIAS_NAME); 294 alias = dlsym(handle, TEP_PLUGIN_ALIAS_NAME);
309 if (!alias) 295 if (!alias)
310 alias = file; 296 alias = file;
311 297
312 func = dlsym(handle, PEVENT_PLUGIN_LOADER_NAME); 298 func = dlsym(handle, TEP_PLUGIN_LOADER_NAME);
313 if (!func) { 299 if (!func) {
314 warning("could not find func '%s' in plugin '%s'\n%s\n", 300 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());
316 goto out_free; 302 goto out_free;
317 } 303 }
318 304
@@ -336,9 +322,9 @@ load_plugin(struct pevent *pevent, const char *path,
336} 322}
337 323
338static void 324static void
339load_plugins_dir(struct pevent *pevent, const char *suffix, 325load_plugins_dir(struct tep_handle *pevent, const char *suffix,
340 const char *path, 326 const char *path,
341 void (*load_plugin)(struct pevent *pevent, 327 void (*load_plugin)(struct tep_handle *pevent,
342 const char *path, 328 const char *path,
343 const char *name, 329 const char *name,
344 void *data), 330 void *data),
@@ -378,8 +364,8 @@ load_plugins_dir(struct pevent *pevent, const char *suffix,
378} 364}
379 365
380static void 366static void
381load_plugins(struct pevent *pevent, const char *suffix, 367load_plugins(struct tep_handle *pevent, const char *suffix,
382 void (*load_plugin)(struct pevent *pevent, 368 void (*load_plugin)(struct tep_handle *pevent,
383 const char *path, 369 const char *path,
384 const char *name, 370 const char *name,
385 void *data), 371 void *data),
@@ -390,7 +376,7 @@ load_plugins(struct pevent *pevent, const char *suffix,
390 char *envdir; 376 char *envdir;
391 int ret; 377 int ret;
392 378
393 if (pevent->flags & PEVENT_DISABLE_PLUGINS) 379 if (pevent->flags & TEP_DISABLE_PLUGINS)
394 return; 380 return;
395 381
396 /* 382 /*
@@ -398,7 +384,7 @@ load_plugins(struct pevent *pevent, const char *suffix,
398 * check that first. 384 * check that first.
399 */ 385 */
400#ifdef PLUGIN_DIR 386#ifdef PLUGIN_DIR
401 if (!(pevent->flags & PEVENT_DISABLE_SYS_PLUGINS)) 387 if (!(pevent->flags & TEP_DISABLE_SYS_PLUGINS))
402 load_plugins_dir(pevent, suffix, PLUGIN_DIR, 388 load_plugins_dir(pevent, suffix, PLUGIN_DIR,
403 load_plugin, data); 389 load_plugin, data);
404#endif 390#endif
@@ -431,7 +417,7 @@ load_plugins(struct pevent *pevent, const char *suffix,
431} 417}
432 418
433struct plugin_list* 419struct plugin_list*
434traceevent_load_plugins(struct pevent *pevent) 420tep_load_plugins(struct tep_handle *pevent)
435{ 421{
436 struct plugin_list *list = NULL; 422 struct plugin_list *list = NULL;
437 423
@@ -440,15 +426,15 @@ traceevent_load_plugins(struct pevent *pevent)
440} 426}
441 427
442void 428void
443traceevent_unload_plugins(struct plugin_list *plugin_list, struct pevent *pevent) 429tep_unload_plugins(struct plugin_list *plugin_list, struct tep_handle *pevent)
444{ 430{
445 pevent_plugin_unload_func func; 431 tep_plugin_unload_func func;
446 struct plugin_list *list; 432 struct plugin_list *list;
447 433
448 while (plugin_list) { 434 while (plugin_list) {
449 list = plugin_list; 435 list = plugin_list;
450 plugin_list = list->next; 436 plugin_list = list->next;
451 func = dlsym(list->handle, PEVENT_PLUGIN_UNLOADER_NAME); 437 func = dlsym(list->handle, TEP_PLUGIN_UNLOADER_NAME);
452 if (func) 438 if (func)
453 func(pevent); 439 func(pevent);
454 dlclose(list->handle); 440 dlclose(list->handle);
diff --git a/tools/lib/traceevent/event-utils.h b/tools/lib/traceevent/event-utils.h
index d1dc2170e402..0560b96a31d1 100644
--- a/tools/lib/traceevent/event-utils.h
+++ b/tools/lib/traceevent/event-utils.h
@@ -1,21 +1,7 @@
1/* SPDX-License-Identifier: LGPL-2.1 */
1/* 2/*
2 * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> 3 * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3 * 4 *
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 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */ 5 */
20#ifndef __UTIL_H 6#ifndef __UTIL_H
21#define __UTIL_H 7#define __UTIL_H
diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
index ca424b157e46..af2a1f3b7424 100644
--- a/tools/lib/traceevent/kbuffer-parse.c
+++ b/tools/lib/traceevent/kbuffer-parse.c
@@ -1,22 +1,7 @@
1// SPDX-License-Identifier: LGPL-2.1
1/* 2/*
2 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> 3 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3 * 4 *
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 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 */ 5 */
21#include <stdio.h> 6#include <stdio.h>
22#include <stdlib.h> 7#include <stdlib.h>
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 431e8b309f6e..e76154c02ee7 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1,21 +1,7 @@
1// SPDX-License-Identifier: LGPL-2.1
1/* 2/*
2 * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> 3 * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3 * 4 *
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 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */ 5 */
20#include <stdio.h> 6#include <stdio.h>
21#include <stdlib.h> 7#include <stdlib.h>
@@ -51,8 +37,8 @@ static void show_error(char *error_buf, const char *fmt, ...)
51 int len; 37 int len;
52 int i; 38 int i;
53 39
54 input = pevent_get_input_buf(); 40 input = tep_get_input_buf();
55 index = pevent_get_input_buf_ptr(); 41 index = tep_get_input_buf_ptr();
56 len = input ? strlen(input) : 0; 42 len = input ? strlen(input) : 0;
57 43
58 if (len) { 44 if (len) {
@@ -66,13 +52,13 @@ static void show_error(char *error_buf, const char *fmt, ...)
66 } 52 }
67 53
68 va_start(ap, fmt); 54 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);
70 va_end(ap); 56 va_end(ap);
71} 57}
72 58
73static void free_token(char *token) 59static void free_token(char *token)
74{ 60{
75 pevent_free_token(token); 61 tep_free_token(token);
76} 62}
77 63
78static enum event_type read_token(char **tok) 64static enum event_type read_token(char **tok)
@@ -82,13 +68,13 @@ static enum event_type read_token(char **tok)
82 68
83 do { 69 do {
84 free_token(token); 70 free_token(token);
85 type = pevent_read_token(&token); 71 type = tep_read_token(&token);
86 } while (type == EVENT_NEWLINE || type == EVENT_SPACE); 72 } while (type == EVENT_NEWLINE || type == EVENT_SPACE);
87 73
88 /* If token is = or ! check to see if the next char is ~ */ 74 /* If token is = or ! check to see if the next char is ~ */
89 if (token && 75 if (token &&
90 (strcmp(token, "=") == 0 || strcmp(token, "!") == 0) && 76 (strcmp(token, "=") == 0 || strcmp(token, "!") == 0) &&
91 pevent_peek_char() == '~') { 77 tep_peek_char() == '~') {
92 /* append it */ 78 /* append it */
93 *tok = malloc(3); 79 *tok = malloc(3);
94 if (*tok == NULL) { 80 if (*tok == NULL) {
@@ -98,7 +84,7 @@ static enum event_type read_token(char **tok)
98 sprintf(*tok, "%c%c", *token, '~'); 84 sprintf(*tok, "%c%c", *token, '~');
99 free_token(token); 85 free_token(token);
100 /* Now remove the '~' from the buffer */ 86 /* Now remove the '~' from the buffer */
101 pevent_read_token(&token); 87 tep_read_token(&token);
102 free_token(token); 88 free_token(token);
103 } else 89 } else
104 *tok = token; 90 *tok = token;
@@ -167,7 +153,7 @@ add_filter_type(struct event_filter *filter, int id)
167 153
168 filter_type = &filter->event_filters[i]; 154 filter_type = &filter->event_filters[i];
169 filter_type->event_id = id; 155 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);
171 filter_type->filter = NULL; 157 filter_type->filter = NULL;
172 158
173 filter->filters++; 159 filter->filters++;
@@ -176,10 +162,10 @@ add_filter_type(struct event_filter *filter, int id)
176} 162}
177 163
178/** 164/**
179 * pevent_filter_alloc - create a new event filter 165 * tep_filter_alloc - create a new event filter
180 * @pevent: The pevent that this filter is associated with 166 * @pevent: The pevent that this filter is associated with
181 */ 167 */
182struct event_filter *pevent_filter_alloc(struct pevent *pevent) 168struct event_filter *tep_filter_alloc(struct tep_handle *pevent)
183{ 169{
184 struct event_filter *filter; 170 struct event_filter *filter;
185 171
@@ -189,7 +175,7 @@ struct event_filter *pevent_filter_alloc(struct pevent *pevent)
189 175
190 memset(filter, 0, sizeof(*filter)); 176 memset(filter, 0, sizeof(*filter));
191 filter->pevent = pevent; 177 filter->pevent = pevent;
192 pevent_ref(pevent); 178 tep_ref(pevent);
193 179
194 return filter; 180 return filter;
195} 181}
@@ -268,8 +254,8 @@ static int event_match(struct event_format *event,
268 !regexec(ereg, event->name, 0, NULL, 0); 254 !regexec(ereg, event->name, 0, NULL, 0);
269} 255}
270 256
271static enum pevent_errno 257static enum tep_errno
272find_event(struct pevent *pevent, struct event_list **events, 258find_event(struct tep_handle *pevent, struct event_list **events,
273 char *sys_name, char *event_name) 259 char *sys_name, char *event_name)
274{ 260{
275 struct event_format *event; 261 struct event_format *event;
@@ -289,26 +275,26 @@ find_event(struct pevent *pevent, struct event_list **events,
289 275
290 ret = asprintf(&reg, "^%s$", event_name); 276 ret = asprintf(&reg, "^%s$", event_name);
291 if (ret < 0) 277 if (ret < 0)
292 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 278 return TEP_ERRNO__MEM_ALLOC_FAILED;
293 279
294 ret = regcomp(&ereg, reg, REG_ICASE|REG_NOSUB); 280 ret = regcomp(&ereg, reg, REG_ICASE|REG_NOSUB);
295 free(reg); 281 free(reg);
296 282
297 if (ret) 283 if (ret)
298 return PEVENT_ERRNO__INVALID_EVENT_NAME; 284 return TEP_ERRNO__INVALID_EVENT_NAME;
299 285
300 if (sys_name) { 286 if (sys_name) {
301 ret = asprintf(&reg, "^%s$", sys_name); 287 ret = asprintf(&reg, "^%s$", sys_name);
302 if (ret < 0) { 288 if (ret < 0) {
303 regfree(&ereg); 289 regfree(&ereg);
304 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 290 return TEP_ERRNO__MEM_ALLOC_FAILED;
305 } 291 }
306 292
307 ret = regcomp(&sreg, reg, REG_ICASE|REG_NOSUB); 293 ret = regcomp(&sreg, reg, REG_ICASE|REG_NOSUB);
308 free(reg); 294 free(reg);
309 if (ret) { 295 if (ret) {
310 regfree(&ereg); 296 regfree(&ereg);
311 return PEVENT_ERRNO__INVALID_EVENT_NAME; 297 return TEP_ERRNO__INVALID_EVENT_NAME;
312 } 298 }
313 } 299 }
314 300
@@ -328,9 +314,9 @@ find_event(struct pevent *pevent, struct event_list **events,
328 regfree(&sreg); 314 regfree(&sreg);
329 315
330 if (!match) 316 if (!match)
331 return PEVENT_ERRNO__EVENT_NOT_FOUND; 317 return TEP_ERRNO__EVENT_NOT_FOUND;
332 if (fail) 318 if (fail)
333 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 319 return TEP_ERRNO__MEM_ALLOC_FAILED;
334 320
335 return 0; 321 return 0;
336} 322}
@@ -346,7 +332,7 @@ static void free_events(struct event_list *events)
346 } 332 }
347} 333}
348 334
349static enum pevent_errno 335static enum tep_errno
350create_arg_item(struct event_format *event, const char *token, 336create_arg_item(struct event_format *event, const char *token,
351 enum event_type type, struct filter_arg **parg, char *error_str) 337 enum event_type type, struct filter_arg **parg, char *error_str)
352{ 338{
@@ -356,7 +342,7 @@ create_arg_item(struct event_format *event, const char *token,
356 arg = allocate_arg(); 342 arg = allocate_arg();
357 if (arg == NULL) { 343 if (arg == NULL) {
358 show_error(error_str, "failed to allocate filter arg"); 344 show_error(error_str, "failed to allocate filter arg");
359 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 345 return TEP_ERRNO__MEM_ALLOC_FAILED;
360 } 346 }
361 347
362 switch (type) { 348 switch (type) {
@@ -370,7 +356,7 @@ create_arg_item(struct event_format *event, const char *token,
370 if (!arg->value.str) { 356 if (!arg->value.str) {
371 free_arg(arg); 357 free_arg(arg);
372 show_error(error_str, "failed to allocate string filter arg"); 358 show_error(error_str, "failed to allocate string filter arg");
373 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 359 return TEP_ERRNO__MEM_ALLOC_FAILED;
374 } 360 }
375 break; 361 break;
376 case EVENT_ITEM: 362 case EVENT_ITEM:
@@ -382,7 +368,7 @@ create_arg_item(struct event_format *event, const char *token,
382 break; 368 break;
383 } 369 }
384 /* Consider this a field */ 370 /* Consider this a field */
385 field = pevent_find_any_field(event, token); 371 field = tep_find_any_field(event, token);
386 if (!field) { 372 if (!field) {
387 /* If token is 'COMM' or 'CPU' then it is special */ 373 /* If token is 'COMM' or 'CPU' then it is special */
388 if (strcmp(token, COMM) == 0) { 374 if (strcmp(token, COMM) == 0) {
@@ -402,7 +388,7 @@ create_arg_item(struct event_format *event, const char *token,
402 default: 388 default:
403 free_arg(arg); 389 free_arg(arg);
404 show_error(error_str, "expected a value but found %s", token); 390 show_error(error_str, "expected a value but found %s", token);
405 return PEVENT_ERRNO__UNEXPECTED_TYPE; 391 return TEP_ERRNO__UNEXPECTED_TYPE;
406 } 392 }
407 *parg = arg; 393 *parg = arg;
408 return 0; 394 return 0;
@@ -454,7 +440,7 @@ create_arg_cmp(enum filter_cmp_type ctype)
454 return arg; 440 return arg;
455} 441}
456 442
457static enum pevent_errno 443static enum tep_errno
458add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str) 444add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
459{ 445{
460 struct filter_arg *left; 446 struct filter_arg *left;
@@ -487,7 +473,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
487 break; 473 break;
488 default: 474 default:
489 show_error(error_str, "Illegal rvalue"); 475 show_error(error_str, "Illegal rvalue");
490 return PEVENT_ERRNO__ILLEGAL_RVALUE; 476 return TEP_ERRNO__ILLEGAL_RVALUE;
491 } 477 }
492 478
493 /* 479 /*
@@ -534,7 +520,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
534 if (left->type != FILTER_ARG_FIELD) { 520 if (left->type != FILTER_ARG_FIELD) {
535 show_error(error_str, 521 show_error(error_str,
536 "Illegal lvalue for string comparison"); 522 "Illegal lvalue for string comparison");
537 return PEVENT_ERRNO__ILLEGAL_LVALUE; 523 return TEP_ERRNO__ILLEGAL_LVALUE;
538 } 524 }
539 525
540 /* Make sure this is a valid string compare */ 526 /* 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)
553 show_error(error_str, 539 show_error(error_str,
554 "RegEx '%s' did not compute", 540 "RegEx '%s' did not compute",
555 str); 541 str);
556 return PEVENT_ERRNO__INVALID_REGEX; 542 return TEP_ERRNO__INVALID_REGEX;
557 } 543 }
558 break; 544 break;
559 default: 545 default:
560 show_error(error_str, 546 show_error(error_str,
561 "Illegal comparison for string"); 547 "Illegal comparison for string");
562 return PEVENT_ERRNO__ILLEGAL_STRING_CMP; 548 return TEP_ERRNO__ILLEGAL_STRING_CMP;
563 } 549 }
564 550
565 op->type = FILTER_ARG_STR; 551 op->type = FILTER_ARG_STR;
@@ -568,7 +554,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
568 op->str.val = strdup(str); 554 op->str.val = strdup(str);
569 if (!op->str.val) { 555 if (!op->str.val) {
570 show_error(error_str, "Failed to allocate string filter"); 556 show_error(error_str, "Failed to allocate string filter");
571 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 557 return TEP_ERRNO__MEM_ALLOC_FAILED;
572 } 558 }
573 /* 559 /*
574 * Need a buffer to copy data for tests 560 * 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)
576 op->str.buffer = malloc(op->str.field->size + 1); 562 op->str.buffer = malloc(op->str.field->size + 1);
577 if (!op->str.buffer) { 563 if (!op->str.buffer) {
578 show_error(error_str, "Failed to allocate string filter"); 564 show_error(error_str, "Failed to allocate string filter");
579 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 565 return TEP_ERRNO__MEM_ALLOC_FAILED;
580 } 566 }
581 /* Null terminate this buffer */ 567 /* Null terminate this buffer */
582 op->str.buffer[op->str.field->size] = 0; 568 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)
595 case FILTER_CMP_NOT_REGEX: 581 case FILTER_CMP_NOT_REGEX:
596 show_error(error_str, 582 show_error(error_str,
597 "Op not allowed with integers"); 583 "Op not allowed with integers");
598 return PEVENT_ERRNO__ILLEGAL_INTEGER_CMP; 584 return TEP_ERRNO__ILLEGAL_INTEGER_CMP;
599 585
600 default: 586 default:
601 break; 587 break;
@@ -616,7 +602,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
616 602
617 out_fail: 603 out_fail:
618 show_error(error_str, "Syntax error"); 604 show_error(error_str, "Syntax error");
619 return PEVENT_ERRNO__SYNTAX_ERROR; 605 return TEP_ERRNO__SYNTAX_ERROR;
620} 606}
621 607
622static struct filter_arg * 608static struct filter_arg *
@@ -629,7 +615,7 @@ rotate_op_right(struct filter_arg *a, struct filter_arg *b)
629 return arg; 615 return arg;
630} 616}
631 617
632static enum pevent_errno add_left(struct filter_arg *op, struct filter_arg *arg) 618static enum tep_errno add_left(struct filter_arg *op, struct filter_arg *arg)
633{ 619{
634 switch (op->type) { 620 switch (op->type) {
635 case FILTER_ARG_EXP: 621 case FILTER_ARG_EXP:
@@ -648,11 +634,11 @@ static enum pevent_errno add_left(struct filter_arg *op, struct filter_arg *arg)
648 /* left arg of compares must be a field */ 634 /* left arg of compares must be a field */
649 if (arg->type != FILTER_ARG_FIELD && 635 if (arg->type != FILTER_ARG_FIELD &&
650 arg->type != FILTER_ARG_BOOLEAN) 636 arg->type != FILTER_ARG_BOOLEAN)
651 return PEVENT_ERRNO__INVALID_ARG_TYPE; 637 return TEP_ERRNO__INVALID_ARG_TYPE;
652 op->num.left = arg; 638 op->num.left = arg;
653 break; 639 break;
654 default: 640 default:
655 return PEVENT_ERRNO__INVALID_ARG_TYPE; 641 return TEP_ERRNO__INVALID_ARG_TYPE;
656 } 642 }
657 return 0; 643 return 0;
658} 644}
@@ -765,7 +751,7 @@ enum filter_vals {
765 FILTER_VAL_TRUE, 751 FILTER_VAL_TRUE,
766}; 752};
767 753
768static enum pevent_errno 754static enum tep_errno
769reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child, 755reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child,
770 struct filter_arg *arg, char *error_str) 756 struct filter_arg *arg, char *error_str)
771{ 757{
@@ -775,7 +761,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child,
775 if (parent->type != FILTER_ARG_OP && 761 if (parent->type != FILTER_ARG_OP &&
776 arg->type != FILTER_ARG_OP) { 762 arg->type != FILTER_ARG_OP) {
777 show_error(error_str, "can not reparent other than OP"); 763 show_error(error_str, "can not reparent other than OP");
778 return PEVENT_ERRNO__REPARENT_NOT_OP; 764 return TEP_ERRNO__REPARENT_NOT_OP;
779 } 765 }
780 766
781 /* Get the sibling */ 767 /* Get the sibling */
@@ -787,7 +773,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child,
787 other_child = old_child->op.right; 773 other_child = old_child->op.right;
788 } else { 774 } else {
789 show_error(error_str, "Error in reparent op, find other child"); 775 show_error(error_str, "Error in reparent op, find other child");
790 return PEVENT_ERRNO__REPARENT_FAILED; 776 return TEP_ERRNO__REPARENT_FAILED;
791 } 777 }
792 778
793 /* Detach arg from old_child */ 779 /* Detach arg from old_child */
@@ -808,7 +794,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child,
808 ptr = &parent->op.left; 794 ptr = &parent->op.left;
809 else { 795 else {
810 show_error(error_str, "Error in reparent op"); 796 show_error(error_str, "Error in reparent op");
811 return PEVENT_ERRNO__REPARENT_FAILED; 797 return TEP_ERRNO__REPARENT_FAILED;
812 } 798 }
813 799
814 *ptr = arg; 800 *ptr = arg;
@@ -817,7 +803,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child,
817 return 0; 803 return 0;
818} 804}
819 805
820/* Returns either filter_vals (success) or pevent_errno (failfure) */ 806/* Returns either filter_vals (success) or tep_errno (failfure) */
821static int test_arg(struct filter_arg *parent, struct filter_arg *arg, 807static int test_arg(struct filter_arg *parent, struct filter_arg *arg,
822 char *error_str) 808 char *error_str)
823{ 809{
@@ -912,7 +898,7 @@ static int test_arg(struct filter_arg *parent, struct filter_arg *arg,
912 return rval; 898 return rval;
913 default: 899 default:
914 show_error(error_str, "bad arg in filter tree"); 900 show_error(error_str, "bad arg in filter tree");
915 return PEVENT_ERRNO__BAD_FILTER_ARG; 901 return TEP_ERRNO__BAD_FILTER_ARG;
916 } 902 }
917 return FILTER_VAL_NORM; 903 return FILTER_VAL_NORM;
918} 904}
@@ -937,7 +923,7 @@ static int collapse_tree(struct filter_arg *arg,
937 arg->boolean.value = ret == FILTER_VAL_TRUE; 923 arg->boolean.value = ret == FILTER_VAL_TRUE;
938 } else { 924 } else {
939 show_error(error_str, "Failed to allocate filter arg"); 925 show_error(error_str, "Failed to allocate filter arg");
940 ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; 926 ret = TEP_ERRNO__MEM_ALLOC_FAILED;
941 } 927 }
942 break; 928 break;
943 929
@@ -952,7 +938,7 @@ static int collapse_tree(struct filter_arg *arg,
952 return ret; 938 return ret;
953} 939}
954 940
955static enum pevent_errno 941static enum tep_errno
956process_filter(struct event_format *event, struct filter_arg **parg, 942process_filter(struct event_format *event, struct filter_arg **parg,
957 char *error_str, int not) 943 char *error_str, int not)
958{ 944{
@@ -966,7 +952,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
966 enum filter_op_type btype; 952 enum filter_op_type btype;
967 enum filter_exp_type etype; 953 enum filter_exp_type etype;
968 enum filter_cmp_type ctype; 954 enum filter_cmp_type ctype;
969 enum pevent_errno ret; 955 enum tep_errno ret;
970 956
971 *parg = NULL; 957 *parg = NULL;
972 958
@@ -1004,7 +990,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
1004 case EVENT_DELIM: 990 case EVENT_DELIM:
1005 if (*token == ',') { 991 if (*token == ',') {
1006 show_error(error_str, "Illegal token ','"); 992 show_error(error_str, "Illegal token ','");
1007 ret = PEVENT_ERRNO__ILLEGAL_TOKEN; 993 ret = TEP_ERRNO__ILLEGAL_TOKEN;
1008 goto fail; 994 goto fail;
1009 } 995 }
1010 996
@@ -1012,22 +998,22 @@ process_filter(struct event_format *event, struct filter_arg **parg,
1012 if (left_item) { 998 if (left_item) {
1013 show_error(error_str, 999 show_error(error_str,
1014 "Open paren can not come after item"); 1000 "Open paren can not come after item");
1015 ret = PEVENT_ERRNO__INVALID_PAREN; 1001 ret = TEP_ERRNO__INVALID_PAREN;
1016 goto fail; 1002 goto fail;
1017 } 1003 }
1018 if (current_exp) { 1004 if (current_exp) {
1019 show_error(error_str, 1005 show_error(error_str,
1020 "Open paren can not come after expression"); 1006 "Open paren can not come after expression");
1021 ret = PEVENT_ERRNO__INVALID_PAREN; 1007 ret = TEP_ERRNO__INVALID_PAREN;
1022 goto fail; 1008 goto fail;
1023 } 1009 }
1024 1010
1025 ret = process_filter(event, &arg, error_str, 0); 1011 ret = process_filter(event, &arg, error_str, 0);
1026 if (ret != PEVENT_ERRNO__UNBALANCED_PAREN) { 1012 if (ret != TEP_ERRNO__UNBALANCED_PAREN) {
1027 if (ret == 0) { 1013 if (ret == 0) {
1028 show_error(error_str, 1014 show_error(error_str,
1029 "Unbalanced number of '('"); 1015 "Unbalanced number of '('");
1030 ret = PEVENT_ERRNO__UNBALANCED_PAREN; 1016 ret = TEP_ERRNO__UNBALANCED_PAREN;
1031 } 1017 }
1032 goto fail; 1018 goto fail;
1033 } 1019 }
@@ -1064,7 +1050,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
1064 else 1050 else
1065 *parg = current_exp; 1051 *parg = current_exp;
1066 free(token); 1052 free(token);
1067 return PEVENT_ERRNO__UNBALANCED_PAREN; 1053 return TEP_ERRNO__UNBALANCED_PAREN;
1068 } 1054 }
1069 break; 1055 break;
1070 1056
@@ -1091,7 +1077,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
1091 case OP_NONE: 1077 case OP_NONE:
1092 show_error(error_str, 1078 show_error(error_str,
1093 "Unknown op token %s", token); 1079 "Unknown op token %s", token);
1094 ret = PEVENT_ERRNO__UNKNOWN_TOKEN; 1080 ret = TEP_ERRNO__UNKNOWN_TOKEN;
1095 goto fail; 1081 goto fail;
1096 } 1082 }
1097 1083
@@ -1179,11 +1165,11 @@ process_filter(struct event_format *event, struct filter_arg **parg,
1179 1165
1180 fail_alloc: 1166 fail_alloc:
1181 show_error(error_str, "failed to allocate filter arg"); 1167 show_error(error_str, "failed to allocate filter arg");
1182 ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; 1168 ret = TEP_ERRNO__MEM_ALLOC_FAILED;
1183 goto fail; 1169 goto fail;
1184 fail_syntax: 1170 fail_syntax:
1185 show_error(error_str, "Syntax error"); 1171 show_error(error_str, "Syntax error");
1186 ret = PEVENT_ERRNO__SYNTAX_ERROR; 1172 ret = TEP_ERRNO__SYNTAX_ERROR;
1187 fail: 1173 fail:
1188 free_arg(current_op); 1174 free_arg(current_op);
1189 free_arg(current_exp); 1175 free_arg(current_exp);
@@ -1192,13 +1178,13 @@ process_filter(struct event_format *event, struct filter_arg **parg,
1192 return ret; 1178 return ret;
1193} 1179}
1194 1180
1195static enum pevent_errno 1181static enum tep_errno
1196process_event(struct event_format *event, const char *filter_str, 1182process_event(struct event_format *event, const char *filter_str,
1197 struct filter_arg **parg, char *error_str) 1183 struct filter_arg **parg, char *error_str)
1198{ 1184{
1199 int ret; 1185 int ret;
1200 1186
1201 pevent_buffer_init(filter_str, strlen(filter_str)); 1187 tep_buffer_init(filter_str, strlen(filter_str));
1202 1188
1203 ret = process_filter(event, parg, error_str, 0); 1189 ret = process_filter(event, parg, error_str, 0);
1204 if (ret < 0) 1190 if (ret < 0)
@@ -1208,7 +1194,7 @@ process_event(struct event_format *event, const char *filter_str,
1208 if (!*parg) { 1194 if (!*parg) {
1209 *parg = allocate_arg(); 1195 *parg = allocate_arg();
1210 if (*parg == NULL) 1196 if (*parg == NULL)
1211 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 1197 return TEP_ERRNO__MEM_ALLOC_FAILED;
1212 1198
1213 (*parg)->type = FILTER_ARG_BOOLEAN; 1199 (*parg)->type = FILTER_ARG_BOOLEAN;
1214 (*parg)->boolean.value = FILTER_FALSE; 1200 (*parg)->boolean.value = FILTER_FALSE;
@@ -1217,13 +1203,13 @@ process_event(struct event_format *event, const char *filter_str,
1217 return 0; 1203 return 0;
1218} 1204}
1219 1205
1220static enum pevent_errno 1206static enum tep_errno
1221filter_event(struct event_filter *filter, struct event_format *event, 1207filter_event(struct event_filter *filter, struct event_format *event,
1222 const char *filter_str, char *error_str) 1208 const char *filter_str, char *error_str)
1223{ 1209{
1224 struct filter_type *filter_type; 1210 struct filter_type *filter_type;
1225 struct filter_arg *arg; 1211 struct filter_arg *arg;
1226 enum pevent_errno ret; 1212 enum tep_errno ret;
1227 1213
1228 if (filter_str) { 1214 if (filter_str) {
1229 ret = process_event(event, filter_str, &arg, error_str); 1215 ret = process_event(event, filter_str, &arg, error_str);
@@ -1234,7 +1220,7 @@ filter_event(struct event_filter *filter, struct event_format *event,
1234 /* just add a TRUE arg */ 1220 /* just add a TRUE arg */
1235 arg = allocate_arg(); 1221 arg = allocate_arg();
1236 if (arg == NULL) 1222 if (arg == NULL)
1237 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 1223 return TEP_ERRNO__MEM_ALLOC_FAILED;
1238 1224
1239 arg->type = FILTER_ARG_BOOLEAN; 1225 arg->type = FILTER_ARG_BOOLEAN;
1240 arg->boolean.value = FILTER_TRUE; 1226 arg->boolean.value = FILTER_TRUE;
@@ -1242,7 +1228,7 @@ filter_event(struct event_filter *filter, struct event_format *event,
1242 1228
1243 filter_type = add_filter_type(filter, event->id); 1229 filter_type = add_filter_type(filter, event->id);
1244 if (filter_type == NULL) 1230 if (filter_type == NULL)
1245 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 1231 return TEP_ERRNO__MEM_ALLOC_FAILED;
1246 1232
1247 if (filter_type->filter) 1233 if (filter_type->filter)
1248 free_arg(filter_type->filter); 1234 free_arg(filter_type->filter);
@@ -1254,23 +1240,23 @@ filter_event(struct event_filter *filter, struct event_format *event,
1254static void filter_init_error_buf(struct event_filter *filter) 1240static void filter_init_error_buf(struct event_filter *filter)
1255{ 1241{
1256 /* clear buffer to reset show error */ 1242 /* clear buffer to reset show error */
1257 pevent_buffer_init("", 0); 1243 tep_buffer_init("", 0);
1258 filter->error_buffer[0] = '\0'; 1244 filter->error_buffer[0] = '\0';
1259} 1245}
1260 1246
1261/** 1247/**
1262 * pevent_filter_add_filter_str - add a new filter 1248 * tep_filter_add_filter_str - add a new filter
1263 * @filter: the event filter to add to 1249 * @filter: the event filter to add to
1264 * @filter_str: the filter string that contains the filter 1250 * @filter_str: the filter string that contains the filter
1265 * 1251 *
1266 * Returns 0 if the filter was successfully added or a 1252 * 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
1268 * actual error message in case of error. 1254 * actual error message in case of error.
1269 */ 1255 */
1270enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter, 1256enum tep_errno tep_filter_add_filter_str(struct event_filter *filter,
1271 const char *filter_str) 1257 const char *filter_str)
1272{ 1258{
1273 struct pevent *pevent = filter->pevent; 1259 struct tep_handle *pevent = filter->pevent;
1274 struct event_list *event; 1260 struct event_list *event;
1275 struct event_list *events = NULL; 1261 struct event_list *events = NULL;
1276 const char *filter_start; 1262 const char *filter_start;
@@ -1279,7 +1265,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
1279 char *event_name = NULL; 1265 char *event_name = NULL;
1280 char *sys_name = NULL; 1266 char *sys_name = NULL;
1281 char *sp; 1267 char *sp;
1282 enum pevent_errno rtn = 0; /* PEVENT_ERRNO__SUCCESS */ 1268 enum tep_errno rtn = 0; /* TEP_ERRNO__SUCCESS */
1283 int len; 1269 int len;
1284 int ret; 1270 int ret;
1285 1271
@@ -1305,7 +1291,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
1305 if (this_event == NULL) { 1291 if (this_event == NULL) {
1306 /* This can only happen when events is NULL, but still */ 1292 /* This can only happen when events is NULL, but still */
1307 free_events(events); 1293 free_events(events);
1308 return PEVENT_ERRNO__MEM_ALLOC_FAILED; 1294 return TEP_ERRNO__MEM_ALLOC_FAILED;
1309 } 1295 }
1310 memcpy(this_event, filter_str, len); 1296 memcpy(this_event, filter_str, len);
1311 this_event[len] = 0; 1297 this_event[len] = 0;
@@ -1322,7 +1308,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
1322 /* This can only happen when events is NULL, but still */ 1308 /* This can only happen when events is NULL, but still */
1323 free_events(events); 1309 free_events(events);
1324 free(this_event); 1310 free(this_event);
1325 return PEVENT_ERRNO__FILTER_NOT_FOUND; 1311 return TEP_ERRNO__FILTER_NOT_FOUND;
1326 } 1312 }
1327 1313
1328 /* Find this event */ 1314 /* Find this event */
@@ -1349,7 +1335,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
1349 1335
1350 if (ret >= 0 && pevent->test_filters) { 1336 if (ret >= 0 && pevent->test_filters) {
1351 char *test; 1337 char *test;
1352 test = pevent_filter_make_string(filter, event->event->id); 1338 test = tep_filter_make_string(filter, event->event->id);
1353 if (test) { 1339 if (test) {
1354 printf(" '%s: %s'\n", event->event->name, test); 1340 printf(" '%s: %s'\n", event->event->name, test);
1355 free(test); 1341 free(test);
@@ -1371,7 +1357,7 @@ static void free_filter_type(struct filter_type *filter_type)
1371} 1357}
1372 1358
1373/** 1359/**
1374 * pevent_filter_strerror - fill error message in a buffer 1360 * tep_filter_strerror - fill error message in a buffer
1375 * @filter: the event filter contains error 1361 * @filter: the event filter contains error
1376 * @err: the error code 1362 * @err: the error code
1377 * @buf: the buffer to be filled in 1363 * @buf: the buffer to be filled in
@@ -1379,10 +1365,10 @@ static void free_filter_type(struct filter_type *filter_type)
1379 * 1365 *
1380 * Returns 0 if message was filled successfully, -1 if error 1366 * Returns 0 if message was filled successfully, -1 if error
1381 */ 1367 */
1382int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err, 1368int tep_filter_strerror(struct event_filter *filter, enum tep_errno err,
1383 char *buf, size_t buflen) 1369 char *buf, size_t buflen)
1384{ 1370{
1385 if (err <= __PEVENT_ERRNO__START || err >= __PEVENT_ERRNO__END) 1371 if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END)
1386 return -1; 1372 return -1;
1387 1373
1388 if (strlen(filter->error_buffer) > 0) { 1374 if (strlen(filter->error_buffer) > 0) {
@@ -1393,11 +1379,11 @@ int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err,
1393 return 0; 1379 return 0;
1394 } 1380 }
1395 1381
1396 return pevent_strerror(filter->pevent, err, buf, buflen); 1382 return tep_strerror(filter->pevent, err, buf, buflen);
1397} 1383}
1398 1384
1399/** 1385/**
1400 * pevent_filter_remove_event - remove a filter for an event 1386 * tep_filter_remove_event - remove a filter for an event
1401 * @filter: the event filter to remove from 1387 * @filter: the event filter to remove from
1402 * @event_id: the event to remove a filter for 1388 * @event_id: the event to remove a filter for
1403 * 1389 *
@@ -1407,8 +1393,8 @@ int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err,
1407 * Returns 1: if an event was removed 1393 * Returns 1: if an event was removed
1408 * 0: if the event was not found 1394 * 0: if the event was not found
1409 */ 1395 */
1410int pevent_filter_remove_event(struct event_filter *filter, 1396int tep_filter_remove_event(struct event_filter *filter,
1411 int event_id) 1397 int event_id)
1412{ 1398{
1413 struct filter_type *filter_type; 1399 struct filter_type *filter_type;
1414 unsigned long len; 1400 unsigned long len;
@@ -1437,12 +1423,12 @@ int pevent_filter_remove_event(struct event_filter *filter,
1437} 1423}
1438 1424
1439/** 1425/**
1440 * pevent_filter_reset - clear all filters in a filter 1426 * tep_filter_reset - clear all filters in a filter
1441 * @filter: the event filter to reset 1427 * @filter: the event filter to reset
1442 * 1428 *
1443 * Removes all filters from a filter and resets it. 1429 * Removes all filters from a filter and resets it.
1444 */ 1430 */
1445void pevent_filter_reset(struct event_filter *filter) 1431void tep_filter_reset(struct event_filter *filter)
1446{ 1432{
1447 int i; 1433 int i;
1448 1434
@@ -1454,11 +1440,11 @@ void pevent_filter_reset(struct event_filter *filter)
1454 filter->event_filters = NULL; 1440 filter->event_filters = NULL;
1455} 1441}
1456 1442
1457void pevent_filter_free(struct event_filter *filter) 1443void tep_filter_free(struct event_filter *filter)
1458{ 1444{
1459 pevent_unref(filter->pevent); 1445 tep_unref(filter->pevent);
1460 1446
1461 pevent_filter_reset(filter); 1447 tep_filter_reset(filter);
1462 1448
1463 free(filter); 1449 free(filter);
1464} 1450}
@@ -1478,7 +1464,7 @@ static int copy_filter_type(struct event_filter *filter,
1478 /* Can't assume that the pevent's are the same */ 1464 /* Can't assume that the pevent's are the same */
1479 sys = filter_type->event->system; 1465 sys = filter_type->event->system;
1480 name = filter_type->event->name; 1466 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);
1482 if (!event) 1468 if (!event)
1483 return -1; 1469 return -1;
1484 1470
@@ -1515,18 +1501,18 @@ static int copy_filter_type(struct event_filter *filter,
1515} 1501}
1516 1502
1517/** 1503/**
1518 * pevent_filter_copy - copy a filter using another filter 1504 * tep_filter_copy - copy a filter using another filter
1519 * @dest - the filter to copy to 1505 * @dest - the filter to copy to
1520 * @source - the filter to copy from 1506 * @source - the filter to copy from
1521 * 1507 *
1522 * Returns 0 on success and -1 if not all filters were copied 1508 * Returns 0 on success and -1 if not all filters were copied
1523 */ 1509 */
1524int pevent_filter_copy(struct event_filter *dest, struct event_filter *source) 1510int tep_filter_copy(struct event_filter *dest, struct event_filter *source)
1525{ 1511{
1526 int ret = 0; 1512 int ret = 0;
1527 int i; 1513 int i;
1528 1514
1529 pevent_filter_reset(dest); 1515 tep_filter_reset(dest);
1530 1516
1531 for (i = 0; i < source->filters; i++) { 1517 for (i = 0; i < source->filters; i++) {
1532 if (copy_filter_type(dest, source, &source->event_filters[i])) 1518 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)
1537 1523
1538 1524
1539/** 1525/**
1540 * pevent_update_trivial - update the trivial filters with the given filter 1526 * tep_update_trivial - update the trivial filters with the given filter
1541 * @dest - the filter to update 1527 * @dest - the filter to update
1542 * @source - the filter as the source of the update 1528 * @source - the filter as the source of the update
1543 * @type - the type of trivial filter to update. 1529 * @type - the type of trivial filter to update.
@@ -1547,11 +1533,11 @@ int pevent_filter_copy(struct event_filter *dest, struct event_filter *source)
1547 * Returns 0 on success and -1 if there was a problem updating, but 1533 * Returns 0 on success and -1 if there was a problem updating, but
1548 * events may have still been updated on error. 1534 * events may have still been updated on error.
1549 */ 1535 */
1550int pevent_update_trivial(struct event_filter *dest, struct event_filter *source, 1536int tep_update_trivial(struct event_filter *dest, struct event_filter *source,
1551 enum filter_trivial_type type) 1537 enum filter_trivial_type type)
1552{ 1538{
1553 struct pevent *src_pevent; 1539 struct tep_handle *src_pevent;
1554 struct pevent *dest_pevent; 1540 struct tep_handle *dest_pevent;
1555 struct event_format *event; 1541 struct event_format *event;
1556 struct filter_type *filter_type; 1542 struct filter_type *filter_type;
1557 struct filter_arg *arg; 1543 struct filter_arg *arg;
@@ -1578,14 +1564,14 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
1578 1564
1579 if (src_pevent != dest_pevent) { 1565 if (src_pevent != dest_pevent) {
1580 /* do a look up */ 1566 /* do a look up */
1581 event = pevent_find_event_by_name(src_pevent, 1567 event = tep_find_event_by_name(src_pevent,
1582 event->system, 1568 event->system,
1583 event->name); 1569 event->name);
1584 if (!event) 1570 if (!event)
1585 return -1; 1571 return -1;
1586 } 1572 }
1587 1573
1588 str = pevent_filter_make_string(source, event->id); 1574 str = tep_filter_make_string(source, event->id);
1589 if (!str) 1575 if (!str)
1590 continue; 1576 continue;
1591 1577
@@ -1598,7 +1584,7 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
1598} 1584}
1599 1585
1600/** 1586/**
1601 * pevent_filter_clear_trivial - clear TRUE and FALSE filters 1587 * tep_filter_clear_trivial - clear TRUE and FALSE filters
1602 * @filter: the filter to remove trivial filters from 1588 * @filter: the filter to remove trivial filters from
1603 * @type: remove only true, false, or both 1589 * @type: remove only true, false, or both
1604 * 1590 *
@@ -1606,8 +1592,8 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
1606 * 1592 *
1607 * Returns 0 on success and -1 if there was a problem. 1593 * Returns 0 on success and -1 if there was a problem.
1608 */ 1594 */
1609int pevent_filter_clear_trivial(struct event_filter *filter, 1595int tep_filter_clear_trivial(struct event_filter *filter,
1610 enum filter_trivial_type type) 1596 enum filter_trivial_type type)
1611{ 1597{
1612 struct filter_type *filter_type; 1598 struct filter_type *filter_type;
1613 int count = 0; 1599 int count = 0;
@@ -1653,14 +1639,14 @@ int pevent_filter_clear_trivial(struct event_filter *filter,
1653 return 0; 1639 return 0;
1654 1640
1655 for (i = 0; i < count; i++) 1641 for (i = 0; i < count; i++)
1656 pevent_filter_remove_event(filter, ids[i]); 1642 tep_filter_remove_event(filter, ids[i]);
1657 1643
1658 free(ids); 1644 free(ids);
1659 return 0; 1645 return 0;
1660} 1646}
1661 1647
1662/** 1648/**
1663 * pevent_filter_event_has_trivial - return true event contains trivial filter 1649 * tep_filter_event_has_trivial - return true event contains trivial filter
1664 * @filter: the filter with the information 1650 * @filter: the filter with the information
1665 * @event_id: the id of the event to test 1651 * @event_id: the id of the event to test
1666 * @type: trivial type to test for (TRUE, FALSE, EITHER) 1652 * @type: trivial type to test for (TRUE, FALSE, EITHER)
@@ -1668,9 +1654,9 @@ int pevent_filter_clear_trivial(struct event_filter *filter,
1668 * Returns 1 if the event contains a matching trivial type 1654 * Returns 1 if the event contains a matching trivial type
1669 * otherwise 0. 1655 * otherwise 0.
1670 */ 1656 */
1671int pevent_filter_event_has_trivial(struct event_filter *filter, 1657int tep_filter_event_has_trivial(struct event_filter *filter,
1672 int event_id, 1658 int event_id,
1673 enum filter_trivial_type type) 1659 enum filter_trivial_type type)
1674{ 1660{
1675 struct filter_type *filter_type; 1661 struct filter_type *filter_type;
1676 1662
@@ -1697,22 +1683,22 @@ int pevent_filter_event_has_trivial(struct event_filter *filter,
1697} 1683}
1698 1684
1699static int test_filter(struct event_format *event, struct filter_arg *arg, 1685static 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);
1701 1687
1702static const char * 1688static const char *
1703get_comm(struct event_format *event, struct pevent_record *record) 1689get_comm(struct event_format *event, struct tep_record *record)
1704{ 1690{
1705 const char *comm; 1691 const char *comm;
1706 int pid; 1692 int pid;
1707 1693
1708 pid = pevent_data_pid(event->pevent, record); 1694 pid = tep_data_pid(event->pevent, record);
1709 comm = pevent_data_comm_from_pid(event->pevent, pid); 1695 comm = tep_data_comm_from_pid(event->pevent, pid);
1710 return comm; 1696 return comm;
1711} 1697}
1712 1698
1713static unsigned long long 1699static unsigned long long
1714get_value(struct event_format *event, 1700get_value(struct event_format *event,
1715 struct format_field *field, struct pevent_record *record) 1701 struct format_field *field, struct tep_record *record)
1716{ 1702{
1717 unsigned long long val; 1703 unsigned long long val;
1718 1704
@@ -1728,7 +1714,7 @@ get_value(struct event_format *event,
1728 if (field == &cpu) 1714 if (field == &cpu)
1729 return record->cpu; 1715 return record->cpu;
1730 1716
1731 pevent_read_number_field(field, record->data, &val); 1717 tep_read_number_field(field, record->data, &val);
1732 1718
1733 if (!(field->flags & FIELD_IS_SIGNED)) 1719 if (!(field->flags & FIELD_IS_SIGNED))
1734 return val; 1720 return val;
@@ -1748,11 +1734,11 @@ get_value(struct event_format *event,
1748 1734
1749static unsigned long long 1735static unsigned long long
1750get_arg_value(struct event_format *event, struct filter_arg *arg, 1736get_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);
1752 1738
1753static unsigned long long 1739static unsigned long long
1754get_exp_value(struct event_format *event, struct filter_arg *arg, 1740get_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)
1756{ 1742{
1757 unsigned long long lval, rval; 1743 unsigned long long lval, rval;
1758 1744
@@ -1800,14 +1786,14 @@ get_exp_value(struct event_format *event, struct filter_arg *arg,
1800 case FILTER_EXP_NOT: 1786 case FILTER_EXP_NOT:
1801 default: 1787 default:
1802 if (!*err) 1788 if (!*err)
1803 *err = PEVENT_ERRNO__INVALID_EXP_TYPE; 1789 *err = TEP_ERRNO__INVALID_EXP_TYPE;
1804 } 1790 }
1805 return 0; 1791 return 0;
1806} 1792}
1807 1793
1808static unsigned long long 1794static unsigned long long
1809get_arg_value(struct event_format *event, struct filter_arg *arg, 1795get_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)
1811{ 1797{
1812 switch (arg->type) { 1798 switch (arg->type) {
1813 case FILTER_ARG_FIELD: 1799 case FILTER_ARG_FIELD:
@@ -1816,7 +1802,7 @@ get_arg_value(struct event_format *event, struct filter_arg *arg,
1816 case FILTER_ARG_VALUE: 1802 case FILTER_ARG_VALUE:
1817 if (arg->value.type != FILTER_NUMBER) { 1803 if (arg->value.type != FILTER_NUMBER) {
1818 if (!*err) 1804 if (!*err)
1819 *err = PEVENT_ERRNO__NOT_A_NUMBER; 1805 *err = TEP_ERRNO__NOT_A_NUMBER;
1820 } 1806 }
1821 return arg->value.val; 1807 return arg->value.val;
1822 1808
@@ -1825,13 +1811,13 @@ get_arg_value(struct event_format *event, struct filter_arg *arg,
1825 1811
1826 default: 1812 default:
1827 if (!*err) 1813 if (!*err)
1828 *err = PEVENT_ERRNO__INVALID_ARG_TYPE; 1814 *err = TEP_ERRNO__INVALID_ARG_TYPE;
1829 } 1815 }
1830 return 0; 1816 return 0;
1831} 1817}
1832 1818
1833static int test_num(struct event_format *event, struct filter_arg *arg, 1819static 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)
1835{ 1821{
1836 unsigned long long lval, rval; 1822 unsigned long long lval, rval;
1837 1823
@@ -1866,15 +1852,15 @@ static int test_num(struct event_format *event, struct filter_arg *arg,
1866 1852
1867 default: 1853 default:
1868 if (!*err) 1854 if (!*err)
1869 *err = PEVENT_ERRNO__ILLEGAL_INTEGER_CMP; 1855 *err = TEP_ERRNO__ILLEGAL_INTEGER_CMP;
1870 return 0; 1856 return 0;
1871 } 1857 }
1872} 1858}
1873 1859
1874static const char *get_field_str(struct filter_arg *arg, struct pevent_record *record) 1860static const char *get_field_str(struct filter_arg *arg, struct tep_record *record)
1875{ 1861{
1876 struct event_format *event; 1862 struct event_format *event;
1877 struct pevent *pevent; 1863 struct tep_handle *pevent;
1878 unsigned long long addr; 1864 unsigned long long addr;
1879 const char *val = NULL; 1865 const char *val = NULL;
1880 unsigned int size; 1866 unsigned int size;
@@ -1909,7 +1895,7 @@ static const char *get_field_str(struct filter_arg *arg, struct pevent_record *r
1909 1895
1910 if (arg->str.field->flags & (FIELD_IS_POINTER | FIELD_IS_LONG)) 1896 if (arg->str.field->flags & (FIELD_IS_POINTER | FIELD_IS_LONG))
1911 /* convert to a kernel symbol */ 1897 /* convert to a kernel symbol */
1912 val = pevent_find_function(pevent, addr); 1898 val = tep_find_function(pevent, addr);
1913 1899
1914 if (val == NULL) { 1900 if (val == NULL) {
1915 /* just use the hex of the string name */ 1901 /* 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
1922} 1908}
1923 1909
1924static int test_str(struct event_format *event, struct filter_arg *arg, 1910static 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)
1926{ 1912{
1927 const char *val; 1913 const char *val;
1928 1914
@@ -1947,13 +1933,13 @@ static int test_str(struct event_format *event, struct filter_arg *arg,
1947 1933
1948 default: 1934 default:
1949 if (!*err) 1935 if (!*err)
1950 *err = PEVENT_ERRNO__ILLEGAL_STRING_CMP; 1936 *err = TEP_ERRNO__ILLEGAL_STRING_CMP;
1951 return 0; 1937 return 0;
1952 } 1938 }
1953} 1939}
1954 1940
1955static int test_op(struct event_format *event, struct filter_arg *arg, 1941static 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)
1957{ 1943{
1958 switch (arg->op.type) { 1944 switch (arg->op.type) {
1959 case FILTER_OP_AND: 1945 case FILTER_OP_AND:
@@ -1969,13 +1955,13 @@ static int test_op(struct event_format *event, struct filter_arg *arg,
1969 1955
1970 default: 1956 default:
1971 if (!*err) 1957 if (!*err)
1972 *err = PEVENT_ERRNO__INVALID_OP_TYPE; 1958 *err = TEP_ERRNO__INVALID_OP_TYPE;
1973 return 0; 1959 return 0;
1974 } 1960 }
1975} 1961}
1976 1962
1977static int test_filter(struct event_format *event, struct filter_arg *arg, 1963static 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)
1979{ 1965{
1980 if (*err) { 1966 if (*err) {
1981 /* 1967 /*
@@ -2009,20 +1995,20 @@ static int test_filter(struct event_format *event, struct filter_arg *arg,
2009 1995
2010 default: 1996 default:
2011 if (!*err) 1997 if (!*err)
2012 *err = PEVENT_ERRNO__INVALID_ARG_TYPE; 1998 *err = TEP_ERRNO__INVALID_ARG_TYPE;
2013 return 0; 1999 return 0;
2014 } 2000 }
2015} 2001}
2016 2002
2017/** 2003/**
2018 * pevent_event_filtered - return true if event has filter 2004 * tep_event_filtered - return true if event has filter
2019 * @filter: filter struct with filter information 2005 * @filter: filter struct with filter information
2020 * @event_id: event id to test if filter exists 2006 * @event_id: event id to test if filter exists
2021 * 2007 *
2022 * Returns 1 if filter found for @event_id 2008 * Returns 1 if filter found for @event_id
2023 * otherwise 0; 2009 * otherwise 0;
2024 */ 2010 */
2025int pevent_event_filtered(struct event_filter *filter, int event_id) 2011int tep_event_filtered(struct event_filter *filter, int event_id)
2026{ 2012{
2027 struct filter_type *filter_type; 2013 struct filter_type *filter_type;
2028 2014
@@ -2035,42 +2021,42 @@ int pevent_event_filtered(struct event_filter *filter, int event_id)
2035} 2021}
2036 2022
2037/** 2023/**
2038 * pevent_filter_match - test if a record matches a filter 2024 * tep_filter_match - test if a record matches a filter
2039 * @filter: filter struct with filter information 2025 * @filter: filter struct with filter information
2040 * @record: the record to test against the filter 2026 * @record: the record to test against the filter
2041 * 2027 *
2042 * Returns: match result or error code (prefixed with PEVENT_ERRNO__) 2028 * Returns: match result or error code (prefixed with TEP_ERRNO__)
2043 * FILTER_MATCH - filter found for event and @record matches 2029 * FILTER_MATCH - filter found for event and @record matches
2044 * FILTER_MISS - filter found for event and @record does not match 2030 * FILTER_MISS - filter found for event and @record does not match
2045 * FILTER_NOT_FOUND - no filter found for @record's event 2031 * FILTER_NOT_FOUND - no filter found for @record's event
2046 * NO_FILTER - if no filters exist 2032 * NO_FILTER - if no filters exist
2047 * otherwise - error occurred during test 2033 * otherwise - error occurred during test
2048 */ 2034 */
2049enum pevent_errno pevent_filter_match(struct event_filter *filter, 2035enum tep_errno tep_filter_match(struct event_filter *filter,
2050 struct pevent_record *record) 2036 struct tep_record *record)
2051{ 2037{
2052 struct pevent *pevent = filter->pevent; 2038 struct tep_handle *pevent = filter->pevent;
2053 struct filter_type *filter_type; 2039 struct filter_type *filter_type;
2054 int event_id; 2040 int event_id;
2055 int ret; 2041 int ret;
2056 enum pevent_errno err = 0; 2042 enum tep_errno err = 0;
2057 2043
2058 filter_init_error_buf(filter); 2044 filter_init_error_buf(filter);
2059 2045
2060 if (!filter->filters) 2046 if (!filter->filters)
2061 return PEVENT_ERRNO__NO_FILTER; 2047 return TEP_ERRNO__NO_FILTER;
2062 2048
2063 event_id = pevent_data_type(pevent, record); 2049 event_id = tep_data_type(pevent, record);
2064 2050
2065 filter_type = find_filter_type(filter, event_id); 2051 filter_type = find_filter_type(filter, event_id);
2066 if (!filter_type) 2052 if (!filter_type)
2067 return PEVENT_ERRNO__FILTER_NOT_FOUND; 2053 return TEP_ERRNO__FILTER_NOT_FOUND;
2068 2054
2069 ret = test_filter(filter_type->event, filter_type->filter, record, &err); 2055 ret = test_filter(filter_type->event, filter_type->filter, record, &err);
2070 if (err) 2056 if (err)
2071 return err; 2057 return err;
2072 2058
2073 return ret ? PEVENT_ERRNO__FILTER_MATCH : PEVENT_ERRNO__FILTER_MISS; 2059 return ret ? TEP_ERRNO__FILTER_MATCH : TEP_ERRNO__FILTER_MISS;
2074} 2060}
2075 2061
2076static char *op_to_str(struct event_filter *filter, struct filter_arg *arg) 2062static 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)
2364} 2350}
2365 2351
2366/** 2352/**
2367 * pevent_filter_make_string - return a string showing the filter 2353 * tep_filter_make_string - return a string showing the filter
2368 * @filter: filter struct with filter information 2354 * @filter: filter struct with filter information
2369 * @event_id: the event id to return the filter string with 2355 * @event_id: the event id to return the filter string with
2370 * 2356 *
@@ -2373,7 +2359,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
2373 * NULL is returned if no filter is found or allocation failed. 2359 * NULL is returned if no filter is found or allocation failed.
2374 */ 2360 */
2375char * 2361char *
2376pevent_filter_make_string(struct event_filter *filter, int event_id) 2362tep_filter_make_string(struct event_filter *filter, int event_id)
2377{ 2363{
2378 struct filter_type *filter_type; 2364 struct filter_type *filter_type;
2379 2365
@@ -2389,7 +2375,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id)
2389} 2375}
2390 2376
2391/** 2377/**
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
2393 * @filter1: Filter to compare with @filter2 2379 * @filter1: Filter to compare with @filter2
2394 * @filter2: Filter to compare with @filter1 2380 * @filter2: Filter to compare with @filter1
2395 * 2381 *
@@ -2397,7 +2383,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id)
2397 * 1 if the two filters hold the same content. 2383 * 1 if the two filters hold the same content.
2398 * 0 if they do not. 2384 * 0 if they do not.
2399 */ 2385 */
2400int pevent_filter_compare(struct event_filter *filter1, struct event_filter *filter2) 2386int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2)
2401{ 2387{
2402 struct filter_type *filter_type1; 2388 struct filter_type *filter_type1;
2403 struct filter_type *filter_type2; 2389 struct filter_type *filter_type2;
diff --git a/tools/lib/traceevent/parse-utils.c b/tools/lib/traceevent/parse-utils.c
index eda07fa31dca..77e4ec6402dd 100644
--- a/tools/lib/traceevent/parse-utils.c
+++ b/tools/lib/traceevent/parse-utils.c
@@ -1,21 +1,7 @@
1// SPDX-License-Identifier: LGPL-2.1
1/* 2/*
2 * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> 3 * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3 * 4 *
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 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */ 5 */
20#include <stdio.h> 6#include <stdio.h>
21#include <stdlib.h> 7#include <stdlib.h>
diff --git a/tools/lib/traceevent/plugin_cfg80211.c b/tools/lib/traceevent/plugin_cfg80211.c
index 8f8586912da7..a51b366f47da 100644
--- a/tools/lib/traceevent/plugin_cfg80211.c
+++ b/tools/lib/traceevent/plugin_cfg80211.c
@@ -25,19 +25,19 @@ process___le16_to_cpup(struct trace_seq *s, unsigned long long *args)
25 return val ? (long long) le16toh(*val) : 0; 25 return val ? (long long) le16toh(*val) : 0;
26} 26}
27 27
28int PEVENT_PLUGIN_LOADER(struct pevent *pevent) 28int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
29{ 29{
30 pevent_register_print_function(pevent, 30 tep_register_print_function(pevent,
31 process___le16_to_cpup, 31 process___le16_to_cpup,
32 PEVENT_FUNC_ARG_INT, 32 TEP_FUNC_ARG_INT,
33 "__le16_to_cpup", 33 "__le16_to_cpup",
34 PEVENT_FUNC_ARG_PTR, 34 TEP_FUNC_ARG_PTR,
35 PEVENT_FUNC_ARG_VOID); 35 TEP_FUNC_ARG_VOID);
36 return 0; 36 return 0;
37} 37}
38 38
39void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) 39void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
40{ 40{
41 pevent_unregister_print_function(pevent, process___le16_to_cpup, 41 tep_unregister_print_function(pevent, process___le16_to_cpup,
42 "__le16_to_cpup"); 42 "__le16_to_cpup");
43} 43}
diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c
index 42dbf73758f3..424747475d37 100644
--- a/tools/lib/traceevent/plugin_function.c
+++ b/tools/lib/traceevent/plugin_function.c
@@ -33,7 +33,7 @@ static int cpus = -1;
33 33
34#define STK_BLK 10 34#define STK_BLK 10
35 35
36struct pevent_plugin_option plugin_options[] = 36struct tep_plugin_option plugin_options[] =
37{ 37{
38 { 38 {
39 .name = "parent", 39 .name = "parent",
@@ -53,8 +53,8 @@ struct pevent_plugin_option plugin_options[] =
53 } 53 }
54}; 54};
55 55
56static struct pevent_plugin_option *ftrace_parent = &plugin_options[0]; 56static struct tep_plugin_option *ftrace_parent = &plugin_options[0];
57static struct pevent_plugin_option *ftrace_indent = &plugin_options[1]; 57static struct tep_plugin_option *ftrace_indent = &plugin_options[1];
58 58
59static void add_child(struct func_stack *stack, const char *child, int pos) 59static void add_child(struct func_stack *stack, const char *child, int pos)
60{ 60{
@@ -122,25 +122,25 @@ static int add_and_get_index(const char *parent, const char *child, int cpu)
122 return 0; 122 return 0;
123} 123}
124 124
125static int function_handler(struct trace_seq *s, struct pevent_record *record, 125static int function_handler(struct trace_seq *s, struct tep_record *record,
126 struct event_format *event, void *context) 126 struct event_format *event, void *context)
127{ 127{
128 struct pevent *pevent = event->pevent; 128 struct tep_handle *pevent = event->pevent;
129 unsigned long long function; 129 unsigned long long function;
130 unsigned long long pfunction; 130 unsigned long long pfunction;
131 const char *func; 131 const char *func;
132 const char *parent; 132 const char *parent;
133 int index = 0; 133 int index = 0;
134 134
135 if (pevent_get_field_val(s, event, "ip", record, &function, 1)) 135 if (tep_get_field_val(s, event, "ip", record, &function, 1))
136 return trace_seq_putc(s, '!'); 136 return trace_seq_putc(s, '!');
137 137
138 func = pevent_find_function(pevent, function); 138 func = tep_find_function(pevent, function);
139 139
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))
141 return trace_seq_putc(s, '!'); 141 return trace_seq_putc(s, '!');
142 142
143 parent = pevent_find_function(pevent, pfunction); 143 parent = tep_find_function(pevent, pfunction);
144 144
145 if (parent && ftrace_indent->set) 145 if (parent && ftrace_indent->set)
146 index = add_and_get_index(parent, func, record->cpu); 146 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,
163 return 0; 163 return 0;
164} 164}
165 165
166int PEVENT_PLUGIN_LOADER(struct pevent *pevent) 166int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
167{ 167{
168 pevent_register_event_handler(pevent, -1, "ftrace", "function", 168 tep_register_event_handler(pevent, -1, "ftrace", "function",
169 function_handler, NULL); 169 function_handler, NULL);
170 170
171 traceevent_plugin_add_options("ftrace", plugin_options); 171 tep_plugin_add_options("ftrace", plugin_options);
172 172
173 return 0; 173 return 0;
174} 174}
175 175
176void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) 176void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
177{ 177{
178 int i, x; 178 int i, x;
179 179
180 pevent_unregister_event_handler(pevent, -1, "ftrace", "function", 180 tep_unregister_event_handler(pevent, -1, "ftrace", "function",
181 function_handler, NULL); 181 function_handler, NULL);
182 182
183 for (i = 0; i <= cpus; i++) { 183 for (i = 0; i <= cpus; i++) {
184 for (x = 0; x < fstack[i].size && fstack[i].stack[x]; x++) 184 for (x = 0; x < fstack[i].size && fstack[i].stack[x]; x++)
@@ -186,7 +186,7 @@ void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
186 free(fstack[i].stack); 186 free(fstack[i].stack);
187 } 187 }
188 188
189 traceevent_plugin_remove_options(plugin_options); 189 tep_plugin_remove_options(plugin_options);
190 190
191 free(fstack); 191 free(fstack);
192 fstack = NULL; 192 fstack = NULL;
diff --git a/tools/lib/traceevent/plugin_hrtimer.c b/tools/lib/traceevent/plugin_hrtimer.c
index 12bf14cc1152..b43bfec565d8 100644
--- a/tools/lib/traceevent/plugin_hrtimer.c
+++ b/tools/lib/traceevent/plugin_hrtimer.c
@@ -25,64 +25,64 @@
25#include "event-parse.h" 25#include "event-parse.h"
26 26
27static int timer_expire_handler(struct trace_seq *s, 27static int timer_expire_handler(struct trace_seq *s,
28 struct pevent_record *record, 28 struct tep_record *record,
29 struct event_format *event, void *context) 29 struct event_format *event, void *context)
30{ 30{
31 trace_seq_printf(s, "hrtimer="); 31 trace_seq_printf(s, "hrtimer=");
32 32
33 if (pevent_print_num_field(s, "0x%llx", event, "timer", 33 if (tep_print_num_field(s, "0x%llx", event, "timer",
34 record, 0) == -1) 34 record, 0) == -1)
35 pevent_print_num_field(s, "0x%llx", event, "hrtimer", 35 tep_print_num_field(s, "0x%llx", event, "hrtimer",
36 record, 1); 36 record, 1);
37 37
38 trace_seq_printf(s, " now="); 38 trace_seq_printf(s, " now=");
39 39
40 pevent_print_num_field(s, "%llu", event, "now", record, 1); 40 tep_print_num_field(s, "%llu", event, "now", record, 1);
41 41
42 pevent_print_func_field(s, " function=%s", event, "function", 42 tep_print_func_field(s, " function=%s", event, "function",
43 record, 0); 43 record, 0);
44 return 0; 44 return 0;
45} 45}
46 46
47static int timer_start_handler(struct trace_seq *s, 47static int timer_start_handler(struct trace_seq *s,
48 struct pevent_record *record, 48 struct tep_record *record,
49 struct event_format *event, void *context) 49 struct event_format *event, void *context)
50{ 50{
51 trace_seq_printf(s, "hrtimer="); 51 trace_seq_printf(s, "hrtimer=");
52 52
53 if (pevent_print_num_field(s, "0x%llx", event, "timer", 53 if (tep_print_num_field(s, "0x%llx", event, "timer",
54 record, 0) == -1) 54 record, 0) == -1)
55 pevent_print_num_field(s, "0x%llx", event, "hrtimer", 55 tep_print_num_field(s, "0x%llx", event, "hrtimer",
56 record, 1); 56 record, 1);
57 57
58 pevent_print_func_field(s, " function=%s", event, "function", 58 tep_print_func_field(s, " function=%s", event, "function",
59 record, 0); 59 record, 0);
60 60
61 trace_seq_printf(s, " expires="); 61 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);
63 63
64 trace_seq_printf(s, " softexpires="); 64 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);
66 return 0; 66 return 0;
67} 67}
68 68
69int PEVENT_PLUGIN_LOADER(struct pevent *pevent) 69int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
70{ 70{
71 pevent_register_event_handler(pevent, -1, 71 tep_register_event_handler(pevent, -1,
72 "timer", "hrtimer_expire_entry", 72 "timer", "hrtimer_expire_entry",
73 timer_expire_handler, NULL); 73 timer_expire_handler, NULL);
74 74
75 pevent_register_event_handler(pevent, -1, "timer", "hrtimer_start", 75 tep_register_event_handler(pevent, -1, "timer", "hrtimer_start",
76 timer_start_handler, NULL); 76 timer_start_handler, NULL);
77 return 0; 77 return 0;
78} 78}
79 79
80void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) 80void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
81{ 81{
82 pevent_unregister_event_handler(pevent, -1, 82 tep_unregister_event_handler(pevent, -1,
83 "timer", "hrtimer_expire_entry", 83 "timer", "hrtimer_expire_entry",
84 timer_expire_handler, NULL); 84 timer_expire_handler, NULL);
85 85
86 pevent_unregister_event_handler(pevent, -1, "timer", "hrtimer_start", 86 tep_unregister_event_handler(pevent, -1, "timer", "hrtimer_start",
87 timer_start_handler, NULL); 87 timer_start_handler, NULL);
88} 88}
diff --git a/tools/lib/traceevent/plugin_jbd2.c b/tools/lib/traceevent/plugin_jbd2.c
index 5c23d5bd27ce..45a9acd19640 100644
--- a/tools/lib/traceevent/plugin_jbd2.c
+++ b/tools/lib/traceevent/plugin_jbd2.c
@@ -47,29 +47,29 @@ process_jiffies_to_msecs(struct trace_seq *s, unsigned long long *args)
47 return jiffies; 47 return jiffies;
48} 48}
49 49
50int PEVENT_PLUGIN_LOADER(struct pevent *pevent) 50int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
51{ 51{
52 pevent_register_print_function(pevent, 52 tep_register_print_function(pevent,
53 process_jbd2_dev_to_name, 53 process_jbd2_dev_to_name,
54 PEVENT_FUNC_ARG_STRING, 54 TEP_FUNC_ARG_STRING,
55 "jbd2_dev_to_name", 55 "jbd2_dev_to_name",
56 PEVENT_FUNC_ARG_INT, 56 TEP_FUNC_ARG_INT,
57 PEVENT_FUNC_ARG_VOID); 57 TEP_FUNC_ARG_VOID);
58 58
59 pevent_register_print_function(pevent, 59 tep_register_print_function(pevent,
60 process_jiffies_to_msecs, 60 process_jiffies_to_msecs,
61 PEVENT_FUNC_ARG_LONG, 61 TEP_FUNC_ARG_LONG,
62 "jiffies_to_msecs", 62 "jiffies_to_msecs",
63 PEVENT_FUNC_ARG_LONG, 63 TEP_FUNC_ARG_LONG,
64 PEVENT_FUNC_ARG_VOID); 64 TEP_FUNC_ARG_VOID);
65 return 0; 65 return 0;
66} 66}
67 67
68void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) 68void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
69{ 69{
70 pevent_unregister_print_function(pevent, process_jbd2_dev_to_name, 70 tep_unregister_print_function(pevent, process_jbd2_dev_to_name,
71 "jbd2_dev_to_name"); 71 "jbd2_dev_to_name");
72 72
73 pevent_unregister_print_function(pevent, process_jiffies_to_msecs, 73 tep_unregister_print_function(pevent, process_jiffies_to_msecs,
74 "jiffies_to_msecs"); 74 "jiffies_to_msecs");
75} 75}
diff --git a/tools/lib/traceevent/plugin_kmem.c b/tools/lib/traceevent/plugin_kmem.c
index 70650ff48d78..73966b05abce 100644
--- a/tools/lib/traceevent/plugin_kmem.c
+++ b/tools/lib/traceevent/plugin_kmem.c
@@ -23,7 +23,7 @@
23 23
24#include "event-parse.h" 24#include "event-parse.h"
25 25
26static int call_site_handler(struct trace_seq *s, struct pevent_record *record, 26static int call_site_handler(struct trace_seq *s, struct tep_record *record,
27 struct event_format *event, void *context) 27 struct event_format *event, void *context)
28{ 28{
29 struct format_field *field; 29 struct format_field *field;
@@ -31,64 +31,64 @@ static int call_site_handler(struct trace_seq *s, struct pevent_record *record,
31 void *data = record->data; 31 void *data = record->data;
32 const char *func; 32 const char *func;
33 33
34 field = pevent_find_field(event, "call_site"); 34 field = tep_find_field(event, "call_site");
35 if (!field) 35 if (!field)
36 return 1; 36 return 1;
37 37
38 if (pevent_read_number_field(field, data, &val)) 38 if (tep_read_number_field(field, data, &val))
39 return 1; 39 return 1;
40 40
41 func = pevent_find_function(event->pevent, val); 41 func = tep_find_function(event->pevent, val);
42 if (!func) 42 if (!func)
43 return 1; 43 return 1;
44 44
45 addr = pevent_find_function_address(event->pevent, val); 45 addr = tep_find_function_address(event->pevent, val);
46 46
47 trace_seq_printf(s, "(%s+0x%x) ", func, (int)(val - addr)); 47 trace_seq_printf(s, "(%s+0x%x) ", func, (int)(val - addr));
48 return 1; 48 return 1;
49} 49}
50 50
51int PEVENT_PLUGIN_LOADER(struct pevent *pevent) 51int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
52{ 52{
53 pevent_register_event_handler(pevent, -1, "kmem", "kfree", 53 tep_register_event_handler(pevent, -1, "kmem", "kfree",
54 call_site_handler, NULL); 54 call_site_handler, NULL);
55 55
56 pevent_register_event_handler(pevent, -1, "kmem", "kmalloc", 56 tep_register_event_handler(pevent, -1, "kmem", "kmalloc",
57 call_site_handler, NULL); 57 call_site_handler, NULL);
58 58
59 pevent_register_event_handler(pevent, -1, "kmem", "kmalloc_node", 59 tep_register_event_handler(pevent, -1, "kmem", "kmalloc_node",
60 call_site_handler, NULL); 60 call_site_handler, NULL);
61 61
62 pevent_register_event_handler(pevent, -1, "kmem", "kmem_cache_alloc", 62 tep_register_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
63 call_site_handler, NULL); 63 call_site_handler, NULL);
64 64
65 pevent_register_event_handler(pevent, -1, "kmem", 65 tep_register_event_handler(pevent, -1, "kmem",
66 "kmem_cache_alloc_node", 66 "kmem_cache_alloc_node",
67 call_site_handler, NULL); 67 call_site_handler, NULL);
68 68
69 pevent_register_event_handler(pevent, -1, "kmem", "kmem_cache_free", 69 tep_register_event_handler(pevent, -1, "kmem", "kmem_cache_free",
70 call_site_handler, NULL); 70 call_site_handler, NULL);
71 return 0; 71 return 0;
72} 72}
73 73
74void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) 74void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
75{ 75{
76 pevent_unregister_event_handler(pevent, -1, "kmem", "kfree", 76 tep_unregister_event_handler(pevent, -1, "kmem", "kfree",
77 call_site_handler, NULL); 77 call_site_handler, NULL);
78 78
79 pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc", 79 tep_unregister_event_handler(pevent, -1, "kmem", "kmalloc",
80 call_site_handler, NULL); 80 call_site_handler, NULL);
81 81
82 pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc_node", 82 tep_unregister_event_handler(pevent, -1, "kmem", "kmalloc_node",
83 call_site_handler, NULL); 83 call_site_handler, NULL);
84 84
85 pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_alloc", 85 tep_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
86 call_site_handler, NULL); 86 call_site_handler, NULL);
87 87
88 pevent_unregister_event_handler(pevent, -1, "kmem", 88 tep_unregister_event_handler(pevent, -1, "kmem",
89 "kmem_cache_alloc_node", 89 "kmem_cache_alloc_node",
90 call_site_handler, NULL); 90 call_site_handler, NULL);
91 91
92 pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_free", 92 tep_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_free",
93 call_site_handler, NULL); 93 call_site_handler, NULL);
94} 94}
diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c
index 18536f756577..1d0d15906225 100644
--- a/tools/lib/traceevent/plugin_kvm.c
+++ b/tools/lib/traceevent/plugin_kvm.c
@@ -247,17 +247,17 @@ static const char *find_exit_reason(unsigned isa, int val)
247 return strings[i].str; 247 return strings[i].str;
248} 248}
249 249
250static int print_exit_reason(struct trace_seq *s, struct pevent_record *record, 250static int print_exit_reason(struct trace_seq *s, struct tep_record *record,
251 struct event_format *event, const char *field) 251 struct event_format *event, const char *field)
252{ 252{
253 unsigned long long isa; 253 unsigned long long isa;
254 unsigned long long val; 254 unsigned long long val;
255 const char *reason; 255 const char *reason;
256 256
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)
258 return -1; 258 return -1;
259 259
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)
261 isa = 1; 261 isa = 1;
262 262
263 reason = find_exit_reason(isa, val); 263 reason = find_exit_reason(isa, val);
@@ -268,7 +268,7 @@ static int print_exit_reason(struct trace_seq *s, struct pevent_record *record,
268 return 0; 268 return 0;
269} 269}
270 270
271static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record, 271static int kvm_exit_handler(struct trace_seq *s, struct tep_record *record,
272 struct event_format *event, void *context) 272 struct event_format *event, void *context)
273{ 273{
274 unsigned long long info1 = 0, info2 = 0; 274 unsigned long long info1 = 0, info2 = 0;
@@ -276,10 +276,10 @@ static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record,
276 if (print_exit_reason(s, record, event, "exit_reason") < 0) 276 if (print_exit_reason(s, record, event, "exit_reason") < 0)
277 return -1; 277 return -1;
278 278
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);
280 280
281 if (pevent_get_field_val(s, event, "info1", record, &info1, 0) >= 0 281 if (tep_get_field_val(s, event, "info1", record, &info1, 0) >= 0
282 && pevent_get_field_val(s, event, "info2", record, &info2, 0) >= 0) 282 && tep_get_field_val(s, event, "info2", record, &info2, 0) >= 0)
283 trace_seq_printf(s, " info %llx %llx", info1, info2); 283 trace_seq_printf(s, " info %llx %llx", info1, info2);
284 284
285 return 0; 285 return 0;
@@ -291,7 +291,7 @@ static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record,
291#define KVM_EMUL_INSN_F_CS_L (1 << 3) 291#define KVM_EMUL_INSN_F_CS_L (1 << 3)
292 292
293static int kvm_emulate_insn_handler(struct trace_seq *s, 293static int kvm_emulate_insn_handler(struct trace_seq *s,
294 struct pevent_record *record, 294 struct tep_record *record,
295 struct event_format *event, void *context) 295 struct event_format *event, void *context)
296{ 296{
297 unsigned long long rip, csbase, len, flags, failed; 297 unsigned long long rip, csbase, len, flags, failed;
@@ -299,22 +299,22 @@ static int kvm_emulate_insn_handler(struct trace_seq *s,
299 uint8_t *insn; 299 uint8_t *insn;
300 const char *disasm; 300 const char *disasm;
301 301
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)
303 return -1; 303 return -1;
304 304
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)
306 return -1; 306 return -1;
307 307
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)
309 return -1; 309 return -1;
310 310
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)
312 return -1; 312 return -1;
313 313
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)
315 return -1; 315 return -1;
316 316
317 insn = pevent_get_field_raw(s, event, "insn", record, &llen, 1); 317 insn = tep_get_field_raw(s, event, "insn", record, &llen, 1);
318 if (!insn) 318 if (!insn)
319 return -1; 319 return -1;
320 320
@@ -330,24 +330,24 @@ static int kvm_emulate_insn_handler(struct trace_seq *s,
330} 330}
331 331
332 332
333static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct pevent_record *record, 333static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct tep_record *record,
334 struct event_format *event, void *context) 334 struct event_format *event, void *context)
335{ 335{
336 if (print_exit_reason(s, record, event, "exit_code") < 0) 336 if (print_exit_reason(s, record, event, "exit_code") < 0)
337 return -1; 337 return -1;
338 338
339 pevent_print_num_field(s, " info1 %llx", event, "exit_info1", record, 1); 339 tep_print_num_field(s, " info1 %llx", event, "exit_info1", record, 1);
340 pevent_print_num_field(s, " info2 %llx", event, "exit_info2", record, 1); 340 tep_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); 341 tep_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); 342 tep_print_num_field(s, " int_info_err %llx", event, "exit_int_info_err", record, 1);
343 343
344 return 0; 344 return 0;
345} 345}
346 346
347static int kvm_nested_vmexit_handler(struct trace_seq *s, struct pevent_record *record, 347static int kvm_nested_vmexit_handler(struct trace_seq *s, struct tep_record *record,
348 struct event_format *event, void *context) 348 struct event_format *event, void *context)
349{ 349{
350 pevent_print_num_field(s, "rip %llx ", event, "rip", record, 1); 350 tep_print_num_field(s, "rip %llx ", event, "rip", record, 1);
351 351
352 return kvm_nested_vmexit_inject_handler(s, record, event, context); 352 return kvm_nested_vmexit_inject_handler(s, record, event, context);
353} 353}
@@ -370,7 +370,7 @@ union kvm_mmu_page_role {
370 }; 370 };
371}; 371};
372 372
373static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record, 373static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record,
374 struct event_format *event, void *context) 374 struct event_format *event, void *context)
375{ 375{
376 unsigned long long val; 376 unsigned long long val;
@@ -379,7 +379,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record,
379 }; 379 };
380 union kvm_mmu_page_role role; 380 union kvm_mmu_page_role role;
381 381
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)
383 return -1; 383 return -1;
384 384
385 role.word = (int)val; 385 role.word = (int)val;
@@ -388,8 +388,8 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record,
388 * We can only use the structure if file is of the same 388 * We can only use the structure if file is of the same
389 * endianess. 389 * endianess.
390 */ 390 */
391 if (pevent_is_file_bigendian(event->pevent) == 391 if (tep_is_file_bigendian(event->pevent) ==
392 pevent_is_host_bigendian(event->pevent)) { 392 tep_is_host_bigendian(event->pevent)) {
393 393
394 trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s", 394 trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s",
395 role.level, 395 role.level,
@@ -406,10 +406,10 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record,
406 } else 406 } else
407 trace_seq_printf(s, "WORD: %08x", role.word); 407 trace_seq_printf(s, "WORD: %08x", role.word);
408 408
409 pevent_print_num_field(s, " root %u ", event, 409 tep_print_num_field(s, " root %u ", event,
410 "root_count", record, 1); 410 "root_count", record, 1);
411 411
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)
413 return -1; 413 return -1;
414 414
415 trace_seq_printf(s, "%s%c", val ? "unsync" : "sync", 0); 415 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,
417} 417}
418 418
419static int kvm_mmu_get_page_handler(struct trace_seq *s, 419static int kvm_mmu_get_page_handler(struct trace_seq *s,
420 struct pevent_record *record, 420 struct tep_record *record,
421 struct event_format *event, void *context) 421 struct event_format *event, void *context)
422{ 422{
423 unsigned long long val; 423 unsigned long long val;
424 424
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)
426 return -1; 426 return -1;
427 427
428 trace_seq_printf(s, "%s ", val ? "new" : "existing"); 428 trace_seq_printf(s, "%s ", val ? "new" : "existing");
429 429
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)
431 return -1; 431 return -1;
432 432
433 trace_seq_printf(s, "sp gfn %llx ", val); 433 trace_seq_printf(s, "sp gfn %llx ", val);
@@ -444,79 +444,79 @@ process_is_writable_pte(struct trace_seq *s, unsigned long long *args)
444 return pte & PT_WRITABLE_MASK; 444 return pte & PT_WRITABLE_MASK;
445} 445}
446 446
447int PEVENT_PLUGIN_LOADER(struct pevent *pevent) 447int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
448{ 448{
449 init_disassembler(); 449 init_disassembler();
450 450
451 pevent_register_event_handler(pevent, -1, "kvm", "kvm_exit", 451 tep_register_event_handler(pevent, -1, "kvm", "kvm_exit",
452 kvm_exit_handler, NULL); 452 kvm_exit_handler, NULL);
453 453
454 pevent_register_event_handler(pevent, -1, "kvm", "kvm_emulate_insn", 454 tep_register_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
455 kvm_emulate_insn_handler, NULL); 455 kvm_emulate_insn_handler, NULL);
456 456
457 pevent_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit", 457 tep_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit",
458 kvm_nested_vmexit_handler, NULL); 458 kvm_nested_vmexit_handler, NULL);
459 459
460 pevent_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject", 460 tep_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject",
461 kvm_nested_vmexit_inject_handler, NULL); 461 kvm_nested_vmexit_inject_handler, NULL);
462 462
463 pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page", 463 tep_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
464 kvm_mmu_get_page_handler, NULL); 464 kvm_mmu_get_page_handler, NULL);
465 465
466 pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page", 466 tep_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
467 kvm_mmu_print_role, NULL); 467 kvm_mmu_print_role, NULL);
468 468
469 pevent_register_event_handler(pevent, -1, 469 tep_register_event_handler(pevent, -1,
470 "kvmmmu", "kvm_mmu_unsync_page", 470 "kvmmmu", "kvm_mmu_unsync_page",
471 kvm_mmu_print_role, NULL); 471 kvm_mmu_print_role, NULL);
472 472
473 pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page", 473 tep_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
474 kvm_mmu_print_role, NULL); 474 kvm_mmu_print_role, NULL);
475 475
476 pevent_register_event_handler(pevent, -1, "kvmmmu", 476 tep_register_event_handler(pevent, -1, "kvmmmu",
477 "kvm_mmu_prepare_zap_page", kvm_mmu_print_role, 477 "kvm_mmu_prepare_zap_page", kvm_mmu_print_role,
478 NULL); 478 NULL);
479 479
480 pevent_register_print_function(pevent, 480 tep_register_print_function(pevent,
481 process_is_writable_pte, 481 process_is_writable_pte,
482 PEVENT_FUNC_ARG_INT, 482 TEP_FUNC_ARG_INT,
483 "is_writable_pte", 483 "is_writable_pte",
484 PEVENT_FUNC_ARG_LONG, 484 TEP_FUNC_ARG_LONG,
485 PEVENT_FUNC_ARG_VOID); 485 TEP_FUNC_ARG_VOID);
486 return 0; 486 return 0;
487} 487}
488 488
489void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) 489void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
490{ 490{
491 pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_exit", 491 tep_unregister_event_handler(pevent, -1, "kvm", "kvm_exit",
492 kvm_exit_handler, NULL); 492 kvm_exit_handler, NULL);
493 493
494 pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_emulate_insn", 494 tep_unregister_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
495 kvm_emulate_insn_handler, NULL); 495 kvm_emulate_insn_handler, NULL);
496 496
497 pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit", 497 tep_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit",
498 kvm_nested_vmexit_handler, NULL); 498 kvm_nested_vmexit_handler, NULL);
499 499
500 pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject", 500 tep_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject",
501 kvm_nested_vmexit_inject_handler, NULL); 501 kvm_nested_vmexit_inject_handler, NULL);
502 502
503 pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page", 503 tep_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
504 kvm_mmu_get_page_handler, NULL); 504 kvm_mmu_get_page_handler, NULL);
505 505
506 pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page", 506 tep_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
507 kvm_mmu_print_role, NULL); 507 kvm_mmu_print_role, NULL);
508 508
509 pevent_unregister_event_handler(pevent, -1, 509 tep_unregister_event_handler(pevent, -1,
510 "kvmmmu", "kvm_mmu_unsync_page", 510 "kvmmmu", "kvm_mmu_unsync_page",
511 kvm_mmu_print_role, NULL); 511 kvm_mmu_print_role, NULL);
512 512
513 pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page", 513 tep_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
514 kvm_mmu_print_role, NULL); 514 kvm_mmu_print_role, NULL);
515 515
516 pevent_unregister_event_handler(pevent, -1, "kvmmmu", 516 tep_unregister_event_handler(pevent, -1, "kvmmmu",
517 "kvm_mmu_prepare_zap_page", kvm_mmu_print_role, 517 "kvm_mmu_prepare_zap_page", kvm_mmu_print_role,
518 NULL); 518 NULL);
519 519
520 pevent_unregister_print_function(pevent, process_is_writable_pte, 520 tep_unregister_print_function(pevent, process_is_writable_pte,
521 "is_writable_pte"); 521 "is_writable_pte");
522} 522}
diff --git a/tools/lib/traceevent/plugin_mac80211.c b/tools/lib/traceevent/plugin_mac80211.c
index 7e15a0f1c2fd..de50a5316203 100644
--- a/tools/lib/traceevent/plugin_mac80211.c
+++ b/tools/lib/traceevent/plugin_mac80211.c
@@ -28,7 +28,7 @@
28static void print_string(struct trace_seq *s, struct event_format *event, 28static void print_string(struct trace_seq *s, struct event_format *event,
29 const char *name, const void *data) 29 const char *name, const void *data)
30{ 30{
31 struct format_field *f = pevent_find_field(event, name); 31 struct format_field *f = tep_find_field(event, name);
32 int offset; 32 int offset;
33 int length; 33 int length;
34 34
@@ -42,7 +42,7 @@ static void print_string(struct trace_seq *s, struct event_format *event,
42 42
43 if (!strncmp(f->type, "__data_loc", 10)) { 43 if (!strncmp(f->type, "__data_loc", 10)) {
44 unsigned long long v; 44 unsigned long long v;
45 if (pevent_read_number_field(f, data, &v)) { 45 if (tep_read_number_field(f, data, &v)) {
46 trace_seq_printf(s, "invalid_data_loc"); 46 trace_seq_printf(s, "invalid_data_loc");
47 return; 47 return;
48 } 48 }
@@ -53,12 +53,12 @@ static void print_string(struct trace_seq *s, struct event_format *event,
53 trace_seq_printf(s, "%.*s", length, (char *)data + offset); 53 trace_seq_printf(s, "%.*s", length, (char *)data + offset);
54} 54}
55 55
56#define SF(fn) pevent_print_num_field(s, fn ":%d", event, fn, record, 0) 56#define SF(fn) tep_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) 57#define SFX(fn) tep_print_num_field(s, fn ":%#x", event, fn, record, 0)
58#define SP() trace_seq_putc(s, ' ') 58#define SP() trace_seq_putc(s, ' ')
59 59
60static int drv_bss_info_changed(struct trace_seq *s, 60static int drv_bss_info_changed(struct trace_seq *s,
61 struct pevent_record *record, 61 struct tep_record *record,
62 struct event_format *event, void *context) 62 struct event_format *event, void *context)
63{ 63{
64 void *data = record->data; 64 void *data = record->data;
@@ -66,7 +66,7 @@ static int drv_bss_info_changed(struct trace_seq *s,
66 print_string(s, event, "wiphy_name", data); 66 print_string(s, event, "wiphy_name", data);
67 trace_seq_printf(s, " vif:"); 67 trace_seq_printf(s, " vif:");
68 print_string(s, event, "vif_name", data); 68 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);
70 70
71 trace_seq_printf(s, "\n%*s", INDENT, ""); 71 trace_seq_printf(s, "\n%*s", INDENT, "");
72 SF("assoc"); SP(); 72 SF("assoc"); SP();
@@ -86,17 +86,17 @@ static int drv_bss_info_changed(struct trace_seq *s,
86 return 0; 86 return 0;
87} 87}
88 88
89int PEVENT_PLUGIN_LOADER(struct pevent *pevent) 89int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
90{ 90{
91 pevent_register_event_handler(pevent, -1, "mac80211", 91 tep_register_event_handler(pevent, -1, "mac80211",
92 "drv_bss_info_changed", 92 "drv_bss_info_changed",
93 drv_bss_info_changed, NULL); 93 drv_bss_info_changed, NULL);
94 return 0; 94 return 0;
95} 95}
96 96
97void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) 97void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
98{ 98{
99 pevent_unregister_event_handler(pevent, -1, "mac80211", 99 tep_unregister_event_handler(pevent, -1, "mac80211",
100 "drv_bss_info_changed", 100 "drv_bss_info_changed",
101 drv_bss_info_changed, NULL); 101 drv_bss_info_changed, NULL);
102} 102}
diff --git a/tools/lib/traceevent/plugin_sched_switch.c b/tools/lib/traceevent/plugin_sched_switch.c
index ec30c2fcbac0..eecb4bd95c11 100644
--- a/tools/lib/traceevent/plugin_sched_switch.c
+++ b/tools/lib/traceevent/plugin_sched_switch.c
@@ -45,7 +45,7 @@ static void write_state(struct trace_seq *s, int val)
45} 45}
46 46
47static void write_and_save_comm(struct format_field *field, 47static void write_and_save_comm(struct format_field *field,
48 struct pevent_record *record, 48 struct tep_record *record,
49 struct trace_seq *s, int pid) 49 struct trace_seq *s, int pid)
50{ 50{
51 const char *comm; 51 const char *comm;
@@ -61,100 +61,100 @@ static void write_and_save_comm(struct format_field *field,
61 comm = &s->buffer[len]; 61 comm = &s->buffer[len];
62 62
63 /* Help out the comm to ids. This will handle dups */ 63 /* 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);
65} 65}
66 66
67static int sched_wakeup_handler(struct trace_seq *s, 67static int sched_wakeup_handler(struct trace_seq *s,
68 struct pevent_record *record, 68 struct tep_record *record,
69 struct event_format *event, void *context) 69 struct event_format *event, void *context)
70{ 70{
71 struct format_field *field; 71 struct format_field *field;
72 unsigned long long val; 72 unsigned long long val;
73 73
74 if (pevent_get_field_val(s, event, "pid", record, &val, 1)) 74 if (tep_get_field_val(s, event, "pid", record, &val, 1))
75 return trace_seq_putc(s, '!'); 75 return trace_seq_putc(s, '!');
76 76
77 field = pevent_find_any_field(event, "comm"); 77 field = tep_find_any_field(event, "comm");
78 if (field) { 78 if (field) {
79 write_and_save_comm(field, record, s, val); 79 write_and_save_comm(field, record, s, val);
80 trace_seq_putc(s, ':'); 80 trace_seq_putc(s, ':');
81 } 81 }
82 trace_seq_printf(s, "%lld", val); 82 trace_seq_printf(s, "%lld", val);
83 83
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)
85 trace_seq_printf(s, " [%lld]", val); 85 trace_seq_printf(s, " [%lld]", val);
86 86
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)
88 trace_seq_printf(s, " success=%lld", val); 88 trace_seq_printf(s, " success=%lld", val);
89 89
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)
91 trace_seq_printf(s, " CPU:%03llu", val); 91 trace_seq_printf(s, " CPU:%03llu", val);
92 92
93 return 0; 93 return 0;
94} 94}
95 95
96static int sched_switch_handler(struct trace_seq *s, 96static int sched_switch_handler(struct trace_seq *s,
97 struct pevent_record *record, 97 struct tep_record *record,
98 struct event_format *event, void *context) 98 struct event_format *event, void *context)
99{ 99{
100 struct format_field *field; 100 struct format_field *field;
101 unsigned long long val; 101 unsigned long long val;
102 102
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))
104 return trace_seq_putc(s, '!'); 104 return trace_seq_putc(s, '!');
105 105
106 field = pevent_find_any_field(event, "prev_comm"); 106 field = tep_find_any_field(event, "prev_comm");
107 if (field) { 107 if (field) {
108 write_and_save_comm(field, record, s, val); 108 write_and_save_comm(field, record, s, val);
109 trace_seq_putc(s, ':'); 109 trace_seq_putc(s, ':');
110 } 110 }
111 trace_seq_printf(s, "%lld ", val); 111 trace_seq_printf(s, "%lld ", val);
112 112
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)
114 trace_seq_printf(s, "[%d] ", (int) val); 114 trace_seq_printf(s, "[%d] ", (int) val);
115 115
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)
117 write_state(s, val); 117 write_state(s, val);
118 118
119 trace_seq_puts(s, " ==> "); 119 trace_seq_puts(s, " ==> ");
120 120
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))
122 return trace_seq_putc(s, '!'); 122 return trace_seq_putc(s, '!');
123 123
124 field = pevent_find_any_field(event, "next_comm"); 124 field = tep_find_any_field(event, "next_comm");
125 if (field) { 125 if (field) {
126 write_and_save_comm(field, record, s, val); 126 write_and_save_comm(field, record, s, val);
127 trace_seq_putc(s, ':'); 127 trace_seq_putc(s, ':');
128 } 128 }
129 trace_seq_printf(s, "%lld", val); 129 trace_seq_printf(s, "%lld", val);
130 130
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)
132 trace_seq_printf(s, " [%d]", (int) val); 132 trace_seq_printf(s, " [%d]", (int) val);
133 133
134 return 0; 134 return 0;
135} 135}
136 136
137int PEVENT_PLUGIN_LOADER(struct pevent *pevent) 137int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
138{ 138{
139 pevent_register_event_handler(pevent, -1, "sched", "sched_switch", 139 tep_register_event_handler(pevent, -1, "sched", "sched_switch",
140 sched_switch_handler, NULL); 140 sched_switch_handler, NULL);
141 141
142 pevent_register_event_handler(pevent, -1, "sched", "sched_wakeup", 142 tep_register_event_handler(pevent, -1, "sched", "sched_wakeup",
143 sched_wakeup_handler, NULL); 143 sched_wakeup_handler, NULL);
144 144
145 pevent_register_event_handler(pevent, -1, "sched", "sched_wakeup_new", 145 tep_register_event_handler(pevent, -1, "sched", "sched_wakeup_new",
146 sched_wakeup_handler, NULL); 146 sched_wakeup_handler, NULL);
147 return 0; 147 return 0;
148} 148}
149 149
150void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) 150void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
151{ 151{
152 pevent_unregister_event_handler(pevent, -1, "sched", "sched_switch", 152 tep_unregister_event_handler(pevent, -1, "sched", "sched_switch",
153 sched_switch_handler, NULL); 153 sched_switch_handler, NULL);
154 154
155 pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup", 155 tep_unregister_event_handler(pevent, -1, "sched", "sched_wakeup",
156 sched_wakeup_handler, NULL); 156 sched_wakeup_handler, NULL);
157 157
158 pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup_new", 158 tep_unregister_event_handler(pevent, -1, "sched", "sched_wakeup_new",
159 sched_wakeup_handler, NULL); 159 sched_wakeup_handler, NULL);
160} 160}
diff --git a/tools/lib/traceevent/plugin_scsi.c b/tools/lib/traceevent/plugin_scsi.c
index 5e750af2b461..5ec346f6b842 100644
--- a/tools/lib/traceevent/plugin_scsi.c
+++ b/tools/lib/traceevent/plugin_scsi.c
@@ -413,21 +413,21 @@ unsigned long long process_scsi_trace_parse_cdb(struct trace_seq *s,
413 return 0; 413 return 0;
414} 414}
415 415
416int PEVENT_PLUGIN_LOADER(struct pevent *pevent) 416int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
417{ 417{
418 pevent_register_print_function(pevent, 418 tep_register_print_function(pevent,
419 process_scsi_trace_parse_cdb, 419 process_scsi_trace_parse_cdb,
420 PEVENT_FUNC_ARG_STRING, 420 TEP_FUNC_ARG_STRING,
421 "scsi_trace_parse_cdb", 421 "scsi_trace_parse_cdb",
422 PEVENT_FUNC_ARG_PTR, 422 TEP_FUNC_ARG_PTR,
423 PEVENT_FUNC_ARG_PTR, 423 TEP_FUNC_ARG_PTR,
424 PEVENT_FUNC_ARG_INT, 424 TEP_FUNC_ARG_INT,
425 PEVENT_FUNC_ARG_VOID); 425 TEP_FUNC_ARG_VOID);
426 return 0; 426 return 0;
427} 427}
428 428
429void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) 429void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
430{ 430{
431 pevent_unregister_print_function(pevent, process_scsi_trace_parse_cdb, 431 tep_unregister_print_function(pevent, process_scsi_trace_parse_cdb,
432 "scsi_trace_parse_cdb"); 432 "scsi_trace_parse_cdb");
433} 433}
diff --git a/tools/lib/traceevent/plugin_xen.c b/tools/lib/traceevent/plugin_xen.c
index 690173bfa13e..b2acbd6e9c86 100644
--- a/tools/lib/traceevent/plugin_xen.c
+++ b/tools/lib/traceevent/plugin_xen.c
@@ -119,19 +119,19 @@ unsigned long long process_xen_hypercall_name(struct trace_seq *s,
119 return 0; 119 return 0;
120} 120}
121 121
122int PEVENT_PLUGIN_LOADER(struct pevent *pevent) 122int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
123{ 123{
124 pevent_register_print_function(pevent, 124 tep_register_print_function(pevent,
125 process_xen_hypercall_name, 125 process_xen_hypercall_name,
126 PEVENT_FUNC_ARG_STRING, 126 TEP_FUNC_ARG_STRING,
127 "xen_hypercall_name", 127 "xen_hypercall_name",
128 PEVENT_FUNC_ARG_INT, 128 TEP_FUNC_ARG_INT,
129 PEVENT_FUNC_ARG_VOID); 129 TEP_FUNC_ARG_VOID);
130 return 0; 130 return 0;
131} 131}
132 132
133void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent) 133void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
134{ 134{
135 pevent_unregister_print_function(pevent, process_xen_hypercall_name, 135 tep_unregister_print_function(pevent, process_xen_hypercall_name,
136 "xen_hypercall_name"); 136 "xen_hypercall_name");
137} 137}
diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c
index 292dc9f1d233..e3bac4543d3b 100644
--- a/tools/lib/traceevent/trace-seq.c
+++ b/tools/lib/traceevent/trace-seq.c
@@ -1,21 +1,7 @@
1// SPDX-License-Identifier: LGPL-2.1
1/* 2/*
2 * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> 3 * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3 * 4 *
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 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */ 5 */
20#include <stdio.h> 6#include <stdio.h>
21#include <stdlib.h> 7#include <stdlib.h>
diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
index 749cc6055dac..e8c972f89357 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -118,6 +118,15 @@ OPTIONS
118--group:: 118--group::
119 Show event group information together 119 Show event group information together
120 120
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
121SEE ALSO 130SEE ALSO
122-------- 131--------
123linkperf:perf-record[1], linkperf:perf-report[1] 132linkperf:perf-record[1], linkperf:perf-report[1]
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 917e36fde6d8..474a4941f65d 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -477,6 +477,15 @@ include::itrace.txt[]
477 Display monitored tasks stored in perf data. Displaying pid/tid/ppid 477 Display monitored tasks stored in perf data. Displaying pid/tid/ppid
478 plus the command string aligned to distinguish parent and child tasks. 478 plus the command string aligned to distinguish parent and child tasks.
479 479
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
480include::callchain-overhead-calculation.txt[] 489include::callchain-overhead-calculation.txt[]
481 490
482SEE ALSO 491SEE ALSO
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 225454416ed5..7902a5681fc8 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -84,10 +84,10 @@ endif # has_clean
84endif # MAKECMDGOALS 84endif # MAKECMDGOALS
85 85
86# 86#
87# The clean target is not really parallel, don't print the jobs info: 87# Explicitly disable parallelism for the clean target.
88# 88#
89clean: 89clean:
90 $(make) 90 $(make) -j1
91 91
92# 92#
93# The build-test target is not really parallel, don't print the jobs info, 93# The build-test target is not really parallel, don't print the jobs info,
diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c
index 1120e39c1b00..5ccfce87e693 100644
--- a/tools/perf/arch/arm64/util/arm-spe.c
+++ b/tools/perf/arch/arm64/util/arm-spe.c
@@ -194,6 +194,7 @@ struct auxtrace_record *arm_spe_recording_init(int *err,
194 sper->itr.read_finish = arm_spe_read_finish; 194 sper->itr.read_finish = arm_spe_read_finish;
195 sper->itr.alignment = 0; 195 sper->itr.alignment = 0;
196 196
197 *err = 0;
197 return &sper->itr; 198 return &sper->itr;
198} 199}
199 200
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c
index 53d83d7e6a09..20e7d74d86cd 100644
--- a/tools/perf/arch/powerpc/util/sym-handling.c
+++ b/tools/perf/arch/powerpc/util/sym-handling.c
@@ -141,8 +141,10 @@ void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
141 for (i = 0; i < ntevs; i++) { 141 for (i = 0; i < ntevs; i++) {
142 tev = &pev->tevs[i]; 142 tev = &pev->tevs[i];
143 map__for_each_symbol(map, sym, tmp) { 143 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) {
145 arch__fix_tev_from_maps(pev, tev, map, sym); 145 arch__fix_tev_from_maps(pev, tev, map, sym);
146 break;
147 }
146 } 148 }
147 } 149 }
148} 150}
diff --git a/tools/perf/arch/s390/util/auxtrace.c b/tools/perf/arch/s390/util/auxtrace.c
index 3afe8256eff2..44c857388897 100644
--- a/tools/perf/arch/s390/util/auxtrace.c
+++ b/tools/perf/arch/s390/util/auxtrace.c
@@ -30,6 +30,7 @@ cpumsf_info_fill(struct auxtrace_record *itr __maybe_unused,
30 struct auxtrace_info_event *auxtrace_info __maybe_unused, 30 struct auxtrace_info_event *auxtrace_info __maybe_unused,
31 size_t priv_size __maybe_unused) 31 size_t priv_size __maybe_unused)
32{ 32{
33 auxtrace_info->type = PERF_AUXTRACE_S390_CPUMSF;
33 return 0; 34 return 0;
34} 35}
35 36
diff --git a/tools/perf/arch/x86/Makefile b/tools/perf/arch/x86/Makefile
index 1a38e78117ce..8cc6642fce7a 100644
--- a/tools/perf/arch/x86/Makefile
+++ b/tools/perf/arch/x86/Makefile
@@ -19,9 +19,6 @@ systbl := $(sys)/syscalltbl.sh
19_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)') 19_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
20 20
21$(header): $(sys)/syscall_64.tbl $(systbl) 21$(header): $(sys)/syscall_64.tbl $(systbl)
22 @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
23 (diff -B arch/x86/entry/syscalls/syscall_64.tbl ../../arch/x86/entry/syscalls/syscall_64.tbl >/dev/null) \
24 || echo "Warning: Kernel ABI header at 'tools/perf/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl'" >&2 )) || true
25 $(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@ 22 $(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@
26 23
27clean:: 24clean::
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 8180319285af..830481b8db26 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -542,6 +542,10 @@ int cmd_annotate(int argc, const char **argv)
542 OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode", 542 OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
543 "'always' (default), 'never' or 'auto' only applicable to --stdio mode", 543 "'always' (default), 'never' or 'auto' only applicable to --stdio mode",
544 stdio__config_color, "always"), 544 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
545 OPT_END() 549 OPT_END()
546 }; 550 };
547 int ret; 551 int ret;
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 54d3f21b0e62..b63bca4b0c2a 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -729,7 +729,7 @@ static char *compact_gfp_string(unsigned long gfp_flags)
729static int parse_gfp_flags(struct perf_evsel *evsel, struct perf_sample *sample, 729static int parse_gfp_flags(struct perf_evsel *evsel, struct perf_sample *sample,
730 unsigned int gfp_flags) 730 unsigned int gfp_flags)
731{ 731{
732 struct pevent_record record = { 732 struct tep_record record = {
733 .cpu = sample->cpu, 733 .cpu = sample->cpu,
734 .data = sample->raw_data, 734 .data = sample->raw_data,
735 .size = sample->raw_size, 735 .size = sample->raw_size,
@@ -747,7 +747,7 @@ static int parse_gfp_flags(struct perf_evsel *evsel, struct perf_sample *sample,
747 } 747 }
748 748
749 trace_seq_init(&seq); 749 trace_seq_init(&seq);
750 pevent_event_info(&seq, evsel->tp_format, &record); 750 tep_event_info(&seq, evsel->tp_format, &record);
751 751
752 str = strtok_r(seq.buffer, " ", &pos); 752 str = strtok_r(seq.buffer, " ", &pos);
753 while (str) { 753 while (str) {
@@ -1974,7 +1974,7 @@ int cmd_kmem(int argc, const char **argv)
1974 goto out_delete; 1974 goto out_delete;
1975 } 1975 }
1976 1976
1977 kmem_page_size = pevent_get_page_size(evsel->tp_format->pevent); 1977 kmem_page_size = tep_get_page_size(evsel->tp_format->pevent);
1978 symbol_conf.use_callchain = true; 1978 symbol_conf.use_callchain = true;
1979 } 1979 }
1980 1980
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 02f7a3c27761..76e12bcd1765 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1124,6 +1124,9 @@ int cmd_report(int argc, const char **argv)
1124 "Time span of interest (start,stop)"), 1124 "Time span of interest (start,stop)"),
1125 OPT_BOOLEAN(0, "inline", &symbol_conf.inline_name, 1125 OPT_BOOLEAN(0, "inline", &symbol_conf.inline_name,
1126 "Show inline function"), 1126 "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),
1127 OPT_END() 1130 OPT_END()
1128 }; 1131 };
1129 struct perf_data data = { 1132 struct perf_data data = {
@@ -1366,9 +1369,9 @@ repeat:
1366 } 1369 }
1367 1370
1368 if (session->tevent.pevent && 1371 if (session->tevent.pevent &&
1369 pevent_set_function_resolver(session->tevent.pevent, 1372 tep_set_function_resolver(session->tevent.pevent,
1370 machine__resolve_kernel_addr, 1373 machine__resolve_kernel_addr,
1371 &session->machines.host) < 0) { 1374 &session->machines.host) < 0) {
1372 pr_err("%s: failed to set libtraceevent function resolver\n", 1375 pr_err("%s: failed to set libtraceevent function resolver\n",
1373 __func__); 1376 __func__);
1374 return -1; 1377 return -1;
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 568ddfac3213..ba481d73f910 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -3429,9 +3429,9 @@ int cmd_script(int argc, const char **argv)
3429 symbol_conf.use_callchain = false; 3429 symbol_conf.use_callchain = false;
3430 3430
3431 if (session->tevent.pevent && 3431 if (session->tevent.pevent &&
3432 pevent_set_function_resolver(session->tevent.pevent, 3432 tep_set_function_resolver(session->tevent.pevent,
3433 machine__resolve_kernel_addr, 3433 machine__resolve_kernel_addr,
3434 &session->machines.host) < 0) { 3434 &session->machines.host) < 0) {
3435 pr_err("%s: failed to set libtraceevent function resolver\n", __func__); 3435 pr_err("%s: failed to set libtraceevent function resolver\n", __func__);
3436 err = -1; 3436 err = -1;
3437 goto out_delete; 3437 goto out_delete;
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 88561eed7950..22ab8e67c760 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -77,7 +77,8 @@ struct trace {
77 struct syscall *table; 77 struct syscall *table;
78 struct { 78 struct {
79 struct perf_evsel *sys_enter, 79 struct perf_evsel *sys_enter,
80 *sys_exit; 80 *sys_exit,
81 *augmented;
81 } events; 82 } events;
82 } syscalls; 83 } syscalls;
83 struct record_opts opts; 84 struct record_opts opts;
@@ -121,7 +122,6 @@ struct trace {
121 bool force; 122 bool force;
122 bool vfs_getname; 123 bool vfs_getname;
123 int trace_pgfaults; 124 int trace_pgfaults;
124 int open_id;
125}; 125};
126 126
127struct tp_field { 127struct tp_field {
@@ -157,13 +157,11 @@ TP_UINT_FIELD__SWAPPED(16);
157TP_UINT_FIELD__SWAPPED(32); 157TP_UINT_FIELD__SWAPPED(32);
158TP_UINT_FIELD__SWAPPED(64); 158TP_UINT_FIELD__SWAPPED(64);
159 159
160static int tp_field__init_uint(struct tp_field *field, 160static int __tp_field__init_uint(struct tp_field *field, int size, int offset, bool needs_swap)
161 struct format_field *format_field,
162 bool needs_swap)
163{ 161{
164 field->offset = format_field->offset; 162 field->offset = offset;
165 163
166 switch (format_field->size) { 164 switch (size) {
167 case 1: 165 case 1:
168 field->integer = tp_field__u8; 166 field->integer = tp_field__u8;
169 break; 167 break;
@@ -183,18 +181,28 @@ static int tp_field__init_uint(struct tp_field *field,
183 return 0; 181 return 0;
184} 182}
185 183
184static 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
186static void *tp_field__ptr(struct tp_field *field, struct perf_sample *sample) 189static void *tp_field__ptr(struct tp_field *field, struct perf_sample *sample)
187{ 190{
188 return sample->raw_data + field->offset; 191 return sample->raw_data + field->offset;
189} 192}
190 193
191static int tp_field__init_ptr(struct tp_field *field, struct format_field *format_field) 194static int __tp_field__init_ptr(struct tp_field *field, int offset)
192{ 195{
193 field->offset = format_field->offset; 196 field->offset = offset;
194 field->pointer = tp_field__ptr; 197 field->pointer = tp_field__ptr;
195 return 0; 198 return 0;
196} 199}
197 200
201static 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
198struct syscall_tp { 206struct syscall_tp {
199 struct tp_field id; 207 struct tp_field id;
200 union { 208 union {
@@ -240,7 +248,47 @@ static void perf_evsel__delete_priv(struct perf_evsel *evsel)
240 perf_evsel__delete(evsel); 248 perf_evsel__delete(evsel);
241} 249}
242 250
243static int perf_evsel__init_syscall_tp(struct perf_evsel *evsel, void *handler) 251static 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;
262out_delete:
263 zfree(&evsel->priv);
264 return -ENOENT;
265}
266
267static 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;
279out_delete:
280 zfree(&evsel->priv);
281 return -EINVAL;
282}
283
284static 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
291static int perf_evsel__init_raw_syscall_tp(struct perf_evsel *evsel, void *handler)
244{ 292{
245 evsel->priv = malloc(sizeof(struct syscall_tp)); 293 evsel->priv = malloc(sizeof(struct syscall_tp));
246 if (evsel->priv != NULL) { 294 if (evsel->priv != NULL) {
@@ -258,7 +306,7 @@ out_delete:
258 return -ENOENT; 306 return -ENOENT;
259} 307}
260 308
261static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void *handler) 309static struct perf_evsel *perf_evsel__raw_syscall_newtp(const char *direction, void *handler)
262{ 310{
263 struct perf_evsel *evsel = perf_evsel__newtp("raw_syscalls", direction); 311 struct perf_evsel *evsel = perf_evsel__newtp("raw_syscalls", direction);
264 312
@@ -269,7 +317,7 @@ static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void
269 if (IS_ERR(evsel)) 317 if (IS_ERR(evsel))
270 return NULL; 318 return NULL;
271 319
272 if (perf_evsel__init_syscall_tp(evsel, handler)) 320 if (perf_evsel__init_raw_syscall_tp(evsel, handler))
273 goto out_delete; 321 goto out_delete;
274 322
275 return evsel; 323 return evsel;
@@ -805,12 +853,17 @@ static struct syscall_fmt *syscall_fmt__find(const char *name)
805 return bsearch(name, syscall_fmts, nmemb, sizeof(struct syscall_fmt), syscall_fmt__cmp); 853 return bsearch(name, syscall_fmts, nmemb, sizeof(struct syscall_fmt), syscall_fmt__cmp);
806} 854}
807 855
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 */
808struct syscall { 860struct syscall {
809 struct event_format *tp_format; 861 struct event_format *tp_format;
810 int nr_args; 862 int nr_args;
863 bool is_exit;
864 bool is_open;
811 struct format_field *args; 865 struct format_field *args;
812 const char *name; 866 const char *name;
813 bool is_exit;
814 struct syscall_fmt *fmt; 867 struct syscall_fmt *fmt;
815 struct syscall_arg_fmt *arg_fmt; 868 struct syscall_arg_fmt *arg_fmt;
816}; 869};
@@ -1299,6 +1352,7 @@ static int trace__read_syscall_info(struct trace *trace, int id)
1299 } 1352 }
1300 1353
1301 sc->is_exit = !strcmp(name, "exit_group") || !strcmp(name, "exit"); 1354 sc->is_exit = !strcmp(name, "exit_group") || !strcmp(name, "exit");
1355 sc->is_open = !strcmp(name, "open") || !strcmp(name, "openat");
1302 1356
1303 return syscall__set_arg_fmts(sc); 1357 return syscall__set_arg_fmts(sc);
1304} 1358}
@@ -1661,6 +1715,37 @@ out_put:
1661 return err; 1715 return err;
1662} 1716}
1663 1717
1718static 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;
1744out_put:
1745 thread__put(thread);
1746 return err;
1747}
1748
1664static int trace__resolve_callchain(struct trace *trace, struct perf_evsel *evsel, 1749static int trace__resolve_callchain(struct trace *trace, struct perf_evsel *evsel,
1665 struct perf_sample *sample, 1750 struct perf_sample *sample,
1666 struct callchain_cursor *cursor) 1751 struct callchain_cursor *cursor)
@@ -1722,7 +1807,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
1722 1807
1723 ret = perf_evsel__sc_tp_uint(evsel, ret, sample); 1808 ret = perf_evsel__sc_tp_uint(evsel, ret, sample);
1724 1809
1725 if (id == trace->open_id && ret >= 0 && ttrace->filename.pending_open) { 1810 if (sc->is_open && ret >= 0 && ttrace->filename.pending_open) {
1726 trace__set_fd_pathname(thread, ret, ttrace->filename.name); 1811 trace__set_fd_pathname(thread, ret, ttrace->filename.name);
1727 ttrace->filename.pending_open = false; 1812 ttrace->filename.pending_open = false;
1728 ++trace->stats.vfs_getname; 1813 ++trace->stats.vfs_getname;
@@ -1957,11 +2042,17 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel,
1957 fprintf(trace->output, "%s:", evsel->name); 2042 fprintf(trace->output, "%s:", evsel->name);
1958 2043
1959 if (perf_evsel__is_bpf_output(evsel)) { 2044 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);
1961 } else if (evsel->tp_format) { 2049 } else if (evsel->tp_format) {
1962 event_format__fprintf(evsel->tp_format, sample->cpu, 2050 if (strncmp(evsel->tp_format->name, "sys_enter_", 10) ||
1963 sample->raw_data, sample->raw_size, 2051 trace__fprintf_sys_enter(trace, evsel, sample)) {
1964 trace->output); 2052 event_format__fprintf(evsel->tp_format, sample->cpu,
2053 sample->raw_data, sample->raw_size,
2054 trace->output);
2055 }
1965 } 2056 }
1966 2057
1967 fprintf(trace->output, "\n"); 2058 fprintf(trace->output, "\n");
@@ -2242,14 +2333,14 @@ static int trace__add_syscall_newtp(struct trace *trace)
2242 struct perf_evlist *evlist = trace->evlist; 2333 struct perf_evlist *evlist = trace->evlist;
2243 struct perf_evsel *sys_enter, *sys_exit; 2334 struct perf_evsel *sys_enter, *sys_exit;
2244 2335
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);
2246 if (sys_enter == NULL) 2337 if (sys_enter == NULL)
2247 goto out; 2338 goto out;
2248 2339
2249 if (perf_evsel__init_sc_tp_ptr_field(sys_enter, args)) 2340 if (perf_evsel__init_sc_tp_ptr_field(sys_enter, args))
2250 goto out_delete_sys_enter; 2341 goto out_delete_sys_enter;
2251 2342
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);
2253 if (sys_exit == NULL) 2344 if (sys_exit == NULL)
2254 goto out_delete_sys_enter; 2345 goto out_delete_sys_enter;
2255 2346
@@ -2671,7 +2762,7 @@ static int trace__replay(struct trace *trace)
2671 "syscalls:sys_enter"); 2762 "syscalls:sys_enter");
2672 2763
2673 if (evsel && 2764 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 ||
2675 perf_evsel__init_sc_tp_ptr_field(evsel, args))) { 2766 perf_evsel__init_sc_tp_ptr_field(evsel, args))) {
2676 pr_err("Error during initialize raw_syscalls:sys_enter event\n"); 2767 pr_err("Error during initialize raw_syscalls:sys_enter event\n");
2677 goto out; 2768 goto out;
@@ -2683,7 +2774,7 @@ static int trace__replay(struct trace *trace)
2683 evsel = perf_evlist__find_tracepoint_by_name(session->evlist, 2774 evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
2684 "syscalls:sys_exit"); 2775 "syscalls:sys_exit");
2685 if (evsel && 2776 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 ||
2687 perf_evsel__init_sc_tp_uint_field(evsel, ret))) { 2778 perf_evsel__init_sc_tp_uint_field(evsel, ret))) {
2688 pr_err("Error during initialize raw_syscalls:sys_exit event\n"); 2779 pr_err("Error during initialize raw_syscalls:sys_exit event\n");
2689 goto out; 2780 goto out;
@@ -2923,6 +3014,36 @@ static void evlist__set_evsel_handler(struct perf_evlist *evlist, void *handler)
2923 evsel->handler = handler; 3014 evsel->handler = handler;
2924} 3015}
2925 3016
3017static 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
2926/* 3047/*
2927 * XXX: Hackish, just splitting the combined -e+--event (syscalls 3048 * XXX: Hackish, just splitting the combined -e+--event (syscalls
2928 * (raw_syscalls:{sys_{enter,exit}} + events (tracepoints, HW, SW, etc) to use 3049 * (raw_syscalls:{sys_{enter,exit}} + events (tracepoints, HW, SW, etc) to use
@@ -3123,8 +3244,9 @@ int cmd_trace(int argc, const char **argv)
3123 }; 3244 };
3124 bool __maybe_unused max_stack_user_set = true; 3245 bool __maybe_unused max_stack_user_set = true;
3125 bool mmap_pages_user_set = true; 3246 bool mmap_pages_user_set = true;
3247 struct perf_evsel *evsel;
3126 const char * const trace_subcommands[] = { "record", NULL }; 3248 const char * const trace_subcommands[] = { "record", NULL };
3127 int err; 3249 int err = -1;
3128 char bf[BUFSIZ]; 3250 char bf[BUFSIZ];
3129 3251
3130 signal(SIGSEGV, sighandler_dump_stack); 3252 signal(SIGSEGV, sighandler_dump_stack);
@@ -3147,6 +3269,20 @@ int cmd_trace(int argc, const char **argv)
3147 "cgroup monitoring only available in system-wide mode"); 3269 "cgroup monitoring only available in system-wide mode");
3148 } 3270 }
3149 3271
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
3150 err = bpf__setup_stdout(trace.evlist); 3286 err = bpf__setup_stdout(trace.evlist);
3151 if (err) { 3287 if (err) {
3152 bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf)); 3288 bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf));
@@ -3182,8 +3318,13 @@ int cmd_trace(int argc, const char **argv)
3182 symbol_conf.use_callchain = true; 3318 symbol_conf.use_callchain = true;
3183 } 3319 }
3184 3320
3185 if (trace.evlist->nr_entries > 0) 3321 if (trace.evlist->nr_entries > 0) {
3186 evlist__set_evsel_handler(trace.evlist, trace__event_handler); 3322 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 }
3187 3328
3188 if ((argc >= 1) && (strcmp(argv[0], "record") == 0)) 3329 if ((argc >= 1) && (strcmp(argv[0], "record") == 0))
3189 return trace__record(&trace, argc-1, &argv[1]); 3330 return trace__record(&trace, argc-1, &argv[1]);
@@ -3205,8 +3346,6 @@ int cmd_trace(int argc, const char **argv)
3205 } 3346 }
3206 } 3347 }
3207 3348
3208 trace.open_id = syscalltbl__id(trace.sctbl, "open");
3209
3210 err = target__validate(&trace.opts.target); 3349 err = target__validate(&trace.opts.target);
3211 if (err) { 3350 if (err) {
3212 target__strerror(&trace.opts.target, err, bf, sizeof(bf)); 3351 target__strerror(&trace.opts.target, err, bf, sizeof(bf));
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index de28466c0186..466540ee8ea7 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -67,8 +67,12 @@ check_2 () {
67 67
68 cmd="diff $* $file1 $file2 > /dev/null" 68 cmd="diff $* $file1 $file2 > /dev/null"
69 69
70 test -f $file2 && 70 test -f $file2 && {
71 eval $cmd || echo "Warning: Kernel ABI header at 'tools/$file' differs from latest version at '$file'" >&2 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 }
72} 76}
73 77
74check () { 78check () {
@@ -76,7 +80,7 @@ check () {
76 80
77 shift 81 shift
78 82
79 check_2 ../$file ../../$file $* 83 check_2 tools/$file $file $*
80} 84}
81 85
82# Check if we have the kernel headers (tools/perf/../../include), else 86# Check if we have the kernel headers (tools/perf/../../include), else
@@ -84,6 +88,8 @@ check () {
84# differences. 88# differences.
85test -d ../../include || exit 0 89test -d ../../include || exit 0
86 90
91cd ../..
92
87# simple diff check 93# simple diff check
88for i in $HEADERS; do 94for i in $HEADERS; do
89 check $i -B 95 check $i -B
@@ -94,3 +100,8 @@ check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/ex
94check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' 100check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"'
95check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common.h>"' 101check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common.h>"'
96check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"' 102check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"'
103
104# diff non-symmetric files
105check_2 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
106
107cd tools/perf
diff --git a/tools/perf/examples/bpf/augmented_syscalls.c b/tools/perf/examples/bpf/augmented_syscalls.c
new file mode 100644
index 000000000000..69a31386d8cd
--- /dev/null
+++ b/tools/perf/examples/bpf/augmented_syscalls.c
@@ -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
23struct 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
30struct 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
39struct augmented_enter_openat_args {
40 struct syscall_enter_openat_args args;
41 char filename[64];
42};
43
44int 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
55license(GPL);
diff --git a/tools/perf/examples/bpf/hello.c b/tools/perf/examples/bpf/hello.c
new file mode 100644
index 000000000000..cf3c2fdc7f79
--- /dev/null
+++ b/tools/perf/examples/bpf/hello.c
@@ -0,0 +1,9 @@
1#include <stdio.h>
2
3int syscall_enter(openat)(void *args)
4{
5 puts("Hello, world\n");
6 return 0;
7}
8
9license(GPL);
diff --git a/tools/perf/examples/bpf/sys_enter_openat.c b/tools/perf/examples/bpf/sys_enter_openat.c
new file mode 100644
index 000000000000..9cd124b09392
--- /dev/null
+++ b/tools/perf/examples/bpf/sys_enter_openat.c
@@ -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
19struct 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
28int syscall_enter(openat)(struct syscall_enter_openat_args *args)
29{
30 return 1;
31}
32
33license(GPL);
diff --git a/tools/perf/include/bpf/bpf.h b/tools/perf/include/bpf/bpf.h
index a63aa6241b7f..47897d65e799 100644
--- a/tools/perf/include/bpf/bpf.h
+++ b/tools/perf/include/bpf/bpf.h
@@ -4,13 +4,33 @@
4 4
5#include <uapi/linux/bpf.h> 5#include <uapi/linux/bpf.h>
6 6
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 */
11struct 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
7#define SEC(NAME) __attribute__((section(NAME), used)) 21#define SEC(NAME) __attribute__((section(NAME), used))
8 22
9#define probe(function, vars) \ 23#define probe(function, vars) \
10 SEC(#function "=" #function " " #vars) function 24 SEC(#function "=" #function " " #vars) function
11 25
26#define syscall_enter(name) \
27 SEC("syscalls:sys_enter_" #name) syscall_enter_ ## name
28
12#define license(name) \ 29#define license(name) \
13char _license[] SEC("license") = #name; \ 30char _license[] SEC("license") = #name; \
14int _version SEC("version") = LINUX_VERSION_CODE; 31int _version SEC("version") = LINUX_VERSION_CODE;
15 32
33static int (*probe_read)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read;
34static int (*probe_read_str)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read_str;
35
16#endif /* _PERF_BPF_H */ 36#endif /* _PERF_BPF_H */
diff --git a/tools/perf/include/bpf/stdio.h b/tools/perf/include/bpf/stdio.h
new file mode 100644
index 000000000000..2899cb7bfed8
--- /dev/null
+++ b/tools/perf/include/bpf/stdio.h
@@ -0,0 +1,19 @@
1// SPDX-License-Identifier: GPL-2.0
2
3#include <bpf.h>
4
5struct 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
12static 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)); })
diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json
new file mode 100644
index 000000000000..bc03c06c3918
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/core-imp-def.json
@@ -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]
diff --git a/tools/perf/pmu-events/arch/arm64/mapfile.csv b/tools/perf/pmu-events/arch/arm64/mapfile.csv
index f03e26ecb658..59cd8604b0bd 100644
--- a/tools/perf/pmu-events/arch/arm64/mapfile.csv
+++ b/tools/perf/pmu-events/arch/arm64/mapfile.csv
@@ -16,3 +16,4 @@
160x00000000420f5160,v1,cavium/thunderx2,core 160x00000000420f5160,v1,cavium/thunderx2,core
170x00000000430f0af0,v1,cavium/thunderx2,core 170x00000000430f0af0,v1,cavium/thunderx2,core
180x00000000480fd010,v1,hisilicon/hip08,core 180x00000000480fd010,v1,hisilicon/hip08,core
190x00000000500f0000,v1,ampere/emag,core
diff --git a/tools/perf/tests/bitmap.c b/tools/perf/tests/bitmap.c
index 47bedf25ba69..96e7fc1ad3f9 100644
--- a/tools/perf/tests/bitmap.c
+++ b/tools/perf/tests/bitmap.c
@@ -16,8 +16,6 @@ static unsigned long *get_bitmap(const char *str, int nbits)
16 bm = bitmap_alloc(nbits); 16 bm = bitmap_alloc(nbits);
17 17
18 if (map && bm) { 18 if (map && bm) {
19 bitmap_zero(bm, nbits);
20
21 for (i = 0; i < map->nr; i++) 19 for (i = 0; i < map->nr; i++)
22 set_bit(map->map[i], bm); 20 set_bit(map->map[i], bm);
23 } 21 }
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 4892bd2dc33e..6b049f3f5cf4 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -232,6 +232,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
232 u64 objdump_addr; 232 u64 objdump_addr;
233 const char *objdump_name; 233 const char *objdump_name;
234 char decomp_name[KMOD_DECOMP_LEN]; 234 char decomp_name[KMOD_DECOMP_LEN];
235 bool decomp = false;
235 int ret; 236 int ret;
236 237
237 pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr); 238 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,
305 return -1; 306 return -1;
306 } 307 }
307 308
309 decomp = true;
308 objdump_name = decomp_name; 310 objdump_name = decomp_name;
309 } 311 }
310 312
@@ -312,7 +314,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,
312 objdump_addr = map__rip_2objdump(al.map, al.addr); 314 objdump_addr = map__rip_2objdump(al.map, al.addr);
313 ret = read_via_objdump(objdump_name, objdump_addr, buf2, len); 315 ret = read_via_objdump(objdump_name, objdump_addr, buf2, len);
314 316
315 if (dso__needs_decompress(al.map->dso)) 317 if (decomp)
316 unlink(objdump_name); 318 unlink(objdump_name);
317 319
318 if (ret > 0) { 320 if (ret > 0) {
diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c
index 148dd31cc201..0579a70bbbff 100644
--- a/tools/perf/tests/kmod-path.c
+++ b/tools/perf/tests/kmod-path.c
@@ -5,34 +5,28 @@
5#include "dso.h" 5#include "dso.h"
6#include "debug.h" 6#include "debug.h"
7 7
8static int test(const char *path, bool alloc_name, bool alloc_ext, 8static int test(const char *path, bool alloc_name, bool kmod,
9 bool kmod, bool comp, const char *name, const char *ext) 9 int comp, const char *name)
10{ 10{
11 struct kmod_path m; 11 struct kmod_path m;
12 12
13 memset(&m, 0x0, sizeof(m)); 13 memset(&m, 0x0, sizeof(m));
14 14
15 TEST_ASSERT_VAL("kmod_path__parse", 15 TEST_ASSERT_VAL("kmod_path__parse",
16 !__kmod_path__parse(&m, path, alloc_name, alloc_ext)); 16 !__kmod_path__parse(&m, path, alloc_name));
17 17
18 pr_debug("%s - alloc name %d, alloc ext %d, kmod %d, comp %d, name '%s', ext '%s'\n", 18 pr_debug("%s - alloc name %d, kmod %d, comp %d, name '%s'\n",
19 path, alloc_name, alloc_ext, m.kmod, m.comp, m.name, m.ext); 19 path, alloc_name, m.kmod, m.comp, m.name);
20 20
21 TEST_ASSERT_VAL("wrong kmod", m.kmod == kmod); 21 TEST_ASSERT_VAL("wrong kmod", m.kmod == kmod);
22 TEST_ASSERT_VAL("wrong comp", m.comp == comp); 22 TEST_ASSERT_VAL("wrong comp", m.comp == comp);
23 23
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
29 if (name) 24 if (name)
30 TEST_ASSERT_VAL("wrong name", m.name && !strcmp(name, m.name)); 25 TEST_ASSERT_VAL("wrong name", m.name && !strcmp(name, m.name));
31 else 26 else
32 TEST_ASSERT_VAL("wrong name", !m.name); 27 TEST_ASSERT_VAL("wrong name", !m.name);
33 28
34 free(m.name); 29 free(m.name);
35 free(m.ext);
36 return 0; 30 return 0;
37} 31}
38 32
@@ -45,118 +39,118 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect)
45 return 0; 39 return 0;
46} 40}
47 41
48#define T(path, an, ae, k, c, n, e) \ 42#define T(path, an, k, c, n) \
49 TEST_ASSERT_VAL("failed", !test(path, an, ae, k, c, n, e)) 43 TEST_ASSERT_VAL("failed", !test(path, an, k, c, n))
50 44
51#define M(path, c, e) \ 45#define M(path, c, e) \
52 TEST_ASSERT_VAL("failed", !test_is_kernel_module(path, c, e)) 46 TEST_ASSERT_VAL("failed", !test_is_kernel_module(path, c, e))
53 47
54int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused) 48int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
55{ 49{
56 /* path alloc_name alloc_ext kmod comp name ext */ 50 /* path alloc_name kmod comp name */
57 T("/xxxx/xxxx/x-x.ko", true , true , true, false, "[x_x]", NULL); 51 T("/xxxx/xxxx/x-x.ko", true , true, 0 , "[x_x]");
58 T("/xxxx/xxxx/x-x.ko", false , true , true, false, NULL , NULL); 52 T("/xxxx/xxxx/x-x.ko", false , true, 0 , NULL );
59 T("/xxxx/xxxx/x-x.ko", true , false , true, false, "[x_x]", NULL); 53 T("/xxxx/xxxx/x-x.ko", true , true, 0 , "[x_x]");
60 T("/xxxx/xxxx/x-x.ko", false , false , true, false, NULL , NULL); 54 T("/xxxx/xxxx/x-x.ko", false , true, 0 , NULL );
61 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); 55 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
62 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true); 56 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true);
63 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false); 57 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false);
64 58
65#ifdef HAVE_ZLIB_SUPPORT 59#ifdef HAVE_ZLIB_SUPPORT
66 /* path alloc_name alloc_ext kmod comp name ext */ 60 /* path alloc_name kmod comp name */
67 T("/xxxx/xxxx/x.ko.gz", true , true , true, true, "[x]", "gz"); 61 T("/xxxx/xxxx/x.ko.gz", true , true, 1 , "[x]");
68 T("/xxxx/xxxx/x.ko.gz", false , true , true, true, NULL , "gz"); 62 T("/xxxx/xxxx/x.ko.gz", false , true, 1 , NULL );
69 T("/xxxx/xxxx/x.ko.gz", true , false , true, true, "[x]", NULL); 63 T("/xxxx/xxxx/x.ko.gz", true , true, 1 , "[x]");
70 T("/xxxx/xxxx/x.ko.gz", false , false , true, true, NULL , NULL); 64 T("/xxxx/xxxx/x.ko.gz", false , true, 1 , NULL );
71 M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); 65 M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
72 M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_KERNEL, true); 66 M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
73 M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_USER, false); 67 M("/xxxx/xxxx/x.ko.gz", PERF_RECORD_MISC_USER, false);
74 68
75 /* path alloc_name alloc_ext kmod comp name ext */ 69 /* path alloc_name kmod comp name */
76 T("/xxxx/xxxx/x.gz", true , true , false, true, "x.gz" ,"gz"); 70 T("/xxxx/xxxx/x.gz", true , false, 1 , "x.gz");
77 T("/xxxx/xxxx/x.gz", false , true , false, true, NULL ,"gz"); 71 T("/xxxx/xxxx/x.gz", false , false, 1 , NULL );
78 T("/xxxx/xxxx/x.gz", true , false , false, true, "x.gz" , NULL); 72 T("/xxxx/xxxx/x.gz", true , false, 1 , "x.gz");
79 T("/xxxx/xxxx/x.gz", false , false , false, true, NULL , NULL); 73 T("/xxxx/xxxx/x.gz", false , false, 1 , NULL );
80 M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false); 74 M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
81 M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_KERNEL, false); 75 M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_KERNEL, false);
82 M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_USER, false); 76 M("/xxxx/xxxx/x.gz", PERF_RECORD_MISC_USER, false);
83 77
84 /* path alloc_name alloc_ext kmod comp name ext */ 78 /* path alloc_name kmod comp name */
85 T("x.gz", true , true , false, true, "x.gz", "gz"); 79 T("x.gz", true , false, 1 , "x.gz");
86 T("x.gz", false , true , false, true, NULL , "gz"); 80 T("x.gz", false , false, 1 , NULL );
87 T("x.gz", true , false , false, true, "x.gz", NULL); 81 T("x.gz", true , false, 1 , "x.gz");
88 T("x.gz", false , false , false, true, NULL , NULL); 82 T("x.gz", false , false, 1 , NULL );
89 M("x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false); 83 M("x.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
90 M("x.gz", PERF_RECORD_MISC_KERNEL, false); 84 M("x.gz", PERF_RECORD_MISC_KERNEL, false);
91 M("x.gz", PERF_RECORD_MISC_USER, false); 85 M("x.gz", PERF_RECORD_MISC_USER, false);
92 86
93 /* path alloc_name alloc_ext kmod comp name ext */ 87 /* path alloc_name kmod comp name */
94 T("x.ko.gz", true , true , true, true, "[x]", "gz"); 88 T("x.ko.gz", true , true, 1 , "[x]");
95 T("x.ko.gz", false , true , true, true, NULL , "gz"); 89 T("x.ko.gz", false , true, 1 , NULL );
96 T("x.ko.gz", true , false , true, true, "[x]", NULL); 90 T("x.ko.gz", true , true, 1 , "[x]");
97 T("x.ko.gz", false , false , true, true, NULL , NULL); 91 T("x.ko.gz", false , true, 1 , NULL );
98 M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); 92 M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
99 M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true); 93 M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true);
100 M("x.ko.gz", PERF_RECORD_MISC_USER, false); 94 M("x.ko.gz", PERF_RECORD_MISC_USER, false);
101#endif 95#endif
102 96
103 /* path alloc_name alloc_ext kmod comp name ext */ 97 /* path alloc_name kmod comp name */
104 T("[test_module]", true , true , true, false, "[test_module]", NULL); 98 T("[test_module]", true , true, false, "[test_module]");
105 T("[test_module]", false , true , true, false, NULL , NULL); 99 T("[test_module]", false , true, false, NULL );
106 T("[test_module]", true , false , true, false, "[test_module]", NULL); 100 T("[test_module]", true , true, false, "[test_module]");
107 T("[test_module]", false , false , true, false, NULL , NULL); 101 T("[test_module]", false , true, false, NULL );
108 M("[test_module]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); 102 M("[test_module]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
109 M("[test_module]", PERF_RECORD_MISC_KERNEL, true); 103 M("[test_module]", PERF_RECORD_MISC_KERNEL, true);
110 M("[test_module]", PERF_RECORD_MISC_USER, false); 104 M("[test_module]", PERF_RECORD_MISC_USER, false);
111 105
112 /* path alloc_name alloc_ext kmod comp name ext */ 106 /* path alloc_name kmod comp name */
113 T("[test.module]", true , true , true, false, "[test.module]", NULL); 107 T("[test.module]", true , true, false, "[test.module]");
114 T("[test.module]", false , true , true, false, NULL , NULL); 108 T("[test.module]", false , true, false, NULL );
115 T("[test.module]", true , false , true, false, "[test.module]", NULL); 109 T("[test.module]", true , true, false, "[test.module]");
116 T("[test.module]", false , false , true, false, NULL , NULL); 110 T("[test.module]", false , true, false, NULL );
117 M("[test.module]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); 111 M("[test.module]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true);
118 M("[test.module]", PERF_RECORD_MISC_KERNEL, true); 112 M("[test.module]", PERF_RECORD_MISC_KERNEL, true);
119 M("[test.module]", PERF_RECORD_MISC_USER, false); 113 M("[test.module]", PERF_RECORD_MISC_USER, false);
120 114
121 /* path alloc_name alloc_ext kmod comp name ext */ 115 /* path alloc_name kmod comp name */
122 T("[vdso]", true , true , false, false, "[vdso]", NULL); 116 T("[vdso]", true , false, false, "[vdso]");
123 T("[vdso]", false , true , false, false, NULL , NULL); 117 T("[vdso]", false , false, false, NULL );
124 T("[vdso]", true , false , false, false, "[vdso]", NULL); 118 T("[vdso]", true , false, false, "[vdso]");
125 T("[vdso]", false , false , false, false, NULL , NULL); 119 T("[vdso]", false , false, false, NULL );
126 M("[vdso]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false); 120 M("[vdso]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
127 M("[vdso]", PERF_RECORD_MISC_KERNEL, false); 121 M("[vdso]", PERF_RECORD_MISC_KERNEL, false);
128 M("[vdso]", PERF_RECORD_MISC_USER, false); 122 M("[vdso]", PERF_RECORD_MISC_USER, false);
129 123
130 T("[vdso32]", true , true , false, false, "[vdso32]", NULL); 124 T("[vdso32]", true , false, false, "[vdso32]");
131 T("[vdso32]", false , true , false, false, NULL , NULL); 125 T("[vdso32]", false , false, false, NULL );
132 T("[vdso32]", true , false , false, false, "[vdso32]", NULL); 126 T("[vdso32]", true , false, false, "[vdso32]");
133 T("[vdso32]", false , false , false, false, NULL , NULL); 127 T("[vdso32]", false , false, false, NULL );
134 M("[vdso32]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false); 128 M("[vdso32]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
135 M("[vdso32]", PERF_RECORD_MISC_KERNEL, false); 129 M("[vdso32]", PERF_RECORD_MISC_KERNEL, false);
136 M("[vdso32]", PERF_RECORD_MISC_USER, false); 130 M("[vdso32]", PERF_RECORD_MISC_USER, false);
137 131
138 T("[vdsox32]", true , true , false, false, "[vdsox32]", NULL); 132 T("[vdsox32]", true , false, false, "[vdsox32]");
139 T("[vdsox32]", false , true , false, false, NULL , NULL); 133 T("[vdsox32]", false , false, false, NULL );
140 T("[vdsox32]", true , false , false, false, "[vdsox32]", NULL); 134 T("[vdsox32]", true , false, false, "[vdsox32]");
141 T("[vdsox32]", false , false , false, false, NULL , NULL); 135 T("[vdsox32]", false , false, false, NULL );
142 M("[vdsox32]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false); 136 M("[vdsox32]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
143 M("[vdsox32]", PERF_RECORD_MISC_KERNEL, false); 137 M("[vdsox32]", PERF_RECORD_MISC_KERNEL, false);
144 M("[vdsox32]", PERF_RECORD_MISC_USER, false); 138 M("[vdsox32]", PERF_RECORD_MISC_USER, false);
145 139
146 /* path alloc_name alloc_ext kmod comp name ext */ 140 /* path alloc_name kmod comp name */
147 T("[vsyscall]", true , true , false, false, "[vsyscall]", NULL); 141 T("[vsyscall]", true , false, false, "[vsyscall]");
148 T("[vsyscall]", false , true , false, false, NULL , NULL); 142 T("[vsyscall]", false , false, false, NULL );
149 T("[vsyscall]", true , false , false, false, "[vsyscall]", NULL); 143 T("[vsyscall]", true , false, false, "[vsyscall]");
150 T("[vsyscall]", false , false , false, false, NULL , NULL); 144 T("[vsyscall]", false , false, false, NULL );
151 M("[vsyscall]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false); 145 M("[vsyscall]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
152 M("[vsyscall]", PERF_RECORD_MISC_KERNEL, false); 146 M("[vsyscall]", PERF_RECORD_MISC_KERNEL, false);
153 M("[vsyscall]", PERF_RECORD_MISC_USER, false); 147 M("[vsyscall]", PERF_RECORD_MISC_USER, false);
154 148
155 /* path alloc_name alloc_ext kmod comp name ext */ 149 /* path alloc_name kmod comp name */
156 T("[kernel.kallsyms]", true , true , false, false, "[kernel.kallsyms]", NULL); 150 T("[kernel.kallsyms]", true , false, false, "[kernel.kallsyms]");
157 T("[kernel.kallsyms]", false , true , false, false, NULL , NULL); 151 T("[kernel.kallsyms]", false , false, false, NULL );
158 T("[kernel.kallsyms]", true , false , false, false, "[kernel.kallsyms]", NULL); 152 T("[kernel.kallsyms]", true , false, false, "[kernel.kallsyms]");
159 T("[kernel.kallsyms]", false , false , false, false, NULL , NULL); 153 T("[kernel.kallsyms]", false , false, false, NULL );
160 M("[kernel.kallsyms]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false); 154 M("[kernel.kallsyms]", PERF_RECORD_MISC_CPUMODE_UNKNOWN, false);
161 M("[kernel.kallsyms]", PERF_RECORD_MISC_KERNEL, false); 155 M("[kernel.kallsyms]", PERF_RECORD_MISC_KERNEL, false);
162 M("[kernel.kallsyms]", PERF_RECORD_MISC_USER, false); 156 M("[kernel.kallsyms]", PERF_RECORD_MISC_USER, false);
diff --git a/tools/perf/tests/mem2node.c b/tools/perf/tests/mem2node.c
index 0c3c87f86e03..9e9e4d37cc77 100644
--- a/tools/perf/tests/mem2node.c
+++ b/tools/perf/tests/mem2node.c
@@ -24,8 +24,6 @@ static unsigned long *get_bitmap(const char *str, int nbits)
24 bm = bitmap_alloc(nbits); 24 bm = bitmap_alloc(nbits);
25 25
26 if (map && bm) { 26 if (map && bm) {
27 bitmap_zero(bm, nbits);
28
29 for (i = 0; i < map->nr; i++) { 27 for (i = 0; i < map->nr; i++) {
30 set_bit(map->map[i], bm); 28 set_bit(map->map[i], bm);
31 } 29 }
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 3b4f1c10ff57..1d00e5ec7906 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -15,6 +15,7 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <sys/ttydefaults.h> 17#include <sys/ttydefaults.h>
18#include <asm/bug.h>
18 19
19struct disasm_line_samples { 20struct disasm_line_samples {
20 double percent; 21 double percent;
@@ -115,7 +116,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
115 if (!browser->navkeypressed) 116 if (!browser->navkeypressed)
116 ops.width += 1; 117 ops.width += 1;
117 118
118 annotation_line__write(al, notes, &ops); 119 annotation_line__write(al, notes, &ops, ab->opts);
119 120
120 if (ops.current_entry) 121 if (ops.current_entry)
121 ab->selection = al; 122 ab->selection = al;
@@ -227,10 +228,10 @@ static int disasm__cmp(struct annotation_line *a, struct annotation_line *b)
227{ 228{
228 int i; 229 int i;
229 230
230 for (i = 0; i < a->samples_nr; i++) { 231 for (i = 0; i < a->data_nr; i++) {
231 if (a->samples[i].percent == b->samples[i].percent) 232 if (a->data[i].percent == b->data[i].percent)
232 continue; 233 continue;
233 return a->samples[i].percent < b->samples[i].percent; 234 return a->data[i].percent < b->data[i].percent;
234 } 235 }
235 return 0; 236 return 0;
236} 237}
@@ -314,11 +315,14 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
314 continue; 315 continue;
315 } 316 }
316 317
317 for (i = 0; i < pos->al.samples_nr; i++) { 318 for (i = 0; i < pos->al.data_nr; i++) {
318 struct annotation_data *sample = &pos->al.samples[i]; 319 double percent;
319 320
320 if (max_percent < sample->percent) 321 percent = annotation_data__percent(&pos->al.data[i],
321 max_percent = sample->percent; 322 browser->opts->percent_type);
323
324 if (max_percent < percent)
325 max_percent = percent;
322 } 326 }
323 327
324 if (max_percent < 0.01 && pos->al.ipc == 0) { 328 if (max_percent < 0.01 && pos->al.ipc == 0) {
@@ -380,9 +384,10 @@ static void ui_browser__init_asm_mode(struct ui_browser *browser)
380#define SYM_TITLE_MAX_SIZE (PATH_MAX + 64) 384#define SYM_TITLE_MAX_SIZE (PATH_MAX + 64)
381 385
382static int sym_title(struct symbol *sym, struct map *map, char *title, 386static int sym_title(struct symbol *sym, struct map *map, char *title,
383 size_t sz) 387 size_t sz, int percent_type)
384{ 388{
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));
386} 391}
387 392
388/* 393/*
@@ -420,7 +425,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
420 425
421 pthread_mutex_unlock(&notes->lock); 426 pthread_mutex_unlock(&notes->lock);
422 symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, browser->opts); 427 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);
424 ui_browser__show_title(&browser->b, title); 429 ui_browser__show_title(&browser->b, title);
425 return true; 430 return true;
426} 431}
@@ -595,6 +600,7 @@ bool annotate_browser__continue_search_reverse(struct annotate_browser *browser,
595 600
596static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help) 601static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help)
597{ 602{
603 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
598 struct map_symbol *ms = browser->priv; 604 struct map_symbol *ms = browser->priv;
599 struct symbol *sym = ms->sym; 605 struct symbol *sym = ms->sym;
600 char symbol_dso[SYM_TITLE_MAX_SIZE]; 606 char symbol_dso[SYM_TITLE_MAX_SIZE];
@@ -602,7 +608,7 @@ static int annotate_browser__show(struct ui_browser *browser, char *title, const
602 if (ui_browser__show(browser, title, help) < 0) 608 if (ui_browser__show(browser, title, help) < 0)
603 return -1; 609 return -1;
604 610
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);
606 612
607 ui_browser__gotorc_title(browser, 0, 0); 613 ui_browser__gotorc_title(browser, 0, 0);
608 ui_browser__set_color(browser, HE_COLORSET_ROOT); 614 ui_browser__set_color(browser, HE_COLORSET_ROOT);
@@ -610,6 +616,39 @@ static int annotate_browser__show(struct ui_browser *browser, char *title, const
610 return 0; 616 return 0;
611} 617}
612 618
619static void
620switch_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
613static int annotate_browser__run(struct annotate_browser *browser, 652static int annotate_browser__run(struct annotate_browser *browser,
614 struct perf_evsel *evsel, 653 struct perf_evsel *evsel,
615 struct hist_browser_timer *hbt) 654 struct hist_browser_timer *hbt)
@@ -624,8 +663,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
624 char title[256]; 663 char title[256];
625 int key; 664 int key;
626 665
627 annotation__scnprintf_samples_period(notes, title, sizeof(title), evsel); 666 hists__scnprintf_title(hists, title, sizeof(title));
628
629 if (annotate_browser__show(&browser->b, title, help) < 0) 667 if (annotate_browser__show(&browser->b, title, help) < 0)
630 return -1; 668 return -1;
631 669
@@ -701,6 +739,8 @@ static int annotate_browser__run(struct annotate_browser *browser,
701 "k Toggle line numbers\n" 739 "k Toggle line numbers\n"
702 "P Print to [symbol_name].annotation file.\n" 740 "P Print to [symbol_name].annotation file.\n"
703 "r Run available scripts\n" 741 "r Run available scripts\n"
742 "p Toggle percent type [local/global]\n"
743 "b Toggle percent base [period/hits]\n"
704 "? Search string backwards\n"); 744 "? Search string backwards\n");
705 continue; 745 continue;
706 case 'r': 746 case 'r':
@@ -781,7 +821,7 @@ show_sup_ins:
781 continue; 821 continue;
782 } 822 }
783 case 'P': 823 case 'P':
784 map_symbol__annotation_dump(ms, evsel); 824 map_symbol__annotation_dump(ms, evsel, browser->opts);
785 continue; 825 continue;
786 case 't': 826 case 't':
787 if (notes->options->show_total_period) { 827 if (notes->options->show_total_period) {
@@ -800,6 +840,12 @@ show_sup_ins:
800 notes->options->show_minmax_cycle = true; 840 notes->options->show_minmax_cycle = true;
801 annotation__update_column_widths(notes); 841 annotation__update_column_widths(notes);
802 continue; 842 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;
803 case K_LEFT: 849 case K_LEFT:
804 case K_ESC: 850 case K_ESC:
805 case 'q': 851 case 'q':
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index b604ef334dc9..7efe15b9618d 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -87,6 +87,7 @@ libperf-$(CONFIG_AUXTRACE) += intel-pt.o
87libperf-$(CONFIG_AUXTRACE) += intel-bts.o 87libperf-$(CONFIG_AUXTRACE) += intel-bts.o
88libperf-$(CONFIG_AUXTRACE) += arm-spe.o 88libperf-$(CONFIG_AUXTRACE) += arm-spe.o
89libperf-$(CONFIG_AUXTRACE) += arm-spe-pkt-decoder.o 89libperf-$(CONFIG_AUXTRACE) += arm-spe-pkt-decoder.o
90libperf-$(CONFIG_AUXTRACE) += s390-cpumsf.o
90 91
91ifdef CONFIG_LIBOPENCSD 92ifdef CONFIG_LIBOPENCSD
92libperf-$(CONFIG_AUXTRACE) += cs-etm.o 93libperf-$(CONFIG_AUXTRACE) += cs-etm.o
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index f91775b4bc3c..20061cf42288 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -49,6 +49,7 @@ struct annotation_options annotation__default_options = {
49 .jump_arrows = true, 49 .jump_arrows = true,
50 .annotate_src = true, 50 .annotate_src = true,
51 .offset_level = ANNOTATION__OFFSET_JUMP_TARGETS, 51 .offset_level = ANNOTATION__OFFSET_JUMP_TARGETS,
52 .percent_type = PERCENT_PERIOD_LOCAL,
52}; 53};
53 54
54static regex_t file_lineno; 55static regex_t file_lineno;
@@ -1108,7 +1109,7 @@ annotation_line__new(struct annotate_args *args, size_t privsize)
1108 if (perf_evsel__is_group_event(evsel)) 1109 if (perf_evsel__is_group_event(evsel))
1109 nr = evsel->nr_members; 1110 nr = evsel->nr_members;
1110 1111
1111 size += sizeof(al->samples[0]) * nr; 1112 size += sizeof(al->data[0]) * nr;
1112 1113
1113 al = zalloc(size); 1114 al = zalloc(size);
1114 if (al) { 1115 if (al) {
@@ -1117,7 +1118,7 @@ annotation_line__new(struct annotate_args *args, size_t privsize)
1117 al->offset = args->offset; 1118 al->offset = args->offset;
1118 al->line = strdup(args->line); 1119 al->line = strdup(args->line);
1119 al->line_nr = args->line_nr; 1120 al->line_nr = args->line_nr;
1120 al->samples_nr = nr; 1121 al->data_nr = nr;
1121 } 1122 }
1122 1123
1123 return al; 1124 return al;
@@ -1297,7 +1298,8 @@ static int disasm_line__print(struct disasm_line *dl, u64 start, int addr_fmt_wi
1297static int 1298static int
1298annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start, 1299annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start,
1299 struct perf_evsel *evsel, u64 len, int min_pcnt, int printed, 1300 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)
1301{ 1303{
1302 struct disasm_line *dl = container_of(al, struct disasm_line, al); 1304 struct disasm_line *dl = container_of(al, struct disasm_line, al);
1303 static const char *prev_line; 1305 static const char *prev_line;
@@ -1309,15 +1311,18 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start
1309 const char *color; 1311 const char *color;
1310 struct annotation *notes = symbol__annotation(sym); 1312 struct annotation *notes = symbol__annotation(sym);
1311 1313
1312 for (i = 0; i < al->samples_nr; i++) { 1314 for (i = 0; i < al->data_nr; i++) {
1313 struct annotation_data *sample = &al->samples[i]; 1315 double percent;
1314 1316
1315 if (sample->percent > max_percent) 1317 percent = annotation_data__percent(&al->data[i],
1316 max_percent = sample->percent; 1318 percent_type);
1319
1320 if (percent > max_percent)
1321 max_percent = percent;
1317 } 1322 }
1318 1323
1319 if (al->samples_nr > nr_percent) 1324 if (al->data_nr > nr_percent)
1320 nr_percent = al->samples_nr; 1325 nr_percent = al->data_nr;
1321 1326
1322 if (max_percent < min_pcnt) 1327 if (max_percent < min_pcnt)
1323 return -1; 1328 return -1;
@@ -1330,7 +1335,8 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start
1330 if (queue == al) 1335 if (queue == al)
1331 break; 1336 break;
1332 annotation_line__print(queue, sym, start, evsel, len, 1337 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);
1334 } 1340 }
1335 } 1341 }
1336 1342
@@ -1351,18 +1357,20 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start
1351 } 1357 }
1352 1358
1353 for (i = 0; i < nr_percent; i++) { 1359 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;
1355 1362
1356 color = get_percent_color(sample->percent); 1363 percent = annotation_data__percent(data, percent_type);
1364 color = get_percent_color(percent);
1357 1365
1358 if (symbol_conf.show_total_period) 1366 if (symbol_conf.show_total_period)
1359 color_fprintf(stdout, color, " %11" PRIu64, 1367 color_fprintf(stdout, color, " %11" PRIu64,
1360 sample->he.period); 1368 data->he.period);
1361 else if (symbol_conf.show_nr_samples) 1369 else if (symbol_conf.show_nr_samples)
1362 color_fprintf(stdout, color, " %7" PRIu64, 1370 color_fprintf(stdout, color, " %7" PRIu64,
1363 sample->he.nr_samples); 1371 data->he.nr_samples);
1364 else 1372 else
1365 color_fprintf(stdout, color, " %7.2f", sample->percent); 1373 color_fprintf(stdout, color, " %7.2f", percent);
1366 } 1374 }
1367 1375
1368 printf(" : "); 1376 printf(" : ");
@@ -1621,6 +1629,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
1621 char symfs_filename[PATH_MAX]; 1629 char symfs_filename[PATH_MAX];
1622 struct kcore_extract kce; 1630 struct kcore_extract kce;
1623 bool delete_extract = false; 1631 bool delete_extract = false;
1632 bool decomp = false;
1624 int stdout_fd[2]; 1633 int stdout_fd[2];
1625 int lineno = 0; 1634 int lineno = 0;
1626 int nline; 1635 int nline;
@@ -1654,6 +1663,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
1654 tmp, sizeof(tmp)) < 0) 1663 tmp, sizeof(tmp)) < 0)
1655 goto out; 1664 goto out;
1656 1665
1666 decomp = true;
1657 strcpy(symfs_filename, tmp); 1667 strcpy(symfs_filename, tmp);
1658 } 1668 }
1659 1669
@@ -1740,7 +1750,7 @@ out_free_command:
1740out_remove_tmp: 1750out_remove_tmp:
1741 close(stdout_fd[0]); 1751 close(stdout_fd[0]);
1742 1752
1743 if (dso__needs_decompress(dso)) 1753 if (decomp)
1744 unlink(symfs_filename); 1754 unlink(symfs_filename);
1745 1755
1746 if (delete_extract) 1756 if (delete_extract)
@@ -1753,34 +1763,45 @@ out_close_stdout:
1753 goto out_free_command; 1763 goto out_free_command;
1754} 1764}
1755 1765
1756static void calc_percent(struct sym_hist *hist, 1766static void calc_percent(struct sym_hist *sym_hist,
1757 struct annotation_data *sample, 1767 struct hists *hists,
1768 struct annotation_data *data,
1758 s64 offset, s64 end) 1769 s64 offset, s64 end)
1759{ 1770{
1760 unsigned int hits = 0; 1771 unsigned int hits = 0;
1761 u64 period = 0; 1772 u64 period = 0;
1762 1773
1763 while (offset < end) { 1774 while (offset < end) {
1764 hits += hist->addr[offset].nr_samples; 1775 hits += sym_hist->addr[offset].nr_samples;
1765 period += hist->addr[offset].period; 1776 period += sym_hist->addr[offset].period;
1766 ++offset; 1777 ++offset;
1767 } 1778 }
1768 1779
1769 if (hist->nr_samples) { 1780 if (sym_hist->nr_samples) {
1770 sample->he.period = period; 1781 data->he.period = period;
1771 sample->he.nr_samples = hits; 1782 data->he.nr_samples = hits;
1772 sample->percent = 100.0 * hits / hist->nr_samples; 1783 data->percent[PERCENT_HITS_LOCAL] = 100.0 * hits / sym_hist->nr_samples;
1773 } 1784 }
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;
1774} 1794}
1775 1795
1776static void annotation__calc_percent(struct annotation *notes, 1796static void annotation__calc_percent(struct annotation *notes,
1777 struct perf_evsel *evsel, s64 len) 1797 struct perf_evsel *leader, s64 len)
1778{ 1798{
1779 struct annotation_line *al, *next; 1799 struct annotation_line *al, *next;
1800 struct perf_evsel *evsel;
1780 1801
1781 list_for_each_entry(al, &notes->src->source, node) { 1802 list_for_each_entry(al, &notes->src->source, node) {
1782 s64 end; 1803 s64 end;
1783 int i; 1804 int i = 0;
1784 1805
1785 if (al->offset == -1) 1806 if (al->offset == -1)
1786 continue; 1807 continue;
@@ -1788,14 +1809,17 @@ static void annotation__calc_percent(struct annotation *notes,
1788 next = annotation_line__next(al, &notes->src->source); 1809 next = annotation_line__next(al, &notes->src->source);
1789 end = next ? next->offset : len; 1810 end = next ? next->offset : len;
1790 1811
1791 for (i = 0; i < al->samples_nr; i++) { 1812 for_each_group_evsel(evsel, leader) {
1792 struct annotation_data *sample; 1813 struct hists *hists = evsel__hists(evsel);
1793 struct sym_hist *hist; 1814 struct annotation_data *data;
1815 struct sym_hist *sym_hist;
1816
1817 BUG_ON(i >= al->data_nr);
1794 1818
1795 hist = annotation__histogram(notes, evsel->idx + i); 1819 sym_hist = annotation__histogram(notes, evsel->idx);
1796 sample = &al->samples[i]; 1820 data = &al->data[i++];
1797 1821
1798 calc_percent(hist, sample, al->offset, end); 1822 calc_percent(sym_hist, hists, data, al->offset, end);
1799 } 1823 }
1800 } 1824 }
1801} 1825}
@@ -1846,7 +1870,8 @@ int symbol__annotate(struct symbol *sym, struct map *map,
1846 return symbol__disassemble(sym, &args); 1870 return symbol__disassemble(sym, &args);
1847} 1871}
1848 1872
1849static void insert_source_line(struct rb_root *root, struct annotation_line *al) 1873static void insert_source_line(struct rb_root *root, struct annotation_line *al,
1874 struct annotation_options *opts)
1850{ 1875{
1851 struct annotation_line *iter; 1876 struct annotation_line *iter;
1852 struct rb_node **p = &root->rb_node; 1877 struct rb_node **p = &root->rb_node;
@@ -1859,8 +1884,10 @@ static void insert_source_line(struct rb_root *root, struct annotation_line *al)
1859 1884
1860 ret = strcmp(iter->path, al->path); 1885 ret = strcmp(iter->path, al->path);
1861 if (ret == 0) { 1886 if (ret == 0) {
1862 for (i = 0; i < al->samples_nr; i++) 1887 for (i = 0; i < al->data_nr; i++) {
1863 iter->samples[i].percent_sum += al->samples[i].percent; 1888 iter->data[i].percent_sum += annotation_data__percent(&al->data[i],
1889 opts->percent_type);
1890 }
1864 return; 1891 return;
1865 } 1892 }
1866 1893
@@ -1870,8 +1897,10 @@ static void insert_source_line(struct rb_root *root, struct annotation_line *al)
1870 p = &(*p)->rb_right; 1897 p = &(*p)->rb_right;
1871 } 1898 }
1872 1899
1873 for (i = 0; i < al->samples_nr; i++) 1900 for (i = 0; i < al->data_nr; i++) {
1874 al->samples[i].percent_sum = al->samples[i].percent; 1901 al->data[i].percent_sum = annotation_data__percent(&al->data[i],
1902 opts->percent_type);
1903 }
1875 1904
1876 rb_link_node(&al->rb_node, parent, p); 1905 rb_link_node(&al->rb_node, parent, p);
1877 rb_insert_color(&al->rb_node, root); 1906 rb_insert_color(&al->rb_node, root);
@@ -1881,10 +1910,10 @@ static int cmp_source_line(struct annotation_line *a, struct annotation_line *b)
1881{ 1910{
1882 int i; 1911 int i;
1883 1912
1884 for (i = 0; i < a->samples_nr; i++) { 1913 for (i = 0; i < a->data_nr; i++) {
1885 if (a->samples[i].percent_sum == b->samples[i].percent_sum) 1914 if (a->data[i].percent_sum == b->data[i].percent_sum)
1886 continue; 1915 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;
1888 } 1917 }
1889 1918
1890 return 0; 1919 return 0;
@@ -1949,8 +1978,8 @@ static void print_summary(struct rb_root *root, const char *filename)
1949 int i; 1978 int i;
1950 1979
1951 al = rb_entry(node, struct annotation_line, rb_node); 1980 al = rb_entry(node, struct annotation_line, rb_node);
1952 for (i = 0; i < al->samples_nr; i++) { 1981 for (i = 0; i < al->data_nr; i++) {
1953 percent = al->samples[i].percent_sum; 1982 percent = al->data[i].percent_sum;
1954 color = get_percent_color(percent); 1983 color = get_percent_color(percent);
1955 color_fprintf(stdout, color, " %7.2f", percent); 1984 color_fprintf(stdout, color, " %7.2f", percent);
1956 1985
@@ -2029,10 +2058,12 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
2029 evsel_name = buf; 2058 evsel_name = buf;
2030 } 2059 }
2031 2060
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",
2033 width, width, symbol_conf.show_total_period ? "Period" : 2063 width, width, symbol_conf.show_total_period ? "Period" :
2034 symbol_conf.show_nr_samples ? "Samples" : "Percent", 2064 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));
2036 2067
2037 printf("%-*.*s----\n", 2068 printf("%-*.*s----\n",
2038 graph_dotted_len, graph_dotted_len, graph_dotted_line); 2069 graph_dotted_len, graph_dotted_len, graph_dotted_line);
@@ -2052,7 +2083,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
2052 2083
2053 err = annotation_line__print(pos, sym, start, evsel, len, 2084 err = annotation_line__print(pos, sym, start, evsel, len,
2054 opts->min_pcnt, printed, opts->max_lines, 2085 opts->min_pcnt, printed, opts->max_lines,
2055 queue, addr_fmt_width); 2086 queue, addr_fmt_width, opts->percent_type);
2056 2087
2057 switch (err) { 2088 switch (err) {
2058 case 0: 2089 case 0:
@@ -2129,10 +2160,11 @@ static void FILE__write_graph(void *fp, int graph)
2129 fputs(s, fp); 2160 fputs(s, fp);
2130} 2161}
2131 2162
2132int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp) 2163static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp,
2164 struct annotation_options *opts)
2133{ 2165{
2134 struct annotation *notes = symbol__annotation(sym); 2166 struct annotation *notes = symbol__annotation(sym);
2135 struct annotation_write_ops ops = { 2167 struct annotation_write_ops wops = {
2136 .first_line = true, 2168 .first_line = true,
2137 .obj = fp, 2169 .obj = fp,
2138 .set_color = FILE__set_color, 2170 .set_color = FILE__set_color,
@@ -2146,15 +2178,16 @@ int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp)
2146 list_for_each_entry(al, &notes->src->source, node) { 2178 list_for_each_entry(al, &notes->src->source, node) {
2147 if (annotation_line__filter(al, notes)) 2179 if (annotation_line__filter(al, notes))
2148 continue; 2180 continue;
2149 annotation_line__write(al, notes, &ops); 2181 annotation_line__write(al, notes, &wops, opts);
2150 fputc('\n', fp); 2182 fputc('\n', fp);
2151 ops.first_line = false; 2183 wops.first_line = false;
2152 } 2184 }
2153 2185
2154 return 0; 2186 return 0;
2155} 2187}
2156 2188
2157int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel) 2189int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel,
2190 struct annotation_options *opts)
2158{ 2191{
2159 const char *ev_name = perf_evsel__name(evsel); 2192 const char *ev_name = perf_evsel__name(evsel);
2160 char buf[1024]; 2193 char buf[1024];
@@ -2176,7 +2209,7 @@ int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel)
2176 2209
2177 fprintf(fp, "%s() %s\nEvent: %s\n\n", 2210 fprintf(fp, "%s() %s\nEvent: %s\n\n",
2178 ms->sym->name, ms->map->dso->long_name, ev_name); 2211 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);
2180 2213
2181 fclose(fp); 2214 fclose(fp);
2182 err = 0; 2215 err = 0;
@@ -2346,7 +2379,8 @@ void annotation__update_column_widths(struct annotation *notes)
2346} 2379}
2347 2380
2348static void annotation__calc_lines(struct annotation *notes, struct map *map, 2381static 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)
2350{ 2384{
2351 struct annotation_line *al; 2385 struct annotation_line *al;
2352 struct rb_root tmp_root = RB_ROOT; 2386 struct rb_root tmp_root = RB_ROOT;
@@ -2355,13 +2389,14 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map,
2355 double percent_max = 0.0; 2389 double percent_max = 0.0;
2356 int i; 2390 int i;
2357 2391
2358 for (i = 0; i < al->samples_nr; i++) { 2392 for (i = 0; i < al->data_nr; i++) {
2359 struct annotation_data *sample; 2393 double percent;
2360 2394
2361 sample = &al->samples[i]; 2395 percent = annotation_data__percent(&al->data[i],
2396 opts->percent_type);
2362 2397
2363 if (sample->percent > percent_max) 2398 if (percent > percent_max)
2364 percent_max = sample->percent; 2399 percent_max = percent;
2365 } 2400 }
2366 2401
2367 if (percent_max <= 0.5) 2402 if (percent_max <= 0.5)
@@ -2369,18 +2404,19 @@ static void annotation__calc_lines(struct annotation *notes, struct map *map,
2369 2404
2370 al->path = get_srcline(map->dso, notes->start + al->offset, NULL, 2405 al->path = get_srcline(map->dso, notes->start + al->offset, NULL,
2371 false, true, notes->start + al->offset); 2406 false, true, notes->start + al->offset);
2372 insert_source_line(&tmp_root, al); 2407 insert_source_line(&tmp_root, al, opts);
2373 } 2408 }
2374 2409
2375 resort_source_line(root, &tmp_root); 2410 resort_source_line(root, &tmp_root);
2376} 2411}
2377 2412
2378static void symbol__calc_lines(struct symbol *sym, struct map *map, 2413static 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)
2380{ 2416{
2381 struct annotation *notes = symbol__annotation(sym); 2417 struct annotation *notes = symbol__annotation(sym);
2382 2418
2383 annotation__calc_lines(notes, map, root); 2419 annotation__calc_lines(notes, map, root, opts);
2384} 2420}
2385 2421
2386int symbol__tty_annotate2(struct symbol *sym, struct map *map, 2422int symbol__tty_annotate2(struct symbol *sym, struct map *map,
@@ -2389,7 +2425,7 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map,
2389{ 2425{
2390 struct dso *dso = map->dso; 2426 struct dso *dso = map->dso;
2391 struct rb_root source_line = RB_ROOT; 2427 struct rb_root source_line = RB_ROOT;
2392 struct annotation *notes = symbol__annotation(sym); 2428 struct hists *hists = evsel__hists(evsel);
2393 char buf[1024]; 2429 char buf[1024];
2394 2430
2395 if (symbol__annotate2(sym, map, evsel, opts, NULL) < 0) 2431 if (symbol__annotate2(sym, map, evsel, opts, NULL) < 0)
@@ -2397,13 +2433,14 @@ int symbol__tty_annotate2(struct symbol *sym, struct map *map,
2397 2433
2398 if (opts->print_lines) { 2434 if (opts->print_lines) {
2399 srcline_full_filename = opts->full_path; 2435 srcline_full_filename = opts->full_path;
2400 symbol__calc_lines(sym, map, &source_line); 2436 symbol__calc_lines(sym, map, &source_line, opts);
2401 print_summary(&source_line, dso->long_name); 2437 print_summary(&source_line, dso->long_name);
2402 } 2438 }
2403 2439
2404 annotation__scnprintf_samples_period(notes, buf, sizeof(buf), evsel); 2440 hists__scnprintf_title(hists, buf, sizeof(buf));
2405 fprintf(stdout, "%s\n%s() %s\n", buf, sym->name, dso->long_name); 2441 fprintf(stdout, "%s, [percent: %s]\n%s() %s\n",
2406 symbol__annotate_fprintf2(sym, stdout); 2442 buf, percent_type_str(opts->percent_type), sym->name, dso->long_name);
2443 symbol__annotate_fprintf2(sym, stdout, opts);
2407 2444
2408 annotated_source__purge(symbol__annotation(sym)->src); 2445 annotated_source__purge(symbol__annotation(sym)->src);
2409 2446
@@ -2424,7 +2461,7 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map,
2424 2461
2425 if (opts->print_lines) { 2462 if (opts->print_lines) {
2426 srcline_full_filename = opts->full_path; 2463 srcline_full_filename = opts->full_path;
2427 symbol__calc_lines(sym, map, &source_line); 2464 symbol__calc_lines(sym, map, &source_line, opts);
2428 print_summary(&source_line, dso->long_name); 2465 print_summary(&source_line, dso->long_name);
2429 } 2466 }
2430 2467
@@ -2441,14 +2478,21 @@ bool ui__has_annotation(void)
2441} 2478}
2442 2479
2443 2480
2444double annotation_line__max_percent(struct annotation_line *al, struct annotation *notes) 2481static double annotation_line__max_percent(struct annotation_line *al,
2482 struct annotation *notes,
2483 unsigned int percent_type)
2445{ 2484{
2446 double percent_max = 0.0; 2485 double percent_max = 0.0;
2447 int i; 2486 int i;
2448 2487
2449 for (i = 0; i < notes->nr_events; i++) { 2488 for (i = 0; i < notes->nr_events; i++) {
2450 if (al->samples[i].percent > percent_max) 2489 double percent;
2451 percent_max = al->samples[i].percent; 2490
2491 percent = annotation_data__percent(&al->data[i],
2492 percent_type);
2493
2494 if (percent > percent_max)
2495 percent_max = percent;
2452 } 2496 }
2453 2497
2454 return percent_max; 2498 return percent_max;
@@ -2487,7 +2531,7 @@ call_like:
2487 2531
2488static void __annotation_line__write(struct annotation_line *al, struct annotation *notes, 2532static void __annotation_line__write(struct annotation_line *al, struct annotation *notes,
2489 bool first_line, bool current_entry, bool change_color, int width, 2533 bool first_line, bool current_entry, bool change_color, int width,
2490 void *obj, 2534 void *obj, unsigned int percent_type,
2491 int (*obj__set_color)(void *obj, int color), 2535 int (*obj__set_color)(void *obj, int color),
2492 void (*obj__set_percent_color)(void *obj, double percent, bool current), 2536 void (*obj__set_percent_color)(void *obj, double percent, bool current),
2493 int (*obj__set_jumps_percent_color)(void *obj, int nr, bool current), 2537 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
2495 void (*obj__write_graph)(void *obj, int graph)) 2539 void (*obj__write_graph)(void *obj, int graph))
2496 2540
2497{ 2541{
2498 double percent_max = annotation_line__max_percent(al, notes); 2542 double percent_max = annotation_line__max_percent(al, notes, percent_type);
2499 int pcnt_width = annotation__pcnt_width(notes), 2543 int pcnt_width = annotation__pcnt_width(notes),
2500 cycles_width = annotation__cycles_width(notes); 2544 cycles_width = annotation__cycles_width(notes);
2501 bool show_title = false; 2545 bool show_title = false;
@@ -2514,15 +2558,18 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
2514 int i; 2558 int i;
2515 2559
2516 for (i = 0; i < notes->nr_events; i++) { 2560 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);
2518 if (notes->options->show_total_period) { 2566 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);
2520 } else if (notes->options->show_nr_samples) { 2568 } else if (notes->options->show_nr_samples) {
2521 obj__printf(obj, "%6" PRIu64 " ", 2569 obj__printf(obj, "%6" PRIu64 " ",
2522 al->samples[i].he.nr_samples); 2570 al->data[i].he.nr_samples);
2523 } else { 2571 } else {
2524 obj__printf(obj, "%6.2f ", 2572 obj__printf(obj, "%6.2f ", percent);
2525 al->samples[i].percent);
2526 } 2573 }
2527 } 2574 }
2528 } else { 2575 } else {
@@ -2640,13 +2687,15 @@ print_addr:
2640} 2687}
2641 2688
2642void annotation_line__write(struct annotation_line *al, struct annotation *notes, 2689void 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)
2644{ 2692{
2645 __annotation_line__write(al, notes, ops->first_line, ops->current_entry, 2693 __annotation_line__write(al, notes, wops->first_line, wops->current_entry,
2646 ops->change_color, ops->width, ops->obj, 2694 wops->change_color, wops->width, wops->obj,
2647 ops->set_color, ops->set_percent_color, 2695 opts->percent_type,
2648 ops->set_jumps_percent_color, ops->printf, 2696 wops->set_color, wops->set_percent_color,
2649 ops->write_graph); 2697 wops->set_jumps_percent_color, wops->printf,
2698 wops->write_graph);
2650} 2699}
2651 2700
2652int symbol__annotate2(struct symbol *sym, struct map *map, struct perf_evsel *evsel, 2701int symbol__annotate2(struct symbol *sym, struct map *map, struct perf_evsel *evsel,
@@ -2688,46 +2737,6 @@ out_free_offsets:
2688 return -1; 2737 return -1;
2689} 2738}
2690 2739
2691int __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
2731#define ANNOTATION__CFG(n) \ 2740#define ANNOTATION__CFG(n) \
2732 { .name = #n, .value = &annotation__default_options.n, } 2741 { .name = #n, .value = &annotation__default_options.n, }
2733 2742
@@ -2792,3 +2801,55 @@ void annotation_config__init(void)
2792 annotation__default_options.show_total_period = symbol_conf.show_total_period; 2801 annotation__default_options.show_total_period = symbol_conf.show_total_period;
2793 annotation__default_options.show_nr_samples = symbol_conf.show_nr_samples; 2802 annotation__default_options.show_nr_samples = symbol_conf.show_nr_samples;
2794} 2803}
2804
2805static 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
2826int 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
2852out:
2853 free(str1);
2854 return err;
2855}
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index a4c0d91907e6..005a5fe8a8c6 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -11,6 +11,7 @@
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/rbtree.h> 12#include <linux/rbtree.h>
13#include <pthread.h> 13#include <pthread.h>
14#include <asm/bug.h>
14 15
15struct ins_ops; 16struct ins_ops;
16 17
@@ -82,6 +83,7 @@ struct annotation_options {
82 int context; 83 int context;
83 const char *objdump_path; 84 const char *objdump_path;
84 const char *disassembler_style; 85 const char *disassembler_style;
86 unsigned int percent_type;
85}; 87};
86 88
87enum { 89enum {
@@ -101,8 +103,16 @@ struct sym_hist_entry {
101 u64 period; 103 u64 period;
102}; 104};
103 105
106enum {
107 PERCENT_HITS_LOCAL,
108 PERCENT_HITS_GLOBAL,
109 PERCENT_PERIOD_LOCAL,
110 PERCENT_PERIOD_GLOBAL,
111 PERCENT_MAX,
112};
113
104struct annotation_data { 114struct annotation_data {
105 double percent; 115 double percent[PERCENT_MAX];
106 double percent_sum; 116 double percent_sum;
107 struct sym_hist_entry he; 117 struct sym_hist_entry he;
108}; 118};
@@ -122,8 +132,8 @@ struct annotation_line {
122 char *path; 132 char *path;
123 u32 idx; 133 u32 idx;
124 int idx_asm; 134 int idx_asm;
125 int samples_nr; 135 int data_nr;
126 struct annotation_data samples[0]; 136 struct annotation_data data[0];
127}; 137};
128 138
129struct disasm_line { 139struct disasm_line {
@@ -134,6 +144,27 @@ struct disasm_line {
134 struct annotation_line al; 144 struct annotation_line al;
135}; 145};
136 146
147static 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
153static 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
137static inline struct disasm_line *disasm_line(struct annotation_line *al) 168static inline struct disasm_line *disasm_line(struct annotation_line *al)
138{ 169{
139 return al ? container_of(al, struct disasm_line, al) : NULL; 170 return al ? container_of(al, struct disasm_line, al) : NULL;
@@ -169,22 +200,15 @@ struct annotation_write_ops {
169 void (*write_graph)(void *obj, int graph); 200 void (*write_graph)(void *obj, int graph);
170}; 201};
171 202
172double annotation_line__max_percent(struct annotation_line *al, struct annotation *notes);
173void annotation_line__write(struct annotation_line *al, struct annotation *notes, 203void 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);
175 206
176int __annotation__scnprintf_samples_period(struct annotation *notes, 207int __annotation__scnprintf_samples_period(struct annotation *notes,
177 char *bf, size_t size, 208 char *bf, size_t size,
178 struct perf_evsel *evsel, 209 struct perf_evsel *evsel,
179 bool show_freq); 210 bool show_freq);
180 211
181static 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
188int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw); 212int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw);
189size_t disasm__fprintf(struct list_head *head, FILE *fp); 213size_t disasm__fprintf(struct list_head *head, FILE *fp);
190void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel); 214void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel);
@@ -340,12 +364,12 @@ int symbol__strerror_disassemble(struct symbol *sym, struct map *map,
340int symbol__annotate_printf(struct symbol *sym, struct map *map, 364int symbol__annotate_printf(struct symbol *sym, struct map *map,
341 struct perf_evsel *evsel, 365 struct perf_evsel *evsel,
342 struct annotation_options *options); 366 struct annotation_options *options);
343int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp);
344void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); 367void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
345void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); 368void symbol__annotate_decay_histogram(struct symbol *sym, int evidx);
346void annotated_source__purge(struct annotated_source *as); 369void annotated_source__purge(struct annotated_source *as);
347 370
348int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel); 371int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel,
372 struct annotation_options *opts);
349 373
350bool ui__has_annotation(void); 374bool ui__has_annotation(void);
351 375
@@ -373,4 +397,6 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused,
373 397
374void annotation_config__init(void); 398void annotation_config__init(void);
375 399
400int annotate_parse_percent_type(const struct option *opt, const char *_str,
401 int unset);
376#endif /* __PERF_ANNOTATE_H */ 402#endif /* __PERF_ANNOTATE_H */
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index d056447520a2..db1511359c5e 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -56,6 +56,7 @@
56#include "intel-pt.h" 56#include "intel-pt.h"
57#include "intel-bts.h" 57#include "intel-bts.h"
58#include "arm-spe.h" 58#include "arm-spe.h"
59#include "s390-cpumsf.h"
59 60
60#include "sane_ctype.h" 61#include "sane_ctype.h"
61#include "symbol/kallsyms.h" 62#include "symbol/kallsyms.h"
@@ -202,6 +203,9 @@ static int auxtrace_queues__grow(struct auxtrace_queues *queues,
202 for (i = 0; i < queues->nr_queues; i++) { 203 for (i = 0; i < queues->nr_queues; i++) {
203 list_splice_tail(&queues->queue_array[i].head, 204 list_splice_tail(&queues->queue_array[i].head,
204 &queue_array[i].head); 205 &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;
205 queue_array[i].priv = queues->queue_array[i].priv; 209 queue_array[i].priv = queues->queue_array[i].priv;
206 } 210 }
207 211
@@ -920,6 +924,8 @@ int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused,
920 return arm_spe_process_auxtrace_info(event, session); 924 return arm_spe_process_auxtrace_info(event, session);
921 case PERF_AUXTRACE_CS_ETM: 925 case PERF_AUXTRACE_CS_ETM:
922 return cs_etm__process_auxtrace_info(event, session); 926 return cs_etm__process_auxtrace_info(event, session);
927 case PERF_AUXTRACE_S390_CPUMSF:
928 return s390_cpumsf_process_auxtrace_info(event, session);
923 case PERF_AUXTRACE_UNKNOWN: 929 case PERF_AUXTRACE_UNKNOWN:
924 default: 930 default:
925 return -EINVAL; 931 return -EINVAL;
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index e731f55da072..71fc3bd74299 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -44,6 +44,7 @@ enum auxtrace_type {
44 PERF_AUXTRACE_INTEL_BTS, 44 PERF_AUXTRACE_INTEL_BTS,
45 PERF_AUXTRACE_CS_ETM, 45 PERF_AUXTRACE_CS_ETM,
46 PERF_AUXTRACE_ARM_SPE, 46 PERF_AUXTRACE_ARM_SPE,
47 PERF_AUXTRACE_S390_CPUMSF,
47}; 48};
48 49
49enum itrace_period_type { 50enum itrace_period_type {
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 3d02ae38ec56..47aac41349a2 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -1529,13 +1529,13 @@ int bpf__apply_obj_config(void)
1529 bpf_object__for_each_safe(obj, objtmp) \ 1529 bpf_object__for_each_safe(obj, objtmp) \
1530 bpf_map__for_each(pos, obj) 1530 bpf_map__for_each(pos, obj)
1531 1531
1532#define bpf__for_each_stdout_map(pos, obj, objtmp) \ 1532#define bpf__for_each_map_named(pos, obj, objtmp, name) \
1533 bpf__for_each_map(pos, obj, objtmp) \ 1533 bpf__for_each_map(pos, obj, objtmp) \
1534 if (bpf_map__name(pos) && \ 1534 if (bpf_map__name(pos) && \
1535 (strcmp("__bpf_stdout__", \ 1535 (strcmp(name, \
1536 bpf_map__name(pos)) == 0)) 1536 bpf_map__name(pos)) == 0))
1537 1537
1538int bpf__setup_stdout(struct perf_evlist *evlist) 1538struct perf_evsel *bpf__setup_output_event(struct perf_evlist *evlist, const char *name)
1539{ 1539{
1540 struct bpf_map_priv *tmpl_priv = NULL; 1540 struct bpf_map_priv *tmpl_priv = NULL;
1541 struct bpf_object *obj, *tmp; 1541 struct bpf_object *obj, *tmp;
@@ -1544,11 +1544,11 @@ int bpf__setup_stdout(struct perf_evlist *evlist)
1544 int err; 1544 int err;
1545 bool need_init = false; 1545 bool need_init = false;
1546 1546
1547 bpf__for_each_stdout_map(map, obj, tmp) { 1547 bpf__for_each_map_named(map, obj, tmp, name) {
1548 struct bpf_map_priv *priv = bpf_map__priv(map); 1548 struct bpf_map_priv *priv = bpf_map__priv(map);
1549 1549
1550 if (IS_ERR(priv)) 1550 if (IS_ERR(priv))
1551 return -BPF_LOADER_ERRNO__INTERNAL; 1551 return ERR_PTR(-BPF_LOADER_ERRNO__INTERNAL);
1552 1552
1553 /* 1553 /*
1554 * No need to check map type: type should have been 1554 * No need to check map type: type should have been
@@ -1561,49 +1561,61 @@ int bpf__setup_stdout(struct perf_evlist *evlist)
1561 } 1561 }
1562 1562
1563 if (!need_init) 1563 if (!need_init)
1564 return 0; 1564 return NULL;
1565 1565
1566 if (!tmpl_priv) { 1566 if (!tmpl_priv) {
1567 err = parse_events(evlist, "bpf-output/no-inherit=1,name=__bpf_stdout__/", 1567 char *event_definition = NULL;
1568 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
1569 if (err) { 1575 if (err) {
1570 pr_debug("ERROR: failed to create bpf-output event\n"); 1576 pr_debug("ERROR: failed to create the \"%s\" bpf-output event\n", name);
1571 return -err; 1577 return ERR_PTR(-err);
1572 } 1578 }
1573 1579
1574 evsel = perf_evlist__last(evlist); 1580 evsel = perf_evlist__last(evlist);
1575 } 1581 }
1576 1582
1577 bpf__for_each_stdout_map(map, obj, tmp) { 1583 bpf__for_each_map_named(map, obj, tmp, name) {
1578 struct bpf_map_priv *priv = bpf_map__priv(map); 1584 struct bpf_map_priv *priv = bpf_map__priv(map);
1579 1585
1580 if (IS_ERR(priv)) 1586 if (IS_ERR(priv))
1581 return -BPF_LOADER_ERRNO__INTERNAL; 1587 return ERR_PTR(-BPF_LOADER_ERRNO__INTERNAL);
1582 if (priv) 1588 if (priv)
1583 continue; 1589 continue;
1584 1590
1585 if (tmpl_priv) { 1591 if (tmpl_priv) {
1586 priv = bpf_map_priv__clone(tmpl_priv); 1592 priv = bpf_map_priv__clone(tmpl_priv);
1587 if (!priv) 1593 if (!priv)
1588 return -ENOMEM; 1594 return ERR_PTR(-ENOMEM);
1589 1595
1590 err = bpf_map__set_priv(map, priv, bpf_map_priv__clear); 1596 err = bpf_map__set_priv(map, priv, bpf_map_priv__clear);
1591 if (err) { 1597 if (err) {
1592 bpf_map_priv__clear(map, priv); 1598 bpf_map_priv__clear(map, priv);
1593 return err; 1599 return ERR_PTR(err);
1594 } 1600 }
1595 } else if (evsel) { 1601 } else if (evsel) {
1596 struct bpf_map_op *op; 1602 struct bpf_map_op *op;
1597 1603
1598 op = bpf_map__add_newop(map, NULL); 1604 op = bpf_map__add_newop(map, NULL);
1599 if (IS_ERR(op)) 1605 if (IS_ERR(op))
1600 return PTR_ERR(op); 1606 return ERR_PTR(PTR_ERR(op));
1601 op->op_type = BPF_MAP_OP_SET_EVSEL; 1607 op->op_type = BPF_MAP_OP_SET_EVSEL;
1602 op->v.evsel = evsel; 1608 op->v.evsel = evsel;
1603 } 1609 }
1604 } 1610 }
1605 1611
1606 return 0; 1612 return evsel;
1613}
1614
1615int 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;
1607} 1619}
1608 1620
1609#define ERRNO_OFFSET(e) ((e) - __BPF_LOADER_ERRNO__START) 1621#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)
1780 return 0; 1792 return 0;
1781} 1793}
1782 1794
1783int bpf__strerror_setup_stdout(struct perf_evlist *evlist __maybe_unused, 1795int bpf__strerror_setup_output_event(struct perf_evlist *evlist __maybe_unused,
1784 int err, char *buf, size_t size) 1796 int err, char *buf, size_t size)
1785{ 1797{
1786 bpf__strerror_head(err, buf, size); 1798 bpf__strerror_head(err, buf, size);
1787 bpf__strerror_end(buf, size); 1799 bpf__strerror_end(buf, size);
diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h
index 5d3aefd6fae7..62d245a90e1d 100644
--- a/tools/perf/util/bpf-loader.h
+++ b/tools/perf/util/bpf-loader.h
@@ -43,6 +43,7 @@ enum bpf_loader_errno {
43 __BPF_LOADER_ERRNO__END, 43 __BPF_LOADER_ERRNO__END,
44}; 44};
45 45
46struct perf_evsel;
46struct bpf_object; 47struct bpf_object;
47struct parse_events_term; 48struct parse_events_term;
48#define PERF_BPF_PROBE_GROUP "perf_bpf_probe" 49#define PERF_BPF_PROBE_GROUP "perf_bpf_probe"
@@ -82,9 +83,8 @@ int bpf__apply_obj_config(void);
82int bpf__strerror_apply_obj_config(int err, char *buf, size_t size); 83int bpf__strerror_apply_obj_config(int err, char *buf, size_t size);
83 84
84int bpf__setup_stdout(struct perf_evlist *evlist); 85int bpf__setup_stdout(struct perf_evlist *evlist);
85int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err, 86struct perf_evsel *bpf__setup_output_event(struct perf_evlist *evlist, const char *name);
86 char *buf, size_t size); 87int bpf__strerror_setup_output_event(struct perf_evlist *evlist, int err, char *buf, size_t size);
87
88#else 88#else
89#include <errno.h> 89#include <errno.h>
90 90
@@ -138,6 +138,12 @@ bpf__setup_stdout(struct perf_evlist *evlist __maybe_unused)
138 return 0; 138 return 0;
139} 139}
140 140
141static inline struct perf_evsel *
142bpf__setup_output_event(struct perf_evlist *evlist __maybe_unused, const char *name __maybe_unused)
143{
144 return NULL;
145}
146
141static inline int 147static inline int
142__bpf_strerror(char *buf, size_t size) 148__bpf_strerror(char *buf, size_t size)
143{ 149{
@@ -193,11 +199,16 @@ bpf__strerror_apply_obj_config(int err __maybe_unused,
193} 199}
194 200
195static inline int 201static inline int
196bpf__strerror_setup_stdout(struct perf_evlist *evlist __maybe_unused, 202bpf__strerror_setup_output_event(struct perf_evlist *evlist __maybe_unused,
197 int err __maybe_unused, char *buf, 203 int err __maybe_unused, char *buf, size_t size)
198 size_t size)
199{ 204{
200 return __bpf_strerror(buf, size); 205 return __bpf_strerror(buf, size);
201} 206}
207
202#endif 208#endif
209
210static 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}
203#endif 214#endif
diff --git a/tools/perf/util/compress.h b/tools/perf/util/compress.h
index ecca688a25fb..892e92e7e7fc 100644
--- a/tools/perf/util/compress.h
+++ b/tools/perf/util/compress.h
@@ -4,10 +4,12 @@
4 4
5#ifdef HAVE_ZLIB_SUPPORT 5#ifdef HAVE_ZLIB_SUPPORT
6int gzip_decompress_to_file(const char *input, int output_fd); 6int gzip_decompress_to_file(const char *input, int output_fd);
7bool gzip_is_compressed(const char *input);
7#endif 8#endif
8 9
9#ifdef HAVE_LZMA_SUPPORT 10#ifdef HAVE_LZMA_SUPPORT
10int lzma_decompress_to_file(const char *input, int output_fd); 11int lzma_decompress_to_file(const char *input, int output_fd);
12bool lzma_is_compressed(const char *input);
11#endif 13#endif
12 14
13#endif /* PERF_COMPRESS_H */ 15#endif /* PERF_COMPRESS_H */
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 5744c12641a5..abd38abf1d91 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -310,8 +310,8 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
310 if (flags & FIELD_IS_DYNAMIC) { 310 if (flags & FIELD_IS_DYNAMIC) {
311 unsigned long long tmp_val; 311 unsigned long long tmp_val;
312 312
313 tmp_val = pevent_read_number(fmtf->event->pevent, 313 tmp_val = tep_read_number(fmtf->event->pevent,
314 data + offset, len); 314 data + offset, len);
315 offset = tmp_val; 315 offset = tmp_val;
316 len = offset >> 16; 316 len = offset >> 16;
317 offset &= 0xffff; 317 offset &= 0xffff;
@@ -353,7 +353,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
353 else { 353 else {
354 unsigned long long value_int; 354 unsigned long long value_int;
355 355
356 value_int = pevent_read_number( 356 value_int = tep_read_number(
357 fmtf->event->pevent, 357 fmtf->event->pevent,
358 data + offset + i * len, len); 358 data + offset + i * len, len);
359 359
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 51cf82cf1882..bbed90e5d9bb 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -189,28 +189,34 @@ int dso__read_binary_type_filename(const struct dso *dso,
189 return ret; 189 return ret;
190} 190}
191 191
192enum {
193 COMP_ID__NONE = 0,
194};
195
192static const struct { 196static const struct {
193 const char *fmt; 197 const char *fmt;
194 int (*decompress)(const char *input, int output); 198 int (*decompress)(const char *input, int output);
199 bool (*is_compressed)(const char *input);
195} compressions[] = { 200} compressions[] = {
201 [COMP_ID__NONE] = { .fmt = NULL, },
196#ifdef HAVE_ZLIB_SUPPORT 202#ifdef HAVE_ZLIB_SUPPORT
197 { "gz", gzip_decompress_to_file }, 203 { "gz", gzip_decompress_to_file, gzip_is_compressed },
198#endif 204#endif
199#ifdef HAVE_LZMA_SUPPORT 205#ifdef HAVE_LZMA_SUPPORT
200 { "xz", lzma_decompress_to_file }, 206 { "xz", lzma_decompress_to_file, lzma_is_compressed },
201#endif 207#endif
202 { NULL, NULL }, 208 { NULL, NULL, NULL },
203}; 209};
204 210
205bool is_supported_compression(const char *ext) 211static int is_supported_compression(const char *ext)
206{ 212{
207 unsigned i; 213 unsigned i;
208 214
209 for (i = 0; compressions[i].fmt; i++) { 215 for (i = 1; compressions[i].fmt; i++) {
210 if (!strcmp(ext, compressions[i].fmt)) 216 if (!strcmp(ext, compressions[i].fmt))
211 return true; 217 return i;
212 } 218 }
213 return false; 219 return COMP_ID__NONE;
214} 220}
215 221
216bool is_kernel_module(const char *pathname, int cpumode) 222bool is_kernel_module(const char *pathname, int cpumode)
@@ -239,80 +245,73 @@ bool is_kernel_module(const char *pathname, int cpumode)
239 return m.kmod; 245 return m.kmod;
240} 246}
241 247
242bool 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
254bool dso__needs_decompress(struct dso *dso) 248bool dso__needs_decompress(struct dso *dso)
255{ 249{
256 return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP || 250 return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
257 dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP; 251 dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
258} 252}
259 253
260static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf) 254static int decompress_kmodule(struct dso *dso, const char *name,
255 char *pathname, size_t len)
261{ 256{
257 char tmpbuf[] = KMOD_DECOMP_NAME;
262 int fd = -1; 258 int fd = -1;
263 struct kmod_path m;
264 259
265 if (!dso__needs_decompress(dso)) 260 if (!dso__needs_decompress(dso))
266 return -1; 261 return -1;
267 262
268 if (kmod_path__parse_ext(&m, dso->long_name)) 263 if (dso->comp == COMP_ID__NONE)
269 return -1; 264 return -1;
270 265
271 if (!m.comp) 266 /*
272 goto out; 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);
273 281
274 fd = mkstemp(tmpbuf); 282 fd = mkstemp(tmpbuf);
275 if (fd < 0) { 283 if (fd < 0) {
276 dso->load_errno = errno; 284 dso->load_errno = errno;
277 goto out; 285 return -1;
278 } 286 }
279 287
280 if (!decompress_to_file(m.ext, name, fd)) { 288 if (compressions[dso->comp].decompress(name, fd)) {
281 dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE; 289 dso->load_errno = DSO_LOAD_ERRNO__DECOMPRESSION_FAILURE;
282 close(fd); 290 close(fd);
283 fd = -1; 291 fd = -1;
284 } 292 }
285 293
286out: 294 if (!pathname || (fd < 0))
287 free(m.ext); 295 unlink(tmpbuf);
296
297 if (pathname && (fd >= 0))
298 strncpy(pathname, tmpbuf, len);
299
288 return fd; 300 return fd;
289} 301}
290 302
291int dso__decompress_kmodule_fd(struct dso *dso, const char *name) 303int dso__decompress_kmodule_fd(struct dso *dso, const char *name)
292{ 304{
293 char tmpbuf[] = KMOD_DECOMP_NAME; 305 return decompress_kmodule(dso, name, NULL, 0);
294 int fd;
295
296 fd = decompress_kmodule(dso, name, tmpbuf);
297 unlink(tmpbuf);
298 return fd;
299} 306}
300 307
301int dso__decompress_kmodule_path(struct dso *dso, const char *name, 308int dso__decompress_kmodule_path(struct dso *dso, const char *name,
302 char *pathname, size_t len) 309 char *pathname, size_t len)
303{ 310{
304 char tmpbuf[] = KMOD_DECOMP_NAME; 311 int fd = decompress_kmodule(dso, name, pathname, len);
305 int fd;
306 312
307 fd = decompress_kmodule(dso, name, tmpbuf);
308 if (fd < 0) {
309 unlink(tmpbuf);
310 return -1;
311 }
312
313 strncpy(pathname, tmpbuf, len);
314 close(fd); 313 close(fd);
315 return 0; 314 return fd >= 0 ? 0 : -1;
316} 315}
317 316
318/* 317/*
@@ -332,7 +331,7 @@ int dso__decompress_kmodule_path(struct dso *dso, const char *name,
332 * Returns 0 if there's no strdup error, -ENOMEM otherwise. 331 * Returns 0 if there's no strdup error, -ENOMEM otherwise.
333 */ 332 */
334int __kmod_path__parse(struct kmod_path *m, const char *path, 333int __kmod_path__parse(struct kmod_path *m, const char *path,
335 bool alloc_name, bool alloc_ext) 334 bool alloc_name)
336{ 335{
337 const char *name = strrchr(path, '/'); 336 const char *name = strrchr(path, '/');
338 const char *ext = strrchr(path, '.'); 337 const char *ext = strrchr(path, '.');
@@ -372,10 +371,9 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
372 return 0; 371 return 0;
373 } 372 }
374 373
375 if (is_supported_compression(ext + 1)) { 374 m->comp = is_supported_compression(ext + 1);
376 m->comp = true; 375 if (m->comp > COMP_ID__NONE)
377 ext -= 3; 376 ext -= 3;
378 }
379 377
380 /* Check .ko extension only if there's enough name left. */ 378 /* Check .ko extension only if there's enough name left. */
381 if (ext > name) 379 if (ext > name)
@@ -393,14 +391,6 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
393 strxfrchar(m->name, '-', '_'); 391 strxfrchar(m->name, '-', '_');
394 } 392 }
395 393
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
404 return 0; 394 return 0;
405} 395}
406 396
@@ -413,8 +403,10 @@ void dso__set_module_info(struct dso *dso, struct kmod_path *m,
413 dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE; 403 dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
414 404
415 /* _KMODULE_COMP should be next to _KMODULE */ 405 /* _KMODULE_COMP should be next to _KMODULE */
416 if (m->kmod && m->comp) 406 if (m->kmod && m->comp) {
417 dso->symtab_type++; 407 dso->symtab_type++;
408 dso->comp = m->comp;
409 }
418 410
419 dso__set_short_name(dso, strdup(m->name), true); 411 dso__set_short_name(dso, strdup(m->name), true);
420} 412}
@@ -468,6 +460,7 @@ static int __open_dso(struct dso *dso, struct machine *machine)
468 int fd = -EINVAL; 460 int fd = -EINVAL;
469 char *root_dir = (char *)""; 461 char *root_dir = (char *)"";
470 char *name = malloc(PATH_MAX); 462 char *name = malloc(PATH_MAX);
463 bool decomp = false;
471 464
472 if (!name) 465 if (!name)
473 return -ENOMEM; 466 return -ENOMEM;
@@ -491,12 +484,13 @@ static int __open_dso(struct dso *dso, struct machine *machine)
491 goto out; 484 goto out;
492 } 485 }
493 486
487 decomp = true;
494 strcpy(name, newpath); 488 strcpy(name, newpath);
495 } 489 }
496 490
497 fd = do_open(name); 491 fd = do_open(name);
498 492
499 if (dso__needs_decompress(dso)) 493 if (decomp)
500 unlink(name); 494 unlink(name);
501 495
502out: 496out:
@@ -1218,6 +1212,7 @@ struct dso *dso__new(const char *name)
1218 dso->a2l_fails = 1; 1212 dso->a2l_fails = 1;
1219 dso->kernel = DSO_TYPE_USER; 1213 dso->kernel = DSO_TYPE_USER;
1220 dso->needs_swap = DSO_SWAP__UNSET; 1214 dso->needs_swap = DSO_SWAP__UNSET;
1215 dso->comp = COMP_ID__NONE;
1221 RB_CLEAR_NODE(&dso->rb_node); 1216 RB_CLEAR_NODE(&dso->rb_node);
1222 dso->root = NULL; 1217 dso->root = NULL;
1223 INIT_LIST_HEAD(&dso->node); 1218 INIT_LIST_HEAD(&dso->node);
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index ef69de2e69ea..c5380500bed4 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -175,6 +175,7 @@ struct dso {
175 u16 short_name_len; 175 u16 short_name_len;
176 void *dwfl; /* DWARF debug info */ 176 void *dwfl; /* DWARF debug info */
177 struct auxtrace_cache *auxtrace_cache; 177 struct auxtrace_cache *auxtrace_cache;
178 int comp;
178 179
179 /* dso data file */ 180 /* dso data file */
180 struct { 181 struct {
@@ -250,9 +251,7 @@ int dso__kernel_module_get_build_id(struct dso *dso, const char *root_dir);
250char dso__symtab_origin(const struct dso *dso); 251char dso__symtab_origin(const struct dso *dso);
251int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type type, 252int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type type,
252 char *root_dir, char *filename, size_t size); 253 char *root_dir, char *filename, size_t size);
253bool is_supported_compression(const char *ext);
254bool is_kernel_module(const char *pathname, int cpumode); 254bool is_kernel_module(const char *pathname, int cpumode);
255bool decompress_to_file(const char *ext, const char *filename, int output_fd);
256bool dso__needs_decompress(struct dso *dso); 255bool dso__needs_decompress(struct dso *dso);
257int dso__decompress_kmodule_fd(struct dso *dso, const char *name); 256int dso__decompress_kmodule_fd(struct dso *dso, const char *name);
258int dso__decompress_kmodule_path(struct dso *dso, const char *name, 257int 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,
263 262
264struct kmod_path { 263struct kmod_path {
265 char *name; 264 char *name;
266 char *ext; 265 int comp;
267 bool comp;
268 bool kmod; 266 bool kmod;
269}; 267};
270 268
271int __kmod_path__parse(struct kmod_path *m, const char *path, 269int __kmod_path__parse(struct kmod_path *m, const char *path,
272 bool alloc_name, bool alloc_ext); 270 bool alloc_name);
273 271
274#define kmod_path__parse(__m, __p) __kmod_path__parse(__m, __p, false, false) 272#define kmod_path__parse(__m, __p) __kmod_path__parse(__m, __p, false)
275#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false) 273#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true)
276#define kmod_path__parse_ext(__m, __p) __kmod_path__parse(__m, __p, false, true)
277 274
278void dso__set_module_info(struct dso *dso, struct kmod_path *m, 275void dso__set_module_info(struct dso *dso, struct kmod_path *m,
279 struct machine *machine); 276 struct machine *machine);
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 0c8ecf0c78a4..0cd42150f712 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -541,10 +541,17 @@ static int __event__synthesize_thread(union perf_event *comm_event,
541 tgid, process, machine) < 0) 541 tgid, process, machine) < 0)
542 return -1; 542 return -1;
543 543
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;
544 553
545 return perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid, 554 return 0;
546 process, machine, mmap_data,
547 proc_map_timeout);
548 } 555 }
549 556
550 if (machine__is_default_guest(machine)) 557 if (machine__is_default_guest(machine))
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index e7a4b31a84fb..be440df29615 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -803,7 +803,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
803 if (*output == -1) { 803 if (*output == -1) {
804 *output = fd; 804 *output = fd;
805 805
806 if (perf_mmap__mmap(&maps[idx], mp, *output) < 0) 806 if (perf_mmap__mmap(&maps[idx], mp, *output, evlist_cpu) < 0)
807 return -1; 807 return -1;
808 } else { 808 } else {
809 if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0) 809 if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ddf84b941abf..c980bbff6353 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2683,7 +2683,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
2683 2683
2684struct format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name) 2684struct format_field *perf_evsel__field(struct perf_evsel *evsel, const char *name)
2685{ 2685{
2686 return pevent_find_field(evsel->tp_format, name); 2686 return tep_find_field(evsel->tp_format, name);
2687} 2687}
2688 2688
2689void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample, 2689void *perf_evsel__rawptr(struct perf_evsel *evsel, struct perf_sample *sample,
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 973c03167947..163c960614d3 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -452,11 +452,18 @@ static inline int perf_evsel__group_idx(struct perf_evsel *evsel)
452 return evsel->idx - evsel->leader->idx; 452 return evsel->idx - evsel->leader->idx;
453} 453}
454 454
455/* Iterates group WITHOUT the leader. */
455#define for_each_group_member(_evsel, _leader) \ 456#define for_each_group_member(_evsel, _leader) \
456for ((_evsel) = list_entry((_leader)->node.next, struct perf_evsel, node); \ 457for ((_evsel) = list_entry((_leader)->node.next, struct perf_evsel, node); \
457 (_evsel) && (_evsel)->leader == (_leader); \ 458 (_evsel) && (_evsel)->leader == (_leader); \
458 (_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node)) 459 (_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node))
459 460
461/* Iterates group WITH the leader. */
462#define for_each_group_evsel(_evsel, _leader) \
463for ((_evsel) = _leader; \
464 (_evsel) && (_evsel)->leader == (_leader); \
465 (_evsel) = list_entry((_evsel)->node.next, struct perf_evsel, node))
466
460static inline bool perf_evsel__has_branch_callstack(const struct perf_evsel *evsel) 467static inline bool perf_evsel__has_branch_callstack(const struct perf_evsel *evsel)
461{ 468{
462 return evsel->attr.branch_sample_type & PERF_SAMPLE_BRANCH_CALL_STACK; 469 return evsel->attr.branch_sample_type & PERF_SAMPLE_BRANCH_CALL_STACK;
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 5af58aac91ad..3cadc252dd89 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -279,8 +279,6 @@ static int do_read_bitmap(struct feat_fd *ff, unsigned long **pset, u64 *psize)
279 if (!set) 279 if (!set)
280 return -ENOMEM; 280 return -ENOMEM;
281 281
282 bitmap_zero(set, size);
283
284 p = (u64 *) set; 282 p = (u64 *) set;
285 283
286 for (i = 0; (u64) i < BITS_TO_U64(size); i++) { 284 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)
1285 return -ENOMEM; 1283 return -ENOMEM;
1286 } 1284 }
1287 1285
1288 bitmap_zero(n->set, size);
1289 n->node = idx; 1286 n->node = idx;
1290 n->size = size; 1287 n->size = size;
1291 1288
@@ -3207,7 +3204,7 @@ static int read_attr(int fd, struct perf_header *ph,
3207} 3204}
3208 3205
3209static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel, 3206static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel,
3210 struct pevent *pevent) 3207 struct tep_handle *pevent)
3211{ 3208{
3212 struct event_format *event; 3209 struct event_format *event;
3213 char bf[128]; 3210 char bf[128];
@@ -3221,7 +3218,7 @@ static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel,
3221 return -1; 3218 return -1;
3222 } 3219 }
3223 3220
3224 event = pevent_find_event(pevent, evsel->attr.config); 3221 event = tep_find_event(pevent, evsel->attr.config);
3225 if (event == NULL) { 3222 if (event == NULL) {
3226 pr_debug("cannot find event format for %d\n", (int)evsel->attr.config); 3223 pr_debug("cannot find event format for %d\n", (int)evsel->attr.config);
3227 return -1; 3224 return -1;
@@ -3239,7 +3236,7 @@ static int perf_evsel__prepare_tracepoint_event(struct perf_evsel *evsel,
3239} 3236}
3240 3237
3241static int perf_evlist__prepare_tracepoint_events(struct perf_evlist *evlist, 3238static int perf_evlist__prepare_tracepoint_events(struct perf_evlist *evlist,
3242 struct pevent *pevent) 3239 struct tep_handle *pevent)
3243{ 3240{
3244 struct perf_evsel *pos; 3241 struct perf_evsel *pos;
3245 3242
diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
index 5e94857dfca2..19262f98cd4e 100644
--- a/tools/perf/util/llvm-utils.c
+++ b/tools/perf/util/llvm-utils.c
@@ -22,12 +22,14 @@
22 "$CLANG_OPTIONS $KERNEL_INC_OPTIONS $PERF_BPF_INC_OPTIONS " \ 22 "$CLANG_OPTIONS $KERNEL_INC_OPTIONS $PERF_BPF_INC_OPTIONS " \
23 "-Wno-unused-value -Wno-pointer-sign " \ 23 "-Wno-unused-value -Wno-pointer-sign " \
24 "-working-directory $WORKING_DIR " \ 24 "-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"
26 26
27struct llvm_param llvm_param = { 27struct llvm_param llvm_param = {
28 .clang_path = "clang", 28 .clang_path = "clang",
29 .llc_path = "llc",
29 .clang_bpf_cmd_template = CLANG_BPF_CMD_DEFAULT_TEMPLATE, 30 .clang_bpf_cmd_template = CLANG_BPF_CMD_DEFAULT_TEMPLATE,
30 .clang_opt = NULL, 31 .clang_opt = NULL,
32 .opts = NULL,
31 .kbuild_dir = NULL, 33 .kbuild_dir = NULL,
32 .kbuild_opts = NULL, 34 .kbuild_opts = NULL,
33 .user_set_param = false, 35 .user_set_param = false,
@@ -51,6 +53,8 @@ int perf_llvm_config(const char *var, const char *value)
51 llvm_param.kbuild_opts = strdup(value); 53 llvm_param.kbuild_opts = strdup(value);
52 else if (!strcmp(var, "dump-obj")) 54 else if (!strcmp(var, "dump-obj"))
53 llvm_param.dump_obj = !!perf_config_bool(var, value); 55 llvm_param.dump_obj = !!perf_config_bool(var, value);
56 else if (!strcmp(var, "opts"))
57 llvm_param.opts = strdup(value);
54 else { 58 else {
55 pr_debug("Invalid LLVM config option: %s\n", value); 59 pr_debug("Invalid LLVM config option: %s\n", value);
56 return -1; 60 return -1;
@@ -430,11 +434,13 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
430 unsigned int kernel_version; 434 unsigned int kernel_version;
431 char linux_version_code_str[64]; 435 char linux_version_code_str[64];
432 const char *clang_opt = llvm_param.clang_opt; 436 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];
434 char serr[STRERR_BUFSIZE]; 438 char serr[STRERR_BUFSIZE];
435 char *kbuild_dir = NULL, *kbuild_include_opts = NULL, 439 char *kbuild_dir = NULL, *kbuild_include_opts = NULL,
436 *perf_bpf_include_opts = NULL; 440 *perf_bpf_include_opts = NULL;
437 const char *template = llvm_param.clang_bpf_cmd_template; 441 const char *template = llvm_param.clang_bpf_cmd_template;
442 char *pipe_template = NULL;
443 const char *opts = llvm_param.opts;
438 char *command_echo = NULL, *command_out; 444 char *command_echo = NULL, *command_out;
439 char *perf_include_dir = system_path(PERF_INCLUDE_DIR); 445 char *perf_include_dir = system_path(PERF_INCLUDE_DIR);
440 446
@@ -484,6 +490,26 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
484 force_set_env("PERF_BPF_INC_OPTIONS", perf_bpf_include_opts); 490 force_set_env("PERF_BPF_INC_OPTIONS", perf_bpf_include_opts);
485 force_set_env("WORKING_DIR", kbuild_dir ? : "."); 491 force_set_env("WORKING_DIR", kbuild_dir ? : ".");
486 492
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
487 /* 513 /*
488 * Since we may reset clang's working dir, path of source file 514 * Since we may reset clang's working dir, path of source file
489 * should be transferred into absolute path, except we want 515 * should be transferred into absolute path, except we want
@@ -535,6 +561,7 @@ errout:
535 free(obj_buf); 561 free(obj_buf);
536 free(perf_bpf_include_opts); 562 free(perf_bpf_include_opts);
537 free(perf_include_dir); 563 free(perf_include_dir);
564 free(pipe_template);
538 if (p_obj_buf) 565 if (p_obj_buf)
539 *p_obj_buf = NULL; 566 *p_obj_buf = NULL;
540 if (p_obj_buf_sz) 567 if (p_obj_buf_sz)
diff --git a/tools/perf/util/llvm-utils.h b/tools/perf/util/llvm-utils.h
index d3ad8deb5db4..bf3f3f4c4fe2 100644
--- a/tools/perf/util/llvm-utils.h
+++ b/tools/perf/util/llvm-utils.h
@@ -11,6 +11,8 @@
11struct llvm_param { 11struct llvm_param {
12 /* Path of clang executable */ 12 /* Path of clang executable */
13 const char *clang_path; 13 const char *clang_path;
14 /* Path of llc executable */
15 const char *llc_path;
14 /* 16 /*
15 * Template of clang bpf compiling. 5 env variables 17 * Template of clang bpf compiling. 5 env variables
16 * can be used: 18 * can be used:
@@ -23,6 +25,13 @@ struct llvm_param {
23 const char *clang_bpf_cmd_template; 25 const char *clang_bpf_cmd_template;
24 /* Will be filled in $CLANG_OPTIONS */ 26 /* Will be filled in $CLANG_OPTIONS */
25 const char *clang_opt; 27 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;
26 /* Where to find kbuild system */ 35 /* Where to find kbuild system */
27 const char *kbuild_dir; 36 const char *kbuild_dir;
28 /* 37 /*
diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c
index 07498eaddc08..b1dd29a9d915 100644
--- a/tools/perf/util/lzma.c
+++ b/tools/perf/util/lzma.c
@@ -3,9 +3,13 @@
3#include <lzma.h> 3#include <lzma.h>
4#include <stdio.h> 4#include <stdio.h>
5#include <linux/compiler.h> 5#include <linux/compiler.h>
6#include <sys/types.h>
7#include <sys/stat.h>
8#include <fcntl.h>
6#include "compress.h" 9#include "compress.h"
7#include "util.h" 10#include "util.h"
8#include "debug.h" 11#include "debug.h"
12#include <unistd.h>
9 13
10#define BUFSIZE 8192 14#define BUFSIZE 8192
11 15
@@ -99,3 +103,19 @@ err_fclose:
99 fclose(infile); 103 fclose(infile);
100 return err; 104 return err;
101} 105}
106
107bool 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}
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index b300a3973448..c4acd2001db0 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1212,8 +1212,10 @@ static int map_groups__set_module_path(struct map_groups *mg, const char *path,
1212 * Full name could reveal us kmod compression, so 1212 * Full name could reveal us kmod compression, so
1213 * we need to update the symtab_type if needed. 1213 * we need to update the symtab_type if needed.
1214 */ 1214 */
1215 if (m->comp && is_kmod_dso(map->dso)) 1215 if (m->comp && is_kmod_dso(map->dso)) {
1216 map->dso->symtab_type++; 1216 map->dso->symtab_type++;
1217 map->dso->comp = m->comp;
1218 }
1217 1219
1218 return 0; 1220 return 0;
1219} 1221}
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 1de7660d93e9..d856b85862e2 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -265,7 +265,7 @@ pid_t machine__get_current_tid(struct machine *machine, int cpu);
265int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid, 265int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
266 pid_t tid); 266 pid_t tid);
267/* 267/*
268 * For use with libtraceevent's pevent_set_function_resolver() 268 * For use with libtraceevent's tep_set_function_resolver()
269 */ 269 */
270char *machine__resolve_kernel_addr(void *vmachine, unsigned long long *addrp, char **modp); 270char *machine__resolve_kernel_addr(void *vmachine, unsigned long long *addrp, char **modp);
271 271
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 89ac5b5dc218..36d0763311ef 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -381,20 +381,6 @@ struct map *map__clone(struct map *from)
381 return map; 381 return map;
382} 382}
383 383
384int 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
398size_t map__fprintf(struct map *map, FILE *fp) 384size_t map__fprintf(struct map *map, FILE *fp)
399{ 385{
400 return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n", 386 return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %" PRIx64 " %s\n",
@@ -675,20 +661,42 @@ static void __map_groups__insert(struct map_groups *mg, struct map *map)
675static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp) 661static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
676{ 662{
677 struct rb_root *root; 663 struct rb_root *root;
678 struct rb_node *next; 664 struct rb_node *next, *first;
679 int err = 0; 665 int err = 0;
680 666
681 down_write(&maps->lock); 667 down_write(&maps->lock);
682 668
683 root = &maps->entries; 669 root = &maps->entries;
684 next = rb_first(root);
685 670
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;
686 while (next) { 690 while (next) {
687 struct map *pos = rb_entry(next, struct map, rb_node); 691 struct map *pos = rb_entry(next, struct map, rb_node);
688 next = rb_next(&pos->rb_node); 692 next = rb_next(&pos->rb_node);
689 693
690 if (!map__overlap(pos, map)) 694 /*
691 continue; 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;
692 700
693 if (verbose >= 2) { 701 if (verbose >= 2) {
694 702
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 4cb90f242bed..e0f327b51e66 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -166,7 +166,6 @@ static inline void __map__zput(struct map **map)
166 166
167#define map__zput(map) __map__zput(&map) 167#define map__zput(map) __map__zput(&map)
168 168
169int map__overlap(struct map *l, struct map *r);
170size_t map__fprintf(struct map *map, FILE *fp); 169size_t map__fprintf(struct map *map, FILE *fp);
171size_t map__fprintf_dsoname(struct map *map, FILE *fp); 170size_t map__fprintf_dsoname(struct map *map, FILE *fp);
172char *map__srcline(struct map *map, u64 addr, struct symbol *sym); 171char *map__srcline(struct map *map, u64 addr, struct symbol *sym);
diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
index fc832676a798..215f69f41672 100644
--- a/tools/perf/util/mmap.c
+++ b/tools/perf/util/mmap.c
@@ -164,7 +164,7 @@ void perf_mmap__munmap(struct perf_mmap *map)
164 auxtrace_mmap__munmap(&map->auxtrace_mmap); 164 auxtrace_mmap__munmap(&map->auxtrace_mmap);
165} 165}
166 166
167int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd) 167int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int cpu)
168{ 168{
169 /* 169 /*
170 * The last one will be done at perf_mmap__consume(), so that we 170 * 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)
191 return -1; 191 return -1;
192 } 192 }
193 map->fd = fd; 193 map->fd = fd;
194 map->cpu = cpu;
194 195
195 if (auxtrace_mmap__mmap(&map->auxtrace_mmap, 196 if (auxtrace_mmap__mmap(&map->auxtrace_mmap,
196 &mp->auxtrace_mp, map->base, fd)) 197 &mp->auxtrace_mp, map->base, fd))
diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h
index d82294db1295..05a6d47c7956 100644
--- a/tools/perf/util/mmap.h
+++ b/tools/perf/util/mmap.h
@@ -18,6 +18,7 @@ struct perf_mmap {
18 void *base; 18 void *base;
19 int mask; 19 int mask;
20 int fd; 20 int fd;
21 int cpu;
21 refcount_t refcnt; 22 refcount_t refcnt;
22 u64 prev; 23 u64 prev;
23 u64 start; 24 u64 start;
@@ -60,7 +61,7 @@ struct mmap_params {
60 struct auxtrace_mmap_params auxtrace_mp; 61 struct auxtrace_mmap_params auxtrace_mp;
61}; 62};
62 63
63int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd); 64int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int cpu);
64void perf_mmap__munmap(struct perf_mmap *map); 65void perf_mmap__munmap(struct perf_mmap *map);
65 66
66void perf_mmap__get(struct perf_mmap *map); 67void perf_mmap__get(struct perf_mmap *map);
diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c
index 5be021701f34..cf8bd123cf73 100644
--- a/tools/perf/util/namespaces.c
+++ b/tools/perf/util/namespaces.c
@@ -139,6 +139,9 @@ struct nsinfo *nsinfo__copy(struct nsinfo *nsi)
139{ 139{
140 struct nsinfo *nnsi; 140 struct nsinfo *nnsi;
141 141
142 if (nsi == NULL)
143 return NULL;
144
142 nnsi = calloc(1, sizeof(*nnsi)); 145 nnsi = calloc(1, sizeof(*nnsi));
143 if (nnsi != NULL) { 146 if (nnsi != NULL) {
144 nnsi->pid = nsi->pid; 147 nnsi->pid = nsi->pid;
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 15eec49e71a1..f8cd3e7c9186 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1991,8 +1991,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
1991 int nr_addr_filters = 0; 1991 int nr_addr_filters = 0;
1992 struct perf_pmu *pmu = NULL; 1992 struct perf_pmu *pmu = NULL;
1993 1993
1994 if (evsel == NULL) 1994 if (evsel == NULL) {
1995 goto err; 1995 fprintf(stderr,
1996 "--filter option should follow a -e tracepoint or HW tracer option\n");
1997 return -1;
1998 }
1996 1999
1997 if (evsel->attr.type == PERF_TYPE_TRACEPOINT) { 2000 if (evsel->attr.type == PERF_TYPE_TRACEPOINT) {
1998 if (perf_evsel__append_tp_filter(evsel, str) < 0) { 2001 if (perf_evsel__append_tp_filter(evsel, str) < 0) {
@@ -2014,8 +2017,11 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
2014 perf_pmu__scan_file(pmu, "nr_addr_filters", 2017 perf_pmu__scan_file(pmu, "nr_addr_filters",
2015 "%d", &nr_addr_filters); 2018 "%d", &nr_addr_filters);
2016 2019
2017 if (!nr_addr_filters) 2020 if (!nr_addr_filters) {
2018 goto err; 2021 fprintf(stderr,
2022 "This CPU does not support address filtering\n");
2023 return -1;
2024 }
2019 2025
2020 if (perf_evsel__append_addr_filter(evsel, str) < 0) { 2026 if (perf_evsel__append_addr_filter(evsel, str) < 0) {
2021 fprintf(stderr, 2027 fprintf(stderr,
@@ -2024,12 +2030,6 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
2024 } 2030 }
2025 2031
2026 return 0; 2032 return 0;
2027
2028err:
2029 fprintf(stderr,
2030 "--filter option should follow a -e tracepoint or HW tracer option\n");
2031
2032 return -1;
2033} 2033}
2034 2034
2035int parse_filter(const struct option *opt, const char *str, 2035int parse_filter(const struct option *opt, const char *str,
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 863b61478edd..ce501ba14b08 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -11,6 +11,7 @@
11#include "cpumap.h" 11#include "cpumap.h"
12#include "print_binary.h" 12#include "print_binary.h"
13#include "thread_map.h" 13#include "thread_map.h"
14#include "mmap.h"
14 15
15#if PY_MAJOR_VERSION < 3 16#if PY_MAJOR_VERSION < 3
16#define _PyUnicode_FromString(arg) \ 17#define _PyUnicode_FromString(arg) \
@@ -341,7 +342,7 @@ static bool is_tracepoint(struct pyrf_event *pevent)
341static PyObject* 342static PyObject*
342tracepoint_field(struct pyrf_event *pe, struct format_field *field) 343tracepoint_field(struct pyrf_event *pe, struct format_field *field)
343{ 344{
344 struct pevent *pevent = field->event->pevent; 345 struct tep_handle *pevent = field->event->pevent;
345 void *data = pe->sample.raw_data; 346 void *data = pe->sample.raw_data;
346 PyObject *ret = NULL; 347 PyObject *ret = NULL;
347 unsigned long long val; 348 unsigned long long val;
@@ -351,7 +352,7 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field)
351 offset = field->offset; 352 offset = field->offset;
352 len = field->size; 353 len = field->size;
353 if (field->flags & FIELD_IS_DYNAMIC) { 354 if (field->flags & FIELD_IS_DYNAMIC) {
354 val = pevent_read_number(pevent, data + offset, len); 355 val = tep_read_number(pevent, data + offset, len);
355 offset = val; 356 offset = val;
356 len = offset >> 16; 357 len = offset >> 16;
357 offset &= 0xffff; 358 offset &= 0xffff;
@@ -364,8 +365,8 @@ tracepoint_field(struct pyrf_event *pe, struct format_field *field)
364 field->flags &= ~FIELD_IS_STRING; 365 field->flags &= ~FIELD_IS_STRING;
365 } 366 }
366 } else { 367 } else {
367 val = pevent_read_number(pevent, data + field->offset, 368 val = tep_read_number(pevent, data + field->offset,
368 field->size); 369 field->size);
369 if (field->flags & FIELD_IS_POINTER) 370 if (field->flags & FIELD_IS_POINTER)
370 ret = PyLong_FromUnsignedLong((unsigned long) val); 371 ret = PyLong_FromUnsignedLong((unsigned long) val);
371 else if (field->flags & FIELD_IS_SIGNED) 372 else if (field->flags & FIELD_IS_SIGNED)
@@ -394,7 +395,7 @@ get_tracepoint_field(struct pyrf_event *pevent, PyObject *attr_name)
394 evsel->tp_format = tp_format; 395 evsel->tp_format = tp_format;
395 } 396 }
396 397
397 field = pevent_find_any_field(evsel->tp_format, str); 398 field = tep_find_any_field(evsel->tp_format, str);
398 if (!field) 399 if (!field)
399 return NULL; 400 return NULL;
400 401
@@ -976,6 +977,20 @@ static PyObject *pyrf_evlist__add(struct pyrf_evlist *pevlist,
976 return Py_BuildValue("i", evlist->nr_entries); 977 return Py_BuildValue("i", evlist->nr_entries);
977} 978}
978 979
980static 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
979static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, 994static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
980 PyObject *args, PyObject *kwargs) 995 PyObject *args, PyObject *kwargs)
981{ 996{
@@ -990,7 +1005,10 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist,
990 &cpu, &sample_id_all)) 1005 &cpu, &sample_id_all))
991 return NULL; 1006 return NULL;
992 1007
993 md = &evlist->mmap[cpu]; 1008 md = get_md(evlist, cpu);
1009 if (!md)
1010 return NULL;
1011
994 if (perf_mmap__read_init(md) < 0) 1012 if (perf_mmap__read_init(md) < 0)
995 goto end; 1013 goto end;
996 1014
diff --git a/tools/perf/util/s390-cpumsf-kernel.h b/tools/perf/util/s390-cpumsf-kernel.h
new file mode 100644
index 000000000000..de8c7ad0eca8
--- /dev/null
+++ b/tools/perf/util/s390-cpumsf-kernel.h
@@ -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
15struct 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
33struct 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
40struct 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
45struct 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
diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c
new file mode 100644
index 000000000000..d2c78ffd9fee
--- /dev/null
+++ b/tools/perf/util/s390-cpumsf.c
@@ -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
163struct 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
175struct 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 */
183static 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 */
204static 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 */
217static 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 */
229static 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 */
261static 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 */
306static 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 */
318static 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
379static 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
388static 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
432static 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 */
477static 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 }
543out:
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 */
570static 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
631static struct s390_cpumsf_queue *
632s390_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
646static 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
667static 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
681static 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
690static 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
733static 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
751static 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
757static int
758s390_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
789struct s390_cpumsf_synth {
790 struct perf_tool cpumsf_tool;
791 struct perf_session *session;
792};
793
794static int
795s390_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
835static void s390_cpumsf_free_events(struct perf_session *session __maybe_unused)
836{
837}
838
839static int s390_cpumsf_flush(struct perf_session *session __maybe_unused,
840 struct perf_tool *tool __maybe_unused)
841{
842 return 0;
843}
844
845static 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
858static 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
870static 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 */
883static 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
891int 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
939err_free_queues:
940 auxtrace_queues__free(&sf->queues);
941 session->auxtrace = NULL;
942err_free:
943 free(sf);
944 return err;
945}
diff --git a/tools/perf/util/s390-cpumsf.h b/tools/perf/util/s390-cpumsf.h
new file mode 100644
index 000000000000..fb64d100555c
--- /dev/null
+++ b/tools/perf/util/s390-cpumsf.h
@@ -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
12union perf_event;
13struct perf_session;
14struct perf_pmu;
15
16struct auxtrace_record *
17s390_cpumsf_recording_init(int *err, struct perf_pmu *s390_cpumsf_pmu);
18
19int s390_cpumsf_process_auxtrace_info(union perf_event *event,
20 struct perf_session *session);
21#endif
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index 7b79c413486b..45484f0f7292 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -535,7 +535,7 @@ static int perl_stop_script(void)
535 return 0; 535 return 0;
536} 536}
537 537
538static int perl_generate_script(struct pevent *pevent, const char *outfile) 538static int perl_generate_script(struct tep_handle *pevent, const char *outfile)
539{ 539{
540 struct event_format *event = NULL; 540 struct event_format *event = NULL;
541 struct format_field *f; 541 struct format_field *f;
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index bc32e57d17be..dfc6093f118c 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -871,8 +871,8 @@ static void python_process_tracepoint(struct perf_sample *sample,
871 offset = field->offset; 871 offset = field->offset;
872 len = field->size; 872 len = field->size;
873 if (field->flags & FIELD_IS_DYNAMIC) { 873 if (field->flags & FIELD_IS_DYNAMIC) {
874 val = pevent_read_number(scripting_context->pevent, 874 val = tep_read_number(scripting_context->pevent,
875 data + offset, len); 875 data + offset, len);
876 offset = val; 876 offset = val;
877 len = offset >> 16; 877 len = offset >> 16;
878 offset &= 0xffff; 878 offset &= 0xffff;
@@ -1588,7 +1588,7 @@ static int python_stop_script(void)
1588 return 0; 1588 return 0;
1589} 1589}
1590 1590
1591static int python_generate_script(struct pevent *pevent, const char *outfile) 1591static int python_generate_script(struct tep_handle *pevent, const char *outfile)
1592{ 1592{
1593 struct event_format *event = NULL; 1593 struct event_format *event = NULL;
1594 struct format_field *f; 1594 struct format_field *f;
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index 001be4f9d3b9..97efbcad076e 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -1,12 +1,20 @@
1#!/usr/bin/python 1#!/usr/bin/python
2 2
3from os import getenv 3from os import getenv
4from subprocess import Popen, PIPE
5from re import sub
6
7def clang_has_option(option):
8 return [o for o in Popen(['clang', option], stderr=PIPE).stderr.readlines() if "unknown argument" in o] == [ ]
4 9
5cc = getenv("CC") 10cc = getenv("CC")
6if cc == "clang": 11if cc == "clang":
7 from _sysconfigdata import build_time_vars 12 from _sysconfigdata import build_time_vars
8 from re import sub
9 build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", build_time_vars["CFLAGS"]) 13 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"])
10 18
11from distutils.core import setup, Extension 19from distutils.core import setup, Extension
12 20
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index fed2952ab45a..b284276ec963 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -601,7 +601,7 @@ static char *get_trace_output(struct hist_entry *he)
601{ 601{
602 struct trace_seq seq; 602 struct trace_seq seq;
603 struct perf_evsel *evsel; 603 struct perf_evsel *evsel;
604 struct pevent_record rec = { 604 struct tep_record rec = {
605 .data = he->raw_data, 605 .data = he->raw_data,
606 .size = he->raw_size, 606 .size = he->raw_size,
607 }; 607 };
@@ -610,10 +610,10 @@ static char *get_trace_output(struct hist_entry *he)
610 610
611 trace_seq_init(&seq); 611 trace_seq_init(&seq);
612 if (symbol_conf.raw_trace) { 612 if (symbol_conf.raw_trace) {
613 pevent_print_fields(&seq, he->raw_data, he->raw_size, 613 tep_print_fields(&seq, he->raw_data, he->raw_size,
614 evsel->tp_format); 614 evsel->tp_format);
615 } else { 615 } else {
616 pevent_event_info(&seq, evsel->tp_format, &rec); 616 tep_event_info(&seq, evsel->tp_format, &rec);
617 } 617 }
618 /* 618 /*
619 * Trim the buffer, it starts at 4KB and we're not going to 619 * 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,
2047 struct trace_seq seq; 2047 struct trace_seq seq;
2048raw_field: 2048raw_field:
2049 trace_seq_init(&seq); 2049 trace_seq_init(&seq);
2050 pevent_print_field(&seq, he->raw_data, hde->field); 2050 tep_print_field(&seq, he->raw_data, hde->field);
2051 str = seq.buffer; 2051 str = seq.buffer;
2052 } 2052 }
2053 2053
@@ -2074,7 +2074,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
2074 if (field->flags & FIELD_IS_DYNAMIC) { 2074 if (field->flags & FIELD_IS_DYNAMIC) {
2075 unsigned long long dyn; 2075 unsigned long long dyn;
2076 2076
2077 pevent_read_number_field(field, a->raw_data, &dyn); 2077 tep_read_number_field(field, a->raw_data, &dyn);
2078 offset = dyn & 0xffff; 2078 offset = dyn & 0xffff;
2079 size = (dyn >> 16) & 0xffff; 2079 size = (dyn >> 16) & 0xffff;
2080 2080
@@ -2311,7 +2311,7 @@ static int add_all_matching_fields(struct perf_evlist *evlist,
2311 if (evsel->attr.type != PERF_TYPE_TRACEPOINT) 2311 if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
2312 continue; 2312 continue;
2313 2313
2314 field = pevent_find_any_field(evsel->tp_format, field_name); 2314 field = tep_find_any_field(evsel->tp_format, field_name);
2315 if (field == NULL) 2315 if (field == NULL)
2316 continue; 2316 continue;
2317 2317
@@ -2378,7 +2378,7 @@ static int add_dynamic_entry(struct perf_evlist *evlist, const char *tok,
2378 if (!strcmp(field_name, "*")) { 2378 if (!strcmp(field_name, "*")) {
2379 ret = add_evsel_fields(evsel, raw_trace, level); 2379 ret = add_evsel_fields(evsel, raw_trace, level);
2380 } else { 2380 } else {
2381 field = pevent_find_any_field(evsel->tp_format, field_name); 2381 field = tep_find_any_field(evsel->tp_format, field_name);
2382 if (field == NULL) { 2382 if (field == NULL) {
2383 pr_debug("Cannot find event field for %s.%s\n", 2383 pr_debug("Cannot find event field for %s.%s\n",
2384 event_name, field_name); 2384 event_name, field_name);
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 8bf302cafcec..a97cf8e6be86 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -276,7 +276,7 @@ extern struct sort_entry sort_thread;
276extern struct list_head hist_entry__sort_list; 276extern struct list_head hist_entry__sort_list;
277 277
278struct perf_evlist; 278struct perf_evlist;
279struct pevent; 279struct tep_handle;
280int setup_sorting(struct perf_evlist *evlist); 280int setup_sorting(struct perf_evlist *evlist);
281int setup_output_field(void); 281int setup_output_field(void);
282void reset_output_field(void); 282void reset_output_field(void);
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index e0a6e9a6a053..920b1d58a068 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -32,7 +32,7 @@
32static int get_common_field(struct scripting_context *context, 32static int get_common_field(struct scripting_context *context,
33 int *offset, int *size, const char *type) 33 int *offset, int *size, const char *type)
34{ 34{
35 struct pevent *pevent = context->pevent; 35 struct tep_handle *pevent = context->pevent;
36 struct event_format *event; 36 struct event_format *event;
37 struct format_field *field; 37 struct format_field *field;
38 38
@@ -41,14 +41,14 @@ static int get_common_field(struct scripting_context *context,
41 return 0; 41 return 0;
42 42
43 event = pevent->events[0]; 43 event = pevent->events[0];
44 field = pevent_find_common_field(event, type); 44 field = tep_find_common_field(event, type);
45 if (!field) 45 if (!field)
46 return 0; 46 return 0;
47 *offset = field->offset; 47 *offset = field->offset;
48 *size = field->size; 48 *size = field->size;
49 } 49 }
50 50
51 return pevent_read_number(pevent, context->event_data + *offset, *size); 51 return tep_read_number(pevent, context->event_data + *offset, *size);
52} 52}
53 53
54int common_lock_depth(struct scripting_context *context) 54int common_lock_depth(struct scripting_context *context)
@@ -99,24 +99,24 @@ raw_field_value(struct event_format *event, const char *name, void *data)
99 struct format_field *field; 99 struct format_field *field;
100 unsigned long long val; 100 unsigned long long val;
101 101
102 field = pevent_find_any_field(event, name); 102 field = tep_find_any_field(event, name);
103 if (!field) 103 if (!field)
104 return 0ULL; 104 return 0ULL;
105 105
106 pevent_read_number_field(field, data, &val); 106 tep_read_number_field(field, data, &val);
107 107
108 return val; 108 return val;
109} 109}
110 110
111unsigned long long read_size(struct event_format *event, void *ptr, int size) 111unsigned long long read_size(struct event_format *event, void *ptr, int size)
112{ 112{
113 return pevent_read_number(event->pevent, ptr, size); 113 return tep_read_number(event->pevent, ptr, size);
114} 114}
115 115
116void event_format__fprintf(struct event_format *event, 116void event_format__fprintf(struct event_format *event,
117 int cpu, void *data, int size, FILE *fp) 117 int cpu, void *data, int size, FILE *fp)
118{ 118{
119 struct pevent_record record; 119 struct tep_record record;
120 struct trace_seq s; 120 struct trace_seq s;
121 121
122 memset(&record, 0, sizeof(record)); 122 memset(&record, 0, sizeof(record));
@@ -125,7 +125,7 @@ void event_format__fprintf(struct event_format *event,
125 record.data = data; 125 record.data = data;
126 126
127 trace_seq_init(&s); 127 trace_seq_init(&s);
128 pevent_event_info(&s, event, &record); 128 tep_event_info(&s, event, &record);
129 trace_seq_do_fprintf(&s, fp); 129 trace_seq_do_fprintf(&s, fp);
130 trace_seq_destroy(&s); 130 trace_seq_destroy(&s);
131} 131}
@@ -136,7 +136,7 @@ void event_format__print(struct event_format *event,
136 return event_format__fprintf(event, cpu, data, size, stdout); 136 return event_format__fprintf(event, cpu, data, size, stdout);
137} 137}
138 138
139void parse_ftrace_printk(struct pevent *pevent, 139void parse_ftrace_printk(struct tep_handle *pevent,
140 char *file, unsigned int size __maybe_unused) 140 char *file, unsigned int size __maybe_unused)
141{ 141{
142 unsigned long long addr; 142 unsigned long long addr;
@@ -157,11 +157,11 @@ void parse_ftrace_printk(struct pevent *pevent,
157 /* fmt still has a space, skip it */ 157 /* fmt still has a space, skip it */
158 printk = strdup(fmt+1); 158 printk = strdup(fmt+1);
159 line = strtok_r(NULL, "\n", &next); 159 line = strtok_r(NULL, "\n", &next);
160 pevent_register_print_string(pevent, printk, addr); 160 tep_register_print_string(pevent, printk, addr);
161 } 161 }
162} 162}
163 163
164void parse_saved_cmdline(struct pevent *pevent, 164void parse_saved_cmdline(struct tep_handle *pevent,
165 char *file, unsigned int size __maybe_unused) 165 char *file, unsigned int size __maybe_unused)
166{ 166{
167 char *comm; 167 char *comm;
@@ -172,24 +172,24 @@ void parse_saved_cmdline(struct pevent *pevent,
172 line = strtok_r(file, "\n", &next); 172 line = strtok_r(file, "\n", &next);
173 while (line) { 173 while (line) {
174 sscanf(line, "%d %ms", &pid, &comm); 174 sscanf(line, "%d %ms", &pid, &comm);
175 pevent_register_comm(pevent, comm, pid); 175 tep_register_comm(pevent, comm, pid);
176 free(comm); 176 free(comm);
177 line = strtok_r(NULL, "\n", &next); 177 line = strtok_r(NULL, "\n", &next);
178 } 178 }
179} 179}
180 180
181int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size) 181int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size)
182{ 182{
183 return pevent_parse_event(pevent, buf, size, "ftrace"); 183 return tep_parse_event(pevent, buf, size, "ftrace");
184} 184}
185 185
186int parse_event_file(struct pevent *pevent, 186int parse_event_file(struct tep_handle *pevent,
187 char *buf, unsigned long size, char *sys) 187 char *buf, unsigned long size, char *sys)
188{ 188{
189 return pevent_parse_event(pevent, buf, size, sys); 189 return tep_parse_event(pevent, buf, size, sys);
190} 190}
191 191
192struct event_format *trace_find_next_event(struct pevent *pevent, 192struct event_format *trace_find_next_event(struct tep_handle *pevent,
193 struct event_format *event) 193 struct event_format *event)
194{ 194{
195 static int idx; 195 static int idx;
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index 40b425949aa3..3dfc1db6b25b 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -96,7 +96,7 @@ static void skip(int size)
96 }; 96 };
97} 97}
98 98
99static unsigned int read4(struct pevent *pevent) 99static unsigned int read4(struct tep_handle *pevent)
100{ 100{
101 unsigned int data; 101 unsigned int data;
102 102
@@ -105,7 +105,7 @@ static unsigned int read4(struct pevent *pevent)
105 return __data2host4(pevent, data); 105 return __data2host4(pevent, data);
106} 106}
107 107
108static unsigned long long read8(struct pevent *pevent) 108static unsigned long long read8(struct tep_handle *pevent)
109{ 109{
110 unsigned long long data; 110 unsigned long long data;
111 111
@@ -158,7 +158,7 @@ out:
158 return str; 158 return str;
159} 159}
160 160
161static int read_proc_kallsyms(struct pevent *pevent) 161static int read_proc_kallsyms(struct tep_handle *pevent)
162{ 162{
163 unsigned int size; 163 unsigned int size;
164 164
@@ -181,7 +181,7 @@ static int read_proc_kallsyms(struct pevent *pevent)
181 return 0; 181 return 0;
182} 182}
183 183
184static int read_ftrace_printk(struct pevent *pevent) 184static int read_ftrace_printk(struct tep_handle *pevent)
185{ 185{
186 unsigned int size; 186 unsigned int size;
187 char *buf; 187 char *buf;
@@ -208,7 +208,7 @@ static int read_ftrace_printk(struct pevent *pevent)
208 return 0; 208 return 0;
209} 209}
210 210
211static int read_header_files(struct pevent *pevent) 211static int read_header_files(struct tep_handle *pevent)
212{ 212{
213 unsigned long long size; 213 unsigned long long size;
214 char *header_page; 214 char *header_page;
@@ -235,13 +235,13 @@ static int read_header_files(struct pevent *pevent)
235 return -1; 235 return -1;
236 } 236 }
237 237
238 if (!pevent_parse_header_page(pevent, header_page, size, 238 if (!tep_parse_header_page(pevent, header_page, size,
239 pevent_get_long_size(pevent))) { 239 tep_get_long_size(pevent))) {
240 /* 240 /*
241 * The commit field in the page is of type long, 241 * The commit field in the page is of type long,
242 * use that instead, since it represents the kernel. 242 * use that instead, since it represents the kernel.
243 */ 243 */
244 pevent_set_long_size(pevent, pevent->header_page_size_size); 244 tep_set_long_size(pevent, pevent->header_page_size_size);
245 } 245 }
246 free(header_page); 246 free(header_page);
247 247
@@ -259,7 +259,7 @@ static int read_header_files(struct pevent *pevent)
259 return ret; 259 return ret;
260} 260}
261 261
262static int read_ftrace_file(struct pevent *pevent, unsigned long long size) 262static int read_ftrace_file(struct tep_handle *pevent, unsigned long long size)
263{ 263{
264 int ret; 264 int ret;
265 char *buf; 265 char *buf;
@@ -284,8 +284,8 @@ out:
284 return ret; 284 return ret;
285} 285}
286 286
287static int read_event_file(struct pevent *pevent, char *sys, 287static int read_event_file(struct tep_handle *pevent, char *sys,
288 unsigned long long size) 288 unsigned long long size)
289{ 289{
290 int ret; 290 int ret;
291 char *buf; 291 char *buf;
@@ -310,7 +310,7 @@ out:
310 return ret; 310 return ret;
311} 311}
312 312
313static int read_ftrace_files(struct pevent *pevent) 313static int read_ftrace_files(struct tep_handle *pevent)
314{ 314{
315 unsigned long long size; 315 unsigned long long size;
316 int count; 316 int count;
@@ -328,7 +328,7 @@ static int read_ftrace_files(struct pevent *pevent)
328 return 0; 328 return 0;
329} 329}
330 330
331static int read_event_files(struct pevent *pevent) 331static int read_event_files(struct tep_handle *pevent)
332{ 332{
333 unsigned long long size; 333 unsigned long long size;
334 char *sys; 334 char *sys;
@@ -356,7 +356,7 @@ static int read_event_files(struct pevent *pevent)
356 return 0; 356 return 0;
357} 357}
358 358
359static int read_saved_cmdline(struct pevent *pevent) 359static int read_saved_cmdline(struct tep_handle *pevent)
360{ 360{
361 unsigned long long size; 361 unsigned long long size;
362 char *buf; 362 char *buf;
@@ -399,7 +399,7 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe)
399 int host_bigendian; 399 int host_bigendian;
400 int file_long_size; 400 int file_long_size;
401 int file_page_size; 401 int file_page_size;
402 struct pevent *pevent = NULL; 402 struct tep_handle *pevent = NULL;
403 int err; 403 int err;
404 404
405 repipe = __repipe; 405 repipe = __repipe;
@@ -439,9 +439,9 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe)
439 439
440 pevent = tevent->pevent; 440 pevent = tevent->pevent;
441 441
442 pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT); 442 tep_set_flag(pevent, TEP_NSEC_OUTPUT);
443 pevent_set_file_bigendian(pevent, file_bigendian); 443 tep_set_file_bigendian(pevent, file_bigendian);
444 pevent_set_host_bigendian(pevent, host_bigendian); 444 tep_set_host_bigendian(pevent, host_bigendian);
445 445
446 if (do_read(buf, 1) < 0) 446 if (do_read(buf, 1) < 0)
447 goto out; 447 goto out;
@@ -451,8 +451,8 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe)
451 if (!file_page_size) 451 if (!file_page_size)
452 goto out; 452 goto out;
453 453
454 pevent_set_long_size(pevent, file_long_size); 454 tep_set_long_size(pevent, file_long_size);
455 pevent_set_page_size(pevent, file_page_size); 455 tep_set_page_size(pevent, file_page_size);
456 456
457 err = read_header_files(pevent); 457 err = read_header_files(pevent);
458 if (err) 458 if (err)
@@ -479,9 +479,9 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe)
479 repipe = false; 479 repipe = false;
480 480
481 if (show_funcs) { 481 if (show_funcs) {
482 pevent_print_funcs(pevent); 482 tep_print_funcs(pevent);
483 } else if (show_printk) { 483 } else if (show_printk) {
484 pevent_print_printk(pevent); 484 tep_print_printk(pevent);
485 } 485 }
486 486
487 pevent = NULL; 487 pevent = NULL;
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
index b1e5c3a2b8e3..b749f812ac70 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -66,7 +66,7 @@ static int python_start_script_unsupported(const char *script __maybe_unused,
66 return -1; 66 return -1;
67} 67}
68 68
69static int python_generate_script_unsupported(struct pevent *pevent 69static int python_generate_script_unsupported(struct tep_handle *pevent
70 __maybe_unused, 70 __maybe_unused,
71 const char *outfile 71 const char *outfile
72 __maybe_unused) 72 __maybe_unused)
@@ -130,7 +130,7 @@ static int perl_start_script_unsupported(const char *script __maybe_unused,
130 return -1; 130 return -1;
131} 131}
132 132
133static int perl_generate_script_unsupported(struct pevent *pevent 133static int perl_generate_script_unsupported(struct tep_handle *pevent
134 __maybe_unused, 134 __maybe_unused,
135 const char *outfile __maybe_unused) 135 const char *outfile __maybe_unused)
136{ 136{
diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c
index 1aa368603268..58bb72f266f3 100644
--- a/tools/perf/util/trace-event.c
+++ b/tools/perf/util/trace-event.c
@@ -28,10 +28,10 @@ static bool tevent_initialized;
28 28
29int trace_event__init(struct trace_event *t) 29int trace_event__init(struct trace_event *t)
30{ 30{
31 struct pevent *pevent = pevent_alloc(); 31 struct tep_handle *pevent = tep_alloc();
32 32
33 if (pevent) { 33 if (pevent) {
34 t->plugin_list = traceevent_load_plugins(pevent); 34 t->plugin_list = tep_load_plugins(pevent);
35 t->pevent = pevent; 35 t->pevent = pevent;
36 } 36 }
37 37
@@ -40,33 +40,33 @@ int trace_event__init(struct trace_event *t)
40 40
41static int trace_event__init2(void) 41static int trace_event__init2(void)
42{ 42{
43 int be = traceevent_host_bigendian(); 43 int be = tep_host_bigendian();
44 struct pevent *pevent; 44 struct tep_handle *pevent;
45 45
46 if (trace_event__init(&tevent)) 46 if (trace_event__init(&tevent))
47 return -1; 47 return -1;
48 48
49 pevent = tevent.pevent; 49 pevent = tevent.pevent;
50 pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT); 50 tep_set_flag(pevent, TEP_NSEC_OUTPUT);
51 pevent_set_file_bigendian(pevent, be); 51 tep_set_file_bigendian(pevent, be);
52 pevent_set_host_bigendian(pevent, be); 52 tep_set_host_bigendian(pevent, be);
53 tevent_initialized = true; 53 tevent_initialized = true;
54 return 0; 54 return 0;
55} 55}
56 56
57int trace_event__register_resolver(struct machine *machine, 57int trace_event__register_resolver(struct machine *machine,
58 pevent_func_resolver_t *func) 58 tep_func_resolver_t *func)
59{ 59{
60 if (!tevent_initialized && trace_event__init2()) 60 if (!tevent_initialized && trace_event__init2())
61 return -1; 61 return -1;
62 62
63 return pevent_set_function_resolver(tevent.pevent, func, machine); 63 return tep_set_function_resolver(tevent.pevent, func, machine);
64} 64}
65 65
66void trace_event__cleanup(struct trace_event *t) 66void trace_event__cleanup(struct trace_event *t)
67{ 67{
68 traceevent_unload_plugins(t->plugin_list, t->pevent); 68 tep_unload_plugins(t->plugin_list, t->pevent);
69 pevent_free(t->pevent); 69 tep_free(t->pevent);
70} 70}
71 71
72/* 72/*
@@ -76,7 +76,7 @@ static struct event_format*
76tp_format(const char *sys, const char *name) 76tp_format(const char *sys, const char *name)
77{ 77{
78 char *tp_dir = get_events_file(sys); 78 char *tp_dir = get_events_file(sys);
79 struct pevent *pevent = tevent.pevent; 79 struct tep_handle *pevent = tevent.pevent;
80 struct event_format *event = NULL; 80 struct event_format *event = NULL;
81 char path[PATH_MAX]; 81 char path[PATH_MAX];
82 size_t size; 82 size_t size;
@@ -93,7 +93,7 @@ tp_format(const char *sys, const char *name)
93 if (err) 93 if (err)
94 return ERR_PTR(err); 94 return ERR_PTR(err);
95 95
96 pevent_parse_format(pevent, &event, data, size, sys); 96 tep_parse_format(pevent, &event, data, size, sys);
97 97
98 free(data); 98 free(data);
99 return event; 99 return event;
@@ -116,5 +116,5 @@ struct event_format *trace_event__tp_format_id(int id)
116 if (!tevent_initialized && trace_event__init2()) 116 if (!tevent_initialized && trace_event__init2())
117 return ERR_PTR(-ENOMEM); 117 return ERR_PTR(-ENOMEM);
118 118
119 return pevent_find_event(tevent.pevent, id); 119 return tep_find_event(tevent.pevent, id);
120} 120}
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index dcbdb53dc702..40204ec3a7a2 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -13,14 +13,14 @@ struct thread;
13struct plugin_list; 13struct plugin_list;
14 14
15struct trace_event { 15struct trace_event {
16 struct pevent *pevent; 16 struct tep_handle *pevent;
17 struct plugin_list *plugin_list; 17 struct plugin_list *plugin_list;
18}; 18};
19 19
20int trace_event__init(struct trace_event *t); 20int trace_event__init(struct trace_event *t);
21void trace_event__cleanup(struct trace_event *t); 21void trace_event__cleanup(struct trace_event *t);
22int trace_event__register_resolver(struct machine *machine, 22int trace_event__register_resolver(struct machine *machine,
23 pevent_func_resolver_t *func); 23 tep_func_resolver_t *func);
24struct event_format* 24struct event_format*
25trace_event__tp_format(const char *sys, const char *name); 25trace_event__tp_format(const char *sys, const char *name);
26 26
@@ -34,20 +34,20 @@ void event_format__fprintf(struct event_format *event,
34void event_format__print(struct event_format *event, 34void event_format__print(struct event_format *event,
35 int cpu, void *data, int size); 35 int cpu, void *data, int size);
36 36
37int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size); 37int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size);
38int parse_event_file(struct pevent *pevent, 38int parse_event_file(struct tep_handle *pevent,
39 char *buf, unsigned long size, char *sys); 39 char *buf, unsigned long size, char *sys);
40 40
41unsigned long long 41unsigned long long
42raw_field_value(struct event_format *event, const char *name, void *data); 42raw_field_value(struct event_format *event, const char *name, void *data);
43 43
44void parse_proc_kallsyms(struct pevent *pevent, char *file, unsigned int size); 44void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size);
45void parse_ftrace_printk(struct pevent *pevent, char *file, unsigned int size); 45void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size);
46void parse_saved_cmdline(struct pevent *pevent, char *file, unsigned int size); 46void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int size);
47 47
48ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe); 48ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe);
49 49
50struct event_format *trace_find_next_event(struct pevent *pevent, 50struct event_format *trace_find_next_event(struct tep_handle *pevent,
51 struct event_format *event); 51 struct event_format *event);
52unsigned long long read_size(struct event_format *event, void *ptr, int size); 52unsigned long long read_size(struct event_format *event, void *ptr, int size);
53unsigned long long eval_flag(const char *flag); 53unsigned long long eval_flag(const char *flag);
@@ -83,7 +83,7 @@ struct scripting_ops {
83 void (*process_stat)(struct perf_stat_config *config, 83 void (*process_stat)(struct perf_stat_config *config,
84 struct perf_evsel *evsel, u64 tstamp); 84 struct perf_evsel *evsel, u64 tstamp);
85 void (*process_stat_interval)(u64 tstamp); 85 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);
87}; 87};
88 88
89extern unsigned int scripting_max_stack; 89extern unsigned int scripting_max_stack;
@@ -94,7 +94,7 @@ void setup_perl_scripting(void);
94void setup_python_scripting(void); 94void setup_python_scripting(void);
95 95
96struct scripting_context { 96struct scripting_context {
97 struct pevent *pevent; 97 struct tep_handle *pevent;
98 void *event_data; 98 void *event_data;
99}; 99};
100 100
diff --git a/tools/perf/util/zlib.c b/tools/perf/util/zlib.c
index a725b958cf31..902ce6384f57 100644
--- a/tools/perf/util/zlib.c
+++ b/tools/perf/util/zlib.c
@@ -5,6 +5,8 @@
5#include <sys/stat.h> 5#include <sys/stat.h>
6#include <sys/mman.h> 6#include <sys/mman.h>
7#include <zlib.h> 7#include <zlib.h>
8#include <linux/compiler.h>
9#include <unistd.h>
8 10
9#include "util/compress.h" 11#include "util/compress.h"
10#include "util/util.h" 12#include "util/util.h"
@@ -79,3 +81,19 @@ out_close:
79 81
80 return ret == Z_STREAM_END ? 0 : -1; 82 return ret == Z_STREAM_END ? 0 : -1;
81} 83}
84
85bool 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}
diff --git a/tools/power/cpupower/po/de.po b/tools/power/cpupower/po/de.po
index 78c09e51663a..840c17cc450a 100644
--- a/tools/power/cpupower/po/de.po
+++ b/tools/power/cpupower/po/de.po
@@ -323,12 +323,12 @@ msgstr " Hardwarebedingte Grenzen der Taktfrequenz: "
323#: utils/cpufreq-info.c:256 323#: utils/cpufreq-info.c:256
324#, c-format 324#, c-format
325msgid " available frequency steps: " 325msgid " available frequency steps: "
326msgstr " mögliche Taktfrequenzen: " 326msgstr " mögliche Taktfrequenzen: "
327 327
328#: utils/cpufreq-info.c:269 328#: utils/cpufreq-info.c:269
329#, c-format 329#, c-format
330msgid " available cpufreq governors: " 330msgid " available cpufreq governors: "
331msgstr " mögliche Regler: " 331msgstr " mögliche Regler: "
332 332
333#: utils/cpufreq-info.c:280 333#: utils/cpufreq-info.c:280
334#, c-format 334#, c-format
@@ -381,7 +381,7 @@ msgstr "Optionen:\n"
381msgid " -e, --debug Prints out debug information [default]\n" 381msgid " -e, --debug Prints out debug information [default]\n"
382msgstr "" 382msgstr ""
383" -e, --debug Erzeugt detaillierte Informationen, hilfreich\n" 383" -e, --debug Erzeugt detaillierte Informationen, hilfreich\n"
384" zum Aufspüren von Fehlern\n" 384" zum Aufspüren von Fehlern\n"
385 385
386#: utils/cpufreq-info.c:475 386#: utils/cpufreq-info.c:475
387#, c-format 387#, c-format
@@ -424,7 +424,7 @@ msgstr " -p, --policy Findet die momentane Taktik heraus *\n"
424#: utils/cpufreq-info.c:482 424#: utils/cpufreq-info.c:482
425#, c-format 425#, c-format
426msgid " -g, --governors Determines available cpufreq governors *\n" 426msgid " -g, --governors Determines available cpufreq governors *\n"
427msgstr " -g, --governors Erzeugt eine Liste mit verfügbaren Reglern *\n" 427msgstr " -g, --governors Erzeugt eine Liste mit verfügbaren Reglern *\n"
428 428
429#: utils/cpufreq-info.c:483 429#: utils/cpufreq-info.c:483
430#, c-format 430#, c-format
@@ -450,7 +450,7 @@ msgstr ""
450#, c-format 450#, c-format
451msgid " -s, --stats Shows cpufreq statistics if available\n" 451msgid " -s, --stats Shows cpufreq statistics if available\n"
452msgstr "" 452msgstr ""
453" -s, --stats Zeigt, sofern möglich, Statistiken über cpufreq an.\n" 453" -s, --stats Zeigt, sofern möglich, Statistiken über cpufreq an.\n"
454 454
455#: utils/cpufreq-info.c:487 455#: utils/cpufreq-info.c:487
456#, c-format 456#, c-format
@@ -473,9 +473,9 @@ msgid ""
473"cpufreq\n" 473"cpufreq\n"
474" interface in 2.4. and early 2.6. kernels\n" 474" interface in 2.4. and early 2.6. kernels\n"
475msgstr "" 475msgstr ""
476" -o, --proc Erzeugt Informationen in einem ähnlichem Format zu " 476" -o, --proc Erzeugt Informationen in einem ähnlichem Format zu "
477"dem\n" 477"dem\n"
478" der /proc/cpufreq-Datei in 2.4. und frühen 2.6.\n" 478" der /proc/cpufreq-Datei in 2.4. und frühen 2.6.\n"
479" Kernel-Versionen\n" 479" Kernel-Versionen\n"
480 480
481#: utils/cpufreq-info.c:491 481#: utils/cpufreq-info.c:491
@@ -491,7 +491,7 @@ msgstr ""
491#: utils/cpufreq-info.c:492 utils/cpuidle-info.c:152 491#: utils/cpufreq-info.c:492 utils/cpuidle-info.c:152
492#, c-format 492#, c-format
493msgid " -h, --help Prints out this screen\n" 493msgid " -h, --help Prints out this screen\n"
494msgstr " -h, --help Gibt diese Kurzübersicht aus\n" 494msgstr " -h, --help Gibt diese Kurzübersicht aus\n"
495 495
496#: utils/cpufreq-info.c:495 496#: utils/cpufreq-info.c:495
497#, c-format 497#, c-format
@@ -501,7 +501,7 @@ msgid ""
501msgstr "" 501msgstr ""
502"Sofern kein anderer Parameter als '-c, --cpu' angegeben wird, liefert " 502"Sofern kein anderer Parameter als '-c, --cpu' angegeben wird, liefert "
503"dieses\n" 503"dieses\n"
504"Programm Informationen, die z.B. zum Berichten von Fehlern nützlich sind.\n" 504"Programm Informationen, die z.B. zum Berichten von Fehlern nützlich sind.\n"
505 505
506#: utils/cpufreq-info.c:497 506#: utils/cpufreq-info.c:497
507#, c-format 507#, c-format
@@ -557,7 +557,7 @@ msgid ""
557"select\n" 557"select\n"
558msgstr "" 558msgstr ""
559" -d FREQ, --min FREQ neue minimale Taktfrequenz, die der Regler\n" 559" -d FREQ, --min FREQ neue minimale Taktfrequenz, die der Regler\n"
560" auswählen darf\n" 560" auswählen darf\n"
561 561
562#: utils/cpufreq-set.c:28 562#: utils/cpufreq-set.c:28
563#, c-format 563#, c-format
@@ -566,7 +566,7 @@ msgid ""
566"select\n" 566"select\n"
567msgstr "" 567msgstr ""
568" -u FREQ, --max FREQ neue maximale Taktfrequenz, die der Regler\n" 568" -u FREQ, --max FREQ neue maximale Taktfrequenz, die der Regler\n"
569" auswählen darf\n" 569" auswählen darf\n"
570 570
571#: utils/cpufreq-set.c:29 571#: utils/cpufreq-set.c:29
572#, c-format 572#, c-format
@@ -579,20 +579,20 @@ msgid ""
579" -f FREQ, --freq FREQ specific frequency to be set. Requires userspace\n" 579" -f FREQ, --freq FREQ specific frequency to be set. Requires userspace\n"
580" governor to be available and loaded\n" 580" governor to be available and loaded\n"
581msgstr "" 581msgstr ""
582" -f FREQ, --freq FREQ setze exakte Taktfrequenz. Benötigt den Regler\n" 582" -f FREQ, --freq FREQ setze exakte Taktfrequenz. Benötigt den Regler\n"
583" 'userspace'.\n" 583" 'userspace'.\n"
584 584
585#: utils/cpufreq-set.c:32 585#: utils/cpufreq-set.c:32
586#, c-format 586#, c-format
587msgid " -r, --related Switches all hardware-related CPUs\n" 587msgid " -r, --related Switches all hardware-related CPUs\n"
588msgstr "" 588msgstr ""
589" -r, --related Setze Werte für alle CPUs, deren Taktfrequenz\n" 589" -r, --related Setze Werte für alle CPUs, deren Taktfrequenz\n"
590" hardwarebedingt identisch ist.\n" 590" hardwarebedingt identisch ist.\n"
591 591
592#: utils/cpufreq-set.c:33 utils/cpupower-set.c:28 utils/cpupower-info.c:27 592#: utils/cpufreq-set.c:33 utils/cpupower-set.c:28 utils/cpupower-info.c:27
593#, c-format 593#, c-format
594msgid " -h, --help Prints out this screen\n" 594msgid " -h, --help Prints out this screen\n"
595msgstr " -h, --help Gibt diese Kurzübersicht aus\n" 595msgstr " -h, --help Gibt diese Kurzübersicht aus\n"
596 596
597#: utils/cpufreq-set.c:35 597#: utils/cpufreq-set.c:35
598#, fuzzy, c-format 598#, fuzzy, c-format
@@ -618,8 +618,8 @@ msgstr ""
618" angenommen\n" 618" angenommen\n"
619"2. Der Parameter -f bzw. --freq kann mit keinem anderen als dem Parameter\n" 619"2. Der Parameter -f bzw. --freq kann mit keinem anderen als dem Parameter\n"
620" -c bzw. --cpu kombiniert werden\n" 620" -c bzw. --cpu kombiniert werden\n"
621"3. FREQuenzen können in Hz, kHz (Standard), MHz, GHz oder THz eingegeben\n" 621"3. FREQuenzen können in Hz, kHz (Standard), MHz, GHz oder THz eingegeben\n"
622" werden, indem der Wert und unmittelbar anschließend (ohne Leerzeichen!)\n" 622" werden, indem der Wert und unmittelbar anschließend (ohne Leerzeichen!)\n"
623" die Einheit angegeben werden. (Bsp: 1GHz )\n" 623" die Einheit angegeben werden. (Bsp: 1GHz )\n"
624" (FREQuenz in kHz =^ MHz * 1000 =^ GHz * 1000000).\n" 624" (FREQuenz in kHz =^ MHz * 1000 =^ GHz * 1000000).\n"
625 625
@@ -638,7 +638,7 @@ msgid ""
638msgstr "" 638msgstr ""
639"Beim Einstellen ist ein Fehler aufgetreten. Typische Fehlerquellen sind:\n" 639"Beim Einstellen ist ein Fehler aufgetreten. Typische Fehlerquellen sind:\n"
640"- nicht ausreichende Rechte (Administrator)\n" 640"- nicht ausreichende Rechte (Administrator)\n"
641"- der Regler ist nicht verfügbar bzw. nicht geladen\n" 641"- der Regler ist nicht verfügbar bzw. nicht geladen\n"
642"- die angegebene Taktik ist inkorrekt\n" 642"- die angegebene Taktik ist inkorrekt\n"
643"- eine spezifische Frequenz wurde angegeben, aber der Regler 'userspace'\n" 643"- eine spezifische Frequenz wurde angegeben, aber der Regler 'userspace'\n"
644" kann entweder hardwarebedingt nicht genutzt werden oder ist nicht geladen\n" 644" kann entweder hardwarebedingt nicht genutzt werden oder ist nicht geladen\n"
@@ -821,7 +821,7 @@ msgstr ""
821#: utils/cpuidle-info.c:48 821#: utils/cpuidle-info.c:48
822#, fuzzy, c-format 822#, fuzzy, c-format
823msgid "Available idle states:" 823msgid "Available idle states:"
824msgstr " mögliche Taktfrequenzen: " 824msgstr " mögliche Taktfrequenzen: "
825 825
826#: utils/cpuidle-info.c:71 826#: utils/cpuidle-info.c:71
827#, c-format 827#, c-format
@@ -924,7 +924,7 @@ msgstr "Aufruf: cpufreq-info [Optionen]\n"
924msgid " -s, --silent Only show general C-state information\n" 924msgid " -s, --silent Only show general C-state information\n"
925msgstr "" 925msgstr ""
926" -e, --debug Erzeugt detaillierte Informationen, hilfreich\n" 926" -e, --debug Erzeugt detaillierte Informationen, hilfreich\n"
927" zum Aufspüren von Fehlern\n" 927" zum Aufspüren von Fehlern\n"
928 928
929#: utils/cpuidle-info.c:150 929#: utils/cpuidle-info.c:150
930#, fuzzy, c-format 930#, fuzzy, c-format
@@ -933,9 +933,9 @@ msgid ""
933"acpi/processor/*/power\n" 933"acpi/processor/*/power\n"
934" interface in older kernels\n" 934" interface in older kernels\n"
935msgstr "" 935msgstr ""
936" -o, --proc Erzeugt Informationen in einem ähnlichem Format zu " 936" -o, --proc Erzeugt Informationen in einem ähnlichem Format zu "
937"dem\n" 937"dem\n"
938" der /proc/cpufreq-Datei in 2.4. und frühen 2.6.\n" 938" der /proc/cpufreq-Datei in 2.4. und frühen 2.6.\n"
939" Kernel-Versionen\n" 939" Kernel-Versionen\n"
940 940
941#: utils/cpuidle-info.c:209 941#: utils/cpuidle-info.c:209
@@ -949,7 +949,7 @@ msgstr ""
949#~ " -c CPU, --cpu CPU CPU number which information shall be determined " 949#~ " -c CPU, --cpu CPU CPU number which information shall be determined "
950#~ "about\n" 950#~ "about\n"
951#~ msgstr "" 951#~ msgstr ""
952#~ " -c CPU, --cpu CPU Nummer der CPU, über die Informationen " 952#~ " -c CPU, --cpu CPU Nummer der CPU, über die Informationen "
953#~ "herausgefunden werden sollen\n" 953#~ "herausgefunden werden sollen\n"
954 954
955#~ msgid "" 955#~ msgid ""
diff --git a/tools/power/cpupower/po/fr.po b/tools/power/cpupower/po/fr.po
index 245ad20a9bf9..b46ca2548f86 100644
--- a/tools/power/cpupower/po/fr.po
+++ b/tools/power/cpupower/po/fr.po
@@ -212,7 +212,7 @@ msgstr ""
212#: utils/cpupower.c:91 212#: utils/cpupower.c:91
213#, c-format 213#, c-format
214msgid "Report errors and bugs to %s, please.\n" 214msgid "Report errors and bugs to %s, please.\n"
215msgstr "Veuillez rapportez les erreurs et les bogues à %s, s'il vous plait.\n" 215msgstr "Veuillez rapportez les erreurs et les bogues à %s, s'il vous plait.\n"
216 216
217#: utils/cpupower.c:114 217#: utils/cpupower.c:114
218#, c-format 218#, c-format
@@ -227,14 +227,14 @@ msgstr ""
227#: utils/cpufreq-info.c:31 227#: utils/cpufreq-info.c:31
228#, c-format 228#, c-format
229msgid "Couldn't count the number of CPUs (%s: %s), assuming 1\n" 229msgid "Couldn't count the number of CPUs (%s: %s), assuming 1\n"
230msgstr "Détermination du nombre de CPUs (%s : %s) impossible. Assume 1\n" 230msgstr "Détermination du nombre de CPUs (%s : %s) impossible. Assume 1\n"
231 231
232#: utils/cpufreq-info.c:63 232#: utils/cpufreq-info.c:63
233#, c-format 233#, c-format
234msgid "" 234msgid ""
235" minimum CPU frequency - maximum CPU frequency - governor\n" 235" minimum CPU frequency - maximum CPU frequency - governor\n"
236msgstr "" 236msgstr ""
237" Fréquence CPU minimale - Fréquence CPU maximale - régulateur\n" 237" Fréquence CPU minimale - Fréquence CPU maximale - régulateur\n"
238 238
239#: utils/cpufreq-info.c:151 239#: utils/cpufreq-info.c:151
240#, c-format 240#, c-format
@@ -302,12 +302,12 @@ msgstr " pilote : %s\n"
302#: utils/cpufreq-info.c:219 302#: utils/cpufreq-info.c:219
303#, fuzzy, c-format 303#, fuzzy, c-format
304msgid " CPUs which run at the same hardware frequency: " 304msgid " CPUs which run at the same hardware frequency: "
305msgstr " CPUs qui doivent changer de fréquences en même temps : " 305msgstr " CPUs qui doivent changer de fréquences en même temps : "
306 306
307#: utils/cpufreq-info.c:230 307#: utils/cpufreq-info.c:230
308#, fuzzy, c-format 308#, fuzzy, c-format
309msgid " CPUs which need to have their frequency coordinated by software: " 309msgid " CPUs which need to have their frequency coordinated by software: "
310msgstr " CPUs qui doivent changer de fréquences en même temps : " 310msgstr " CPUs qui doivent changer de fréquences en même temps : "
311 311
312#: utils/cpufreq-info.c:241 312#: utils/cpufreq-info.c:241
313#, c-format 313#, c-format
@@ -317,22 +317,22 @@ msgstr ""
317#: utils/cpufreq-info.c:247 317#: utils/cpufreq-info.c:247
318#, c-format 318#, c-format
319msgid " hardware limits: " 319msgid " hardware limits: "
320msgstr " limitation matérielle : " 320msgstr " limitation matérielle : "
321 321
322#: utils/cpufreq-info.c:256 322#: utils/cpufreq-info.c:256
323#, c-format 323#, c-format
324msgid " available frequency steps: " 324msgid " available frequency steps: "
325msgstr " plage de fréquence : " 325msgstr " plage de fréquence : "
326 326
327#: utils/cpufreq-info.c:269 327#: utils/cpufreq-info.c:269
328#, c-format 328#, c-format
329msgid " available cpufreq governors: " 329msgid " available cpufreq governors: "
330msgstr " régulateurs disponibles : " 330msgstr " régulateurs disponibles : "
331 331
332#: utils/cpufreq-info.c:280 332#: utils/cpufreq-info.c:280
333#, c-format 333#, c-format
334msgid " current policy: frequency should be within " 334msgid " current policy: frequency should be within "
335msgstr " tactique actuelle : la fréquence doit être comprise entre " 335msgstr " tactique actuelle : la fréquence doit être comprise entre "
336 336
337#: utils/cpufreq-info.c:282 337#: utils/cpufreq-info.c:282
338#, c-format 338#, c-format
@@ -345,18 +345,18 @@ msgid ""
345"The governor \"%s\" may decide which speed to use\n" 345"The governor \"%s\" may decide which speed to use\n"
346" within this range.\n" 346" within this range.\n"
347msgstr "" 347msgstr ""
348"Le régulateur \"%s\" est libre de choisir la vitesse\n" 348"Le régulateur \"%s\" est libre de choisir la vitesse\n"
349" dans cette plage de fréquences.\n" 349" dans cette plage de fréquences.\n"
350 350
351#: utils/cpufreq-info.c:293 351#: utils/cpufreq-info.c:293
352#, c-format 352#, c-format
353msgid " current CPU frequency is " 353msgid " current CPU frequency is "
354msgstr " la fréquence actuelle de ce CPU est " 354msgstr " la fréquence actuelle de ce CPU est "
355 355
356#: utils/cpufreq-info.c:296 356#: utils/cpufreq-info.c:296
357#, c-format 357#, c-format
358msgid " (asserted by call to hardware)" 358msgid " (asserted by call to hardware)"
359msgstr " (vérifié par un appel direct du matériel)" 359msgstr " (vérifié par un appel direct du matériel)"
360 360
361#: utils/cpufreq-info.c:304 361#: utils/cpufreq-info.c:304
362#, c-format 362#, c-format
@@ -377,7 +377,7 @@ msgstr "Options :\n"
377#: utils/cpufreq-info.c:474 377#: utils/cpufreq-info.c:474
378#, fuzzy, c-format 378#, fuzzy, c-format
379msgid " -e, --debug Prints out debug information [default]\n" 379msgid " -e, --debug Prints out debug information [default]\n"
380msgstr " -e, --debug Afficher les informations de déboguage\n" 380msgstr " -e, --debug Afficher les informations de déboguage\n"
381 381
382#: utils/cpufreq-info.c:475 382#: utils/cpufreq-info.c:475
383#, c-format 383#, c-format
@@ -385,8 +385,8 @@ msgid ""
385" -f, --freq Get frequency the CPU currently runs at, according\n" 385" -f, --freq Get frequency the CPU currently runs at, according\n"
386" to the cpufreq core *\n" 386" to the cpufreq core *\n"
387msgstr "" 387msgstr ""
388" -f, --freq Obtenir la fréquence actuelle du CPU selon le point\n" 388" -f, --freq Obtenir la fréquence actuelle du CPU selon le point\n"
389" de vue du coeur du système de cpufreq *\n" 389" de vue du coeur du système de cpufreq *\n"
390 390
391#: utils/cpufreq-info.c:477 391#: utils/cpufreq-info.c:477
392#, c-format 392#, c-format
@@ -394,8 +394,8 @@ msgid ""
394" -w, --hwfreq Get frequency the CPU currently runs at, by reading\n" 394" -w, --hwfreq Get frequency the CPU currently runs at, by reading\n"
395" it from hardware (only available to root) *\n" 395" it from hardware (only available to root) *\n"
396msgstr "" 396msgstr ""
397" -w, --hwfreq Obtenir la fréquence actuelle du CPU directement par\n" 397" -w, --hwfreq Obtenir la fréquence actuelle du CPU directement par\n"
398" le matériel (doit être root) *\n" 398" le matériel (doit être root) *\n"
399 399
400#: utils/cpufreq-info.c:479 400#: utils/cpufreq-info.c:479
401#, c-format 401#, c-format
@@ -403,13 +403,13 @@ msgid ""
403" -l, --hwlimits Determine the minimum and maximum CPU frequency " 403" -l, --hwlimits Determine the minimum and maximum CPU frequency "
404"allowed *\n" 404"allowed *\n"
405msgstr "" 405msgstr ""
406" -l, --hwlimits Affiche les fréquences minimales et maximales du CPU " 406" -l, --hwlimits Affiche les fréquences minimales et maximales du CPU "
407"*\n" 407"*\n"
408 408
409#: utils/cpufreq-info.c:480 409#: utils/cpufreq-info.c:480
410#, c-format 410#, c-format
411msgid " -d, --driver Determines the used cpufreq kernel driver *\n" 411msgid " -d, --driver Determines the used cpufreq kernel driver *\n"
412msgstr " -d, --driver Affiche le pilote cpufreq utilisé *\n" 412msgstr " -d, --driver Affiche le pilote cpufreq utilisé *\n"
413 413
414#: utils/cpufreq-info.c:481 414#: utils/cpufreq-info.c:481
415#, c-format 415#, c-format
@@ -420,7 +420,7 @@ msgstr " -p, --policy Affiche la tactique actuelle de cpufreq *\n"
420#, c-format 420#, c-format
421msgid " -g, --governors Determines available cpufreq governors *\n" 421msgid " -g, --governors Determines available cpufreq governors *\n"
422msgstr "" 422msgstr ""
423" -g, --governors Affiche les régulateurs disponibles de cpufreq *\n" 423" -g, --governors Affiche les régulateurs disponibles de cpufreq *\n"
424 424
425#: utils/cpufreq-info.c:483 425#: utils/cpufreq-info.c:483
426#, fuzzy, c-format 426#, fuzzy, c-format
@@ -429,7 +429,7 @@ msgid ""
429"frequency *\n" 429"frequency *\n"
430msgstr "" 430msgstr ""
431" -a, --affected-cpus Affiche quels sont les CPUs qui doivent changer de\n" 431" -a, --affected-cpus Affiche quels sont les CPUs qui doivent changer de\n"
432" fréquences en même temps *\n" 432" fréquences en même temps *\n"
433 433
434#: utils/cpufreq-info.c:484 434#: utils/cpufreq-info.c:484
435#, fuzzy, c-format 435#, fuzzy, c-format
@@ -438,7 +438,7 @@ msgid ""
438" coordinated by software *\n" 438" coordinated by software *\n"
439msgstr "" 439msgstr ""
440" -a, --affected-cpus Affiche quels sont les CPUs qui doivent changer de\n" 440" -a, --affected-cpus Affiche quels sont les CPUs qui doivent changer de\n"
441" fréquences en même temps *\n" 441" fréquences en même temps *\n"
442 442
443#: utils/cpufreq-info.c:486 443#: utils/cpufreq-info.c:486
444#, c-format 444#, c-format
@@ -453,7 +453,7 @@ msgid ""
453" -y, --latency Determines the maximum latency on CPU frequency " 453" -y, --latency Determines the maximum latency on CPU frequency "
454"changes *\n" 454"changes *\n"
455msgstr "" 455msgstr ""
456" -l, --hwlimits Affiche les fréquences minimales et maximales du CPU " 456" -l, --hwlimits Affiche les fréquences minimales et maximales du CPU "
457"*\n" 457"*\n"
458 458
459#: utils/cpufreq-info.c:488 459#: utils/cpufreq-info.c:488
@@ -469,7 +469,7 @@ msgid ""
469" interface in 2.4. and early 2.6. kernels\n" 469" interface in 2.4. and early 2.6. kernels\n"
470msgstr "" 470msgstr ""
471" -o, --proc Affiche les informations en utilisant l'interface\n" 471" -o, --proc Affiche les informations en utilisant l'interface\n"
472" fournie par /proc/cpufreq, présente dans les " 472" fournie par /proc/cpufreq, présente dans les "
473"versions\n" 473"versions\n"
474" 2.4 et les anciennes versions 2.6 du noyau\n" 474" 2.4 et les anciennes versions 2.6 du noyau\n"
475 475
@@ -485,7 +485,7 @@ msgstr ""
485#: utils/cpufreq-info.c:492 utils/cpuidle-info.c:152 485#: utils/cpufreq-info.c:492 utils/cpuidle-info.c:152
486#, c-format 486#, c-format
487msgid " -h, --help Prints out this screen\n" 487msgid " -h, --help Prints out this screen\n"
488msgstr " -h, --help affiche l'aide-mémoire\n" 488msgstr " -h, --help affiche l'aide-mémoire\n"
489 489
490#: utils/cpufreq-info.c:495 490#: utils/cpufreq-info.c:495
491#, c-format 491#, c-format
@@ -493,8 +493,8 @@ msgid ""
493"If no argument or only the -c, --cpu parameter is given, debug output about\n" 493"If no argument or only the -c, --cpu parameter is given, debug output about\n"
494"cpufreq is printed which is useful e.g. for reporting bugs.\n" 494"cpufreq is printed which is useful e.g. for reporting bugs.\n"
495msgstr "" 495msgstr ""
496"Par défaut, les informations de déboguage seront affichées si aucun\n" 496"Par défaut, les informations de déboguage seront affichées si aucun\n"
497"argument, ou bien si seulement l'argument -c (--cpu) est donné, afin de\n" 497"argument, ou bien si seulement l'argument -c (--cpu) est donné, afin de\n"
498"faciliter les rapports de bogues par exemple\n" 498"faciliter les rapports de bogues par exemple\n"
499 499
500#: utils/cpufreq-info.c:497 500#: utils/cpufreq-info.c:497
@@ -517,8 +517,8 @@ msgid ""
517"You can't specify more than one --cpu parameter and/or\n" 517"You can't specify more than one --cpu parameter and/or\n"
518"more than one output-specific argument\n" 518"more than one output-specific argument\n"
519msgstr "" 519msgstr ""
520"On ne peut indiquer plus d'un paramètre --cpu, tout comme l'on ne peut\n" 520"On ne peut indiquer plus d'un paramètre --cpu, tout comme l'on ne peut\n"
521"spécifier plus d'un argument de formatage\n" 521"spécifier plus d'un argument de formatage\n"
522 522
523#: utils/cpufreq-info.c:600 utils/cpufreq-set.c:82 utils/cpupower-set.c:42 523#: utils/cpufreq-info.c:600 utils/cpufreq-set.c:82 utils/cpupower-set.c:42
524#: utils/cpupower-info.c:42 utils/cpuidle-info.c:213 524#: utils/cpupower-info.c:42 utils/cpuidle-info.c:213
@@ -529,7 +529,7 @@ msgstr "option invalide\n"
529#: utils/cpufreq-info.c:617 529#: utils/cpufreq-info.c:617
530#, c-format 530#, c-format
531msgid "couldn't analyze CPU %d as it doesn't seem to be present\n" 531msgid "couldn't analyze CPU %d as it doesn't seem to be present\n"
532msgstr "analyse du CPU %d impossible puisqu'il ne semble pas être présent\n" 532msgstr "analyse du CPU %d impossible puisqu'il ne semble pas être présent\n"
533 533
534#: utils/cpufreq-info.c:620 utils/cpupower-info.c:142 534#: utils/cpufreq-info.c:620 utils/cpupower-info.c:142
535#, c-format 535#, c-format
@@ -547,8 +547,8 @@ msgid ""
547" -d FREQ, --min FREQ new minimum CPU frequency the governor may " 547" -d FREQ, --min FREQ new minimum CPU frequency the governor may "
548"select\n" 548"select\n"
549msgstr "" 549msgstr ""
550" -d FREQ, --min FREQ nouvelle fréquence minimale du CPU à utiliser\n" 550" -d FREQ, --min FREQ nouvelle fréquence minimale du CPU à utiliser\n"
551" par le régulateur\n" 551" par le régulateur\n"
552 552
553#: utils/cpufreq-set.c:28 553#: utils/cpufreq-set.c:28
554#, c-format 554#, c-format
@@ -556,13 +556,13 @@ msgid ""
556" -u FREQ, --max FREQ new maximum CPU frequency the governor may " 556" -u FREQ, --max FREQ new maximum CPU frequency the governor may "
557"select\n" 557"select\n"
558msgstr "" 558msgstr ""
559" -u FREQ, --max FREQ nouvelle fréquence maximale du CPU à utiliser\n" 559" -u FREQ, --max FREQ nouvelle fréquence maximale du CPU à utiliser\n"
560" par le régulateur\n" 560" par le régulateur\n"
561 561
562#: utils/cpufreq-set.c:29 562#: utils/cpufreq-set.c:29
563#, c-format 563#, c-format
564msgid " -g GOV, --governor GOV new cpufreq governor\n" 564msgid " -g GOV, --governor GOV new cpufreq governor\n"
565msgstr " -g GOV, --governor GOV active le régulateur GOV\n" 565msgstr " -g GOV, --governor GOV active le régulateur GOV\n"
566 566
567#: utils/cpufreq-set.c:30 567#: utils/cpufreq-set.c:30
568#, c-format 568#, c-format
@@ -570,9 +570,9 @@ msgid ""
570" -f FREQ, --freq FREQ specific frequency to be set. Requires userspace\n" 570" -f FREQ, --freq FREQ specific frequency to be set. Requires userspace\n"
571" governor to be available and loaded\n" 571" governor to be available and loaded\n"
572msgstr "" 572msgstr ""
573" -f FREQ, --freq FREQ fixe la fréquence du processeur à FREQ. Il faut\n" 573" -f FREQ, --freq FREQ fixe la fréquence du processeur à FREQ. Il faut\n"
574" que le régulateur « userspace » soit disponible \n" 574" que le régulateur « userspace » soit disponible \n"
575" et activé.\n" 575" et activé.\n"
576 576
577#: utils/cpufreq-set.c:32 577#: utils/cpufreq-set.c:32
578#, c-format 578#, c-format
@@ -582,7 +582,7 @@ msgstr ""
582#: utils/cpufreq-set.c:33 utils/cpupower-set.c:28 utils/cpupower-info.c:27 582#: utils/cpufreq-set.c:33 utils/cpupower-set.c:28 utils/cpupower-info.c:27
583#, fuzzy, c-format 583#, fuzzy, c-format
584msgid " -h, --help Prints out this screen\n" 584msgid " -h, --help Prints out this screen\n"
585msgstr " -h, --help affiche l'aide-mémoire\n" 585msgstr " -h, --help affiche l'aide-mémoire\n"
586 586
587#: utils/cpufreq-set.c:35 587#: utils/cpufreq-set.c:35
588#, fuzzy, c-format 588#, fuzzy, c-format
@@ -602,11 +602,11 @@ msgid ""
602" (FREQuency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n" 602" (FREQuency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"
603msgstr "" 603msgstr ""
604"Remarque :\n" 604"Remarque :\n"
605"1. Le CPU numéro 0 sera utilisé par défaut si -c (ou --cpu) est omis ;\n" 605"1. Le CPU numéro 0 sera utilisé par défaut si -c (ou --cpu) est omis ;\n"
606"2. l'argument -f FREQ (ou --freq FREQ) ne peut être utilisé qu'avec --cpu ;\n" 606"2. l'argument -f FREQ (ou --freq FREQ) ne peut être utilisé qu'avec --cpu ;\n"
607"3. on pourra préciser l'unité des fréquences en postfixant sans aucune " 607"3. on pourra préciser l'unité des fréquences en postfixant sans aucune "
608"espace\n" 608"espace\n"
609" les valeurs par hz, kHz (par défaut), MHz, GHz ou THz\n" 609" les valeurs par hz, kHz (par défaut), MHz, GHz ou THz\n"
610" (kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n" 610" (kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).\n"
611 611
612#: utils/cpufreq-set.c:57 612#: utils/cpufreq-set.c:57
@@ -622,21 +622,21 @@ msgid ""
622"frequency\n" 622"frequency\n"
623" or because the userspace governor isn't loaded?\n" 623" or because the userspace governor isn't loaded?\n"
624msgstr "" 624msgstr ""
625"En ajustant les nouveaux paramètres, une erreur est apparue. Les sources\n" 625"En ajustant les nouveaux paramètres, une erreur est apparue. Les sources\n"
626"d'erreur typique sont :\n" 626"d'erreur typique sont :\n"
627"- droit d'administration insuffisant (êtes-vous root ?) ;\n" 627"- droit d'administration insuffisant (êtes-vous root ?) ;\n"
628"- le régulateur choisi n'est pas disponible, ou bien n'est pas disponible " 628"- le régulateur choisi n'est pas disponible, ou bien n'est pas disponible "
629"en\n" 629"en\n"
630" tant que module noyau ;\n" 630" tant que module noyau ;\n"
631"- la tactique n'est pas disponible ;\n" 631"- la tactique n'est pas disponible ;\n"
632"- vous voulez utiliser l'option -f/--freq, mais le régulateur « userspace »\n" 632"- vous voulez utiliser l'option -f/--freq, mais le régulateur « userspace »\n"
633" n'est pas disponible, par exemple parce que le matériel ne le supporte\n" 633" n'est pas disponible, par exemple parce que le matériel ne le supporte\n"
634" pas, ou bien n'est tout simplement pas chargé.\n" 634" pas, ou bien n'est tout simplement pas chargé.\n"
635 635
636#: utils/cpufreq-set.c:170 636#: utils/cpufreq-set.c:170
637#, c-format 637#, c-format
638msgid "wrong, unknown or unhandled CPU?\n" 638msgid "wrong, unknown or unhandled CPU?\n"
639msgstr "CPU inconnu ou non supporté ?\n" 639msgstr "CPU inconnu ou non supporté ?\n"
640 640
641#: utils/cpufreq-set.c:302 641#: utils/cpufreq-set.c:302
642#, c-format 642#, c-format
@@ -653,7 +653,7 @@ msgid ""
653"At least one parameter out of -f/--freq, -d/--min, -u/--max, and\n" 653"At least one parameter out of -f/--freq, -d/--min, -u/--max, and\n"
654"-g/--governor must be passed\n" 654"-g/--governor must be passed\n"
655msgstr "" 655msgstr ""
656"L'un de ces paramètres est obligatoire : -f/--freq, -d/--min, -u/--max et\n" 656"L'un de ces paramètres est obligatoire : -f/--freq, -d/--min, -u/--max et\n"
657"-g/--governor\n" 657"-g/--governor\n"
658 658
659#: utils/cpufreq-set.c:347 659#: utils/cpufreq-set.c:347
@@ -810,7 +810,7 @@ msgstr ""
810#: utils/cpuidle-info.c:48 810#: utils/cpuidle-info.c:48
811#, fuzzy, c-format 811#, fuzzy, c-format
812msgid "Available idle states:" 812msgid "Available idle states:"
813msgstr " plage de fréquence : " 813msgstr " plage de fréquence : "
814 814
815#: utils/cpuidle-info.c:71 815#: utils/cpuidle-info.c:71
816#, c-format 816#, c-format
@@ -911,7 +911,7 @@ msgstr "Usage : cpufreq-info [options]\n"
911#: utils/cpuidle-info.c:149 911#: utils/cpuidle-info.c:149
912#, fuzzy, c-format 912#, fuzzy, c-format
913msgid " -s, --silent Only show general C-state information\n" 913msgid " -s, --silent Only show general C-state information\n"
914msgstr " -e, --debug Afficher les informations de déboguage\n" 914msgstr " -e, --debug Afficher les informations de déboguage\n"
915 915
916#: utils/cpuidle-info.c:150 916#: utils/cpuidle-info.c:150
917#, fuzzy, c-format 917#, fuzzy, c-format
@@ -921,7 +921,7 @@ msgid ""
921" interface in older kernels\n" 921" interface in older kernels\n"
922msgstr "" 922msgstr ""
923" -o, --proc Affiche les informations en utilisant l'interface\n" 923" -o, --proc Affiche les informations en utilisant l'interface\n"
924" fournie par /proc/cpufreq, présente dans les " 924" fournie par /proc/cpufreq, présente dans les "
925"versions\n" 925"versions\n"
926" 2.4 et les anciennes versions 2.6 du noyau\n" 926" 2.4 et les anciennes versions 2.6 du noyau\n"
927 927
@@ -929,19 +929,19 @@ msgstr ""
929#, fuzzy, c-format 929#, fuzzy, c-format
930msgid "You can't specify more than one output-specific argument\n" 930msgid "You can't specify more than one output-specific argument\n"
931msgstr "" 931msgstr ""
932"On ne peut indiquer plus d'un paramètre --cpu, tout comme l'on ne peut\n" 932"On ne peut indiquer plus d'un paramètre --cpu, tout comme l'on ne peut\n"
933"spécifier plus d'un argument de formatage\n" 933"spécifier plus d'un argument de formatage\n"
934 934
935#~ msgid "" 935#~ msgid ""
936#~ " -c CPU, --cpu CPU CPU number which information shall be determined " 936#~ " -c CPU, --cpu CPU CPU number which information shall be determined "
937#~ "about\n" 937#~ "about\n"
938#~ msgstr "" 938#~ msgstr ""
939#~ " -c CPU, --cpu CPU Numéro du CPU pour lequel l'information sera " 939#~ " -c CPU, --cpu CPU Numéro du CPU pour lequel l'information sera "
940#~ "affichée\n" 940#~ "affichée\n"
941 941
942#~ msgid "" 942#~ msgid ""
943#~ " -c CPU, --cpu CPU number of CPU where cpufreq settings shall be " 943#~ " -c CPU, --cpu CPU number of CPU where cpufreq settings shall be "
944#~ "modified\n" 944#~ "modified\n"
945#~ msgstr "" 945#~ msgstr ""
946#~ " -c CPU, --cpu CPU numéro du CPU à prendre en compte pour les\n" 946#~ " -c CPU, --cpu CPU numéro du CPU à prendre en compte pour les\n"
947#~ " changements\n" 947#~ " changements\n"
diff --git a/tools/testing/nvdimm/pmem-dax.c b/tools/testing/nvdimm/pmem-dax.c
index b53596ad601b..2e7fd8227969 100644
--- a/tools/testing/nvdimm/pmem-dax.c
+++ b/tools/testing/nvdimm/pmem-dax.c
@@ -31,17 +31,21 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff,
31 if (get_nfit_res(pmem->phys_addr + offset)) { 31 if (get_nfit_res(pmem->phys_addr + offset)) {
32 struct page *page; 32 struct page *page;
33 33
34 *kaddr = pmem->virt_addr + offset; 34 if (kaddr)
35 *kaddr = pmem->virt_addr + offset;
35 page = vmalloc_to_page(pmem->virt_addr + offset); 36 page = vmalloc_to_page(pmem->virt_addr + offset);
36 *pfn = page_to_pfn_t(page); 37 if (pfn)
38 *pfn = page_to_pfn_t(page);
37 pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n", 39 pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n",
38 __func__, pmem, pgoff, page_to_pfn(page)); 40 __func__, pmem, pgoff, page_to_pfn(page));
39 41
40 return 1; 42 return 1;
41 } 43 }
42 44
43 *kaddr = pmem->virt_addr + offset; 45 if (kaddr)
44 *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); 46 *kaddr = pmem->virt_addr + offset;
47 if (pfn)
48 *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags);
45 49
46 /* 50 /*
47 * If badblocks are present, limit known good range to the 51 * If badblocks are present, limit known good range to the
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index e2926f72a821..cffc2c5a778d 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -142,6 +142,28 @@ static u32 handle[] = {
142static unsigned long dimm_fail_cmd_flags[NUM_DCR]; 142static unsigned long dimm_fail_cmd_flags[NUM_DCR];
143static int dimm_fail_cmd_code[NUM_DCR]; 143static int dimm_fail_cmd_code[NUM_DCR];
144 144
145static const struct nd_intel_smart smart_def = {
146 .flags = ND_INTEL_SMART_HEALTH_VALID
147 | ND_INTEL_SMART_SPARES_VALID
148 | ND_INTEL_SMART_ALARM_VALID
149 | ND_INTEL_SMART_USED_VALID
150 | ND_INTEL_SMART_SHUTDOWN_VALID
151 | ND_INTEL_SMART_MTEMP_VALID
152 | ND_INTEL_SMART_CTEMP_VALID,
153 .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH,
154 .media_temperature = 23 * 16,
155 .ctrl_temperature = 25 * 16,
156 .pmic_temperature = 40 * 16,
157 .spares = 75,
158 .alarm_flags = ND_INTEL_SMART_SPARE_TRIP
159 | ND_INTEL_SMART_TEMP_TRIP,
160 .ait_status = 1,
161 .life_used = 5,
162 .shutdown_state = 0,
163 .vendor_size = 0,
164 .shutdown_count = 100,
165};
166
145struct nfit_test_fw { 167struct nfit_test_fw {
146 enum intel_fw_update_state state; 168 enum intel_fw_update_state state;
147 u32 context; 169 u32 context;
@@ -752,15 +774,30 @@ static int nfit_test_cmd_smart_inject(
752 if (buf_len != sizeof(*inj)) 774 if (buf_len != sizeof(*inj))
753 return -EINVAL; 775 return -EINVAL;
754 776
755 if (inj->mtemp_enable) 777 if (inj->flags & ND_INTEL_SMART_INJECT_MTEMP) {
756 smart->media_temperature = inj->media_temperature; 778 if (inj->mtemp_enable)
757 if (inj->spare_enable) 779 smart->media_temperature = inj->media_temperature;
758 smart->spares = inj->spares; 780 else
759 if (inj->fatal_enable) 781 smart->media_temperature = smart_def.media_temperature;
760 smart->health = ND_INTEL_SMART_FATAL_HEALTH; 782 }
761 if (inj->unsafe_shutdown_enable) { 783 if (inj->flags & ND_INTEL_SMART_INJECT_SPARE) {
762 smart->shutdown_state = 1; 784 if (inj->spare_enable)
763 smart->shutdown_count++; 785 smart->spares = inj->spares;
786 else
787 smart->spares = smart_def.spares;
788 }
789 if (inj->flags & ND_INTEL_SMART_INJECT_FATAL) {
790 if (inj->fatal_enable)
791 smart->health = ND_INTEL_SMART_FATAL_HEALTH;
792 else
793 smart->health = ND_INTEL_SMART_NON_CRITICAL_HEALTH;
794 }
795 if (inj->flags & ND_INTEL_SMART_INJECT_SHUTDOWN) {
796 if (inj->unsafe_shutdown_enable) {
797 smart->shutdown_state = 1;
798 smart->shutdown_count++;
799 } else
800 smart->shutdown_state = 0;
764 } 801 }
765 inj->status = 0; 802 inj->status = 0;
766 smart_notify(bus_dev, dimm_dev, smart, thresh); 803 smart_notify(bus_dev, dimm_dev, smart, thresh);
@@ -884,6 +921,16 @@ static int nd_intel_test_cmd_set_lss_status(struct nfit_test *t,
884 return 0; 921 return 0;
885} 922}
886 923
924static int override_return_code(int dimm, unsigned int func, int rc)
925{
926 if ((1 << func) & dimm_fail_cmd_flags[dimm]) {
927 if (dimm_fail_cmd_code[dimm])
928 return dimm_fail_cmd_code[dimm];
929 return -EIO;
930 }
931 return rc;
932}
933
887static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func) 934static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func)
888{ 935{
889 int i; 936 int i;
@@ -894,13 +941,6 @@ static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func)
894 break; 941 break;
895 if (i >= ARRAY_SIZE(handle)) 942 if (i >= ARRAY_SIZE(handle))
896 return -ENXIO; 943 return -ENXIO;
897
898 if ((1 << func) & dimm_fail_cmd_flags[i]) {
899 if (dimm_fail_cmd_code[i])
900 return dimm_fail_cmd_code[i];
901 return -EIO;
902 }
903
904 return i; 944 return i;
905} 945}
906 946
@@ -939,48 +979,59 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
939 979
940 switch (func) { 980 switch (func) {
941 case ND_INTEL_ENABLE_LSS_STATUS: 981 case ND_INTEL_ENABLE_LSS_STATUS:
942 return nd_intel_test_cmd_set_lss_status(t, 982 rc = nd_intel_test_cmd_set_lss_status(t,
943 buf, buf_len); 983 buf, buf_len);
984 break;
944 case ND_INTEL_FW_GET_INFO: 985 case ND_INTEL_FW_GET_INFO:
945 return nd_intel_test_get_fw_info(t, buf, 986 rc = nd_intel_test_get_fw_info(t, buf,
946 buf_len, i - t->dcr_idx); 987 buf_len, i - t->dcr_idx);
988 break;
947 case ND_INTEL_FW_START_UPDATE: 989 case ND_INTEL_FW_START_UPDATE:
948 return nd_intel_test_start_update(t, buf, 990 rc = nd_intel_test_start_update(t, buf,
949 buf_len, i - t->dcr_idx); 991 buf_len, i - t->dcr_idx);
992 break;
950 case ND_INTEL_FW_SEND_DATA: 993 case ND_INTEL_FW_SEND_DATA:
951 return nd_intel_test_send_data(t, buf, 994 rc = nd_intel_test_send_data(t, buf,
952 buf_len, i - t->dcr_idx); 995 buf_len, i - t->dcr_idx);
996 break;
953 case ND_INTEL_FW_FINISH_UPDATE: 997 case ND_INTEL_FW_FINISH_UPDATE:
954 return nd_intel_test_finish_fw(t, buf, 998 rc = nd_intel_test_finish_fw(t, buf,
955 buf_len, i - t->dcr_idx); 999 buf_len, i - t->dcr_idx);
1000 break;
956 case ND_INTEL_FW_FINISH_QUERY: 1001 case ND_INTEL_FW_FINISH_QUERY:
957 return nd_intel_test_finish_query(t, buf, 1002 rc = nd_intel_test_finish_query(t, buf,
958 buf_len, i - t->dcr_idx); 1003 buf_len, i - t->dcr_idx);
1004 break;
959 case ND_INTEL_SMART: 1005 case ND_INTEL_SMART:
960 return nfit_test_cmd_smart(buf, buf_len, 1006 rc = nfit_test_cmd_smart(buf, buf_len,
961 &t->smart[i - t->dcr_idx]); 1007 &t->smart[i - t->dcr_idx]);
1008 break;
962 case ND_INTEL_SMART_THRESHOLD: 1009 case ND_INTEL_SMART_THRESHOLD:
963 return nfit_test_cmd_smart_threshold(buf, 1010 rc = nfit_test_cmd_smart_threshold(buf,
964 buf_len, 1011 buf_len,
965 &t->smart_threshold[i - 1012 &t->smart_threshold[i -
966 t->dcr_idx]); 1013 t->dcr_idx]);
1014 break;
967 case ND_INTEL_SMART_SET_THRESHOLD: 1015 case ND_INTEL_SMART_SET_THRESHOLD:
968 return nfit_test_cmd_smart_set_threshold(buf, 1016 rc = nfit_test_cmd_smart_set_threshold(buf,
969 buf_len, 1017 buf_len,
970 &t->smart_threshold[i - 1018 &t->smart_threshold[i -
971 t->dcr_idx], 1019 t->dcr_idx],
972 &t->smart[i - t->dcr_idx], 1020 &t->smart[i - t->dcr_idx],
973 &t->pdev.dev, t->dimm_dev[i]); 1021 &t->pdev.dev, t->dimm_dev[i]);
1022 break;
974 case ND_INTEL_SMART_INJECT: 1023 case ND_INTEL_SMART_INJECT:
975 return nfit_test_cmd_smart_inject(buf, 1024 rc = nfit_test_cmd_smart_inject(buf,
976 buf_len, 1025 buf_len,
977 &t->smart_threshold[i - 1026 &t->smart_threshold[i -
978 t->dcr_idx], 1027 t->dcr_idx],
979 &t->smart[i - t->dcr_idx], 1028 &t->smart[i - t->dcr_idx],
980 &t->pdev.dev, t->dimm_dev[i]); 1029 &t->pdev.dev, t->dimm_dev[i]);
1030 break;
981 default: 1031 default:
982 return -ENOTTY; 1032 return -ENOTTY;
983 } 1033 }
1034 return override_return_code(i, func, rc);
984 } 1035 }
985 1036
986 if (!test_bit(cmd, &cmd_mask) 1037 if (!test_bit(cmd, &cmd_mask)
@@ -1006,6 +1057,7 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
1006 default: 1057 default:
1007 return -ENOTTY; 1058 return -ENOTTY;
1008 } 1059 }
1060 return override_return_code(i, func, rc);
1009 } else { 1061 } else {
1010 struct ars_state *ars_state = &t->ars_state; 1062 struct ars_state *ars_state = &t->ars_state;
1011 struct nd_cmd_pkg *call_pkg = buf; 1063 struct nd_cmd_pkg *call_pkg = buf;
@@ -1302,29 +1354,9 @@ static void smart_init(struct nfit_test *t)
1302 .ctrl_temperature = 30 * 16, 1354 .ctrl_temperature = 30 * 16,
1303 .spares = 5, 1355 .spares = 5,
1304 }; 1356 };
1305 const struct nd_intel_smart smart_data = {
1306 .flags = ND_INTEL_SMART_HEALTH_VALID
1307 | ND_INTEL_SMART_SPARES_VALID
1308 | ND_INTEL_SMART_ALARM_VALID
1309 | ND_INTEL_SMART_USED_VALID
1310 | ND_INTEL_SMART_SHUTDOWN_VALID
1311 | ND_INTEL_SMART_MTEMP_VALID,
1312 .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH,
1313 .media_temperature = 23 * 16,
1314 .ctrl_temperature = 25 * 16,
1315 .pmic_temperature = 40 * 16,
1316 .spares = 75,
1317 .alarm_flags = ND_INTEL_SMART_SPARE_TRIP
1318 | ND_INTEL_SMART_TEMP_TRIP,
1319 .ait_status = 1,
1320 .life_used = 5,
1321 .shutdown_state = 0,
1322 .vendor_size = 0,
1323 .shutdown_count = 100,
1324 };
1325 1357
1326 for (i = 0; i < t->num_dcr; i++) { 1358 for (i = 0; i < t->num_dcr; i++) {
1327 memcpy(&t->smart[i], &smart_data, sizeof(smart_data)); 1359 memcpy(&t->smart[i], &smart_def, sizeof(smart_def));
1328 memcpy(&t->smart_threshold[i], &smart_t_data, 1360 memcpy(&t->smart_threshold[i], &smart_t_data,
1329 sizeof(smart_t_data)); 1361 sizeof(smart_t_data));
1330 } 1362 }
diff --git a/tools/testing/radix-tree/Makefile b/tools/testing/radix-tree/Makefile
index db66f8a0d4be..37baecc3766f 100644
--- a/tools/testing/radix-tree/Makefile
+++ b/tools/testing/radix-tree/Makefile
@@ -1,7 +1,8 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2 2
3CFLAGS += -I. -I../../include -g -O2 -Wall -D_LGPL_SOURCE -fsanitize=address 3CFLAGS += -I. -I../../include -g -Og -Wall -D_LGPL_SOURCE -fsanitize=address \
4LDFLAGS += -fsanitize=address 4 -fsanitize=undefined
5LDFLAGS += -fsanitize=address -fsanitize=undefined
5LDLIBS+= -lpthread -lurcu 6LDLIBS+= -lpthread -lurcu
6TARGETS = main idr-test multiorder 7TARGETS = main idr-test multiorder
7CORE_OFILES := radix-tree.o idr.o linux.o test.o find_bit.o 8CORE_OFILES := radix-tree.o idr.o linux.o test.o find_bit.o
@@ -21,6 +22,7 @@ targets: generated/map-shift.h $(TARGETS)
21 22
22main: $(OFILES) 23main: $(OFILES)
23 24
25idr-test.o: ../../../lib/test_ida.c
24idr-test: idr-test.o $(CORE_OFILES) 26idr-test: idr-test.o $(CORE_OFILES)
25 27
26multiorder: multiorder.o $(CORE_OFILES) 28multiorder: multiorder.o $(CORE_OFILES)
diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c
index ee820fcc29b0..321ba92c70d2 100644
--- a/tools/testing/radix-tree/idr-test.c
+++ b/tools/testing/radix-tree/idr-test.c
@@ -309,141 +309,61 @@ void idr_checks(void)
309 idr_u32_test(0); 309 idr_u32_test(0);
310} 310}
311 311
312#define module_init(x)
313#define module_exit(x)
314#define MODULE_AUTHOR(x)
315#define MODULE_LICENSE(x)
316#define dump_stack() assert(0)
317void ida_dump(struct ida *);
318
319#include "../../../lib/test_ida.c"
320
312/* 321/*
313 * Check that we get the correct error when we run out of memory doing 322 * Check that we get the correct error when we run out of memory doing
314 * allocations. To ensure we run out of memory, just "forget" to preload. 323 * allocations. In userspace, GFP_NOWAIT will always fail an allocation.
315 * The first test is for not having a bitmap available, and the second test 324 * The first test is for not having a bitmap available, and the second test
316 * is for not being able to allocate a level of the radix tree. 325 * is for not being able to allocate a level of the radix tree.
317 */ 326 */
318void ida_check_nomem(void) 327void ida_check_nomem(void)
319{ 328{
320 DEFINE_IDA(ida); 329 DEFINE_IDA(ida);
321 int id, err;
322
323 err = ida_get_new_above(&ida, 256, &id);
324 assert(err == -EAGAIN);
325 err = ida_get_new_above(&ida, 1UL << 30, &id);
326 assert(err == -EAGAIN);
327}
328
329/*
330 * Check what happens when we fill a leaf and then delete it. This may
331 * discover mishandling of IDR_FREE.
332 */
333void ida_check_leaf(void)
334{
335 DEFINE_IDA(ida);
336 int id; 330 int id;
337 unsigned long i;
338 331
339 for (i = 0; i < IDA_BITMAP_BITS; i++) { 332 id = ida_alloc_min(&ida, 256, GFP_NOWAIT);
340 assert(ida_pre_get(&ida, GFP_KERNEL)); 333 IDA_BUG_ON(&ida, id != -ENOMEM);
341 assert(!ida_get_new(&ida, &id)); 334 id = ida_alloc_min(&ida, 1UL << 30, GFP_NOWAIT);
342 assert(id == i); 335 IDA_BUG_ON(&ida, id != -ENOMEM);
343 } 336 IDA_BUG_ON(&ida, !ida_is_empty(&ida));
344
345 ida_destroy(&ida);
346 assert(ida_is_empty(&ida));
347
348 assert(ida_pre_get(&ida, GFP_KERNEL));
349 assert(!ida_get_new(&ida, &id));
350 assert(id == 0);
351 ida_destroy(&ida);
352 assert(ida_is_empty(&ida));
353} 337}
354 338
355/* 339/*
356 * Check handling of conversions between exceptional entries and full bitmaps. 340 * Check handling of conversions between exceptional entries and full bitmaps.
357 */ 341 */
358void ida_check_conv(void) 342void ida_check_conv_user(void)
359{ 343{
360 DEFINE_IDA(ida); 344 DEFINE_IDA(ida);
361 int id;
362 unsigned long i; 345 unsigned long i;
363 346
364 for (i = 0; i < IDA_BITMAP_BITS * 2; i += IDA_BITMAP_BITS) {
365 assert(ida_pre_get(&ida, GFP_KERNEL));
366 assert(!ida_get_new_above(&ida, i + 1, &id));
367 assert(id == i + 1);
368 assert(!ida_get_new_above(&ida, i + BITS_PER_LONG, &id));
369 assert(id == i + BITS_PER_LONG);
370 ida_remove(&ida, i + 1);
371 ida_remove(&ida, i + BITS_PER_LONG);
372 assert(ida_is_empty(&ida));
373 }
374
375 assert(ida_pre_get(&ida, GFP_KERNEL));
376
377 for (i = 0; i < IDA_BITMAP_BITS * 2; i++) {
378 assert(ida_pre_get(&ida, GFP_KERNEL));
379 assert(!ida_get_new(&ida, &id));
380 assert(id == i);
381 }
382
383 for (i = IDA_BITMAP_BITS * 2; i > 0; i--) {
384 ida_remove(&ida, i - 1);
385 }
386 assert(ida_is_empty(&ida));
387
388 for (i = 0; i < IDA_BITMAP_BITS + BITS_PER_LONG - 4; i++) {
389 assert(ida_pre_get(&ida, GFP_KERNEL));
390 assert(!ida_get_new(&ida, &id));
391 assert(id == i);
392 }
393
394 for (i = IDA_BITMAP_BITS + BITS_PER_LONG - 4; i > 0; i--) {
395 ida_remove(&ida, i - 1);
396 }
397 assert(ida_is_empty(&ida));
398
399 radix_tree_cpu_dead(1); 347 radix_tree_cpu_dead(1);
400 for (i = 0; i < 1000000; i++) { 348 for (i = 0; i < 1000000; i++) {
401 int err = ida_get_new(&ida, &id); 349 int id = ida_alloc(&ida, GFP_NOWAIT);
402 if (err == -EAGAIN) { 350 if (id == -ENOMEM) {
403 assert((i % IDA_BITMAP_BITS) == (BITS_PER_LONG - 2)); 351 IDA_BUG_ON(&ida, (i % IDA_BITMAP_BITS) !=
404 assert(ida_pre_get(&ida, GFP_KERNEL)); 352 BITS_PER_LONG - 2);
405 err = ida_get_new(&ida, &id); 353 id = ida_alloc(&ida, GFP_KERNEL);
406 } else { 354 } else {
407 assert((i % IDA_BITMAP_BITS) != (BITS_PER_LONG - 2)); 355 IDA_BUG_ON(&ida, (i % IDA_BITMAP_BITS) ==
356 BITS_PER_LONG - 2);
408 } 357 }
409 assert(!err); 358 IDA_BUG_ON(&ida, id != i);
410 assert(id == i);
411 } 359 }
412 ida_destroy(&ida); 360 ida_destroy(&ida);
413} 361}
414 362
415/*
416 * Check allocations up to and slightly above the maximum allowed (2^31-1) ID.
417 * Allocating up to 2^31-1 should succeed, and then allocating the next one
418 * should fail.
419 */
420void ida_check_max(void)
421{
422 DEFINE_IDA(ida);
423 int id, err;
424 unsigned long i, j;
425
426 for (j = 1; j < 65537; j *= 2) {
427 unsigned long base = (1UL << 31) - j;
428 for (i = 0; i < j; i++) {
429 assert(ida_pre_get(&ida, GFP_KERNEL));
430 assert(!ida_get_new_above(&ida, base, &id));
431 assert(id == base + i);
432 }
433 assert(ida_pre_get(&ida, GFP_KERNEL));
434 err = ida_get_new_above(&ida, base, &id);
435 assert(err == -ENOSPC);
436 ida_destroy(&ida);
437 assert(ida_is_empty(&ida));
438 rcu_barrier();
439 }
440}
441
442void ida_check_random(void) 363void ida_check_random(void)
443{ 364{
444 DEFINE_IDA(ida); 365 DEFINE_IDA(ida);
445 DECLARE_BITMAP(bitmap, 2048); 366 DECLARE_BITMAP(bitmap, 2048);
446 int id, err;
447 unsigned int i; 367 unsigned int i;
448 time_t s = time(NULL); 368 time_t s = time(NULL);
449 369
@@ -454,15 +374,11 @@ void ida_check_random(void)
454 int bit = i & 2047; 374 int bit = i & 2047;
455 if (test_bit(bit, bitmap)) { 375 if (test_bit(bit, bitmap)) {
456 __clear_bit(bit, bitmap); 376 __clear_bit(bit, bitmap);
457 ida_remove(&ida, bit); 377 ida_free(&ida, bit);
458 } else { 378 } else {
459 __set_bit(bit, bitmap); 379 __set_bit(bit, bitmap);
460 do { 380 IDA_BUG_ON(&ida, ida_alloc_min(&ida, bit, GFP_KERNEL)
461 ida_pre_get(&ida, GFP_KERNEL); 381 != bit);
462 err = ida_get_new_above(&ida, bit, &id);
463 } while (err == -EAGAIN);
464 assert(!err);
465 assert(id == bit);
466 } 382 }
467 } 383 }
468 ida_destroy(&ida); 384 ida_destroy(&ida);
@@ -488,71 +404,12 @@ void ida_simple_get_remove_test(void)
488 ida_destroy(&ida); 404 ida_destroy(&ida);
489} 405}
490 406
491void ida_checks(void) 407void user_ida_checks(void)
492{ 408{
493 DEFINE_IDA(ida);
494 int id;
495 unsigned long i;
496
497 radix_tree_cpu_dead(1); 409 radix_tree_cpu_dead(1);
498 ida_check_nomem();
499
500 for (i = 0; i < 10000; i++) {
501 assert(ida_pre_get(&ida, GFP_KERNEL));
502 assert(!ida_get_new(&ida, &id));
503 assert(id == i);
504 }
505
506 ida_remove(&ida, 20);
507 ida_remove(&ida, 21);
508 for (i = 0; i < 3; i++) {
509 assert(ida_pre_get(&ida, GFP_KERNEL));
510 assert(!ida_get_new(&ida, &id));
511 if (i == 2)
512 assert(id == 10000);
513 }
514
515 for (i = 0; i < 5000; i++)
516 ida_remove(&ida, i);
517
518 assert(ida_pre_get(&ida, GFP_KERNEL));
519 assert(!ida_get_new_above(&ida, 5000, &id));
520 assert(id == 10001);
521
522 ida_destroy(&ida);
523
524 assert(ida_is_empty(&ida));
525 410
526 assert(ida_pre_get(&ida, GFP_KERNEL)); 411 ida_check_nomem();
527 assert(!ida_get_new_above(&ida, 1, &id)); 412 ida_check_conv_user();
528 assert(id == 1);
529
530 ida_remove(&ida, id);
531 assert(ida_is_empty(&ida));
532 ida_destroy(&ida);
533 assert(ida_is_empty(&ida));
534
535 assert(ida_pre_get(&ida, GFP_KERNEL));
536 assert(!ida_get_new_above(&ida, 1, &id));
537 ida_destroy(&ida);
538 assert(ida_is_empty(&ida));
539
540 assert(ida_pre_get(&ida, GFP_KERNEL));
541 assert(!ida_get_new_above(&ida, 1, &id));
542 assert(id == 1);
543 assert(ida_pre_get(&ida, GFP_KERNEL));
544 assert(!ida_get_new_above(&ida, 1025, &id));
545 assert(id == 1025);
546 assert(ida_pre_get(&ida, GFP_KERNEL));
547 assert(!ida_get_new_above(&ida, 10000, &id));
548 assert(id == 10000);
549 ida_remove(&ida, 1025);
550 ida_destroy(&ida);
551 assert(ida_is_empty(&ida));
552
553 ida_check_leaf();
554 ida_check_max();
555 ida_check_conv();
556 ida_check_random(); 413 ida_check_random();
557 ida_simple_get_remove_test(); 414 ida_simple_get_remove_test();
558 415
@@ -582,12 +439,19 @@ void ida_thread_tests(void)
582 pthread_join(threads[i], NULL); 439 pthread_join(threads[i], NULL);
583} 440}
584 441
442void ida_tests(void)
443{
444 user_ida_checks();
445 ida_checks();
446 ida_exit();
447 ida_thread_tests();
448}
449
585int __weak main(void) 450int __weak main(void)
586{ 451{
587 radix_tree_init(); 452 radix_tree_init();
588 idr_checks(); 453 idr_checks();
589 ida_checks(); 454 ida_tests();
590 ida_thread_tests();
591 radix_tree_cpu_dead(1); 455 radix_tree_cpu_dead(1);
592 rcu_barrier(); 456 rcu_barrier();
593 if (nr_allocated) 457 if (nr_allocated)
diff --git a/tools/testing/radix-tree/linux/xarray.h b/tools/testing/radix-tree/linux/xarray.h
new file mode 100644
index 000000000000..df3812cda376
--- /dev/null
+++ b/tools/testing/radix-tree/linux/xarray.h
@@ -0,0 +1,2 @@
1#include "generated/map-shift.h"
2#include "../../../../include/linux/xarray.h"
diff --git a/tools/testing/radix-tree/main.c b/tools/testing/radix-tree/main.c
index 257f3f8aacaa..b741686e53d6 100644
--- a/tools/testing/radix-tree/main.c
+++ b/tools/testing/radix-tree/main.c
@@ -27,20 +27,22 @@ void __gang_check(unsigned long middle, long down, long up, int chunk, int hop)
27 item_check_present(&tree, middle + idx); 27 item_check_present(&tree, middle + idx);
28 item_check_absent(&tree, middle + up); 28 item_check_absent(&tree, middle + up);
29 29
30 item_gang_check_present(&tree, middle - down, 30 if (chunk > 0) {
31 up + down, chunk, hop); 31 item_gang_check_present(&tree, middle - down, up + down,
32 item_full_scan(&tree, middle - down, down + up, chunk); 32 chunk, hop);
33 item_full_scan(&tree, middle - down, down + up, chunk);
34 }
33 item_kill_tree(&tree); 35 item_kill_tree(&tree);
34} 36}
35 37
36void gang_check(void) 38void gang_check(void)
37{ 39{
38 __gang_check(1 << 30, 128, 128, 35, 2); 40 __gang_check(1UL << 30, 128, 128, 35, 2);
39 __gang_check(1 << 31, 128, 128, 32, 32); 41 __gang_check(1UL << 31, 128, 128, 32, 32);
40 __gang_check(1 << 31, 128, 128, 32, 100); 42 __gang_check(1UL << 31, 128, 128, 32, 100);
41 __gang_check(1 << 31, 128, 128, 17, 7); 43 __gang_check(1UL << 31, 128, 128, 17, 7);
42 __gang_check(0xffff0000, 0, 65536, 17, 7); 44 __gang_check(0xffff0000UL, 0, 65536, 17, 7);
43 __gang_check(0xfffffffe, 1, 1, 17, 7); 45 __gang_check(0xfffffffeUL, 1, 1, 17, 7);
44} 46}
45 47
46void __big_gang_check(void) 48void __big_gang_check(void)
@@ -322,7 +324,7 @@ static void single_thread_tests(bool long_run)
322 printv(2, "after dynamic_height_check: %d allocated, preempt %d\n", 324 printv(2, "after dynamic_height_check: %d allocated, preempt %d\n",
323 nr_allocated, preempt_count); 325 nr_allocated, preempt_count);
324 idr_checks(); 326 idr_checks();
325 ida_checks(); 327 ida_tests();
326 rcu_barrier(); 328 rcu_barrier();
327 printv(2, "after idr_checks: %d allocated, preempt %d\n", 329 printv(2, "after idr_checks: %d allocated, preempt %d\n",
328 nr_allocated, preempt_count); 330 nr_allocated, preempt_count);
@@ -369,7 +371,6 @@ int main(int argc, char **argv)
369 iteration_test(0, 10 + 90 * long_run); 371 iteration_test(0, 10 + 90 * long_run);
370 iteration_test(7, 10 + 90 * long_run); 372 iteration_test(7, 10 + 90 * long_run);
371 single_thread_tests(long_run); 373 single_thread_tests(long_run);
372 ida_thread_tests();
373 374
374 /* Free any remaining preallocated nodes */ 375 /* Free any remaining preallocated nodes */
375 radix_tree_cpu_dead(0); 376 radix_tree_cpu_dead(0);
diff --git a/tools/testing/radix-tree/test.h b/tools/testing/radix-tree/test.h
index 31f1d9b6f506..92d901eacf49 100644
--- a/tools/testing/radix-tree/test.h
+++ b/tools/testing/radix-tree/test.h
@@ -39,8 +39,7 @@ void multiorder_checks(void);
39void iteration_test(unsigned order, unsigned duration); 39void iteration_test(unsigned order, unsigned duration);
40void benchmark(void); 40void benchmark(void);
41void idr_checks(void); 41void idr_checks(void);
42void ida_checks(void); 42void ida_tests(void);
43void ida_thread_tests(void);
44 43
45struct item * 44struct item *
46item_tag_set(struct radix_tree_root *root, unsigned long index, int tag); 45item_tag_set(struct radix_tree_root *root, unsigned long index, int tag);
diff --git a/tools/testing/selftests/android/ion/ionapp_export.c b/tools/testing/selftests/android/ion/ionapp_export.c
index a944e72621a9..b5fa0a2dc968 100644
--- a/tools/testing/selftests/android/ion/ionapp_export.c
+++ b/tools/testing/selftests/android/ion/ionapp_export.c
@@ -51,6 +51,7 @@ int main(int argc, char *argv[])
51 51
52 heap_size = 0; 52 heap_size = 0;
53 flags = 0; 53 flags = 0;
54 heap_type = ION_HEAP_TYPE_SYSTEM;
54 55
55 while ((opt = getopt(argc, argv, "hi:s:")) != -1) { 56 while ((opt = getopt(argc, argv, "hi:s:")) != -1) {
56 switch (opt) { 57 switch (opt) {
diff --git a/tools/testing/selftests/cgroup/.gitignore b/tools/testing/selftests/cgroup/.gitignore
new file mode 100644
index 000000000000..95eb3a53c381
--- /dev/null
+++ b/tools/testing/selftests/cgroup/.gitignore
@@ -0,0 +1 @@
test_memcontrol
diff --git a/tools/testing/selftests/cgroup/Makefile b/tools/testing/selftests/cgroup/Makefile
index f7a31392eb2f..23fbaa4a9630 100644
--- a/tools/testing/selftests/cgroup/Makefile
+++ b/tools/testing/selftests/cgroup/Makefile
@@ -4,7 +4,9 @@ CFLAGS += -Wall
4all: 4all:
5 5
6TEST_GEN_PROGS = test_memcontrol 6TEST_GEN_PROGS = test_memcontrol
7TEST_GEN_PROGS += test_core
7 8
8include ../lib.mk 9include ../lib.mk
9 10
10$(OUTPUT)/test_memcontrol: cgroup_util.c 11$(OUTPUT)/test_memcontrol: cgroup_util.c
12$(OUTPUT)/test_core: cgroup_util.c
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index 1e9e3c470561..1c5d2b2a583b 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -229,6 +229,14 @@ retry:
229 return ret; 229 return ret;
230} 230}
231 231
232int cg_enter_current(const char *cgroup)
233{
234 char pidbuf[64];
235
236 snprintf(pidbuf, sizeof(pidbuf), "%d", getpid());
237 return cg_write(cgroup, "cgroup.procs", pidbuf);
238}
239
232int cg_run(const char *cgroup, 240int cg_run(const char *cgroup,
233 int (*fn)(const char *cgroup, void *arg), 241 int (*fn)(const char *cgroup, void *arg),
234 void *arg) 242 void *arg)
diff --git a/tools/testing/selftests/cgroup/cgroup_util.h b/tools/testing/selftests/cgroup/cgroup_util.h
index fe82a297d4e0..1ff6f9f1abdc 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.h
+++ b/tools/testing/selftests/cgroup/cgroup_util.h
@@ -32,6 +32,7 @@ extern int cg_write(const char *cgroup, const char *control, char *buf);
32extern int cg_run(const char *cgroup, 32extern int cg_run(const char *cgroup,
33 int (*fn)(const char *cgroup, void *arg), 33 int (*fn)(const char *cgroup, void *arg),
34 void *arg); 34 void *arg);
35extern int cg_enter_current(const char *cgroup);
35extern int cg_run_nowait(const char *cgroup, 36extern int cg_run_nowait(const char *cgroup,
36 int (*fn)(const char *cgroup, void *arg), 37 int (*fn)(const char *cgroup, void *arg),
37 void *arg); 38 void *arg);
diff --git a/tools/testing/selftests/cgroup/test_core.c b/tools/testing/selftests/cgroup/test_core.c
new file mode 100644
index 000000000000..be59f9c34ea2
--- /dev/null
+++ b/tools/testing/selftests/cgroup/test_core.c
@@ -0,0 +1,395 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2
3#include <linux/limits.h>
4#include <sys/types.h>
5#include <unistd.h>
6#include <stdio.h>
7#include <errno.h>
8
9#include "../kselftest.h"
10#include "cgroup_util.h"
11
12/*
13 * A(0) - B(0) - C(1)
14 * \ D(0)
15 *
16 * A, B and C's "populated" fields would be 1 while D's 0.
17 * test that after the one process in C is moved to root,
18 * A,B and C's "populated" fields would flip to "0" and file
19 * modified events will be generated on the
20 * "cgroup.events" files of both cgroups.
21 */
22static int test_cgcore_populated(const char *root)
23{
24 int ret = KSFT_FAIL;
25 char *cg_test_a = NULL, *cg_test_b = NULL;
26 char *cg_test_c = NULL, *cg_test_d = NULL;
27
28 cg_test_a = cg_name(root, "cg_test_a");
29 cg_test_b = cg_name(root, "cg_test_a/cg_test_b");
30 cg_test_c = cg_name(root, "cg_test_a/cg_test_b/cg_test_c");
31 cg_test_d = cg_name(root, "cg_test_a/cg_test_b/cg_test_d");
32
33 if (!cg_test_a || !cg_test_b || !cg_test_c || !cg_test_d)
34 goto cleanup;
35
36 if (cg_create(cg_test_a))
37 goto cleanup;
38
39 if (cg_create(cg_test_b))
40 goto cleanup;
41
42 if (cg_create(cg_test_c))
43 goto cleanup;
44
45 if (cg_create(cg_test_d))
46 goto cleanup;
47
48 if (cg_enter_current(cg_test_c))
49 goto cleanup;
50
51 if (cg_read_strcmp(cg_test_a, "cgroup.events", "populated 1\n"))
52 goto cleanup;
53
54 if (cg_read_strcmp(cg_test_b, "cgroup.events", "populated 1\n"))
55 goto cleanup;
56
57 if (cg_read_strcmp(cg_test_c, "cgroup.events", "populated 1\n"))
58 goto cleanup;
59
60 if (cg_read_strcmp(cg_test_d, "cgroup.events", "populated 0\n"))
61 goto cleanup;
62
63 if (cg_enter_current(root))
64 goto cleanup;
65
66 if (cg_read_strcmp(cg_test_a, "cgroup.events", "populated 0\n"))
67 goto cleanup;
68
69 if (cg_read_strcmp(cg_test_b, "cgroup.events", "populated 0\n"))
70 goto cleanup;
71
72 if (cg_read_strcmp(cg_test_c, "cgroup.events", "populated 0\n"))
73 goto cleanup;
74
75 if (cg_read_strcmp(cg_test_d, "cgroup.events", "populated 0\n"))
76 goto cleanup;
77
78 ret = KSFT_PASS;
79
80cleanup:
81 if (cg_test_d)
82 cg_destroy(cg_test_d);
83 if (cg_test_c)
84 cg_destroy(cg_test_c);
85 if (cg_test_b)
86 cg_destroy(cg_test_b);
87 if (cg_test_a)
88 cg_destroy(cg_test_a);
89 free(cg_test_d);
90 free(cg_test_c);
91 free(cg_test_b);
92 free(cg_test_a);
93 return ret;
94}
95
96/*
97 * A (domain threaded) - B (threaded) - C (domain)
98 *
99 * test that C can't be used until it is turned into a
100 * threaded cgroup. "cgroup.type" file will report "domain (invalid)" in
101 * these cases. Operations which fail due to invalid topology use
102 * EOPNOTSUPP as the errno.
103 */
104static int test_cgcore_invalid_domain(const char *root)
105{
106 int ret = KSFT_FAIL;
107 char *grandparent = NULL, *parent = NULL, *child = NULL;
108
109 grandparent = cg_name(root, "cg_test_grandparent");
110 parent = cg_name(root, "cg_test_grandparent/cg_test_parent");
111 child = cg_name(root, "cg_test_grandparent/cg_test_parent/cg_test_child");
112 if (!parent || !child || !grandparent)
113 goto cleanup;
114
115 if (cg_create(grandparent))
116 goto cleanup;
117
118 if (cg_create(parent))
119 goto cleanup;
120
121 if (cg_create(child))
122 goto cleanup;
123
124 if (cg_write(parent, "cgroup.type", "threaded"))
125 goto cleanup;
126
127 if (cg_read_strcmp(child, "cgroup.type", "domain invalid\n"))
128 goto cleanup;
129
130 if (!cg_enter_current(child))
131 goto cleanup;
132
133 if (errno != EOPNOTSUPP)
134 goto cleanup;
135
136 ret = KSFT_PASS;
137
138cleanup:
139 cg_enter_current(root);
140 if (child)
141 cg_destroy(child);
142 if (parent)
143 cg_destroy(parent);
144 if (grandparent)
145 cg_destroy(grandparent);
146 free(child);
147 free(parent);
148 free(grandparent);
149 return ret;
150}
151
152/*
153 * Test that when a child becomes threaded
154 * the parent type becomes domain threaded.
155 */
156static int test_cgcore_parent_becomes_threaded(const char *root)
157{
158 int ret = KSFT_FAIL;
159 char *parent = NULL, *child = NULL;
160
161 parent = cg_name(root, "cg_test_parent");
162 child = cg_name(root, "cg_test_parent/cg_test_child");
163 if (!parent || !child)
164 goto cleanup;
165
166 if (cg_create(parent))
167 goto cleanup;
168
169 if (cg_create(child))
170 goto cleanup;
171
172 if (cg_write(child, "cgroup.type", "threaded"))
173 goto cleanup;
174
175 if (cg_read_strcmp(parent, "cgroup.type", "domain threaded\n"))
176 goto cleanup;
177
178 ret = KSFT_PASS;
179
180cleanup:
181 if (child)
182 cg_destroy(child);
183 if (parent)
184 cg_destroy(parent);
185 free(child);
186 free(parent);
187 return ret;
188
189}
190
191/*
192 * Test that there's no internal process constrain on threaded cgroups.
193 * You can add threads/processes on a parent with a controller enabled.
194 */
195static int test_cgcore_no_internal_process_constraint_on_threads(const char *root)
196{
197 int ret = KSFT_FAIL;
198 char *parent = NULL, *child = NULL;
199
200 if (cg_read_strstr(root, "cgroup.controllers", "cpu") ||
201 cg_read_strstr(root, "cgroup.subtree_control", "cpu")) {
202 ret = KSFT_SKIP;
203 goto cleanup;
204 }
205
206 parent = cg_name(root, "cg_test_parent");
207 child = cg_name(root, "cg_test_parent/cg_test_child");
208 if (!parent || !child)
209 goto cleanup;
210
211 if (cg_create(parent))
212 goto cleanup;
213
214 if (cg_create(child))
215 goto cleanup;
216
217 if (cg_write(parent, "cgroup.type", "threaded"))
218 goto cleanup;
219
220 if (cg_write(child, "cgroup.type", "threaded"))
221 goto cleanup;
222
223 if (cg_write(parent, "cgroup.subtree_control", "+cpu"))
224 goto cleanup;
225
226 if (cg_enter_current(parent))
227 goto cleanup;
228
229 ret = KSFT_PASS;
230
231cleanup:
232 cg_enter_current(root);
233 cg_enter_current(root);
234 if (child)
235 cg_destroy(child);
236 if (parent)
237 cg_destroy(parent);
238 free(child);
239 free(parent);
240 return ret;
241}
242
243/*
244 * Test that you can't enable a controller on a child if it's not enabled
245 * on the parent.
246 */
247static int test_cgcore_top_down_constraint_enable(const char *root)
248{
249 int ret = KSFT_FAIL;
250 char *parent = NULL, *child = NULL;
251
252 parent = cg_name(root, "cg_test_parent");
253 child = cg_name(root, "cg_test_parent/cg_test_child");
254 if (!parent || !child)
255 goto cleanup;
256
257 if (cg_create(parent))
258 goto cleanup;
259
260 if (cg_create(child))
261 goto cleanup;
262
263 if (!cg_write(child, "cgroup.subtree_control", "+memory"))
264 goto cleanup;
265
266 ret = KSFT_PASS;
267
268cleanup:
269 if (child)
270 cg_destroy(child);
271 if (parent)
272 cg_destroy(parent);
273 free(child);
274 free(parent);
275 return ret;
276}
277
278/*
279 * Test that you can't disable a controller on a parent
280 * if it's enabled in a child.
281 */
282static int test_cgcore_top_down_constraint_disable(const char *root)
283{
284 int ret = KSFT_FAIL;
285 char *parent = NULL, *child = NULL;
286
287 parent = cg_name(root, "cg_test_parent");
288 child = cg_name(root, "cg_test_parent/cg_test_child");
289 if (!parent || !child)
290 goto cleanup;
291
292 if (cg_create(parent))
293 goto cleanup;
294
295 if (cg_create(child))
296 goto cleanup;
297
298 if (cg_write(parent, "cgroup.subtree_control", "+memory"))
299 goto cleanup;
300
301 if (cg_write(child, "cgroup.subtree_control", "+memory"))
302 goto cleanup;
303
304 if (!cg_write(parent, "cgroup.subtree_control", "-memory"))
305 goto cleanup;
306
307 ret = KSFT_PASS;
308
309cleanup:
310 if (child)
311 cg_destroy(child);
312 if (parent)
313 cg_destroy(parent);
314 free(child);
315 free(parent);
316 return ret;
317}
318
319/*
320 * Test internal process constraint.
321 * You can't add a pid to a domain parent if a controller is enabled.
322 */
323static int test_cgcore_internal_process_constraint(const char *root)
324{
325 int ret = KSFT_FAIL;
326 char *parent = NULL, *child = NULL;
327
328 parent = cg_name(root, "cg_test_parent");
329 child = cg_name(root, "cg_test_parent/cg_test_child");
330 if (!parent || !child)
331 goto cleanup;
332
333 if (cg_create(parent))
334 goto cleanup;
335
336 if (cg_create(child))
337 goto cleanup;
338
339 if (cg_write(parent, "cgroup.subtree_control", "+memory"))
340 goto cleanup;
341
342 if (!cg_enter_current(parent))
343 goto cleanup;
344
345 ret = KSFT_PASS;
346
347cleanup:
348 if (child)
349 cg_destroy(child);
350 if (parent)
351 cg_destroy(parent);
352 free(child);
353 free(parent);
354 return ret;
355}
356
357#define T(x) { x, #x }
358struct corecg_test {
359 int (*fn)(const char *root);
360 const char *name;
361} tests[] = {
362 T(test_cgcore_internal_process_constraint),
363 T(test_cgcore_top_down_constraint_enable),
364 T(test_cgcore_top_down_constraint_disable),
365 T(test_cgcore_no_internal_process_constraint_on_threads),
366 T(test_cgcore_parent_becomes_threaded),
367 T(test_cgcore_invalid_domain),
368 T(test_cgcore_populated),
369};
370#undef T
371
372int main(int argc, char *argv[])
373{
374 char root[PATH_MAX];
375 int i, ret = EXIT_SUCCESS;
376
377 if (cg_find_unified_root(root, sizeof(root)))
378 ksft_exit_skip("cgroup v2 isn't mounted\n");
379 for (i = 0; i < ARRAY_SIZE(tests); i++) {
380 switch (tests[i].fn(root)) {
381 case KSFT_PASS:
382 ksft_test_result_pass("%s\n", tests[i].name);
383 break;
384 case KSFT_SKIP:
385 ksft_test_result_skip("%s\n", tests[i].name);
386 break;
387 default:
388 ret = EXIT_FAILURE;
389 ksft_test_result_fail("%s\n", tests[i].name);
390 break;
391 }
392 }
393
394 return ret;
395}
diff --git a/tools/testing/selftests/ftrace/config b/tools/testing/selftests/ftrace/config
index b01924c71c09..07db5ab09cc7 100644
--- a/tools/testing/selftests/ftrace/config
+++ b/tools/testing/selftests/ftrace/config
@@ -4,3 +4,6 @@ CONFIG_FUNCTION_PROFILER=y
4CONFIG_TRACER_SNAPSHOT=y 4CONFIG_TRACER_SNAPSHOT=y
5CONFIG_STACK_TRACER=y 5CONFIG_STACK_TRACER=y
6CONFIG_HIST_TRIGGERS=y 6CONFIG_HIST_TRIGGERS=y
7CONFIG_PREEMPT_TRACER=y
8CONFIG_IRQSOFF_TRACER=y
9CONFIG_PREEMPTIRQ_DELAY_TEST=m
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc
index a0002563e9ee..1ad70cdaf442 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc
@@ -9,28 +9,22 @@ echo > kprobe_events
9 9
10case `uname -m` in 10case `uname -m` in
11x86_64) 11x86_64)
12 ARG2=%si 12 ARG1=%di
13 OFFS=8
14;; 13;;
15i[3456]86) 14i[3456]86)
16 ARG2=%cx 15 ARG1=%ax
17 OFFS=4
18;; 16;;
19aarch64) 17aarch64)
20 ARG2=%x1 18 ARG1=%x0
21 OFFS=8
22;; 19;;
23arm*) 20arm*)
24 ARG2=%r1 21 ARG1=%r0
25 OFFS=4
26;; 22;;
27ppc64*) 23ppc64*)
28 ARG2=%r4 24 ARG1=%r3
29 OFFS=8
30;; 25;;
31ppc*) 26ppc*)
32 ARG2=%r4 27 ARG1=%r3
33 OFFS=4
34;; 28;;
35*) 29*)
36 echo "Please implement other architecture here" 30 echo "Please implement other architecture here"
@@ -38,17 +32,17 @@ ppc*)
38esac 32esac
39 33
40: "Test get argument (1)" 34: "Test get argument (1)"
41echo "p:testprobe create_trace_kprobe arg1=+0(+0(${ARG2})):string" > kprobe_events 35echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):string" > kprobe_events
42echo 1 > events/kprobes/testprobe/enable 36echo 1 > events/kprobes/testprobe/enable
43! echo test >> kprobe_events 37echo "p:test _do_fork" >> kprobe_events
44tail -n 1 trace | grep -qe "testprobe.* arg1=\"test\"" 38grep -qe "testprobe.* arg1=\"test\"" trace
45 39
46echo 0 > events/kprobes/testprobe/enable 40echo 0 > events/kprobes/testprobe/enable
47: "Test get argument (2)" 41: "Test get argument (2)"
48echo "p:testprobe create_trace_kprobe arg1=+0(+0(${ARG2})):string arg2=+0(+${OFFS}(${ARG2})):string" > kprobe_events 42echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):string arg2=+0(${ARG1}):string" > kprobe_events
49echo 1 > events/kprobes/testprobe/enable 43echo 1 > events/kprobes/testprobe/enable
50! echo test1 test2 >> kprobe_events 44echo "p:test _do_fork" >> kprobe_events
51tail -n 1 trace | grep -qe "testprobe.* arg1=\"test1\" arg2=\"test2\"" 45grep -qe "testprobe.* arg1=\"test\" arg2=\"test\"" trace
52 46
53echo 0 > events/enable 47echo 0 > events/enable
54echo > kprobe_events 48echo > kprobe_events
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc
index 4fda01a08da4..519d2763f5d2 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc
@@ -4,7 +4,7 @@
4 4
5[ -f kprobe_events ] || exit_unsupported # this is configurable 5[ -f kprobe_events ] || exit_unsupported # this is configurable
6 6
7TARGET_FUNC=create_trace_kprobe 7TARGET_FUNC=tracefs_create_dir
8 8
9dec_addr() { # hexaddr 9dec_addr() { # hexaddr
10 printf "%d" "0x"`echo $1 | tail -c 8` 10 printf "%d" "0x"`echo $1 | tail -c 8`
diff --git a/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc b/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc
new file mode 100644
index 000000000000..cbd174334a48
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc
@@ -0,0 +1,73 @@
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: test for the preemptirqsoff tracer
4
5MOD=preemptirq_delay_test
6
7fail() {
8 reset_tracer
9 rmmod $MOD || true
10 exit_fail
11}
12
13unsup() { #msg
14 reset_tracer
15 rmmod $MOD || true
16 echo $1
17 exit_unsupported
18}
19
20modprobe $MOD || unsup "$MOD module not available"
21rmmod $MOD
22
23grep -q "preemptoff" available_tracers || unsup "preemptoff tracer not enabled"
24grep -q "irqsoff" available_tracers || unsup "irqsoff tracer not enabled"
25
26reset_tracer
27
28# Simulate preemptoff section for half a second couple of times
29echo preemptoff > current_tracer
30sleep 1
31modprobe $MOD test_mode=preempt delay=500000 || fail
32rmmod $MOD || fail
33modprobe $MOD test_mode=preempt delay=500000 || fail
34rmmod $MOD || fail
35modprobe $MOD test_mode=preempt delay=500000 || fail
36rmmod $MOD || fail
37
38cat trace
39
40# Confirm which tracer
41grep -q "tracer: preemptoff" trace || fail
42
43# Check the end of the section
44egrep -q "5.....us : <stack trace>" trace || fail
45
46# Check for 500ms of latency
47egrep -q "latency: 5..... us" trace || fail
48
49reset_tracer
50
51# Simulate irqsoff section for half a second couple of times
52echo irqsoff > current_tracer
53sleep 1
54modprobe $MOD test_mode=irq delay=500000 || fail
55rmmod $MOD || fail
56modprobe $MOD test_mode=irq delay=500000 || fail
57rmmod $MOD || fail
58modprobe $MOD test_mode=irq delay=500000 || fail
59rmmod $MOD || fail
60
61cat trace
62
63# Confirm which tracer
64grep -q "tracer: irqsoff" trace || fail
65
66# Check the end of the section
67egrep -q "5.....us : <stack trace>" trace || fail
68
69# Check for 500ms of latency
70egrep -q "latency: 5..... us" trace || fail
71
72reset_tracer
73exit 0
diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index dd0e5163f01f..03b0f551bedf 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -11,13 +11,16 @@ TEST_GEN_PROGS_x86_64 += sync_regs_test
11TEST_GEN_PROGS_x86_64 += vmx_tsc_adjust_test 11TEST_GEN_PROGS_x86_64 += vmx_tsc_adjust_test
12TEST_GEN_PROGS_x86_64 += cr4_cpuid_sync_test 12TEST_GEN_PROGS_x86_64 += cr4_cpuid_sync_test
13TEST_GEN_PROGS_x86_64 += state_test 13TEST_GEN_PROGS_x86_64 += state_test
14TEST_GEN_PROGS_x86_64 += dirty_log_test
14 15
15TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M)) 16TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(UNAME_M))
16LIBKVM += $(LIBKVM_$(UNAME_M)) 17LIBKVM += $(LIBKVM_$(UNAME_M))
17 18
18INSTALL_HDR_PATH = $(top_srcdir)/usr 19INSTALL_HDR_PATH = $(top_srcdir)/usr
19LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/ 20LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/
20CFLAGS += -O2 -g -std=gnu99 -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -I.. 21LINUX_TOOL_INCLUDE = $(top_srcdir)tools/include
22CFLAGS += -O2 -g -std=gnu99 -I$(LINUX_TOOL_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -I..
23LDFLAGS += -lpthread
21 24
22# After inclusion, $(OUTPUT) is defined and 25# After inclusion, $(OUTPUT) is defined and
23# $(TEST_GEN_PROGS) starts with $(OUTPUT)/ 26# $(TEST_GEN_PROGS) starts with $(OUTPUT)/
diff --git a/tools/testing/selftests/kvm/cr4_cpuid_sync_test.c b/tools/testing/selftests/kvm/cr4_cpuid_sync_test.c
index 8346b33c2073..11ec358bf969 100644
--- a/tools/testing/selftests/kvm/cr4_cpuid_sync_test.c
+++ b/tools/testing/selftests/kvm/cr4_cpuid_sync_test.c
@@ -23,20 +23,6 @@
23#define X86_FEATURE_OSXSAVE (1<<27) 23#define X86_FEATURE_OSXSAVE (1<<27)
24#define VCPU_ID 1 24#define VCPU_ID 1
25 25
26enum {
27 GUEST_UPDATE_CR4 = 0x1000,
28 GUEST_FAILED,
29 GUEST_DONE,
30};
31
32static void exit_to_hv(uint16_t port)
33{
34 __asm__ __volatile__("in %[port], %%al"
35 :
36 : [port]"d"(port)
37 : "rax");
38}
39
40static inline bool cr4_cpuid_is_sync(void) 26static inline bool cr4_cpuid_is_sync(void)
41{ 27{
42 int func, subfunc; 28 int func, subfunc;
@@ -64,17 +50,15 @@ static void guest_code(void)
64 set_cr4(cr4); 50 set_cr4(cr4);
65 51
66 /* verify CR4.OSXSAVE == CPUID.OSXSAVE */ 52 /* verify CR4.OSXSAVE == CPUID.OSXSAVE */
67 if (!cr4_cpuid_is_sync()) 53 GUEST_ASSERT(cr4_cpuid_is_sync());
68 exit_to_hv(GUEST_FAILED);
69 54
70 /* notify hypervisor to change CR4 */ 55 /* notify hypervisor to change CR4 */
71 exit_to_hv(GUEST_UPDATE_CR4); 56 GUEST_SYNC(0);
72 57
73 /* check again */ 58 /* check again */
74 if (!cr4_cpuid_is_sync()) 59 GUEST_ASSERT(cr4_cpuid_is_sync());
75 exit_to_hv(GUEST_FAILED);
76 60
77 exit_to_hv(GUEST_DONE); 61 GUEST_DONE();
78} 62}
79 63
80int main(int argc, char *argv[]) 64int main(int argc, char *argv[])
@@ -95,7 +79,7 @@ int main(int argc, char *argv[])
95 setbuf(stdout, NULL); 79 setbuf(stdout, NULL);
96 80
97 /* Create VM */ 81 /* Create VM */
98 vm = vm_create_default(VCPU_ID, guest_code); 82 vm = vm_create_default(VCPU_ID, 0, guest_code);
99 vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid()); 83 vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
100 run = vcpu_state(vm, VCPU_ID); 84 run = vcpu_state(vm, VCPU_ID);
101 85
@@ -104,16 +88,16 @@ int main(int argc, char *argv[])
104 88
105 if (run->exit_reason == KVM_EXIT_IO) { 89 if (run->exit_reason == KVM_EXIT_IO) {
106 switch (run->io.port) { 90 switch (run->io.port) {
107 case GUEST_UPDATE_CR4: 91 case GUEST_PORT_SYNC:
108 /* emulate hypervisor clearing CR4.OSXSAVE */ 92 /* emulate hypervisor clearing CR4.OSXSAVE */
109 vcpu_sregs_get(vm, VCPU_ID, &sregs); 93 vcpu_sregs_get(vm, VCPU_ID, &sregs);
110 sregs.cr4 &= ~X86_CR4_OSXSAVE; 94 sregs.cr4 &= ~X86_CR4_OSXSAVE;
111 vcpu_sregs_set(vm, VCPU_ID, &sregs); 95 vcpu_sregs_set(vm, VCPU_ID, &sregs);
112 break; 96 break;
113 case GUEST_FAILED: 97 case GUEST_PORT_ABORT:
114 TEST_ASSERT(false, "Guest CR4 bit (OSXSAVE) unsynchronized with CPUID bit."); 98 TEST_ASSERT(false, "Guest CR4 bit (OSXSAVE) unsynchronized with CPUID bit.");
115 break; 99 break;
116 case GUEST_DONE: 100 case GUEST_PORT_DONE:
117 goto done; 101 goto done;
118 default: 102 default:
119 TEST_ASSERT(false, "Unknown port 0x%x.", 103 TEST_ASSERT(false, "Unknown port 0x%x.",
diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
new file mode 100644
index 000000000000..0c2cdc105f96
--- /dev/null
+++ b/tools/testing/selftests/kvm/dirty_log_test.c
@@ -0,0 +1,308 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * KVM dirty page logging test
4 *
5 * Copyright (C) 2018, Red Hat, Inc.
6 */
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <unistd.h>
11#include <time.h>
12#include <pthread.h>
13#include <linux/bitmap.h>
14#include <linux/bitops.h>
15
16#include "test_util.h"
17#include "kvm_util.h"
18
19#define DEBUG printf
20
21#define VCPU_ID 1
22/* The memory slot index to track dirty pages */
23#define TEST_MEM_SLOT_INDEX 1
24/*
25 * GPA offset of the testing memory slot. Must be bigger than the
26 * default vm mem slot, which is DEFAULT_GUEST_PHY_PAGES.
27 */
28#define TEST_MEM_OFFSET (1ULL << 30) /* 1G */
29/* Size of the testing memory slot */
30#define TEST_MEM_PAGES (1ULL << 18) /* 1G for 4K pages */
31/* How many pages to dirty for each guest loop */
32#define TEST_PAGES_PER_LOOP 1024
33/* How many host loops to run (one KVM_GET_DIRTY_LOG for each loop) */
34#define TEST_HOST_LOOP_N 32
35/* Interval for each host loop (ms) */
36#define TEST_HOST_LOOP_INTERVAL 10
37
38/*
39 * Guest variables. We use these variables to share data between host
40 * and guest. There are two copies of the variables, one in host memory
41 * (which is unused) and one in guest memory. When the host wants to
42 * access these variables, it needs to call addr_gva2hva() to access the
43 * guest copy.
44 */
45uint64_t guest_random_array[TEST_PAGES_PER_LOOP];
46uint64_t guest_iteration;
47uint64_t guest_page_size;
48
49/*
50 * Writes to the first byte of a random page within the testing memory
51 * region continuously.
52 */
53void guest_code(void)
54{
55 int i = 0;
56 uint64_t volatile *array = guest_random_array;
57 uint64_t volatile *guest_addr;
58
59 while (true) {
60 for (i = 0; i < TEST_PAGES_PER_LOOP; i++) {
61 /*
62 * Write to the first 8 bytes of a random page
63 * on the testing memory region.
64 */
65 guest_addr = (uint64_t *)
66 (TEST_MEM_OFFSET +
67 (array[i] % TEST_MEM_PAGES) * guest_page_size);
68 *guest_addr = guest_iteration;
69 }
70 /* Tell the host that we need more random numbers */
71 GUEST_SYNC(1);
72 }
73}
74
75/*
76 * Host variables. These variables should only be used by the host
77 * rather than the guest.
78 */
79bool host_quit;
80
81/* Points to the test VM memory region on which we track dirty logs */
82void *host_test_mem;
83
84/* For statistics only */
85uint64_t host_dirty_count;
86uint64_t host_clear_count;
87uint64_t host_track_next_count;
88
89/*
90 * We use this bitmap to track some pages that should have its dirty
91 * bit set in the _next_ iteration. For example, if we detected the
92 * page value changed to current iteration but at the same time the
93 * page bit is cleared in the latest bitmap, then the system must
94 * report that write in the next get dirty log call.
95 */
96unsigned long *host_bmap_track;
97
98void generate_random_array(uint64_t *guest_array, uint64_t size)
99{
100 uint64_t i;
101
102 for (i = 0; i < size; i++) {
103 guest_array[i] = random();
104 }
105}
106
107void *vcpu_worker(void *data)
108{
109 int ret;
110 uint64_t loops, *guest_array, pages_count = 0;
111 struct kvm_vm *vm = data;
112 struct kvm_run *run;
113 struct guest_args args;
114
115 run = vcpu_state(vm, VCPU_ID);
116
117 /* Retrieve the guest random array pointer and cache it */
118 guest_array = addr_gva2hva(vm, (vm_vaddr_t)guest_random_array);
119
120 DEBUG("VCPU starts\n");
121
122 generate_random_array(guest_array, TEST_PAGES_PER_LOOP);
123
124 while (!READ_ONCE(host_quit)) {
125 /* Let the guest to dirty these random pages */
126 ret = _vcpu_run(vm, VCPU_ID);
127 guest_args_read(vm, VCPU_ID, &args);
128 if (run->exit_reason == KVM_EXIT_IO &&
129 args.port == GUEST_PORT_SYNC) {
130 pages_count += TEST_PAGES_PER_LOOP;
131 generate_random_array(guest_array, TEST_PAGES_PER_LOOP);
132 } else {
133 TEST_ASSERT(false,
134 "Invalid guest sync status: "
135 "exit_reason=%s\n",
136 exit_reason_str(run->exit_reason));
137 }
138 }
139
140 DEBUG("VCPU exits, dirtied %"PRIu64" pages\n", pages_count);
141
142 return NULL;
143}
144
145void vm_dirty_log_verify(unsigned long *bmap, uint64_t iteration)
146{
147 uint64_t page;
148 uint64_t volatile *value_ptr;
149
150 for (page = 0; page < TEST_MEM_PAGES; page++) {
151 value_ptr = host_test_mem + page * getpagesize();
152
153 /* If this is a special page that we were tracking... */
154 if (test_and_clear_bit(page, host_bmap_track)) {
155 host_track_next_count++;
156 TEST_ASSERT(test_bit(page, bmap),
157 "Page %"PRIu64" should have its dirty bit "
158 "set in this iteration but it is missing",
159 page);
160 }
161
162 if (test_bit(page, bmap)) {
163 host_dirty_count++;
164 /*
165 * If the bit is set, the value written onto
166 * the corresponding page should be either the
167 * previous iteration number or the current one.
168 */
169 TEST_ASSERT(*value_ptr == iteration ||
170 *value_ptr == iteration - 1,
171 "Set page %"PRIu64" value %"PRIu64
172 " incorrect (iteration=%"PRIu64")",
173 page, *value_ptr, iteration);
174 } else {
175 host_clear_count++;
176 /*
177 * If cleared, the value written can be any
178 * value smaller or equals to the iteration
179 * number. Note that the value can be exactly
180 * (iteration-1) if that write can happen
181 * like this:
182 *
183 * (1) increase loop count to "iteration-1"
184 * (2) write to page P happens (with value
185 * "iteration-1")
186 * (3) get dirty log for "iteration-1"; we'll
187 * see that page P bit is set (dirtied),
188 * and not set the bit in host_bmap_track
189 * (4) increase loop count to "iteration"
190 * (which is current iteration)
191 * (5) get dirty log for current iteration,
192 * we'll see that page P is cleared, with
193 * value "iteration-1".
194 */
195 TEST_ASSERT(*value_ptr <= iteration,
196 "Clear page %"PRIu64" value %"PRIu64
197 " incorrect (iteration=%"PRIu64")",
198 page, *value_ptr, iteration);
199 if (*value_ptr == iteration) {
200 /*
201 * This page is _just_ modified; it
202 * should report its dirtyness in the
203 * next run
204 */
205 set_bit(page, host_bmap_track);
206 }
207 }
208 }
209}
210
211void help(char *name)
212{
213 puts("");
214 printf("usage: %s [-i iterations] [-I interval] [-h]\n", name);
215 puts("");
216 printf(" -i: specify iteration counts (default: %"PRIu64")\n",
217 TEST_HOST_LOOP_N);
218 printf(" -I: specify interval in ms (default: %"PRIu64" ms)\n",
219 TEST_HOST_LOOP_INTERVAL);
220 puts("");
221 exit(0);
222}
223
224int main(int argc, char *argv[])
225{
226 pthread_t vcpu_thread;
227 struct kvm_vm *vm;
228 uint64_t volatile *psize, *iteration;
229 unsigned long *bmap, iterations = TEST_HOST_LOOP_N,
230 interval = TEST_HOST_LOOP_INTERVAL;
231 int opt;
232
233 while ((opt = getopt(argc, argv, "hi:I:")) != -1) {
234 switch (opt) {
235 case 'i':
236 iterations = strtol(optarg, NULL, 10);
237 break;
238 case 'I':
239 interval = strtol(optarg, NULL, 10);
240 break;
241 case 'h':
242 default:
243 help(argv[0]);
244 break;
245 }
246 }
247
248 TEST_ASSERT(iterations > 2, "Iteration must be bigger than zero\n");
249 TEST_ASSERT(interval > 0, "Interval must be bigger than zero");
250
251 DEBUG("Test iterations: %"PRIu64", interval: %"PRIu64" (ms)\n",
252 iterations, interval);
253
254 srandom(time(0));
255
256 bmap = bitmap_alloc(TEST_MEM_PAGES);
257 host_bmap_track = bitmap_alloc(TEST_MEM_PAGES);
258
259 vm = vm_create_default(VCPU_ID, TEST_MEM_PAGES, guest_code);
260
261 /* Add an extra memory slot for testing dirty logging */
262 vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS,
263 TEST_MEM_OFFSET,
264 TEST_MEM_SLOT_INDEX,
265 TEST_MEM_PAGES,
266 KVM_MEM_LOG_DIRTY_PAGES);
267 /* Cache the HVA pointer of the region */
268 host_test_mem = addr_gpa2hva(vm, (vm_paddr_t)TEST_MEM_OFFSET);
269
270 /* Do 1:1 mapping for the dirty track memory slot */
271 virt_map(vm, TEST_MEM_OFFSET, TEST_MEM_OFFSET,
272 TEST_MEM_PAGES * getpagesize(), 0);
273
274 vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
275
276 /* Tell the guest about the page size on the system */
277 psize = addr_gva2hva(vm, (vm_vaddr_t)&guest_page_size);
278 *psize = getpagesize();
279
280 /* Start the iterations */
281 iteration = addr_gva2hva(vm, (vm_vaddr_t)&guest_iteration);
282 *iteration = 1;
283
284 /* Start dirtying pages */
285 pthread_create(&vcpu_thread, NULL, vcpu_worker, vm);
286
287 while (*iteration < iterations) {
288 /* Give the vcpu thread some time to dirty some pages */
289 usleep(interval * 1000);
290 kvm_vm_get_dirty_log(vm, TEST_MEM_SLOT_INDEX, bmap);
291 vm_dirty_log_verify(bmap, *iteration);
292 (*iteration)++;
293 }
294
295 /* Tell the vcpu thread to quit */
296 host_quit = true;
297 pthread_join(vcpu_thread, NULL);
298
299 DEBUG("Total bits checked: dirty (%"PRIu64"), clear (%"PRIu64"), "
300 "track_next (%"PRIu64")\n", host_dirty_count, host_clear_count,
301 host_track_next_count);
302
303 free(bmap);
304 free(host_bmap_track);
305 kvm_vm_free(vm);
306
307 return 0;
308}
diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
index d32632f71ab8..bb5a25fb82c6 100644
--- a/tools/testing/selftests/kvm/include/kvm_util.h
+++ b/tools/testing/selftests/kvm/include/kvm_util.h
@@ -55,6 +55,7 @@ struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm);
55void kvm_vm_free(struct kvm_vm *vmp); 55void kvm_vm_free(struct kvm_vm *vmp);
56void kvm_vm_restart(struct kvm_vm *vmp, int perm); 56void kvm_vm_restart(struct kvm_vm *vmp, int perm);
57void kvm_vm_release(struct kvm_vm *vmp); 57void kvm_vm_release(struct kvm_vm *vmp);
58void kvm_vm_get_dirty_log(struct kvm_vm *vm, int slot, void *log);
58 59
59int kvm_memcmp_hva_gva(void *hva, 60int kvm_memcmp_hva_gva(void *hva,
60 struct kvm_vm *vm, const vm_vaddr_t gva, size_t len); 61 struct kvm_vm *vm, const vm_vaddr_t gva, size_t len);
@@ -80,6 +81,8 @@ void vm_mem_region_set_flags(struct kvm_vm *vm, uint32_t slot, uint32_t flags);
80void vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpuid, int pgd_memslot, int gdt_memslot); 81void vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpuid, int pgd_memslot, int gdt_memslot);
81vm_vaddr_t vm_vaddr_alloc(struct kvm_vm *vm, size_t sz, vm_vaddr_t vaddr_min, 82vm_vaddr_t vm_vaddr_alloc(struct kvm_vm *vm, size_t sz, vm_vaddr_t vaddr_min,
82 uint32_t data_memslot, uint32_t pgd_memslot); 83 uint32_t data_memslot, uint32_t pgd_memslot);
84void virt_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr,
85 size_t size, uint32_t pgd_memslot);
83void *addr_gpa2hva(struct kvm_vm *vm, vm_paddr_t gpa); 86void *addr_gpa2hva(struct kvm_vm *vm, vm_paddr_t gpa);
84void *addr_gva2hva(struct kvm_vm *vm, vm_vaddr_t gva); 87void *addr_gva2hva(struct kvm_vm *vm, vm_vaddr_t gva);
85vm_paddr_t addr_hva2gpa(struct kvm_vm *vm, void *hva); 88vm_paddr_t addr_hva2gpa(struct kvm_vm *vm, void *hva);
@@ -127,7 +130,8 @@ kvm_get_supported_cpuid_entry(uint32_t function)
127 return kvm_get_supported_cpuid_index(function, 0); 130 return kvm_get_supported_cpuid_index(function, 0);
128} 131}
129 132
130struct kvm_vm *vm_create_default(uint32_t vcpuid, void *guest_code); 133struct kvm_vm *vm_create_default(uint32_t vcpuid, uint64_t extra_mem_size,
134 void *guest_code);
131void vm_vcpu_add_default(struct kvm_vm *vm, uint32_t vcpuid, void *guest_code); 135void vm_vcpu_add_default(struct kvm_vm *vm, uint32_t vcpuid, void *guest_code);
132 136
133typedef void (*vmx_guest_code_t)(vm_vaddr_t vmxon_vaddr, 137typedef void (*vmx_guest_code_t)(vm_vaddr_t vmxon_vaddr,
@@ -144,4 +148,43 @@ allocate_kvm_dirty_log(struct kvm_userspace_memory_region *region);
144 148
145int vm_create_device(struct kvm_vm *vm, struct kvm_create_device *cd); 149int vm_create_device(struct kvm_vm *vm, struct kvm_create_device *cd);
146 150
151#define GUEST_PORT_SYNC 0x1000
152#define GUEST_PORT_ABORT 0x1001
153#define GUEST_PORT_DONE 0x1002
154
155static inline void __exit_to_l0(uint16_t port, uint64_t arg0, uint64_t arg1)
156{
157 __asm__ __volatile__("in %[port], %%al"
158 :
159 : [port]"d"(port), "D"(arg0), "S"(arg1)
160 : "rax");
161}
162
163/*
164 * Allows to pass three arguments to the host: port is 16bit wide,
165 * arg0 & arg1 are 64bit wide
166 */
167#define GUEST_SYNC_ARGS(_port, _arg0, _arg1) \
168 __exit_to_l0(_port, (uint64_t) (_arg0), (uint64_t) (_arg1))
169
170#define GUEST_ASSERT(_condition) do { \
171 if (!(_condition)) \
172 GUEST_SYNC_ARGS(GUEST_PORT_ABORT, \
173 "Failed guest assert: " \
174 #_condition, __LINE__); \
175 } while (0)
176
177#define GUEST_SYNC(stage) GUEST_SYNC_ARGS(GUEST_PORT_SYNC, "hello", stage)
178
179#define GUEST_DONE() GUEST_SYNC_ARGS(GUEST_PORT_DONE, 0, 0)
180
181struct guest_args {
182 uint64_t arg0;
183 uint64_t arg1;
184 uint16_t port;
185} __attribute__ ((packed));
186
187void guest_args_read(struct kvm_vm *vm, uint32_t vcpu_id,
188 struct guest_args *args);
189
147#endif /* SELFTEST_KVM_UTIL_H */ 190#endif /* SELFTEST_KVM_UTIL_H */
diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h
index ac53730b30aa..73c3933436ec 100644
--- a/tools/testing/selftests/kvm/include/test_util.h
+++ b/tools/testing/selftests/kvm/include/test_util.h
@@ -28,8 +28,6 @@ int test_seq_read(const char *path, char **bufp, size_t *sizep);
28void test_assert(bool exp, const char *exp_str, 28void test_assert(bool exp, const char *exp_str,
29 const char *file, unsigned int line, const char *fmt, ...); 29 const char *file, unsigned int line, const char *fmt, ...);
30 30
31#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
32
33#define TEST_ASSERT(e, fmt, ...) \ 31#define TEST_ASSERT(e, fmt, ...) \
34 test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__) 32 test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
35 33
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 643309d6de74..e9ba389c48db 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -14,6 +14,7 @@
14#include <sys/mman.h> 14#include <sys/mman.h>
15#include <sys/types.h> 15#include <sys/types.h>
16#include <sys/stat.h> 16#include <sys/stat.h>
17#include <linux/kernel.h>
17 18
18#define KVM_DEV_PATH "/dev/kvm" 19#define KVM_DEV_PATH "/dev/kvm"
19 20
@@ -168,6 +169,16 @@ void kvm_vm_restart(struct kvm_vm *vmp, int perm)
168 } 169 }
169} 170}
170 171
172void kvm_vm_get_dirty_log(struct kvm_vm *vm, int slot, void *log)
173{
174 struct kvm_dirty_log args = { .dirty_bitmap = log, .slot = slot };
175 int ret;
176
177 ret = ioctl(vm->fd, KVM_GET_DIRTY_LOG, &args);
178 TEST_ASSERT(ret == 0, "%s: KVM_GET_DIRTY_LOG failed: %s",
179 strerror(-ret));
180}
181
171/* Userspace Memory Region Find 182/* Userspace Memory Region Find
172 * 183 *
173 * Input Args: 184 * Input Args:
@@ -923,6 +934,39 @@ vm_vaddr_t vm_vaddr_alloc(struct kvm_vm *vm, size_t sz, vm_vaddr_t vaddr_min,
923 return vaddr_start; 934 return vaddr_start;
924} 935}
925 936
937/*
938 * Map a range of VM virtual address to the VM's physical address
939 *
940 * Input Args:
941 * vm - Virtual Machine
942 * vaddr - Virtuall address to map
943 * paddr - VM Physical Address
944 * size - The size of the range to map
945 * pgd_memslot - Memory region slot for new virtual translation tables
946 *
947 * Output Args: None
948 *
949 * Return: None
950 *
951 * Within the VM given by vm, creates a virtual translation for the
952 * page range starting at vaddr to the page range starting at paddr.
953 */
954void virt_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr,
955 size_t size, uint32_t pgd_memslot)
956{
957 size_t page_size = vm->page_size;
958 size_t npages = size / page_size;
959
960 TEST_ASSERT(vaddr + size > vaddr, "Vaddr overflow");
961 TEST_ASSERT(paddr + size > paddr, "Paddr overflow");
962
963 while (npages--) {
964 virt_pg_map(vm, vaddr, paddr, pgd_memslot);
965 vaddr += page_size;
966 paddr += page_size;
967 }
968}
969
926/* Address VM Physical to Host Virtual 970/* Address VM Physical to Host Virtual
927 * 971 *
928 * Input Args: 972 * Input Args:
@@ -1536,3 +1580,17 @@ void *addr_gva2hva(struct kvm_vm *vm, vm_vaddr_t gva)
1536{ 1580{
1537 return addr_gpa2hva(vm, addr_gva2gpa(vm, gva)); 1581 return addr_gpa2hva(vm, addr_gva2gpa(vm, gva));
1538} 1582}
1583
1584void guest_args_read(struct kvm_vm *vm, uint32_t vcpu_id,
1585 struct guest_args *args)
1586{
1587 struct kvm_run *run = vcpu_state(vm, vcpu_id);
1588 struct kvm_regs regs;
1589
1590 memset(&regs, 0, sizeof(regs));
1591 vcpu_regs_get(vm, vcpu_id, &regs);
1592
1593 args->port = run->io.port;
1594 args->arg0 = regs.rdi;
1595 args->arg1 = regs.rsi;
1596}
diff --git a/tools/testing/selftests/kvm/lib/x86.c b/tools/testing/selftests/kvm/lib/x86.c
index e38345252df5..a3122f1949a8 100644
--- a/tools/testing/selftests/kvm/lib/x86.c
+++ b/tools/testing/selftests/kvm/lib/x86.c
@@ -702,6 +702,9 @@ void vcpu_set_cpuid(struct kvm_vm *vm,
702 * 702 *
703 * Input Args: 703 * Input Args:
704 * vcpuid - The id of the single VCPU to add to the VM. 704 * vcpuid - The id of the single VCPU to add to the VM.
705 * extra_mem_pages - The size of extra memories to add (this will
706 * decide how much extra space we will need to
707 * setup the page tables using mem slot 0)
705 * guest_code - The vCPU's entry point 708 * guest_code - The vCPU's entry point
706 * 709 *
707 * Output Args: None 710 * Output Args: None
@@ -709,12 +712,23 @@ void vcpu_set_cpuid(struct kvm_vm *vm,
709 * Return: 712 * Return:
710 * Pointer to opaque structure that describes the created VM. 713 * Pointer to opaque structure that describes the created VM.
711 */ 714 */
712struct kvm_vm *vm_create_default(uint32_t vcpuid, void *guest_code) 715struct kvm_vm *vm_create_default(uint32_t vcpuid, uint64_t extra_mem_pages,
716 void *guest_code)
713{ 717{
714 struct kvm_vm *vm; 718 struct kvm_vm *vm;
719 /*
720 * For x86 the maximum page table size for a memory region
721 * will be when only 4K pages are used. In that case the
722 * total extra size for page tables (for extra N pages) will
723 * be: N/512+N/512^2+N/512^3+... which is definitely smaller
724 * than N/512*2.
725 */
726 uint64_t extra_pg_pages = extra_mem_pages / 512 * 2;
715 727
716 /* Create VM */ 728 /* Create VM */
717 vm = vm_create(VM_MODE_FLAT48PG, DEFAULT_GUEST_PHY_PAGES, O_RDWR); 729 vm = vm_create(VM_MODE_FLAT48PG,
730 DEFAULT_GUEST_PHY_PAGES + extra_pg_pages,
731 O_RDWR);
718 732
719 /* Setup guest code */ 733 /* Setup guest code */
720 kvm_vm_elf_load(vm, program_invocation_name, 0, 0); 734 kvm_vm_elf_load(vm, program_invocation_name, 0, 0);
diff --git a/tools/testing/selftests/kvm/set_sregs_test.c b/tools/testing/selftests/kvm/set_sregs_test.c
index 090fd3f19352..881419d5746e 100644
--- a/tools/testing/selftests/kvm/set_sregs_test.c
+++ b/tools/testing/selftests/kvm/set_sregs_test.c
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
36 setbuf(stdout, NULL); 36 setbuf(stdout, NULL);
37 37
38 /* Create VM */ 38 /* Create VM */
39 vm = vm_create_default(VCPU_ID, NULL); 39 vm = vm_create_default(VCPU_ID, 0, NULL);
40 40
41 vcpu_sregs_get(vm, VCPU_ID, &sregs); 41 vcpu_sregs_get(vm, VCPU_ID, &sregs);
42 sregs.apic_base = 1 << 10; 42 sregs.apic_base = 1 << 10;
diff --git a/tools/testing/selftests/kvm/state_test.c b/tools/testing/selftests/kvm/state_test.c
index ecabf25b7077..900e3e9dfb9f 100644
--- a/tools/testing/selftests/kvm/state_test.c
+++ b/tools/testing/selftests/kvm/state_test.c
@@ -21,28 +21,6 @@
21#include "vmx.h" 21#include "vmx.h"
22 22
23#define VCPU_ID 5 23#define VCPU_ID 5
24#define PORT_SYNC 0x1000
25#define PORT_ABORT 0x1001
26#define PORT_DONE 0x1002
27
28static inline void __exit_to_l0(uint16_t port, uint64_t arg0, uint64_t arg1)
29{
30 __asm__ __volatile__("in %[port], %%al"
31 :
32 : [port]"d"(port), "D"(arg0), "S"(arg1)
33 : "rax");
34}
35
36#define exit_to_l0(_port, _arg0, _arg1) \
37 __exit_to_l0(_port, (uint64_t) (_arg0), (uint64_t) (_arg1))
38
39#define GUEST_ASSERT(_condition) do { \
40 if (!(_condition)) \
41 exit_to_l0(PORT_ABORT, "Failed guest assert: " #_condition, __LINE__);\
42} while (0)
43
44#define GUEST_SYNC(stage) \
45 exit_to_l0(PORT_SYNC, "hello", stage);
46 24
47static bool have_nested_state; 25static bool have_nested_state;
48 26
@@ -137,7 +115,7 @@ void guest_code(struct vmx_pages *vmx_pages)
137 if (vmx_pages) 115 if (vmx_pages)
138 l1_guest_code(vmx_pages); 116 l1_guest_code(vmx_pages);
139 117
140 exit_to_l0(PORT_DONE, 0, 0); 118 GUEST_DONE();
141} 119}
142 120
143int main(int argc, char *argv[]) 121int main(int argc, char *argv[])
@@ -154,7 +132,7 @@ int main(int argc, char *argv[])
154 struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1); 132 struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1);
155 133
156 /* Create VM */ 134 /* Create VM */
157 vm = vm_create_default(VCPU_ID, guest_code); 135 vm = vm_create_default(VCPU_ID, 0, guest_code);
158 vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid()); 136 vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
159 run = vcpu_state(vm, VCPU_ID); 137 run = vcpu_state(vm, VCPU_ID);
160 138
@@ -178,13 +156,13 @@ int main(int argc, char *argv[])
178 memset(&regs1, 0, sizeof(regs1)); 156 memset(&regs1, 0, sizeof(regs1));
179 vcpu_regs_get(vm, VCPU_ID, &regs1); 157 vcpu_regs_get(vm, VCPU_ID, &regs1);
180 switch (run->io.port) { 158 switch (run->io.port) {
181 case PORT_ABORT: 159 case GUEST_PORT_ABORT:
182 TEST_ASSERT(false, "%s at %s:%d", (const char *) regs1.rdi, 160 TEST_ASSERT(false, "%s at %s:%d", (const char *) regs1.rdi,
183 __FILE__, regs1.rsi); 161 __FILE__, regs1.rsi);
184 /* NOT REACHED */ 162 /* NOT REACHED */
185 case PORT_SYNC: 163 case GUEST_PORT_SYNC:
186 break; 164 break;
187 case PORT_DONE: 165 case GUEST_PORT_DONE:
188 goto done; 166 goto done;
189 default: 167 default:
190 TEST_ASSERT(false, "Unknown port 0x%x.", run->io.port); 168 TEST_ASSERT(false, "Unknown port 0x%x.", run->io.port);
diff --git a/tools/testing/selftests/kvm/sync_regs_test.c b/tools/testing/selftests/kvm/sync_regs_test.c
index eae1ece3c31b..213343e5dff9 100644
--- a/tools/testing/selftests/kvm/sync_regs_test.c
+++ b/tools/testing/selftests/kvm/sync_regs_test.c
@@ -22,28 +22,11 @@
22#include "x86.h" 22#include "x86.h"
23 23
24#define VCPU_ID 5 24#define VCPU_ID 5
25#define PORT_HOST_SYNC 0x1000
26
27static void __exit_to_l0(uint16_t port, uint64_t arg0, uint64_t arg1)
28{
29 __asm__ __volatile__("in %[port], %%al"
30 :
31 : [port]"d"(port), "D"(arg0), "S"(arg1)
32 : "rax");
33}
34
35#define exit_to_l0(_port, _arg0, _arg1) \
36 __exit_to_l0(_port, (uint64_t) (_arg0), (uint64_t) (_arg1))
37
38#define GUEST_ASSERT(_condition) do { \
39 if (!(_condition)) \
40 exit_to_l0(PORT_ABORT, "Failed guest assert: " #_condition, 0);\
41} while (0)
42 25
43void guest_code(void) 26void guest_code(void)
44{ 27{
45 for (;;) { 28 for (;;) {
46 exit_to_l0(PORT_HOST_SYNC, "hello", 0); 29 GUEST_SYNC(0);
47 asm volatile ("inc %r11"); 30 asm volatile ("inc %r11");
48 } 31 }
49} 32}
@@ -111,7 +94,7 @@ int main(int argc, char *argv[])
111 } 94 }
112 95
113 /* Create VM */ 96 /* Create VM */
114 vm = vm_create_default(VCPU_ID, guest_code); 97 vm = vm_create_default(VCPU_ID, 0, guest_code);
115 98
116 run = vcpu_state(vm, VCPU_ID); 99 run = vcpu_state(vm, VCPU_ID);
117 100
diff --git a/tools/testing/selftests/kvm/vmx_tsc_adjust_test.c b/tools/testing/selftests/kvm/vmx_tsc_adjust_test.c
index fc414c284368..49bcc68b0235 100644
--- a/tools/testing/selftests/kvm/vmx_tsc_adjust_test.c
+++ b/tools/testing/selftests/kvm/vmx_tsc_adjust_test.c
@@ -62,27 +62,12 @@ struct kvm_single_msr {
62/* The virtual machine object. */ 62/* The virtual machine object. */
63static struct kvm_vm *vm; 63static struct kvm_vm *vm;
64 64
65#define exit_to_l0(_port, _arg) do_exit_to_l0(_port, (unsigned long) (_arg))
66static void do_exit_to_l0(uint16_t port, unsigned long arg)
67{
68 __asm__ __volatile__("in %[port], %%al"
69 :
70 : [port]"d"(port), "D"(arg)
71 : "rax");
72}
73
74
75#define GUEST_ASSERT(_condition) do { \
76 if (!(_condition)) \
77 exit_to_l0(PORT_ABORT, "Failed guest assert: " #_condition); \
78} while (0)
79
80static void check_ia32_tsc_adjust(int64_t max) 65static void check_ia32_tsc_adjust(int64_t max)
81{ 66{
82 int64_t adjust; 67 int64_t adjust;
83 68
84 adjust = rdmsr(MSR_IA32_TSC_ADJUST); 69 adjust = rdmsr(MSR_IA32_TSC_ADJUST);
85 exit_to_l0(PORT_REPORT, adjust); 70 GUEST_SYNC(adjust);
86 GUEST_ASSERT(adjust <= max); 71 GUEST_ASSERT(adjust <= max);
87} 72}
88 73
@@ -132,7 +117,7 @@ static void l1_guest_code(struct vmx_pages *vmx_pages)
132 117
133 check_ia32_tsc_adjust(-2 * TSC_ADJUST_VALUE); 118 check_ia32_tsc_adjust(-2 * TSC_ADJUST_VALUE);
134 119
135 exit_to_l0(PORT_DONE, 0); 120 GUEST_DONE();
136} 121}
137 122
138void report(int64_t val) 123void report(int64_t val)
@@ -152,7 +137,7 @@ int main(int argc, char *argv[])
152 exit(KSFT_SKIP); 137 exit(KSFT_SKIP);
153 } 138 }
154 139
155 vm = vm_create_default(VCPU_ID, (void *) l1_guest_code); 140 vm = vm_create_default(VCPU_ID, 0, (void *) l1_guest_code);
156 vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid()); 141 vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
157 142
158 /* Allocate VMX pages and shared descriptors (vmx_pages). */ 143 /* Allocate VMX pages and shared descriptors (vmx_pages). */
@@ -161,26 +146,26 @@ int main(int argc, char *argv[])
161 146
162 for (;;) { 147 for (;;) {
163 volatile struct kvm_run *run = vcpu_state(vm, VCPU_ID); 148 volatile struct kvm_run *run = vcpu_state(vm, VCPU_ID);
164 struct kvm_regs regs; 149 struct guest_args args;
165 150
166 vcpu_run(vm, VCPU_ID); 151 vcpu_run(vm, VCPU_ID);
167 vcpu_regs_get(vm, VCPU_ID, &regs); 152 guest_args_read(vm, VCPU_ID, &args);
168 TEST_ASSERT(run->exit_reason == KVM_EXIT_IO, 153 TEST_ASSERT(run->exit_reason == KVM_EXIT_IO,
169 "Got exit_reason other than KVM_EXIT_IO: %u (%s), rip=%lx\n", 154 "Got exit_reason other than KVM_EXIT_IO: %u (%s)\n",
170 run->exit_reason, 155 run->exit_reason,
171 exit_reason_str(run->exit_reason), regs.rip); 156 exit_reason_str(run->exit_reason));
172 157
173 switch (run->io.port) { 158 switch (args.port) {
174 case PORT_ABORT: 159 case GUEST_PORT_ABORT:
175 TEST_ASSERT(false, "%s", (const char *) regs.rdi); 160 TEST_ASSERT(false, "%s", (const char *) args.arg0);
176 /* NOT REACHED */ 161 /* NOT REACHED */
177 case PORT_REPORT: 162 case GUEST_PORT_SYNC:
178 report(regs.rdi); 163 report(args.arg1);
179 break; 164 break;
180 case PORT_DONE: 165 case GUEST_PORT_DONE:
181 goto done; 166 goto done;
182 default: 167 default:
183 TEST_ASSERT(false, "Unknown port 0x%x.", run->io.port); 168 TEST_ASSERT(false, "Unknown port 0x%x.", args.port);
184 } 169 }
185 } 170 }
186 171
diff --git a/tools/testing/selftests/mount/config b/tools/testing/selftests/mount/config
index b5d881e48548..416bd53ce982 100644
--- a/tools/testing/selftests/mount/config
+++ b/tools/testing/selftests/mount/config
@@ -1,2 +1 @@
1CONFIG_USER_NS=y CONFIG_USER_NS=y
2CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
index f8cc38afffa2..32a194e3e07a 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -46,6 +46,9 @@
46# Kselftest framework requirement - SKIP code is 4. 46# Kselftest framework requirement - SKIP code is 4.
47ksft_skip=4 47ksft_skip=4
48 48
49# Some systems don't have a ping6 binary anymore
50which ping6 > /dev/null 2>&1 && ping6=$(which ping6) || ping6=$(which ping)
51
49tests=" 52tests="
50 pmtu_vti6_exception vti6: PMTU exceptions 53 pmtu_vti6_exception vti6: PMTU exceptions
51 pmtu_vti4_exception vti4: PMTU exceptions 54 pmtu_vti4_exception vti4: PMTU exceptions
@@ -274,7 +277,7 @@ test_pmtu_vti6_exception() {
274 mtu "${ns_b}" veth_b 4000 277 mtu "${ns_b}" veth_b 4000
275 mtu "${ns_a}" vti6_a 5000 278 mtu "${ns_a}" vti6_a 5000
276 mtu "${ns_b}" vti6_b 5000 279 mtu "${ns_b}" vti6_b 5000
277 ${ns_a} ping6 -q -i 0.1 -w 2 -s 60000 ${vti6_b_addr} > /dev/null 280 ${ns_a} ${ping6} -q -i 0.1 -w 2 -s 60000 ${vti6_b_addr} > /dev/null
278 281
279 # Check that exception was created 282 # Check that exception was created
280 if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" = "" ]; then 283 if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" = "" ]; then
@@ -334,7 +337,7 @@ test_pmtu_vti4_link_add_mtu() {
334 fail=0 337 fail=0
335 338
336 min=68 339 min=68
337 max=$((65528 - 20)) 340 max=$((65535 - 20))
338 # Check invalid values first 341 # Check invalid values first
339 for v in $((min - 1)) $((max + 1)); do 342 for v in $((min - 1)) $((max + 1)); do
340 ${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10 2>/dev/null 343 ${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10 2>/dev/null
diff --git a/tools/testing/selftests/proc/.gitignore b/tools/testing/selftests/proc/.gitignore
index 74e5912e9f2e..82121a81681f 100644
--- a/tools/testing/selftests/proc/.gitignore
+++ b/tools/testing/selftests/proc/.gitignore
@@ -9,3 +9,5 @@
9/proc-uptime-001 9/proc-uptime-001
10/proc-uptime-002 10/proc-uptime-002
11/read 11/read
12/self
13/thread-self
diff --git a/tools/testing/selftests/proc/Makefile b/tools/testing/selftests/proc/Makefile
index db310eedc268..1c12c34cf85d 100644
--- a/tools/testing/selftests/proc/Makefile
+++ b/tools/testing/selftests/proc/Makefile
@@ -1,4 +1,5 @@
1CFLAGS += -Wall -O2 -Wno-unused-function 1CFLAGS += -Wall -O2 -Wno-unused-function
2CFLAGS += -D_GNU_SOURCE
2 3
3TEST_GEN_PROGS := 4TEST_GEN_PROGS :=
4TEST_GEN_PROGS += fd-001-lookup 5TEST_GEN_PROGS += fd-001-lookup
@@ -12,5 +13,7 @@ TEST_GEN_PROGS += proc-self-wchan
12TEST_GEN_PROGS += proc-uptime-001 13TEST_GEN_PROGS += proc-uptime-001
13TEST_GEN_PROGS += proc-uptime-002 14TEST_GEN_PROGS += proc-uptime-002
14TEST_GEN_PROGS += read 15TEST_GEN_PROGS += read
16TEST_GEN_PROGS += self
17TEST_GEN_PROGS += thread-self
15 18
16include ../lib.mk 19include ../lib.mk
diff --git a/tools/testing/selftests/proc/proc.h b/tools/testing/selftests/proc/proc.h
index 4e178166fd84..b7d57ea40237 100644
--- a/tools/testing/selftests/proc/proc.h
+++ b/tools/testing/selftests/proc/proc.h
@@ -6,6 +6,18 @@
6#include <stdbool.h> 6#include <stdbool.h>
7#include <stdlib.h> 7#include <stdlib.h>
8#include <string.h> 8#include <string.h>
9#include <unistd.h>
10#include <sys/syscall.h>
11
12static inline pid_t sys_getpid(void)
13{
14 return syscall(SYS_getpid);
15}
16
17static inline pid_t sys_gettid(void)
18{
19 return syscall(SYS_gettid);
20}
9 21
10static inline bool streq(const char *s1, const char *s2) 22static inline bool streq(const char *s1, const char *s2)
11{ 23{
diff --git a/tools/testing/selftests/proc/self.c b/tools/testing/selftests/proc/self.c
new file mode 100644
index 000000000000..21c15a1ffefb
--- /dev/null
+++ b/tools/testing/selftests/proc/self.c
@@ -0,0 +1,39 @@
1/*
2 * Copyright © 2018 Alexey Dobriyan <adobriyan@gmail.com>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16// Test that /proc/self gives correct TGID.
17#undef NDEBUG
18#include <assert.h>
19#include <stdio.h>
20#include <unistd.h>
21
22#include "proc.h"
23
24int main(void)
25{
26 char buf1[64], buf2[64];
27 pid_t pid;
28 ssize_t rv;
29
30 pid = sys_getpid();
31 snprintf(buf1, sizeof(buf1), "%u", pid);
32
33 rv = readlink("/proc/self", buf2, sizeof(buf2));
34 assert(rv == strlen(buf1));
35 buf2[rv] = '\0';
36 assert(streq(buf1, buf2));
37
38 return 0;
39}
diff --git a/tools/testing/selftests/proc/thread-self.c b/tools/testing/selftests/proc/thread-self.c
new file mode 100644
index 000000000000..4b23b39b7ae0
--- /dev/null
+++ b/tools/testing/selftests/proc/thread-self.c
@@ -0,0 +1,64 @@
1/*
2 * Copyright © 2018 Alexey Dobriyan <adobriyan@gmail.com>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16// Test that /proc/thread-self gives correct TGID/PID.
17#undef NDEBUG
18#include <assert.h>
19#include <sched.h>
20#include <stdio.h>
21#include <unistd.h>
22#include <sys/mman.h>
23#include <sys/wait.h>
24
25#include "proc.h"
26
27int f(void *arg)
28{
29 char buf1[64], buf2[64];
30 pid_t pid, tid;
31 ssize_t rv;
32
33 pid = sys_getpid();
34 tid = sys_gettid();
35 snprintf(buf1, sizeof(buf1), "%u/task/%u", pid, tid);
36
37 rv = readlink("/proc/thread-self", buf2, sizeof(buf2));
38 assert(rv == strlen(buf1));
39 buf2[rv] = '\0';
40 assert(streq(buf1, buf2));
41
42 if (arg)
43 exit(0);
44 return 0;
45}
46
47int main(void)
48{
49 const int PAGE_SIZE = sysconf(_SC_PAGESIZE);
50 pid_t pid;
51 void *stack;
52
53 /* main thread */
54 f((void *)0);
55
56 stack = mmap(NULL, 2 * PAGE_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
57 assert(stack != MAP_FAILED);
58 /* side thread */
59 pid = clone(f, stack + PAGE_SIZE, CLONE_THREAD|CLONE_SIGHAND|CLONE_VM, (void *)1);
60 assert(pid > 0);
61 pause();
62
63 return 0;
64}
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json
index f03763d81617..30f9b54bd666 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json
@@ -313,6 +313,54 @@
313 ] 313 ]
314 }, 314 },
315 { 315 {
316 "id": "6aaf",
317 "name": "Add police actions with conform-exceed control pass/pipe [with numeric values]",
318 "category": [
319 "actions",
320 "police"
321 ],
322 "setup": [
323 [
324 "$TC actions flush action police",
325 0,
326 1,
327 255
328 ]
329 ],
330 "cmdUnderTest": "$TC actions add action police rate 3mbit burst 250k conform-exceed 0/3 index 1",
331 "expExitCode": "0",
332 "verifyCmd": "$TC actions get action police index 1",
333 "matchPattern": "action order [0-9]*: police 0x1 rate 3Mbit burst 250Kb mtu 2Kb action pass/pipe",
334 "matchCount": "1",
335 "teardown": [
336 "$TC actions flush action police"
337 ]
338 },
339 {
340 "id": "29b1",
341 "name": "Add police actions with conform-exceed control <invalid>/drop",
342 "category": [
343 "actions",
344 "police"
345 ],
346 "setup": [
347 [
348 "$TC actions flush action police",
349 0,
350 1,
351 255
352 ]
353 ],
354 "cmdUnderTest": "$TC actions add action police rate 3mbit burst 250k conform-exceed 10/drop index 1",
355 "expExitCode": "255",
356 "verifyCmd": "$TC actions ls action police",
357 "matchPattern": "action order [0-9]*: police 0x1 rate 3Mbit burst 250Kb mtu 2Kb action ",
358 "matchCount": "0",
359 "teardown": [
360 "$TC actions flush action police"
361 ]
362 },
363 {
316 "id": "c26f", 364 "id": "c26f",
317 "name": "Add police action with invalid peakrate value", 365 "name": "Add police action with invalid peakrate value",
318 "category": [ 366 "category": [
diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftests/vDSO/Makefile
index f5d7a7851e21..9e03d61f52fd 100644
--- a/tools/testing/selftests/vDSO/Makefile
+++ b/tools/testing/selftests/vDSO/Makefile
@@ -1,6 +1,14 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2include ../lib.mk 2include ../lib.mk
3 3
4uname_M := $(shell uname -m 2>/dev/null || echo not)
5ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
6
7TEST_GEN_PROGS := $(OUTPUT)/vdso_test
8ifeq ($(ARCH),x86)
9TEST_GEN_PROGS += $(OUTPUT)/vdso_standalone_test_x86
10endif
11
4ifndef CROSS_COMPILE 12ifndef CROSS_COMPILE
5CFLAGS := -std=gnu99 13CFLAGS := -std=gnu99
6CFLAGS_vdso_standalone_test_x86 := -nostdlib -fno-asynchronous-unwind-tables -fno-stack-protector 14CFLAGS_vdso_standalone_test_x86 := -nostdlib -fno-asynchronous-unwind-tables -fno-stack-protector
@@ -8,14 +16,11 @@ ifeq ($(CONFIG_X86_32),y)
8LDLIBS += -lgcc_s 16LDLIBS += -lgcc_s
9endif 17endif
10 18
11TEST_PROGS := $(OUTPUT)/vdso_test $(OUTPUT)/vdso_standalone_test_x86 19all: $(TEST_GEN_PROGS)
12
13all: $(TEST_PROGS)
14$(OUTPUT)/vdso_test: parse_vdso.c vdso_test.c 20$(OUTPUT)/vdso_test: parse_vdso.c vdso_test.c
15$(OUTPUT)/vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c 21$(OUTPUT)/vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c
16 $(CC) $(CFLAGS) $(CFLAGS_vdso_standalone_test_x86) \ 22 $(CC) $(CFLAGS) $(CFLAGS_vdso_standalone_test_x86) \
17 vdso_standalone_test_x86.c parse_vdso.c \ 23 vdso_standalone_test_x86.c parse_vdso.c \
18 -o $@ 24 -o $@
19 25
20EXTRA_CLEAN := $(TEST_PROGS)
21endif 26endif
diff --git a/tools/testing/selftests/vDSO/vdso_test.c b/tools/testing/selftests/vDSO/vdso_test.c
index 2df26bd0099c..eda53f833d8e 100644
--- a/tools/testing/selftests/vDSO/vdso_test.c
+++ b/tools/testing/selftests/vDSO/vdso_test.c
@@ -15,6 +15,8 @@
15#include <sys/auxv.h> 15#include <sys/auxv.h>
16#include <sys/time.h> 16#include <sys/time.h>
17 17
18#include "../kselftest.h"
19
18extern void *vdso_sym(const char *version, const char *name); 20extern void *vdso_sym(const char *version, const char *name);
19extern void vdso_init_from_sysinfo_ehdr(uintptr_t base); 21extern void vdso_init_from_sysinfo_ehdr(uintptr_t base);
20extern void vdso_init_from_auxv(void *auxv); 22extern void vdso_init_from_auxv(void *auxv);
@@ -37,7 +39,7 @@ int main(int argc, char **argv)
37 unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); 39 unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
38 if (!sysinfo_ehdr) { 40 if (!sysinfo_ehdr) {
39 printf("AT_SYSINFO_EHDR is not present!\n"); 41 printf("AT_SYSINFO_EHDR is not present!\n");
40 return 0; 42 return KSFT_SKIP;
41 } 43 }
42 44
43 vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR)); 45 vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR));
@@ -48,7 +50,7 @@ int main(int argc, char **argv)
48 50
49 if (!gtod) { 51 if (!gtod) {
50 printf("Could not find %s\n", name); 52 printf("Could not find %s\n", name);
51 return 1; 53 return KSFT_SKIP;
52 } 54 }
53 55
54 struct timeval tv; 56 struct timeval tv;
@@ -59,6 +61,7 @@ int main(int argc, char **argv)
59 (long long)tv.tv_sec, (long long)tv.tv_usec); 61 (long long)tv.tv_sec, (long long)tv.tv_usec);
60 } else { 62 } else {
61 printf("%s failed\n", name); 63 printf("%s failed\n", name);
64 return KSFT_FAIL;
62 } 65 }
63 66
64 return 0; 67 return 0;
diff --git a/tools/testing/selftests/vm/.gitignore b/tools/testing/selftests/vm/.gitignore
index 342c7bc9dc8c..af5ff83f6d7f 100644
--- a/tools/testing/selftests/vm/.gitignore
+++ b/tools/testing/selftests/vm/.gitignore
@@ -1,6 +1,7 @@
1hugepage-mmap 1hugepage-mmap
2hugepage-shm 2hugepage-shm
3map_hugetlb 3map_hugetlb
4map_populate
4thuge-gen 5thuge-gen
5compaction_test 6compaction_test
6mlock2-tests 7mlock2-tests
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index fdefa2295ddc..9881876d2aa0 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -12,6 +12,7 @@ TEST_GEN_FILES += gup_benchmark
12TEST_GEN_FILES += hugepage-mmap 12TEST_GEN_FILES += hugepage-mmap
13TEST_GEN_FILES += hugepage-shm 13TEST_GEN_FILES += hugepage-shm
14TEST_GEN_FILES += map_hugetlb 14TEST_GEN_FILES += map_hugetlb
15TEST_GEN_FILES += map_populate
15TEST_GEN_FILES += mlock-random-test 16TEST_GEN_FILES += mlock-random-test
16TEST_GEN_FILES += mlock2-tests 17TEST_GEN_FILES += mlock2-tests
17TEST_GEN_FILES += on-fault-limit 18TEST_GEN_FILES += on-fault-limit
diff --git a/tools/testing/selftests/vm/map_populate.c b/tools/testing/selftests/vm/map_populate.c
new file mode 100644
index 000000000000..6b8aeaa0bf7a
--- /dev/null
+++ b/tools/testing/selftests/vm/map_populate.c
@@ -0,0 +1,113 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2018 Dmitry Safonov, Arista Networks
4 *
5 * MAP_POPULATE | MAP_PRIVATE should COW VMA pages.
6 */
7
8#define _GNU_SOURCE
9#include <errno.h>
10#include <fcntl.h>
11#include <sys/mman.h>
12#include <sys/socket.h>
13#include <sys/types.h>
14#include <sys/wait.h>
15#include <stdio.h>
16#include <stdlib.h>
17#include <string.h>
18#include <unistd.h>
19
20#ifndef MMAP_SZ
21#define MMAP_SZ 4096
22#endif
23
24#define BUG_ON(condition, description) \
25 do { \
26 if (condition) { \
27 fprintf(stderr, "[FAIL]\t%s:%d\t%s:%s\n", __func__, \
28 __LINE__, (description), strerror(errno)); \
29 exit(1); \
30 } \
31 } while (0)
32
33static int parent_f(int sock, unsigned long *smap, int child)
34{
35 int status, ret;
36
37 ret = read(sock, &status, sizeof(int));
38 BUG_ON(ret <= 0, "read(sock)");
39
40 *smap = 0x22222BAD;
41 ret = msync(smap, MMAP_SZ, MS_SYNC);
42 BUG_ON(ret, "msync()");
43
44 ret = write(sock, &status, sizeof(int));
45 BUG_ON(ret <= 0, "write(sock)");
46
47 waitpid(child, &status, 0);
48 BUG_ON(!WIFEXITED(status), "child in unexpected state");
49
50 return WEXITSTATUS(status);
51}
52
53static int child_f(int sock, unsigned long *smap, int fd)
54{
55 int ret, buf = 0;
56
57 smap = mmap(0, MMAP_SZ, PROT_READ | PROT_WRITE,
58 MAP_PRIVATE | MAP_POPULATE, fd, 0);
59 BUG_ON(smap == MAP_FAILED, "mmap()");
60
61 BUG_ON(*smap != 0xdeadbabe, "MAP_PRIVATE | MAP_POPULATE changed file");
62
63 ret = write(sock, &buf, sizeof(int));
64 BUG_ON(ret <= 0, "write(sock)");
65
66 ret = read(sock, &buf, sizeof(int));
67 BUG_ON(ret <= 0, "read(sock)");
68
69 BUG_ON(*smap == 0x22222BAD, "MAP_POPULATE didn't COW private page");
70 BUG_ON(*smap != 0xdeadbabe, "mapping was corrupted");
71
72 return 0;
73}
74
75int main(int argc, char **argv)
76{
77 int sock[2], child, ret;
78 FILE *ftmp;
79 unsigned long *smap;
80
81 ftmp = tmpfile();
82 BUG_ON(ftmp == 0, "tmpfile()");
83
84 ret = ftruncate(fileno(ftmp), MMAP_SZ);
85 BUG_ON(ret, "ftruncate()");
86
87 smap = mmap(0, MMAP_SZ, PROT_READ | PROT_WRITE,
88 MAP_SHARED, fileno(ftmp), 0);
89 BUG_ON(smap == MAP_FAILED, "mmap()");
90
91 *smap = 0xdeadbabe;
92 /* Probably unnecessary, but let it be. */
93 ret = msync(smap, MMAP_SZ, MS_SYNC);
94 BUG_ON(ret, "msync()");
95
96 ret = socketpair(PF_LOCAL, SOCK_SEQPACKET, 0, sock);
97 BUG_ON(ret, "socketpair()");
98
99 child = fork();
100 BUG_ON(child == -1, "fork()");
101
102 if (child) {
103 ret = close(sock[0]);
104 BUG_ON(ret, "close()");
105
106 return parent_f(sock[1], smap, child);
107 }
108
109 ret = close(sock[1]);
110 BUG_ON(ret, "close()");
111
112 return child_f(sock[0], smap, fileno(ftmp));
113}
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
index 88cbe5575f0c..584a91ae4a8f 100755
--- a/tools/testing/selftests/vm/run_vmtests
+++ b/tools/testing/selftests/vm/run_vmtests
@@ -168,6 +168,17 @@ else
168fi 168fi
169 169
170echo "--------------------" 170echo "--------------------"
171echo "running map_populate"
172echo "--------------------"
173./map_populate
174if [ $? -ne 0 ]; then
175 echo "[FAIL]"
176 exitcode=1
177else
178 echo "[PASS]"
179fi
180
181echo "--------------------"
171echo "running mlock2-tests" 182echo "running mlock2-tests"
172echo "--------------------" 183echo "--------------------"
173./mlock2-tests 184./mlock2-tests
diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c
index 30cb0a0713ff..37908a83ddc2 100644
--- a/tools/vm/page-types.c
+++ b/tools/vm/page-types.c
@@ -159,12 +159,6 @@ static const char * const page_flag_names[] = {
159}; 159};
160 160
161 161
162static const char * const debugfs_known_mountpoints[] = {
163 "/sys/kernel/debug",
164 "/debug",
165 0,
166};
167
168/* 162/*
169 * data structures 163 * data structures
170 */ 164 */
diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c
index f82c2eaa859d..334b16db0ebb 100644
--- a/tools/vm/slabinfo.c
+++ b/tools/vm/slabinfo.c
@@ -30,8 +30,8 @@ struct slabinfo {
30 int alias; 30 int alias;
31 int refs; 31 int refs;
32 int aliases, align, cache_dma, cpu_slabs, destroy_by_rcu; 32 int aliases, align, cache_dma, cpu_slabs, destroy_by_rcu;
33 int hwcache_align, object_size, objs_per_slab; 33 unsigned int hwcache_align, object_size, objs_per_slab;
34 int sanity_checks, slab_size, store_user, trace; 34 unsigned int sanity_checks, slab_size, store_user, trace;
35 int order, poison, reclaim_account, red_zone; 35 int order, poison, reclaim_account, red_zone;
36 unsigned long partial, objects, slabs, objects_partial, objects_total; 36 unsigned long partial, objects, slabs, objects_partial, objects_total;
37 unsigned long alloc_fastpath, alloc_slowpath; 37 unsigned long alloc_fastpath, alloc_slowpath;