History

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

Pull perf updates from Ingo Molnar: "Kernel side changes: - Improve accuracy of perf/sched clock on x86. (Adrian Hunter) - Intel DS and BTS updates. (Alexander Shishkin) - Intel cstate PMU support. (Kan Liang) - Add group read support to perf_event_read(). (Peter Zijlstra) - Branch call hardware sampling support, implemented on x86 and PowerPC. (Stephane Eranian) - Event groups transactional interface enhancements. (Sukadev Bhattiprolu) - Enable proper x86/intel/uncore PMU support on multi-segment PCI systems. (Taku Izumi) - ... misc fixes and cleanups. The perf tooling team was very busy again with 200+ commits, the full diff doesn't fit into lkml size limits. Here's an (incomplete) list of the tooling highlights: New features: - Change the default event used in all tools (record/top): use the most precise "cycles" hw counter available, i.e. when the user doesn't specify any event, it will try using cycles:ppp, cycles:pp, etc and fall back transparently until it finds a working counter. (Arnaldo Carvalho de Melo) - Integration of perf with eBPF that, given an eBPF .c source file (or .o file built for the 'bpf' target with clang), will get it automatically built, validated and loaded into the kernel via the sys_bpf syscall, which can then be used and seen using 'perf trace' and other tools. (Wang Nan) Various user interface improvements: - Automatic pager invocation on long help output. (Namhyung Kim) - Search for more options when passing args to -h, e.g.: (Arnaldo Carvalho de Melo) $ perf report -h interface Usage: perf report [<options>] --gtk Use the GTK2 interface --stdio Use the stdio interface --tui Use the TUI interface - Show ordered command line options when -h is used or when an unknown option is specified. (Arnaldo Carvalho de Melo) - If options are passed after -h, show just its descriptions, not all options. (Arnaldo Carvalho de Melo) - Implement column based horizontal scrolling in the hists browser (top, report), making it possible to use the TUI for things like 'perf mem report' where there are many more columns than can fit in a terminal. (Arnaldo Carvalho de Melo) - Enhance the error reporting of tracepoint event parsing, e.g.: $ oldperf record -e sched:sched_switc usleep 1 event syntax error: 'sched:sched_switc' \___ unknown tracepoint Run 'perf list' for a list of valid events Now we get the much nicer: $ perf record -e sched:sched_switc ls event syntax error: 'sched:sched_switc' \___ can't access trace events Error: No permissions to read /sys/kernel/debug/tracing/events/sched/sched_switc Hint: Try 'sudo mount -o remount,mode=755 /sys/kernel/debug' And after we have those mount point permissions fixed: $ perf record -e sched:sched_switc ls event syntax error: 'sched:sched_switc' \___ unknown tracepoint Error: File /sys/kernel/debug/tracing/events/sched/sched_switc not found. Hint: Perhaps this kernel misses some CONFIG_ setting to enable this feature?. I.e. basically now the event parsing routing uses the strerror_open() routines introduced by and used in 'perf trace' work. (Jiri Olsa) - Fail properly when pattern matching fails to find a tracepoint, i.e. '-e non:existent' was being correctly handled, with a proper error message about that not being a valid event, but '-e non:existent*' wasn't, fix it. (Jiri Olsa) - Do event name substring search as last resort in 'perf list'. (Arnaldo Carvalho de Melo) E.g.: # perf list clock List of pre-defined events (to be used in -e): cpu-clock [Software event] task-clock [Software event] uncore_cbox_0/clockticks/ [Kernel PMU event] uncore_cbox_1/clockticks/ [Kernel PMU event] kvm:kvm_pvclock_update [Tracepoint event] kvm:kvm_update_master_clock [Tracepoint event] power:clock_disable [Tracepoint event] power:clock_enable [Tracepoint event] power:clock_set_rate [Tracepoint event] syscalls:sys_enter_clock_adjtime [Tracepoint event] syscalls:sys_enter_clock_getres [Tracepoint event] syscalls:sys_enter_clock_gettime [Tracepoint event] syscalls:sys_enter_clock_nanosleep [Tracepoint event] syscalls:sys_enter_clock_settime [Tracepoint event] syscalls:sys_exit_clock_adjtime [Tracepoint event] syscalls:sys_exit_clock_getres [Tracepoint event] syscalls:sys_exit_clock_gettime [Tracepoint event] syscalls:sys_exit_clock_nanosleep [Tracepoint event] syscalls:sys_exit_clock_settime [Tracepoint event] Intel PT hardware tracing enhancements: - Accept a zero --itrace period, meaning "as often as possible". In the case of Intel PT that is the same as a period of 1 and a unit of 'instructions' (i.e. --itrace=i1i). (Adrian Hunter) - Harmonize itrace's synthesized callchains with the existing --max-stack tool option. (Adrian Hunter) - Allow time to be displayed in nanoseconds in 'perf script'. (Adrian Hunter) - Fix potential infinite loop when handling Intel PT timestamps. (Adrian Hunter) - Slighly improve Intel PT debug logging. (Adrian Hunter) - Warn when AUX data has been lost, just like when processing PERF_RECORD_LOST. (Adrian Hunter) - Further document export-to-postgresql.py script. (Adrian Hunter) - Add option to synthesize branch stack from auxtrace data. (Adrian Hunter) Misc notable changes: - Switch the default callchain output mode to 'graph,0.5,caller', to make it look like the default for other tools, reducing the learning curve for people used to 'caller' based viewing. (Arnaldo Carvalho de Melo) - various call chain usability enhancements. (Namhyung Kim) - Introduce the 'P' event modifier, meaning 'max precision level, please', i.e.: $ perf record -e cycles:P usleep 1 Is now similar to: $ perf record usleep 1 Useful, for instance, when specifying multiple events. (Jiri Olsa) - Add 'socket' sort entry, to sort by the processor socket in 'perf top' and 'perf report'. (Kan Liang) - Introduce --socket-filter to 'perf report', for filtering by processor socket. (Kan Liang) - Add new "Zoom into Processor Socket" operation in the perf hists browser, used in 'perf top' and 'perf report'. (Kan Liang) - Allow probing on kmodules without DWARF. (Masami Hiramatsu) - Fix 'perf probe -l' for probes added to kernel module functions. (Masami Hiramatsu) - Preparatory work for the 'perf stat record' feature that will allow generating perf.data files with counting data in addition to the sampling mode we have now (Jiri Olsa) - Update libtraceevent KVM plugin. (Paolo Bonzini) - ... plus lots of other enhancements that I failed to list properly, by: Adrian Hunter, Alexander Shishkin, Andi Kleen, Andrzej Hajda, Arnaldo Carvalho de Melo, Dima Kogan, Don Zickus, Geliang Tang, He Kuang, Huaitong Han, Ingo Molnar, Jan Stancek, Jiri Olsa, Kan Liang, Kirill Tkhai, Masami Hiramatsu, Matt Fleming, Namhyung Kim, Paolo Bonzini, Peter Zijlstra, Rabin Vincent, Scott Wood, Stephane Eranian, Sukadev Bhattiprolu, Taku Izumi, Vaishali Thakkar, Wang Nan, Yang Shi and Yunlong Song" * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (260 commits) perf unwind: Pass symbol source to libunwind tools build: Fix libiberty feature detection perf tools: Compile scriptlets to BPF objects when passing '.c' to --event perf record: Add clang options for compiling BPF scripts perf bpf: Attach eBPF filter to perf event perf tools: Make sure fixdep is built before libbpf perf script: Enable printing of branch stack perf trace: Add cmd string table to decode sys_bpf first arg perf bpf: Collect perf_evsel in BPF object files perf tools: Load eBPF object into kernel perf tools: Create probe points for BPF programs perf tools: Enable passing bpf object file to --event perf ebpf: Add the libbpf glue perf tools: Make perf depend on libbpf perf symbols: Fix endless loop in dso__split_kallsyms_for_kcore perf tools: Enable pre-event inherit setting by config terms perf symbols: we can now read separate debug-info files based on a build ID perf symbols: Fix type error when reading a build-id perf tools: Search for more options when passing args to -h perf stat: Cache aggregated map entries in extra cpumap ...

Linus Torvalds committed 11 years ago

Commit b02ac6b2 parents 105ff3c bebd23a215 files · +9951 −2026Browse files

Unified · Split

215 files
  1. arch/powerpc/perf/core-book3s.c +30 −6
  2. arch/powerpc/perf/hv-24x7.c +164 −2
  3. arch/powerpc/perf/power8-pmu.c +3 −0
  4. arch/s390/kernel/perf_cpum_cf.c +30 −5
  5. arch/sparc/kernel/perf_event.c +25 −7
  6. arch/x86/kernel/cpu/Makefile +1 −0
  7. arch/x86/kernel/cpu/intel_cacheinfo.c +4 −4
  8. arch/x86/kernel/cpu/perf_event.c +33 −6
  9. arch/x86/kernel/cpu/perf_event.h +1 −1
  10. arch/x86/kernel/cpu/perf_event_intel_bts.c +13 −0
  11. arch/x86/kernel/cpu/perf_event_intel_cstate.c +694 −0
  12. arch/x86/kernel/cpu/perf_event_intel_ds.c +34 −6
  13. arch/x86/kernel/cpu/perf_event_intel_lbr.c +6 −2
  14. arch/x86/kernel/cpu/perf_event_intel_pt.c +4 −3
  15. arch/x86/kernel/cpu/perf_event_intel_uncore.c +58 −3
  16. arch/x86/kernel/cpu/perf_event_intel_uncore.h +11 −1
  17. arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c +13 −3
  18. arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c +25 −9
  19. arch/x86/kernel/tsc.c +22 −13
  20. arch/x86/lib/x86-opcode-map.txt +19 −5
  21. include/linux/perf_event.h +103 −17
  22. include/uapi/linux/perf_event.h +4 −2
  23. kernel/events/core.c +165 −59
  24. tools/build/.gitignore +1 −0
  25. tools/build/Build +1 −0
  26. tools/build/Build.include +14 −3
  27. tools/build/Documentation/Build.txt +39 −13
  28. tools/build/Makefile +43 −0
  29. tools/build/Makefile.build +7 −0
  30. tools/build/Makefile.feature +9 −6
  31. tools/build/Makefile.include +10 −0
  32. tools/build/feature/Makefile +2 −2
  33. tools/build/fixdep.c +168 −0
  34. tools/build/tests/ex/Build +1 −0
  35. tools/build/tests/ex/Makefile +8 −5
  36. tools/build/tests/ex/ex.c +2 −0
  37. tools/build/tests/ex/inc.c +8 −0
  38. tools/build/tests/run.sh +27 −0
  39. tools/include/linux/compiler.h +24 −8
  40. tools/include/linux/err.h +49 −0
  41. tools/include/linux/filter.h +231 −0
  42. tools/lib/api/Build +1 −0
  43. tools/lib/api/Makefile +4 −2
  44. tools/lib/api/cpu.c +18 −0
  45. tools/lib/api/cpu.h +6 −0
  46. tools/lib/api/fs/Build +1 −3
  47. tools/lib/api/fs/debugfs.c +0 −129
  48. tools/lib/api/fs/debugfs.h +0 −23
  49. tools/lib/api/fs/findfs.c +0 −63
  50. tools/lib/api/fs/findfs.h +0 −23
  51. tools/lib/api/fs/fs.c +153 −12
  52. tools/lib/api/fs/fs.h +23 −7
  53. tools/lib/api/fs/tracefs.c +0 −78
  54. tools/lib/api/fs/tracefs.h +0 −21
  55. tools/lib/api/fs/tracing_path.c +135 −0
  56. tools/lib/api/fs/tracing_path.h +16 −0
  57. tools/lib/bpf/Makefile +7 −4
  58. tools/lib/lockdep/Makefile +4 −2
  59. tools/lib/symbol/kallsyms.c +6 −0
  60. tools/lib/symbol/kallsyms.h +3 −1
  61. tools/lib/traceevent/event-parse.c +56 −4
  62. tools/lib/traceevent/event-parse.h +1 −0
  63. tools/lib/traceevent/plugin_kvm.c +17 −8
  64. tools/perf/Documentation/intel-pt.txt +44 −0
  65. tools/perf/Documentation/itrace.txt +4 −0
  66. tools/perf/Documentation/perf-bench.txt +19 −35
  67. tools/perf/Documentation/perf-inject.txt +3 −0
  68. tools/perf/Documentation/perf-list.txt +3 −0
  69. tools/perf/Documentation/perf-record.txt +14 −2
  70. tools/perf/Documentation/perf-report.txt +32 −16
  71. tools/perf/Documentation/perf-script.txt +15 −2
  72. tools/perf/Documentation/perf-stat.txt +3 −2
  73. tools/perf/Documentation/perf-top.txt +3 −2
  74. tools/perf/Documentation/perf.txt +8 −0
  75. tools/perf/MANIFEST +5 −0
  76. tools/perf/Makefile.perf +35 −18
  77. tools/perf/arch/common.c +4 −6
  78. tools/perf/arch/common.h +2 −2
  79. tools/perf/arch/x86/Build +1 −1
  80. tools/perf/arch/x86/Makefile +1 −0
  81. tools/perf/arch/x86/include/arch-tests.h +19 −0
  82. tools/perf/arch/x86/tests/Build +8 −2
  83. tools/perf/arch/x86/tests/arch-tests.c +34 −0
  84. tools/perf/arch/x86/tests/dwarf-unwind.c +1 −0
  85. tools/perf/arch/x86/tests/gen-insn-x86-dat.awk +75 −0
  86. tools/perf/arch/x86/tests/gen-insn-x86-dat.sh +43 −0
  87. tools/perf/arch/x86/tests/insn-x86-dat-32.c +658 −0
  88. tools/perf/arch/x86/tests/insn-x86-dat-64.c +768 −0
  89. tools/perf/arch/x86/tests/insn-x86-dat-src.c +877 −0
  90. tools/perf/arch/x86/tests/insn-x86.c +185 −0
  91. tools/perf/arch/x86/tests/intel-cqm.c +124 −0
  92. tools/perf/arch/x86/tests/perf-time-to-tsc.c +3 −1
  93. tools/perf/arch/x86/tests/rdpmc.c +2 −5
  94. tools/perf/arch/x86/util/dwarf-regs.c +88 −34
  95. tools/perf/arch/x86/util/intel-pt.c +47 −8
  96. tools/perf/bench/Build +1 −1
  97. tools/perf/bench/mem-functions.c +379 −0
  98. tools/perf/bench/mem-memcpy.c +0 −434
  99. tools/perf/bench/numa.c +2 −2
  100. tools/perf/bench/sched-messaging.c +5 −5
  101. tools/perf/builtin-annotate.c +1 −1
  102. tools/perf/builtin-bench.c +7 −7
  103. tools/perf/builtin-evlist.c +2 −2
  104. tools/perf/builtin-help.c +1 −1
  105. tools/perf/builtin-inject.c +125 −2
  106. tools/perf/builtin-kmem.c +1 −1
  107. tools/perf/builtin-kvm.c +0 −1
  108. tools/perf/builtin-list.c +17 −3
  109. tools/perf/builtin-probe.c +131 −16
  110. tools/perf/builtin-record.c +40 −16
  111. tools/perf/builtin-report.c +55 −10
  112. tools/perf/builtin-sched.c +2 −2
  113. tools/perf/builtin-script.c +104 −9
  114. tools/perf/builtin-stat.c +82 −11
  115. tools/perf/builtin-top.c +50 −9
  116. tools/perf/builtin-trace.c +21 −10
  117. tools/perf/config/Makefile +22 −1
  118. tools/perf/perf.c +25 −5
  119. tools/perf/python/twatch.py +20 −3
  120. tools/perf/scripts/python/export-to-postgresql.py +221 −0
  121. tools/perf/tests/Build +1 −3
  122. tools/perf/tests/bpf-script-example.c +44 −0
  123. tools/perf/tests/builtin-test.c +36 −40
  124. tools/perf/tests/code-reading.c +61 −15
  125. tools/perf/tests/dwarf-unwind.c +4 −0
  126. tools/perf/tests/evsel-tp-sched.c +8 −2
  127. tools/perf/tests/hists_filter.c +45 −10
  128. tools/perf/tests/make +3 −1
  129. tools/perf/tests/mmap-basic.c +2 −1
  130. tools/perf/tests/openat-syscall-all-cpus.c +6 −7
  131. tools/perf/tests/openat-syscall-tp-fields.c +3 −2
  132. tools/perf/tests/openat-syscall.c +6 −7
  133. tools/perf/tests/parse-events.c +33 −16
  134. tools/perf/tests/tests.h +7 −3
  135. tools/perf/tests/topology.c +115 −0
  136. tools/perf/tests/vmlinux-kallsyms.c +2 −2
  137. tools/perf/trace/strace/groups/file +2 −0
  138. tools/perf/ui/browser.c +14 −0
  139. tools/perf/ui/browser.h +1 −1
  140. tools/perf/ui/browsers/annotate.c +7 −7
  141. tools/perf/ui/browsers/hists.c +95 −25
  142. tools/perf/ui/browsers/map.c +1 −1
  143. tools/perf/ui/browsers/scripts.c +1 −1
  144. tools/perf/ui/hist.c +8 −8
  145. tools/perf/ui/tui/setup.c +4 −4
  146. tools/perf/util/Build +2 −0
  147. tools/perf/util/annotate.c +4 −1
  148. tools/perf/util/annotate.h +1 −1
  149. tools/perf/util/auxtrace.c +23 −1
  150. tools/perf/util/auxtrace.h +4 −0
  151. tools/perf/util/bpf-loader.c +352 −0
  152. tools/perf/util/bpf-loader.h +85 −0
  153. tools/perf/util/callchain.c +39 −3
  154. tools/perf/util/callchain.h +26 −0
  155. tools/perf/util/cpumap.c +52 −45
  156. tools/perf/util/cpumap.h +8 −2
  157. tools/perf/util/env.c +86 −0
  158. tools/perf/util/env.h +44 −0
  159. tools/perf/util/event.c +15 −7
  160. tools/perf/util/event.h +6 −0
  161. tools/perf/util/evlist.c +43 −4
  162. tools/perf/util/evlist.h +5 −0
  163. tools/perf/util/evsel.c +45 −5
  164. tools/perf/util/evsel.h +8 −2
  165. tools/perf/util/header.c +93 −43
  166. tools/perf/util/header.h +1 −26
  167. tools/perf/util/hist.c +56 −3
  168. tools/perf/util/hist.h +7 −1
  169. tools/perf/util/include/dwarf-regs.h +8 −0
  170. tools/perf/util/intel-pt-decoder/Build +12 −1
  171. tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +2 −2
  172. tools/perf/util/intel-pt-decoder/intel-pt-log.c +11 −10
  173. tools/perf/util/intel-pt-decoder/intel-pt-log.h +32 −6
  174. tools/perf/util/intel-pt-decoder/x86-opcode-map.txt +19 −5
  175. tools/perf/util/intel-pt.c +237 −29
  176. tools/perf/util/machine.c +15 −14
  177. tools/perf/util/machine.h +8 −1
  178. tools/perf/util/map.c +14 −7
  179. tools/perf/util/map.h +2 −0
  180. tools/perf/util/parse-branch-options.c +1 −0
  181. tools/perf/util/parse-events.c +334 −40
  182. tools/perf/util/parse-events.h +15 −1
  183. tools/perf/util/parse-events.l +10 −2
  184. tools/perf/util/parse-events.y +69 −13
  185. tools/perf/util/parse-options.c +133 −23
  186. tools/perf/util/parse-options.h +5 −0
  187. tools/perf/util/pmu.c +17 −25
  188. tools/perf/util/probe-event.c +122 −112
  189. tools/perf/util/probe-event.h +11 −0
  190. tools/perf/util/probe-file.c +38 −18
  191. tools/perf/util/probe-file.h +4 −0
  192. tools/perf/util/probe-finder.c +54 −4
  193. tools/perf/util/python.c +55 −4
  194. tools/perf/util/scripting-engines/trace-event-perl.c +1 −0
  195. tools/perf/util/scripting-engines/trace-event-python.c +2 −1
  196. tools/perf/util/session.c +16 −21
  197. tools/perf/util/session.h +2 −0
  198. tools/perf/util/sort.c +70 −4
  199. tools/perf/util/sort.h +6 −0
  200. tools/perf/util/srcline.c +24 −5
  201. tools/perf/util/stat.c +7 −6
  202. tools/perf/util/stat.h +2 −1
  203. tools/perf/util/strbuf.c +15 −7
  204. tools/perf/util/strbuf.h +2 −0
  205. tools/perf/util/symbol-minimal.c +1 −1
  206. tools/perf/util/symbol.c +20 −11
  207. tools/perf/util/symbol.h +1 −0
  208. tools/perf/util/trace-event-info.c +1 −1
  209. tools/perf/util/trace-event.c +13 −3
  210. tools/perf/util/trace-event.h +2 −0
  211. tools/perf/util/unwind-libunwind.c +12 −7
  212. tools/perf/util/usage.c +5 −0
  213. tools/perf/util/util.c +1 −71
  214. tools/perf/util/util.h +4 −8
  215. tools/vm/page-types.c +3 −3
arch/powerpc/perf/core-book3s.c+30−6
@@ -48,7 +48,7 @@ struct cpu_hw_events { · 47 unmodified lines
4848 unsigned long amasks[MAX_HWEVENTS][MAX_EVENT_ALTERNATIVES];
4949 unsigned long avalues[MAX_HWEVENTS][MAX_EVENT_ALTERNATIVES];
5050
51− unsigned int group_flag;
51+ unsigned int txn_flags;
5252 int n_txn_start;
5353
5454 /* BHRB bits */
@@ -1441,7 +1441,7 @@ static int power_pmu_add(struct perf_event *event, int ef_flags) · 1386 unmodified lines
14411441 * skip the schedulability test here, it will be performed
14421442 * at commit time(->commit_txn) as a whole
14431443 */
1444− if (cpuhw->group_flag & PERF_EVENT_TXN)
1444+ if (cpuhw->txn_flags & PERF_PMU_TXN_ADD)
14451445 goto nocheck;
14461446
14471447 if (check_excludes(cpuhw->event, cpuhw->flags, n0, 1))
@@ -1586,13 +1586,22 @@ static void power_pmu_stop(struct perf_event *event, int ef_flags) · 138 unmodified lines
15861586 * Start group events scheduling transaction
15871587 * Set the flag to make pmu::enable() not perform the
15881588 * schedulability test, it will be performed at commit time
1589+ *
1590+ * We only support PERF_PMU_TXN_ADD transactions. Save the
1591+ * transaction flags but otherwise ignore non-PERF_PMU_TXN_ADD
1592+ * transactions.
15891593 */
1590−static void power_pmu_start_txn(struct pmu *pmu)
1594+static void power_pmu_start_txn(struct pmu *pmu, unsigned int txn_flags)
15911595 {
15921596 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events);
15931597
1598+ WARN_ON_ONCE(cpuhw->txn_flags); /* txn already in flight */
1599+
1600+ cpuhw->txn_flags = txn_flags;
1601+ if (txn_flags & ~PERF_PMU_TXN_ADD)
1602+ return;
1603+
15941604 perf_pmu_disable(pmu);
1595− cpuhw->group_flag |= PERF_EVENT_TXN;
15961605 cpuhw->n_txn_start = cpuhw->n_events;
15971606 }
15981607
@@ -1604,8 +1613,15 @@ static void power_pmu_start_txn(struct pmu *pmu) · 5 unmodified lines
16041613 static void power_pmu_cancel_txn(struct pmu *pmu)
16051614 {
16061615 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events);
1616+ unsigned int txn_flags;
1617+
1618+ WARN_ON_ONCE(!cpuhw->txn_flags); /* no txn in flight */
1619+
1620+ txn_flags = cpuhw->txn_flags;
1621+ cpuhw->txn_flags = 0;
1622+ if (txn_flags & ~PERF_PMU_TXN_ADD)
1623+ return;
16071624
1608− cpuhw->group_flag &= ~PERF_EVENT_TXN;
16091625 perf_pmu_enable(pmu);
16101626 }
16111627
@@ -1621,7 +1637,15 @@ static int power_pmu_commit_txn(struct pmu *pmu) · 9 unmodified lines
16211637
16221638 if (!ppmu)
16231639 return -EAGAIN;
1640+
16241641 cpuhw = this_cpu_ptr(&cpu_hw_events);
1642+ WARN_ON_ONCE(!cpuhw->txn_flags); /* no txn in flight */
1643+
1644+ if (cpuhw->txn_flags & ~PERF_PMU_TXN_ADD) {
1645+ cpuhw->txn_flags = 0;
1646+ return 0;
1647+ }
1648+
16251649 n = cpuhw->n_events;
16261650 if (check_excludes(cpuhw->event, cpuhw->flags, 0, n))
16271651 return -EAGAIN;
@@ -1632,7 +1656,7 @@ static int power_pmu_commit_txn(struct pmu *pmu) · 4 unmodified lines
16321656 for (i = cpuhw->n_txn_start; i < n; ++i)
16331657 cpuhw->event[i]->hw.config = cpuhw->events[i];
16341658
1635− cpuhw->group_flag &= ~PERF_EVENT_TXN;
1659+ cpuhw->txn_flags = 0;
16361660 perf_pmu_enable(pmu);
16371661 return 0;
16381662 }
arch/powerpc/perf/hv-24x7.c+164−2
@@ -142,6 +142,15 @@ static struct attribute_group event_long_desc_group = { · 141 unmodified lines
142142
143143 static struct kmem_cache *hv_page_cache;
144144
145+DEFINE_PER_CPU(int, hv_24x7_txn_flags);
146+DEFINE_PER_CPU(int, hv_24x7_txn_err);
147+
148+struct hv_24x7_hw {
149+ struct perf_event *events[255];
150+};
151+
152+DEFINE_PER_CPU(struct hv_24x7_hw, hv_24x7_hw);
153+
145154 /*
146155 * request_buffer and result_buffer are not required to be 4k aligned,
147156 * but are not allowed to cross any 4k boundary. Aligning them to 4k is
@@ -1231,9 +1240,48 @@ static void update_event_count(struct perf_event *event, u64 now) · 1083 unmodified lines
12311240 static void h_24x7_event_read(struct perf_event *event)
12321241 {
12331242 u64 now;
1243+ struct hv_24x7_request_buffer *request_buffer;
1244+ struct hv_24x7_hw *h24x7hw;
1245+ int txn_flags;
1246+
1247+ txn_flags = __this_cpu_read(hv_24x7_txn_flags);
1248+
1249+ /*
1250+ * If in a READ transaction, add this counter to the list of
1251+ * counters to read during the next HCALL (i.e commit_txn()).
1252+ * If not in a READ transaction, go ahead and make the HCALL
1253+ * to read this counter by itself.
1254+ */
1255+
1256+ if (txn_flags & PERF_PMU_TXN_READ) {
1257+ int i;
1258+ int ret;
12341259
1235− now = h_24x7_get_value(event);
1236− update_event_count(event, now);
1260+ if (__this_cpu_read(hv_24x7_txn_err))
1261+ return;
1262+
1263+ request_buffer = (void *)get_cpu_var(hv_24x7_reqb);
1264+
1265+ ret = add_event_to_24x7_request(event, request_buffer);
1266+ if (ret) {
1267+ __this_cpu_write(hv_24x7_txn_err, ret);
1268+ } else {
1269+ /*
1270+ * Assoicate the event with the HCALL request index,
1271+ * so ->commit_txn() can quickly find/update count.
1272+ */
1273+ i = request_buffer->num_requests - 1;
1274+
1275+ h24x7hw = &get_cpu_var(hv_24x7_hw);
1276+ h24x7hw->events[i] = event;
1277+ put_cpu_var(h24x7hw);
1278+ }
1279+
1280+ put_cpu_var(hv_24x7_reqb);
1281+ } else {
1282+ now = h_24x7_get_value(event);
1283+ update_event_count(event, now);
1284+ }
12371285 }
12381286
12391287 static void h_24x7_event_start(struct perf_event *event, int flags)
@@ -1255,6 +1303,117 @@ static int h_24x7_event_add(struct perf_event *event, int flags) · 15 unmodified lines
12551303 return 0;
12561304 }
12571305
1306+/*
1307+ * 24x7 counters only support READ transactions. They are
1308+ * always counting and dont need/support ADD transactions.
1309+ * Cache the flags, but otherwise ignore transactions that
1310+ * are not PERF_PMU_TXN_READ.
1311+ */
1312+static void h_24x7_event_start_txn(struct pmu *pmu, unsigned int flags)
1313+{
1314+ struct hv_24x7_request_buffer *request_buffer;
1315+ struct hv_24x7_data_result_buffer *result_buffer;
1316+
1317+ /* We should not be called if we are already in a txn */
1318+ WARN_ON_ONCE(__this_cpu_read(hv_24x7_txn_flags));
1319+
1320+ __this_cpu_write(hv_24x7_txn_flags, flags);
1321+ if (flags & ~PERF_PMU_TXN_READ)
1322+ return;
1323+
1324+ request_buffer = (void *)get_cpu_var(hv_24x7_reqb);
1325+ result_buffer = (void *)get_cpu_var(hv_24x7_resb);
1326+
1327+ init_24x7_request(request_buffer, result_buffer);
1328+
1329+ put_cpu_var(hv_24x7_resb);
1330+ put_cpu_var(hv_24x7_reqb);
1331+}
1332+
1333+/*
1334+ * Clean up transaction state.
1335+ *
1336+ * NOTE: Ignore state of request and result buffers for now.
1337+ * We will initialize them during the next read/txn.
1338+ */
1339+static void reset_txn(void)
1340+{
1341+ __this_cpu_write(hv_24x7_txn_flags, 0);
1342+ __this_cpu_write(hv_24x7_txn_err, 0);
1343+}
1344+
1345+/*
1346+ * 24x7 counters only support READ transactions. They are always counting
1347+ * and dont need/support ADD transactions. Clear ->txn_flags but otherwise
1348+ * ignore transactions that are not of type PERF_PMU_TXN_READ.
1349+ *
1350+ * For READ transactions, submit all pending 24x7 requests (i.e requests
1351+ * that were queued by h_24x7_event_read()), to the hypervisor and update
1352+ * the event counts.
1353+ */
1354+static int h_24x7_event_commit_txn(struct pmu *pmu)
1355+{
1356+ struct hv_24x7_request_buffer *request_buffer;
1357+ struct hv_24x7_data_result_buffer *result_buffer;
1358+ struct hv_24x7_result *resb;
1359+ struct perf_event *event;
1360+ u64 count;
1361+ int i, ret, txn_flags;
1362+ struct hv_24x7_hw *h24x7hw;
1363+
1364+ txn_flags = __this_cpu_read(hv_24x7_txn_flags);
1365+ WARN_ON_ONCE(!txn_flags);
1366+
1367+ ret = 0;
1368+ if (txn_flags & ~PERF_PMU_TXN_READ)
1369+ goto out;
1370+
1371+ ret = __this_cpu_read(hv_24x7_txn_err);
1372+ if (ret)
1373+ goto out;
1374+
1375+ request_buffer = (void *)get_cpu_var(hv_24x7_reqb);
1376+ result_buffer = (void *)get_cpu_var(hv_24x7_resb);
1377+
1378+ ret = make_24x7_request(request_buffer, result_buffer);
1379+ if (ret) {
1380+ log_24x7_hcall(request_buffer, result_buffer, ret);
1381+ goto put_reqb;
1382+ }
1383+
1384+ h24x7hw = &get_cpu_var(hv_24x7_hw);
1385+
1386+ /* Update event counts from hcall */
1387+ for (i = 0; i < request_buffer->num_requests; i++) {
1388+ resb = &result_buffer->results[i];
1389+ count = be64_to_cpu(resb->elements[0].element_data[0]);
1390+ event = h24x7hw->events[i];
1391+ h24x7hw->events[i] = NULL;
1392+ update_event_count(event, count);
1393+ }
1394+
1395+ put_cpu_var(hv_24x7_hw);
1396+
1397+put_reqb:
1398+ put_cpu_var(hv_24x7_resb);
1399+ put_cpu_var(hv_24x7_reqb);
1400+out:
1401+ reset_txn();
1402+ return ret;
1403+}
1404+
1405+/*
1406+ * 24x7 counters only support READ transactions. They are always counting
1407+ * and dont need/support ADD transactions. However, regardless of type
1408+ * of transaction, all we need to do is cleanup, so we don't have to check
1409+ * the type of transaction.
1410+ */
1411+static void h_24x7_event_cancel_txn(struct pmu *pmu)
1412+{
1413+ WARN_ON_ONCE(!__this_cpu_read(hv_24x7_txn_flags));
1414+ reset_txn();
1415+}
1416+
12581417 static struct pmu h_24x7_pmu = {
12591418 .task_ctx_nr = perf_invalid_context,
12601419
@@ -1266,6 +1425,9 @@ static struct pmu h_24x7_pmu = { · 5 unmodified lines
12661425 .start = h_24x7_event_start,
12671426 .stop = h_24x7_event_stop,
12681427 .read = h_24x7_event_read,
1428+ .start_txn = h_24x7_event_start_txn,
1429+ .commit_txn = h_24x7_event_commit_txn,
1430+ .cancel_txn = h_24x7_event_cancel_txn,
12691431 };
12701432
12711433 static int hv_24x7_init(void)
arch/powerpc/perf/power8-pmu.c+3−0
@@ -676,6 +676,9 @@ static u64 power8_bhrb_filter_map(u64 branch_sample_type) · 675 unmodified lines
676676 if (branch_sample_type & PERF_SAMPLE_BRANCH_IND_CALL)
677677 return -1;
678678
679+ if (branch_sample_type & PERF_SAMPLE_BRANCH_CALL)
680+ return -1;
681+
679682 if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_CALL) {
680683 pmu_bhrb_filter |= POWER8_MMCRA_IFM1;
681684 return pmu_bhrb_filter;
arch/s390/kernel/perf_cpum_cf.c+30−5
@@ -72,6 +72,7 @@ struct cpu_hw_events { · 71 unmodified lines
7272 atomic_t ctr_set[CPUMF_CTR_SET_MAX];
7373 u64 state, tx_state;
7474 unsigned int flags;
75+ unsigned int txn_flags;
7576 };
7677 static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = {
7778 .ctr_set = {
@@ -82,6 +83,7 @@ static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = { · 4 unmodified lines
8283 },
8384 .state = 0,
8485 .flags = 0,
86+ .txn_flags = 0,
8587 };
8688
8789 static int get_counter_set(u64 event)
@@ -538,7 +540,7 @@ static int cpumf_pmu_add(struct perf_event *event, int flags) · 450 unmodified lines
538540 * For group events transaction, the authorization check is
539541 * done in cpumf_pmu_commit_txn().
540542 */
541− if (!(cpuhw->flags & PERF_EVENT_TXN))
543+ if (!(cpuhw->txn_flags & PERF_PMU_TXN_ADD))
542544 if (validate_ctr_auth(&event->hw))
543545 return -ENOENT;
544546
@@ -576,13 +578,22 @@ static void cpumf_pmu_del(struct perf_event *event, int flags) · 31 unmodified lines
576578 /*
577579 * Start group events scheduling transaction.
578580 * Set flags to perform a single test at commit time.
581+ *
582+ * We only support PERF_PMU_TXN_ADD transactions. Save the
583+ * transaction flags but otherwise ignore non-PERF_PMU_TXN_ADD
584+ * transactions.
579585 */
580−static void cpumf_pmu_start_txn(struct pmu *pmu)
586+static void cpumf_pmu_start_txn(struct pmu *pmu, unsigned int txn_flags)
581587 {
582588 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events);
583589
590+ WARN_ON_ONCE(cpuhw->txn_flags); /* txn already in flight */
591+
592+ cpuhw->txn_flags = txn_flags;
593+ if (txn_flags & ~PERF_PMU_TXN_ADD)
594+ return;
595+
584596 perf_pmu_disable(pmu);
585− cpuhw->flags |= PERF_EVENT_TXN;
586597 cpuhw->tx_state = cpuhw->state;
587598 }
588599
@@ -593,11 +604,18 @@ static void cpumf_pmu_start_txn(struct pmu *pmu) · 4 unmodified lines
593604 */
594605 static void cpumf_pmu_cancel_txn(struct pmu *pmu)
595606 {
607+ unsigned int txn_flags;
596608 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events);
597609
610+ WARN_ON_ONCE(!cpuhw->txn_flags); /* no txn in flight */
611+
612+ txn_flags = cpuhw->txn_flags;
613+ cpuhw->txn_flags = 0;
614+ if (txn_flags & ~PERF_PMU_TXN_ADD)
615+ return;
616+
598617 WARN_ON(cpuhw->tx_state != cpuhw->state);
599618
600− cpuhw->flags &= ~PERF_EVENT_TXN;
601619 perf_pmu_enable(pmu);
602620 }
603621
@@ -611,13 +629,20 @@ static int cpumf_pmu_commit_txn(struct pmu *pmu) · 7 unmodified lines
611629 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events);
612630 u64 state;
613631
632+ WARN_ON_ONCE(!cpuhw->txn_flags); /* no txn in flight */
633+
634+ if (cpuhw->txn_flags & ~PERF_PMU_TXN_ADD) {
635+ cpuhw->txn_flags = 0;
636+ return 0;
637+ }
638+
614639 /* check if the updated state can be scheduled */
615640 state = cpuhw->state & ~((1 << CPUMF_LCCTL_ENABLE_SHIFT) - 1);
616641 state >>= CPUMF_LCCTL_ENABLE_SHIFT;
617642 if ((state & cpuhw->info.auth_ctl) != state)
618643 return -ENOENT;
619644
620− cpuhw->flags &= ~PERF_EVENT_TXN;
645+ cpuhw->txn_flags = 0;
621646 perf_pmu_enable(pmu);
622647 return 0;
623648 }
arch/sparc/kernel/perf_event.c+25−7
@@ -108,7 +108,7 @@ struct cpu_hw_events { · 107 unmodified lines
108108 /* Enabled/disable state. */
109109 int enabled;
110110
111− unsigned int group_flag;
111+ unsigned int txn_flags;
112112 };
113113 static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = { .enabled = 1, };
114114
@@ -1379,7 +1379,7 @@ static int sparc_pmu_add(struct perf_event *event, int ef_flags) · 1264 unmodified lines
13791379 * skip the schedulability test here, it will be performed
13801380 * at commit time(->commit_txn) as a whole
13811381 */
1382− if (cpuc->group_flag & PERF_EVENT_TXN)
1382+ if (cpuc->txn_flags & PERF_PMU_TXN_ADD)
13831383 goto nocheck;
13841384
13851385 if (check_excludes(cpuc->event, n0, 1))
@@ -1494,12 +1494,17 @@ static int sparc_pmu_event_init(struct perf_event *event) · 108 unmodified lines
14941494 * Set the flag to make pmu::enable() not perform the
14951495 * schedulability test, it will be performed at commit time
14961496 */
1497−static void sparc_pmu_start_txn(struct pmu *pmu)
1497+static void sparc_pmu_start_txn(struct pmu *pmu, unsigned int txn_flags)
14981498 {
14991499 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events);
15001500
1501+ WARN_ON_ONCE(cpuhw->txn_flags); /* txn already in flight */
1502+
1503+ cpuhw->txn_flags = txn_flags;
1504+ if (txn_flags & ~PERF_PMU_TXN_ADD)
1505+ return;
1506+
15011507 perf_pmu_disable(pmu);
1502− cpuhw->group_flag |= PERF_EVENT_TXN;
15031508 }
15041509
15051510 /*
@@ -1510,8 +1515,15 @@ static void sparc_pmu_start_txn(struct pmu *pmu) · 4 unmodified lines
15101515 static void sparc_pmu_cancel_txn(struct pmu *pmu)
15111516 {
15121517 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events);
1518+ unsigned int txn_flags;
1519+
1520+ WARN_ON_ONCE(!cpuhw->txn_flags); /* no txn in flight */
1521+
1522+ txn_flags = cpuhw->txn_flags;
1523+ cpuhw->txn_flags = 0;
1524+ if (txn_flags & ~PERF_PMU_TXN_ADD)
1525+ return;
15131526
1514− cpuhw->group_flag &= ~PERF_EVENT_TXN;
15151527 perf_pmu_enable(pmu);
15161528 }
15171529
@@ -1528,14 +1540,20 @@ static int sparc_pmu_commit_txn(struct pmu *pmu) · 10 unmodified lines
15281540 if (!sparc_pmu)
15291541 return -EINVAL;
15301542
1531− cpuc = this_cpu_ptr(&cpu_hw_events);
1543+ WARN_ON_ONCE(!cpuc->txn_flags); /* no txn in flight */
1544+
1545+ if (cpuc->txn_flags & ~PERF_PMU_TXN_ADD) {
1546+ cpuc->txn_flags = 0;
1547+ return 0;
1548+ }
1549+
15321550 n = cpuc->n_events;
15331551 if (check_excludes(cpuc->event, 0, n))
15341552 return -EINVAL;
15351553 if (sparc_check_constraints(cpuc->event, cpuc->events, n))
15361554 return -EAGAIN;
15371555
1538− cpuc->group_flag &= ~PERF_EVENT_TXN;
1556+ cpuc->txn_flags = 0;
15391557 perf_pmu_enable(pmu);
15401558 return 0;
15411559 }
arch/x86/kernel/cpu/Makefile+1−0
@@ -41,6 +41,7 @@ obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_p6.o perf_event_knc.o perf_event_p4.o · 40 unmodified lines
4141 obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_lbr.o perf_event_intel_ds.o perf_event_intel.o
4242 obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_rapl.o perf_event_intel_cqm.o
4343 obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_pt.o perf_event_intel_bts.o
44+obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_cstate.o
4445
4546 obj-$(CONFIG_PERF_EVENTS_INTEL_UNCORE) += perf_event_intel_uncore.o \
4647 perf_event_intel_uncore_snb.o \
arch/x86/kernel/cpu/intel_cacheinfo.c+4−4
@@ -157,7 +157,7 @@ struct _cpuid4_info_regs { · 156 unmodified lines
157157 struct amd_northbridge *nb;
158158 };
159159
160−unsigned short num_cache_leaves;
160+static unsigned short num_cache_leaves;
161161
162162 /* AMD doesn't have CPUID4. Emulate it here to report the same
163163 information to the user. This makes some assumptions about the machine:
@@ -326,7 +326,7 @@ static void amd_calc_l3_indices(struct amd_northbridge *nb) · 162 unmodified lines
326326 *
327327 * @returns: the disabled index if used or negative value if slot free.
328328 */
329−int amd_get_l3_disable_slot(struct amd_northbridge *nb, unsigned slot)
329+static int amd_get_l3_disable_slot(struct amd_northbridge *nb, unsigned slot)
330330 {
331331 unsigned int reg = 0;
332332
@@ -403,8 +403,8 @@ static void amd_l3_disable_index(struct amd_northbridge *nb, int cpu, · 70 unmodified lines
403403 *
404404 * @return: 0 on success, error status on failure
405405 */
406−int amd_set_l3_disable_slot(struct amd_northbridge *nb, int cpu, unsigned slot,
407− unsigned long index)
406+static int amd_set_l3_disable_slot(struct amd_northbridge *nb, int cpu,
407+ unsigned slot, unsigned long index)
408408 {
409409 int ret = 0;
410410
arch/x86/kernel/cpu/perf_event.c+33−6
@@ -1175,7 +1175,7 @@ static int x86_pmu_add(struct perf_event *event, int flags) · 1174 unmodified lines
11751175 * skip the schedulability test here, it will be performed
11761176 * at commit time (->commit_txn) as a whole.
11771177 */
1178− if (cpuc->group_flag & PERF_EVENT_TXN)
1178+ if (cpuc->txn_flags & PERF_PMU_TXN_ADD)
11791179 goto done_collect;
11801180
11811181 ret = x86_pmu.schedule_events(cpuc, n, assign);
@@ -1326,7 +1326,7 @@ static void x86_pmu_del(struct perf_event *event, int flags) · 144 unmodified lines
13261326 * XXX assumes any ->del() called during a TXN will only be on
13271327 * an event added during that same TXN.
13281328 */
1329− if (cpuc->group_flag & PERF_EVENT_TXN)
1329+ if (cpuc->txn_flags & PERF_PMU_TXN_ADD)
13301330 return;
13311331
13321332 /*
@@ -1748,11 +1748,22 @@ static inline void x86_pmu_read(struct perf_event *event) · 415 unmodified lines
17481748 * Start group events scheduling transaction
17491749 * Set the flag to make pmu::enable() not perform the
17501750 * schedulability test, it will be performed at commit time
1751+ *
1752+ * We only support PERF_PMU_TXN_ADD transactions. Save the
1753+ * transaction flags but otherwise ignore non-PERF_PMU_TXN_ADD
1754+ * transactions.
17511755 */
1752−static void x86_pmu_start_txn(struct pmu *pmu)
1756+static void x86_pmu_start_txn(struct pmu *pmu, unsigned int txn_flags)
17531757 {
1758+ struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
1759+
1760+ WARN_ON_ONCE(cpuc->txn_flags); /* txn already in flight */
1761+
1762+ cpuc->txn_flags = txn_flags;
1763+ if (txn_flags & ~PERF_PMU_TXN_ADD)
1764+ return;
1765+
17541766 perf_pmu_disable(pmu);
1755− __this_cpu_or(cpu_hw_events.group_flag, PERF_EVENT_TXN);
17561767 __this_cpu_write(cpu_hw_events.n_txn, 0);
17571768 }
17581769
@@ -1763,7 +1774,16 @@ static void x86_pmu_start_txn(struct pmu *pmu) · 4 unmodified lines
17631774 */
17641775 static void x86_pmu_cancel_txn(struct pmu *pmu)
17651776 {
1766− __this_cpu_and(cpu_hw_events.group_flag, ~PERF_EVENT_TXN);
1777+ unsigned int txn_flags;
1778+ struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
1779+
1780+ WARN_ON_ONCE(!cpuc->txn_flags); /* no txn in flight */
1781+
1782+ txn_flags = cpuc->txn_flags;
1783+ cpuc->txn_flags = 0;
1784+ if (txn_flags & ~PERF_PMU_TXN_ADD)
1785+ return;
1786+
17671787 /*
17681788 * Truncate collected array by the number of events added in this
17691789 * transaction. See x86_pmu_add() and x86_pmu_*_txn().
@@ -1786,6 +1806,13 @@ static int x86_pmu_commit_txn(struct pmu *pmu) · 16 unmodified lines
17861806 int assign[X86_PMC_IDX_MAX];
17871807 int n, ret;
17881808
1809+ WARN_ON_ONCE(!cpuc->txn_flags); /* no txn in flight */
1810+
1811+ if (cpuc->txn_flags & ~PERF_PMU_TXN_ADD) {
1812+ cpuc->txn_flags = 0;
1813+ return 0;
1814+ }
1815+
17891816 n = cpuc->n_events;
17901817
17911818 if (!x86_pmu_initialized())
@@ -1801,7 +1828,7 @@ static int x86_pmu_commit_txn(struct pmu *pmu) · 9 unmodified lines
18011828 */
18021829 memcpy(cpuc->assign, assign, n*sizeof(int));
18031830
1804− cpuc->group_flag &= ~PERF_EVENT_TXN;
1831+ cpuc->txn_flags = 0;
18051832 perf_pmu_enable(pmu);
18061833 return 0;
18071834 }
arch/x86/kernel/cpu/perf_event.h+1−1
@@ -196,7 +196,7 @@ struct cpu_hw_events { · 195 unmodified lines
196196
197197 int n_excl; /* the number of exclusive events */
198198
199− unsigned int group_flag;
199+ unsigned int txn_flags;
200200 int is_fake;
201201
202202 /*
arch/x86/kernel/cpu/perf_event_intel_bts.c+13−0
@@ -495,6 +495,19 @@ static int bts_event_init(struct perf_event *event) · 494 unmodified lines
495495 if (x86_add_exclusive(x86_lbr_exclusive_bts))
496496 return -EBUSY;
497497
498+ /*
499+ * BTS leaks kernel addresses even when CPL0 tracing is
500+ * disabled, so disallow intel_bts driver for unprivileged
501+ * users on paranoid systems since it provides trace data
502+ * to the user in a zero-copy fashion.
503+ *
504+ * Note that the default paranoia setting permits unprivileged
505+ * users to profile the kernel.
506+ */
507+ if (event->attr.exclude_kernel && perf_paranoid_kernel() &&
508+ !capable(CAP_SYS_ADMIN))
509+ return -EACCES;
510+
498511 ret = x86_reserve_hardware();
499512 if (ret) {
500513 x86_del_exclusive(x86_lbr_exclusive_bts);
arch/x86/kernel/cpu/perf_event_intel_cstate.c+694−0
@@ -0,0 +1,694 @@
1+/*
2+ * perf_event_intel_cstate.c: support cstate residency counters
3+ *
4+ * Copyright (C) 2015, Intel Corp.
5+ * Author: Kan Liang (kan.liang@intel.com)
6+ *
7+ * This library is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU Library General Public
9+ * License as published by the Free Software Foundation; either
10+ * version 2 of the License, or (at your option) any later version.
11+ *
12+ * This library is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+ * Library General Public License for more details.
16+ *
17+ */
18+
19+/*
20+ * This file export cstate related free running (read-only) counters
21+ * for perf. These counters may be use simultaneously by other tools,
22+ * such as turbostat. However, it still make sense to implement them
23+ * in perf. Because we can conveniently collect them together with
24+ * other events, and allow to use them from tools without special MSR
25+ * access code.
26+ *
27+ * The events only support system-wide mode counting. There is no
28+ * sampling support because it is not supported by the hardware.
29+ *
30+ * According to counters' scope and category, two PMUs are registered
31+ * with the perf_event core subsystem.
32+ * - 'cstate_core': The counter is available for each physical core.
33+ * The counters include CORE_C*_RESIDENCY.
34+ * - 'cstate_pkg': The counter is available for each physical package.
35+ * The counters include PKG_C*_RESIDENCY.
36+ *
37+ * All of these counters are specified in the Intel® 64 and IA-32
38+ * Architectures Software Developer.s Manual Vol3b.
39+ *
40+ * Model specific counters:
41+ * MSR_CORE_C1_RES: CORE C1 Residency Counter
42+ * perf code: 0x00
43+ * Available model: SLM,AMT
44+ * Scope: Core (each processor core has a MSR)
45+ * MSR_CORE_C3_RESIDENCY: CORE C3 Residency Counter
46+ * perf code: 0x01
47+ * Available model: NHM,WSM,SNB,IVB,HSW,BDW,SKL
48+ * Scope: Core
49+ * MSR_CORE_C6_RESIDENCY: CORE C6 Residency Counter
50+ * perf code: 0x02
51+ * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW,SKL
52+ * Scope: Core
53+ * MSR_CORE_C7_RESIDENCY: CORE C7 Residency Counter
54+ * perf code: 0x03
55+ * Available model: SNB,IVB,HSW,BDW,SKL
56+ * Scope: Core
57+ * MSR_PKG_C2_RESIDENCY: Package C2 Residency Counter.
58+ * perf code: 0x00
59+ * Available model: SNB,IVB,HSW,BDW,SKL
60+ * Scope: Package (physical package)
61+ * MSR_PKG_C3_RESIDENCY: Package C3 Residency Counter.
62+ * perf code: 0x01
63+ * Available model: NHM,WSM,SNB,IVB,HSW,BDW,SKL
64+ * Scope: Package (physical package)
65+ * MSR_PKG_C6_RESIDENCY: Package C6 Residency Counter.
66+ * perf code: 0x02
67+ * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW,SKL
68+ * Scope: Package (physical package)
69+ * MSR_PKG_C7_RESIDENCY: Package C7 Residency Counter.
70+ * perf code: 0x03
71+ * Available model: NHM,WSM,SNB,IVB,HSW,BDW,SKL
72+ * Scope: Package (physical package)
73+ * MSR_PKG_C8_RESIDENCY: Package C8 Residency Counter.
74+ * perf code: 0x04
75+ * Available model: HSW ULT only
76+ * Scope: Package (physical package)
77+ * MSR_PKG_C9_RESIDENCY: Package C9 Residency Counter.
78+ * perf code: 0x05
79+ * Available model: HSW ULT only
80+ * Scope: Package (physical package)
81+ * MSR_PKG_C10_RESIDENCY: Package C10 Residency Counter.
82+ * perf code: 0x06
83+ * Available model: HSW ULT only
84+ * Scope: Package (physical package)
85+ *
86+ */
87+
88+#include <linux/module.h>
89+#include <linux/slab.h>
90+#include <linux/perf_event.h>
91+#include <asm/cpu_device_id.h>
92+#include "perf_event.h"
93+
94+#define DEFINE_CSTATE_FORMAT_ATTR(_var, _name, _format) \
95+static ssize_t __cstate_##_var##_show(struct kobject *kobj, \
96+ struct kobj_attribute *attr, \
97+ char *page) \
98+{ \
99+ BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \
100+ return sprintf(page, _format "\n"); \
101+} \
102+static struct kobj_attribute format_attr_##_var = \
103+ __ATTR(_name, 0444, __cstate_##_var##_show, NULL)
104+
105+static ssize_t cstate_get_attr_cpumask(struct device *dev,
106+ struct device_attribute *attr,
107+ char *buf);
108+
109+struct perf_cstate_msr {
110+ u64 msr;
111+ struct perf_pmu_events_attr *attr;
112+ bool (*test)(int idx);
113+};
114+
115+
116+/* cstate_core PMU */
117+
118+static struct pmu cstate_core_pmu;
119+static bool has_cstate_core;
120+
121+enum perf_cstate_core_id {
122+ /*
123+ * cstate_core events
124+ */
125+ PERF_CSTATE_CORE_C1_RES = 0,
126+ PERF_CSTATE_CORE_C3_RES,
127+ PERF_CSTATE_CORE_C6_RES,
128+ PERF_CSTATE_CORE_C7_RES,
129+
130+ PERF_CSTATE_CORE_EVENT_MAX,
131+};
132+
133+bool test_core(int idx)
134+{
135+ if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
136+ boot_cpu_data.x86 != 6)
137+ return false;
138+
139+ switch (boot_cpu_data.x86_model) {
140+ case 30: /* 45nm Nehalem */
141+ case 26: /* 45nm Nehalem-EP */
142+ case 46: /* 45nm Nehalem-EX */
143+
144+ case 37: /* 32nm Westmere */
145+ case 44: /* 32nm Westmere-EP */
146+ case 47: /* 32nm Westmere-EX */
147+ if (idx == PERF_CSTATE_CORE_C3_RES ||
148+ idx == PERF_CSTATE_CORE_C6_RES)
149+ return true;
150+ break;
151+ case 42: /* 32nm SandyBridge */
152+ case 45: /* 32nm SandyBridge-E/EN/EP */
153+
154+ case 58: /* 22nm IvyBridge */
155+ case 62: /* 22nm IvyBridge-EP/EX */
156+
157+ case 60: /* 22nm Haswell Core */
158+ case 63: /* 22nm Haswell Server */
159+ case 69: /* 22nm Haswell ULT */
160+ case 70: /* 22nm Haswell + GT3e (Intel Iris Pro graphics) */
161+
162+ case 61: /* 14nm Broadwell Core-M */
163+ case 86: /* 14nm Broadwell Xeon D */
164+ case 71: /* 14nm Broadwell + GT3e (Intel Iris Pro graphics) */
165+ case 79: /* 14nm Broadwell Server */
166+
167+ case 78: /* 14nm Skylake Mobile */
168+ case 94: /* 14nm Skylake Desktop */
169+ if (idx == PERF_CSTATE_CORE_C3_RES ||
170+ idx == PERF_CSTATE_CORE_C6_RES ||
171+ idx == PERF_CSTATE_CORE_C7_RES)
172+ return true;
173+ break;
174+ case 55: /* 22nm Atom "Silvermont" */
175+ case 77: /* 22nm Atom "Silvermont Avoton/Rangely" */
176+ case 76: /* 14nm Atom "Airmont" */
177+ if (idx == PERF_CSTATE_CORE_C1_RES ||
178+ idx == PERF_CSTATE_CORE_C6_RES)
179+ return true;
180+ break;
181+ }
182+
183+ return false;
184+}
185+
186+PMU_EVENT_ATTR_STRING(c1-residency, evattr_cstate_core_c1, "event=0x00");
187+PMU_EVENT_ATTR_STRING(c3-residency, evattr_cstate_core_c3, "event=0x01");
188+PMU_EVENT_ATTR_STRING(c6-residency, evattr_cstate_core_c6, "event=0x02");
189+PMU_EVENT_ATTR_STRING(c7-residency, evattr_cstate_core_c7, "event=0x03");
190+
191+static struct perf_cstate_msr core_msr[] = {
192+ [PERF_CSTATE_CORE_C1_RES] = { MSR_CORE_C1_RES, &evattr_cstate_core_c1, test_core, },
193+ [PERF_CSTATE_CORE_C3_RES] = { MSR_CORE_C3_RESIDENCY, &evattr_cstate_core_c3, test_core, },
194+ [PERF_CSTATE_CORE_C6_RES] = { MSR_CORE_C6_RESIDENCY, &evattr_cstate_core_c6, test_core, },
195+ [PERF_CSTATE_CORE_C7_RES] = { MSR_CORE_C7_RESIDENCY, &evattr_cstate_core_c7, test_core, },
196+};
197+
198+static struct attribute *core_events_attrs[PERF_CSTATE_CORE_EVENT_MAX + 1] = {
199+ NULL,
200+};
201+
202+static struct attribute_group core_events_attr_group = {
203+ .name = "events",
204+ .attrs = core_events_attrs,
205+};
206+
207+DEFINE_CSTATE_FORMAT_ATTR(core_event, event, "config:0-63");
208+static struct attribute *core_format_attrs[] = {
209+ &format_attr_core_event.attr,
210+ NULL,
211+};
212+
213+static struct attribute_group core_format_attr_group = {
214+ .name = "format",
215+ .attrs = core_format_attrs,
216+};
217+
218+static cpumask_t cstate_core_cpu_mask;
219+static DEVICE_ATTR(cpumask, S_IRUGO, cstate_get_attr_cpumask, NULL);
220+
221+static struct attribute *cstate_cpumask_attrs[] = {
222+ &dev_attr_cpumask.attr,
223+ NULL,
224+};
225+
226+static struct attribute_group cpumask_attr_group = {
227+ .attrs = cstate_cpumask_attrs,
228+};
229+
230+static const struct attribute_group *core_attr_groups[] = {
231+ &core_events_attr_group,
232+ &core_format_attr_group,
233+ &cpumask_attr_group,
234+ NULL,
235+};
236+
237+/* cstate_core PMU end */
238+
239+
240+/* cstate_pkg PMU */
241+
242+static struct pmu cstate_pkg_pmu;
243+static bool has_cstate_pkg;
244+
245+enum perf_cstate_pkg_id {
246+ /*
247+ * cstate_pkg events
248+ */
249+ PERF_CSTATE_PKG_C2_RES = 0,
250+ PERF_CSTATE_PKG_C3_RES,
251+ PERF_CSTATE_PKG_C6_RES,
252+ PERF_CSTATE_PKG_C7_RES,
253+ PERF_CSTATE_PKG_C8_RES,
254+ PERF_CSTATE_PKG_C9_RES,
255+ PERF_CSTATE_PKG_C10_RES,
256+
257+ PERF_CSTATE_PKG_EVENT_MAX,
258+};
259+
260+bool test_pkg(int idx)
261+{
262+ if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
263+ boot_cpu_data.x86 != 6)
264+ return false;
265+
266+ switch (boot_cpu_data.x86_model) {
267+ case 30: /* 45nm Nehalem */
268+ case 26: /* 45nm Nehalem-EP */
269+ case 46: /* 45nm Nehalem-EX */
270+
271+ case 37: /* 32nm Westmere */
272+ case 44: /* 32nm Westmere-EP */
273+ case 47: /* 32nm Westmere-EX */
274+ if (idx == PERF_CSTATE_CORE_C3_RES ||
275+ idx == PERF_CSTATE_CORE_C6_RES ||
276+ idx == PERF_CSTATE_CORE_C7_RES)
277+ return true;
278+ break;
279+ case 42: /* 32nm SandyBridge */
280+ case 45: /* 32nm SandyBridge-E/EN/EP */
281+
282+ case 58: /* 22nm IvyBridge */
283+ case 62: /* 22nm IvyBridge-EP/EX */
284+
285+ case 60: /* 22nm Haswell Core */
286+ case 63: /* 22nm Haswell Server */
287+ case 70: /* 22nm Haswell + GT3e (Intel Iris Pro graphics) */
288+
289+ case 61: /* 14nm Broadwell Core-M */
290+ case 86: /* 14nm Broadwell Xeon D */
291+ case 71: /* 14nm Broadwell + GT3e (Intel Iris Pro graphics) */
292+ case 79: /* 14nm Broadwell Server */
293+
294+ case 78: /* 14nm Skylake Mobile */
295+ case 94: /* 14nm Skylake Desktop */
296+ if (idx == PERF_CSTATE_PKG_C2_RES ||
297+ idx == PERF_CSTATE_PKG_C3_RES ||
298+ idx == PERF_CSTATE_PKG_C6_RES ||
299+ idx == PERF_CSTATE_PKG_C7_RES)
300+ return true;
301+ break;
302+ case 55: /* 22nm Atom "Silvermont" */
303+ case 77: /* 22nm Atom "Silvermont Avoton/Rangely" */
304+ case 76: /* 14nm Atom "Airmont" */
305+ if (idx == PERF_CSTATE_CORE_C6_RES)
306+ return true;
307+ break;
308+ case 69: /* 22nm Haswell ULT */
309+ if (idx == PERF_CSTATE_PKG_C2_RES ||
310+ idx == PERF_CSTATE_PKG_C3_RES ||
311+ idx == PERF_CSTATE_PKG_C6_RES ||
312+ idx == PERF_CSTATE_PKG_C7_RES ||
313+ idx == PERF_CSTATE_PKG_C8_RES ||
314+ idx == PERF_CSTATE_PKG_C9_RES ||
315+ idx == PERF_CSTATE_PKG_C10_RES)
316+ return true;
317+ break;
318+ }
319+
320+ return false;
321+}
322+
323+PMU_EVENT_ATTR_STRING(c2-residency, evattr_cstate_pkg_c2, "event=0x00");
324+PMU_EVENT_ATTR_STRING(c3-residency, evattr_cstate_pkg_c3, "event=0x01");
325+PMU_EVENT_ATTR_STRING(c6-residency, evattr_cstate_pkg_c6, "event=0x02");
326+PMU_EVENT_ATTR_STRING(c7-residency, evattr_cstate_pkg_c7, "event=0x03");
327+PMU_EVENT_ATTR_STRING(c8-residency, evattr_cstate_pkg_c8, "event=0x04");
328+PMU_EVENT_ATTR_STRING(c9-residency, evattr_cstate_pkg_c9, "event=0x05");
329+PMU_EVENT_ATTR_STRING(c10-residency, evattr_cstate_pkg_c10, "event=0x06");
330+
331+static struct perf_cstate_msr pkg_msr[] = {
332+ [PERF_CSTATE_PKG_C2_RES] = { MSR_PKG_C2_RESIDENCY, &evattr_cstate_pkg_c2, test_pkg, },
333+ [PERF_CSTATE_PKG_C3_RES] = { MSR_PKG_C3_RESIDENCY, &evattr_cstate_pkg_c3, test_pkg, },
334+ [PERF_CSTATE_PKG_C6_RES] = { MSR_PKG_C6_RESIDENCY, &evattr_cstate_pkg_c6, test_pkg, },
335+ [PERF_CSTATE_PKG_C7_RES] = { MSR_PKG_C7_RESIDENCY, &evattr_cstate_pkg_c7, test_pkg, },
336+ [PERF_CSTATE_PKG_C8_RES] = { MSR_PKG_C8_RESIDENCY, &evattr_cstate_pkg_c8, test_pkg, },
337+ [PERF_CSTATE_PKG_C9_RES] = { MSR_PKG_C9_RESIDENCY, &evattr_cstate_pkg_c9, test_pkg, },
338+ [PERF_CSTATE_PKG_C10_RES] = { MSR_PKG_C10_RESIDENCY, &evattr_cstate_pkg_c10, test_pkg, },
339+};
340+
341+static struct attribute *pkg_events_attrs[PERF_CSTATE_PKG_EVENT_MAX + 1] = {
342+ NULL,
343+};
344+
345+static struct attribute_group pkg_events_attr_group = {
346+ .name = "events",
347+ .attrs = pkg_events_attrs,
348+};
349+
350+DEFINE_CSTATE_FORMAT_ATTR(pkg_event, event, "config:0-63");
351+static struct attribute *pkg_format_attrs[] = {
352+ &format_attr_pkg_event.attr,
353+ NULL,
354+};
355+static struct attribute_group pkg_format_attr_group = {
356+ .name = "format",
357+ .attrs = pkg_format_attrs,
358+};
359+
360+static cpumask_t cstate_pkg_cpu_mask;
361+
362+static const struct attribute_group *pkg_attr_groups[] = {
363+ &pkg_events_attr_group,
364+ &pkg_format_attr_group,
365+ &cpumask_attr_group,
366+ NULL,
367+};
368+
369+/* cstate_pkg PMU end*/
370+
371+static ssize_t cstate_get_attr_cpumask(struct device *dev,
372+ struct device_attribute *attr,
373+ char *buf)
374+{
375+ struct pmu *pmu = dev_get_drvdata(dev);
376+
377+ if (pmu == &cstate_core_pmu)
378+ return cpumap_print_to_pagebuf(true, buf, &cstate_core_cpu_mask);
379+ else if (pmu == &cstate_pkg_pmu)
380+ return cpumap_print_to_pagebuf(true, buf, &cstate_pkg_cpu_mask);
381+ else
382+ return 0;
383+}
384+
385+static int cstate_pmu_event_init(struct perf_event *event)
386+{
387+ u64 cfg = event->attr.config;
388+ int ret = 0;
389+
390+ if (event->attr.type != event->pmu->type)
391+ return -ENOENT;
392+
393+ /* unsupported modes and filters */
394+ if (event->attr.exclude_user ||
395+ event->attr.exclude_kernel ||
396+ event->attr.exclude_hv ||
397+ event->attr.exclude_idle ||
398+ event->attr.exclude_host ||
399+ event->attr.exclude_guest ||
400+ event->attr.sample_period) /* no sampling */
401+ return -EINVAL;
402+
403+ if (event->pmu == &cstate_core_pmu) {
404+ if (cfg >= PERF_CSTATE_CORE_EVENT_MAX)
405+ return -EINVAL;
406+ if (!core_msr[cfg].attr)
407+ return -EINVAL;
408+ event->hw.event_base = core_msr[cfg].msr;
409+ } else if (event->pmu == &cstate_pkg_pmu) {
410+ if (cfg >= PERF_CSTATE_PKG_EVENT_MAX)
411+ return -EINVAL;
412+ if (!pkg_msr[cfg].attr)
413+ return -EINVAL;
414+ event->hw.event_base = pkg_msr[cfg].msr;
415+ } else
416+ return -ENOENT;
417+
418+ /* must be done before validate_group */
419+ event->hw.config = cfg;
420+ event->hw.idx = -1;
421+
422+ return ret;
423+}
424+
425+static inline u64 cstate_pmu_read_counter(struct perf_event *event)
426+{
427+ u64 val;
428+
429+ rdmsrl(event->hw.event_base, val);
430+ return val;
431+}
432+
433+static void cstate_pmu_event_update(struct perf_event *event)
434+{
435+ struct hw_perf_event *hwc = &event->hw;
436+ u64 prev_raw_count, new_raw_count;
437+
438+again:
439+ prev_raw_count = local64_read(&hwc->prev_count);
440+ new_raw_count = cstate_pmu_read_counter(event);
441+
442+ if (local64_cmpxchg(&hwc->prev_count, prev_raw_count,
443+ new_raw_count) != prev_raw_count)
444+ goto again;
445+
446+ local64_add(new_raw_count - prev_raw_count, &event->count);
447+}
448+
449+static void cstate_pmu_event_start(struct perf_event *event, int mode)
450+{
451+ local64_set(&event->hw.prev_count, cstate_pmu_read_counter(event));
452+}
453+
454+static void cstate_pmu_event_stop(struct perf_event *event, int mode)
455+{
456+ cstate_pmu_event_update(event);
457+}
458+
459+static void cstate_pmu_event_del(struct perf_event *event, int mode)
460+{
461+ cstate_pmu_event_stop(event, PERF_EF_UPDATE);
462+}
463+
464+static int cstate_pmu_event_add(struct perf_event *event, int mode)
465+{
466+ if (mode & PERF_EF_START)
467+ cstate_pmu_event_start(event, mode);
468+
469+ return 0;
470+}
471+
472+static void cstate_cpu_exit(int cpu)
473+{
474+ int i, id, target;
475+
476+ /* cpu exit for cstate core */
477+ if (has_cstate_core) {
478+ id = topology_core_id(cpu);
479+ target = -1;
480+
481+ for_each_online_cpu(i) {
482+ if (i == cpu)
483+ continue;
484+ if (id == topology_core_id(i)) {
485+ target = i;
486+ break;
487+ }
488+ }
489+ if (cpumask_test_and_clear_cpu(cpu, &cstate_core_cpu_mask) && target >= 0)
490+ cpumask_set_cpu(target, &cstate_core_cpu_mask);
491+ WARN_ON(cpumask_empty(&cstate_core_cpu_mask));
492+ if (target >= 0)
493+ perf_pmu_migrate_context(&cstate_core_pmu, cpu, target);
494+ }
495+
496+ /* cpu exit for cstate pkg */
497+ if (has_cstate_pkg) {
498+ id = topology_physical_package_id(cpu);
499+ target = -1;
500+
501+ for_each_online_cpu(i) {
502+ if (i == cpu)
503+ continue;
504+ if (id == topology_physical_package_id(i)) {
505+ target = i;
506+ break;
507+ }
508+ }
509+ if (cpumask_test_and_clear_cpu(cpu, &cstate_pkg_cpu_mask) && target >= 0)
510+ cpumask_set_cpu(target, &cstate_pkg_cpu_mask);
511+ WARN_ON(cpumask_empty(&cstate_pkg_cpu_mask));
512+ if (target >= 0)
513+ perf_pmu_migrate_context(&cstate_pkg_pmu, cpu, target);
514+ }
515+}
516+
517+static void cstate_cpu_init(int cpu)
518+{
519+ int i, id;
520+
521+ /* cpu init for cstate core */
522+ if (has_cstate_core) {
523+ id = topology_core_id(cpu);
524+ for_each_cpu(i, &cstate_core_cpu_mask) {
525+ if (id == topology_core_id(i))
526+ break;
527+ }
528+ if (i >= nr_cpu_ids)
529+ cpumask_set_cpu(cpu, &cstate_core_cpu_mask);
530+ }
531+
532+ /* cpu init for cstate pkg */
533+ if (has_cstate_pkg) {
534+ id = topology_physical_package_id(cpu);
535+ for_each_cpu(i, &cstate_pkg_cpu_mask) {
536+ if (id == topology_physical_package_id(i))
537+ break;
538+ }
539+ if (i >= nr_cpu_ids)
540+ cpumask_set_cpu(cpu, &cstate_pkg_cpu_mask);
541+ }
542+}
543+
544+static int cstate_cpu_notifier(struct notifier_block *self,
545+ unsigned long action, void *hcpu)
546+{
547+ unsigned int cpu = (long)hcpu;
548+
549+ switch (action & ~CPU_TASKS_FROZEN) {
550+ case CPU_UP_PREPARE:
551+ break;
552+ case CPU_STARTING:
553+ cstate_cpu_init(cpu);
554+ break;
555+ case CPU_UP_CANCELED:
556+ case CPU_DYING:
557+ break;
558+ case CPU_ONLINE:
559+ case CPU_DEAD:
560+ break;
561+ case CPU_DOWN_PREPARE:
562+ cstate_cpu_exit(cpu);
563+ break;
564+ default:
565+ break;
566+ }
567+
568+ return NOTIFY_OK;
569+}
570+
571+/*
572+ * Probe the cstate events and insert the available one into sysfs attrs
573+ * Return false if there is no available events.
574+ */
575+static bool cstate_probe_msr(struct perf_cstate_msr *msr,
576+ struct attribute **events_attrs,
577+ int max_event_nr)
578+{
579+ int i, j = 0;
580+ u64 val;
581+
582+ /* Probe the cstate events. */
583+ for (i = 0; i < max_event_nr; i++) {
584+ if (!msr[i].test(i) || rdmsrl_safe(msr[i].msr, &val))
585+ msr[i].attr = NULL;
586+ }
587+
588+ /* List remaining events in the sysfs attrs. */
589+ for (i = 0; i < max_event_nr; i++) {
590+ if (msr[i].attr)
591+ events_attrs[j++] = &msr[i].attr->attr.attr;
592+ }
593+ events_attrs[j] = NULL;
594+
595+ return (j > 0) ? true : false;
596+}
597+
598+static int __init cstate_init(void)
599+{
600+ /* SLM has different MSR for PKG C6 */
601+ switch (boot_cpu_data.x86_model) {
602+ case 55:
603+ case 76:
604+ case 77:
605+ pkg_msr[PERF_CSTATE_PKG_C6_RES].msr = MSR_PKG_C7_RESIDENCY;
606+ }
607+
608+ if (cstate_probe_msr(core_msr, core_events_attrs, PERF_CSTATE_CORE_EVENT_MAX))
609+ has_cstate_core = true;
610+
611+ if (cstate_probe_msr(pkg_msr, pkg_events_attrs, PERF_CSTATE_PKG_EVENT_MAX))
612+ has_cstate_pkg = true;
613+
614+ return (has_cstate_core || has_cstate_pkg) ? 0 : -ENODEV;
615+}
616+
617+static void __init cstate_cpumask_init(void)
618+{
619+ int cpu;
620+
621+ cpu_notifier_register_begin();
622+
623+ for_each_online_cpu(cpu)
624+ cstate_cpu_init(cpu);
625+
626+ __perf_cpu_notifier(cstate_cpu_notifier);
627+
628+ cpu_notifier_register_done();
629+}
630+
631+static struct pmu cstate_core_pmu = {
632+ .attr_groups = core_attr_groups,
633+ .name = "cstate_core",
634+ .task_ctx_nr = perf_invalid_context,
635+ .event_init = cstate_pmu_event_init,
636+ .add = cstate_pmu_event_add, /* must have */
637+ .del = cstate_pmu_event_del, /* must have */
638+ .start = cstate_pmu_event_start,
639+ .stop = cstate_pmu_event_stop,
640+ .read = cstate_pmu_event_update,
641+ .capabilities = PERF_PMU_CAP_NO_INTERRUPT,
642+};
643+
644+static struct pmu cstate_pkg_pmu = {
645+ .attr_groups = pkg_attr_groups,
646+ .name = "cstate_pkg",
647+ .task_ctx_nr = perf_invalid_context,
648+ .event_init = cstate_pmu_event_init,
649+ .add = cstate_pmu_event_add, /* must have */
650+ .del = cstate_pmu_event_del, /* must have */
651+ .start = cstate_pmu_event_start,
652+ .stop = cstate_pmu_event_stop,
653+ .read = cstate_pmu_event_update,
654+ .capabilities = PERF_PMU_CAP_NO_INTERRUPT,
655+};
656+
657+static void __init cstate_pmus_register(void)
658+{
659+ int err;
660+
661+ if (has_cstate_core) {
662+ err = perf_pmu_register(&cstate_core_pmu, cstate_core_pmu.name, -1);
663+ if (WARN_ON(err))
664+ pr_info("Failed to register PMU %s error %d\n",
665+ cstate_core_pmu.name, err);
666+ }
667+
668+ if (has_cstate_pkg) {
669+ err = perf_pmu_register(&cstate_pkg_pmu, cstate_pkg_pmu.name, -1);
670+ if (WARN_ON(err))
671+ pr_info("Failed to register PMU %s error %d\n",
672+ cstate_pkg_pmu.name, err);
673+ }
674+}
675+
676+static int __init cstate_pmu_init(void)
677+{
678+ int err;
679+
680+ if (cpu_has_hypervisor)
681+ return -ENODEV;
682+
683+ err = cstate_init();
684+ if (err)
685+ return err;
686+
687+ cstate_cpumask_init();
688+
689+ cstate_pmus_register();
690+
691+ return 0;
692+}
693+
694+device_initcall(cstate_pmu_init);
arch/x86/kernel/cpu/perf_event_intel_ds.c+34−6
@@ -510,10 +510,11 @@ int intel_pmu_drain_bts_buffer(void) · 509 unmodified lines
510510 u64 flags;
511511 };
512512 struct perf_event *event = cpuc->events[INTEL_PMC_IDX_FIXED_BTS];
513− struct bts_record *at, *top;
513+ struct bts_record *at, *base, *top;
514514 struct perf_output_handle handle;
515515 struct perf_event_header header;
516516 struct perf_sample_data data;
517+ unsigned long skip = 0;
517518 struct pt_regs regs;
518519
519520 if (!event)
@@ -522,10 +523,10 @@ int intel_pmu_drain_bts_buffer(void) · 2 unmodified lines
522523 if (!x86_pmu.bts_active)
523524 return 0;
524525
525− at = (struct bts_record *)(unsigned long)ds->bts_buffer_base;
526− top = (struct bts_record *)(unsigned long)ds->bts_index;
526+ base = (struct bts_record *)(unsigned long)ds->bts_buffer_base;
527+ top = (struct bts_record *)(unsigned long)ds->bts_index;
527528
528− if (top <= at)
529+ if (top <= base)
529530 return 0;
530531
531532 memset(&regs, 0, sizeof(regs));
@@ -534,6 +535,27 @@ int intel_pmu_drain_bts_buffer(void) · 2 unmodified lines
534535
535536 perf_sample_data_init(&data, 0, event->hw.last_period);
536537
538+ /*
539+ * BTS leaks kernel addresses in branches across the cpl boundary,
540+ * such as traps or system calls, so unless the user is asking for
541+ * kernel tracing (and right now it's not possible), we'd need to
542+ * filter them out. But first we need to count how many of those we
543+ * have in the current batch. This is an extra O(n) pass, however,
544+ * it's much faster than the other one especially considering that
545+ * n <= 2560 (BTS_BUFFER_SIZE / BTS_RECORD_SIZE * 15/16; see the
546+ * alloc_bts_buffer()).
547+ */
548+ for (at = base; at < top; at++) {
549+ /*
550+ * Note that right now *this* BTS code only works if
551+ * attr::exclude_kernel is set, but let's keep this extra
552+ * check here in case that changes.
553+ */
554+ if (event->attr.exclude_kernel &&
555+ (kernel_ip(at->from) || kernel_ip(at->to)))
556+ skip++;
557+ }
558+
537559 /*
538560 * Prepare a generic sample, i.e. fill in the invariant fields.
539561 * We will overwrite the from and to address before we output
@@ -541,10 +563,16 @@ int intel_pmu_drain_bts_buffer(void) · 1 unmodified line
541563 */
542564 perf_prepare_sample(&header, &data, event, &regs);
543565
544− if (perf_output_begin(&handle, event, header.size * (top - at)))
566+ if (perf_output_begin(&handle, event, header.size *
567+ (top - base - skip)))
545568 return 1;
546569
547− for (; at < top; at++) {
570+ for (at = base; at < top; at++) {
571+ /* Filter out any records that contain kernel addresses. */
572+ if (event->attr.exclude_kernel &&
573+ (kernel_ip(at->from) || kernel_ip(at->to)))
574+ continue;
575+
548576 data.ip = at->from;
549577 data.addr = at->to;
550578
arch/x86/kernel/cpu/perf_event_intel_lbr.c+6−2
@@ -151,10 +151,10 @@ static void __intel_pmu_lbr_enable(bool pmi) · 150 unmodified lines
151151 * No need to reprogram LBR_SELECT in a PMI, as it
152152 * did not change.
153153 */
154− if (cpuc->lbr_sel && !pmi) {
154+ if (cpuc->lbr_sel)
155155 lbr_select = cpuc->lbr_sel->config;
156+ if (!pmi)
156157 wrmsrl(MSR_LBR_SELECT, lbr_select);
157− }
158158
159159 rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
160160 orig_debugctl = debugctl;
@@ -555,6 +555,8 @@ static int intel_pmu_setup_sw_lbr_filter(struct perf_event *event) · 394 unmodified lines
555555 if (br_type & PERF_SAMPLE_BRANCH_IND_JUMP)
556556 mask |= X86_BR_IND_JMP;
557557
558+ if (br_type & PERF_SAMPLE_BRANCH_CALL)
559+ mask |= X86_BR_CALL | X86_BR_ZERO_CALL;
558560 /*
559561 * stash actual user request into reg, it may
560562 * be used by fixup code for some CPU
@@ -890,6 +892,7 @@ static const int snb_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX_SHIFT] = { · 329 unmodified lines
890892 [PERF_SAMPLE_BRANCH_IND_CALL_SHIFT] = LBR_IND_CALL,
891893 [PERF_SAMPLE_BRANCH_COND_SHIFT] = LBR_JCC,
892894 [PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT] = LBR_IND_JMP,
895+ [PERF_SAMPLE_BRANCH_CALL_SHIFT] = LBR_REL_CALL,
893896 };
894897
895898 static const int hsw_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX_SHIFT] = {
@@ -905,6 +908,7 @@ static const int hsw_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX_SHIFT] = { · 9 unmodified lines
905908 [PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT] = LBR_REL_CALL | LBR_IND_CALL
906909 | LBR_RETURN | LBR_CALL_STACK,
907910 [PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT] = LBR_IND_JMP,
911+ [PERF_SAMPLE_BRANCH_CALL_SHIFT] = LBR_REL_CALL,
908912 };
909913
910914 /* core */
arch/x86/kernel/cpu/perf_event_intel_pt.c+4−3
@@ -139,9 +139,6 @@ static int __init pt_pmu_hw_init(void) · 138 unmodified lines
139139 long i;
140140
141141 attrs = NULL;
142− ret = -ENODEV;
143− if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_INTEL_PT))
144− goto fail;
145142
146143 for (i = 0; i < PT_CPUID_LEAVES; i++) {
147144 cpuid_count(20, i,
@@ -1130,6 +1127,10 @@ static __init int pt_init(void) · 982 unmodified lines
11301127 int ret, cpu, prior_warn = 0;
11311128
11321129 BUILD_BUG_ON(sizeof(struct topa) > PAGE_SIZE);
1130+
1131+ if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_INTEL_PT))
1132+ return -ENODEV;
1133+
11331134 get_online_cpus();
11341135 for_each_online_cpu(cpu) {
11351136 u64 ctl;
arch/x86/kernel/cpu/perf_event_intel_uncore.c+58−3
@@ -7,7 +7,8 @@ struct intel_uncore_type **uncore_pci_uncores = empty_uncore; · 6 unmodified lines
77 static bool pcidrv_registered;
88 struct pci_driver *uncore_pci_driver;
99 /* pci bus to socket mapping */
10−int uncore_pcibus_to_physid[256] = { [0 ... 255] = -1, };
10+DEFINE_RAW_SPINLOCK(pci2phy_map_lock);
11+struct list_head pci2phy_map_head = LIST_HEAD_INIT(pci2phy_map_head);
1112 struct pci_dev *uncore_extra_pci_dev[UNCORE_SOCKET_MAX][UNCORE_EXTRA_PCI_DEV_MAX];
1213
1314 static DEFINE_RAW_SPINLOCK(uncore_box_lock);
@@ -20,6 +21,59 @@ static struct event_constraint uncore_constraint_fixed = · 6 unmodified lines
2021 struct event_constraint uncore_constraint_empty =
2122 EVENT_CONSTRAINT(0, 0, 0);
2223
24+int uncore_pcibus_to_physid(struct pci_bus *bus)
25+{
26+ struct pci2phy_map *map;
27+ int phys_id = -1;
28+
29+ raw_spin_lock(&pci2phy_map_lock);
30+ list_for_each_entry(map, &pci2phy_map_head, list) {
31+ if (map->segment == pci_domain_nr(bus)) {
32+ phys_id = map->pbus_to_physid[bus->number];
33+ break;
34+ }
35+ }
36+ raw_spin_unlock(&pci2phy_map_lock);
37+
38+ return phys_id;
39+}
40+
41+struct pci2phy_map *__find_pci2phy_map(int segment)
42+{
43+ struct pci2phy_map *map, *alloc = NULL;
44+ int i;
45+
46+ lockdep_assert_held(&pci2phy_map_lock);
47+
48+lookup:
49+ list_for_each_entry(map, &pci2phy_map_head, list) {
50+ if (map->segment == segment)
51+ goto end;
52+ }
53+
54+ if (!alloc) {
55+ raw_spin_unlock(&pci2phy_map_lock);
56+ alloc = kmalloc(sizeof(struct pci2phy_map), GFP_KERNEL);
57+ raw_spin_lock(&pci2phy_map_lock);
58+
59+ if (!alloc)
60+ return NULL;
61+
62+ goto lookup;
63+ }
64+
65+ map = alloc;
66+ alloc = NULL;
67+ map->segment = segment;
68+ for (i = 0; i < 256; i++)
69+ map->pbus_to_physid[i] = -1;
70+ list_add_tail(&map->list, &pci2phy_map_head);
71+
72+end:
73+ kfree(alloc);
74+ return map;
75+}
76+
2377 ssize_t uncore_event_show(struct kobject *kobj,
2478 struct kobj_attribute *attr, char *buf)
2579 {
@@ -809,7 +863,7 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id · 783 unmodified lines
809863 int phys_id;
810864 bool first_box = false;
811865
812− phys_id = uncore_pcibus_to_physid[pdev->bus->number];
866+ phys_id = uncore_pcibus_to_physid(pdev->bus);
813867 if (phys_id < 0)
814868 return -ENODEV;
815869
@@ -856,9 +910,10 @@ static void uncore_pci_remove(struct pci_dev *pdev) · 40 unmodified lines
856910 {
857911 struct intel_uncore_box *box = pci_get_drvdata(pdev);
858912 struct intel_uncore_pmu *pmu;
859− int i, cpu, phys_id = uncore_pcibus_to_physid[pdev->bus->number];
913+ int i, cpu, phys_id;
860914 bool last_box = false;
861915
916+ phys_id = uncore_pcibus_to_physid(pdev->bus);
862917 box = pci_get_drvdata(pdev);
863918 if (!box) {
864919 for (i = 0; i < UNCORE_EXTRA_PCI_DEV_MAX; i++) {
arch/x86/kernel/cpu/perf_event_intel_uncore.h+11−1
@@ -117,6 +117,15 @@ struct uncore_event_desc { · 116 unmodified lines
117117 const char *config;
118118 };
119119
120+struct pci2phy_map {
121+ struct list_head list;
122+ int segment;
123+ int pbus_to_physid[256];
124+};
125+
126+int uncore_pcibus_to_physid(struct pci_bus *bus);
127+struct pci2phy_map *__find_pci2phy_map(int segment);
128+
120129 ssize_t uncore_event_show(struct kobject *kobj,
121130 struct kobj_attribute *attr, char *buf);
122131
@@ -317,7 +326,8 @@ u64 uncore_shared_reg_config(struct intel_uncore_box *box, int idx); · 194 unmodified lines
317326 extern struct intel_uncore_type **uncore_msr_uncores;
318327 extern struct intel_uncore_type **uncore_pci_uncores;
319328 extern struct pci_driver *uncore_pci_driver;
320−extern int uncore_pcibus_to_physid[256];
329+extern raw_spinlock_t pci2phy_map_lock;
330+extern struct list_head pci2phy_map_head;
321331 extern struct pci_dev *uncore_extra_pci_dev[UNCORE_SOCKET_MAX][UNCORE_EXTRA_PCI_DEV_MAX];
322332 extern struct event_constraint uncore_constraint_empty;
323333
arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c+13−3
@@ -420,15 +420,25 @@ static void snb_uncore_imc_event_del(struct perf_event *event, int flags) · 419 unmodified lines
420420 static int snb_pci2phy_map_init(int devid)
421421 {
422422 struct pci_dev *dev = NULL;
423− int bus;
423+ struct pci2phy_map *map;
424+ int bus, segment;
424425
425426 dev = pci_get_device(PCI_VENDOR_ID_INTEL, devid, dev);
426427 if (!dev)
427428 return -ENOTTY;
428429
429430 bus = dev->bus->number;
430−
431− uncore_pcibus_to_physid[bus] = 0;
431+ segment = pci_domain_nr(dev->bus);
432+
433+ raw_spin_lock(&pci2phy_map_lock);
434+ map = __find_pci2phy_map(segment);
435+ if (!map) {
436+ raw_spin_unlock(&pci2phy_map_lock);
437+ pci_dev_put(dev);
438+ return -ENOMEM;
439+ }
440+ map->pbus_to_physid[bus] = 0;
441+ raw_spin_unlock(&pci2phy_map_lock);
432442
433443 pci_dev_put(dev);
434444
arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c+25−9
@@ -1087,7 +1087,8 @@ static struct pci_driver snbep_uncore_pci_driver = { · 1086 unmodified lines
10871087 static int snbep_pci2phy_map_init(int devid)
10881088 {
10891089 struct pci_dev *ubox_dev = NULL;
1090− int i, bus, nodeid;
1090+ int i, bus, nodeid, segment;
1091+ struct pci2phy_map *map;
10911092 int err = 0;
10921093 u32 config = 0;
10931094
@@ -1106,16 +1107,27 @@ static int snbep_pci2phy_map_init(int devid) · 12 unmodified lines
11061107 err = pci_read_config_dword(ubox_dev, 0x54, &config);
11071108 if (err)
11081109 break;
1110+
1111+ segment = pci_domain_nr(ubox_dev->bus);
1112+ raw_spin_lock(&pci2phy_map_lock);
1113+ map = __find_pci2phy_map(segment);
1114+ if (!map) {
1115+ raw_spin_unlock(&pci2phy_map_lock);
1116+ err = -ENOMEM;
1117+ break;
1118+ }
1119+
11091120 /*
11101121 * every three bits in the Node ID mapping register maps
11111122 * to a particular node.
11121123 */
11131124 for (i = 0; i < 8; i++) {
11141125 if (nodeid == ((config >> (3 * i)) & 0x7)) {
1115− uncore_pcibus_to_physid[bus] = i;
1126+ map->pbus_to_physid[bus] = i;
11161127 break;
11171128 }
11181129 }
1130+ raw_spin_unlock(&pci2phy_map_lock);
11191131 }
11201132
11211133 if (!err) {
@@ -1123,13 +1135,17 @@ static int snbep_pci2phy_map_init(int devid) · 1 unmodified line
11231135 * For PCI bus with no UBOX device, find the next bus
11241136 * that has UBOX device and use its mapping.
11251137 */
1126− i = -1;
1127− for (bus = 255; bus >= 0; bus--) {
1128− if (uncore_pcibus_to_physid[bus] >= 0)
1129− i = uncore_pcibus_to_physid[bus];
1130− else
1131− uncore_pcibus_to_physid[bus] = i;
1138+ raw_spin_lock(&pci2phy_map_lock);
1139+ list_for_each_entry(map, &pci2phy_map_head, list) {
1140+ i = -1;
1141+ for (bus = 255; bus >= 0; bus--) {
1142+ if (map->pbus_to_physid[bus] >= 0)
1143+ i = map->pbus_to_physid[bus];
1144+ else
1145+ map->pbus_to_physid[bus] = i;
1146+ }
11321147 }
1148+ raw_spin_unlock(&pci2phy_map_lock);
11331149 }
11341150
11351151 pci_dev_put(ubox_dev);
@@ -2444,7 +2460,7 @@ static struct intel_uncore_type *bdx_pci_uncores[] = { · 1308 unmodified lines
24442460 NULL,
24452461 };
24462462
2447−static DEFINE_PCI_DEVICE_TABLE(bdx_uncore_pci_ids) = {
2463+static const struct pci_device_id bdx_uncore_pci_ids[] = {
24482464 { /* Home Agent 0 */
24492465 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f30),
24502466 .driver_data = UNCORE_PCI_DEV_DATA(BDX_PCI_UNCORE_HA, 0),
arch/x86/kernel/tsc.c+22−13
@@ -168,21 +168,20 @@ static void cyc2ns_write_end(int cpu, struct cyc2ns_data *data) · 167 unmodified lines
168168 * ns = cycles * cyc2ns_scale / SC
169169 *
170170 * And since SC is a constant power of two, we can convert the div
171− * into a shift.
171+ * into a shift. The larger SC is, the more accurate the conversion, but
172+ * cyc2ns_scale needs to be a 32-bit value so that 32-bit multiplication
173+ * (64-bit result) can be used.
172174 *
173− * We can use khz divisor instead of mhz to keep a better precision, since
174− * cyc2ns_scale is limited to 10^6 * 2^10, which fits in 32 bits.
175+ * We can use khz divisor instead of mhz to keep a better precision.
175176 * (mathieu.desnoyers@polymtl.ca)
176177 *
177178 * -johnstul@us.ibm.com "math is hard, lets go shopping!"
178179 */
179180
180−#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
181−
182181 static void cyc2ns_data_init(struct cyc2ns_data *data)
183182 {
184183 data->cyc2ns_mul = 0;
185− data->cyc2ns_shift = CYC2NS_SCALE_FACTOR;
184+ data->cyc2ns_shift = 0;
186185 data->cyc2ns_offset = 0;
187186 data->__count = 0;
188187 }
@@ -216,14 +215,14 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc) · 27 unmodified lines
216215
217216 if (likely(data == tail)) {
218217 ns = data->cyc2ns_offset;
219− ns += mul_u64_u32_shr(cyc, data->cyc2ns_mul, CYC2NS_SCALE_FACTOR);
218+ ns += mul_u64_u32_shr(cyc, data->cyc2ns_mul, data->cyc2ns_shift);
220219 } else {
221220 data->__count++;
222221
223222 barrier();
224223
225224 ns = data->cyc2ns_offset;
226− ns += mul_u64_u32_shr(cyc, data->cyc2ns_mul, CYC2NS_SCALE_FACTOR);
225+ ns += mul_u64_u32_shr(cyc, data->cyc2ns_mul, data->cyc2ns_shift);
227226
228227 barrier();
229228
@@ -257,12 +256,22 @@ static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu) · 27 unmodified lines
257256 * time function is continuous; see the comment near struct
258257 * cyc2ns_data.
259258 */
260− data->cyc2ns_mul =
261− DIV_ROUND_CLOSEST(NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR,
262− cpu_khz);
263− data->cyc2ns_shift = CYC2NS_SCALE_FACTOR;
259+ clocks_calc_mult_shift(&data->cyc2ns_mul, &data->cyc2ns_shift, cpu_khz,
260+ NSEC_PER_MSEC, 0);
261+
262+ /*
263+ * cyc2ns_shift is exported via arch_perf_update_userpage() where it is
264+ * not expected to be greater than 31 due to the original published
265+ * conversion algorithm shifting a 32-bit value (now specifies a 64-bit
266+ * value) - refer perf_event_mmap_page documentation in perf_event.h.
267+ */
268+ if (data->cyc2ns_shift == 32) {
269+ data->cyc2ns_shift = 31;
270+ data->cyc2ns_mul >>= 1;
271+ }
272+
264273 data->cyc2ns_offset = ns_now -
265− mul_u64_u32_shr(tsc_now, data->cyc2ns_mul, CYC2NS_SCALE_FACTOR);
274+ mul_u64_u32_shr(tsc_now, data->cyc2ns_mul, data->cyc2ns_shift);
266275
267276 cyc2ns_write_end(cpu, data);
268277
arch/x86/lib/x86-opcode-map.txt+19−5
@@ -353,8 +353,12 @@ AVXcode: 1 · 352 unmodified lines
353353 17: vmovhps Mq,Vq (v1) | vmovhpd Mq,Vq (66),(v1)
354354 18: Grp16 (1A)
355355 19:
356−1a: BNDCL Ev,Gv | BNDCU Ev,Gv | BNDMOV Gv,Ev | BNDLDX Gv,Ev,Gv
357−1b: BNDCN Ev,Gv | BNDMOV Ev,Gv | BNDMK Gv,Ev | BNDSTX Ev,GV,Gv
356+# Intel SDM opcode map does not list MPX instructions. For now using Gv for
357+# bnd registers and Ev for everything else is OK because the instruction
358+# decoder does not use the information except as an indication that there is
359+# a ModR/M byte.
360+1a: BNDCL Gv,Ev (F3) | BNDCU Gv,Ev (F2) | BNDMOV Gv,Ev (66) | BNDLDX Gv,Ev
361+1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv
358362 1c:
359363 1d:
360364 1e:
@@ -732,6 +736,12 @@ bd: vfnmadd231ss/d Vx,Hx,Wx (66),(v),(v1) · 371 unmodified lines
732736 be: vfnmsub231ps/d Vx,Hx,Wx (66),(v)
733737 bf: vfnmsub231ss/d Vx,Hx,Wx (66),(v),(v1)
734738 # 0x0f 0x38 0xc0-0xff
739+c8: sha1nexte Vdq,Wdq
740+c9: sha1msg1 Vdq,Wdq
741+ca: sha1msg2 Vdq,Wdq
742+cb: sha256rnds2 Vdq,Wdq
743+cc: sha256msg1 Vdq,Wdq
744+cd: sha256msg2 Vdq,Wdq
735745 db: VAESIMC Vdq,Wdq (66),(v1)
736746 dc: VAESENC Vdq,Hdq,Wdq (66),(v1)
737747 dd: VAESENCLAST Vdq,Hdq,Wdq (66),(v1)
@@ -790,6 +800,7 @@ AVXcode: 3 · 52 unmodified lines
790800 61: vpcmpestri Vdq,Wdq,Ib (66),(v1)
791801 62: vpcmpistrm Vdq,Wdq,Ib (66),(v1)
792802 63: vpcmpistri Vdq,Wdq,Ib (66),(v1)
803+cc: sha1rnds4 Vdq,Wdq,Ib
793804 df: VAESKEYGEN Vdq,Wdq,Ib (66),(v1)
794805 f0: RORX Gy,Ey,Ib (F2),(v)
795806 EndTable
@@ -874,7 +885,7 @@ GrpTable: Grp7 · 78 unmodified lines
874885 2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B)
875886 3: LIDT Ms
876887 4: SMSW Mw/Rv
877−5:
888+5: rdpkru (110),(11B) | wrpkru (111),(11B)
878889 6: LMSW Ew
879890 7: INVLPG Mb | SWAPGS (o64),(000),(11B) | RDTSCP (001),(11B)
880891 EndTable
@@ -888,6 +899,9 @@ EndTable · 7 unmodified lines
888899
889900 GrpTable: Grp9
890901 1: CMPXCHG8B/16B Mq/Mdq
902+3: xrstors
903+4: xsavec
904+5: xsaves
891905 6: VMPTRLD Mq | VMCLEAR Mq (66) | VMXON Mq (F3) | RDRAND Rv (11B)
892906 7: VMPTRST Mq | VMPTRST Mq (F3) | RDSEED Rv (11B)
893907 EndTable
@@ -932,8 +946,8 @@ GrpTable: Grp15 · 38 unmodified lines
932946 3: vstmxcsr Md (v1) | WRGSBASE Ry (F3),(11B)
933947 4: XSAVE
934948 5: XRSTOR | lfence (11B)
935−6: XSAVEOPT | mfence (11B)
936−7: clflush | sfence (11B)
949+6: XSAVEOPT | clwb (66) | mfence (11B)
950+7: clflush | clflushopt (66) | sfence (11B) | pcommit (66),(11B)
937951 EndTable
938952
939953 GrpTable: Grp16
include/linux/perf_event.h+103−17
@@ -140,33 +140,67 @@ struct hw_perf_event { · 139 unmodified lines
140140 };
141141 #endif
142142 };
143+ /*
144+ * If the event is a per task event, this will point to the task in
145+ * question. See the comment in perf_event_alloc().
146+ */
143147 struct task_struct *target;
148+
149+/*
150+ * hw_perf_event::state flags; used to track the PERF_EF_* state.
151+ */
152+#define PERF_HES_STOPPED 0x01 /* the counter is stopped */
153+#define PERF_HES_UPTODATE 0x02 /* event->count up-to-date */
154+#define PERF_HES_ARCH 0x04
155+
144156 int state;
157+
158+ /*
159+ * The last observed hardware counter value, updated with a
160+ * local64_cmpxchg() such that pmu::read() can be called nested.
161+ */
145162 local64_t prev_count;
163+
164+ /*
165+ * The period to start the next sample with.
166+ */
146167 u64 sample_period;
168+
169+ /*
170+ * The period we started this sample with.
171+ */
147172 u64 last_period;
173+
174+ /*
175+ * However much is left of the current period; note that this is
176+ * a full 64bit value and allows for generation of periods longer
177+ * than hardware might allow.
178+ */
148179 local64_t period_left;
180+
181+ /*
182+ * State for throttling the event, see __perf_event_overflow() and
183+ * perf_adjust_freq_unthr_context().
184+ */
149185 u64 interrupts_seq;
150186 u64 interrupts;
151187
188+ /*
189+ * State for freq target events, see __perf_event_overflow() and
190+ * perf_adjust_freq_unthr_context().
191+ */
152192 u64 freq_time_stamp;
153193 u64 freq_count_stamp;
154194 #endif
155195 };
156196
157−/*
158− * hw_perf_event::state flags
159− */
160−#define PERF_HES_STOPPED 0x01 /* the counter is stopped */
161−#define PERF_HES_UPTODATE 0x02 /* event->count up-to-date */
162−#define PERF_HES_ARCH 0x04
163−
164197 struct perf_event;
165198
166199 /*
167200 * Common implementation detail of pmu::{start,commit,cancel}_txn
168201 */
169−#define PERF_EVENT_TXN 0x1
202+#define PERF_PMU_TXN_ADD 0x1 /* txn to add/schedule event on PMU */
203+#define PERF_PMU_TXN_READ 0x2 /* txn to read event group from PMU */
170204
171205 /**
172206 * pmu::capabilities flags
@@ -210,7 +244,19 @@ struct pmu { · 37 unmodified lines
210244
211245 /*
212246 * Try and initialize the event for this PMU.
213− * Should return -ENOENT when the @event doesn't match this PMU.
247+ *
248+ * Returns:
249+ * -ENOENT -- @event is not for this PMU
250+ *
251+ * -ENODEV -- @event is for this PMU but PMU not present
252+ * -EBUSY -- @event is for this PMU but PMU temporarily unavailable
253+ * -EINVAL -- @event is for this PMU but @event is not valid
254+ * -EOPNOTSUPP -- @event is for this PMU, @event is valid, but not supported
255+ * -EACCESS -- @event is for this PMU, @event is valid, but no privilidges
256+ *
257+ * 0 -- @event is for this PMU and valid
258+ *
259+ * Other error return values are allowed.
214260 */
215261 int (*event_init) (struct perf_event *event);
216262
@@ -221,27 +267,61 @@ struct pmu { · 4 unmodified lines
221267 void (*event_mapped) (struct perf_event *event); /*optional*/
222268 void (*event_unmapped) (struct perf_event *event); /*optional*/
223269
270+ /*
271+ * Flags for ->add()/->del()/ ->start()/->stop(). There are
272+ * matching hw_perf_event::state flags.
273+ */
224274 #define PERF_EF_START 0x01 /* start the counter when adding */
225275 #define PERF_EF_RELOAD 0x02 /* reload the counter when starting */
226276 #define PERF_EF_UPDATE 0x04 /* update the counter when stopping */
227277
228278 /*
229− * Adds/Removes a counter to/from the PMU, can be done inside
230− * a transaction, see the ->*_txn() methods.
279+ * Adds/Removes a counter to/from the PMU, can be done inside a
280+ * transaction, see the ->*_txn() methods.
281+ *
282+ * The add/del callbacks will reserve all hardware resources required
283+ * to service the event, this includes any counter constraint
284+ * scheduling etc.
285+ *
286+ * Called with IRQs disabled and the PMU disabled on the CPU the event
287+ * is on.
288+ *
289+ * ->add() called without PERF_EF_START should result in the same state
290+ * as ->add() followed by ->stop().
291+ *
292+ * ->del() must always PERF_EF_UPDATE stop an event. If it calls
293+ * ->stop() that must deal with already being stopped without
294+ * PERF_EF_UPDATE.
231295 */
232296 int (*add) (struct perf_event *event, int flags);
233297 void (*del) (struct perf_event *event, int flags);
234298
235299 /*
236− * Starts/Stops a counter present on the PMU. The PMI handler
237− * should stop the counter when perf_event_overflow() returns
238− * !0. ->start() will be used to continue.
300+ * Starts/Stops a counter present on the PMU.
301+ *
302+ * The PMI handler should stop the counter when perf_event_overflow()
303+ * returns !0. ->start() will be used to continue.
304+ *
305+ * Also used to change the sample period.
306+ *
307+ * Called with IRQs disabled and the PMU disabled on the CPU the event
308+ * is on -- will be called from NMI context with the PMU generates
309+ * NMIs.
310+ *
311+ * ->stop() with PERF_EF_UPDATE will read the counter and update
312+ * period/count values like ->read() would.
313+ *
314+ * ->start() with PERF_EF_RELOAD will reprogram the the counter
315+ * value, must be preceded by a ->stop() with PERF_EF_UPDATE.
239316 */
240317 void (*start) (struct perf_event *event, int flags);
241318 void (*stop) (struct perf_event *event, int flags);
242319
243320 /*
244321 * Updates the counter value of the event.
322+ *
323+ * For sampling capable PMUs this will also update the software period
324+ * hw_perf_event::period_left field.
245325 */
246326 void (*read) (struct perf_event *event);
247327
@@ -252,20 +332,26 @@ struct pmu { · 4 unmodified lines
252332 *
253333 * Start the transaction, after this ->add() doesn't need to
254334 * do schedulability tests.
335+ *
336+ * Optional.
255337 */
256− void (*start_txn) (struct pmu *pmu); /* optional */
338+ void (*start_txn) (struct pmu *pmu, unsigned int txn_flags);
257339 /*
258340 * If ->start_txn() disabled the ->add() schedulability test
259341 * then ->commit_txn() is required to perform one. On success
260342 * the transaction is closed. On error the transaction is kept
261343 * open until ->cancel_txn() is called.
344+ *
345+ * Optional.
262346 */
263− int (*commit_txn) (struct pmu *pmu); /* optional */
347+ int (*commit_txn) (struct pmu *pmu);
264348 /*
265349 * Will cancel the transaction, assumes ->del() is called
266350 * for each successful ->add() during the transaction.
351+ *
352+ * Optional.
267353 */
268− void (*cancel_txn) (struct pmu *pmu); /* optional */
354+ void (*cancel_txn) (struct pmu *pmu);
269355
270356 /*
271357 * Will return the value for perf_event_mmap_page::index for this event,
include/uapi/linux/perf_event.h+4−2
@@ -168,6 +168,7 @@ enum perf_branch_sample_type_shift { · 167 unmodified lines
168168
169169 PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT = 11, /* call/ret stack */
170170 PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT = 12, /* indirect jumps */
171+ PERF_SAMPLE_BRANCH_CALL_SHIFT = 13, /* direct call */
171172
172173 PERF_SAMPLE_BRANCH_MAX_SHIFT /* non-ABI */
173174 };
@@ -188,6 +189,7 @@ enum perf_branch_sample_type { · 14 unmodified lines
188189
189190 PERF_SAMPLE_BRANCH_CALL_STACK = 1U << PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT,
190191 PERF_SAMPLE_BRANCH_IND_JUMP = 1U << PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT,
192+ PERF_SAMPLE_BRANCH_CALL = 1U << PERF_SAMPLE_BRANCH_CALL_SHIFT,
191193
192194 PERF_SAMPLE_BRANCH_MAX = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
193195 };
@@ -476,7 +478,7 @@ struct perf_event_mmap_page { · 282 unmodified lines
476478 * u64 delta;
477479 *
478480 * quot = (cyc >> time_shift);
479− * rem = cyc & ((1 << time_shift) - 1);
481+ * rem = cyc & (((u64)1 << time_shift) - 1);
480482 * delta = time_offset + quot * time_mult +
481483 * ((rem * time_mult) >> time_shift);
482484 *
@@ -507,7 +509,7 @@ struct perf_event_mmap_page { · 24 unmodified lines
507509 * And vice versa:
508510 *
509511 * quot = cyc >> time_shift;
510− * rem = cyc & ((1 << time_shift) - 1);
512+ * rem = cyc & (((u64)1 << time_shift) - 1);
511513 * timestamp = time_zero + quot * time_mult +
512514 * ((rem * time_mult) >> time_shift);
513515 */
kernel/events/core.c+165−59
@@ -196,7 +196,7 @@ static int perf_sample_period_ns __read_mostly = DEFAULT_SAMPLE_PERIOD_NS; · 195 unmodified lines
196196 static int perf_sample_allowed_ns __read_mostly =
197197 DEFAULT_SAMPLE_PERIOD_NS * DEFAULT_CPU_TIME_MAX_PERCENT / 100;
198198
199−void update_perf_cpu_limits(void)
199+static void update_perf_cpu_limits(void)
200200 {
201201 u64 tmp = perf_sample_period_ns;
202202
@@ -472,7 +472,7 @@ perf_cgroup_set_timestamp(struct task_struct *task, · 269 unmodified lines
472472 * mode SWOUT : schedule out everything
473473 * mode SWIN : schedule in based on cgroup for next
474474 */
475−void perf_cgroup_switch(struct task_struct *task, int mode)
475+static void perf_cgroup_switch(struct task_struct *task, int mode)
476476 {
477477 struct perf_cpu_context *cpuctx;
478478 struct pmu *pmu;
@@ -1939,7 +1939,7 @@ group_sched_in(struct perf_event *group_event, · 1460 unmodified lines
19391939 if (group_event->state == PERF_EVENT_STATE_OFF)
19401940 return 0;
19411941
1942− pmu->start_txn(pmu);
1942+ pmu->start_txn(pmu, PERF_PMU_TXN_ADD);
19431943
19441944 if (event_sched_in(group_event, cpuctx, ctx)) {
19451945 pmu->cancel_txn(pmu);
@@ -3209,14 +3209,22 @@ void perf_event_exec(void) · 1263 unmodified lines
32093209 rcu_read_unlock();
32103210 }
32113211
3212+struct perf_read_data {
3213+ struct perf_event *event;
3214+ bool group;
3215+ int ret;
3216+};
3217+
32123218 /*
32133219 * Cross CPU call to read the hardware event
32143220 */
32153221 static void __perf_event_read(void *info)
32163222 {
3217− struct perf_event *event = info;
3223+ struct perf_read_data *data = info;
3224+ struct perf_event *sub, *event = data->event;
32183225 struct perf_event_context *ctx = event->ctx;
32193226 struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
3227+ struct pmu *pmu = event->pmu;
32203228
32213229 /*
32223230 * If this is a task context, we need to check whether it is
@@ -3233,9 +3241,35 @@ static void __perf_event_read(void *info) · 10 unmodified lines
32333241 update_context_time(ctx);
32343242 update_cgrp_time_from_event(event);
32353243 }
3244+
32363245 update_event_times(event);
3237− if (event->state == PERF_EVENT_STATE_ACTIVE)
3238− event->pmu->read(event);
3246+ if (event->state != PERF_EVENT_STATE_ACTIVE)
3247+ goto unlock;
3248+
3249+ if (!data->group) {
3250+ pmu->read(event);
3251+ data->ret = 0;
3252+ goto unlock;
3253+ }
3254+
3255+ pmu->start_txn(pmu, PERF_PMU_TXN_READ);
3256+
3257+ pmu->read(event);
3258+
3259+ list_for_each_entry(sub, &event->sibling_list, group_entry) {
3260+ update_event_times(sub);
3261+ if (sub->state == PERF_EVENT_STATE_ACTIVE) {
3262+ /*
3263+ * Use sibling's PMU rather than @event's since
3264+ * sibling could be on different (eg: software) PMU.
3265+ */
3266+ sub->pmu->read(sub);
3267+ }
3268+ }
3269+
3270+ data->ret = pmu->commit_txn(pmu);
3271+
3272+unlock:
32393273 raw_spin_unlock(&ctx->lock);
32403274 }
32413275
@@ -3300,15 +3334,23 @@ u64 perf_event_read_local(struct perf_event *event) · 58 unmodified lines
33003334 return val;
33013335 }
33023336
3303−static u64 perf_event_read(struct perf_event *event)
3337+static int perf_event_read(struct perf_event *event, bool group)
33043338 {
3339+ int ret = 0;
3340+
33053341 /*
33063342 * If event is enabled and currently active on a CPU, update the
33073343 * value in the event structure:
33083344 */
33093345 if (event->state == PERF_EVENT_STATE_ACTIVE) {
3346+ struct perf_read_data data = {
3347+ .event = event,
3348+ .group = group,
3349+ .ret = 0,
3350+ };
33103351 smp_call_function_single(event->oncpu,
3311− __perf_event_read, event, 1);
3352+ __perf_event_read, &data, 1);
3353+ ret = data.ret;
33123354 } else if (event->state == PERF_EVENT_STATE_INACTIVE) {
33133355 struct perf_event_context *ctx = event->ctx;
33143356 unsigned long flags;
@@ -3323,11 +3365,14 @@ static u64 perf_event_read(struct perf_event *event) · 8 unmodified lines
33233365 update_context_time(ctx);
33243366 update_cgrp_time_from_event(event);
33253367 }
3326− update_event_times(event);
3368+ if (group)
3369+ update_group_times(event);
3370+ else
3371+ update_event_times(event);
33273372 raw_spin_unlock_irqrestore(&ctx->lock, flags);
33283373 }
33293374
3330− return perf_event_count(event);
3375+ return ret;
33313376 }
33323377
33333378 /*
@@ -3769,7 +3814,7 @@ static void put_event(struct perf_event *event) · 435 unmodified lines
37693814 * see the comment there.
37703815 *
37713816 * 2) there is a lock-inversion with mmap_sem through
3772− * perf_event_read_group(), which takes faults while
3817+ * perf_read_group(), which takes faults while
37733818 * holding ctx->mutex, however this is called after
37743819 * the last filedesc died, so there is no possibility
37753820 * to trigger the AB-BA case.
@@ -3843,14 +3888,18 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running) · 67 unmodified lines
38433888 *running = 0;
38443889
38453890 mutex_lock(&event->child_mutex);
3846− total += perf_event_read(event);
3891+
3892+ (void)perf_event_read(event, false);
3893+ total += perf_event_count(event);
3894+
38473895 *enabled += event->total_time_enabled +
38483896 atomic64_read(&event->child_total_time_enabled);
38493897 *running += event->total_time_running +
38503898 atomic64_read(&event->child_total_time_running);
38513899
38523900 list_for_each_entry(child, &event->child_list, child_list) {
3853− total += perf_event_read(child);
3901+ (void)perf_event_read(child, false);
3902+ total += perf_event_count(child);
38543903 *enabled += child->total_time_enabled;
38553904 *running += child->total_time_running;
38563905 }
@@ -3860,55 +3909,95 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running) · 3 unmodified lines
38603909 }
38613910 EXPORT_SYMBOL_GPL(perf_event_read_value);
38623911
3863−static int perf_event_read_group(struct perf_event *event,
3864− u64 read_format, char __user *buf)
3912+static int __perf_read_group_add(struct perf_event *leader,
3913+ u64 read_format, u64 *values)
38653914 {
3866− struct perf_event *leader = event->group_leader, *sub;
3867− struct perf_event_context *ctx = leader->ctx;
3868− int n = 0, size = 0, ret;
3869− u64 count, enabled, running;
3870− u64 values[5];
3915+ struct perf_event *sub;
3916+ int n = 1; /* skip @nr */
3917+ int ret;
38713918
3872− lockdep_assert_held(&ctx->mutex);
3919+ ret = perf_event_read(leader, true);
3920+ if (ret)
3921+ return ret;
38733922
3874− count = perf_event_read_value(leader, &enabled, &running);
3923+ /*
3924+ * Since we co-schedule groups, {enabled,running} times of siblings
3925+ * will be identical to those of the leader, so we only publish one
3926+ * set.
3927+ */
3928+ if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
3929+ values[n++] += leader->total_time_enabled +
3930+ atomic64_read(&leader->child_total_time_enabled);
3931+ }
38753932
3876− values[n++] = 1 + leader->nr_siblings;
3877− if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
3878− values[n++] = enabled;
3879− if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
3880− values[n++] = running;
3881− values[n++] = count;
3933+ if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
3934+ values[n++] += leader->total_time_running +
3935+ atomic64_read(&leader->child_total_time_running);
3936+ }
3937+
3938+ /*
3939+ * Write {count,id} tuples for every sibling.
3940+ */
3941+ values[n++] += perf_event_count(leader);
38823942 if (read_format & PERF_FORMAT_ID)
38833943 values[n++] = primary_event_id(leader);
38843944
3885− size = n * sizeof(u64);
3945+ list_for_each_entry(sub, &leader->sibling_list, group_entry) {
3946+ values[n++] += perf_event_count(sub);
3947+ if (read_format & PERF_FORMAT_ID)
3948+ values[n++] = primary_event_id(sub);
3949+ }
38863950
3887− if (copy_to_user(buf, values, size))
3888− return -EFAULT;
3951+ return 0;
3952+}
3953+
3954+static int perf_read_group(struct perf_event *event,
3955+ u64 read_format, char __user *buf)
3956+{
3957+ struct perf_event *leader = event->group_leader, *child;
3958+ struct perf_event_context *ctx = leader->ctx;
3959+ int ret;
3960+ u64 *values;
38893961
3890− ret = size;
3962+ lockdep_assert_held(&ctx->mutex);
38913963
3892− list_for_each_entry(sub, &leader->sibling_list, group_entry) {
3893− n = 0;
3964+ values = kzalloc(event->read_size, GFP_KERNEL);
3965+ if (!values)
3966+ return -ENOMEM;
38943967
3895− values[n++] = perf_event_read_value(sub, &enabled, &running);
3896− if (read_format & PERF_FORMAT_ID)
3897− values[n++] = primary_event_id(sub);
3968+ values[0] = 1 + leader->nr_siblings;
38983969
3899− size = n * sizeof(u64);
3970+ /*
3971+ * By locking the child_mutex of the leader we effectively
3972+ * lock the child list of all siblings.. XXX explain how.
3973+ */
3974+ mutex_lock(&leader->child_mutex);
39003975
3901− if (copy_to_user(buf + ret, values, size)) {
3902− return -EFAULT;
3903− }
3976+ ret = __perf_read_group_add(leader, read_format, values);
3977+ if (ret)
3978+ goto unlock;
39043979
3905− ret += size;
3980+ list_for_each_entry(child, &leader->child_list, child_list) {
3981+ ret = __perf_read_group_add(child, read_format, values);
3982+ if (ret)
3983+ goto unlock;
39063984 }
39073985
3986+ mutex_unlock(&leader->child_mutex);
3987+
3988+ ret = event->read_size;
3989+ if (copy_to_user(buf, values, event->read_size))
3990+ ret = -EFAULT;
3991+ goto out;
3992+
3993+unlock:
3994+ mutex_unlock(&leader->child_mutex);
3995+out:
3996+ kfree(values);
39083997 return ret;
39093998 }
39103999
3911−static int perf_event_read_one(struct perf_event *event,
4000+static int perf_read_one(struct perf_event *event,
39124001 u64 read_format, char __user *buf)
39134002 {
39144003 u64 enabled, running;
@@ -3946,7 +4035,7 @@ static bool is_event_hup(struct perf_event *event) · 31 unmodified lines
39464035 * Read the performance event - simple non blocking version for now
39474036 */
39484037 static ssize_t
3949−perf_read_hw(struct perf_event *event, char __user *buf, size_t count)
4038+__perf_read(struct perf_event *event, char __user *buf, size_t count)
39504039 {
39514040 u64 read_format = event->attr.read_format;
39524041 int ret;
@@ -3964,9 +4053,9 @@ perf_read_hw(struct perf_event *event, char __user *buf, size_t count) · 11 unmodified lines
39644053
39654054 WARN_ON_ONCE(event->ctx->parent_ctx);
39664055 if (read_format & PERF_FORMAT_GROUP)
3967− ret = perf_event_read_group(event, read_format, buf);
4056+ ret = perf_read_group(event, read_format, buf);
39684057 else
3969− ret = perf_event_read_one(event, read_format, buf);
4058+ ret = perf_read_one(event, read_format, buf);
39704059
39714060 return ret;
39724061 }
@@ -3979,7 +4068,7 @@ perf_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) · 6 unmodified lines
39794068 int ret;
39804069
39814070 ctx = perf_event_ctx_lock(event);
3982− ret = perf_read_hw(event, buf, count);
4071+ ret = __perf_read(event, buf, count);
39834072 perf_event_ctx_unlock(event, ctx);
39844073
39854074 return ret;
@@ -4010,7 +4099,7 @@ static unsigned int perf_poll(struct file *file, poll_table *wait) · 24 unmodified lines
40104099
40114100 static void _perf_event_reset(struct perf_event *event)
40124101 {
4013− (void)perf_event_read(event);
4102+ (void)perf_event_read(event, false);
40144103 local64_set(&event->count, 0);
40154104 perf_event_update_userpage(event);
40164105 }
@@ -7292,24 +7381,49 @@ static void perf_pmu_nop_void(struct pmu *pmu) · 3275 unmodified lines
72927381 {
72937382 }
72947383
7384+static void perf_pmu_nop_txn(struct pmu *pmu, unsigned int flags)
7385+{
7386+}
7387+
72957388 static int perf_pmu_nop_int(struct pmu *pmu)
72967389 {
72977390 return 0;
72987391 }
72997392
7300−static void perf_pmu_start_txn(struct pmu *pmu)
7393+static DEFINE_PER_CPU(unsigned int, nop_txn_flags);
7394+
7395+static void perf_pmu_start_txn(struct pmu *pmu, unsigned int flags)
73017396 {
7397+ __this_cpu_write(nop_txn_flags, flags);
7398+
7399+ if (flags & ~PERF_PMU_TXN_ADD)
7400+ return;
7401+
73027402 perf_pmu_disable(pmu);
73037403 }
73047404
73057405 static int perf_pmu_commit_txn(struct pmu *pmu)
73067406 {
7407+ unsigned int flags = __this_cpu_read(nop_txn_flags);
7408+
7409+ __this_cpu_write(nop_txn_flags, 0);
7410+
7411+ if (flags & ~PERF_PMU_TXN_ADD)
7412+ return 0;
7413+
73077414 perf_pmu_enable(pmu);
73087415 return 0;
73097416 }
73107417
73117418 static void perf_pmu_cancel_txn(struct pmu *pmu)
73127419 {
7420+ unsigned int flags = __this_cpu_read(nop_txn_flags);
7421+
7422+ __this_cpu_write(nop_txn_flags, 0);
7423+
7424+ if (flags & ~PERF_PMU_TXN_ADD)
7425+ return;
7426+
73137427 perf_pmu_enable(pmu);
73147428 }
73157429
@@ -7548,7 +7662,7 @@ got_cpu_context: · 232 unmodified lines
75487662 pmu->commit_txn = perf_pmu_commit_txn;
75497663 pmu->cancel_txn = perf_pmu_cancel_txn;
75507664 } else {
7551− pmu->start_txn = perf_pmu_nop_void;
7665+ pmu->start_txn = perf_pmu_nop_txn;
75527666 pmu->commit_txn = perf_pmu_nop_int;
75537667 pmu->cancel_txn = perf_pmu_nop_void;
75547668 }
@@ -7636,7 +7750,7 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event) · 81 unmodified lines
76367750 return ret;
76377751 }
76387752
7639−struct pmu *perf_init_event(struct perf_event *event)
7753+static struct pmu *perf_init_event(struct perf_event *event)
76407754 {
76417755 struct pmu *pmu = NULL;
76427756 int idx;
@@ -9345,14 +9459,6 @@ static void perf_cgroup_exit(struct cgroup_subsys_state *css, · 1702 unmodified lines
93459459 struct cgroup_subsys_state *old_css,
93469460 struct task_struct *task)
93479461 {
9348− /*
9349− * cgroup_exit() is called in the copy_process() failure path.
9350− * Ignore this case since the task hasn't ran yet, this avoids
9351− * trying to poke a half freed task state from generic code.
9352− */
9353− if (!(task->flags & PF_EXITING))
9354− return;
9355−
93569462 task_function_call(task, __perf_cgroup_move, task);
93579463 }
93589464
tools/build/.gitignore+1−0
@@ -0,0 +1 @@
1+fixdep
tools/build/Build+1−0
@@ -0,0 +1 @@
1+fixdep-y := fixdep.o
tools/build/Build.include+14−3
@@ -54,15 +54,26 @@ make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) · 53 unmodified lines
5454 # PHONY targets skipped in both cases.
5555 any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
5656
57+###
58+# Copy dependency data into .cmd file
59+# - gcc -M dependency info
60+# - command line to create object 'cmd_object :='
61+dep-cmd = $(if $(wildcard $(fixdep)), \
62+ $(fixdep) $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp; \
63+ rm -f $(depfile); \
64+ mv -f $(dot-target).tmp $(dot-target).cmd, \
65+ printf '\# cannot find fixdep (%s)\n' $(fixdep) > $(dot-target).cmd; \
66+ printf '\# using basic dep data\n\n' >> $(dot-target).cmd; \
67+ cat $(depfile) >> $(dot-target).cmd; \
68+ printf '%s\n' 'cmd_$@ := $(make-cmd)' >> $(dot-target).cmd)
69+
5770 ###
5871 # if_changed_dep - execute command if any prerequisite is newer than
5972 # target, or command line has changed and update
6073 # dependencies in the cmd file
6174 if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)), \
6275 @set -e; \
63− $(echo-cmd) $(cmd_$(1)); \
64− cat $(depfile) > $(dot-target).cmd; \
65− printf '%s\n' 'cmd_$@ := $(make-cmd)' >> $(dot-target).cmd)
76+ $(echo-cmd) $(cmd_$(1)) && $(dep-cmd))
6677
6778 # if_changed - execute command if any prerequisite is newer than
6879 # target, or command line has changed
tools/build/Documentation/Build.txt+39−13
@@ -11,8 +11,9 @@ Unlike the kernel we don't have a single build object 'obj-y' list that where · 10 unmodified lines
1111 we setup source objects, but we support more. This allows one 'Build' file to
1212 carry a sources list for multiple build objects.
1313
14−a) Build framework makefiles
15−----------------------------
14+
15+Build framework makefiles
16+-------------------------
1617
1718 The build framework consists of 2 Makefiles:
1819
@@ -23,7 +24,7 @@ While the 'Build.include' file contains just some generic definitions, the · 4 unmodified lines
2324 'Makefile.build' file is the makefile used from the outside. It's
2425 interface/usage is following:
2526
26− $ make -f tools/build/Makefile srctree=$(KSRC) dir=$(DIR) obj=$(OBJECT)
27+ $ make -f tools/build/Makefile.build srctree=$(KSRC) dir=$(DIR) obj=$(OBJECT)
2728
2829 where:
2930
@@ -38,8 +39,9 @@ called $(OBJECT)-in.o: · 8 unmodified lines
3839
3940 which includes all compiled sources described in 'Build' makefiles.
4041
41−a) Build makefiles
42−------------------
42+
43+Build makefiles
44+---------------
4345
4446 The user supplies 'Build' makefiles that contains a objects list, and connects
4547 the build to nested directories.
@@ -95,8 +97,31 @@ It's only a matter of 2 single commands to create the final binaries: · 49 unmodified lines
9597
9698 You can check the 'ex' example in 'tools/build/tests/ex' for more details.
9799
98−b) Rules
99−--------
100+
101+Makefile.include
102+----------------
103+
104+The tools/build/Makefile.include makefile could be included
105+via user makefiles to get usefull definitions.
106+
107+It defines following interface:
108+
109+ - build macro definition:
110+ build := -f $(srctree)/tools/build/Makefile.build dir=. obj
111+
112+ to make it easier to invoke build like:
113+ make $(build)=ex
114+
115+
116+Fixdep
117+------
118+It is necessary to build the fixdep helper before invoking the build.
119+The Makefile.include file adds the fixdep target, that could be
120+invoked by the user.
121+
122+
123+Rules
124+-----
100125
101126 The build framework provides standard compilation rules to handle .S and .c
102127 compilation.
@@ -104,8 +129,9 @@ compilation. · 1 unmodified line
104129 It's possible to include special rule if needed (like we do for flex or bison
105130 code generation).
106131
107−c) CFLAGS
108−---------
132+
133+CFLAGS
134+------
109135
110136 It's possible to alter the standard object C flags in the following way:
111137
@@ -115,8 +141,8 @@ It's possible to alter the standard object C flags in the following way: · 3 unmodified lines
115141 This C flags changes has the scope of the Build makefile they are defined in.
116142
117143
118−d) Dependencies
119−---------------
144+Dependencies
145+------------
120146
121147 For each built object file 'a.o' the '.a.cmd' is created and holds:
122148
@@ -130,8 +156,8 @@ All existing '.cmd' files are included in the Build process to follow properly · 7 unmodified lines
130156 the dependencies and trigger a rebuild when necessary.
131157
132158
133−e) Single rules
134−---------------
159+Single rules
160+------------
135161
136162 It's possible to build single object file by choice, like:
137163
tools/build/Makefile+43−0
@@ -0,0 +1,43 @@
1+ifeq ($(srctree),)
2+srctree := $(patsubst %/,%,$(dir $(shell pwd)))
3+srctree := $(patsubst %/,%,$(dir $(srctree)))
4+endif
5+
6+include $(srctree)/tools//scripts/Makefile.include
7+
8+define allow-override
9+ $(if $(or $(findstring environment,$(origin $(1))),\
10+ $(findstring command line,$(origin $(1)))),,\
11+ $(eval $(1) = $(2)))
12+endef
13+
14+$(call allow-override,CC,$(CROSS_COMPILE)gcc)
15+$(call allow-override,LD,$(CROSS_COMPILE)ld)
16+
17+ifeq ($(V),1)
18+ Q =
19+else
20+ Q = @
21+endif
22+
23+export Q srctree CC LD
24+
25+MAKEFLAGS := --no-print-directory
26+build := -f $(srctree)/tools/build/Makefile.build dir=. obj
27+
28+all: fixdep
29+
30+clean:
31+ $(call QUIET_CLEAN, fixdep)
32+ $(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
33+ $(Q)rm -f fixdep
34+
35+$(OUTPUT)fixdep-in.o: FORCE
36+ $(Q)$(MAKE) $(build)=fixdep
37+
38+$(OUTPUT)fixdep: $(OUTPUT)fixdep-in.o
39+ $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $<
40+
41+FORCE:
42+
43+.PHONY: FORCE
tools/build/Makefile.build+7−0
@@ -21,6 +21,13 @@ endif · 20 unmodified lines
2121
2222 build-dir := $(srctree)/tools/build
2323
24+# Define $(fixdep) for dep-cmd function
25+ifeq ($(OUTPUT),)
26+ fixdep := $(build-dir)/fixdep
27+else
28+ fixdep := $(OUTPUT)/fixdep
29+endif
30+
2431 # Generic definitions
2532 include $(build-dir)/Build.include
2633
tools/build/Makefile.feature+9−6
@@ -53,7 +53,8 @@ FEATURE_TESTS ?= \ · 52 unmodified lines
5353 libdw-dwarf-unwind \
5454 zlib \
5555 lzma \
56− get_cpuid
56+ get_cpuid \
57+ bpf
5758
5859 FEATURE_DISPLAY ?= \
5960 dwarf \
@@ -71,7 +72,8 @@ FEATURE_DISPLAY ?= \ · 11 unmodified lines
7172 libdw-dwarf-unwind \
7273 zlib \
7374 lzma \
74− get_cpuid
75+ get_cpuid \
76+ bpf
7577
7678 # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
7779 # If in the future we need per-feature checks/flags for features not
@@ -121,8 +123,9 @@ define feature_print_text_code · 43 unmodified lines
121123 MSG = $(shell printf '...%30s: %s' $(1) $(2))
122124 endef
123125
126+FEATURE_DUMP_FILENAME = $(OUTPUT)FEATURE-DUMP$(FEATURE_USER)
124127 FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
125−FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
128+FEATURE_DUMP_FILE := $(shell touch $(FEATURE_DUMP_FILENAME); cat $(FEATURE_DUMP_FILENAME))
126129
127130 ifeq ($(dwarf-post-unwind),1)
128131 FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
@@ -131,16 +134,16 @@ endif · 2 unmodified lines
131134 # The $(feature_display) controls the default detection message
132135 # output. It's set if:
133136 # - detected features differes from stored features from
134−# last build (in FEATURE-DUMP file)
137+# last build (in $(FEATURE_DUMP_FILENAME) file)
135138 # - one of the $(FEATURE_DISPLAY) is not detected
136139 # - VF is enabled
137140
138141 ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
139− $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
142+ $(shell echo "$(FEATURE_DUMP)" > $(FEATURE_DUMP_FILENAME))
140143 feature_display := 1
141144 endif
142145
143−feature_display_check = $(eval $(feature_check_code))
146+feature_display_check = $(eval $(feature_check_display_code))
144147 define feature_display_check_code
145148 ifneq ($(feature-$(1)), 1)
146149 feature_display := 1
tools/build/Makefile.include+10−0
@@ -0,0 +1,10 @@
1+build := -f $(srctree)/tools/build/Makefile.build dir=. obj
2+
3+ifdef CROSS_COMPILE
4+fixdep:
5+else
6+fixdep:
7+ $(Q)$(MAKE) -C $(srctree)/tools/build fixdep
8+endif
9+
10+.PHONY: fixdep
tools/build/feature/Makefile+2−2
@@ -132,10 +132,10 @@ test-libbfd.bin: · 131 unmodified lines
132132 $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
133133
134134 test-liberty.bin:
135− $(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
135+ $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
136136
137137 test-liberty-z.bin:
138− $(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
138+ $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
139139
140140 test-cplus-demangle.bin:
141141 $(BUILD) -liberty
tools/build/fixdep.c+168−0
@@ -0,0 +1,168 @@
1+/*
2+ * "Optimize" a list of dependencies as spit out by gcc -MD
3+ * for the build framework.
4+ *
5+ * Original author:
6+ * Copyright 2002 by Kai Germaschewski <kai.germaschewski@gmx.de>
7+ *
8+ * This code has been borrowed from kbuild's fixdep (scripts/basic/fixdep.c),
9+ * Please check it for detailed explanation. This fixdep borow only the
10+ * base transformation of dependecies without the CONFIG mangle.
11+ */
12+
13+#include <sys/types.h>
14+#include <sys/stat.h>
15+#include <sys/mman.h>
16+#include <unistd.h>
17+#include <fcntl.h>
18+#include <string.h>
19+#include <stdlib.h>
20+#include <stdio.h>
21+#include <limits.h>
22+
23+char *target;
24+char *depfile;
25+char *cmdline;
26+
27+static void usage(void)
28+{
29+ fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n");
30+ exit(1);
31+}
32+
33+/*
34+ * Print out the commandline prefixed with cmd_<target filename> :=
35+ */
36+static void print_cmdline(void)
37+{
38+ printf("cmd_%s := %s\n\n", target, cmdline);
39+}
40+
41+/*
42+ * Important: The below generated source_foo.o and deps_foo.o variable
43+ * assignments are parsed not only by make, but also by the rather simple
44+ * parser in scripts/mod/sumversion.c.
45+ */
46+static void parse_dep_file(void *map, size_t len)
47+{
48+ char *m = map;
49+ char *end = m + len;
50+ char *p;
51+ char s[PATH_MAX];
52+ int is_target;
53+ int saw_any_target = 0;
54+ int is_first_dep = 0;
55+
56+ while (m < end) {
57+ /* Skip any "white space" */
58+ while (m < end && (*m == ' ' || *m == '\\' || *m == '\n'))
59+ m++;
60+ /* Find next "white space" */
61+ p = m;
62+ while (p < end && *p != ' ' && *p != '\\' && *p != '\n')
63+ p++;
64+ /* Is the token we found a target name? */
65+ is_target = (*(p-1) == ':');
66+ /* Don't write any target names into the dependency file */
67+ if (is_target) {
68+ /* The /next/ file is the first dependency */
69+ is_first_dep = 1;
70+ } else {
71+ /* Save this token/filename */
72+ memcpy(s, m, p-m);
73+ s[p - m] = 0;
74+
75+ /*
76+ * Do not list the source file as dependency,
77+ * so that kbuild is not confused if a .c file
78+ * is rewritten into .S or vice versa. Storing
79+ * it in source_* is needed for modpost to
80+ * compute srcversions.
81+ */
82+ if (is_first_dep) {
83+ /*
84+ * If processing the concatenation of
85+ * multiple dependency files, only
86+ * process the first target name, which
87+ * will be the original source name,
88+ * and ignore any other target names,
89+ * which will be intermediate temporary
90+ * files.
91+ */
92+ if (!saw_any_target) {
93+ saw_any_target = 1;
94+ printf("source_%s := %s\n\n",
95+ target, s);
96+ printf("deps_%s := \\\n",
97+ target);
98+ }
99+ is_first_dep = 0;
100+ } else
101+ printf(" %s \\\n", s);
102+ }
103+ /*
104+ * Start searching for next token immediately after the first
105+ * "whitespace" character that follows this token.
106+ */
107+ m = p + 1;
108+ }
109+
110+ if (!saw_any_target) {
111+ fprintf(stderr, "fixdep: parse error; no targets found\n");
112+ exit(1);
113+ }
114+
115+ printf("\n%s: $(deps_%s)\n\n", target, target);
116+ printf("$(deps_%s):\n", target);
117+}
118+
119+static void print_deps(void)
120+{
121+ struct stat st;
122+ int fd;
123+ void *map;
124+
125+ fd = open(depfile, O_RDONLY);
126+ if (fd < 0) {
127+ fprintf(stderr, "fixdep: error opening depfile: ");
128+ perror(depfile);
129+ exit(2);
130+ }
131+ if (fstat(fd, &st) < 0) {
132+ fprintf(stderr, "fixdep: error fstat'ing depfile: ");
133+ perror(depfile);
134+ exit(2);
135+ }
136+ if (st.st_size == 0) {
137+ fprintf(stderr, "fixdep: %s is empty\n", depfile);
138+ close(fd);
139+ return;
140+ }
141+ map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
142+ if ((long) map == -1) {
143+ perror("fixdep: mmap");
144+ close(fd);
145+ return;
146+ }
147+
148+ parse_dep_file(map, st.st_size);
149+
150+ munmap(map, st.st_size);
151+
152+ close(fd);
153+}
154+
155+int main(int argc, char **argv)
156+{
157+ if (argc != 4)
158+ usage();
159+
160+ depfile = argv[1];
161+ target = argv[2];
162+ cmdline = argv[3];
163+
164+ print_cmdline();
165+ print_deps();
166+
167+ return 0;
168+}
tools/build/tests/ex/Build+1−0
@@ -4,6 +4,7 @@ ex-y += b.o · 3 unmodified lines
44 ex-y += b.o
55 ex-y += empty/
66 ex-y += empty2/
7+ex-y += inc.o
78
89 libex-y += c.o
910 libex-y += d.o
tools/build/tests/ex/Makefile+8−5
@@ -1,19 +1,22 @@
1−export srctree := ../../../..
1+export srctree := $(abspath ../../../..)
22 export CC := gcc
33 export LD := ld
44 export AR := ar
55
6−build := -f $(srctree)/tools/build/Makefile.build dir=. obj
6+ex:
7+
8+include $(srctree)/tools/build/Makefile.include
9+
710 ex: ex-in.o libex-in.o
811 gcc -o $@ $^
912
10−ex.%: FORCE
13+ex.%: fixdep FORCE
1114 make -f $(srctree)/tools/build/Makefile.build dir=. $@
1215
13−ex-in.o: FORCE
16+ex-in.o: fixdep FORCE
1417 make $(build)=ex
1518
16−libex-in.o: FORCE
19+libex-in.o: fixdep FORCE
1720 make $(build)=libex
1821
1922 clean:
tools/build/tests/ex/ex.c+2−0
@@ -5,6 +5,7 @@ int c(void); · 4 unmodified lines
55 int d(void);
66 int e(void);
77 int f(void);
8+int inc(void);
89
910 int main(void)
1011 {
@@ -14,6 +15,7 @@ int main(void) · 3 unmodified lines
1415 d();
1516 e();
1617 f();
18+ inc();
1719
1820 return 0;
1921 }
tools/build/tests/ex/inc.c+8−0
@@ -0,0 +1,8 @@
1+#ifdef INCLUDE
2+#include "krava.h"
3+#endif
4+
5+int inc(void)
6+{
7+ return 0;
8+}
tools/build/tests/run.sh+27−0
@@ -34,9 +34,36 @@ function test_ex_suffix { · 33 unmodified lines
3434 make -C ex V=1 clean > /dev/null 2>&1
3535 rm -f ex.out
3636 }
37+
38+function test_ex_include {
39+ make -C ex V=1 clean > ex.out 2>&1
40+
41+ # build with krava.h include
42+ touch ex/krava.h
43+ make -C ex V=1 CFLAGS=-DINCLUDE >> ex.out 2>&1
44+
45+ if [ ! -x ./ex/ex ]; then
46+ echo FAILED
47+ exit -1
48+ fi
49+
50+ # build without the include
51+ rm -f ex/krava.h ex/ex
52+ make -C ex V=1 >> ex.out 2>&1
53+
54+ if [ ! -x ./ex/ex ]; then
55+ echo FAILED
56+ exit -1
57+ fi
58+
59+ make -C ex V=1 clean > /dev/null 2>&1
60+ rm -f ex.out
61+}
62+
3763 echo -n Testing..
3864
3965 test_ex
4066 test_ex_suffix
67+test_ex_include
4168
4269 echo OK
tools/include/linux/compiler.h+24−8
@@ -43,13 +43,29 @@ · 42 unmodified lines
4343
4444 #include <linux/types.h>
4545
46+/*
47+ * Following functions are taken from kernel sources and
48+ * break aliasing rules in their original form.
49+ *
50+ * While kernel is compiled with -fno-strict-aliasing,
51+ * perf uses -Wstrict-aliasing=3 which makes build fail
52+ * under gcc 4.4.
53+ *
54+ * Using extra __may_alias__ type to allow aliasing
55+ * in this case.
56+ */
57+typedef __u8 __attribute__((__may_alias__)) __u8_alias_t;
58+typedef __u16 __attribute__((__may_alias__)) __u16_alias_t;
59+typedef __u32 __attribute__((__may_alias__)) __u32_alias_t;
60+typedef __u64 __attribute__((__may_alias__)) __u64_alias_t;
61+
4662 static __always_inline void __read_once_size(const volatile void *p, void *res, int size)
4763 {
4864 switch (size) {
49− case 1: *(__u8 *)res = *(volatile __u8 *)p; break;
50− case 2: *(__u16 *)res = *(volatile __u16 *)p; break;
51− case 4: *(__u32 *)res = *(volatile __u32 *)p; break;
52− case 8: *(__u64 *)res = *(volatile __u64 *)p; break;
65+ case 1: *(__u8_alias_t *) res = *(volatile __u8_alias_t *) p; break;
66+ case 2: *(__u16_alias_t *) res = *(volatile __u16_alias_t *) p; break;
67+ case 4: *(__u32_alias_t *) res = *(volatile __u32_alias_t *) p; break;
68+ case 8: *(__u64_alias_t *) res = *(volatile __u64_alias_t *) p; break;
5369 default:
5470 barrier();
5571 __builtin_memcpy((void *)res, (const void *)p, size);
@@ -60,10 +76,10 @@ static __always_inline void __read_once_size(const volatile void *p, void *res, · 4 unmodified lines
6076 static __always_inline void __write_once_size(volatile void *p, void *res, int size)
6177 {
6278 switch (size) {
63− case 1: *(volatile __u8 *)p = *(__u8 *)res; break;
64− case 2: *(volatile __u16 *)p = *(__u16 *)res; break;
65− case 4: *(volatile __u32 *)p = *(__u32 *)res; break;
66− case 8: *(volatile __u64 *)p = *(__u64 *)res; break;
79+ case 1: *(volatile __u8_alias_t *) p = *(__u8_alias_t *) res; break;
80+ case 2: *(volatile __u16_alias_t *) p = *(__u16_alias_t *) res; break;
81+ case 4: *(volatile __u32_alias_t *) p = *(__u32_alias_t *) res; break;
82+ case 8: *(volatile __u64_alias_t *) p = *(__u64_alias_t *) res; break;
6783 default:
6884 barrier();
6985 __builtin_memcpy((void *)p, (const void *)res, size);
tools/include/linux/err.h+49−0
@@ -0,0 +1,49 @@
1+#ifndef __TOOLS_LINUX_ERR_H
2+#define __TOOLS_LINUX_ERR_H
3+
4+#include <linux/compiler.h>
5+#include <linux/types.h>
6+
7+#include <asm/errno.h>
8+
9+/*
10+ * Original kernel header comment:
11+ *
12+ * Kernel pointers have redundant information, so we can use a
13+ * scheme where we can return either an error code or a normal
14+ * pointer with the same return value.
15+ *
16+ * This should be a per-architecture thing, to allow different
17+ * error and pointer decisions.
18+ *
19+ * Userspace note:
20+ * The same principle works for userspace, because 'error' pointers
21+ * fall down to the unused hole far from user space, as described
22+ * in Documentation/x86/x86_64/mm.txt for x86_64 arch:
23+ *
24+ * 0000000000000000 - 00007fffffffffff (=47 bits) user space, different per mm hole caused by [48:63] sign extension
25+ * ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
26+ *
27+ * It should be the same case for other architectures, because
28+ * this code is used in generic kernel code.
29+ */
30+#define MAX_ERRNO 4095
31+
32+#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
33+
34+static inline void * __must_check ERR_PTR(long error_)
35+{
36+ return (void *) error_;
37+}
38+
39+static inline long __must_check PTR_ERR(__force const void *ptr)
40+{
41+ return (long) ptr;
42+}
43+
44+static inline bool __must_check IS_ERR(__force const void *ptr)
45+{
46+ return IS_ERR_VALUE((unsigned long)ptr);
47+}
48+
49+#endif /* _LINUX_ERR_H */
tools/include/linux/filter.h+231−0
@@ -0,0 +1,231 @@
1+/*
2+ * Linux Socket Filter Data Structures
3+ */
4+#ifndef __TOOLS_LINUX_FILTER_H
5+#define __TOOLS_LINUX_FILTER_H
6+
7+#include <linux/bpf.h>
8+
9+/* ArgX, context and stack frame pointer register positions. Note,
10+ * Arg1, Arg2, Arg3, etc are used as argument mappings of function
11+ * calls in BPF_CALL instruction.
12+ */
13+#define BPF_REG_ARG1 BPF_REG_1
14+#define BPF_REG_ARG2 BPF_REG_2
15+#define BPF_REG_ARG3 BPF_REG_3
16+#define BPF_REG_ARG4 BPF_REG_4
17+#define BPF_REG_ARG5 BPF_REG_5
18+#define BPF_REG_CTX BPF_REG_6
19+#define BPF_REG_FP BPF_REG_10
20+
21+/* Additional register mappings for converted user programs. */
22+#define BPF_REG_A BPF_REG_0
23+#define BPF_REG_X BPF_REG_7
24+#define BPF_REG_TMP BPF_REG_8
25+
26+/* BPF program can access up to 512 bytes of stack space. */
27+#define MAX_BPF_STACK 512
28+
29+/* Helper macros for filter block array initializers. */
30+
31+/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */
32+
33+#define BPF_ALU64_REG(OP, DST, SRC) \
34+ ((struct bpf_insn) { \
35+ .code = BPF_ALU64 | BPF_OP(OP) | BPF_X, \
36+ .dst_reg = DST, \
37+ .src_reg = SRC, \
38+ .off = 0, \
39+ .imm = 0 })
40+
41+#define BPF_ALU32_REG(OP, DST, SRC) \
42+ ((struct bpf_insn) { \
43+ .code = BPF_ALU | BPF_OP(OP) | BPF_X, \
44+ .dst_reg = DST, \
45+ .src_reg = SRC, \
46+ .off = 0, \
47+ .imm = 0 })
48+
49+/* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */
50+
51+#define BPF_ALU64_IMM(OP, DST, IMM) \
52+ ((struct bpf_insn) { \
53+ .code = BPF_ALU64 | BPF_OP(OP) | BPF_K, \
54+ .dst_reg = DST, \
55+ .src_reg = 0, \
56+ .off = 0, \
57+ .imm = IMM })
58+
59+#define BPF_ALU32_IMM(OP, DST, IMM) \
60+ ((struct bpf_insn) { \
61+ .code = BPF_ALU | BPF_OP(OP) | BPF_K, \
62+ .dst_reg = DST, \
63+ .src_reg = 0, \
64+ .off = 0, \
65+ .imm = IMM })
66+
67+/* Endianess conversion, cpu_to_{l,b}e(), {l,b}e_to_cpu() */
68+
69+#define BPF_ENDIAN(TYPE, DST, LEN) \
70+ ((struct bpf_insn) { \
71+ .code = BPF_ALU | BPF_END | BPF_SRC(TYPE), \
72+ .dst_reg = DST, \
73+ .src_reg = 0, \
74+ .off = 0, \
75+ .imm = LEN })
76+
77+/* Short form of mov, dst_reg = src_reg */
78+
79+#define BPF_MOV64_REG(DST, SRC) \
80+ ((struct bpf_insn) { \
81+ .code = BPF_ALU64 | BPF_MOV | BPF_X, \
82+ .dst_reg = DST, \
83+ .src_reg = SRC, \
84+ .off = 0, \
85+ .imm = 0 })
86+
87+#define BPF_MOV32_REG(DST, SRC) \
88+ ((struct bpf_insn) { \
89+ .code = BPF_ALU | BPF_MOV | BPF_X, \
90+ .dst_reg = DST, \
91+ .src_reg = SRC, \
92+ .off = 0, \
93+ .imm = 0 })
94+
95+/* Short form of mov, dst_reg = imm32 */
96+
97+#define BPF_MOV64_IMM(DST, IMM) \
98+ ((struct bpf_insn) { \
99+ .code = BPF_ALU64 | BPF_MOV | BPF_K, \
100+ .dst_reg = DST, \
101+ .src_reg = 0, \
102+ .off = 0, \
103+ .imm = IMM })
104+
105+#define BPF_MOV32_IMM(DST, IMM) \
106+ ((struct bpf_insn) { \
107+ .code = BPF_ALU | BPF_MOV | BPF_K, \
108+ .dst_reg = DST, \
109+ .src_reg = 0, \
110+ .off = 0, \
111+ .imm = IMM })
112+
113+/* Short form of mov based on type, BPF_X: dst_reg = src_reg, BPF_K: dst_reg = imm32 */
114+
115+#define BPF_MOV64_RAW(TYPE, DST, SRC, IMM) \
116+ ((struct bpf_insn) { \
117+ .code = BPF_ALU64 | BPF_MOV | BPF_SRC(TYPE), \
118+ .dst_reg = DST, \
119+ .src_reg = SRC, \
120+ .off = 0, \
121+ .imm = IMM })
122+
123+#define BPF_MOV32_RAW(TYPE, DST, SRC, IMM) \
124+ ((struct bpf_insn) { \
125+ .code = BPF_ALU | BPF_MOV | BPF_SRC(TYPE), \
126+ .dst_reg = DST, \
127+ .src_reg = SRC, \
128+ .off = 0, \
129+ .imm = IMM })
130+
131+/* Direct packet access, R0 = *(uint *) (skb->data + imm32) */
132+
133+#define BPF_LD_ABS(SIZE, IMM) \
134+ ((struct bpf_insn) { \
135+ .code = BPF_LD | BPF_SIZE(SIZE) | BPF_ABS, \
136+ .dst_reg = 0, \
137+ .src_reg = 0, \
138+ .off = 0, \
139+ .imm = IMM })
140+
141+/* Indirect packet access, R0 = *(uint *) (skb->data + src_reg + imm32) */
142+
143+#define BPF_LD_IND(SIZE, SRC, IMM) \
144+ ((struct bpf_insn) { \
145+ .code = BPF_LD | BPF_SIZE(SIZE) | BPF_IND, \
146+ .dst_reg = 0, \
147+ .src_reg = SRC, \
148+ .off = 0, \
149+ .imm = IMM })
150+
151+/* Memory load, dst_reg = *(uint *) (src_reg + off16) */
152+
153+#define BPF_LDX_MEM(SIZE, DST, SRC, OFF) \
154+ ((struct bpf_insn) { \
155+ .code = BPF_LDX | BPF_SIZE(SIZE) | BPF_MEM, \
156+ .dst_reg = DST, \
157+ .src_reg = SRC, \
158+ .off = OFF, \
159+ .imm = 0 })
160+
161+/* Memory store, *(uint *) (dst_reg + off16) = src_reg */
162+
163+#define BPF_STX_MEM(SIZE, DST, SRC, OFF) \
164+ ((struct bpf_insn) { \
165+ .code = BPF_STX | BPF_SIZE(SIZE) | BPF_MEM, \
166+ .dst_reg = DST, \
167+ .src_reg = SRC, \
168+ .off = OFF, \
169+ .imm = 0 })
170+
171+/* Memory store, *(uint *) (dst_reg + off16) = imm32 */
172+
173+#define BPF_ST_MEM(SIZE, DST, OFF, IMM) \
174+ ((struct bpf_insn) { \
175+ .code = BPF_ST | BPF_SIZE(SIZE) | BPF_MEM, \
176+ .dst_reg = DST, \
177+ .src_reg = 0, \
178+ .off = OFF, \
179+ .imm = IMM })
180+
181+/* Conditional jumps against registers, if (dst_reg 'op' src_reg) goto pc + off16 */
182+
183+#define BPF_JMP_REG(OP, DST, SRC, OFF) \
184+ ((struct bpf_insn) { \
185+ .code = BPF_JMP | BPF_OP(OP) | BPF_X, \
186+ .dst_reg = DST, \
187+ .src_reg = SRC, \
188+ .off = OFF, \
189+ .imm = 0 })
190+
191+/* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */
192+
193+#define BPF_JMP_IMM(OP, DST, IMM, OFF) \
194+ ((struct bpf_insn) { \
195+ .code = BPF_JMP | BPF_OP(OP) | BPF_K, \
196+ .dst_reg = DST, \
197+ .src_reg = 0, \
198+ .off = OFF, \
199+ .imm = IMM })
200+
201+/* Function call */
202+
203+#define BPF_EMIT_CALL(FUNC) \
204+ ((struct bpf_insn) { \
205+ .code = BPF_JMP | BPF_CALL, \
206+ .dst_reg = 0, \
207+ .src_reg = 0, \
208+ .off = 0, \
209+ .imm = ((FUNC) - BPF_FUNC_unspec) })
210+
211+/* Raw code statement block */
212+
213+#define BPF_RAW_INSN(CODE, DST, SRC, OFF, IMM) \
214+ ((struct bpf_insn) { \
215+ .code = CODE, \
216+ .dst_reg = DST, \
217+ .src_reg = SRC, \
218+ .off = OFF, \
219+ .imm = IMM })
220+
221+/* Program exit */
222+
223+#define BPF_EXIT_INSN() \
224+ ((struct bpf_insn) { \
225+ .code = BPF_JMP | BPF_EXIT, \
226+ .dst_reg = 0, \
227+ .src_reg = 0, \
228+ .off = 0, \
229+ .imm = 0 })
230+
231+#endif /* __TOOLS_LINUX_FILTER_H */
tools/lib/api/Build+1−0
@@ -1,2 +1,3 @@
11 libapi-y += fd/
22 libapi-y += fs/
3+libapi-y += cpu.o
tools/lib/api/Makefile+4−2
@@ -21,12 +21,14 @@ CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 · 20 unmodified lines
2121
2222 RM = rm -f
2323
24−build := -f $(srctree)/tools/build/Makefile.build dir=. obj
2524 API_IN := $(OUTPUT)libapi-in.o
2625
26+all:
27+
2728 export srctree OUTPUT CC LD CFLAGS V
29+include $(srctree)/tools/build/Makefile.include
2830
29−all: $(LIBFILE)
31+all: fixdep $(LIBFILE)
3032
3133 $(API_IN): FORCE
3234 @$(MAKE) $(build)=libapi
tools/lib/api/cpu.c+18−0
@@ -0,0 +1,18 @@
1+#include <stdio.h>
2+
3+#include "cpu.h"
4+#include "fs/fs.h"
5+
6+int cpu__get_max_freq(unsigned long long *freq)
7+{
8+ char entry[PATH_MAX];
9+ int cpu;
10+
11+ if (sysfs__read_int("devices/system/cpu/online", &cpu) < 0)
12+ return -1;
13+
14+ snprintf(entry, sizeof(entry),
15+ "devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", cpu);
16+
17+ return sysfs__read_ull(entry, freq);
18+}
tools/lib/api/cpu.h+6−0
@@ -0,0 +1,6 @@
1+#ifndef __API_CPU__
2+#define __API_CPU__
3+
4+int cpu__get_max_freq(unsigned long long *freq);
5+
6+#endif /* __API_CPU__ */
tools/lib/api/fs/Build+1−3
@@ -1,4 +1,2 @@
11 libapi-y += fs.o
2−libapi-y += debugfs.o
3−libapi-y += findfs.o
4−libapi-y += tracefs.o
2+libapi-y += tracing_path.o
tools/lib/api/fs/debugfs.c+0−129
@@ -1,129 +0,0 @@
1−#define _GNU_SOURCE
2−#include <errno.h>
3−#include <stdio.h>
4−#include <stdlib.h>
5−#include <string.h>
6−#include <unistd.h>
7−#include <stdbool.h>
8−#include <sys/vfs.h>
9−#include <sys/types.h>
10−#include <sys/stat.h>
11−#include <sys/mount.h>
12−#include <linux/kernel.h>
13−
14−#include "debugfs.h"
15−#include "tracefs.h"
16−
17−#ifndef DEBUGFS_DEFAULT_PATH
18−#define DEBUGFS_DEFAULT_PATH "/sys/kernel/debug"
19−#endif
20−
21−char debugfs_mountpoint[PATH_MAX + 1] = DEBUGFS_DEFAULT_PATH;
22−
23−static const char * const debugfs_known_mountpoints[] = {
24− DEBUGFS_DEFAULT_PATH,
25− "/debug",
26− 0,
27−};
28−
29−static bool debugfs_found;
30−
31−bool debugfs_configured(void)
32−{
33− return debugfs_find_mountpoint() != NULL;
34−}
35−
36−/* find the path to the mounted debugfs */
37−const char *debugfs_find_mountpoint(void)
38−{
39− const char *ret;
40−
41− if (debugfs_found)
42− return (const char *)debugfs_mountpoint;
43−
44− ret = find_mountpoint("debugfs", (long) DEBUGFS_MAGIC,
45− debugfs_mountpoint, PATH_MAX + 1,
46− debugfs_known_mountpoints);
47− if (ret)
48− debugfs_found = true;
49−
50− return ret;
51−}
52−
53−/* mount the debugfs somewhere if it's not mounted */
54−char *debugfs_mount(const char *mountpoint)
55−{
56− /* see if it's already mounted */
57− if (debugfs_find_mountpoint())
58− goto out;
59−
60− /* if not mounted and no argument */
61− if (mountpoint == NULL) {
62− /* see if environment variable set */
63− mountpoint = getenv(PERF_DEBUGFS_ENVIRONMENT);
64− /* if no environment variable, use default */
65− if (mountpoint == NULL)
66− mountpoint = DEBUGFS_DEFAULT_PATH;
67− }
68−
69− if (mount(NULL, mountpoint, "debugfs", 0, NULL) < 0)
70− return NULL;
71−
72− /* save the mountpoint */
73− debugfs_found = true;
74− strncpy(debugfs_mountpoint, mountpoint, sizeof(debugfs_mountpoint));
75−out:
76− return debugfs_mountpoint;
77−}
78−
79−int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename)
80−{
81− char sbuf[128];
82−
83− switch (err) {
84− case ENOENT:
85− if (debugfs_found) {
86− snprintf(buf, size,
87− "Error:\tFile %s/%s not found.\n"
88− "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
89− debugfs_mountpoint, filename);
90− break;
91− }
92− snprintf(buf, size, "%s",
93− "Error:\tUnable to find debugfs\n"
94− "Hint:\tWas your kernel compiled with debugfs support?\n"
95− "Hint:\tIs the debugfs filesystem mounted?\n"
96− "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
97− break;
98− case EACCES: {
99− const char *mountpoint = debugfs_mountpoint;
100−
101− if (!access(debugfs_mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
102− const char *tracefs_mntpoint = tracefs_find_mountpoint();
103−
104− if (tracefs_mntpoint)
105− mountpoint = tracefs_mntpoint;
106− }
107−
108− snprintf(buf, size,
109− "Error:\tNo permissions to read %s/%s\n"
110− "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
111− debugfs_mountpoint, filename, mountpoint);
112− }
113− break;
114− default:
115− snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf)));
116− break;
117− }
118−
119− return 0;
120−}
121−
122−int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name)
123−{
124− char path[PATH_MAX];
125−
126− snprintf(path, PATH_MAX, "tracing/events/%s/%s", sys, name ?: "*");
127−
128− return debugfs__strerror_open(err, buf, size, path);
129−}
tools/lib/api/fs/debugfs.h+0−23
@@ -1,23 +0,0 @@
1−#ifndef __API_DEBUGFS_H__
2−#define __API_DEBUGFS_H__
3−
4−#include "findfs.h"
5−
6−#ifndef DEBUGFS_MAGIC
7−#define DEBUGFS_MAGIC 0x64626720
8−#endif
9−
10−#ifndef PERF_DEBUGFS_ENVIRONMENT
11−#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
12−#endif
13−
14−bool debugfs_configured(void);
15−const char *debugfs_find_mountpoint(void);
16−char *debugfs_mount(const char *mountpoint);
17−
18−extern char debugfs_mountpoint[];
19−
20−int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename);
21−int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name);
22−
23−#endif /* __API_DEBUGFS_H__ */
tools/lib/api/fs/findfs.c+0−63
@@ -1,63 +0,0 @@
1−#include <errno.h>
2−#include <stdio.h>
3−#include <stdlib.h>
4−#include <string.h>
5−#include <stdbool.h>
6−#include <sys/vfs.h>
7−
8−#include "findfs.h"
9−
10−/* verify that a mountpoint is actually the type we want */
11−
12−int valid_mountpoint(const char *mount, long magic)
13−{
14− struct statfs st_fs;
15−
16− if (statfs(mount, &st_fs) < 0)
17− return -ENOENT;
18− else if ((long)st_fs.f_type != magic)
19− return -ENOENT;
20−
21− return 0;
22−}
23−
24−/* find the path to a mounted file system */
25−const char *find_mountpoint(const char *fstype, long magic,
26− char *mountpoint, int len,
27− const char * const *known_mountpoints)
28−{
29− const char * const *ptr;
30− char format[128];
31− char type[100];
32− FILE *fp;
33−
34− if (known_mountpoints) {
35− ptr = known_mountpoints;
36− while (*ptr) {
37− if (valid_mountpoint(*ptr, magic) == 0) {
38− strncpy(mountpoint, *ptr, len - 1);
39− mountpoint[len-1] = 0;
40− return mountpoint;
41− }
42− ptr++;
43− }
44− }
45−
46− /* give up and parse /proc/mounts */
47− fp = fopen("/proc/mounts", "r");
48− if (fp == NULL)
49− return NULL;
50−
51− snprintf(format, 128, "%%*s %%%ds %%99s %%*s %%*d %%*d\n", len);
52−
53− while (fscanf(fp, format, mountpoint, type) == 2) {
54− if (strcmp(type, fstype) == 0)
55− break;
56− }
57− fclose(fp);
58−
59− if (strcmp(type, fstype) != 0)
60− return NULL;
61−
62− return mountpoint;
63−}
tools/lib/api/fs/findfs.h+0−23
@@ -1,23 +0,0 @@
1−#ifndef __API_FINDFS_H__
2−#define __API_FINDFS_H__
3−
4−#include <stdbool.h>
5−
6−#define _STR(x) #x
7−#define STR(x) _STR(x)
8−
9−/*
10− * On most systems <limits.h> would have given us this, but not on some systems
11− * (e.g. GNU/Hurd).
12− */
13−#ifndef PATH_MAX
14−#define PATH_MAX 4096
15−#endif
16−
17−const char *find_mountpoint(const char *fstype, long magic,
18− char *mountpoint, int len,
19− const char * const *known_mountpoints);
20−
21−int valid_mountpoint(const char *mount, long magic);
22−
23−#endif /* __API_FINDFS_H__ */
tools/lib/api/fs/fs.c+153−12
@@ -1,7 +1,6 @@
1−/* TODO merge/factor in debugfs.c here */
2−
31 #include <ctype.h>
42 #include <errno.h>
3+#include <limits.h>
54 #include <stdbool.h>
65 #include <stdio.h>
76 #include <stdlib.h>
@@ -11,10 +10,29 @@ · 3 unmodified lines
1110 #include <sys/stat.h>
1211 #include <fcntl.h>
1312 #include <unistd.h>
13+#include <sys/mount.h>
1414
15−#include "debugfs.h"
1615 #include "fs.h"
1716
17+#define _STR(x) #x
18+#define STR(x) _STR(x)
19+
20+#ifndef SYSFS_MAGIC
21+#define SYSFS_MAGIC 0x62656572
22+#endif
23+
24+#ifndef PROC_SUPER_MAGIC
25+#define PROC_SUPER_MAGIC 0x9fa0
26+#endif
27+
28+#ifndef DEBUGFS_MAGIC
29+#define DEBUGFS_MAGIC 0x64626720
30+#endif
31+
32+#ifndef TRACEFS_MAGIC
33+#define TRACEFS_MAGIC 0x74726163
34+#endif
35+
1836 static const char * const sysfs__fs_known_mountpoints[] = {
1937 "/sys",
2038 0,
@@ -25,19 +43,48 @@ static const char * const procfs__known_mountpoints[] = { · 4 unmodified lines
2543 0,
2644 };
2745
46+#ifndef DEBUGFS_DEFAULT_PATH
47+#define DEBUGFS_DEFAULT_PATH "/sys/kernel/debug"
48+#endif
49+
50+static const char * const debugfs__known_mountpoints[] = {
51+ DEBUGFS_DEFAULT_PATH,
52+ "/debug",
53+ 0,
54+};
55+
56+
57+#ifndef TRACEFS_DEFAULT_PATH
58+#define TRACEFS_DEFAULT_PATH "/sys/kernel/tracing"
59+#endif
60+
61+static const char * const tracefs__known_mountpoints[] = {
62+ TRACEFS_DEFAULT_PATH,
63+ "/sys/kernel/debug/tracing",
64+ "/tracing",
65+ "/trace",
66+ 0,
67+};
68+
2869 struct fs {
2970 const char *name;
3071 const char * const *mounts;
31− char path[PATH_MAX + 1];
72+ char path[PATH_MAX];
3273 bool found;
3374 long magic;
3475 };
3576
3677 enum {
37− FS__SYSFS = 0,
38− FS__PROCFS = 1,
78+ FS__SYSFS = 0,
79+ FS__PROCFS = 1,
80+ FS__DEBUGFS = 2,
81+ FS__TRACEFS = 3,
3982 };
4083
84+#ifndef TRACEFS_MAGIC
85+#define TRACEFS_MAGIC 0x74726163
86+#endif
87+
4188 static struct fs fs__entries[] = {
4289 [FS__SYSFS] = {
4390 .name = "sysfs",
@@ -49,6 +96,16 @@ static struct fs fs__entries[] = { · 5 unmodified lines
4996 .mounts = procfs__known_mountpoints,
5097 .magic = PROC_SUPER_MAGIC,
5198 },
99+ [FS__DEBUGFS] = {
100+ .name = "debugfs",
101+ .mounts = debugfs__known_mountpoints,
102+ .magic = DEBUGFS_MAGIC,
103+ },
104+ [FS__TRACEFS] = {
105+ .name = "tracefs",
106+ .mounts = tracefs__known_mountpoints,
107+ .magic = TRACEFS_MAGIC,
108+ },
52109 };
53110
54111 static bool fs__read_mounts(struct fs *fs)
@@ -159,14 +216,54 @@ static const char *fs__mountpoint(int idx) · 104 unmodified lines
159216 return fs__get_mountpoint(fs);
160217 }
161218
162−#define FS__MOUNTPOINT(name, idx) \
163−const char *name##__mountpoint(void) \
164−{ \
165− return fs__mountpoint(idx); \
219+static const char *mount_overload(struct fs *fs)
220+{
221+ size_t name_len = strlen(fs->name);
222+ /* "PERF_" + name + "_ENVIRONMENT" + '\0' */
223+ char upper_name[5 + name_len + 12 + 1];
224+
225+ snprintf(upper_name, name_len, "PERF_%s_ENVIRONMENT", fs->name);
226+ mem_toupper(upper_name, name_len);
227+
228+ return getenv(upper_name) ?: *fs->mounts;
229+}
230+
231+static const char *fs__mount(int idx)
232+{
233+ struct fs *fs = &fs__entries[idx];
234+ const char *mountpoint;
235+
236+ if (fs__mountpoint(idx))
237+ return (const char *)fs->path;
238+
239+ mountpoint = mount_overload(fs);
240+
241+ if (mount(NULL, mountpoint, fs->name, 0, NULL) < 0)
242+ return NULL;
243+
244+ return fs__check_mounts(fs) ? fs->path : NULL;
245+}
246+
247+#define FS(name, idx) \
248+const char *name##__mountpoint(void) \
249+{ \
250+ return fs__mountpoint(idx); \
251+} \
252+ \
253+const char *name##__mount(void) \
254+{ \
255+ return fs__mount(idx); \
256+} \
257+ \
258+bool name##__configured(void) \
259+{ \
260+ return name##__mountpoint() != NULL; \
166261 }
167262
168−FS__MOUNTPOINT(sysfs, FS__SYSFS);
169−FS__MOUNTPOINT(procfs, FS__PROCFS);
263+FS(sysfs, FS__SYSFS);
264+FS(procfs, FS__PROCFS);
265+FS(debugfs, FS__DEBUGFS);
266+FS(tracefs, FS__TRACEFS);
170267
171268 int filename__read_int(const char *filename, int *value)
172269 {
@@ -185,6 +282,50 @@ int filename__read_int(const char *filename, int *value) · 12 unmodified lines
185282 return err;
186283 }
187284
285+int filename__read_ull(const char *filename, unsigned long long *value)
286+{
287+ char line[64];
288+ int fd = open(filename, O_RDONLY), err = -1;
289+
290+ if (fd < 0)
291+ return -1;
292+
293+ if (read(fd, line, sizeof(line)) > 0) {
294+ *value = strtoull(line, NULL, 10);
295+ if (*value != ULLONG_MAX)
296+ err = 0;
297+ }
298+
299+ close(fd);
300+ return err;
301+}
302+
303+int sysfs__read_ull(const char *entry, unsigned long long *value)
304+{
305+ char path[PATH_MAX];
306+ const char *sysfs = sysfs__mountpoint();
307+
308+ if (!sysfs)
309+ return -1;
310+
311+ snprintf(path, sizeof(path), "%s/%s", sysfs, entry);
312+
313+ return filename__read_ull(path, value);
314+}
315+
316+int sysfs__read_int(const char *entry, int *value)
317+{
318+ char path[PATH_MAX];
319+ const char *sysfs = sysfs__mountpoint();
320+
321+ if (!sysfs)
322+ return -1;
323+
324+ snprintf(path, sizeof(path), "%s/%s", sysfs, entry);
325+
326+ return filename__read_int(path, value);
327+}
328+
188329 int sysctl__read_int(const char *sysctl, int *value)
189330 {
190331 char path[PATH_MAX];
tools/lib/api/fs/fs.h+23−7
@@ -1,17 +1,33 @@
11 #ifndef __API_FS__
22 #define __API_FS__
33
4−#ifndef SYSFS_MAGIC
5−#define SYSFS_MAGIC 0x62656572
6−#endif
4+#include <stdbool.h>
75
8−#ifndef PROC_SUPER_MAGIC
9−#define PROC_SUPER_MAGIC 0x9fa0
6+/*
7+ * On most systems <limits.h> would have given us this, but not on some systems
8+ * (e.g. GNU/Hurd).
9+ */
10+#ifndef PATH_MAX
11+#define PATH_MAX 4096
1012 #endif
1113
12−const char *sysfs__mountpoint(void);
13−const char *procfs__mountpoint(void);
14+#define FS(name) \
15+ const char *name##__mountpoint(void); \
16+ const char *name##__mount(void); \
17+ bool name##__configured(void); \
18+
19+FS(sysfs)
20+FS(procfs)
21+FS(debugfs)
22+FS(tracefs)
23+
24+#undef FS
25+
1426
1527 int filename__read_int(const char *filename, int *value);
28+int filename__read_ull(const char *filename, unsigned long long *value);
29+
1630 int sysctl__read_int(const char *sysctl, int *value);
31+int sysfs__read_int(const char *entry, int *value);
32+int sysfs__read_ull(const char *entry, unsigned long long *value);
1733 #endif /* __API_FS__ */
tools/lib/api/fs/tracefs.c+0−78
@@ -1,78 +0,0 @@
1−#include <errno.h>
2−#include <stdio.h>
3−#include <stdlib.h>
4−#include <string.h>
5−#include <unistd.h>
6−#include <stdbool.h>
7−#include <sys/vfs.h>
8−#include <sys/types.h>
9−#include <sys/stat.h>
10−#include <sys/mount.h>
11−#include <linux/kernel.h>
12−
13−#include "tracefs.h"
14−
15−#ifndef TRACEFS_DEFAULT_PATH
16−#define TRACEFS_DEFAULT_PATH "/sys/kernel/tracing"
17−#endif
18−
19−char tracefs_mountpoint[PATH_MAX + 1] = TRACEFS_DEFAULT_PATH;
20−
21−static const char * const tracefs_known_mountpoints[] = {
22− TRACEFS_DEFAULT_PATH,
23− "/sys/kernel/debug/tracing",
24− "/tracing",
25− "/trace",
26− 0,
27−};
28−
29−static bool tracefs_found;
30−
31−bool tracefs_configured(void)
32−{
33− return tracefs_find_mountpoint() != NULL;
34−}
35−
36−/* find the path to the mounted tracefs */
37−const char *tracefs_find_mountpoint(void)
38−{
39− const char *ret;
40−
41− if (tracefs_found)
42− return (const char *)tracefs_mountpoint;
43−
44− ret = find_mountpoint("tracefs", (long) TRACEFS_MAGIC,
45− tracefs_mountpoint, PATH_MAX + 1,
46− tracefs_known_mountpoints);
47−
48− if (ret)
49− tracefs_found = true;
50−
51− return ret;
52−}
53−
54−/* mount the tracefs somewhere if it's not mounted */
55−char *tracefs_mount(const char *mountpoint)
56−{
57− /* see if it's already mounted */
58− if (tracefs_find_mountpoint())
59− goto out;
60−
61− /* if not mounted and no argument */
62− if (mountpoint == NULL) {
63− /* see if environment variable set */
64− mountpoint = getenv(PERF_TRACEFS_ENVIRONMENT);
65− /* if no environment variable, use default */
66− if (mountpoint == NULL)
67− mountpoint = TRACEFS_DEFAULT_PATH;
68− }
69−
70− if (mount(NULL, mountpoint, "tracefs", 0, NULL) < 0)
71− return NULL;
72−
73− /* save the mountpoint */
74− tracefs_found = true;
75− strncpy(tracefs_mountpoint, mountpoint, sizeof(tracefs_mountpoint));
76−out:
77− return tracefs_mountpoint;
78−}
tools/lib/api/fs/tracefs.h+0−21
@@ -1,21 +0,0 @@
1−#ifndef __API_TRACEFS_H__
2−#define __API_TRACEFS_H__
3−
4−#include "findfs.h"
5−
6−#ifndef TRACEFS_MAGIC
7−#define TRACEFS_MAGIC 0x74726163
8−#endif
9−
10−#ifndef PERF_TRACEFS_ENVIRONMENT
11−#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
12−#endif
13−
14−bool tracefs_configured(void);
15−const char *tracefs_find_mountpoint(void);
16−int tracefs_valid_mountpoint(const char *debugfs);
17−char *tracefs_mount(const char *mountpoint);
18−
19−extern char tracefs_mountpoint[];
20−
21−#endif /* __API_DEBUGFS_H__ */
tools/lib/api/fs/tracing_path.c+135−0
@@ -0,0 +1,135 @@
1+#ifndef _GNU_SOURCE
2+# define _GNU_SOURCE
3+#endif
4+
5+#include <stdio.h>
6+#include <stdlib.h>
7+#include <string.h>
8+#include <errno.h>
9+#include <unistd.h>
10+#include "fs.h"
11+
12+#include "tracing_path.h"
13+
14+
15+char tracing_mnt[PATH_MAX] = "/sys/kernel/debug";
16+char tracing_path[PATH_MAX] = "/sys/kernel/debug/tracing";
17+char tracing_events_path[PATH_MAX] = "/sys/kernel/debug/tracing/events";
18+
19+
20+static void __tracing_path_set(const char *tracing, const char *mountpoint)
21+{
22+ snprintf(tracing_mnt, sizeof(tracing_mnt), "%s", mountpoint);
23+ snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
24+ mountpoint, tracing);
25+ snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
26+ mountpoint, tracing, "events");
27+}
28+
29+static const char *tracing_path_tracefs_mount(void)
30+{
31+ const char *mnt;
32+
33+ mnt = tracefs__mount();
34+ if (!mnt)
35+ return NULL;
36+
37+ __tracing_path_set("", mnt);
38+
39+ return mnt;
40+}
41+
42+static const char *tracing_path_debugfs_mount(void)
43+{
44+ const char *mnt;
45+
46+ mnt = debugfs__mount();
47+ if (!mnt)
48+ return NULL;
49+
50+ __tracing_path_set("tracing/", mnt);
51+
52+ return mnt;
53+}
54+
55+const char *tracing_path_mount(void)
56+{
57+ const char *mnt;
58+
59+ mnt = tracing_path_tracefs_mount();
60+ if (mnt)
61+ return mnt;
62+
63+ mnt = tracing_path_debugfs_mount();
64+
65+ return mnt;
66+}
67+
68+void tracing_path_set(const char *mntpt)
69+{
70+ __tracing_path_set("tracing/", mntpt);
71+}
72+
73+char *get_tracing_file(const char *name)
74+{
75+ char *file;
76+
77+ if (asprintf(&file, "%s/%s", tracing_path, name) < 0)
78+ return NULL;
79+
80+ return file;
81+}
82+
83+void put_tracing_file(char *file)
84+{
85+ free(file);
86+}
87+
88+static int strerror_open(int err, char *buf, size_t size, const char *filename)
89+{
90+ char sbuf[128];
91+
92+ switch (err) {
93+ case ENOENT:
94+ /*
95+ * We will get here if we can't find the tracepoint, but one of
96+ * debugfs or tracefs is configured, which means you probably
97+ * want some tracepoint which wasn't compiled in your kernel.
98+ * - jirka
99+ */
100+ if (debugfs__configured() || tracefs__configured()) {
101+ snprintf(buf, size,
102+ "Error:\tFile %s/%s not found.\n"
103+ "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
104+ tracing_events_path, filename);
105+ break;
106+ }
107+ snprintf(buf, size, "%s",
108+ "Error:\tUnable to find debugfs/tracefs\n"
109+ "Hint:\tWas your kernel compiled with debugfs/tracefs support?\n"
110+ "Hint:\tIs the debugfs/tracefs filesystem mounted?\n"
111+ "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
112+ break;
113+ case EACCES: {
114+ snprintf(buf, size,
115+ "Error:\tNo permissions to read %s/%s\n"
116+ "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
117+ tracing_events_path, filename, tracing_mnt);
118+ }
119+ break;
120+ default:
121+ snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf)));
122+ break;
123+ }
124+
125+ return 0;
126+}
127+
128+int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name)
129+{
130+ char path[PATH_MAX];
131+
132+ snprintf(path, PATH_MAX, "%s/%s", sys, name ?: "*");
133+
134+ return strerror_open(err, buf, size, path);
135+}
tools/lib/api/fs/tracing_path.h+16−0
@@ -0,0 +1,16 @@
1+#ifndef __API_FS_TRACING_PATH_H
2+#define __API_FS_TRACING_PATH_H
3+
4+#include <linux/types.h>
5+
6+extern char tracing_path[];
7+extern char tracing_events_path[];
8+
9+void tracing_path_set(const char *mountpoint);
10+const char *tracing_path_mount(void);
11+
12+char *get_tracing_file(const char *name);
13+void put_tracing_file(char *file);
14+
15+int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name);
16+#endif /* __API_FS_TRACING_PATH_H */
tools/lib/bpf/Makefile+7−4
@@ -64,8 +64,9 @@ srctree := $(patsubst %/,%,$(dir $(srctree))) · 63 unmodified lines
6464 #$(info Determined 'srctree' to be $(srctree))
6565 endif
6666
67−FEATURE_DISPLAY = libelf libelf-getphdrnum libelf-mmap bpf
68−FEATURE_TESTS = libelf bpf
67+FEATURE_USER = .libbpf
68+FEATURE_TESTS = libelf libelf-getphdrnum libelf-mmap bpf
69+FEATURE_DISPLAY = libelf bpf
6970
7071 INCLUDES = -I. -I$(srctree)/tools/include -I$(srctree)/arch/$(ARCH)/include/uapi -I$(srctree)/include/uapi
7172 FEATURE_CHECK_CFLAGS-bpf = $(INCLUDES)
@@ -122,8 +123,10 @@ endif · 50 unmodified lines
122123 # the same command line setup.
123124 MAKEOVERRIDES=
124125
126+all:
127+
125128 export srctree OUTPUT CC LD CFLAGS V
126−build := -f $(srctree)/tools/build/Makefile.build dir=. obj
129+include $(srctree)/tools/build/Makefile.include
127130
128131 BPF_IN := $(OUTPUT)libbpf-in.o
129132 LIB_FILE := $(addprefix $(OUTPUT),$(LIB_FILE))
@@ -132,7 +135,7 @@ CMD_TARGETS = $(LIB_FILE) · 2 unmodified lines
132135
133136 TARGETS = $(CMD_TARGETS)
134137
135−all: $(VERSION_FILES) all_cmd
138+all: fixdep $(VERSION_FILES) all_cmd
136139
137140 all_cmd: $(CMD_TARGETS)
138141
tools/lib/lockdep/Makefile+4−2
@@ -93,8 +93,10 @@ else · 92 unmodified lines
9393 print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2';
9494 endif
9595
96+all:
97+
9698 export srctree OUTPUT CC LD CFLAGS V
97−build := -f $(srctree)/tools/build/Makefile.build dir=. obj
99+include $(srctree)/tools/build/Makefile.include
98100
99101 do_compile_shared_library = \
100102 ($(print_shared_lib_compile) \
@@ -109,7 +111,7 @@ CMD_TARGETS = $(LIB_FILE) · 8 unmodified lines
109111 TARGETS = $(CMD_TARGETS)
110112
111113
112−all: all_cmd
114+all: fixdep all_cmd
113115
114116 all_cmd: $(CMD_TARGETS)
115117
tools/lib/symbol/kallsyms.c+6−0
@@ -2,6 +2,12 @@ · 1 unmodified line
22 #include <stdio.h>
33 #include <stdlib.h>
44
5+u8 kallsyms2elf_type(char type)
6+{
7+ type = tolower(type);
8+ return (type == 't' || type == 'w') ? STT_FUNC : STT_OBJECT;
9+}
10+
511 int kallsyms__parse(const char *filename, void *arg,
612 int (*process_symbol)(void *arg, const char *name,
713 char type, u64 start))
tools/lib/symbol/kallsyms.h+3−1
@@ -9,7 +9,7 @@ · 8 unmodified lines
99 #define KSYM_NAME_LEN 256
1010 #endif
1111
12−static inline u8 kallsyms2elf_type(char type)
12+static inline u8 kallsyms2elf_binding(char type)
1313 {
1414 if (type == 'W')
1515 return STB_WEAK;
@@ -17,6 +17,8 @@ static inline u8 kallsyms2elf_type(char type) · 1 unmodified line
1717 return isupper(type) ? STB_GLOBAL : STB_LOCAL;
1818 }
1919
20+u8 kallsyms2elf_type(char type);
21+
2022 int kallsyms__parse(const char *filename, void *arg,
2123 int (*process_symbol)(void *arg, const char *name,
2224 char type, u64 start));
tools/lib/traceevent/event-parse.c+56−4
@@ -848,6 +848,7 @@ static void free_arg(struct print_arg *arg) · 847 unmodified lines
848848 free(arg->bitmask.bitmask);
849849 break;
850850 case PRINT_DYNAMIC_ARRAY:
851+ case PRINT_DYNAMIC_ARRAY_LEN:
851852 free(arg->dynarray.index);
852853 break;
853854 case PRINT_OP:
@@ -2728,6 +2729,42 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char ** · 1874 unmodified lines
27282729 return EVENT_ERROR;
27292730 }
27302731
2732+static enum event_type
2733+process_dynamic_array_len(struct event_format *event, struct print_arg *arg,
2734+ char **tok)
2735+{
2736+ struct format_field *field;
2737+ enum event_type type;
2738+ char *token;
2739+
2740+ if (read_expect_type(EVENT_ITEM, &token) < 0)
2741+ goto out_free;
2742+
2743+ arg->type = PRINT_DYNAMIC_ARRAY_LEN;
2744+
2745+ /* Find the field */
2746+ field = pevent_find_field(event, token);
2747+ if (!field)
2748+ goto out_free;
2749+
2750+ arg->dynarray.field = field;
2751+ arg->dynarray.index = 0;
2752+
2753+ if (read_expected(EVENT_DELIM, ")") < 0)
2754+ goto out_err;
2755+
2756+ type = read_token(&token);
2757+ *tok = token;
2758+
2759+ return type;
2760+
2761+ out_free:
2762+ free_token(token);
2763+ out_err:
2764+ *tok = NULL;
2765+ return EVENT_ERROR;
2766+}
2767+
27312768 static enum event_type
27322769 process_paren(struct event_format *event, struct print_arg *arg, char **tok)
27332770 {
@@ -2975,6 +3012,10 @@ process_function(struct event_format *event, struct print_arg *arg, · 241 unmodified lines
29753012 free_token(token);
29763013 return process_dynamic_array(event, arg, tok);
29773014 }
3015+ if (strcmp(token, "__get_dynamic_array_len") == 0) {
3016+ free_token(token);
3017+ return process_dynamic_array_len(event, arg, tok);
3018+ }
29783019
29793020 func = find_func_handler(event->pevent, token);
29803021 if (func) {
@@ -3655,14 +3696,25 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg · 674 unmodified lines
36553696 goto out_warning_op;
36563697 }
36573698 break;
3699+ case PRINT_DYNAMIC_ARRAY_LEN:
3700+ offset = pevent_read_number(pevent,
3701+ data + arg->dynarray.field->offset,
3702+ arg->dynarray.field->size);
3703+ /*
3704+ * The total allocated length of the dynamic array is
3705+ * stored in the top half of the field, and the offset
3706+ * is in the bottom half of the 32 bit field.
3707+ */
3708+ val = (unsigned long long)(offset >> 16);
3709+ break;
36583710 case PRINT_DYNAMIC_ARRAY:
36593711 /* Without [], we pass the address to the dynamic data */
36603712 offset = pevent_read_number(pevent,
36613713 data + arg->dynarray.field->offset,
36623714 arg->dynarray.field->size);
36633715 /*
3664− * The actual length of the dynamic array is stored
3665− * in the top half of the field, and the offset
3716+ * The total allocated length of the dynamic array is
3717+ * stored in the top half of the field, and the offset
36663718 * is in the bottom half of the 32 bit field.
36673719 */
36683720 offset &= 0xffff;
@@ -4853,8 +4905,8 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event · 1184 unmodified lines
48534905 else
48544906 ls = 2;
48554907
4856− if (*(ptr+1) == 'F' ||
4857− *(ptr+1) == 'f') {
4908+ if (*(ptr+1) == 'F' || *(ptr+1) == 'f' ||
4909+ *(ptr+1) == 'S' || *(ptr+1) == 's') {
48584910 ptr++;
48594911 show_func = *ptr;
48604912 } else if (*(ptr+1) == 'M' || *(ptr+1) == 'm') {
tools/lib/traceevent/event-parse.h+1−0
@@ -294,6 +294,7 @@ enum print_arg_type { · 293 unmodified lines
294294 PRINT_OP,
295295 PRINT_FUNC,
296296 PRINT_BITMASK,
297+ PRINT_DYNAMIC_ARRAY_LEN,
297298 };
298299
299300 struct print_arg {
tools/lib/traceevent/plugin_kvm.c+17−8
@@ -124,7 +124,10 @@ static const char *disassemble(unsigned char *insn, int len, uint64_t rip, · 123 unmodified lines
124124 _ER(WBINVD, 54) \
125125 _ER(XSETBV, 55) \
126126 _ER(APIC_WRITE, 56) \
127− _ER(INVPCID, 58)
127+ _ER(INVPCID, 58) \
128+ _ER(PML_FULL, 62) \
129+ _ER(XSAVES, 63) \
130+ _ER(XRSTORS, 64)
128131
129132 #define SVM_EXIT_REASONS \
130133 _ER(EXIT_READ_CR0, 0x000) \
@@ -352,15 +355,18 @@ static int kvm_nested_vmexit_handler(struct trace_seq *s, struct pevent_record * · 221 unmodified lines
352355 union kvm_mmu_page_role {
353356 unsigned word;
354357 struct {
355− unsigned glevels:4;
356358 unsigned level:4;
359+ unsigned cr4_pae:1;
357360 unsigned quadrant:2;
358− unsigned pad_for_nice_hex_output:6;
359361 unsigned direct:1;
360362 unsigned access:3;
361363 unsigned invalid:1;
362− unsigned cr4_pge:1;
363364 unsigned nxe:1;
365+ unsigned cr0_wp:1;
366+ unsigned smep_and_not_wp:1;
367+ unsigned smap_and_not_wp:1;
368+ unsigned pad_for_nice_hex_output:8;
369+ unsigned smm:8;
364370 };
365371 };
366372
@@ -385,15 +391,18 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record, · 18 unmodified lines
385391 if (pevent_is_file_bigendian(event->pevent) ==
386392 pevent_is_host_bigendian(event->pevent)) {
387393
388− trace_seq_printf(s, "%u/%u q%u%s %s%s %spge %snxe",
394+ trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s",
389395 role.level,
390− role.glevels,
391396 role.quadrant,
392397 role.direct ? " direct" : "",
393398 access_str[role.access],
394399 role.invalid ? " invalid" : "",
395− role.cr4_pge ? "" : "!",
396− role.nxe ? "" : "!");
400+ role.cr4_pae ? "" : "!",
401+ role.nxe ? "" : "!",
402+ role.cr0_wp ? "" : "!",
403+ role.smep_and_not_wp ? " smep" : "",
404+ role.smap_and_not_wp ? " smap" : "",
405+ role.smm ? " smm" : "");
397406 } else
398407 trace_seq_printf(s, "WORD: %08x", role.word);
399408
tools/perf/Documentation/intel-pt.txt+44−0
@@ -671,6 +671,7 @@ The letters are: · 670 unmodified lines
671671 e synthesize tracing error events
672672 d create a debug log
673673 g synthesize a call chain (use with i or x)
674+ l synthesize last branch entries (use with i or x)
674675
675676 "Instructions" events look like they were recorded by "perf record -e
676677 instructions".
@@ -707,12 +708,26 @@ on the sample is *not* adjusted and reflects the last known value of TSC. · 30 unmodified lines
707708
708709 For Intel PT, the default period is 100us.
709710
711+Setting it to a zero period means "as often as possible".
712+
713+In the case of Intel PT that is the same as a period of 1 and a unit of
714+'instructions' (i.e. --itrace=i1i).
715+
710716 Also the call chain size (default 16, max. 1024) for instructions or
711717 transactions events can be specified. e.g.
712718
713719 --itrace=ig32
714720 --itrace=xg32
715721
722+Also the number of last branch entries (default 64, max. 1024) for instructions or
723+transactions events can be specified. e.g.
724+
725+ --itrace=il10
726+ --itrace=xl10
727+
728+Note that last branch entries are cleared for each sample, so there is no overlap
729+from one sample to the next.
730+
716731 To disable trace decoding entirely, use the option --no-itrace.
717732
718733
@@ -749,3 +764,32 @@ perf inject also accepts the --itrace option in which case tracing data is · 30 unmodified lines
749764 removed and replaced with the synthesized events. e.g.
750765
751766 perf inject --itrace -i perf.data -o perf.data.new
767+
768+Below is an example of using Intel PT with autofdo. It requires autofdo
769+(https://github.com/google/autofdo) and gcc version 5. The bubble
770+sort example is from the AutoFDO tutorial (https://gcc.gnu.org/wiki/AutoFDO/Tutorial)
771+amended to take the number of elements as a parameter.
772+
773+ $ gcc-5 -O3 sort.c -o sort_optimized
774+ $ ./sort_optimized 30000
775+ Bubble sorting array of 30000 elements
776+ 2254 ms
777+
778+ $ cat ~/.perfconfig
779+ [intel-pt]
780+ mispred-all
781+
782+ $ perf record -e intel_pt//u ./sort 3000
783+ Bubble sorting array of 3000 elements
784+ 58 ms
785+ [ perf record: Woken up 2 times to write data ]
786+ [ perf record: Captured and wrote 3.939 MB perf.data ]
787+ $ perf inject -i perf.data -o inj --itrace=i100usle --strip
788+ $ ./create_gcov --binary=./sort --profile=inj --gcov=sort.gcov -gcov_version=1
789+ $ gcc-5 -O3 -fauto-profile=sort.gcov sort.c -o sort_autofdo
790+ $ ./sort_autofdo 30000
791+ Bubble sorting array of 30000 elements
792+ 2155 ms
793+
794+Note there is currently no advantage to using Intel PT instead of LBR, but
795+that may change in the future if greater use is made of the data.
tools/perf/Documentation/itrace.txt+4−0
@@ -6,6 +6,7 @@ · 5 unmodified lines
66 e synthesize error events
77 d create a debug log
88 g synthesize a call chain (use with i or x)
9+ l synthesize last branch entries (use with i or x)
910
1011 The default is all events i.e. the same as --itrace=ibxe
1112
@@ -20,3 +21,6 @@ · 8 unmodified lines
2021
2122 Also the call chain size (default 16, max. 1024) for instructions or
2223 transactions events can be specified.
24+
25+ Also the number of last branch entries (default 64, max. 1024) for
26+ instructions or transactions events can be specified.
tools/perf/Documentation/perf-bench.txt+19−35
@@ -82,7 +82,7 @@ Be multi thread instead of multi process · 81 unmodified lines
8282 Specify number of groups
8383
8484 -l::
85−--loop=::
85+--nr_loops=::
8686 Specify number of loops
8787
8888 Example of *messaging*
@@ -139,64 +139,48 @@ Suite for evaluating performance of simple memory copy in various ways. · 50 unmodified lines
139139 Options of *memcpy*
140140 ^^^^^^^^^^^^^^^^^^^
141141 -l::
142−--length::
143−Specify length of memory to copy (default: 1MB).
142+--size::
143+Specify size of memory to copy (default: 1MB).
144144 Available units are B, KB, MB, GB and TB (case insensitive).
145145
146−-r::
147−--routine::
148−Specify routine to copy (default: default).
149−Available routines are depend on the architecture.
146+-f::
147+--function::
148+Specify function to copy (default: default).
149+Available functions are depend on the architecture.
150150 On x86-64, x86-64-unrolled, x86-64-movsq and x86-64-movsb are supported.
151151
152−-i::
153−--iterations::
152+-l::
153+--nr_loops::
154154 Repeat memcpy invocation this number of times.
155155
156156 -c::
157−--cycle::
157+--cycles::
158158 Use perf's cpu-cycles event instead of gettimeofday syscall.
159159
160−-o::
161−--only-prefault::
162−Show only the result with page faults before memcpy.
163−
164−-n::
165−--no-prefault::
166−Show only the result without page faults before memcpy.
167−
168160 *memset*::
169161 Suite for evaluating performance of simple memory set in various ways.
170162
171163 Options of *memset*
172164 ^^^^^^^^^^^^^^^^^^^
173165 -l::
174−--length::
175−Specify length of memory to set (default: 1MB).
166+--size::
167+Specify size of memory to set (default: 1MB).
176168 Available units are B, KB, MB, GB and TB (case insensitive).
177169
178−-r::
179−--routine::
180−Specify routine to set (default: default).
181−Available routines are depend on the architecture.
170+-f::
171+--function::
172+Specify function to set (default: default).
173+Available functions are depend on the architecture.
182174 On x86-64, x86-64-unrolled, x86-64-stosq and x86-64-stosb are supported.
183175
184−-i::
185−--iterations::
176+-l::
177+--nr_loops::
186178 Repeat memset invocation this number of times.
187179
188180 -c::
189−--cycle::
181+--cycles::
190182 Use perf's cpu-cycles event instead of gettimeofday syscall.
191183
192−-o::
193−--only-prefault::
194−Show only the result with page faults before memset.
195−
196−-n::
197−--no-prefault::
198−Show only the result without page faults before memset.
199−
200184 SUITES FOR 'numa'
201185 ~~~~~~~~~~~~~~~~~
202186 *mem*::
tools/perf/Documentation/perf-inject.txt+3−0
@@ -50,6 +50,9 @@ OPTIONS · 49 unmodified lines
5050
5151 include::itrace.txt[]
5252
53+--strip::
54+ Use with --itrace to strip out non-synthesized events.
55+
5356 SEE ALSO
5457 --------
5558 linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-archive[1]
tools/perf/Documentation/perf-list.txt+3−0
@@ -30,6 +30,7 @@ counted. The following modifiers exist: · 29 unmodified lines
3030 G - guest counting (in KVM guests)
3131 H - host counting (not in KVM guests)
3232 p - precise level
33+ P - use maximum detected precise level
3334 S - read sample value (PERF_SAMPLE_READ)
3435 D - pin the event to the PMU
3536
@@ -125,6 +126,8 @@ To limit the list use: · 89 unmodified lines
125126 . If none of the above is matched, it will apply the supplied glob to all
126127 events, printing the ones that match.
127128
129+. As a last resort, it will do a substring search in all event names.
130+
128131 One or more types can be used at the same time, listing the events for the
129132 types specified.
130133
tools/perf/Documentation/perf-record.txt+14−2
@@ -144,7 +144,7 @@ OPTIONS · 143 unmodified lines
144144
145145 --call-graph::
146146 Setup and enable call-graph (stack chain/backtrace) recording,
147− implies -g.
147+ implies -g. Default is "fp".
148148
149149 Allows specifying "fp" (frame pointer) or "dwarf"
150150 (DWARF's CFI - Call Frame Information) or "lbr"
@@ -154,13 +154,18 @@ OPTIONS · 3 unmodified lines
154154 In some systems, where binaries are build with gcc
155155 --fomit-frame-pointer, using the "fp" method will produce bogus
156156 call graphs, using "dwarf", if available (perf tools linked to
157− the libunwind library) should be used instead.
157+ the libunwind or libdw library) should be used instead.
158158 Using the "lbr" method doesn't require any compiler options. It
159159 will produce call graphs from the hardware LBR registers. The
160160 main limition is that it is only available on new Intel
161161 platforms, such as Haswell. It can only get user call chain. It
162162 doesn't work with branch stack sampling at the same time.
163163
164+ When "dwarf" recording is used, perf also records (user) stack dump
165+ when sampled. Default size of the stack dump is 8192 (bytes).
166+ User can change the size by passing the size after comma like
167+ "--call-graph dwarf,4096".
168+
164169 -q::
165170 --quiet::
166171 Don't print any message, useful for scripting.
@@ -236,6 +241,7 @@ following filters are defined: · 69 unmodified lines
236241 - any_call: any function call or system call
237242 - any_ret: any function return or system call return
238243 - ind_call: any indirect branch
244+ - call: direct calls, including far (to/from kernel) calls
239245 - u: only when the branch target is at the user level
240246 - k: only when the branch target is in the kernel
241247 - hv: only when the target is at the hypervisor level
@@ -308,6 +314,12 @@ This option sets the time out limit. The default value is 500 ms. · 66 unmodified lines
308314 Record context switch events i.e. events of type PERF_RECORD_SWITCH or
309315 PERF_RECORD_SWITCH_CPU_WIDE.
310316
317+--clang-path::
318+Path to clang binary to use for compiling BPF scriptlets.
319+
320+--clang-opt::
321+Options passed to clang when compiling BPF scriptlets.
322+
311323 SEE ALSO
312324 --------
313325 linkperf:perf-stat[1], linkperf:perf-list[1]
tools/perf/Documentation/perf-report.txt+32−16
@@ -29,7 +29,7 @@ OPTIONS · 28 unmodified lines
2929 --show-nr-samples::
3030 Show the number of samples for each symbol
3131
32−--showcpuutilization::
32+--show-cpu-utilization::
3333 Show sample percentage for different cpu modes.
3434
3535 -T::
@@ -68,7 +68,7 @@ OPTIONS · 32 unmodified lines
6868 --sort=::
6969 Sort histogram entries by given key(s) - multiple keys can be specified
7070 in CSV format. Following sort keys are available:
71− pid, comm, dso, symbol, parent, cpu, srcline, weight, local_weight.
71+ pid, comm, dso, symbol, parent, cpu, socket, srcline, weight, local_weight.
7272
7373 Each key has following meaning:
7474
@@ -79,6 +79,7 @@ OPTIONS · 4 unmodified lines
7979 - parent: name of function matched to the parent regex filter. Unmatched
8080 entries are displayed as "[other]".
8181 - cpu: cpu number the task ran at the time of sample
82+ - socket: processor socket number the task ran at the time of sample
8283 - srcline: filename and line number executed at the time of sample. The
8384 DWARF debugging info must be provided.
8485 - srcfile: file name of the source file of the same. Requires dwarf
@@ -168,30 +169,40 @@ OPTIONS · 83 unmodified lines
168169 --dump-raw-trace::
169170 Dump raw trace in ASCII.
170171
171−-g [type,min[,limit],order[,key][,branch]]::
172−--call-graph::
173− Display call chains using type, min percent threshold, optional print
174− limit and order.
175− type can be either:
172+-g::
173+--call-graph=<print_type,threshold[,print_limit],order,sort_key,branch>::
174+ Display call chains using type, min percent threshold, print limit,
175+ call order, sort key and branch. Note that ordering of parameters is not
176+ fixed so any parement can be given in an arbitraty order. One exception
177+ is the print_limit which should be preceded by threshold.
178+
179+ print_type can be either:
176180 - flat: single column, linear exposure of call chains.
177− - graph: use a graph tree, displaying absolute overhead rates.
181+ - graph: use a graph tree, displaying absolute overhead rates. (default)
178182 - fractal: like graph, but displays relative rates. Each branch of
179− the tree is considered as a new profiled object. +
183+ the tree is considered as a new profiled object.
184+ - none: disable call chain display.
185+
186+ threshold is a percentage value which specifies a minimum percent to be
187+ included in the output call graph. Default is 0.5 (%).
188+
189+ print_limit is only applied when stdio interface is used. It's to limit
190+ number of call graph entries in a single hist entry. Note that it needs
191+ to be given after threshold (but not necessarily consecutive).
192+ Default is 0 (unlimited).
180193
181194 order can be either:
182195 - callee: callee based call graph.
183196 - caller: inverted caller based call graph.
197+ Default is 'caller' when --children is used, otherwise 'callee'.
184198
185− key can be:
186− - function: compare on functions
199+ sort_key can be:
200+ - function: compare on functions (default)
187201 - address: compare on individual code addresses
188202
189203 branch can be:
190− - branch: include last branch information in callgraph
191− when available. Usually more convenient to use --branch-history
192− for this.
193−
194− Default: fractal,0.5,callee,function.
204+ - branch: include last branch information in callgraph when available.
205+ Usually more convenient to use --branch-history for this.
195206
196207 --children::
197208 Accumulate callchain of children to parent entry so that then can
@@ -204,6 +215,8 @@ OPTIONS · 6 unmodified lines
204215 beyond the specified depth will be ignored. This is a trade-off
205216 between information loss and faster processing especially for
206217 workloads that can have a very long callchain stack.
218+ Note that when using the --itrace option the synthesized callchain size
219+ will override this value if the synthesized callchain size is bigger.
207220
208221 Default: 127
209222
@@ -349,6 +362,9 @@ include::itrace.txt[] · 139 unmodified lines
349362 This option extends the perf report to show reference callgraphs,
350363 which collected by reference event, in no callgraph event.
351364
365+--socket-filter::
366+ Only report the samples on the processor socket that match with this filter
367+
352368 include::callchain-overhead-calculation.txt[]
353369
354370 SEE ALSO
tools/perf/Documentation/perf-script.txt+15−2
@@ -112,11 +112,11 @@ OPTIONS · 111 unmodified lines
112112 --debug-mode::
113113 Do various checks like samples ordering and lost events.
114114
115−-f::
115+-F::
116116 --fields::
117117 Comma separated list of fields to print. Options are:
118118 comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
119− srcline, period, iregs, flags.
119+ srcline, period, iregs, brstack, brstacksym, flags.
120120 Field list can be prepended with the type, trace, sw or hw,
121121 to indicate to which event type the field list applies.
122122 e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace
@@ -175,6 +175,16 @@ OPTIONS · 52 unmodified lines
175175 Finally, a user may not set fields to none for all event types.
176176 i.e., -f "" is not allowed.
177177
178+ The brstack output includes branch related information with raw addresses using the
179+ /v/v/v/v/ syntax in the following order:
180+ FROM: branch source instruction
181+ TO : branch target instruction
182+ M/P/-: M=branch target mispredicted or branch direction was mispredicted, P=target predicted or direction predicted, -=not supported
183+ X/- : X=branch inside a transactional region, -=not in transaction region or not supported
184+ A/- : A=TSX abort entry, -=not aborted region or not supported
185+
186+ The brstacksym is identical to brstack, except that the FROM and TO addresses are printed in a symbolic form if possible.
187+
178188 -k::
179189 --vmlinux=<file>::
180190 vmlinux pathname
@@ -249,6 +259,9 @@ include::itrace.txt[] · 68 unmodified lines
249259 --full-source-path::
250260 Show the full path for source files for srcline output.
251261
262+--ns::
263+ Use 9 decimal places when displaying time (i.e. show the nanoseconds)
264+
252265 SEE ALSO
253266 --------
254267 linkperf:perf-record[1], linkperf:perf-script-perl[1],
tools/perf/Documentation/perf-stat.txt+3−2
@@ -128,8 +128,9 @@ perf stat --repeat 10 --null --sync --pre 'make -s O=defconfig-build/clean' -- m · 127 unmodified lines
128128
129129 -I msecs::
130130 --interval-print msecs::
131− Print count deltas every N milliseconds (minimum: 100ms)
132− example: perf stat -I 1000 -e cycles -a sleep 5
131+Print count deltas every N milliseconds (minimum: 10ms)
132+The overhead percentage could be high in some cases, for instance with small, sub 100ms intervals. Use with caution.
133+ example: 'perf stat -I 1000 -e cycles -a sleep 5'
133134
134135 --per-socket::
135136 Aggregate counts per processor socket for system-wide mode measurements. This
tools/perf/Documentation/perf-top.txt+3−2
@@ -160,9 +160,10 @@ Default is to monitor all CPUS. · 159 unmodified lines
160160 -g::
161161 Enables call-graph (stack chain/backtrace) recording.
162162
163−--call-graph::
163+--call-graph [mode,type,min[,limit],order[,key][,branch]]::
164164 Setup and enable call-graph (stack chain/backtrace) recording,
165− implies -g.
165+ implies -g. See `--call-graph` section in perf-record and
166+ perf-report man pages for details.
166167
167168 --children::
168169 Accumulate callchain of children to parent entry so that then can
tools/perf/Documentation/perf.txt+8−0
@@ -27,6 +27,14 @@ OPTIONS · 26 unmodified lines
2727 Setup buildid cache directory. It has higher priority than
2828 buildid.dir config file option.
2929
30+-v::
31+--version::
32+ Display perf version.
33+
34+-h::
35+--help::
36+ Run perf help command.
37+
3038 DESCRIPTION
3139 -----------
3240 Performance counters for Linux are a new kernel-based subsystem
tools/perf/MANIFEST+5−0
@@ -17,6 +17,7 @@ tools/build · 16 unmodified lines
1717 tools/arch/x86/include/asm/atomic.h
1818 tools/arch/x86/include/asm/rmwcc.h
1919 tools/lib/traceevent
20+tools/lib/bpf
2021 tools/lib/api
2122 tools/lib/bpf
2223 tools/lib/hweight.c
@@ -41,6 +42,7 @@ tools/include/asm-generic/bitops.h · 18 unmodified lines
4142 tools/include/linux/atomic.h
4243 tools/include/linux/bitops.h
4344 tools/include/linux/compiler.h
45+tools/include/linux/filter.h
4446 tools/include/linux/hash.h
4547 tools/include/linux/kernel.h
4648 tools/include/linux/list.h
@@ -49,6 +51,7 @@ tools/include/linux/poison.h · 2 unmodified lines
4951 tools/include/linux/rbtree.h
5052 tools/include/linux/rbtree_augmented.h
5153 tools/include/linux/types.h
54+tools/include/linux/err.h
5255 include/asm-generic/bitops/arch_hweight.h
5356 include/asm-generic/bitops/const_hweight.h
5457 include/asm-generic/bitops/fls64.h
@@ -67,6 +70,8 @@ arch/*/lib/memset*.S · 12 unmodified lines
6770 include/linux/poison.h
6871 include/linux/hw_breakpoint.h
6972 include/uapi/linux/perf_event.h
73+include/uapi/linux/bpf.h
74+include/uapi/linux/bpf_common.h
7075 include/uapi/linux/const.h
7176 include/uapi/linux/swab.h
7277 include/uapi/linux/hw_breakpoint.h
tools/perf/Makefile.perf+35−18
@@ -75,6 +75,8 @@ include config/utilities.mak · 74 unmodified lines
7575 # Define NO_LZMA if you do not want to support compressed (xz) kernel modules
7676 #
7777 # Define NO_AUXTRACE if you do not want AUX area tracing support
78+#
79+# Define NO_LIBBPF if you do not want BPF support
7880
7981 # As per kernel Makefile, avoid funny character set dependencies
8082 unexport LC_ALL
@@ -145,6 +147,7 @@ AWK = awk · 64 unmodified lines
145147
146148 LIB_DIR = $(srctree)/tools/lib/api/
147149 TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
150+BPF_DIR = $(srctree)/tools/lib/bpf/
148151
149152 # include config/Makefile by default and rule out
150153 # non-config cases
@@ -180,6 +183,7 @@ strip-libs = $(filter-out -l%,$(1)) · 29 unmodified lines
180183
181184 ifneq ($(OUTPUT),)
182185 TE_PATH=$(OUTPUT)
186+ BPF_PATH=$(OUTPUT)
183187 ifneq ($(subdir),)
184188 LIB_PATH=$(OUTPUT)/../lib/api/
185189 else
@@ -188,6 +192,7 @@ endif · 2 unmodified lines
188192 else
189193 TE_PATH=$(TRACE_EVENT_DIR)
190194 LIB_PATH=$(LIB_DIR)
195+ BPF_PATH=$(BPF_DIR)
191196 endif
192197
193198 LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
@@ -199,6 +204,8 @@ LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYN · 5 unmodified lines
199204 LIBAPI = $(LIB_PATH)libapi.a
200205 export LIBAPI
201206
207+LIBBPF = $(BPF_PATH)libbpf.a
208+
202209 # python extension build directories
203210 PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
204211 PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
@@ -251,6 +258,9 @@ export PERL_PATH · 46 unmodified lines
251258 LIB_FILE=$(OUTPUT)libperf.a
252259
253260 PERFLIBS = $(LIB_FILE) $(LIBAPI) $(LIBTRACEEVENT)
261+ifndef NO_LIBBPF
262+ PERFLIBS += $(LIBBPF)
263+endif
254264
255265 # We choose to avoid "if .. else if .. else .. endif endif"
256266 # because maintaining the nesting to match is a pain. If
@@ -297,16 +307,16 @@ strip: $(PROGRAMS) $(OUTPUT)perf · 40 unmodified lines
297307 PERF_IN := $(OUTPUT)perf-in.o
298308
299309 export srctree OUTPUT RM CC LD AR CFLAGS V BISON FLEX AWK
300−build := -f $(srctree)/tools/build/Makefile.build dir=. obj
310+include $(srctree)/tools/build/Makefile.include
301311
302−$(PERF_IN): $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h FORCE
312+$(PERF_IN): prepare FORCE
303313 $(Q)$(MAKE) $(build)=perf
304314
305315 $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
306316 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \
307317 $(PERF_IN) $(LIBS) -o $@
308318
309−$(GTK_IN): FORCE
319+$(GTK_IN): fixdep FORCE
310320 $(Q)$(MAKE) $(build)=gtk
311321
312322 $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS)
@@ -349,27 +359,27 @@ endif · 36 unmodified lines
349359 __build-dir = $(subst $(OUTPUT),,$(dir $@))
350360 build-dir = $(if $(__build-dir),$(__build-dir),.)
351361
352−single_dep: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
362+prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h fixdep
353363
354−$(OUTPUT)%.o: %.c single_dep FORCE
364+$(OUTPUT)%.o: %.c prepare FORCE
355365 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
356366
357−$(OUTPUT)%.i: %.c single_dep FORCE
367+$(OUTPUT)%.i: %.c prepare FORCE
358368 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
359369
360−$(OUTPUT)%.s: %.c single_dep FORCE
370+$(OUTPUT)%.s: %.c prepare FORCE
361371 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
362372
363−$(OUTPUT)%-bison.o: %.c single_dep FORCE
373+$(OUTPUT)%-bison.o: %.c prepare FORCE
364374 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
365375
366−$(OUTPUT)%-flex.o: %.c single_dep FORCE
376+$(OUTPUT)%-flex.o: %.c prepare FORCE
367377 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
368378
369−$(OUTPUT)%.o: %.S single_dep FORCE
379+$(OUTPUT)%.o: %.S prepare FORCE
370380 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
371381
372−$(OUTPUT)%.i: %.S single_dep FORCE
382+$(OUTPUT)%.i: %.S prepare FORCE
373383 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
374384
375385 $(OUTPUT)perf-%: %.o $(PERFLIBS)
@@ -389,7 +399,7 @@ $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h) · 13 unmodified lines
389399
390400 LIBPERF_IN := $(OUTPUT)libperf-in.o
391401
392−$(LIBPERF_IN): FORCE
402+$(LIBPERF_IN): fixdep FORCE
393403 $(Q)$(MAKE) $(build)=libperf
394404
395405 $(LIB_FILE): $(LIBPERF_IN)
@@ -397,10 +407,10 @@ $(LIB_FILE): $(LIBPERF_IN) · 1 unmodified line
397407
398408 LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ)
399409
400−$(LIBTRACEEVENT): FORCE
410+$(LIBTRACEEVENT): fixdep FORCE
401411 $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent.a
402412
403−libtraceevent_plugins: FORCE
413+libtraceevent_plugins: fixdep FORCE
404414 $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) plugins
405415
406416 $(LIBTRACEEVENT_DYNAMIC_LIST): libtraceevent_plugins
@@ -413,13 +423,20 @@ $(LIBTRACEEVENT)-clean: · 6 unmodified lines
413423 install-traceevent-plugins: $(LIBTRACEEVENT)
414424 $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) install_plugins
415425
416−$(LIBAPI): FORCE
426+$(LIBAPI): fixdep FORCE
417427 $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a
418428
419429 $(LIBAPI)-clean:
420430 $(call QUIET_CLEAN, libapi)
421431 $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
422432
433+$(LIBBPF): fixdep FORCE
434+ $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a
435+
436+$(LIBBPF)-clean:
437+ $(call QUIET_CLEAN, libbpf)
438+ $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null
439+
423440 help:
424441 @echo 'Perf make targets:'
425442 @echo ' doc - make *all* documentation (see below)'
@@ -459,7 +476,7 @@ INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html · 33 unmodified lines
459476 $(DOC_TARGETS):
460477 $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all)
461478
462−TAG_FOLDERS= . ../lib/traceevent ../lib/api ../lib/symbol
479+TAG_FOLDERS= . ../lib/traceevent ../lib/api ../lib/symbol ../include ../lib/bpf
463480 TAG_FILES= ../../include/uapi/linux/perf_event.h
464481
465482 TAGS:
@@ -567,7 +584,7 @@ config-clean: · 101 unmodified lines
567584 $(call QUIET_CLEAN, config)
568585 $(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
569586
570−clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean config-clean
587+clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean config-clean
571588 $(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
572589 $(Q)find . -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
573590 $(Q)$(RM) $(OUTPUT).config-detected
@@ -591,6 +608,6 @@ FORCE: · 17 unmodified lines
591608
592609 .PHONY: all install clean config-clean strip install-gtk
593610 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
594−.PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE single_dep
611+.PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare
595612 .PHONY: libtraceevent_plugins
596613
tools/perf/arch/common.c+4−6
@@ -128,9 +128,8 @@ static const char *normalize_arch(char *arch) · 127 unmodified lines
128128 return arch;
129129 }
130130
131−static int perf_session_env__lookup_binutils_path(struct perf_env *env,
132− const char *name,
133− const char **path)
131+static int perf_env__lookup_binutils_path(struct perf_env *env,
132+ const char *name, const char **path)
134133 {
135134 int idx;
136135 const char *arch, *cross_env;
@@ -206,7 +205,7 @@ out_error: · 69 unmodified lines
206205 return -1;
207206 }
208207
209−int perf_session_env__lookup_objdump(struct perf_env *env)
208+int perf_env__lookup_objdump(struct perf_env *env)
210209 {
211210 /*
212211 * For live mode, env->arch will be NULL and we can use
@@ -215,6 +214,5 @@ int perf_session_env__lookup_objdump(struct perf_env *env) · 2 unmodified lines
215214 if (env->arch == NULL)
216215 return 0;
217216
218− return perf_session_env__lookup_binutils_path(env, "objdump",
219− &objdump_path);
217+ return perf_env__lookup_binutils_path(env, "objdump", &objdump_path);
220218 }
tools/perf/arch/common.h+2−2
@@ -1,10 +1,10 @@
11 #ifndef ARCH_PERF_COMMON_H
22 #define ARCH_PERF_COMMON_H
33
4−#include "../util/session.h"
4+#include "../util/env.h"
55
66 extern const char *objdump_path;
77
8−int perf_session_env__lookup_objdump(struct perf_env *env);
8+int perf_env__lookup_objdump(struct perf_env *env);
99
1010 #endif /* ARCH_PERF_COMMON_H */
tools/perf/arch/x86/Build+1−1
@@ -1,2 +1,2 @@
11 libperf-y += util/
2−libperf-$(CONFIG_DWARF_UNWIND) += tests/
2+libperf-y += tests/
tools/perf/arch/x86/Makefile+1−0
@@ -2,3 +2,4 @@ ifndef NO_DWARF · 1 unmodified line
22 PERF_HAVE_DWARF_REGS := 1
33 endif
44 HAVE_KVM_STAT_SUPPORT := 1
5+PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
tools/perf/arch/x86/include/arch-tests.h+19−0
@@ -0,0 +1,19 @@
1+#ifndef ARCH_TESTS_H
2+#define ARCH_TESTS_H
3+
4+/* Tests */
5+int test__rdpmc(void);
6+int test__perf_time_to_tsc(void);
7+int test__insn_x86(void);
8+int test__intel_cqm_count_nmi_context(void);
9+
10+#ifdef HAVE_DWARF_UNWIND_SUPPORT
11+struct thread;
12+struct perf_sample;
13+int test__arch_unwind_sample(struct perf_sample *sample,
14+ struct thread *thread);
15+#endif
16+
17+extern struct test arch_tests[];
18+
19+#endif
tools/perf/arch/x86/tests/Build+8−2
@@ -1,2 +1,8 @@
1−libperf-y += regs_load.o
2−libperf-y += dwarf-unwind.o
1+libperf-$(CONFIG_DWARF_UNWIND) += regs_load.o
2+libperf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
3+
4+libperf-y += arch-tests.o
5+libperf-y += rdpmc.o
6+libperf-y += perf-time-to-tsc.o
7+libperf-$(CONFIG_AUXTRACE) += insn-x86.o
8+libperf-y += intel-cqm.o
tools/perf/arch/x86/tests/arch-tests.c+34−0
@@ -0,0 +1,34 @@
1+#include <string.h>
2+#include "tests/tests.h"
3+#include "arch-tests.h"
4+
5+struct test arch_tests[] = {
6+ {
7+ .desc = "x86 rdpmc test",
8+ .func = test__rdpmc,
9+ },
10+ {
11+ .desc = "Test converting perf time to TSC",
12+ .func = test__perf_time_to_tsc,
13+ },
14+#ifdef HAVE_DWARF_UNWIND_SUPPORT
15+ {
16+ .desc = "Test dwarf unwind",
17+ .func = test__dwarf_unwind,
18+ },
19+#endif
20+#ifdef HAVE_AUXTRACE_SUPPORT
21+ {
22+ .desc = "Test x86 instruction decoder - new instructions",
23+ .func = test__insn_x86,
24+ },
25+#endif
26+ {
27+ .desc = "Test intel cqm nmi context read",
28+ .func = test__intel_cqm_count_nmi_context,
29+ },
30+ {
31+ .func = NULL,
32+ },
33+
34+};
tools/perf/arch/x86/tests/dwarf-unwind.c+1−0
@@ -5,6 +5,7 @@ · 4 unmodified lines
55 #include "event.h"
66 #include "debug.h"
77 #include "tests/tests.h"
8+#include "arch-tests.h"
89
910 #define STACK_SIZE 8192
1011
tools/perf/arch/x86/tests/gen-insn-x86-dat.awk+75−0
@@ -0,0 +1,75 @@
1+#!/bin/awk -f
2+# gen-insn-x86-dat.awk: script to convert data for the insn-x86 test
3+# Copyright (c) 2015, Intel Corporation.
4+#
5+# This program is free software; you can redistribute it and/or modify it
6+# under the terms and conditions of the GNU General Public License,
7+# version 2, as published by the Free Software Foundation.
8+#
9+# This program is distributed in the hope it will be useful, but WITHOUT
10+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12+# more details.
13+
14+BEGIN {
15+ print "/*"
16+ print " * Generated by gen-insn-x86-dat.sh and gen-insn-x86-dat.awk"
17+ print " * from insn-x86-dat-src.c for inclusion by insn-x86.c"
18+ print " * Do not change this code."
19+ print "*/\n"
20+ op = ""
21+ branch = ""
22+ rel = 0
23+ going = 0
24+}
25+
26+/ Start here / {
27+ going = 1
28+}
29+
30+/ Stop here / {
31+ going = 0
32+}
33+
34+/^\s*[0-9a-fA-F]+\:/ {
35+ if (going) {
36+ colon_pos = index($0, ":")
37+ useful_line = substr($0, colon_pos + 1)
38+ first_pos = match(useful_line, "[0-9a-fA-F]")
39+ useful_line = substr(useful_line, first_pos)
40+ gsub("\t", "\\t", useful_line)
41+ printf "{{"
42+ len = 0
43+ for (i = 2; i <= NF; i++) {
44+ if (match($i, "^[0-9a-fA-F][0-9a-fA-F]$")) {
45+ printf "0x%s, ", $i
46+ len += 1
47+ } else {
48+ break
49+ }
50+ }
51+ printf "}, %d, %s, \"%s\", \"%s\",", len, rel, op, branch
52+ printf "\n\"%s\",},\n", useful_line
53+ op = ""
54+ branch = ""
55+ rel = 0
56+ }
57+}
58+
59+/ Expecting: / {
60+ expecting_str = " Expecting: "
61+ expecting_len = length(expecting_str)
62+ expecting_pos = index($0, expecting_str)
63+ useful_line = substr($0, expecting_pos + expecting_len)
64+ for (i = 1; i <= NF; i++) {
65+ if ($i == "Expecting:") {
66+ i++
67+ op = $i
68+ i++
69+ branch = $i
70+ i++
71+ rel = $i
72+ break
73+ }
74+ }
75+}
tools/perf/arch/x86/tests/gen-insn-x86-dat.sh+43−0
@@ -0,0 +1,43 @@
1+#!/bin/sh
2+# gen-insn-x86-dat: generate data for the insn-x86 test
3+# Copyright (c) 2015, Intel Corporation.
4+#
5+# This program is free software; you can redistribute it and/or modify it
6+# under the terms and conditions of the GNU General Public License,
7+# version 2, as published by the Free Software Foundation.
8+#
9+# This program is distributed in the hope it will be useful, but WITHOUT
10+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12+# more details.
13+
14+set -e
15+
16+if [ "$(uname -m)" != "x86_64" ]; then
17+ echo "ERROR: This script only works on x86_64"
18+ exit 1
19+fi
20+
21+cd $(dirname $0)
22+
23+trap 'echo "Might need a more recent version of binutils"' EXIT
24+
25+echo "Compiling insn-x86-dat-src.c to 64-bit object"
26+
27+gcc -g -c insn-x86-dat-src.c
28+
29+objdump -dSw insn-x86-dat-src.o | awk -f gen-insn-x86-dat.awk > insn-x86-dat-64.c
30+
31+rm -f insn-x86-dat-src.o
32+
33+echo "Compiling insn-x86-dat-src.c to 32-bit object"
34+
35+gcc -g -c -m32 insn-x86-dat-src.c
36+
37+objdump -dSw insn-x86-dat-src.o | awk -f gen-insn-x86-dat.awk > insn-x86-dat-32.c
38+
39+rm -f insn-x86-dat-src.o
40+
41+trap - EXIT
42+
43+echo "Done (use git diff to see the changes)"
tools/perf/arch/x86/tests/insn-x86-dat-32.c+658−0
@@ -0,0 +1,658 @@
1+/*
2+ * Generated by gen-insn-x86-dat.sh and gen-insn-x86-dat.awk
3+ * from insn-x86-dat-src.c for inclusion by insn-x86.c
4+ * Do not change this code.
5+*/
6+
7+{{0x0f, 0x31, }, 2, 0, "", "",
8+"0f 31 \trdtsc ",},
9+{{0xf3, 0x0f, 0x1b, 0x00, }, 4, 0, "", "",
10+"f3 0f 1b 00 \tbndmk (%eax),%bnd0",},
11+{{0xf3, 0x0f, 0x1b, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
12+"f3 0f 1b 05 78 56 34 12 \tbndmk 0x12345678,%bnd0",},
13+{{0xf3, 0x0f, 0x1b, 0x18, }, 4, 0, "", "",
14+"f3 0f 1b 18 \tbndmk (%eax),%bnd3",},
15+{{0xf3, 0x0f, 0x1b, 0x04, 0x01, }, 5, 0, "", "",
16+"f3 0f 1b 04 01 \tbndmk (%ecx,%eax,1),%bnd0",},
17+{{0xf3, 0x0f, 0x1b, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
18+"f3 0f 1b 04 05 78 56 34 12 \tbndmk 0x12345678(,%eax,1),%bnd0",},
19+{{0xf3, 0x0f, 0x1b, 0x04, 0x08, }, 5, 0, "", "",
20+"f3 0f 1b 04 08 \tbndmk (%eax,%ecx,1),%bnd0",},
21+{{0xf3, 0x0f, 0x1b, 0x04, 0xc8, }, 5, 0, "", "",
22+"f3 0f 1b 04 c8 \tbndmk (%eax,%ecx,8),%bnd0",},
23+{{0xf3, 0x0f, 0x1b, 0x40, 0x12, }, 5, 0, "", "",
24+"f3 0f 1b 40 12 \tbndmk 0x12(%eax),%bnd0",},
25+{{0xf3, 0x0f, 0x1b, 0x45, 0x12, }, 5, 0, "", "",
26+"f3 0f 1b 45 12 \tbndmk 0x12(%ebp),%bnd0",},
27+{{0xf3, 0x0f, 0x1b, 0x44, 0x01, 0x12, }, 6, 0, "", "",
28+"f3 0f 1b 44 01 12 \tbndmk 0x12(%ecx,%eax,1),%bnd0",},
29+{{0xf3, 0x0f, 0x1b, 0x44, 0x05, 0x12, }, 6, 0, "", "",
30+"f3 0f 1b 44 05 12 \tbndmk 0x12(%ebp,%eax,1),%bnd0",},
31+{{0xf3, 0x0f, 0x1b, 0x44, 0x08, 0x12, }, 6, 0, "", "",
32+"f3 0f 1b 44 08 12 \tbndmk 0x12(%eax,%ecx,1),%bnd0",},
33+{{0xf3, 0x0f, 0x1b, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
34+"f3 0f 1b 44 c8 12 \tbndmk 0x12(%eax,%ecx,8),%bnd0",},
35+{{0xf3, 0x0f, 0x1b, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
36+"f3 0f 1b 80 78 56 34 12 \tbndmk 0x12345678(%eax),%bnd0",},
37+{{0xf3, 0x0f, 0x1b, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
38+"f3 0f 1b 85 78 56 34 12 \tbndmk 0x12345678(%ebp),%bnd0",},
39+{{0xf3, 0x0f, 0x1b, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
40+"f3 0f 1b 84 01 78 56 34 12 \tbndmk 0x12345678(%ecx,%eax,1),%bnd0",},
41+{{0xf3, 0x0f, 0x1b, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
42+"f3 0f 1b 84 05 78 56 34 12 \tbndmk 0x12345678(%ebp,%eax,1),%bnd0",},
43+{{0xf3, 0x0f, 0x1b, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
44+"f3 0f 1b 84 08 78 56 34 12 \tbndmk 0x12345678(%eax,%ecx,1),%bnd0",},
45+{{0xf3, 0x0f, 0x1b, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
46+"f3 0f 1b 84 c8 78 56 34 12 \tbndmk 0x12345678(%eax,%ecx,8),%bnd0",},
47+{{0xf3, 0x0f, 0x1a, 0x00, }, 4, 0, "", "",
48+"f3 0f 1a 00 \tbndcl (%eax),%bnd0",},
49+{{0xf3, 0x0f, 0x1a, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
50+"f3 0f 1a 05 78 56 34 12 \tbndcl 0x12345678,%bnd0",},
51+{{0xf3, 0x0f, 0x1a, 0x18, }, 4, 0, "", "",
52+"f3 0f 1a 18 \tbndcl (%eax),%bnd3",},
53+{{0xf3, 0x0f, 0x1a, 0x04, 0x01, }, 5, 0, "", "",
54+"f3 0f 1a 04 01 \tbndcl (%ecx,%eax,1),%bnd0",},
55+{{0xf3, 0x0f, 0x1a, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
56+"f3 0f 1a 04 05 78 56 34 12 \tbndcl 0x12345678(,%eax,1),%bnd0",},
57+{{0xf3, 0x0f, 0x1a, 0x04, 0x08, }, 5, 0, "", "",
58+"f3 0f 1a 04 08 \tbndcl (%eax,%ecx,1),%bnd0",},
59+{{0xf3, 0x0f, 0x1a, 0x04, 0xc8, }, 5, 0, "", "",
60+"f3 0f 1a 04 c8 \tbndcl (%eax,%ecx,8),%bnd0",},
61+{{0xf3, 0x0f, 0x1a, 0x40, 0x12, }, 5, 0, "", "",
62+"f3 0f 1a 40 12 \tbndcl 0x12(%eax),%bnd0",},
63+{{0xf3, 0x0f, 0x1a, 0x45, 0x12, }, 5, 0, "", "",
64+"f3 0f 1a 45 12 \tbndcl 0x12(%ebp),%bnd0",},
65+{{0xf3, 0x0f, 0x1a, 0x44, 0x01, 0x12, }, 6, 0, "", "",
66+"f3 0f 1a 44 01 12 \tbndcl 0x12(%ecx,%eax,1),%bnd0",},
67+{{0xf3, 0x0f, 0x1a, 0x44, 0x05, 0x12, }, 6, 0, "", "",
68+"f3 0f 1a 44 05 12 \tbndcl 0x12(%ebp,%eax,1),%bnd0",},
69+{{0xf3, 0x0f, 0x1a, 0x44, 0x08, 0x12, }, 6, 0, "", "",
70+"f3 0f 1a 44 08 12 \tbndcl 0x12(%eax,%ecx,1),%bnd0",},
71+{{0xf3, 0x0f, 0x1a, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
72+"f3 0f 1a 44 c8 12 \tbndcl 0x12(%eax,%ecx,8),%bnd0",},
73+{{0xf3, 0x0f, 0x1a, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
74+"f3 0f 1a 80 78 56 34 12 \tbndcl 0x12345678(%eax),%bnd0",},
75+{{0xf3, 0x0f, 0x1a, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
76+"f3 0f 1a 85 78 56 34 12 \tbndcl 0x12345678(%ebp),%bnd0",},
77+{{0xf3, 0x0f, 0x1a, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
78+"f3 0f 1a 84 01 78 56 34 12 \tbndcl 0x12345678(%ecx,%eax,1),%bnd0",},
79+{{0xf3, 0x0f, 0x1a, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
80+"f3 0f 1a 84 05 78 56 34 12 \tbndcl 0x12345678(%ebp,%eax,1),%bnd0",},
81+{{0xf3, 0x0f, 0x1a, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
82+"f3 0f 1a 84 08 78 56 34 12 \tbndcl 0x12345678(%eax,%ecx,1),%bnd0",},
83+{{0xf3, 0x0f, 0x1a, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
84+"f3 0f 1a 84 c8 78 56 34 12 \tbndcl 0x12345678(%eax,%ecx,8),%bnd0",},
85+{{0xf3, 0x0f, 0x1a, 0xc0, }, 4, 0, "", "",
86+"f3 0f 1a c0 \tbndcl %eax,%bnd0",},
87+{{0xf2, 0x0f, 0x1a, 0x00, }, 4, 0, "", "",
88+"f2 0f 1a 00 \tbndcu (%eax),%bnd0",},
89+{{0xf2, 0x0f, 0x1a, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
90+"f2 0f 1a 05 78 56 34 12 \tbndcu 0x12345678,%bnd0",},
91+{{0xf2, 0x0f, 0x1a, 0x18, }, 4, 0, "", "",
92+"f2 0f 1a 18 \tbndcu (%eax),%bnd3",},
93+{{0xf2, 0x0f, 0x1a, 0x04, 0x01, }, 5, 0, "", "",
94+"f2 0f 1a 04 01 \tbndcu (%ecx,%eax,1),%bnd0",},
95+{{0xf2, 0x0f, 0x1a, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
96+"f2 0f 1a 04 05 78 56 34 12 \tbndcu 0x12345678(,%eax,1),%bnd0",},
97+{{0xf2, 0x0f, 0x1a, 0x04, 0x08, }, 5, 0, "", "",
98+"f2 0f 1a 04 08 \tbndcu (%eax,%ecx,1),%bnd0",},
99+{{0xf2, 0x0f, 0x1a, 0x04, 0xc8, }, 5, 0, "", "",
100+"f2 0f 1a 04 c8 \tbndcu (%eax,%ecx,8),%bnd0",},
101+{{0xf2, 0x0f, 0x1a, 0x40, 0x12, }, 5, 0, "", "",
102+"f2 0f 1a 40 12 \tbndcu 0x12(%eax),%bnd0",},
103+{{0xf2, 0x0f, 0x1a, 0x45, 0x12, }, 5, 0, "", "",
104+"f2 0f 1a 45 12 \tbndcu 0x12(%ebp),%bnd0",},
105+{{0xf2, 0x0f, 0x1a, 0x44, 0x01, 0x12, }, 6, 0, "", "",
106+"f2 0f 1a 44 01 12 \tbndcu 0x12(%ecx,%eax,1),%bnd0",},
107+{{0xf2, 0x0f, 0x1a, 0x44, 0x05, 0x12, }, 6, 0, "", "",
108+"f2 0f 1a 44 05 12 \tbndcu 0x12(%ebp,%eax,1),%bnd0",},
109+{{0xf2, 0x0f, 0x1a, 0x44, 0x08, 0x12, }, 6, 0, "", "",
110+"f2 0f 1a 44 08 12 \tbndcu 0x12(%eax,%ecx,1),%bnd0",},
111+{{0xf2, 0x0f, 0x1a, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
112+"f2 0f 1a 44 c8 12 \tbndcu 0x12(%eax,%ecx,8),%bnd0",},
113+{{0xf2, 0x0f, 0x1a, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
114+"f2 0f 1a 80 78 56 34 12 \tbndcu 0x12345678(%eax),%bnd0",},
115+{{0xf2, 0x0f, 0x1a, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
116+"f2 0f 1a 85 78 56 34 12 \tbndcu 0x12345678(%ebp),%bnd0",},
117+{{0xf2, 0x0f, 0x1a, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
118+"f2 0f 1a 84 01 78 56 34 12 \tbndcu 0x12345678(%ecx,%eax,1),%bnd0",},
119+{{0xf2, 0x0f, 0x1a, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
120+"f2 0f 1a 84 05 78 56 34 12 \tbndcu 0x12345678(%ebp,%eax,1),%bnd0",},
121+{{0xf2, 0x0f, 0x1a, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
122+"f2 0f 1a 84 08 78 56 34 12 \tbndcu 0x12345678(%eax,%ecx,1),%bnd0",},
123+{{0xf2, 0x0f, 0x1a, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
124+"f2 0f 1a 84 c8 78 56 34 12 \tbndcu 0x12345678(%eax,%ecx,8),%bnd0",},
125+{{0xf2, 0x0f, 0x1a, 0xc0, }, 4, 0, "", "",
126+"f2 0f 1a c0 \tbndcu %eax,%bnd0",},
127+{{0xf2, 0x0f, 0x1b, 0x00, }, 4, 0, "", "",
128+"f2 0f 1b 00 \tbndcn (%eax),%bnd0",},
129+{{0xf2, 0x0f, 0x1b, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
130+"f2 0f 1b 05 78 56 34 12 \tbndcn 0x12345678,%bnd0",},
131+{{0xf2, 0x0f, 0x1b, 0x18, }, 4, 0, "", "",
132+"f2 0f 1b 18 \tbndcn (%eax),%bnd3",},
133+{{0xf2, 0x0f, 0x1b, 0x04, 0x01, }, 5, 0, "", "",
134+"f2 0f 1b 04 01 \tbndcn (%ecx,%eax,1),%bnd0",},
135+{{0xf2, 0x0f, 0x1b, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
136+"f2 0f 1b 04 05 78 56 34 12 \tbndcn 0x12345678(,%eax,1),%bnd0",},
137+{{0xf2, 0x0f, 0x1b, 0x04, 0x08, }, 5, 0, "", "",
138+"f2 0f 1b 04 08 \tbndcn (%eax,%ecx,1),%bnd0",},
139+{{0xf2, 0x0f, 0x1b, 0x04, 0xc8, }, 5, 0, "", "",
140+"f2 0f 1b 04 c8 \tbndcn (%eax,%ecx,8),%bnd0",},
141+{{0xf2, 0x0f, 0x1b, 0x40, 0x12, }, 5, 0, "", "",
142+"f2 0f 1b 40 12 \tbndcn 0x12(%eax),%bnd0",},
143+{{0xf2, 0x0f, 0x1b, 0x45, 0x12, }, 5, 0, "", "",
144+"f2 0f 1b 45 12 \tbndcn 0x12(%ebp),%bnd0",},
145+{{0xf2, 0x0f, 0x1b, 0x44, 0x01, 0x12, }, 6, 0, "", "",
146+"f2 0f 1b 44 01 12 \tbndcn 0x12(%ecx,%eax,1),%bnd0",},
147+{{0xf2, 0x0f, 0x1b, 0x44, 0x05, 0x12, }, 6, 0, "", "",
148+"f2 0f 1b 44 05 12 \tbndcn 0x12(%ebp,%eax,1),%bnd0",},
149+{{0xf2, 0x0f, 0x1b, 0x44, 0x08, 0x12, }, 6, 0, "", "",
150+"f2 0f 1b 44 08 12 \tbndcn 0x12(%eax,%ecx,1),%bnd0",},
151+{{0xf2, 0x0f, 0x1b, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
152+"f2 0f 1b 44 c8 12 \tbndcn 0x12(%eax,%ecx,8),%bnd0",},
153+{{0xf2, 0x0f, 0x1b, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
154+"f2 0f 1b 80 78 56 34 12 \tbndcn 0x12345678(%eax),%bnd0",},
155+{{0xf2, 0x0f, 0x1b, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
156+"f2 0f 1b 85 78 56 34 12 \tbndcn 0x12345678(%ebp),%bnd0",},
157+{{0xf2, 0x0f, 0x1b, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
158+"f2 0f 1b 84 01 78 56 34 12 \tbndcn 0x12345678(%ecx,%eax,1),%bnd0",},
159+{{0xf2, 0x0f, 0x1b, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
160+"f2 0f 1b 84 05 78 56 34 12 \tbndcn 0x12345678(%ebp,%eax,1),%bnd0",},
161+{{0xf2, 0x0f, 0x1b, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
162+"f2 0f 1b 84 08 78 56 34 12 \tbndcn 0x12345678(%eax,%ecx,1),%bnd0",},
163+{{0xf2, 0x0f, 0x1b, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
164+"f2 0f 1b 84 c8 78 56 34 12 \tbndcn 0x12345678(%eax,%ecx,8),%bnd0",},
165+{{0xf2, 0x0f, 0x1b, 0xc0, }, 4, 0, "", "",
166+"f2 0f 1b c0 \tbndcn %eax,%bnd0",},
167+{{0x66, 0x0f, 0x1a, 0x00, }, 4, 0, "", "",
168+"66 0f 1a 00 \tbndmov (%eax),%bnd0",},
169+{{0x66, 0x0f, 0x1a, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
170+"66 0f 1a 05 78 56 34 12 \tbndmov 0x12345678,%bnd0",},
171+{{0x66, 0x0f, 0x1a, 0x18, }, 4, 0, "", "",
172+"66 0f 1a 18 \tbndmov (%eax),%bnd3",},
173+{{0x66, 0x0f, 0x1a, 0x04, 0x01, }, 5, 0, "", "",
174+"66 0f 1a 04 01 \tbndmov (%ecx,%eax,1),%bnd0",},
175+{{0x66, 0x0f, 0x1a, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
176+"66 0f 1a 04 05 78 56 34 12 \tbndmov 0x12345678(,%eax,1),%bnd0",},
177+{{0x66, 0x0f, 0x1a, 0x04, 0x08, }, 5, 0, "", "",
178+"66 0f 1a 04 08 \tbndmov (%eax,%ecx,1),%bnd0",},
179+{{0x66, 0x0f, 0x1a, 0x04, 0xc8, }, 5, 0, "", "",
180+"66 0f 1a 04 c8 \tbndmov (%eax,%ecx,8),%bnd0",},
181+{{0x66, 0x0f, 0x1a, 0x40, 0x12, }, 5, 0, "", "",
182+"66 0f 1a 40 12 \tbndmov 0x12(%eax),%bnd0",},
183+{{0x66, 0x0f, 0x1a, 0x45, 0x12, }, 5, 0, "", "",
184+"66 0f 1a 45 12 \tbndmov 0x12(%ebp),%bnd0",},
185+{{0x66, 0x0f, 0x1a, 0x44, 0x01, 0x12, }, 6, 0, "", "",
186+"66 0f 1a 44 01 12 \tbndmov 0x12(%ecx,%eax,1),%bnd0",},
187+{{0x66, 0x0f, 0x1a, 0x44, 0x05, 0x12, }, 6, 0, "", "",
188+"66 0f 1a 44 05 12 \tbndmov 0x12(%ebp,%eax,1),%bnd0",},
189+{{0x66, 0x0f, 0x1a, 0x44, 0x08, 0x12, }, 6, 0, "", "",
190+"66 0f 1a 44 08 12 \tbndmov 0x12(%eax,%ecx,1),%bnd0",},
191+{{0x66, 0x0f, 0x1a, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
192+"66 0f 1a 44 c8 12 \tbndmov 0x12(%eax,%ecx,8),%bnd0",},
193+{{0x66, 0x0f, 0x1a, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
194+"66 0f 1a 80 78 56 34 12 \tbndmov 0x12345678(%eax),%bnd0",},
195+{{0x66, 0x0f, 0x1a, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
196+"66 0f 1a 85 78 56 34 12 \tbndmov 0x12345678(%ebp),%bnd0",},
197+{{0x66, 0x0f, 0x1a, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
198+"66 0f 1a 84 01 78 56 34 12 \tbndmov 0x12345678(%ecx,%eax,1),%bnd0",},
199+{{0x66, 0x0f, 0x1a, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
200+"66 0f 1a 84 05 78 56 34 12 \tbndmov 0x12345678(%ebp,%eax,1),%bnd0",},
201+{{0x66, 0x0f, 0x1a, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
202+"66 0f 1a 84 08 78 56 34 12 \tbndmov 0x12345678(%eax,%ecx,1),%bnd0",},
203+{{0x66, 0x0f, 0x1a, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
204+"66 0f 1a 84 c8 78 56 34 12 \tbndmov 0x12345678(%eax,%ecx,8),%bnd0",},
205+{{0x66, 0x0f, 0x1b, 0x00, }, 4, 0, "", "",
206+"66 0f 1b 00 \tbndmov %bnd0,(%eax)",},
207+{{0x66, 0x0f, 0x1b, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
208+"66 0f 1b 05 78 56 34 12 \tbndmov %bnd0,0x12345678",},
209+{{0x66, 0x0f, 0x1b, 0x18, }, 4, 0, "", "",
210+"66 0f 1b 18 \tbndmov %bnd3,(%eax)",},
211+{{0x66, 0x0f, 0x1b, 0x04, 0x01, }, 5, 0, "", "",
212+"66 0f 1b 04 01 \tbndmov %bnd0,(%ecx,%eax,1)",},
213+{{0x66, 0x0f, 0x1b, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
214+"66 0f 1b 04 05 78 56 34 12 \tbndmov %bnd0,0x12345678(,%eax,1)",},
215+{{0x66, 0x0f, 0x1b, 0x04, 0x08, }, 5, 0, "", "",
216+"66 0f 1b 04 08 \tbndmov %bnd0,(%eax,%ecx,1)",},
217+{{0x66, 0x0f, 0x1b, 0x04, 0xc8, }, 5, 0, "", "",
218+"66 0f 1b 04 c8 \tbndmov %bnd0,(%eax,%ecx,8)",},
219+{{0x66, 0x0f, 0x1b, 0x40, 0x12, }, 5, 0, "", "",
220+"66 0f 1b 40 12 \tbndmov %bnd0,0x12(%eax)",},
221+{{0x66, 0x0f, 0x1b, 0x45, 0x12, }, 5, 0, "", "",
222+"66 0f 1b 45 12 \tbndmov %bnd0,0x12(%ebp)",},
223+{{0x66, 0x0f, 0x1b, 0x44, 0x01, 0x12, }, 6, 0, "", "",
224+"66 0f 1b 44 01 12 \tbndmov %bnd0,0x12(%ecx,%eax,1)",},
225+{{0x66, 0x0f, 0x1b, 0x44, 0x05, 0x12, }, 6, 0, "", "",
226+"66 0f 1b 44 05 12 \tbndmov %bnd0,0x12(%ebp,%eax,1)",},
227+{{0x66, 0x0f, 0x1b, 0x44, 0x08, 0x12, }, 6, 0, "", "",
228+"66 0f 1b 44 08 12 \tbndmov %bnd0,0x12(%eax,%ecx,1)",},
229+{{0x66, 0x0f, 0x1b, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
230+"66 0f 1b 44 c8 12 \tbndmov %bnd0,0x12(%eax,%ecx,8)",},
231+{{0x66, 0x0f, 0x1b, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
232+"66 0f 1b 80 78 56 34 12 \tbndmov %bnd0,0x12345678(%eax)",},
233+{{0x66, 0x0f, 0x1b, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
234+"66 0f 1b 85 78 56 34 12 \tbndmov %bnd0,0x12345678(%ebp)",},
235+{{0x66, 0x0f, 0x1b, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
236+"66 0f 1b 84 01 78 56 34 12 \tbndmov %bnd0,0x12345678(%ecx,%eax,1)",},
237+{{0x66, 0x0f, 0x1b, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
238+"66 0f 1b 84 05 78 56 34 12 \tbndmov %bnd0,0x12345678(%ebp,%eax,1)",},
239+{{0x66, 0x0f, 0x1b, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
240+"66 0f 1b 84 08 78 56 34 12 \tbndmov %bnd0,0x12345678(%eax,%ecx,1)",},
241+{{0x66, 0x0f, 0x1b, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
242+"66 0f 1b 84 c8 78 56 34 12 \tbndmov %bnd0,0x12345678(%eax,%ecx,8)",},
243+{{0x66, 0x0f, 0x1a, 0xc8, }, 4, 0, "", "",
244+"66 0f 1a c8 \tbndmov %bnd0,%bnd1",},
245+{{0x66, 0x0f, 0x1a, 0xc1, }, 4, 0, "", "",
246+"66 0f 1a c1 \tbndmov %bnd1,%bnd0",},
247+{{0x0f, 0x1a, 0x00, }, 3, 0, "", "",
248+"0f 1a 00 \tbndldx (%eax),%bnd0",},
249+{{0x0f, 0x1a, 0x05, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
250+"0f 1a 05 78 56 34 12 \tbndldx 0x12345678,%bnd0",},
251+{{0x0f, 0x1a, 0x18, }, 3, 0, "", "",
252+"0f 1a 18 \tbndldx (%eax),%bnd3",},
253+{{0x0f, 0x1a, 0x04, 0x01, }, 4, 0, "", "",
254+"0f 1a 04 01 \tbndldx (%ecx,%eax,1),%bnd0",},
255+{{0x0f, 0x1a, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
256+"0f 1a 04 05 78 56 34 12 \tbndldx 0x12345678(,%eax,1),%bnd0",},
257+{{0x0f, 0x1a, 0x04, 0x08, }, 4, 0, "", "",
258+"0f 1a 04 08 \tbndldx (%eax,%ecx,1),%bnd0",},
259+{{0x0f, 0x1a, 0x40, 0x12, }, 4, 0, "", "",
260+"0f 1a 40 12 \tbndldx 0x12(%eax),%bnd0",},
261+{{0x0f, 0x1a, 0x45, 0x12, }, 4, 0, "", "",
262+"0f 1a 45 12 \tbndldx 0x12(%ebp),%bnd0",},
263+{{0x0f, 0x1a, 0x44, 0x01, 0x12, }, 5, 0, "", "",
264+"0f 1a 44 01 12 \tbndldx 0x12(%ecx,%eax,1),%bnd0",},
265+{{0x0f, 0x1a, 0x44, 0x05, 0x12, }, 5, 0, "", "",
266+"0f 1a 44 05 12 \tbndldx 0x12(%ebp,%eax,1),%bnd0",},
267+{{0x0f, 0x1a, 0x44, 0x08, 0x12, }, 5, 0, "", "",
268+"0f 1a 44 08 12 \tbndldx 0x12(%eax,%ecx,1),%bnd0",},
269+{{0x0f, 0x1a, 0x80, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
270+"0f 1a 80 78 56 34 12 \tbndldx 0x12345678(%eax),%bnd0",},
271+{{0x0f, 0x1a, 0x85, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
272+"0f 1a 85 78 56 34 12 \tbndldx 0x12345678(%ebp),%bnd0",},
273+{{0x0f, 0x1a, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
274+"0f 1a 84 01 78 56 34 12 \tbndldx 0x12345678(%ecx,%eax,1),%bnd0",},
275+{{0x0f, 0x1a, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
276+"0f 1a 84 05 78 56 34 12 \tbndldx 0x12345678(%ebp,%eax,1),%bnd0",},
277+{{0x0f, 0x1a, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
278+"0f 1a 84 08 78 56 34 12 \tbndldx 0x12345678(%eax,%ecx,1),%bnd0",},
279+{{0x0f, 0x1b, 0x00, }, 3, 0, "", "",
280+"0f 1b 00 \tbndstx %bnd0,(%eax)",},
281+{{0x0f, 0x1b, 0x05, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
282+"0f 1b 05 78 56 34 12 \tbndstx %bnd0,0x12345678",},
283+{{0x0f, 0x1b, 0x18, }, 3, 0, "", "",
284+"0f 1b 18 \tbndstx %bnd3,(%eax)",},
285+{{0x0f, 0x1b, 0x04, 0x01, }, 4, 0, "", "",
286+"0f 1b 04 01 \tbndstx %bnd0,(%ecx,%eax,1)",},
287+{{0x0f, 0x1b, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
288+"0f 1b 04 05 78 56 34 12 \tbndstx %bnd0,0x12345678(,%eax,1)",},
289+{{0x0f, 0x1b, 0x04, 0x08, }, 4, 0, "", "",
290+"0f 1b 04 08 \tbndstx %bnd0,(%eax,%ecx,1)",},
291+{{0x0f, 0x1b, 0x40, 0x12, }, 4, 0, "", "",
292+"0f 1b 40 12 \tbndstx %bnd0,0x12(%eax)",},
293+{{0x0f, 0x1b, 0x45, 0x12, }, 4, 0, "", "",
294+"0f 1b 45 12 \tbndstx %bnd0,0x12(%ebp)",},
295+{{0x0f, 0x1b, 0x44, 0x01, 0x12, }, 5, 0, "", "",
296+"0f 1b 44 01 12 \tbndstx %bnd0,0x12(%ecx,%eax,1)",},
297+{{0x0f, 0x1b, 0x44, 0x05, 0x12, }, 5, 0, "", "",
298+"0f 1b 44 05 12 \tbndstx %bnd0,0x12(%ebp,%eax,1)",},
299+{{0x0f, 0x1b, 0x44, 0x08, 0x12, }, 5, 0, "", "",
300+"0f 1b 44 08 12 \tbndstx %bnd0,0x12(%eax,%ecx,1)",},
301+{{0x0f, 0x1b, 0x80, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
302+"0f 1b 80 78 56 34 12 \tbndstx %bnd0,0x12345678(%eax)",},
303+{{0x0f, 0x1b, 0x85, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
304+"0f 1b 85 78 56 34 12 \tbndstx %bnd0,0x12345678(%ebp)",},
305+{{0x0f, 0x1b, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
306+"0f 1b 84 01 78 56 34 12 \tbndstx %bnd0,0x12345678(%ecx,%eax,1)",},
307+{{0x0f, 0x1b, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
308+"0f 1b 84 05 78 56 34 12 \tbndstx %bnd0,0x12345678(%ebp,%eax,1)",},
309+{{0x0f, 0x1b, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
310+"0f 1b 84 08 78 56 34 12 \tbndstx %bnd0,0x12345678(%eax,%ecx,1)",},
311+{{0xf2, 0xe8, 0xfc, 0xff, 0xff, 0xff, }, 6, 0xfffffffc, "call", "unconditional",
312+"f2 e8 fc ff ff ff \tbnd call 3c3 <main+0x3c3>",},
313+{{0xf2, 0xff, 0x10, }, 3, 0, "call", "indirect",
314+"f2 ff 10 \tbnd call *(%eax)",},
315+{{0xf2, 0xc3, }, 2, 0, "ret", "indirect",
316+"f2 c3 \tbnd ret ",},
317+{{0xf2, 0xe9, 0xfc, 0xff, 0xff, 0xff, }, 6, 0xfffffffc, "jmp", "unconditional",
318+"f2 e9 fc ff ff ff \tbnd jmp 3ce <main+0x3ce>",},
319+{{0xf2, 0xe9, 0xfc, 0xff, 0xff, 0xff, }, 6, 0xfffffffc, "jmp", "unconditional",
320+"f2 e9 fc ff ff ff \tbnd jmp 3d4 <main+0x3d4>",},
321+{{0xf2, 0xff, 0x21, }, 3, 0, "jmp", "indirect",
322+"f2 ff 21 \tbnd jmp *(%ecx)",},
323+{{0xf2, 0x0f, 0x85, 0xfc, 0xff, 0xff, 0xff, }, 7, 0xfffffffc, "jcc", "conditional",
324+"f2 0f 85 fc ff ff ff \tbnd jne 3de <main+0x3de>",},
325+{{0x0f, 0x3a, 0xcc, 0xc1, 0x00, }, 5, 0, "", "",
326+"0f 3a cc c1 00 \tsha1rnds4 $0x0,%xmm1,%xmm0",},
327+{{0x0f, 0x3a, 0xcc, 0xd7, 0x91, }, 5, 0, "", "",
328+"0f 3a cc d7 91 \tsha1rnds4 $0x91,%xmm7,%xmm2",},
329+{{0x0f, 0x3a, 0xcc, 0x00, 0x91, }, 5, 0, "", "",
330+"0f 3a cc 00 91 \tsha1rnds4 $0x91,(%eax),%xmm0",},
331+{{0x0f, 0x3a, 0xcc, 0x05, 0x78, 0x56, 0x34, 0x12, 0x91, }, 9, 0, "", "",
332+"0f 3a cc 05 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678,%xmm0",},
333+{{0x0f, 0x3a, 0xcc, 0x18, 0x91, }, 5, 0, "", "",
334+"0f 3a cc 18 91 \tsha1rnds4 $0x91,(%eax),%xmm3",},
335+{{0x0f, 0x3a, 0xcc, 0x04, 0x01, 0x91, }, 6, 0, "", "",
336+"0f 3a cc 04 01 91 \tsha1rnds4 $0x91,(%ecx,%eax,1),%xmm0",},
337+{{0x0f, 0x3a, 0xcc, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, 0x91, }, 10, 0, "", "",
338+"0f 3a cc 04 05 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(,%eax,1),%xmm0",},
339+{{0x0f, 0x3a, 0xcc, 0x04, 0x08, 0x91, }, 6, 0, "", "",
340+"0f 3a cc 04 08 91 \tsha1rnds4 $0x91,(%eax,%ecx,1),%xmm0",},
341+{{0x0f, 0x3a, 0xcc, 0x04, 0xc8, 0x91, }, 6, 0, "", "",
342+"0f 3a cc 04 c8 91 \tsha1rnds4 $0x91,(%eax,%ecx,8),%xmm0",},
343+{{0x0f, 0x3a, 0xcc, 0x40, 0x12, 0x91, }, 6, 0, "", "",
344+"0f 3a cc 40 12 91 \tsha1rnds4 $0x91,0x12(%eax),%xmm0",},
345+{{0x0f, 0x3a, 0xcc, 0x45, 0x12, 0x91, }, 6, 0, "", "",
346+"0f 3a cc 45 12 91 \tsha1rnds4 $0x91,0x12(%ebp),%xmm0",},
347+{{0x0f, 0x3a, 0xcc, 0x44, 0x01, 0x12, 0x91, }, 7, 0, "", "",
348+"0f 3a cc 44 01 12 91 \tsha1rnds4 $0x91,0x12(%ecx,%eax,1),%xmm0",},
349+{{0x0f, 0x3a, 0xcc, 0x44, 0x05, 0x12, 0x91, }, 7, 0, "", "",
350+"0f 3a cc 44 05 12 91 \tsha1rnds4 $0x91,0x12(%ebp,%eax,1),%xmm0",},
351+{{0x0f, 0x3a, 0xcc, 0x44, 0x08, 0x12, 0x91, }, 7, 0, "", "",
352+"0f 3a cc 44 08 12 91 \tsha1rnds4 $0x91,0x12(%eax,%ecx,1),%xmm0",},
353+{{0x0f, 0x3a, 0xcc, 0x44, 0xc8, 0x12, 0x91, }, 7, 0, "", "",
354+"0f 3a cc 44 c8 12 91 \tsha1rnds4 $0x91,0x12(%eax,%ecx,8),%xmm0",},
355+{{0x0f, 0x3a, 0xcc, 0x80, 0x78, 0x56, 0x34, 0x12, 0x91, }, 9, 0, "", "",
356+"0f 3a cc 80 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%eax),%xmm0",},
357+{{0x0f, 0x3a, 0xcc, 0x85, 0x78, 0x56, 0x34, 0x12, 0x91, }, 9, 0, "", "",
358+"0f 3a cc 85 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%ebp),%xmm0",},
359+{{0x0f, 0x3a, 0xcc, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, 0x91, }, 10, 0, "", "",
360+"0f 3a cc 84 01 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%ecx,%eax,1),%xmm0",},
361+{{0x0f, 0x3a, 0xcc, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, 0x91, }, 10, 0, "", "",
362+"0f 3a cc 84 05 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%ebp,%eax,1),%xmm0",},
363+{{0x0f, 0x3a, 0xcc, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, 0x91, }, 10, 0, "", "",
364+"0f 3a cc 84 08 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%eax,%ecx,1),%xmm0",},
365+{{0x0f, 0x3a, 0xcc, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, 0x91, }, 10, 0, "", "",
366+"0f 3a cc 84 c8 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%eax,%ecx,8),%xmm0",},
367+{{0x0f, 0x38, 0xc8, 0xc1, }, 4, 0, "", "",
368+"0f 38 c8 c1 \tsha1nexte %xmm1,%xmm0",},
369+{{0x0f, 0x38, 0xc8, 0xd7, }, 4, 0, "", "",
370+"0f 38 c8 d7 \tsha1nexte %xmm7,%xmm2",},
371+{{0x0f, 0x38, 0xc8, 0x00, }, 4, 0, "", "",
372+"0f 38 c8 00 \tsha1nexte (%eax),%xmm0",},
373+{{0x0f, 0x38, 0xc8, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
374+"0f 38 c8 05 78 56 34 12 \tsha1nexte 0x12345678,%xmm0",},
375+{{0x0f, 0x38, 0xc8, 0x18, }, 4, 0, "", "",
376+"0f 38 c8 18 \tsha1nexte (%eax),%xmm3",},
377+{{0x0f, 0x38, 0xc8, 0x04, 0x01, }, 5, 0, "", "",
378+"0f 38 c8 04 01 \tsha1nexte (%ecx,%eax,1),%xmm0",},
379+{{0x0f, 0x38, 0xc8, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
380+"0f 38 c8 04 05 78 56 34 12 \tsha1nexte 0x12345678(,%eax,1),%xmm0",},
381+{{0x0f, 0x38, 0xc8, 0x04, 0x08, }, 5, 0, "", "",
382+"0f 38 c8 04 08 \tsha1nexte (%eax,%ecx,1),%xmm0",},
383+{{0x0f, 0x38, 0xc8, 0x04, 0xc8, }, 5, 0, "", "",
384+"0f 38 c8 04 c8 \tsha1nexte (%eax,%ecx,8),%xmm0",},
385+{{0x0f, 0x38, 0xc8, 0x40, 0x12, }, 5, 0, "", "",
386+"0f 38 c8 40 12 \tsha1nexte 0x12(%eax),%xmm0",},
387+{{0x0f, 0x38, 0xc8, 0x45, 0x12, }, 5, 0, "", "",
388+"0f 38 c8 45 12 \tsha1nexte 0x12(%ebp),%xmm0",},
389+{{0x0f, 0x38, 0xc8, 0x44, 0x01, 0x12, }, 6, 0, "", "",
390+"0f 38 c8 44 01 12 \tsha1nexte 0x12(%ecx,%eax,1),%xmm0",},
391+{{0x0f, 0x38, 0xc8, 0x44, 0x05, 0x12, }, 6, 0, "", "",
392+"0f 38 c8 44 05 12 \tsha1nexte 0x12(%ebp,%eax,1),%xmm0",},
393+{{0x0f, 0x38, 0xc8, 0x44, 0x08, 0x12, }, 6, 0, "", "",
394+"0f 38 c8 44 08 12 \tsha1nexte 0x12(%eax,%ecx,1),%xmm0",},
395+{{0x0f, 0x38, 0xc8, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
396+"0f 38 c8 44 c8 12 \tsha1nexte 0x12(%eax,%ecx,8),%xmm0",},
397+{{0x0f, 0x38, 0xc8, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
398+"0f 38 c8 80 78 56 34 12 \tsha1nexte 0x12345678(%eax),%xmm0",},
399+{{0x0f, 0x38, 0xc8, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
400+"0f 38 c8 85 78 56 34 12 \tsha1nexte 0x12345678(%ebp),%xmm0",},
401+{{0x0f, 0x38, 0xc8, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
402+"0f 38 c8 84 01 78 56 34 12 \tsha1nexte 0x12345678(%ecx,%eax,1),%xmm0",},
403+{{0x0f, 0x38, 0xc8, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
404+"0f 38 c8 84 05 78 56 34 12 \tsha1nexte 0x12345678(%ebp,%eax,1),%xmm0",},
405+{{0x0f, 0x38, 0xc8, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
406+"0f 38 c8 84 08 78 56 34 12 \tsha1nexte 0x12345678(%eax,%ecx,1),%xmm0",},
407+{{0x0f, 0x38, 0xc8, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
408+"0f 38 c8 84 c8 78 56 34 12 \tsha1nexte 0x12345678(%eax,%ecx,8),%xmm0",},
409+{{0x0f, 0x38, 0xc9, 0xc1, }, 4, 0, "", "",
410+"0f 38 c9 c1 \tsha1msg1 %xmm1,%xmm0",},
411+{{0x0f, 0x38, 0xc9, 0xd7, }, 4, 0, "", "",
412+"0f 38 c9 d7 \tsha1msg1 %xmm7,%xmm2",},
413+{{0x0f, 0x38, 0xc9, 0x00, }, 4, 0, "", "",
414+"0f 38 c9 00 \tsha1msg1 (%eax),%xmm0",},
415+{{0x0f, 0x38, 0xc9, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
416+"0f 38 c9 05 78 56 34 12 \tsha1msg1 0x12345678,%xmm0",},
417+{{0x0f, 0x38, 0xc9, 0x18, }, 4, 0, "", "",
418+"0f 38 c9 18 \tsha1msg1 (%eax),%xmm3",},
419+{{0x0f, 0x38, 0xc9, 0x04, 0x01, }, 5, 0, "", "",
420+"0f 38 c9 04 01 \tsha1msg1 (%ecx,%eax,1),%xmm0",},
421+{{0x0f, 0x38, 0xc9, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
422+"0f 38 c9 04 05 78 56 34 12 \tsha1msg1 0x12345678(,%eax,1),%xmm0",},
423+{{0x0f, 0x38, 0xc9, 0x04, 0x08, }, 5, 0, "", "",
424+"0f 38 c9 04 08 \tsha1msg1 (%eax,%ecx,1),%xmm0",},
425+{{0x0f, 0x38, 0xc9, 0x04, 0xc8, }, 5, 0, "", "",
426+"0f 38 c9 04 c8 \tsha1msg1 (%eax,%ecx,8),%xmm0",},
427+{{0x0f, 0x38, 0xc9, 0x40, 0x12, }, 5, 0, "", "",
428+"0f 38 c9 40 12 \tsha1msg1 0x12(%eax),%xmm0",},
429+{{0x0f, 0x38, 0xc9, 0x45, 0x12, }, 5, 0, "", "",
430+"0f 38 c9 45 12 \tsha1msg1 0x12(%ebp),%xmm0",},
431+{{0x0f, 0x38, 0xc9, 0x44, 0x01, 0x12, }, 6, 0, "", "",
432+"0f 38 c9 44 01 12 \tsha1msg1 0x12(%ecx,%eax,1),%xmm0",},
433+{{0x0f, 0x38, 0xc9, 0x44, 0x05, 0x12, }, 6, 0, "", "",
434+"0f 38 c9 44 05 12 \tsha1msg1 0x12(%ebp,%eax,1),%xmm0",},
435+{{0x0f, 0x38, 0xc9, 0x44, 0x08, 0x12, }, 6, 0, "", "",
436+"0f 38 c9 44 08 12 \tsha1msg1 0x12(%eax,%ecx,1),%xmm0",},
437+{{0x0f, 0x38, 0xc9, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
438+"0f 38 c9 44 c8 12 \tsha1msg1 0x12(%eax,%ecx,8),%xmm0",},
439+{{0x0f, 0x38, 0xc9, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
440+"0f 38 c9 80 78 56 34 12 \tsha1msg1 0x12345678(%eax),%xmm0",},
441+{{0x0f, 0x38, 0xc9, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
442+"0f 38 c9 85 78 56 34 12 \tsha1msg1 0x12345678(%ebp),%xmm0",},
443+{{0x0f, 0x38, 0xc9, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
444+"0f 38 c9 84 01 78 56 34 12 \tsha1msg1 0x12345678(%ecx,%eax,1),%xmm0",},
445+{{0x0f, 0x38, 0xc9, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
446+"0f 38 c9 84 05 78 56 34 12 \tsha1msg1 0x12345678(%ebp,%eax,1),%xmm0",},
447+{{0x0f, 0x38, 0xc9, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
448+"0f 38 c9 84 08 78 56 34 12 \tsha1msg1 0x12345678(%eax,%ecx,1),%xmm0",},
449+{{0x0f, 0x38, 0xc9, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
450+"0f 38 c9 84 c8 78 56 34 12 \tsha1msg1 0x12345678(%eax,%ecx,8),%xmm0",},
451+{{0x0f, 0x38, 0xca, 0xc1, }, 4, 0, "", "",
452+"0f 38 ca c1 \tsha1msg2 %xmm1,%xmm0",},
453+{{0x0f, 0x38, 0xca, 0xd7, }, 4, 0, "", "",
454+"0f 38 ca d7 \tsha1msg2 %xmm7,%xmm2",},
455+{{0x0f, 0x38, 0xca, 0x00, }, 4, 0, "", "",
456+"0f 38 ca 00 \tsha1msg2 (%eax),%xmm0",},
457+{{0x0f, 0x38, 0xca, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
458+"0f 38 ca 05 78 56 34 12 \tsha1msg2 0x12345678,%xmm0",},
459+{{0x0f, 0x38, 0xca, 0x18, }, 4, 0, "", "",
460+"0f 38 ca 18 \tsha1msg2 (%eax),%xmm3",},
461+{{0x0f, 0x38, 0xca, 0x04, 0x01, }, 5, 0, "", "",
462+"0f 38 ca 04 01 \tsha1msg2 (%ecx,%eax,1),%xmm0",},
463+{{0x0f, 0x38, 0xca, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
464+"0f 38 ca 04 05 78 56 34 12 \tsha1msg2 0x12345678(,%eax,1),%xmm0",},
465+{{0x0f, 0x38, 0xca, 0x04, 0x08, }, 5, 0, "", "",
466+"0f 38 ca 04 08 \tsha1msg2 (%eax,%ecx,1),%xmm0",},
467+{{0x0f, 0x38, 0xca, 0x04, 0xc8, }, 5, 0, "", "",
468+"0f 38 ca 04 c8 \tsha1msg2 (%eax,%ecx,8),%xmm0",},
469+{{0x0f, 0x38, 0xca, 0x40, 0x12, }, 5, 0, "", "",
470+"0f 38 ca 40 12 \tsha1msg2 0x12(%eax),%xmm0",},
471+{{0x0f, 0x38, 0xca, 0x45, 0x12, }, 5, 0, "", "",
472+"0f 38 ca 45 12 \tsha1msg2 0x12(%ebp),%xmm0",},
473+{{0x0f, 0x38, 0xca, 0x44, 0x01, 0x12, }, 6, 0, "", "",
474+"0f 38 ca 44 01 12 \tsha1msg2 0x12(%ecx,%eax,1),%xmm0",},
475+{{0x0f, 0x38, 0xca, 0x44, 0x05, 0x12, }, 6, 0, "", "",
476+"0f 38 ca 44 05 12 \tsha1msg2 0x12(%ebp,%eax,1),%xmm0",},
477+{{0x0f, 0x38, 0xca, 0x44, 0x08, 0x12, }, 6, 0, "", "",
478+"0f 38 ca 44 08 12 \tsha1msg2 0x12(%eax,%ecx,1),%xmm0",},
479+{{0x0f, 0x38, 0xca, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
480+"0f 38 ca 44 c8 12 \tsha1msg2 0x12(%eax,%ecx,8),%xmm0",},
481+{{0x0f, 0x38, 0xca, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
482+"0f 38 ca 80 78 56 34 12 \tsha1msg2 0x12345678(%eax),%xmm0",},
483+{{0x0f, 0x38, 0xca, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
484+"0f 38 ca 85 78 56 34 12 \tsha1msg2 0x12345678(%ebp),%xmm0",},
485+{{0x0f, 0x38, 0xca, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
486+"0f 38 ca 84 01 78 56 34 12 \tsha1msg2 0x12345678(%ecx,%eax,1),%xmm0",},
487+{{0x0f, 0x38, 0xca, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
488+"0f 38 ca 84 05 78 56 34 12 \tsha1msg2 0x12345678(%ebp,%eax,1),%xmm0",},
489+{{0x0f, 0x38, 0xca, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
490+"0f 38 ca 84 08 78 56 34 12 \tsha1msg2 0x12345678(%eax,%ecx,1),%xmm0",},
491+{{0x0f, 0x38, 0xca, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
492+"0f 38 ca 84 c8 78 56 34 12 \tsha1msg2 0x12345678(%eax,%ecx,8),%xmm0",},
493+{{0x0f, 0x38, 0xcb, 0xcc, }, 4, 0, "", "",
494+"0f 38 cb cc \tsha256rnds2 %xmm0,%xmm4,%xmm1",},
495+{{0x0f, 0x38, 0xcb, 0xd7, }, 4, 0, "", "",
496+"0f 38 cb d7 \tsha256rnds2 %xmm0,%xmm7,%xmm2",},
497+{{0x0f, 0x38, 0xcb, 0x08, }, 4, 0, "", "",
498+"0f 38 cb 08 \tsha256rnds2 %xmm0,(%eax),%xmm1",},
499+{{0x0f, 0x38, 0xcb, 0x0d, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
500+"0f 38 cb 0d 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678,%xmm1",},
501+{{0x0f, 0x38, 0xcb, 0x18, }, 4, 0, "", "",
502+"0f 38 cb 18 \tsha256rnds2 %xmm0,(%eax),%xmm3",},
503+{{0x0f, 0x38, 0xcb, 0x0c, 0x01, }, 5, 0, "", "",
504+"0f 38 cb 0c 01 \tsha256rnds2 %xmm0,(%ecx,%eax,1),%xmm1",},
505+{{0x0f, 0x38, 0xcb, 0x0c, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
506+"0f 38 cb 0c 05 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(,%eax,1),%xmm1",},
507+{{0x0f, 0x38, 0xcb, 0x0c, 0x08, }, 5, 0, "", "",
508+"0f 38 cb 0c 08 \tsha256rnds2 %xmm0,(%eax,%ecx,1),%xmm1",},
509+{{0x0f, 0x38, 0xcb, 0x0c, 0xc8, }, 5, 0, "", "",
510+"0f 38 cb 0c c8 \tsha256rnds2 %xmm0,(%eax,%ecx,8),%xmm1",},
511+{{0x0f, 0x38, 0xcb, 0x48, 0x12, }, 5, 0, "", "",
512+"0f 38 cb 48 12 \tsha256rnds2 %xmm0,0x12(%eax),%xmm1",},
513+{{0x0f, 0x38, 0xcb, 0x4d, 0x12, }, 5, 0, "", "",
514+"0f 38 cb 4d 12 \tsha256rnds2 %xmm0,0x12(%ebp),%xmm1",},
515+{{0x0f, 0x38, 0xcb, 0x4c, 0x01, 0x12, }, 6, 0, "", "",
516+"0f 38 cb 4c 01 12 \tsha256rnds2 %xmm0,0x12(%ecx,%eax,1),%xmm1",},
517+{{0x0f, 0x38, 0xcb, 0x4c, 0x05, 0x12, }, 6, 0, "", "",
518+"0f 38 cb 4c 05 12 \tsha256rnds2 %xmm0,0x12(%ebp,%eax,1),%xmm1",},
519+{{0x0f, 0x38, 0xcb, 0x4c, 0x08, 0x12, }, 6, 0, "", "",
520+"0f 38 cb 4c 08 12 \tsha256rnds2 %xmm0,0x12(%eax,%ecx,1),%xmm1",},
521+{{0x0f, 0x38, 0xcb, 0x4c, 0xc8, 0x12, }, 6, 0, "", "",
522+"0f 38 cb 4c c8 12 \tsha256rnds2 %xmm0,0x12(%eax,%ecx,8),%xmm1",},
523+{{0x0f, 0x38, 0xcb, 0x88, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
524+"0f 38 cb 88 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%eax),%xmm1",},
525+{{0x0f, 0x38, 0xcb, 0x8d, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
526+"0f 38 cb 8d 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%ebp),%xmm1",},
527+{{0x0f, 0x38, 0xcb, 0x8c, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
528+"0f 38 cb 8c 01 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%ecx,%eax,1),%xmm1",},
529+{{0x0f, 0x38, 0xcb, 0x8c, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
530+"0f 38 cb 8c 05 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%ebp,%eax,1),%xmm1",},
531+{{0x0f, 0x38, 0xcb, 0x8c, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
532+"0f 38 cb 8c 08 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%eax,%ecx,1),%xmm1",},
533+{{0x0f, 0x38, 0xcb, 0x8c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
534+"0f 38 cb 8c c8 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%eax,%ecx,8),%xmm1",},
535+{{0x0f, 0x38, 0xcc, 0xc1, }, 4, 0, "", "",
536+"0f 38 cc c1 \tsha256msg1 %xmm1,%xmm0",},
537+{{0x0f, 0x38, 0xcc, 0xd7, }, 4, 0, "", "",
538+"0f 38 cc d7 \tsha256msg1 %xmm7,%xmm2",},
539+{{0x0f, 0x38, 0xcc, 0x00, }, 4, 0, "", "",
540+"0f 38 cc 00 \tsha256msg1 (%eax),%xmm0",},
541+{{0x0f, 0x38, 0xcc, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
542+"0f 38 cc 05 78 56 34 12 \tsha256msg1 0x12345678,%xmm0",},
543+{{0x0f, 0x38, 0xcc, 0x18, }, 4, 0, "", "",
544+"0f 38 cc 18 \tsha256msg1 (%eax),%xmm3",},
545+{{0x0f, 0x38, 0xcc, 0x04, 0x01, }, 5, 0, "", "",
546+"0f 38 cc 04 01 \tsha256msg1 (%ecx,%eax,1),%xmm0",},
547+{{0x0f, 0x38, 0xcc, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
548+"0f 38 cc 04 05 78 56 34 12 \tsha256msg1 0x12345678(,%eax,1),%xmm0",},
549+{{0x0f, 0x38, 0xcc, 0x04, 0x08, }, 5, 0, "", "",
550+"0f 38 cc 04 08 \tsha256msg1 (%eax,%ecx,1),%xmm0",},
551+{{0x0f, 0x38, 0xcc, 0x04, 0xc8, }, 5, 0, "", "",
552+"0f 38 cc 04 c8 \tsha256msg1 (%eax,%ecx,8),%xmm0",},
553+{{0x0f, 0x38, 0xcc, 0x40, 0x12, }, 5, 0, "", "",
554+"0f 38 cc 40 12 \tsha256msg1 0x12(%eax),%xmm0",},
555+{{0x0f, 0x38, 0xcc, 0x45, 0x12, }, 5, 0, "", "",
556+"0f 38 cc 45 12 \tsha256msg1 0x12(%ebp),%xmm0",},
557+{{0x0f, 0x38, 0xcc, 0x44, 0x01, 0x12, }, 6, 0, "", "",
558+"0f 38 cc 44 01 12 \tsha256msg1 0x12(%ecx,%eax,1),%xmm0",},
559+{{0x0f, 0x38, 0xcc, 0x44, 0x05, 0x12, }, 6, 0, "", "",
560+"0f 38 cc 44 05 12 \tsha256msg1 0x12(%ebp,%eax,1),%xmm0",},
561+{{0x0f, 0x38, 0xcc, 0x44, 0x08, 0x12, }, 6, 0, "", "",
562+"0f 38 cc 44 08 12 \tsha256msg1 0x12(%eax,%ecx,1),%xmm0",},
563+{{0x0f, 0x38, 0xcc, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
564+"0f 38 cc 44 c8 12 \tsha256msg1 0x12(%eax,%ecx,8),%xmm0",},
565+{{0x0f, 0x38, 0xcc, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
566+"0f 38 cc 80 78 56 34 12 \tsha256msg1 0x12345678(%eax),%xmm0",},
567+{{0x0f, 0x38, 0xcc, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
568+"0f 38 cc 85 78 56 34 12 \tsha256msg1 0x12345678(%ebp),%xmm0",},
569+{{0x0f, 0x38, 0xcc, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
570+"0f 38 cc 84 01 78 56 34 12 \tsha256msg1 0x12345678(%ecx,%eax,1),%xmm0",},
571+{{0x0f, 0x38, 0xcc, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
572+"0f 38 cc 84 05 78 56 34 12 \tsha256msg1 0x12345678(%ebp,%eax,1),%xmm0",},
573+{{0x0f, 0x38, 0xcc, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
574+"0f 38 cc 84 08 78 56 34 12 \tsha256msg1 0x12345678(%eax,%ecx,1),%xmm0",},
575+{{0x0f, 0x38, 0xcc, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
576+"0f 38 cc 84 c8 78 56 34 12 \tsha256msg1 0x12345678(%eax,%ecx,8),%xmm0",},
577+{{0x0f, 0x38, 0xcd, 0xc1, }, 4, 0, "", "",
578+"0f 38 cd c1 \tsha256msg2 %xmm1,%xmm0",},
579+{{0x0f, 0x38, 0xcd, 0xd7, }, 4, 0, "", "",
580+"0f 38 cd d7 \tsha256msg2 %xmm7,%xmm2",},
581+{{0x0f, 0x38, 0xcd, 0x00, }, 4, 0, "", "",
582+"0f 38 cd 00 \tsha256msg2 (%eax),%xmm0",},
583+{{0x0f, 0x38, 0xcd, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
584+"0f 38 cd 05 78 56 34 12 \tsha256msg2 0x12345678,%xmm0",},
585+{{0x0f, 0x38, 0xcd, 0x18, }, 4, 0, "", "",
586+"0f 38 cd 18 \tsha256msg2 (%eax),%xmm3",},
587+{{0x0f, 0x38, 0xcd, 0x04, 0x01, }, 5, 0, "", "",
588+"0f 38 cd 04 01 \tsha256msg2 (%ecx,%eax,1),%xmm0",},
589+{{0x0f, 0x38, 0xcd, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
590+"0f 38 cd 04 05 78 56 34 12 \tsha256msg2 0x12345678(,%eax,1),%xmm0",},
591+{{0x0f, 0x38, 0xcd, 0x04, 0x08, }, 5, 0, "", "",
592+"0f 38 cd 04 08 \tsha256msg2 (%eax,%ecx,1),%xmm0",},
593+{{0x0f, 0x38, 0xcd, 0x04, 0xc8, }, 5, 0, "", "",
594+"0f 38 cd 04 c8 \tsha256msg2 (%eax,%ecx,8),%xmm0",},
595+{{0x0f, 0x38, 0xcd, 0x40, 0x12, }, 5, 0, "", "",
596+"0f 38 cd 40 12 \tsha256msg2 0x12(%eax),%xmm0",},
597+{{0x0f, 0x38, 0xcd, 0x45, 0x12, }, 5, 0, "", "",
598+"0f 38 cd 45 12 \tsha256msg2 0x12(%ebp),%xmm0",},
599+{{0x0f, 0x38, 0xcd, 0x44, 0x01, 0x12, }, 6, 0, "", "",
600+"0f 38 cd 44 01 12 \tsha256msg2 0x12(%ecx,%eax,1),%xmm0",},
601+{{0x0f, 0x38, 0xcd, 0x44, 0x05, 0x12, }, 6, 0, "", "",
602+"0f 38 cd 44 05 12 \tsha256msg2 0x12(%ebp,%eax,1),%xmm0",},
603+{{0x0f, 0x38, 0xcd, 0x44, 0x08, 0x12, }, 6, 0, "", "",
604+"0f 38 cd 44 08 12 \tsha256msg2 0x12(%eax,%ecx,1),%xmm0",},
605+{{0x0f, 0x38, 0xcd, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
606+"0f 38 cd 44 c8 12 \tsha256msg2 0x12(%eax,%ecx,8),%xmm0",},
607+{{0x0f, 0x38, 0xcd, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
608+"0f 38 cd 80 78 56 34 12 \tsha256msg2 0x12345678(%eax),%xmm0",},
609+{{0x0f, 0x38, 0xcd, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
610+"0f 38 cd 85 78 56 34 12 \tsha256msg2 0x12345678(%ebp),%xmm0",},
611+{{0x0f, 0x38, 0xcd, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
612+"0f 38 cd 84 01 78 56 34 12 \tsha256msg2 0x12345678(%ecx,%eax,1),%xmm0",},
613+{{0x0f, 0x38, 0xcd, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
614+"0f 38 cd 84 05 78 56 34 12 \tsha256msg2 0x12345678(%ebp,%eax,1),%xmm0",},
615+{{0x0f, 0x38, 0xcd, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
616+"0f 38 cd 84 08 78 56 34 12 \tsha256msg2 0x12345678(%eax,%ecx,1),%xmm0",},
617+{{0x0f, 0x38, 0xcd, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
618+"0f 38 cd 84 c8 78 56 34 12 \tsha256msg2 0x12345678(%eax,%ecx,8),%xmm0",},
619+{{0x66, 0x0f, 0xae, 0x38, }, 4, 0, "", "",
620+"66 0f ae 38 \tclflushopt (%eax)",},
621+{{0x66, 0x0f, 0xae, 0x3d, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
622+"66 0f ae 3d 78 56 34 12 \tclflushopt 0x12345678",},
623+{{0x66, 0x0f, 0xae, 0xbc, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
624+"66 0f ae bc c8 78 56 34 12 \tclflushopt 0x12345678(%eax,%ecx,8)",},
625+{{0x0f, 0xae, 0x38, }, 3, 0, "", "",
626+"0f ae 38 \tclflush (%eax)",},
627+{{0x0f, 0xae, 0xf8, }, 3, 0, "", "",
628+"0f ae f8 \tsfence ",},
629+{{0x66, 0x0f, 0xae, 0x30, }, 4, 0, "", "",
630+"66 0f ae 30 \tclwb (%eax)",},
631+{{0x66, 0x0f, 0xae, 0x35, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
632+"66 0f ae 35 78 56 34 12 \tclwb 0x12345678",},
633+{{0x66, 0x0f, 0xae, 0xb4, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
634+"66 0f ae b4 c8 78 56 34 12 \tclwb 0x12345678(%eax,%ecx,8)",},
635+{{0x0f, 0xae, 0x30, }, 3, 0, "", "",
636+"0f ae 30 \txsaveopt (%eax)",},
637+{{0x0f, 0xae, 0xf0, }, 3, 0, "", "",
638+"0f ae f0 \tmfence ",},
639+{{0x0f, 0xc7, 0x20, }, 3, 0, "", "",
640+"0f c7 20 \txsavec (%eax)",},
641+{{0x0f, 0xc7, 0x25, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
642+"0f c7 25 78 56 34 12 \txsavec 0x12345678",},
643+{{0x0f, 0xc7, 0xa4, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
644+"0f c7 a4 c8 78 56 34 12 \txsavec 0x12345678(%eax,%ecx,8)",},
645+{{0x0f, 0xc7, 0x28, }, 3, 0, "", "",
646+"0f c7 28 \txsaves (%eax)",},
647+{{0x0f, 0xc7, 0x2d, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
648+"0f c7 2d 78 56 34 12 \txsaves 0x12345678",},
649+{{0x0f, 0xc7, 0xac, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
650+"0f c7 ac c8 78 56 34 12 \txsaves 0x12345678(%eax,%ecx,8)",},
651+{{0x0f, 0xc7, 0x18, }, 3, 0, "", "",
652+"0f c7 18 \txrstors (%eax)",},
653+{{0x0f, 0xc7, 0x1d, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
654+"0f c7 1d 78 56 34 12 \txrstors 0x12345678",},
655+{{0x0f, 0xc7, 0x9c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
656+"0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%eax,%ecx,8)",},
657+{{0x66, 0x0f, 0xae, 0xf8, }, 4, 0, "", "",
658+"66 0f ae f8 \tpcommit ",},
tools/perf/arch/x86/tests/insn-x86-dat-64.c+768−0
@@ -0,0 +1,768 @@
1+/*
2+ * Generated by gen-insn-x86-dat.sh and gen-insn-x86-dat.awk
3+ * from insn-x86-dat-src.c for inclusion by insn-x86.c
4+ * Do not change this code.
5+*/
6+
7+{{0x0f, 0x31, }, 2, 0, "", "",
8+"0f 31 \trdtsc ",},
9+{{0xf3, 0x0f, 0x1b, 0x00, }, 4, 0, "", "",
10+"f3 0f 1b 00 \tbndmk (%rax),%bnd0",},
11+{{0xf3, 0x41, 0x0f, 0x1b, 0x00, }, 5, 0, "", "",
12+"f3 41 0f 1b 00 \tbndmk (%r8),%bnd0",},
13+{{0xf3, 0x0f, 0x1b, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
14+"f3 0f 1b 04 25 78 56 34 12 \tbndmk 0x12345678,%bnd0",},
15+{{0xf3, 0x0f, 0x1b, 0x18, }, 4, 0, "", "",
16+"f3 0f 1b 18 \tbndmk (%rax),%bnd3",},
17+{{0xf3, 0x0f, 0x1b, 0x04, 0x01, }, 5, 0, "", "",
18+"f3 0f 1b 04 01 \tbndmk (%rcx,%rax,1),%bnd0",},
19+{{0xf3, 0x0f, 0x1b, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
20+"f3 0f 1b 04 05 78 56 34 12 \tbndmk 0x12345678(,%rax,1),%bnd0",},
21+{{0xf3, 0x0f, 0x1b, 0x04, 0x08, }, 5, 0, "", "",
22+"f3 0f 1b 04 08 \tbndmk (%rax,%rcx,1),%bnd0",},
23+{{0xf3, 0x0f, 0x1b, 0x04, 0xc8, }, 5, 0, "", "",
24+"f3 0f 1b 04 c8 \tbndmk (%rax,%rcx,8),%bnd0",},
25+{{0xf3, 0x0f, 0x1b, 0x40, 0x12, }, 5, 0, "", "",
26+"f3 0f 1b 40 12 \tbndmk 0x12(%rax),%bnd0",},
27+{{0xf3, 0x0f, 0x1b, 0x45, 0x12, }, 5, 0, "", "",
28+"f3 0f 1b 45 12 \tbndmk 0x12(%rbp),%bnd0",},
29+{{0xf3, 0x0f, 0x1b, 0x44, 0x01, 0x12, }, 6, 0, "", "",
30+"f3 0f 1b 44 01 12 \tbndmk 0x12(%rcx,%rax,1),%bnd0",},
31+{{0xf3, 0x0f, 0x1b, 0x44, 0x05, 0x12, }, 6, 0, "", "",
32+"f3 0f 1b 44 05 12 \tbndmk 0x12(%rbp,%rax,1),%bnd0",},
33+{{0xf3, 0x0f, 0x1b, 0x44, 0x08, 0x12, }, 6, 0, "", "",
34+"f3 0f 1b 44 08 12 \tbndmk 0x12(%rax,%rcx,1),%bnd0",},
35+{{0xf3, 0x0f, 0x1b, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
36+"f3 0f 1b 44 c8 12 \tbndmk 0x12(%rax,%rcx,8),%bnd0",},
37+{{0xf3, 0x0f, 0x1b, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
38+"f3 0f 1b 80 78 56 34 12 \tbndmk 0x12345678(%rax),%bnd0",},
39+{{0xf3, 0x0f, 0x1b, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
40+"f3 0f 1b 85 78 56 34 12 \tbndmk 0x12345678(%rbp),%bnd0",},
41+{{0xf3, 0x0f, 0x1b, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
42+"f3 0f 1b 84 01 78 56 34 12 \tbndmk 0x12345678(%rcx,%rax,1),%bnd0",},
43+{{0xf3, 0x0f, 0x1b, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
44+"f3 0f 1b 84 05 78 56 34 12 \tbndmk 0x12345678(%rbp,%rax,1),%bnd0",},
45+{{0xf3, 0x0f, 0x1b, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
46+"f3 0f 1b 84 08 78 56 34 12 \tbndmk 0x12345678(%rax,%rcx,1),%bnd0",},
47+{{0xf3, 0x0f, 0x1b, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
48+"f3 0f 1b 84 c8 78 56 34 12 \tbndmk 0x12345678(%rax,%rcx,8),%bnd0",},
49+{{0xf3, 0x0f, 0x1a, 0x00, }, 4, 0, "", "",
50+"f3 0f 1a 00 \tbndcl (%rax),%bnd0",},
51+{{0xf3, 0x41, 0x0f, 0x1a, 0x00, }, 5, 0, "", "",
52+"f3 41 0f 1a 00 \tbndcl (%r8),%bnd0",},
53+{{0xf3, 0x0f, 0x1a, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
54+"f3 0f 1a 04 25 78 56 34 12 \tbndcl 0x12345678,%bnd0",},
55+{{0xf3, 0x0f, 0x1a, 0x18, }, 4, 0, "", "",
56+"f3 0f 1a 18 \tbndcl (%rax),%bnd3",},
57+{{0xf3, 0x0f, 0x1a, 0x04, 0x01, }, 5, 0, "", "",
58+"f3 0f 1a 04 01 \tbndcl (%rcx,%rax,1),%bnd0",},
59+{{0xf3, 0x0f, 0x1a, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
60+"f3 0f 1a 04 05 78 56 34 12 \tbndcl 0x12345678(,%rax,1),%bnd0",},
61+{{0xf3, 0x0f, 0x1a, 0x04, 0x08, }, 5, 0, "", "",
62+"f3 0f 1a 04 08 \tbndcl (%rax,%rcx,1),%bnd0",},
63+{{0xf3, 0x0f, 0x1a, 0x04, 0xc8, }, 5, 0, "", "",
64+"f3 0f 1a 04 c8 \tbndcl (%rax,%rcx,8),%bnd0",},
65+{{0xf3, 0x0f, 0x1a, 0x40, 0x12, }, 5, 0, "", "",
66+"f3 0f 1a 40 12 \tbndcl 0x12(%rax),%bnd0",},
67+{{0xf3, 0x0f, 0x1a, 0x45, 0x12, }, 5, 0, "", "",
68+"f3 0f 1a 45 12 \tbndcl 0x12(%rbp),%bnd0",},
69+{{0xf3, 0x0f, 0x1a, 0x44, 0x01, 0x12, }, 6, 0, "", "",
70+"f3 0f 1a 44 01 12 \tbndcl 0x12(%rcx,%rax,1),%bnd0",},
71+{{0xf3, 0x0f, 0x1a, 0x44, 0x05, 0x12, }, 6, 0, "", "",
72+"f3 0f 1a 44 05 12 \tbndcl 0x12(%rbp,%rax,1),%bnd0",},
73+{{0xf3, 0x0f, 0x1a, 0x44, 0x08, 0x12, }, 6, 0, "", "",
74+"f3 0f 1a 44 08 12 \tbndcl 0x12(%rax,%rcx,1),%bnd0",},
75+{{0xf3, 0x0f, 0x1a, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
76+"f3 0f 1a 44 c8 12 \tbndcl 0x12(%rax,%rcx,8),%bnd0",},
77+{{0xf3, 0x0f, 0x1a, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
78+"f3 0f 1a 80 78 56 34 12 \tbndcl 0x12345678(%rax),%bnd0",},
79+{{0xf3, 0x0f, 0x1a, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
80+"f3 0f 1a 85 78 56 34 12 \tbndcl 0x12345678(%rbp),%bnd0",},
81+{{0xf3, 0x0f, 0x1a, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
82+"f3 0f 1a 84 01 78 56 34 12 \tbndcl 0x12345678(%rcx,%rax,1),%bnd0",},
83+{{0xf3, 0x0f, 0x1a, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
84+"f3 0f 1a 84 05 78 56 34 12 \tbndcl 0x12345678(%rbp,%rax,1),%bnd0",},
85+{{0xf3, 0x0f, 0x1a, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
86+"f3 0f 1a 84 08 78 56 34 12 \tbndcl 0x12345678(%rax,%rcx,1),%bnd0",},
87+{{0xf3, 0x0f, 0x1a, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
88+"f3 0f 1a 84 c8 78 56 34 12 \tbndcl 0x12345678(%rax,%rcx,8),%bnd0",},
89+{{0xf3, 0x0f, 0x1a, 0xc0, }, 4, 0, "", "",
90+"f3 0f 1a c0 \tbndcl %rax,%bnd0",},
91+{{0xf2, 0x0f, 0x1a, 0x00, }, 4, 0, "", "",
92+"f2 0f 1a 00 \tbndcu (%rax),%bnd0",},
93+{{0xf2, 0x41, 0x0f, 0x1a, 0x00, }, 5, 0, "", "",
94+"f2 41 0f 1a 00 \tbndcu (%r8),%bnd0",},
95+{{0xf2, 0x0f, 0x1a, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
96+"f2 0f 1a 04 25 78 56 34 12 \tbndcu 0x12345678,%bnd0",},
97+{{0xf2, 0x0f, 0x1a, 0x18, }, 4, 0, "", "",
98+"f2 0f 1a 18 \tbndcu (%rax),%bnd3",},
99+{{0xf2, 0x0f, 0x1a, 0x04, 0x01, }, 5, 0, "", "",
100+"f2 0f 1a 04 01 \tbndcu (%rcx,%rax,1),%bnd0",},
101+{{0xf2, 0x0f, 0x1a, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
102+"f2 0f 1a 04 05 78 56 34 12 \tbndcu 0x12345678(,%rax,1),%bnd0",},
103+{{0xf2, 0x0f, 0x1a, 0x04, 0x08, }, 5, 0, "", "",
104+"f2 0f 1a 04 08 \tbndcu (%rax,%rcx,1),%bnd0",},
105+{{0xf2, 0x0f, 0x1a, 0x04, 0xc8, }, 5, 0, "", "",
106+"f2 0f 1a 04 c8 \tbndcu (%rax,%rcx,8),%bnd0",},
107+{{0xf2, 0x0f, 0x1a, 0x40, 0x12, }, 5, 0, "", "",
108+"f2 0f 1a 40 12 \tbndcu 0x12(%rax),%bnd0",},
109+{{0xf2, 0x0f, 0x1a, 0x45, 0x12, }, 5, 0, "", "",
110+"f2 0f 1a 45 12 \tbndcu 0x12(%rbp),%bnd0",},
111+{{0xf2, 0x0f, 0x1a, 0x44, 0x01, 0x12, }, 6, 0, "", "",
112+"f2 0f 1a 44 01 12 \tbndcu 0x12(%rcx,%rax,1),%bnd0",},
113+{{0xf2, 0x0f, 0x1a, 0x44, 0x05, 0x12, }, 6, 0, "", "",
114+"f2 0f 1a 44 05 12 \tbndcu 0x12(%rbp,%rax,1),%bnd0",},
115+{{0xf2, 0x0f, 0x1a, 0x44, 0x08, 0x12, }, 6, 0, "", "",
116+"f2 0f 1a 44 08 12 \tbndcu 0x12(%rax,%rcx,1),%bnd0",},
117+{{0xf2, 0x0f, 0x1a, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
118+"f2 0f 1a 44 c8 12 \tbndcu 0x12(%rax,%rcx,8),%bnd0",},
119+{{0xf2, 0x0f, 0x1a, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
120+"f2 0f 1a 80 78 56 34 12 \tbndcu 0x12345678(%rax),%bnd0",},
121+{{0xf2, 0x0f, 0x1a, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
122+"f2 0f 1a 85 78 56 34 12 \tbndcu 0x12345678(%rbp),%bnd0",},
123+{{0xf2, 0x0f, 0x1a, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
124+"f2 0f 1a 84 01 78 56 34 12 \tbndcu 0x12345678(%rcx,%rax,1),%bnd0",},
125+{{0xf2, 0x0f, 0x1a, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
126+"f2 0f 1a 84 05 78 56 34 12 \tbndcu 0x12345678(%rbp,%rax,1),%bnd0",},
127+{{0xf2, 0x0f, 0x1a, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
128+"f2 0f 1a 84 08 78 56 34 12 \tbndcu 0x12345678(%rax,%rcx,1),%bnd0",},
129+{{0xf2, 0x0f, 0x1a, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
130+"f2 0f 1a 84 c8 78 56 34 12 \tbndcu 0x12345678(%rax,%rcx,8),%bnd0",},
131+{{0xf2, 0x0f, 0x1a, 0xc0, }, 4, 0, "", "",
132+"f2 0f 1a c0 \tbndcu %rax,%bnd0",},
133+{{0xf2, 0x0f, 0x1b, 0x00, }, 4, 0, "", "",
134+"f2 0f 1b 00 \tbndcn (%rax),%bnd0",},
135+{{0xf2, 0x41, 0x0f, 0x1b, 0x00, }, 5, 0, "", "",
136+"f2 41 0f 1b 00 \tbndcn (%r8),%bnd0",},
137+{{0xf2, 0x0f, 0x1b, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
138+"f2 0f 1b 04 25 78 56 34 12 \tbndcn 0x12345678,%bnd0",},
139+{{0xf2, 0x0f, 0x1b, 0x18, }, 4, 0, "", "",
140+"f2 0f 1b 18 \tbndcn (%rax),%bnd3",},
141+{{0xf2, 0x0f, 0x1b, 0x04, 0x01, }, 5, 0, "", "",
142+"f2 0f 1b 04 01 \tbndcn (%rcx,%rax,1),%bnd0",},
143+{{0xf2, 0x0f, 0x1b, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
144+"f2 0f 1b 04 05 78 56 34 12 \tbndcn 0x12345678(,%rax,1),%bnd0",},
145+{{0xf2, 0x0f, 0x1b, 0x04, 0x08, }, 5, 0, "", "",
146+"f2 0f 1b 04 08 \tbndcn (%rax,%rcx,1),%bnd0",},
147+{{0xf2, 0x0f, 0x1b, 0x04, 0xc8, }, 5, 0, "", "",
148+"f2 0f 1b 04 c8 \tbndcn (%rax,%rcx,8),%bnd0",},
149+{{0xf2, 0x0f, 0x1b, 0x40, 0x12, }, 5, 0, "", "",
150+"f2 0f 1b 40 12 \tbndcn 0x12(%rax),%bnd0",},
151+{{0xf2, 0x0f, 0x1b, 0x45, 0x12, }, 5, 0, "", "",
152+"f2 0f 1b 45 12 \tbndcn 0x12(%rbp),%bnd0",},
153+{{0xf2, 0x0f, 0x1b, 0x44, 0x01, 0x12, }, 6, 0, "", "",
154+"f2 0f 1b 44 01 12 \tbndcn 0x12(%rcx,%rax,1),%bnd0",},
155+{{0xf2, 0x0f, 0x1b, 0x44, 0x05, 0x12, }, 6, 0, "", "",
156+"f2 0f 1b 44 05 12 \tbndcn 0x12(%rbp,%rax,1),%bnd0",},
157+{{0xf2, 0x0f, 0x1b, 0x44, 0x08, 0x12, }, 6, 0, "", "",
158+"f2 0f 1b 44 08 12 \tbndcn 0x12(%rax,%rcx,1),%bnd0",},
159+{{0xf2, 0x0f, 0x1b, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
160+"f2 0f 1b 44 c8 12 \tbndcn 0x12(%rax,%rcx,8),%bnd0",},
161+{{0xf2, 0x0f, 0x1b, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
162+"f2 0f 1b 80 78 56 34 12 \tbndcn 0x12345678(%rax),%bnd0",},
163+{{0xf2, 0x0f, 0x1b, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
164+"f2 0f 1b 85 78 56 34 12 \tbndcn 0x12345678(%rbp),%bnd0",},
165+{{0xf2, 0x0f, 0x1b, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
166+"f2 0f 1b 84 01 78 56 34 12 \tbndcn 0x12345678(%rcx,%rax,1),%bnd0",},
167+{{0xf2, 0x0f, 0x1b, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
168+"f2 0f 1b 84 05 78 56 34 12 \tbndcn 0x12345678(%rbp,%rax,1),%bnd0",},
169+{{0xf2, 0x0f, 0x1b, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
170+"f2 0f 1b 84 08 78 56 34 12 \tbndcn 0x12345678(%rax,%rcx,1),%bnd0",},
171+{{0xf2, 0x0f, 0x1b, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
172+"f2 0f 1b 84 c8 78 56 34 12 \tbndcn 0x12345678(%rax,%rcx,8),%bnd0",},
173+{{0xf2, 0x0f, 0x1b, 0xc0, }, 4, 0, "", "",
174+"f2 0f 1b c0 \tbndcn %rax,%bnd0",},
175+{{0x66, 0x0f, 0x1a, 0x00, }, 4, 0, "", "",
176+"66 0f 1a 00 \tbndmov (%rax),%bnd0",},
177+{{0x66, 0x41, 0x0f, 0x1a, 0x00, }, 5, 0, "", "",
178+"66 41 0f 1a 00 \tbndmov (%r8),%bnd0",},
179+{{0x66, 0x0f, 0x1a, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
180+"66 0f 1a 04 25 78 56 34 12 \tbndmov 0x12345678,%bnd0",},
181+{{0x66, 0x0f, 0x1a, 0x18, }, 4, 0, "", "",
182+"66 0f 1a 18 \tbndmov (%rax),%bnd3",},
183+{{0x66, 0x0f, 0x1a, 0x04, 0x01, }, 5, 0, "", "",
184+"66 0f 1a 04 01 \tbndmov (%rcx,%rax,1),%bnd0",},
185+{{0x66, 0x0f, 0x1a, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
186+"66 0f 1a 04 05 78 56 34 12 \tbndmov 0x12345678(,%rax,1),%bnd0",},
187+{{0x66, 0x0f, 0x1a, 0x04, 0x08, }, 5, 0, "", "",
188+"66 0f 1a 04 08 \tbndmov (%rax,%rcx,1),%bnd0",},
189+{{0x66, 0x0f, 0x1a, 0x04, 0xc8, }, 5, 0, "", "",
190+"66 0f 1a 04 c8 \tbndmov (%rax,%rcx,8),%bnd0",},
191+{{0x66, 0x0f, 0x1a, 0x40, 0x12, }, 5, 0, "", "",
192+"66 0f 1a 40 12 \tbndmov 0x12(%rax),%bnd0",},
193+{{0x66, 0x0f, 0x1a, 0x45, 0x12, }, 5, 0, "", "",
194+"66 0f 1a 45 12 \tbndmov 0x12(%rbp),%bnd0",},
195+{{0x66, 0x0f, 0x1a, 0x44, 0x01, 0x12, }, 6, 0, "", "",
196+"66 0f 1a 44 01 12 \tbndmov 0x12(%rcx,%rax,1),%bnd0",},
197+{{0x66, 0x0f, 0x1a, 0x44, 0x05, 0x12, }, 6, 0, "", "",
198+"66 0f 1a 44 05 12 \tbndmov 0x12(%rbp,%rax,1),%bnd0",},
199+{{0x66, 0x0f, 0x1a, 0x44, 0x08, 0x12, }, 6, 0, "", "",
200+"66 0f 1a 44 08 12 \tbndmov 0x12(%rax,%rcx,1),%bnd0",},
201+{{0x66, 0x0f, 0x1a, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
202+"66 0f 1a 44 c8 12 \tbndmov 0x12(%rax,%rcx,8),%bnd0",},
203+{{0x66, 0x0f, 0x1a, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
204+"66 0f 1a 80 78 56 34 12 \tbndmov 0x12345678(%rax),%bnd0",},
205+{{0x66, 0x0f, 0x1a, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
206+"66 0f 1a 85 78 56 34 12 \tbndmov 0x12345678(%rbp),%bnd0",},
207+{{0x66, 0x0f, 0x1a, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
208+"66 0f 1a 84 01 78 56 34 12 \tbndmov 0x12345678(%rcx,%rax,1),%bnd0",},
209+{{0x66, 0x0f, 0x1a, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
210+"66 0f 1a 84 05 78 56 34 12 \tbndmov 0x12345678(%rbp,%rax,1),%bnd0",},
211+{{0x66, 0x0f, 0x1a, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
212+"66 0f 1a 84 08 78 56 34 12 \tbndmov 0x12345678(%rax,%rcx,1),%bnd0",},
213+{{0x66, 0x0f, 0x1a, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
214+"66 0f 1a 84 c8 78 56 34 12 \tbndmov 0x12345678(%rax,%rcx,8),%bnd0",},
215+{{0x66, 0x0f, 0x1b, 0x00, }, 4, 0, "", "",
216+"66 0f 1b 00 \tbndmov %bnd0,(%rax)",},
217+{{0x66, 0x41, 0x0f, 0x1b, 0x00, }, 5, 0, "", "",
218+"66 41 0f 1b 00 \tbndmov %bnd0,(%r8)",},
219+{{0x66, 0x0f, 0x1b, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
220+"66 0f 1b 04 25 78 56 34 12 \tbndmov %bnd0,0x12345678",},
221+{{0x66, 0x0f, 0x1b, 0x18, }, 4, 0, "", "",
222+"66 0f 1b 18 \tbndmov %bnd3,(%rax)",},
223+{{0x66, 0x0f, 0x1b, 0x04, 0x01, }, 5, 0, "", "",
224+"66 0f 1b 04 01 \tbndmov %bnd0,(%rcx,%rax,1)",},
225+{{0x66, 0x0f, 0x1b, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
226+"66 0f 1b 04 05 78 56 34 12 \tbndmov %bnd0,0x12345678(,%rax,1)",},
227+{{0x66, 0x0f, 0x1b, 0x04, 0x08, }, 5, 0, "", "",
228+"66 0f 1b 04 08 \tbndmov %bnd0,(%rax,%rcx,1)",},
229+{{0x66, 0x0f, 0x1b, 0x04, 0xc8, }, 5, 0, "", "",
230+"66 0f 1b 04 c8 \tbndmov %bnd0,(%rax,%rcx,8)",},
231+{{0x66, 0x0f, 0x1b, 0x40, 0x12, }, 5, 0, "", "",
232+"66 0f 1b 40 12 \tbndmov %bnd0,0x12(%rax)",},
233+{{0x66, 0x0f, 0x1b, 0x45, 0x12, }, 5, 0, "", "",
234+"66 0f 1b 45 12 \tbndmov %bnd0,0x12(%rbp)",},
235+{{0x66, 0x0f, 0x1b, 0x44, 0x01, 0x12, }, 6, 0, "", "",
236+"66 0f 1b 44 01 12 \tbndmov %bnd0,0x12(%rcx,%rax,1)",},
237+{{0x66, 0x0f, 0x1b, 0x44, 0x05, 0x12, }, 6, 0, "", "",
238+"66 0f 1b 44 05 12 \tbndmov %bnd0,0x12(%rbp,%rax,1)",},
239+{{0x66, 0x0f, 0x1b, 0x44, 0x08, 0x12, }, 6, 0, "", "",
240+"66 0f 1b 44 08 12 \tbndmov %bnd0,0x12(%rax,%rcx,1)",},
241+{{0x66, 0x0f, 0x1b, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
242+"66 0f 1b 44 c8 12 \tbndmov %bnd0,0x12(%rax,%rcx,8)",},
243+{{0x66, 0x0f, 0x1b, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
244+"66 0f 1b 80 78 56 34 12 \tbndmov %bnd0,0x12345678(%rax)",},
245+{{0x66, 0x0f, 0x1b, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
246+"66 0f 1b 85 78 56 34 12 \tbndmov %bnd0,0x12345678(%rbp)",},
247+{{0x66, 0x0f, 0x1b, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
248+"66 0f 1b 84 01 78 56 34 12 \tbndmov %bnd0,0x12345678(%rcx,%rax,1)",},
249+{{0x66, 0x0f, 0x1b, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
250+"66 0f 1b 84 05 78 56 34 12 \tbndmov %bnd0,0x12345678(%rbp,%rax,1)",},
251+{{0x66, 0x0f, 0x1b, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
252+"66 0f 1b 84 08 78 56 34 12 \tbndmov %bnd0,0x12345678(%rax,%rcx,1)",},
253+{{0x66, 0x0f, 0x1b, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
254+"66 0f 1b 84 c8 78 56 34 12 \tbndmov %bnd0,0x12345678(%rax,%rcx,8)",},
255+{{0x66, 0x0f, 0x1a, 0xc8, }, 4, 0, "", "",
256+"66 0f 1a c8 \tbndmov %bnd0,%bnd1",},
257+{{0x66, 0x0f, 0x1a, 0xc1, }, 4, 0, "", "",
258+"66 0f 1a c1 \tbndmov %bnd1,%bnd0",},
259+{{0x0f, 0x1a, 0x00, }, 3, 0, "", "",
260+"0f 1a 00 \tbndldx (%rax),%bnd0",},
261+{{0x41, 0x0f, 0x1a, 0x00, }, 4, 0, "", "",
262+"41 0f 1a 00 \tbndldx (%r8),%bnd0",},
263+{{0x0f, 0x1a, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
264+"0f 1a 04 25 78 56 34 12 \tbndldx 0x12345678,%bnd0",},
265+{{0x0f, 0x1a, 0x18, }, 3, 0, "", "",
266+"0f 1a 18 \tbndldx (%rax),%bnd3",},
267+{{0x0f, 0x1a, 0x04, 0x01, }, 4, 0, "", "",
268+"0f 1a 04 01 \tbndldx (%rcx,%rax,1),%bnd0",},
269+{{0x0f, 0x1a, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
270+"0f 1a 04 05 78 56 34 12 \tbndldx 0x12345678(,%rax,1),%bnd0",},
271+{{0x0f, 0x1a, 0x04, 0x08, }, 4, 0, "", "",
272+"0f 1a 04 08 \tbndldx (%rax,%rcx,1),%bnd0",},
273+{{0x0f, 0x1a, 0x40, 0x12, }, 4, 0, "", "",
274+"0f 1a 40 12 \tbndldx 0x12(%rax),%bnd0",},
275+{{0x0f, 0x1a, 0x45, 0x12, }, 4, 0, "", "",
276+"0f 1a 45 12 \tbndldx 0x12(%rbp),%bnd0",},
277+{{0x0f, 0x1a, 0x44, 0x01, 0x12, }, 5, 0, "", "",
278+"0f 1a 44 01 12 \tbndldx 0x12(%rcx,%rax,1),%bnd0",},
279+{{0x0f, 0x1a, 0x44, 0x05, 0x12, }, 5, 0, "", "",
280+"0f 1a 44 05 12 \tbndldx 0x12(%rbp,%rax,1),%bnd0",},
281+{{0x0f, 0x1a, 0x44, 0x08, 0x12, }, 5, 0, "", "",
282+"0f 1a 44 08 12 \tbndldx 0x12(%rax,%rcx,1),%bnd0",},
283+{{0x0f, 0x1a, 0x80, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
284+"0f 1a 80 78 56 34 12 \tbndldx 0x12345678(%rax),%bnd0",},
285+{{0x0f, 0x1a, 0x85, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
286+"0f 1a 85 78 56 34 12 \tbndldx 0x12345678(%rbp),%bnd0",},
287+{{0x0f, 0x1a, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
288+"0f 1a 84 01 78 56 34 12 \tbndldx 0x12345678(%rcx,%rax,1),%bnd0",},
289+{{0x0f, 0x1a, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
290+"0f 1a 84 05 78 56 34 12 \tbndldx 0x12345678(%rbp,%rax,1),%bnd0",},
291+{{0x0f, 0x1a, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
292+"0f 1a 84 08 78 56 34 12 \tbndldx 0x12345678(%rax,%rcx,1),%bnd0",},
293+{{0x0f, 0x1b, 0x00, }, 3, 0, "", "",
294+"0f 1b 00 \tbndstx %bnd0,(%rax)",},
295+{{0x41, 0x0f, 0x1b, 0x00, }, 4, 0, "", "",
296+"41 0f 1b 00 \tbndstx %bnd0,(%r8)",},
297+{{0x0f, 0x1b, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
298+"0f 1b 04 25 78 56 34 12 \tbndstx %bnd0,0x12345678",},
299+{{0x0f, 0x1b, 0x18, }, 3, 0, "", "",
300+"0f 1b 18 \tbndstx %bnd3,(%rax)",},
301+{{0x0f, 0x1b, 0x04, 0x01, }, 4, 0, "", "",
302+"0f 1b 04 01 \tbndstx %bnd0,(%rcx,%rax,1)",},
303+{{0x0f, 0x1b, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
304+"0f 1b 04 05 78 56 34 12 \tbndstx %bnd0,0x12345678(,%rax,1)",},
305+{{0x0f, 0x1b, 0x04, 0x08, }, 4, 0, "", "",
306+"0f 1b 04 08 \tbndstx %bnd0,(%rax,%rcx,1)",},
307+{{0x0f, 0x1b, 0x40, 0x12, }, 4, 0, "", "",
308+"0f 1b 40 12 \tbndstx %bnd0,0x12(%rax)",},
309+{{0x0f, 0x1b, 0x45, 0x12, }, 4, 0, "", "",
310+"0f 1b 45 12 \tbndstx %bnd0,0x12(%rbp)",},
311+{{0x0f, 0x1b, 0x44, 0x01, 0x12, }, 5, 0, "", "",
312+"0f 1b 44 01 12 \tbndstx %bnd0,0x12(%rcx,%rax,1)",},
313+{{0x0f, 0x1b, 0x44, 0x05, 0x12, }, 5, 0, "", "",
314+"0f 1b 44 05 12 \tbndstx %bnd0,0x12(%rbp,%rax,1)",},
315+{{0x0f, 0x1b, 0x44, 0x08, 0x12, }, 5, 0, "", "",
316+"0f 1b 44 08 12 \tbndstx %bnd0,0x12(%rax,%rcx,1)",},
317+{{0x0f, 0x1b, 0x80, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
318+"0f 1b 80 78 56 34 12 \tbndstx %bnd0,0x12345678(%rax)",},
319+{{0x0f, 0x1b, 0x85, 0x78, 0x56, 0x34, 0x12, }, 7, 0, "", "",
320+"0f 1b 85 78 56 34 12 \tbndstx %bnd0,0x12345678(%rbp)",},
321+{{0x0f, 0x1b, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
322+"0f 1b 84 01 78 56 34 12 \tbndstx %bnd0,0x12345678(%rcx,%rax,1)",},
323+{{0x0f, 0x1b, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
324+"0f 1b 84 05 78 56 34 12 \tbndstx %bnd0,0x12345678(%rbp,%rax,1)",},
325+{{0x0f, 0x1b, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
326+"0f 1b 84 08 78 56 34 12 \tbndstx %bnd0,0x12345678(%rax,%rcx,1)",},
327+{{0xf2, 0xe8, 0x00, 0x00, 0x00, 0x00, }, 6, 0, "call", "unconditional",
328+"f2 e8 00 00 00 00 \tbnd callq 3f6 <main+0x3f6>",},
329+{{0x67, 0xf2, 0xff, 0x10, }, 4, 0, "call", "indirect",
330+"67 f2 ff 10 \tbnd callq *(%eax)",},
331+{{0xf2, 0xc3, }, 2, 0, "ret", "indirect",
332+"f2 c3 \tbnd retq ",},
333+{{0xf2, 0xe9, 0x00, 0x00, 0x00, 0x00, }, 6, 0, "jmp", "unconditional",
334+"f2 e9 00 00 00 00 \tbnd jmpq 402 <main+0x402>",},
335+{{0xf2, 0xe9, 0x00, 0x00, 0x00, 0x00, }, 6, 0, "jmp", "unconditional",
336+"f2 e9 00 00 00 00 \tbnd jmpq 408 <main+0x408>",},
337+{{0x67, 0xf2, 0xff, 0x21, }, 4, 0, "jmp", "indirect",
338+"67 f2 ff 21 \tbnd jmpq *(%ecx)",},
339+{{0xf2, 0x0f, 0x85, 0x00, 0x00, 0x00, 0x00, }, 7, 0, "jcc", "conditional",
340+"f2 0f 85 00 00 00 00 \tbnd jne 413 <main+0x413>",},
341+{{0x0f, 0x3a, 0xcc, 0xc1, 0x00, }, 5, 0, "", "",
342+"0f 3a cc c1 00 \tsha1rnds4 $0x0,%xmm1,%xmm0",},
343+{{0x0f, 0x3a, 0xcc, 0xd7, 0x91, }, 5, 0, "", "",
344+"0f 3a cc d7 91 \tsha1rnds4 $0x91,%xmm7,%xmm2",},
345+{{0x41, 0x0f, 0x3a, 0xcc, 0xc0, 0x91, }, 6, 0, "", "",
346+"41 0f 3a cc c0 91 \tsha1rnds4 $0x91,%xmm8,%xmm0",},
347+{{0x44, 0x0f, 0x3a, 0xcc, 0xc7, 0x91, }, 6, 0, "", "",
348+"44 0f 3a cc c7 91 \tsha1rnds4 $0x91,%xmm7,%xmm8",},
349+{{0x45, 0x0f, 0x3a, 0xcc, 0xc7, 0x91, }, 6, 0, "", "",
350+"45 0f 3a cc c7 91 \tsha1rnds4 $0x91,%xmm15,%xmm8",},
351+{{0x0f, 0x3a, 0xcc, 0x00, 0x91, }, 5, 0, "", "",
352+"0f 3a cc 00 91 \tsha1rnds4 $0x91,(%rax),%xmm0",},
353+{{0x41, 0x0f, 0x3a, 0xcc, 0x00, 0x91, }, 6, 0, "", "",
354+"41 0f 3a cc 00 91 \tsha1rnds4 $0x91,(%r8),%xmm0",},
355+{{0x0f, 0x3a, 0xcc, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, 0x91, }, 10, 0, "", "",
356+"0f 3a cc 04 25 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678,%xmm0",},
357+{{0x0f, 0x3a, 0xcc, 0x18, 0x91, }, 5, 0, "", "",
358+"0f 3a cc 18 91 \tsha1rnds4 $0x91,(%rax),%xmm3",},
359+{{0x0f, 0x3a, 0xcc, 0x04, 0x01, 0x91, }, 6, 0, "", "",
360+"0f 3a cc 04 01 91 \tsha1rnds4 $0x91,(%rcx,%rax,1),%xmm0",},
361+{{0x0f, 0x3a, 0xcc, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, 0x91, }, 10, 0, "", "",
362+"0f 3a cc 04 05 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(,%rax,1),%xmm0",},
363+{{0x0f, 0x3a, 0xcc, 0x04, 0x08, 0x91, }, 6, 0, "", "",
364+"0f 3a cc 04 08 91 \tsha1rnds4 $0x91,(%rax,%rcx,1),%xmm0",},
365+{{0x0f, 0x3a, 0xcc, 0x04, 0xc8, 0x91, }, 6, 0, "", "",
366+"0f 3a cc 04 c8 91 \tsha1rnds4 $0x91,(%rax,%rcx,8),%xmm0",},
367+{{0x0f, 0x3a, 0xcc, 0x40, 0x12, 0x91, }, 6, 0, "", "",
368+"0f 3a cc 40 12 91 \tsha1rnds4 $0x91,0x12(%rax),%xmm0",},
369+{{0x0f, 0x3a, 0xcc, 0x45, 0x12, 0x91, }, 6, 0, "", "",
370+"0f 3a cc 45 12 91 \tsha1rnds4 $0x91,0x12(%rbp),%xmm0",},
371+{{0x0f, 0x3a, 0xcc, 0x44, 0x01, 0x12, 0x91, }, 7, 0, "", "",
372+"0f 3a cc 44 01 12 91 \tsha1rnds4 $0x91,0x12(%rcx,%rax,1),%xmm0",},
373+{{0x0f, 0x3a, 0xcc, 0x44, 0x05, 0x12, 0x91, }, 7, 0, "", "",
374+"0f 3a cc 44 05 12 91 \tsha1rnds4 $0x91,0x12(%rbp,%rax,1),%xmm0",},
375+{{0x0f, 0x3a, 0xcc, 0x44, 0x08, 0x12, 0x91, }, 7, 0, "", "",
376+"0f 3a cc 44 08 12 91 \tsha1rnds4 $0x91,0x12(%rax,%rcx,1),%xmm0",},
377+{{0x0f, 0x3a, 0xcc, 0x44, 0xc8, 0x12, 0x91, }, 7, 0, "", "",
378+"0f 3a cc 44 c8 12 91 \tsha1rnds4 $0x91,0x12(%rax,%rcx,8),%xmm0",},
379+{{0x0f, 0x3a, 0xcc, 0x80, 0x78, 0x56, 0x34, 0x12, 0x91, }, 9, 0, "", "",
380+"0f 3a cc 80 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%rax),%xmm0",},
381+{{0x0f, 0x3a, 0xcc, 0x85, 0x78, 0x56, 0x34, 0x12, 0x91, }, 9, 0, "", "",
382+"0f 3a cc 85 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%rbp),%xmm0",},
383+{{0x0f, 0x3a, 0xcc, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, 0x91, }, 10, 0, "", "",
384+"0f 3a cc 84 01 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%rcx,%rax,1),%xmm0",},
385+{{0x0f, 0x3a, 0xcc, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, 0x91, }, 10, 0, "", "",
386+"0f 3a cc 84 05 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%rbp,%rax,1),%xmm0",},
387+{{0x0f, 0x3a, 0xcc, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, 0x91, }, 10, 0, "", "",
388+"0f 3a cc 84 08 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%rax,%rcx,1),%xmm0",},
389+{{0x0f, 0x3a, 0xcc, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, 0x91, }, 10, 0, "", "",
390+"0f 3a cc 84 c8 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%rax,%rcx,8),%xmm0",},
391+{{0x44, 0x0f, 0x3a, 0xcc, 0xbc, 0xc8, 0x78, 0x56, 0x34, 0x12, 0x91, }, 11, 0, "", "",
392+"44 0f 3a cc bc c8 78 56 34 12 91 \tsha1rnds4 $0x91,0x12345678(%rax,%rcx,8),%xmm15",},
393+{{0x0f, 0x38, 0xc8, 0xc1, }, 4, 0, "", "",
394+"0f 38 c8 c1 \tsha1nexte %xmm1,%xmm0",},
395+{{0x0f, 0x38, 0xc8, 0xd7, }, 4, 0, "", "",
396+"0f 38 c8 d7 \tsha1nexte %xmm7,%xmm2",},
397+{{0x41, 0x0f, 0x38, 0xc8, 0xc0, }, 5, 0, "", "",
398+"41 0f 38 c8 c0 \tsha1nexte %xmm8,%xmm0",},
399+{{0x44, 0x0f, 0x38, 0xc8, 0xc7, }, 5, 0, "", "",
400+"44 0f 38 c8 c7 \tsha1nexte %xmm7,%xmm8",},
401+{{0x45, 0x0f, 0x38, 0xc8, 0xc7, }, 5, 0, "", "",
402+"45 0f 38 c8 c7 \tsha1nexte %xmm15,%xmm8",},
403+{{0x0f, 0x38, 0xc8, 0x00, }, 4, 0, "", "",
404+"0f 38 c8 00 \tsha1nexte (%rax),%xmm0",},
405+{{0x41, 0x0f, 0x38, 0xc8, 0x00, }, 5, 0, "", "",
406+"41 0f 38 c8 00 \tsha1nexte (%r8),%xmm0",},
407+{{0x0f, 0x38, 0xc8, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
408+"0f 38 c8 04 25 78 56 34 12 \tsha1nexte 0x12345678,%xmm0",},
409+{{0x0f, 0x38, 0xc8, 0x18, }, 4, 0, "", "",
410+"0f 38 c8 18 \tsha1nexte (%rax),%xmm3",},
411+{{0x0f, 0x38, 0xc8, 0x04, 0x01, }, 5, 0, "", "",
412+"0f 38 c8 04 01 \tsha1nexte (%rcx,%rax,1),%xmm0",},
413+{{0x0f, 0x38, 0xc8, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
414+"0f 38 c8 04 05 78 56 34 12 \tsha1nexte 0x12345678(,%rax,1),%xmm0",},
415+{{0x0f, 0x38, 0xc8, 0x04, 0x08, }, 5, 0, "", "",
416+"0f 38 c8 04 08 \tsha1nexte (%rax,%rcx,1),%xmm0",},
417+{{0x0f, 0x38, 0xc8, 0x04, 0xc8, }, 5, 0, "", "",
418+"0f 38 c8 04 c8 \tsha1nexte (%rax,%rcx,8),%xmm0",},
419+{{0x0f, 0x38, 0xc8, 0x40, 0x12, }, 5, 0, "", "",
420+"0f 38 c8 40 12 \tsha1nexte 0x12(%rax),%xmm0",},
421+{{0x0f, 0x38, 0xc8, 0x45, 0x12, }, 5, 0, "", "",
422+"0f 38 c8 45 12 \tsha1nexte 0x12(%rbp),%xmm0",},
423+{{0x0f, 0x38, 0xc8, 0x44, 0x01, 0x12, }, 6, 0, "", "",
424+"0f 38 c8 44 01 12 \tsha1nexte 0x12(%rcx,%rax,1),%xmm0",},
425+{{0x0f, 0x38, 0xc8, 0x44, 0x05, 0x12, }, 6, 0, "", "",
426+"0f 38 c8 44 05 12 \tsha1nexte 0x12(%rbp,%rax,1),%xmm0",},
427+{{0x0f, 0x38, 0xc8, 0x44, 0x08, 0x12, }, 6, 0, "", "",
428+"0f 38 c8 44 08 12 \tsha1nexte 0x12(%rax,%rcx,1),%xmm0",},
429+{{0x0f, 0x38, 0xc8, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
430+"0f 38 c8 44 c8 12 \tsha1nexte 0x12(%rax,%rcx,8),%xmm0",},
431+{{0x0f, 0x38, 0xc8, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
432+"0f 38 c8 80 78 56 34 12 \tsha1nexte 0x12345678(%rax),%xmm0",},
433+{{0x0f, 0x38, 0xc8, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
434+"0f 38 c8 85 78 56 34 12 \tsha1nexte 0x12345678(%rbp),%xmm0",},
435+{{0x0f, 0x38, 0xc8, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
436+"0f 38 c8 84 01 78 56 34 12 \tsha1nexte 0x12345678(%rcx,%rax,1),%xmm0",},
437+{{0x0f, 0x38, 0xc8, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
438+"0f 38 c8 84 05 78 56 34 12 \tsha1nexte 0x12345678(%rbp,%rax,1),%xmm0",},
439+{{0x0f, 0x38, 0xc8, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
440+"0f 38 c8 84 08 78 56 34 12 \tsha1nexte 0x12345678(%rax,%rcx,1),%xmm0",},
441+{{0x0f, 0x38, 0xc8, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
442+"0f 38 c8 84 c8 78 56 34 12 \tsha1nexte 0x12345678(%rax,%rcx,8),%xmm0",},
443+{{0x44, 0x0f, 0x38, 0xc8, 0xbc, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 10, 0, "", "",
444+"44 0f 38 c8 bc c8 78 56 34 12 \tsha1nexte 0x12345678(%rax,%rcx,8),%xmm15",},
445+{{0x0f, 0x38, 0xc9, 0xc1, }, 4, 0, "", "",
446+"0f 38 c9 c1 \tsha1msg1 %xmm1,%xmm0",},
447+{{0x0f, 0x38, 0xc9, 0xd7, }, 4, 0, "", "",
448+"0f 38 c9 d7 \tsha1msg1 %xmm7,%xmm2",},
449+{{0x41, 0x0f, 0x38, 0xc9, 0xc0, }, 5, 0, "", "",
450+"41 0f 38 c9 c0 \tsha1msg1 %xmm8,%xmm0",},
451+{{0x44, 0x0f, 0x38, 0xc9, 0xc7, }, 5, 0, "", "",
452+"44 0f 38 c9 c7 \tsha1msg1 %xmm7,%xmm8",},
453+{{0x45, 0x0f, 0x38, 0xc9, 0xc7, }, 5, 0, "", "",
454+"45 0f 38 c9 c7 \tsha1msg1 %xmm15,%xmm8",},
455+{{0x0f, 0x38, 0xc9, 0x00, }, 4, 0, "", "",
456+"0f 38 c9 00 \tsha1msg1 (%rax),%xmm0",},
457+{{0x41, 0x0f, 0x38, 0xc9, 0x00, }, 5, 0, "", "",
458+"41 0f 38 c9 00 \tsha1msg1 (%r8),%xmm0",},
459+{{0x0f, 0x38, 0xc9, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
460+"0f 38 c9 04 25 78 56 34 12 \tsha1msg1 0x12345678,%xmm0",},
461+{{0x0f, 0x38, 0xc9, 0x18, }, 4, 0, "", "",
462+"0f 38 c9 18 \tsha1msg1 (%rax),%xmm3",},
463+{{0x0f, 0x38, 0xc9, 0x04, 0x01, }, 5, 0, "", "",
464+"0f 38 c9 04 01 \tsha1msg1 (%rcx,%rax,1),%xmm0",},
465+{{0x0f, 0x38, 0xc9, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
466+"0f 38 c9 04 05 78 56 34 12 \tsha1msg1 0x12345678(,%rax,1),%xmm0",},
467+{{0x0f, 0x38, 0xc9, 0x04, 0x08, }, 5, 0, "", "",
468+"0f 38 c9 04 08 \tsha1msg1 (%rax,%rcx,1),%xmm0",},
469+{{0x0f, 0x38, 0xc9, 0x04, 0xc8, }, 5, 0, "", "",
470+"0f 38 c9 04 c8 \tsha1msg1 (%rax,%rcx,8),%xmm0",},
471+{{0x0f, 0x38, 0xc9, 0x40, 0x12, }, 5, 0, "", "",
472+"0f 38 c9 40 12 \tsha1msg1 0x12(%rax),%xmm0",},
473+{{0x0f, 0x38, 0xc9, 0x45, 0x12, }, 5, 0, "", "",
474+"0f 38 c9 45 12 \tsha1msg1 0x12(%rbp),%xmm0",},
475+{{0x0f, 0x38, 0xc9, 0x44, 0x01, 0x12, }, 6, 0, "", "",
476+"0f 38 c9 44 01 12 \tsha1msg1 0x12(%rcx,%rax,1),%xmm0",},
477+{{0x0f, 0x38, 0xc9, 0x44, 0x05, 0x12, }, 6, 0, "", "",
478+"0f 38 c9 44 05 12 \tsha1msg1 0x12(%rbp,%rax,1),%xmm0",},
479+{{0x0f, 0x38, 0xc9, 0x44, 0x08, 0x12, }, 6, 0, "", "",
480+"0f 38 c9 44 08 12 \tsha1msg1 0x12(%rax,%rcx,1),%xmm0",},
481+{{0x0f, 0x38, 0xc9, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
482+"0f 38 c9 44 c8 12 \tsha1msg1 0x12(%rax,%rcx,8),%xmm0",},
483+{{0x0f, 0x38, 0xc9, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
484+"0f 38 c9 80 78 56 34 12 \tsha1msg1 0x12345678(%rax),%xmm0",},
485+{{0x0f, 0x38, 0xc9, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
486+"0f 38 c9 85 78 56 34 12 \tsha1msg1 0x12345678(%rbp),%xmm0",},
487+{{0x0f, 0x38, 0xc9, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
488+"0f 38 c9 84 01 78 56 34 12 \tsha1msg1 0x12345678(%rcx,%rax,1),%xmm0",},
489+{{0x0f, 0x38, 0xc9, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
490+"0f 38 c9 84 05 78 56 34 12 \tsha1msg1 0x12345678(%rbp,%rax,1),%xmm0",},
491+{{0x0f, 0x38, 0xc9, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
492+"0f 38 c9 84 08 78 56 34 12 \tsha1msg1 0x12345678(%rax,%rcx,1),%xmm0",},
493+{{0x0f, 0x38, 0xc9, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
494+"0f 38 c9 84 c8 78 56 34 12 \tsha1msg1 0x12345678(%rax,%rcx,8),%xmm0",},
495+{{0x44, 0x0f, 0x38, 0xc9, 0xbc, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 10, 0, "", "",
496+"44 0f 38 c9 bc c8 78 56 34 12 \tsha1msg1 0x12345678(%rax,%rcx,8),%xmm15",},
497+{{0x0f, 0x38, 0xca, 0xc1, }, 4, 0, "", "",
498+"0f 38 ca c1 \tsha1msg2 %xmm1,%xmm0",},
499+{{0x0f, 0x38, 0xca, 0xd7, }, 4, 0, "", "",
500+"0f 38 ca d7 \tsha1msg2 %xmm7,%xmm2",},
501+{{0x41, 0x0f, 0x38, 0xca, 0xc0, }, 5, 0, "", "",
502+"41 0f 38 ca c0 \tsha1msg2 %xmm8,%xmm0",},
503+{{0x44, 0x0f, 0x38, 0xca, 0xc7, }, 5, 0, "", "",
504+"44 0f 38 ca c7 \tsha1msg2 %xmm7,%xmm8",},
505+{{0x45, 0x0f, 0x38, 0xca, 0xc7, }, 5, 0, "", "",
506+"45 0f 38 ca c7 \tsha1msg2 %xmm15,%xmm8",},
507+{{0x0f, 0x38, 0xca, 0x00, }, 4, 0, "", "",
508+"0f 38 ca 00 \tsha1msg2 (%rax),%xmm0",},
509+{{0x41, 0x0f, 0x38, 0xca, 0x00, }, 5, 0, "", "",
510+"41 0f 38 ca 00 \tsha1msg2 (%r8),%xmm0",},
511+{{0x0f, 0x38, 0xca, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
512+"0f 38 ca 04 25 78 56 34 12 \tsha1msg2 0x12345678,%xmm0",},
513+{{0x0f, 0x38, 0xca, 0x18, }, 4, 0, "", "",
514+"0f 38 ca 18 \tsha1msg2 (%rax),%xmm3",},
515+{{0x0f, 0x38, 0xca, 0x04, 0x01, }, 5, 0, "", "",
516+"0f 38 ca 04 01 \tsha1msg2 (%rcx,%rax,1),%xmm0",},
517+{{0x0f, 0x38, 0xca, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
518+"0f 38 ca 04 05 78 56 34 12 \tsha1msg2 0x12345678(,%rax,1),%xmm0",},
519+{{0x0f, 0x38, 0xca, 0x04, 0x08, }, 5, 0, "", "",
520+"0f 38 ca 04 08 \tsha1msg2 (%rax,%rcx,1),%xmm0",},
521+{{0x0f, 0x38, 0xca, 0x04, 0xc8, }, 5, 0, "", "",
522+"0f 38 ca 04 c8 \tsha1msg2 (%rax,%rcx,8),%xmm0",},
523+{{0x0f, 0x38, 0xca, 0x40, 0x12, }, 5, 0, "", "",
524+"0f 38 ca 40 12 \tsha1msg2 0x12(%rax),%xmm0",},
525+{{0x0f, 0x38, 0xca, 0x45, 0x12, }, 5, 0, "", "",
526+"0f 38 ca 45 12 \tsha1msg2 0x12(%rbp),%xmm0",},
527+{{0x0f, 0x38, 0xca, 0x44, 0x01, 0x12, }, 6, 0, "", "",
528+"0f 38 ca 44 01 12 \tsha1msg2 0x12(%rcx,%rax,1),%xmm0",},
529+{{0x0f, 0x38, 0xca, 0x44, 0x05, 0x12, }, 6, 0, "", "",
530+"0f 38 ca 44 05 12 \tsha1msg2 0x12(%rbp,%rax,1),%xmm0",},
531+{{0x0f, 0x38, 0xca, 0x44, 0x08, 0x12, }, 6, 0, "", "",
532+"0f 38 ca 44 08 12 \tsha1msg2 0x12(%rax,%rcx,1),%xmm0",},
533+{{0x0f, 0x38, 0xca, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
534+"0f 38 ca 44 c8 12 \tsha1msg2 0x12(%rax,%rcx,8),%xmm0",},
535+{{0x0f, 0x38, 0xca, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
536+"0f 38 ca 80 78 56 34 12 \tsha1msg2 0x12345678(%rax),%xmm0",},
537+{{0x0f, 0x38, 0xca, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
538+"0f 38 ca 85 78 56 34 12 \tsha1msg2 0x12345678(%rbp),%xmm0",},
539+{{0x0f, 0x38, 0xca, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
540+"0f 38 ca 84 01 78 56 34 12 \tsha1msg2 0x12345678(%rcx,%rax,1),%xmm0",},
541+{{0x0f, 0x38, 0xca, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
542+"0f 38 ca 84 05 78 56 34 12 \tsha1msg2 0x12345678(%rbp,%rax,1),%xmm0",},
543+{{0x0f, 0x38, 0xca, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
544+"0f 38 ca 84 08 78 56 34 12 \tsha1msg2 0x12345678(%rax,%rcx,1),%xmm0",},
545+{{0x0f, 0x38, 0xca, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
546+"0f 38 ca 84 c8 78 56 34 12 \tsha1msg2 0x12345678(%rax,%rcx,8),%xmm0",},
547+{{0x44, 0x0f, 0x38, 0xca, 0xbc, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 10, 0, "", "",
548+"44 0f 38 ca bc c8 78 56 34 12 \tsha1msg2 0x12345678(%rax,%rcx,8),%xmm15",},
549+{{0x0f, 0x38, 0xcb, 0xcc, }, 4, 0, "", "",
550+"0f 38 cb cc \tsha256rnds2 %xmm0,%xmm4,%xmm1",},
551+{{0x0f, 0x38, 0xcb, 0xd7, }, 4, 0, "", "",
552+"0f 38 cb d7 \tsha256rnds2 %xmm0,%xmm7,%xmm2",},
553+{{0x41, 0x0f, 0x38, 0xcb, 0xc8, }, 5, 0, "", "",
554+"41 0f 38 cb c8 \tsha256rnds2 %xmm0,%xmm8,%xmm1",},
555+{{0x44, 0x0f, 0x38, 0xcb, 0xc7, }, 5, 0, "", "",
556+"44 0f 38 cb c7 \tsha256rnds2 %xmm0,%xmm7,%xmm8",},
557+{{0x45, 0x0f, 0x38, 0xcb, 0xc7, }, 5, 0, "", "",
558+"45 0f 38 cb c7 \tsha256rnds2 %xmm0,%xmm15,%xmm8",},
559+{{0x0f, 0x38, 0xcb, 0x08, }, 4, 0, "", "",
560+"0f 38 cb 08 \tsha256rnds2 %xmm0,(%rax),%xmm1",},
561+{{0x41, 0x0f, 0x38, 0xcb, 0x08, }, 5, 0, "", "",
562+"41 0f 38 cb 08 \tsha256rnds2 %xmm0,(%r8),%xmm1",},
563+{{0x0f, 0x38, 0xcb, 0x0c, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
564+"0f 38 cb 0c 25 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678,%xmm1",},
565+{{0x0f, 0x38, 0xcb, 0x18, }, 4, 0, "", "",
566+"0f 38 cb 18 \tsha256rnds2 %xmm0,(%rax),%xmm3",},
567+{{0x0f, 0x38, 0xcb, 0x0c, 0x01, }, 5, 0, "", "",
568+"0f 38 cb 0c 01 \tsha256rnds2 %xmm0,(%rcx,%rax,1),%xmm1",},
569+{{0x0f, 0x38, 0xcb, 0x0c, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
570+"0f 38 cb 0c 05 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(,%rax,1),%xmm1",},
571+{{0x0f, 0x38, 0xcb, 0x0c, 0x08, }, 5, 0, "", "",
572+"0f 38 cb 0c 08 \tsha256rnds2 %xmm0,(%rax,%rcx,1),%xmm1",},
573+{{0x0f, 0x38, 0xcb, 0x0c, 0xc8, }, 5, 0, "", "",
574+"0f 38 cb 0c c8 \tsha256rnds2 %xmm0,(%rax,%rcx,8),%xmm1",},
575+{{0x0f, 0x38, 0xcb, 0x48, 0x12, }, 5, 0, "", "",
576+"0f 38 cb 48 12 \tsha256rnds2 %xmm0,0x12(%rax),%xmm1",},
577+{{0x0f, 0x38, 0xcb, 0x4d, 0x12, }, 5, 0, "", "",
578+"0f 38 cb 4d 12 \tsha256rnds2 %xmm0,0x12(%rbp),%xmm1",},
579+{{0x0f, 0x38, 0xcb, 0x4c, 0x01, 0x12, }, 6, 0, "", "",
580+"0f 38 cb 4c 01 12 \tsha256rnds2 %xmm0,0x12(%rcx,%rax,1),%xmm1",},
581+{{0x0f, 0x38, 0xcb, 0x4c, 0x05, 0x12, }, 6, 0, "", "",
582+"0f 38 cb 4c 05 12 \tsha256rnds2 %xmm0,0x12(%rbp,%rax,1),%xmm1",},
583+{{0x0f, 0x38, 0xcb, 0x4c, 0x08, 0x12, }, 6, 0, "", "",
584+"0f 38 cb 4c 08 12 \tsha256rnds2 %xmm0,0x12(%rax,%rcx,1),%xmm1",},
585+{{0x0f, 0x38, 0xcb, 0x4c, 0xc8, 0x12, }, 6, 0, "", "",
586+"0f 38 cb 4c c8 12 \tsha256rnds2 %xmm0,0x12(%rax,%rcx,8),%xmm1",},
587+{{0x0f, 0x38, 0xcb, 0x88, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
588+"0f 38 cb 88 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%rax),%xmm1",},
589+{{0x0f, 0x38, 0xcb, 0x8d, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
590+"0f 38 cb 8d 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%rbp),%xmm1",},
591+{{0x0f, 0x38, 0xcb, 0x8c, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
592+"0f 38 cb 8c 01 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%rcx,%rax,1),%xmm1",},
593+{{0x0f, 0x38, 0xcb, 0x8c, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
594+"0f 38 cb 8c 05 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%rbp,%rax,1),%xmm1",},
595+{{0x0f, 0x38, 0xcb, 0x8c, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
596+"0f 38 cb 8c 08 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%rax,%rcx,1),%xmm1",},
597+{{0x0f, 0x38, 0xcb, 0x8c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
598+"0f 38 cb 8c c8 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%rax,%rcx,8),%xmm1",},
599+{{0x44, 0x0f, 0x38, 0xcb, 0xbc, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 10, 0, "", "",
600+"44 0f 38 cb bc c8 78 56 34 12 \tsha256rnds2 %xmm0,0x12345678(%rax,%rcx,8),%xmm15",},
601+{{0x0f, 0x38, 0xcc, 0xc1, }, 4, 0, "", "",
602+"0f 38 cc c1 \tsha256msg1 %xmm1,%xmm0",},
603+{{0x0f, 0x38, 0xcc, 0xd7, }, 4, 0, "", "",
604+"0f 38 cc d7 \tsha256msg1 %xmm7,%xmm2",},
605+{{0x41, 0x0f, 0x38, 0xcc, 0xc0, }, 5, 0, "", "",
606+"41 0f 38 cc c0 \tsha256msg1 %xmm8,%xmm0",},
607+{{0x44, 0x0f, 0x38, 0xcc, 0xc7, }, 5, 0, "", "",
608+"44 0f 38 cc c7 \tsha256msg1 %xmm7,%xmm8",},
609+{{0x45, 0x0f, 0x38, 0xcc, 0xc7, }, 5, 0, "", "",
610+"45 0f 38 cc c7 \tsha256msg1 %xmm15,%xmm8",},
611+{{0x0f, 0x38, 0xcc, 0x00, }, 4, 0, "", "",
612+"0f 38 cc 00 \tsha256msg1 (%rax),%xmm0",},
613+{{0x41, 0x0f, 0x38, 0xcc, 0x00, }, 5, 0, "", "",
614+"41 0f 38 cc 00 \tsha256msg1 (%r8),%xmm0",},
615+{{0x0f, 0x38, 0xcc, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
616+"0f 38 cc 04 25 78 56 34 12 \tsha256msg1 0x12345678,%xmm0",},
617+{{0x0f, 0x38, 0xcc, 0x18, }, 4, 0, "", "",
618+"0f 38 cc 18 \tsha256msg1 (%rax),%xmm3",},
619+{{0x0f, 0x38, 0xcc, 0x04, 0x01, }, 5, 0, "", "",
620+"0f 38 cc 04 01 \tsha256msg1 (%rcx,%rax,1),%xmm0",},
621+{{0x0f, 0x38, 0xcc, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
622+"0f 38 cc 04 05 78 56 34 12 \tsha256msg1 0x12345678(,%rax,1),%xmm0",},
623+{{0x0f, 0x38, 0xcc, 0x04, 0x08, }, 5, 0, "", "",
624+"0f 38 cc 04 08 \tsha256msg1 (%rax,%rcx,1),%xmm0",},
625+{{0x0f, 0x38, 0xcc, 0x04, 0xc8, }, 5, 0, "", "",
626+"0f 38 cc 04 c8 \tsha256msg1 (%rax,%rcx,8),%xmm0",},
627+{{0x0f, 0x38, 0xcc, 0x40, 0x12, }, 5, 0, "", "",
628+"0f 38 cc 40 12 \tsha256msg1 0x12(%rax),%xmm0",},
629+{{0x0f, 0x38, 0xcc, 0x45, 0x12, }, 5, 0, "", "",
630+"0f 38 cc 45 12 \tsha256msg1 0x12(%rbp),%xmm0",},
631+{{0x0f, 0x38, 0xcc, 0x44, 0x01, 0x12, }, 6, 0, "", "",
632+"0f 38 cc 44 01 12 \tsha256msg1 0x12(%rcx,%rax,1),%xmm0",},
633+{{0x0f, 0x38, 0xcc, 0x44, 0x05, 0x12, }, 6, 0, "", "",
634+"0f 38 cc 44 05 12 \tsha256msg1 0x12(%rbp,%rax,1),%xmm0",},
635+{{0x0f, 0x38, 0xcc, 0x44, 0x08, 0x12, }, 6, 0, "", "",
636+"0f 38 cc 44 08 12 \tsha256msg1 0x12(%rax,%rcx,1),%xmm0",},
637+{{0x0f, 0x38, 0xcc, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
638+"0f 38 cc 44 c8 12 \tsha256msg1 0x12(%rax,%rcx,8),%xmm0",},
639+{{0x0f, 0x38, 0xcc, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
640+"0f 38 cc 80 78 56 34 12 \tsha256msg1 0x12345678(%rax),%xmm0",},
641+{{0x0f, 0x38, 0xcc, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
642+"0f 38 cc 85 78 56 34 12 \tsha256msg1 0x12345678(%rbp),%xmm0",},
643+{{0x0f, 0x38, 0xcc, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
644+"0f 38 cc 84 01 78 56 34 12 \tsha256msg1 0x12345678(%rcx,%rax,1),%xmm0",},
645+{{0x0f, 0x38, 0xcc, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
646+"0f 38 cc 84 05 78 56 34 12 \tsha256msg1 0x12345678(%rbp,%rax,1),%xmm0",},
647+{{0x0f, 0x38, 0xcc, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
648+"0f 38 cc 84 08 78 56 34 12 \tsha256msg1 0x12345678(%rax,%rcx,1),%xmm0",},
649+{{0x0f, 0x38, 0xcc, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
650+"0f 38 cc 84 c8 78 56 34 12 \tsha256msg1 0x12345678(%rax,%rcx,8),%xmm0",},
651+{{0x44, 0x0f, 0x38, 0xcc, 0xbc, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 10, 0, "", "",
652+"44 0f 38 cc bc c8 78 56 34 12 \tsha256msg1 0x12345678(%rax,%rcx,8),%xmm15",},
653+{{0x0f, 0x38, 0xcd, 0xc1, }, 4, 0, "", "",
654+"0f 38 cd c1 \tsha256msg2 %xmm1,%xmm0",},
655+{{0x0f, 0x38, 0xcd, 0xd7, }, 4, 0, "", "",
656+"0f 38 cd d7 \tsha256msg2 %xmm7,%xmm2",},
657+{{0x41, 0x0f, 0x38, 0xcd, 0xc0, }, 5, 0, "", "",
658+"41 0f 38 cd c0 \tsha256msg2 %xmm8,%xmm0",},
659+{{0x44, 0x0f, 0x38, 0xcd, 0xc7, }, 5, 0, "", "",
660+"44 0f 38 cd c7 \tsha256msg2 %xmm7,%xmm8",},
661+{{0x45, 0x0f, 0x38, 0xcd, 0xc7, }, 5, 0, "", "",
662+"45 0f 38 cd c7 \tsha256msg2 %xmm15,%xmm8",},
663+{{0x0f, 0x38, 0xcd, 0x00, }, 4, 0, "", "",
664+"0f 38 cd 00 \tsha256msg2 (%rax),%xmm0",},
665+{{0x41, 0x0f, 0x38, 0xcd, 0x00, }, 5, 0, "", "",
666+"41 0f 38 cd 00 \tsha256msg2 (%r8),%xmm0",},
667+{{0x0f, 0x38, 0xcd, 0x04, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
668+"0f 38 cd 04 25 78 56 34 12 \tsha256msg2 0x12345678,%xmm0",},
669+{{0x0f, 0x38, 0xcd, 0x18, }, 4, 0, "", "",
670+"0f 38 cd 18 \tsha256msg2 (%rax),%xmm3",},
671+{{0x0f, 0x38, 0xcd, 0x04, 0x01, }, 5, 0, "", "",
672+"0f 38 cd 04 01 \tsha256msg2 (%rcx,%rax,1),%xmm0",},
673+{{0x0f, 0x38, 0xcd, 0x04, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
674+"0f 38 cd 04 05 78 56 34 12 \tsha256msg2 0x12345678(,%rax,1),%xmm0",},
675+{{0x0f, 0x38, 0xcd, 0x04, 0x08, }, 5, 0, "", "",
676+"0f 38 cd 04 08 \tsha256msg2 (%rax,%rcx,1),%xmm0",},
677+{{0x0f, 0x38, 0xcd, 0x04, 0xc8, }, 5, 0, "", "",
678+"0f 38 cd 04 c8 \tsha256msg2 (%rax,%rcx,8),%xmm0",},
679+{{0x0f, 0x38, 0xcd, 0x40, 0x12, }, 5, 0, "", "",
680+"0f 38 cd 40 12 \tsha256msg2 0x12(%rax),%xmm0",},
681+{{0x0f, 0x38, 0xcd, 0x45, 0x12, }, 5, 0, "", "",
682+"0f 38 cd 45 12 \tsha256msg2 0x12(%rbp),%xmm0",},
683+{{0x0f, 0x38, 0xcd, 0x44, 0x01, 0x12, }, 6, 0, "", "",
684+"0f 38 cd 44 01 12 \tsha256msg2 0x12(%rcx,%rax,1),%xmm0",},
685+{{0x0f, 0x38, 0xcd, 0x44, 0x05, 0x12, }, 6, 0, "", "",
686+"0f 38 cd 44 05 12 \tsha256msg2 0x12(%rbp,%rax,1),%xmm0",},
687+{{0x0f, 0x38, 0xcd, 0x44, 0x08, 0x12, }, 6, 0, "", "",
688+"0f 38 cd 44 08 12 \tsha256msg2 0x12(%rax,%rcx,1),%xmm0",},
689+{{0x0f, 0x38, 0xcd, 0x44, 0xc8, 0x12, }, 6, 0, "", "",
690+"0f 38 cd 44 c8 12 \tsha256msg2 0x12(%rax,%rcx,8),%xmm0",},
691+{{0x0f, 0x38, 0xcd, 0x80, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
692+"0f 38 cd 80 78 56 34 12 \tsha256msg2 0x12345678(%rax),%xmm0",},
693+{{0x0f, 0x38, 0xcd, 0x85, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
694+"0f 38 cd 85 78 56 34 12 \tsha256msg2 0x12345678(%rbp),%xmm0",},
695+{{0x0f, 0x38, 0xcd, 0x84, 0x01, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
696+"0f 38 cd 84 01 78 56 34 12 \tsha256msg2 0x12345678(%rcx,%rax,1),%xmm0",},
697+{{0x0f, 0x38, 0xcd, 0x84, 0x05, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
698+"0f 38 cd 84 05 78 56 34 12 \tsha256msg2 0x12345678(%rbp,%rax,1),%xmm0",},
699+{{0x0f, 0x38, 0xcd, 0x84, 0x08, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
700+"0f 38 cd 84 08 78 56 34 12 \tsha256msg2 0x12345678(%rax,%rcx,1),%xmm0",},
701+{{0x0f, 0x38, 0xcd, 0x84, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
702+"0f 38 cd 84 c8 78 56 34 12 \tsha256msg2 0x12345678(%rax,%rcx,8),%xmm0",},
703+{{0x44, 0x0f, 0x38, 0xcd, 0xbc, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 10, 0, "", "",
704+"44 0f 38 cd bc c8 78 56 34 12 \tsha256msg2 0x12345678(%rax,%rcx,8),%xmm15",},
705+{{0x66, 0x0f, 0xae, 0x38, }, 4, 0, "", "",
706+"66 0f ae 38 \tclflushopt (%rax)",},
707+{{0x66, 0x41, 0x0f, 0xae, 0x38, }, 5, 0, "", "",
708+"66 41 0f ae 38 \tclflushopt (%r8)",},
709+{{0x66, 0x0f, 0xae, 0x3c, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
710+"66 0f ae 3c 25 78 56 34 12 \tclflushopt 0x12345678",},
711+{{0x66, 0x0f, 0xae, 0xbc, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
712+"66 0f ae bc c8 78 56 34 12 \tclflushopt 0x12345678(%rax,%rcx,8)",},
713+{{0x66, 0x41, 0x0f, 0xae, 0xbc, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 10, 0, "", "",
714+"66 41 0f ae bc c8 78 56 34 12 \tclflushopt 0x12345678(%r8,%rcx,8)",},
715+{{0x0f, 0xae, 0x38, }, 3, 0, "", "",
716+"0f ae 38 \tclflush (%rax)",},
717+{{0x41, 0x0f, 0xae, 0x38, }, 4, 0, "", "",
718+"41 0f ae 38 \tclflush (%r8)",},
719+{{0x0f, 0xae, 0xf8, }, 3, 0, "", "",
720+"0f ae f8 \tsfence ",},
721+{{0x66, 0x0f, 0xae, 0x30, }, 4, 0, "", "",
722+"66 0f ae 30 \tclwb (%rax)",},
723+{{0x66, 0x41, 0x0f, 0xae, 0x30, }, 5, 0, "", "",
724+"66 41 0f ae 30 \tclwb (%r8)",},
725+{{0x66, 0x0f, 0xae, 0x34, 0x25, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
726+"66 0f ae 34 25 78 56 34 12 \tclwb 0x12345678",},
727+{{0x66, 0x0f, 0xae, 0xb4, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
728+"66 0f ae b4 c8 78 56 34 12 \tclwb 0x12345678(%rax,%rcx,8)",},
729+{{0x66, 0x41, 0x0f, 0xae, 0xb4, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 10, 0, "", "",
730+"66 41 0f ae b4 c8 78 56 34 12 \tclwb 0x12345678(%r8,%rcx,8)",},
731+{{0x0f, 0xae, 0x30, }, 3, 0, "", "",
732+"0f ae 30 \txsaveopt (%rax)",},
733+{{0x41, 0x0f, 0xae, 0x30, }, 4, 0, "", "",
734+"41 0f ae 30 \txsaveopt (%r8)",},
735+{{0x0f, 0xae, 0xf0, }, 3, 0, "", "",
736+"0f ae f0 \tmfence ",},
737+{{0x0f, 0xc7, 0x20, }, 3, 0, "", "",
738+"0f c7 20 \txsavec (%rax)",},
739+{{0x41, 0x0f, 0xc7, 0x20, }, 4, 0, "", "",
740+"41 0f c7 20 \txsavec (%r8)",},
741+{{0x0f, 0xc7, 0x24, 0x25, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
742+"0f c7 24 25 78 56 34 12 \txsavec 0x12345678",},
743+{{0x0f, 0xc7, 0xa4, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
744+"0f c7 a4 c8 78 56 34 12 \txsavec 0x12345678(%rax,%rcx,8)",},
745+{{0x41, 0x0f, 0xc7, 0xa4, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
746+"41 0f c7 a4 c8 78 56 34 12 \txsavec 0x12345678(%r8,%rcx,8)",},
747+{{0x0f, 0xc7, 0x28, }, 3, 0, "", "",
748+"0f c7 28 \txsaves (%rax)",},
749+{{0x41, 0x0f, 0xc7, 0x28, }, 4, 0, "", "",
750+"41 0f c7 28 \txsaves (%r8)",},
751+{{0x0f, 0xc7, 0x2c, 0x25, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
752+"0f c7 2c 25 78 56 34 12 \txsaves 0x12345678",},
753+{{0x0f, 0xc7, 0xac, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
754+"0f c7 ac c8 78 56 34 12 \txsaves 0x12345678(%rax,%rcx,8)",},
755+{{0x41, 0x0f, 0xc7, 0xac, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
756+"41 0f c7 ac c8 78 56 34 12 \txsaves 0x12345678(%r8,%rcx,8)",},
757+{{0x0f, 0xc7, 0x18, }, 3, 0, "", "",
758+"0f c7 18 \txrstors (%rax)",},
759+{{0x41, 0x0f, 0xc7, 0x18, }, 4, 0, "", "",
760+"41 0f c7 18 \txrstors (%r8)",},
761+{{0x0f, 0xc7, 0x1c, 0x25, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
762+"0f c7 1c 25 78 56 34 12 \txrstors 0x12345678",},
763+{{0x0f, 0xc7, 0x9c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
764+"0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%rax,%rcx,8)",},
765+{{0x41, 0x0f, 0xc7, 0x9c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
766+"41 0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%r8,%rcx,8)",},
767+{{0x66, 0x0f, 0xae, 0xf8, }, 4, 0, "", "",
768+"66 0f ae f8 \tpcommit ",},
tools/perf/arch/x86/tests/insn-x86-dat-src.c+877−0
@@ -0,0 +1,877 @@
1+/*
2+ * This file contains instructions for testing by the test titled:
3+ *
4+ * "Test x86 instruction decoder - new instructions"
5+ *
6+ * Note that the 'Expecting' comment lines are consumed by the
7+ * gen-insn-x86-dat.awk script and have the format:
8+ *
9+ * Expecting: <op> <branch> <rel>
10+ *
11+ * If this file is changed, remember to run the gen-insn-x86-dat.sh
12+ * script and commit the result.
13+ *
14+ * Refer to insn-x86.c for more details.
15+ */
16+
17+int main(void)
18+{
19+ /* Following line is a marker for the awk script - do not change */
20+ asm volatile("rdtsc"); /* Start here */
21+
22+#ifdef __x86_64__
23+
24+ /* bndmk m64, bnd */
25+
26+ asm volatile("bndmk (%rax), %bnd0");
27+ asm volatile("bndmk (%r8), %bnd0");
28+ asm volatile("bndmk (0x12345678), %bnd0");
29+ asm volatile("bndmk (%rax), %bnd3");
30+ asm volatile("bndmk (%rcx,%rax,1), %bnd0");
31+ asm volatile("bndmk 0x12345678(,%rax,1), %bnd0");
32+ asm volatile("bndmk (%rax,%rcx,1), %bnd0");
33+ asm volatile("bndmk (%rax,%rcx,8), %bnd0");
34+ asm volatile("bndmk 0x12(%rax), %bnd0");
35+ asm volatile("bndmk 0x12(%rbp), %bnd0");
36+ asm volatile("bndmk 0x12(%rcx,%rax,1), %bnd0");
37+ asm volatile("bndmk 0x12(%rbp,%rax,1), %bnd0");
38+ asm volatile("bndmk 0x12(%rax,%rcx,1), %bnd0");
39+ asm volatile("bndmk 0x12(%rax,%rcx,8), %bnd0");
40+ asm volatile("bndmk 0x12345678(%rax), %bnd0");
41+ asm volatile("bndmk 0x12345678(%rbp), %bnd0");
42+ asm volatile("bndmk 0x12345678(%rcx,%rax,1), %bnd0");
43+ asm volatile("bndmk 0x12345678(%rbp,%rax,1), %bnd0");
44+ asm volatile("bndmk 0x12345678(%rax,%rcx,1), %bnd0");
45+ asm volatile("bndmk 0x12345678(%rax,%rcx,8), %bnd0");
46+
47+ /* bndcl r/m64, bnd */
48+
49+ asm volatile("bndcl (%rax), %bnd0");
50+ asm volatile("bndcl (%r8), %bnd0");
51+ asm volatile("bndcl (0x12345678), %bnd0");
52+ asm volatile("bndcl (%rax), %bnd3");
53+ asm volatile("bndcl (%rcx,%rax,1), %bnd0");
54+ asm volatile("bndcl 0x12345678(,%rax,1), %bnd0");
55+ asm volatile("bndcl (%rax,%rcx,1), %bnd0");
56+ asm volatile("bndcl (%rax,%rcx,8), %bnd0");
57+ asm volatile("bndcl 0x12(%rax), %bnd0");
58+ asm volatile("bndcl 0x12(%rbp), %bnd0");
59+ asm volatile("bndcl 0x12(%rcx,%rax,1), %bnd0");
60+ asm volatile("bndcl 0x12(%rbp,%rax,1), %bnd0");
61+ asm volatile("bndcl 0x12(%rax,%rcx,1), %bnd0");
62+ asm volatile("bndcl 0x12(%rax,%rcx,8), %bnd0");
63+ asm volatile("bndcl 0x12345678(%rax), %bnd0");
64+ asm volatile("bndcl 0x12345678(%rbp), %bnd0");
65+ asm volatile("bndcl 0x12345678(%rcx,%rax,1), %bnd0");
66+ asm volatile("bndcl 0x12345678(%rbp,%rax,1), %bnd0");
67+ asm volatile("bndcl 0x12345678(%rax,%rcx,1), %bnd0");
68+ asm volatile("bndcl 0x12345678(%rax,%rcx,8), %bnd0");
69+ asm volatile("bndcl %rax, %bnd0");
70+
71+ /* bndcu r/m64, bnd */
72+
73+ asm volatile("bndcu (%rax), %bnd0");
74+ asm volatile("bndcu (%r8), %bnd0");
75+ asm volatile("bndcu (0x12345678), %bnd0");
76+ asm volatile("bndcu (%rax), %bnd3");
77+ asm volatile("bndcu (%rcx,%rax,1), %bnd0");
78+ asm volatile("bndcu 0x12345678(,%rax,1), %bnd0");
79+ asm volatile("bndcu (%rax,%rcx,1), %bnd0");
80+ asm volatile("bndcu (%rax,%rcx,8), %bnd0");
81+ asm volatile("bndcu 0x12(%rax), %bnd0");
82+ asm volatile("bndcu 0x12(%rbp), %bnd0");
83+ asm volatile("bndcu 0x12(%rcx,%rax,1), %bnd0");
84+ asm volatile("bndcu 0x12(%rbp,%rax,1), %bnd0");
85+ asm volatile("bndcu 0x12(%rax,%rcx,1), %bnd0");
86+ asm volatile("bndcu 0x12(%rax,%rcx,8), %bnd0");
87+ asm volatile("bndcu 0x12345678(%rax), %bnd0");
88+ asm volatile("bndcu 0x12345678(%rbp), %bnd0");
89+ asm volatile("bndcu 0x12345678(%rcx,%rax,1), %bnd0");
90+ asm volatile("bndcu 0x12345678(%rbp,%rax,1), %bnd0");
91+ asm volatile("bndcu 0x12345678(%rax,%rcx,1), %bnd0");
92+ asm volatile("bndcu 0x12345678(%rax,%rcx,8), %bnd0");
93+ asm volatile("bndcu %rax, %bnd0");
94+
95+ /* bndcn r/m64, bnd */
96+
97+ asm volatile("bndcn (%rax), %bnd0");
98+ asm volatile("bndcn (%r8), %bnd0");
99+ asm volatile("bndcn (0x12345678), %bnd0");
100+ asm volatile("bndcn (%rax), %bnd3");
101+ asm volatile("bndcn (%rcx,%rax,1), %bnd0");
102+ asm volatile("bndcn 0x12345678(,%rax,1), %bnd0");
103+ asm volatile("bndcn (%rax,%rcx,1), %bnd0");
104+ asm volatile("bndcn (%rax,%rcx,8), %bnd0");
105+ asm volatile("bndcn 0x12(%rax), %bnd0");
106+ asm volatile("bndcn 0x12(%rbp), %bnd0");
107+ asm volatile("bndcn 0x12(%rcx,%rax,1), %bnd0");
108+ asm volatile("bndcn 0x12(%rbp,%rax,1), %bnd0");
109+ asm volatile("bndcn 0x12(%rax,%rcx,1), %bnd0");
110+ asm volatile("bndcn 0x12(%rax,%rcx,8), %bnd0");
111+ asm volatile("bndcn 0x12345678(%rax), %bnd0");
112+ asm volatile("bndcn 0x12345678(%rbp), %bnd0");
113+ asm volatile("bndcn 0x12345678(%rcx,%rax,1), %bnd0");
114+ asm volatile("bndcn 0x12345678(%rbp,%rax,1), %bnd0");
115+ asm volatile("bndcn 0x12345678(%rax,%rcx,1), %bnd0");
116+ asm volatile("bndcn 0x12345678(%rax,%rcx,8), %bnd0");
117+ asm volatile("bndcn %rax, %bnd0");
118+
119+ /* bndmov m128, bnd */
120+
121+ asm volatile("bndmov (%rax), %bnd0");
122+ asm volatile("bndmov (%r8), %bnd0");
123+ asm volatile("bndmov (0x12345678), %bnd0");
124+ asm volatile("bndmov (%rax), %bnd3");
125+ asm volatile("bndmov (%rcx,%rax,1), %bnd0");
126+ asm volatile("bndmov 0x12345678(,%rax,1), %bnd0");
127+ asm volatile("bndmov (%rax,%rcx,1), %bnd0");
128+ asm volatile("bndmov (%rax,%rcx,8), %bnd0");
129+ asm volatile("bndmov 0x12(%rax), %bnd0");
130+ asm volatile("bndmov 0x12(%rbp), %bnd0");
131+ asm volatile("bndmov 0x12(%rcx,%rax,1), %bnd0");
132+ asm volatile("bndmov 0x12(%rbp,%rax,1), %bnd0");
133+ asm volatile("bndmov 0x12(%rax,%rcx,1), %bnd0");
134+ asm volatile("bndmov 0x12(%rax,%rcx,8), %bnd0");
135+ asm volatile("bndmov 0x12345678(%rax), %bnd0");
136+ asm volatile("bndmov 0x12345678(%rbp), %bnd0");
137+ asm volatile("bndmov 0x12345678(%rcx,%rax,1), %bnd0");
138+ asm volatile("bndmov 0x12345678(%rbp,%rax,1), %bnd0");
139+ asm volatile("bndmov 0x12345678(%rax,%rcx,1), %bnd0");
140+ asm volatile("bndmov 0x12345678(%rax,%rcx,8), %bnd0");
141+
142+ /* bndmov bnd, m128 */
143+
144+ asm volatile("bndmov %bnd0, (%rax)");
145+ asm volatile("bndmov %bnd0, (%r8)");
146+ asm volatile("bndmov %bnd0, (0x12345678)");
147+ asm volatile("bndmov %bnd3, (%rax)");
148+ asm volatile("bndmov %bnd0, (%rcx,%rax,1)");
149+ asm volatile("bndmov %bnd0, 0x12345678(,%rax,1)");
150+ asm volatile("bndmov %bnd0, (%rax,%rcx,1)");
151+ asm volatile("bndmov %bnd0, (%rax,%rcx,8)");
152+ asm volatile("bndmov %bnd0, 0x12(%rax)");
153+ asm volatile("bndmov %bnd0, 0x12(%rbp)");
154+ asm volatile("bndmov %bnd0, 0x12(%rcx,%rax,1)");
155+ asm volatile("bndmov %bnd0, 0x12(%rbp,%rax,1)");
156+ asm volatile("bndmov %bnd0, 0x12(%rax,%rcx,1)");
157+ asm volatile("bndmov %bnd0, 0x12(%rax,%rcx,8)");
158+ asm volatile("bndmov %bnd0, 0x12345678(%rax)");
159+ asm volatile("bndmov %bnd0, 0x12345678(%rbp)");
160+ asm volatile("bndmov %bnd0, 0x12345678(%rcx,%rax,1)");
161+ asm volatile("bndmov %bnd0, 0x12345678(%rbp,%rax,1)");
162+ asm volatile("bndmov %bnd0, 0x12345678(%rax,%rcx,1)");
163+ asm volatile("bndmov %bnd0, 0x12345678(%rax,%rcx,8)");
164+
165+ /* bndmov bnd2, bnd1 */
166+
167+ asm volatile("bndmov %bnd0, %bnd1");
168+ asm volatile("bndmov %bnd1, %bnd0");
169+
170+ /* bndldx mib, bnd */
171+
172+ asm volatile("bndldx (%rax), %bnd0");
173+ asm volatile("bndldx (%r8), %bnd0");
174+ asm volatile("bndldx (0x12345678), %bnd0");
175+ asm volatile("bndldx (%rax), %bnd3");
176+ asm volatile("bndldx (%rcx,%rax,1), %bnd0");
177+ asm volatile("bndldx 0x12345678(,%rax,1), %bnd0");
178+ asm volatile("bndldx (%rax,%rcx,1), %bnd0");
179+ asm volatile("bndldx 0x12(%rax), %bnd0");
180+ asm volatile("bndldx 0x12(%rbp), %bnd0");
181+ asm volatile("bndldx 0x12(%rcx,%rax,1), %bnd0");
182+ asm volatile("bndldx 0x12(%rbp,%rax,1), %bnd0");
183+ asm volatile("bndldx 0x12(%rax,%rcx,1), %bnd0");
184+ asm volatile("bndldx 0x12345678(%rax), %bnd0");
185+ asm volatile("bndldx 0x12345678(%rbp), %bnd0");
186+ asm volatile("bndldx 0x12345678(%rcx,%rax,1), %bnd0");
187+ asm volatile("bndldx 0x12345678(%rbp,%rax,1), %bnd0");
188+ asm volatile("bndldx 0x12345678(%rax,%rcx,1), %bnd0");
189+
190+ /* bndstx bnd, mib */
191+
192+ asm volatile("bndstx %bnd0, (%rax)");
193+ asm volatile("bndstx %bnd0, (%r8)");
194+ asm volatile("bndstx %bnd0, (0x12345678)");
195+ asm volatile("bndstx %bnd3, (%rax)");
196+ asm volatile("bndstx %bnd0, (%rcx,%rax,1)");
197+ asm volatile("bndstx %bnd0, 0x12345678(,%rax,1)");
198+ asm volatile("bndstx %bnd0, (%rax,%rcx,1)");
199+ asm volatile("bndstx %bnd0, 0x12(%rax)");
200+ asm volatile("bndstx %bnd0, 0x12(%rbp)");
201+ asm volatile("bndstx %bnd0, 0x12(%rcx,%rax,1)");
202+ asm volatile("bndstx %bnd0, 0x12(%rbp,%rax,1)");
203+ asm volatile("bndstx %bnd0, 0x12(%rax,%rcx,1)");
204+ asm volatile("bndstx %bnd0, 0x12345678(%rax)");
205+ asm volatile("bndstx %bnd0, 0x12345678(%rbp)");
206+ asm volatile("bndstx %bnd0, 0x12345678(%rcx,%rax,1)");
207+ asm volatile("bndstx %bnd0, 0x12345678(%rbp,%rax,1)");
208+ asm volatile("bndstx %bnd0, 0x12345678(%rax,%rcx,1)");
209+
210+ /* bnd prefix on call, ret, jmp and all jcc */
211+
212+ asm volatile("bnd call label1"); /* Expecting: call unconditional 0 */
213+ asm volatile("bnd call *(%eax)"); /* Expecting: call indirect 0 */
214+ asm volatile("bnd ret"); /* Expecting: ret indirect 0 */
215+ asm volatile("bnd jmp label1"); /* Expecting: jmp unconditional 0 */
216+ asm volatile("bnd jmp label1"); /* Expecting: jmp unconditional 0 */
217+ asm volatile("bnd jmp *(%ecx)"); /* Expecting: jmp indirect 0 */
218+ asm volatile("bnd jne label1"); /* Expecting: jcc conditional 0 */
219+
220+ /* sha1rnds4 imm8, xmm2/m128, xmm1 */
221+
222+ asm volatile("sha1rnds4 $0x0, %xmm1, %xmm0");
223+ asm volatile("sha1rnds4 $0x91, %xmm7, %xmm2");
224+ asm volatile("sha1rnds4 $0x91, %xmm8, %xmm0");
225+ asm volatile("sha1rnds4 $0x91, %xmm7, %xmm8");
226+ asm volatile("sha1rnds4 $0x91, %xmm15, %xmm8");
227+ asm volatile("sha1rnds4 $0x91, (%rax), %xmm0");
228+ asm volatile("sha1rnds4 $0x91, (%r8), %xmm0");
229+ asm volatile("sha1rnds4 $0x91, (0x12345678), %xmm0");
230+ asm volatile("sha1rnds4 $0x91, (%rax), %xmm3");
231+ asm volatile("sha1rnds4 $0x91, (%rcx,%rax,1), %xmm0");
232+ asm volatile("sha1rnds4 $0x91, 0x12345678(,%rax,1), %xmm0");
233+ asm volatile("sha1rnds4 $0x91, (%rax,%rcx,1), %xmm0");
234+ asm volatile("sha1rnds4 $0x91, (%rax,%rcx,8), %xmm0");
235+ asm volatile("sha1rnds4 $0x91, 0x12(%rax), %xmm0");
236+ asm volatile("sha1rnds4 $0x91, 0x12(%rbp), %xmm0");
237+ asm volatile("sha1rnds4 $0x91, 0x12(%rcx,%rax,1), %xmm0");
238+ asm volatile("sha1rnds4 $0x91, 0x12(%rbp,%rax,1), %xmm0");
239+ asm volatile("sha1rnds4 $0x91, 0x12(%rax,%rcx,1), %xmm0");
240+ asm volatile("sha1rnds4 $0x91, 0x12(%rax,%rcx,8), %xmm0");
241+ asm volatile("sha1rnds4 $0x91, 0x12345678(%rax), %xmm0");
242+ asm volatile("sha1rnds4 $0x91, 0x12345678(%rbp), %xmm0");
243+ asm volatile("sha1rnds4 $0x91, 0x12345678(%rcx,%rax,1), %xmm0");
244+ asm volatile("sha1rnds4 $0x91, 0x12345678(%rbp,%rax,1), %xmm0");
245+ asm volatile("sha1rnds4 $0x91, 0x12345678(%rax,%rcx,1), %xmm0");
246+ asm volatile("sha1rnds4 $0x91, 0x12345678(%rax,%rcx,8), %xmm0");
247+ asm volatile("sha1rnds4 $0x91, 0x12345678(%rax,%rcx,8), %xmm15");
248+
249+ /* sha1nexte xmm2/m128, xmm1 */
250+
251+ asm volatile("sha1nexte %xmm1, %xmm0");
252+ asm volatile("sha1nexte %xmm7, %xmm2");
253+ asm volatile("sha1nexte %xmm8, %xmm0");
254+ asm volatile("sha1nexte %xmm7, %xmm8");
255+ asm volatile("sha1nexte %xmm15, %xmm8");
256+ asm volatile("sha1nexte (%rax), %xmm0");
257+ asm volatile("sha1nexte (%r8), %xmm0");
258+ asm volatile("sha1nexte (0x12345678), %xmm0");
259+ asm volatile("sha1nexte (%rax), %xmm3");
260+ asm volatile("sha1nexte (%rcx,%rax,1), %xmm0");
261+ asm volatile("sha1nexte 0x12345678(,%rax,1), %xmm0");
262+ asm volatile("sha1nexte (%rax,%rcx,1), %xmm0");
263+ asm volatile("sha1nexte (%rax,%rcx,8), %xmm0");
264+ asm volatile("sha1nexte 0x12(%rax), %xmm0");
265+ asm volatile("sha1nexte 0x12(%rbp), %xmm0");
266+ asm volatile("sha1nexte 0x12(%rcx,%rax,1), %xmm0");
267+ asm volatile("sha1nexte 0x12(%rbp,%rax,1), %xmm0");
268+ asm volatile("sha1nexte 0x12(%rax,%rcx,1), %xmm0");
269+ asm volatile("sha1nexte 0x12(%rax,%rcx,8), %xmm0");
270+ asm volatile("sha1nexte 0x12345678(%rax), %xmm0");
271+ asm volatile("sha1nexte 0x12345678(%rbp), %xmm0");
272+ asm volatile("sha1nexte 0x12345678(%rcx,%rax,1), %xmm0");
273+ asm volatile("sha1nexte 0x12345678(%rbp,%rax,1), %xmm0");
274+ asm volatile("sha1nexte 0x12345678(%rax,%rcx,1), %xmm0");
275+ asm volatile("sha1nexte 0x12345678(%rax,%rcx,8), %xmm0");
276+ asm volatile("sha1nexte 0x12345678(%rax,%rcx,8), %xmm15");
277+
278+ /* sha1msg1 xmm2/m128, xmm1 */
279+
280+ asm volatile("sha1msg1 %xmm1, %xmm0");
281+ asm volatile("sha1msg1 %xmm7, %xmm2");
282+ asm volatile("sha1msg1 %xmm8, %xmm0");
283+ asm volatile("sha1msg1 %xmm7, %xmm8");
284+ asm volatile("sha1msg1 %xmm15, %xmm8");
285+ asm volatile("sha1msg1 (%rax), %xmm0");
286+ asm volatile("sha1msg1 (%r8), %xmm0");
287+ asm volatile("sha1msg1 (0x12345678), %xmm0");
288+ asm volatile("sha1msg1 (%rax), %xmm3");
289+ asm volatile("sha1msg1 (%rcx,%rax,1), %xmm0");
290+ asm volatile("sha1msg1 0x12345678(,%rax,1), %xmm0");
291+ asm volatile("sha1msg1 (%rax,%rcx,1), %xmm0");
292+ asm volatile("sha1msg1 (%rax,%rcx,8), %xmm0");
293+ asm volatile("sha1msg1 0x12(%rax), %xmm0");
294+ asm volatile("sha1msg1 0x12(%rbp), %xmm0");
295+ asm volatile("sha1msg1 0x12(%rcx,%rax,1), %xmm0");
296+ asm volatile("sha1msg1 0x12(%rbp,%rax,1), %xmm0");
297+ asm volatile("sha1msg1 0x12(%rax,%rcx,1), %xmm0");
298+ asm volatile("sha1msg1 0x12(%rax,%rcx,8), %xmm0");
299+ asm volatile("sha1msg1 0x12345678(%rax), %xmm0");
300+ asm volatile("sha1msg1 0x12345678(%rbp), %xmm0");
301+ asm volatile("sha1msg1 0x12345678(%rcx,%rax,1), %xmm0");
302+ asm volatile("sha1msg1 0x12345678(%rbp,%rax,1), %xmm0");
303+ asm volatile("sha1msg1 0x12345678(%rax,%rcx,1), %xmm0");
304+ asm volatile("sha1msg1 0x12345678(%rax,%rcx,8), %xmm0");
305+ asm volatile("sha1msg1 0x12345678(%rax,%rcx,8), %xmm15");
306+
307+ /* sha1msg2 xmm2/m128, xmm1 */
308+
309+ asm volatile("sha1msg2 %xmm1, %xmm0");
310+ asm volatile("sha1msg2 %xmm7, %xmm2");
311+ asm volatile("sha1msg2 %xmm8, %xmm0");
312+ asm volatile("sha1msg2 %xmm7, %xmm8");
313+ asm volatile("sha1msg2 %xmm15, %xmm8");
314+ asm volatile("sha1msg2 (%rax), %xmm0");
315+ asm volatile("sha1msg2 (%r8), %xmm0");
316+ asm volatile("sha1msg2 (0x12345678), %xmm0");
317+ asm volatile("sha1msg2 (%rax), %xmm3");
318+ asm volatile("sha1msg2 (%rcx,%rax,1), %xmm0");
319+ asm volatile("sha1msg2 0x12345678(,%rax,1), %xmm0");
320+ asm volatile("sha1msg2 (%rax,%rcx,1), %xmm0");
321+ asm volatile("sha1msg2 (%rax,%rcx,8), %xmm0");
322+ asm volatile("sha1msg2 0x12(%rax), %xmm0");
323+ asm volatile("sha1msg2 0x12(%rbp), %xmm0");
324+ asm volatile("sha1msg2 0x12(%rcx,%rax,1), %xmm0");
325+ asm volatile("sha1msg2 0x12(%rbp,%rax,1), %xmm0");
326+ asm volatile("sha1msg2 0x12(%rax,%rcx,1), %xmm0");
327+ asm volatile("sha1msg2 0x12(%rax,%rcx,8), %xmm0");
328+ asm volatile("sha1msg2 0x12345678(%rax), %xmm0");
329+ asm volatile("sha1msg2 0x12345678(%rbp), %xmm0");
330+ asm volatile("sha1msg2 0x12345678(%rcx,%rax,1), %xmm0");
331+ asm volatile("sha1msg2 0x12345678(%rbp,%rax,1), %xmm0");
332+ asm volatile("sha1msg2 0x12345678(%rax,%rcx,1), %xmm0");
333+ asm volatile("sha1msg2 0x12345678(%rax,%rcx,8), %xmm0");
334+ asm volatile("sha1msg2 0x12345678(%rax,%rcx,8), %xmm15");
335+
336+ /* sha256rnds2 <XMM0>, xmm2/m128, xmm1 */
337+ /* Note sha256rnds2 has an implicit operand 'xmm0' */
338+
339+ asm volatile("sha256rnds2 %xmm4, %xmm1");
340+ asm volatile("sha256rnds2 %xmm7, %xmm2");
341+ asm volatile("sha256rnds2 %xmm8, %xmm1");
342+ asm volatile("sha256rnds2 %xmm7, %xmm8");
343+ asm volatile("sha256rnds2 %xmm15, %xmm8");
344+ asm volatile("sha256rnds2 (%rax), %xmm1");
345+ asm volatile("sha256rnds2 (%r8), %xmm1");
346+ asm volatile("sha256rnds2 (0x12345678), %xmm1");
347+ asm volatile("sha256rnds2 (%rax), %xmm3");
348+ asm volatile("sha256rnds2 (%rcx,%rax,1), %xmm1");
349+ asm volatile("sha256rnds2 0x12345678(,%rax,1), %xmm1");
350+ asm volatile("sha256rnds2 (%rax,%rcx,1), %xmm1");
351+ asm volatile("sha256rnds2 (%rax,%rcx,8), %xmm1");
352+ asm volatile("sha256rnds2 0x12(%rax), %xmm1");
353+ asm volatile("sha256rnds2 0x12(%rbp), %xmm1");
354+ asm volatile("sha256rnds2 0x12(%rcx,%rax,1), %xmm1");
355+ asm volatile("sha256rnds2 0x12(%rbp,%rax,1), %xmm1");
356+ asm volatile("sha256rnds2 0x12(%rax,%rcx,1), %xmm1");
357+ asm volatile("sha256rnds2 0x12(%rax,%rcx,8), %xmm1");
358+ asm volatile("sha256rnds2 0x12345678(%rax), %xmm1");
359+ asm volatile("sha256rnds2 0x12345678(%rbp), %xmm1");
360+ asm volatile("sha256rnds2 0x12345678(%rcx,%rax,1), %xmm1");
361+ asm volatile("sha256rnds2 0x12345678(%rbp,%rax,1), %xmm1");
362+ asm volatile("sha256rnds2 0x12345678(%rax,%rcx,1), %xmm1");
363+ asm volatile("sha256rnds2 0x12345678(%rax,%rcx,8), %xmm1");
364+ asm volatile("sha256rnds2 0x12345678(%rax,%rcx,8), %xmm15");
365+
366+ /* sha256msg1 xmm2/m128, xmm1 */
367+
368+ asm volatile("sha256msg1 %xmm1, %xmm0");
369+ asm volatile("sha256msg1 %xmm7, %xmm2");
370+ asm volatile("sha256msg1 %xmm8, %xmm0");
371+ asm volatile("sha256msg1 %xmm7, %xmm8");
372+ asm volatile("sha256msg1 %xmm15, %xmm8");
373+ asm volatile("sha256msg1 (%rax), %xmm0");
374+ asm volatile("sha256msg1 (%r8), %xmm0");
375+ asm volatile("sha256msg1 (0x12345678), %xmm0");
376+ asm volatile("sha256msg1 (%rax), %xmm3");
377+ asm volatile("sha256msg1 (%rcx,%rax,1), %xmm0");
378+ asm volatile("sha256msg1 0x12345678(,%rax,1), %xmm0");
379+ asm volatile("sha256msg1 (%rax,%rcx,1), %xmm0");
380+ asm volatile("sha256msg1 (%rax,%rcx,8), %xmm0");
381+ asm volatile("sha256msg1 0x12(%rax), %xmm0");
382+ asm volatile("sha256msg1 0x12(%rbp), %xmm0");
383+ asm volatile("sha256msg1 0x12(%rcx,%rax,1), %xmm0");
384+ asm volatile("sha256msg1 0x12(%rbp,%rax,1), %xmm0");
385+ asm volatile("sha256msg1 0x12(%rax,%rcx,1), %xmm0");
386+ asm volatile("sha256msg1 0x12(%rax,%rcx,8), %xmm0");
387+ asm volatile("sha256msg1 0x12345678(%rax), %xmm0");
388+ asm volatile("sha256msg1 0x12345678(%rbp), %xmm0");
389+ asm volatile("sha256msg1 0x12345678(%rcx,%rax,1), %xmm0");
390+ asm volatile("sha256msg1 0x12345678(%rbp,%rax,1), %xmm0");
391+ asm volatile("sha256msg1 0x12345678(%rax,%rcx,1), %xmm0");
392+ asm volatile("sha256msg1 0x12345678(%rax,%rcx,8), %xmm0");
393+ asm volatile("sha256msg1 0x12345678(%rax,%rcx,8), %xmm15");
394+
395+ /* sha256msg2 xmm2/m128, xmm1 */
396+
397+ asm volatile("sha256msg2 %xmm1, %xmm0");
398+ asm volatile("sha256msg2 %xmm7, %xmm2");
399+ asm volatile("sha256msg2 %xmm8, %xmm0");
400+ asm volatile("sha256msg2 %xmm7, %xmm8");
401+ asm volatile("sha256msg2 %xmm15, %xmm8");
402+ asm volatile("sha256msg2 (%rax), %xmm0");
403+ asm volatile("sha256msg2 (%r8), %xmm0");
404+ asm volatile("sha256msg2 (0x12345678), %xmm0");
405+ asm volatile("sha256msg2 (%rax), %xmm3");
406+ asm volatile("sha256msg2 (%rcx,%rax,1), %xmm0");
407+ asm volatile("sha256msg2 0x12345678(,%rax,1), %xmm0");
408+ asm volatile("sha256msg2 (%rax,%rcx,1), %xmm0");
409+ asm volatile("sha256msg2 (%rax,%rcx,8), %xmm0");
410+ asm volatile("sha256msg2 0x12(%rax), %xmm0");
411+ asm volatile("sha256msg2 0x12(%rbp), %xmm0");
412+ asm volatile("sha256msg2 0x12(%rcx,%rax,1), %xmm0");
413+ asm volatile("sha256msg2 0x12(%rbp,%rax,1), %xmm0");
414+ asm volatile("sha256msg2 0x12(%rax,%rcx,1), %xmm0");
415+ asm volatile("sha256msg2 0x12(%rax,%rcx,8), %xmm0");
416+ asm volatile("sha256msg2 0x12345678(%rax), %xmm0");
417+ asm volatile("sha256msg2 0x12345678(%rbp), %xmm0");
418+ asm volatile("sha256msg2 0x12345678(%rcx,%rax,1), %xmm0");
419+ asm volatile("sha256msg2 0x12345678(%rbp,%rax,1), %xmm0");
420+ asm volatile("sha256msg2 0x12345678(%rax,%rcx,1), %xmm0");
421+ asm volatile("sha256msg2 0x12345678(%rax,%rcx,8), %xmm0");
422+ asm volatile("sha256msg2 0x12345678(%rax,%rcx,8), %xmm15");
423+
424+ /* clflushopt m8 */
425+
426+ asm volatile("clflushopt (%rax)");
427+ asm volatile("clflushopt (%r8)");
428+ asm volatile("clflushopt (0x12345678)");
429+ asm volatile("clflushopt 0x12345678(%rax,%rcx,8)");
430+ asm volatile("clflushopt 0x12345678(%r8,%rcx,8)");
431+ /* Also check instructions in the same group encoding as clflushopt */
432+ asm volatile("clflush (%rax)");
433+ asm volatile("clflush (%r8)");
434+ asm volatile("sfence");
435+
436+ /* clwb m8 */
437+
438+ asm volatile("clwb (%rax)");
439+ asm volatile("clwb (%r8)");
440+ asm volatile("clwb (0x12345678)");
441+ asm volatile("clwb 0x12345678(%rax,%rcx,8)");
442+ asm volatile("clwb 0x12345678(%r8,%rcx,8)");
443+ /* Also check instructions in the same group encoding as clwb */
444+ asm volatile("xsaveopt (%rax)");
445+ asm volatile("xsaveopt (%r8)");
446+ asm volatile("mfence");
447+
448+ /* xsavec mem */
449+
450+ asm volatile("xsavec (%rax)");
451+ asm volatile("xsavec (%r8)");
452+ asm volatile("xsavec (0x12345678)");
453+ asm volatile("xsavec 0x12345678(%rax,%rcx,8)");
454+ asm volatile("xsavec 0x12345678(%r8,%rcx,8)");
455+
456+ /* xsaves mem */
457+
458+ asm volatile("xsaves (%rax)");
459+ asm volatile("xsaves (%r8)");
460+ asm volatile("xsaves (0x12345678)");
461+ asm volatile("xsaves 0x12345678(%rax,%rcx,8)");
462+ asm volatile("xsaves 0x12345678(%r8,%rcx,8)");
463+
464+ /* xrstors mem */
465+
466+ asm volatile("xrstors (%rax)");
467+ asm volatile("xrstors (%r8)");
468+ asm volatile("xrstors (0x12345678)");
469+ asm volatile("xrstors 0x12345678(%rax,%rcx,8)");
470+ asm volatile("xrstors 0x12345678(%r8,%rcx,8)");
471+
472+#else /* #ifdef __x86_64__ */
473+
474+ /* bndmk m32, bnd */
475+
476+ asm volatile("bndmk (%eax), %bnd0");
477+ asm volatile("bndmk (0x12345678), %bnd0");
478+ asm volatile("bndmk (%eax), %bnd3");
479+ asm volatile("bndmk (%ecx,%eax,1), %bnd0");
480+ asm volatile("bndmk 0x12345678(,%eax,1), %bnd0");
481+ asm volatile("bndmk (%eax,%ecx,1), %bnd0");
482+ asm volatile("bndmk (%eax,%ecx,8), %bnd0");
483+ asm volatile("bndmk 0x12(%eax), %bnd0");
484+ asm volatile("bndmk 0x12(%ebp), %bnd0");
485+ asm volatile("bndmk 0x12(%ecx,%eax,1), %bnd0");
486+ asm volatile("bndmk 0x12(%ebp,%eax,1), %bnd0");
487+ asm volatile("bndmk 0x12(%eax,%ecx,1), %bnd0");
488+ asm volatile("bndmk 0x12(%eax,%ecx,8), %bnd0");
489+ asm volatile("bndmk 0x12345678(%eax), %bnd0");
490+ asm volatile("bndmk 0x12345678(%ebp), %bnd0");
491+ asm volatile("bndmk 0x12345678(%ecx,%eax,1), %bnd0");
492+ asm volatile("bndmk 0x12345678(%ebp,%eax,1), %bnd0");
493+ asm volatile("bndmk 0x12345678(%eax,%ecx,1), %bnd0");
494+ asm volatile("bndmk 0x12345678(%eax,%ecx,8), %bnd0");
495+
496+ /* bndcl r/m32, bnd */
497+
498+ asm volatile("bndcl (%eax), %bnd0");
499+ asm volatile("bndcl (0x12345678), %bnd0");
500+ asm volatile("bndcl (%eax), %bnd3");
501+ asm volatile("bndcl (%ecx,%eax,1), %bnd0");
502+ asm volatile("bndcl 0x12345678(,%eax,1), %bnd0");
503+ asm volatile("bndcl (%eax,%ecx,1), %bnd0");
504+ asm volatile("bndcl (%eax,%ecx,8), %bnd0");
505+ asm volatile("bndcl 0x12(%eax), %bnd0");
506+ asm volatile("bndcl 0x12(%ebp), %bnd0");
507+ asm volatile("bndcl 0x12(%ecx,%eax,1), %bnd0");
508+ asm volatile("bndcl 0x12(%ebp,%eax,1), %bnd0");
509+ asm volatile("bndcl 0x12(%eax,%ecx,1), %bnd0");
510+ asm volatile("bndcl 0x12(%eax,%ecx,8), %bnd0");
511+ asm volatile("bndcl 0x12345678(%eax), %bnd0");
512+ asm volatile("bndcl 0x12345678(%ebp), %bnd0");
513+ asm volatile("bndcl 0x12345678(%ecx,%eax,1), %bnd0");
514+ asm volatile("bndcl 0x12345678(%ebp,%eax,1), %bnd0");
515+ asm volatile("bndcl 0x12345678(%eax,%ecx,1), %bnd0");
516+ asm volatile("bndcl 0x12345678(%eax,%ecx,8), %bnd0");
517+ asm volatile("bndcl %eax, %bnd0");
518+
519+ /* bndcu r/m32, bnd */
520+
521+ asm volatile("bndcu (%eax), %bnd0");
522+ asm volatile("bndcu (0x12345678), %bnd0");
523+ asm volatile("bndcu (%eax), %bnd3");
524+ asm volatile("bndcu (%ecx,%eax,1), %bnd0");
525+ asm volatile("bndcu 0x12345678(,%eax,1), %bnd0");
526+ asm volatile("bndcu (%eax,%ecx,1), %bnd0");
527+ asm volatile("bndcu (%eax,%ecx,8), %bnd0");
528+ asm volatile("bndcu 0x12(%eax), %bnd0");
529+ asm volatile("bndcu 0x12(%ebp), %bnd0");
530+ asm volatile("bndcu 0x12(%ecx,%eax,1), %bnd0");
531+ asm volatile("bndcu 0x12(%ebp,%eax,1), %bnd0");
532+ asm volatile("bndcu 0x12(%eax,%ecx,1), %bnd0");
533+ asm volatile("bndcu 0x12(%eax,%ecx,8), %bnd0");
534+ asm volatile("bndcu 0x12345678(%eax), %bnd0");
535+ asm volatile("bndcu 0x12345678(%ebp), %bnd0");
536+ asm volatile("bndcu 0x12345678(%ecx,%eax,1), %bnd0");
537+ asm volatile("bndcu 0x12345678(%ebp,%eax,1), %bnd0");
538+ asm volatile("bndcu 0x12345678(%eax,%ecx,1), %bnd0");
539+ asm volatile("bndcu 0x12345678(%eax,%ecx,8), %bnd0");
540+ asm volatile("bndcu %eax, %bnd0");
541+
542+ /* bndcn r/m32, bnd */
543+
544+ asm volatile("bndcn (%eax), %bnd0");
545+ asm volatile("bndcn (0x12345678), %bnd0");
546+ asm volatile("bndcn (%eax), %bnd3");
547+ asm volatile("bndcn (%ecx,%eax,1), %bnd0");
548+ asm volatile("bndcn 0x12345678(,%eax,1), %bnd0");
549+ asm volatile("bndcn (%eax,%ecx,1), %bnd0");
550+ asm volatile("bndcn (%eax,%ecx,8), %bnd0");
551+ asm volatile("bndcn 0x12(%eax), %bnd0");
552+ asm volatile("bndcn 0x12(%ebp), %bnd0");
553+ asm volatile("bndcn 0x12(%ecx,%eax,1), %bnd0");
554+ asm volatile("bndcn 0x12(%ebp,%eax,1), %bnd0");
555+ asm volatile("bndcn 0x12(%eax,%ecx,1), %bnd0");
556+ asm volatile("bndcn 0x12(%eax,%ecx,8), %bnd0");
557+ asm volatile("bndcn 0x12345678(%eax), %bnd0");
558+ asm volatile("bndcn 0x12345678(%ebp), %bnd0");
559+ asm volatile("bndcn 0x12345678(%ecx,%eax,1), %bnd0");
560+ asm volatile("bndcn 0x12345678(%ebp,%eax,1), %bnd0");
561+ asm volatile("bndcn 0x12345678(%eax,%ecx,1), %bnd0");
562+ asm volatile("bndcn 0x12345678(%eax,%ecx,8), %bnd0");
563+ asm volatile("bndcn %eax, %bnd0");
564+
565+ /* bndmov m64, bnd */
566+
567+ asm volatile("bndmov (%eax), %bnd0");
568+ asm volatile("bndmov (0x12345678), %bnd0");
569+ asm volatile("bndmov (%eax), %bnd3");
570+ asm volatile("bndmov (%ecx,%eax,1), %bnd0");
571+ asm volatile("bndmov 0x12345678(,%eax,1), %bnd0");
572+ asm volatile("bndmov (%eax,%ecx,1), %bnd0");
573+ asm volatile("bndmov (%eax,%ecx,8), %bnd0");
574+ asm volatile("bndmov 0x12(%eax), %bnd0");
575+ asm volatile("bndmov 0x12(%ebp), %bnd0");
576+ asm volatile("bndmov 0x12(%ecx,%eax,1), %bnd0");
577+ asm volatile("bndmov 0x12(%ebp,%eax,1), %bnd0");
578+ asm volatile("bndmov 0x12(%eax,%ecx,1), %bnd0");
579+ asm volatile("bndmov 0x12(%eax,%ecx,8), %bnd0");
580+ asm volatile("bndmov 0x12345678(%eax), %bnd0");
581+ asm volatile("bndmov 0x12345678(%ebp), %bnd0");
582+ asm volatile("bndmov 0x12345678(%ecx,%eax,1), %bnd0");
583+ asm volatile("bndmov 0x12345678(%ebp,%eax,1), %bnd0");
584+ asm volatile("bndmov 0x12345678(%eax,%ecx,1), %bnd0");
585+ asm volatile("bndmov 0x12345678(%eax,%ecx,8), %bnd0");
586+
587+ /* bndmov bnd, m64 */
588+
589+ asm volatile("bndmov %bnd0, (%eax)");
590+ asm volatile("bndmov %bnd0, (0x12345678)");
591+ asm volatile("bndmov %bnd3, (%eax)");
592+ asm volatile("bndmov %bnd0, (%ecx,%eax,1)");
593+ asm volatile("bndmov %bnd0, 0x12345678(,%eax,1)");
594+ asm volatile("bndmov %bnd0, (%eax,%ecx,1)");
595+ asm volatile("bndmov %bnd0, (%eax,%ecx,8)");
596+ asm volatile("bndmov %bnd0, 0x12(%eax)");
597+ asm volatile("bndmov %bnd0, 0x12(%ebp)");
598+ asm volatile("bndmov %bnd0, 0x12(%ecx,%eax,1)");
599+ asm volatile("bndmov %bnd0, 0x12(%ebp,%eax,1)");
600+ asm volatile("bndmov %bnd0, 0x12(%eax,%ecx,1)");
601+ asm volatile("bndmov %bnd0, 0x12(%eax,%ecx,8)");
602+ asm volatile("bndmov %bnd0, 0x12345678(%eax)");
603+ asm volatile("bndmov %bnd0, 0x12345678(%ebp)");
604+ asm volatile("bndmov %bnd0, 0x12345678(%ecx,%eax,1)");
605+ asm volatile("bndmov %bnd0, 0x12345678(%ebp,%eax,1)");
606+ asm volatile("bndmov %bnd0, 0x12345678(%eax,%ecx,1)");
607+ asm volatile("bndmov %bnd0, 0x12345678(%eax,%ecx,8)");
608+
609+ /* bndmov bnd2, bnd1 */
610+
611+ asm volatile("bndmov %bnd0, %bnd1");
612+ asm volatile("bndmov %bnd1, %bnd0");
613+
614+ /* bndldx mib, bnd */
615+
616+ asm volatile("bndldx (%eax), %bnd0");
617+ asm volatile("bndldx (0x12345678), %bnd0");
618+ asm volatile("bndldx (%eax), %bnd3");
619+ asm volatile("bndldx (%ecx,%eax,1), %bnd0");
620+ asm volatile("bndldx 0x12345678(,%eax,1), %bnd0");
621+ asm volatile("bndldx (%eax,%ecx,1), %bnd0");
622+ asm volatile("bndldx 0x12(%eax), %bnd0");
623+ asm volatile("bndldx 0x12(%ebp), %bnd0");
624+ asm volatile("bndldx 0x12(%ecx,%eax,1), %bnd0");
625+ asm volatile("bndldx 0x12(%ebp,%eax,1), %bnd0");
626+ asm volatile("bndldx 0x12(%eax,%ecx,1), %bnd0");
627+ asm volatile("bndldx 0x12345678(%eax), %bnd0");
628+ asm volatile("bndldx 0x12345678(%ebp), %bnd0");
629+ asm volatile("bndldx 0x12345678(%ecx,%eax,1), %bnd0");
630+ asm volatile("bndldx 0x12345678(%ebp,%eax,1), %bnd0");
631+ asm volatile("bndldx 0x12345678(%eax,%ecx,1), %bnd0");
632+
633+ /* bndstx bnd, mib */
634+
635+ asm volatile("bndstx %bnd0, (%eax)");
636+ asm volatile("bndstx %bnd0, (0x12345678)");
637+ asm volatile("bndstx %bnd3, (%eax)");
638+ asm volatile("bndstx %bnd0, (%ecx,%eax,1)");
639+ asm volatile("bndstx %bnd0, 0x12345678(,%eax,1)");
640+ asm volatile("bndstx %bnd0, (%eax,%ecx,1)");
641+ asm volatile("bndstx %bnd0, 0x12(%eax)");
642+ asm volatile("bndstx %bnd0, 0x12(%ebp)");
643+ asm volatile("bndstx %bnd0, 0x12(%ecx,%eax,1)");
644+ asm volatile("bndstx %bnd0, 0x12(%ebp,%eax,1)");
645+ asm volatile("bndstx %bnd0, 0x12(%eax,%ecx,1)");
646+ asm volatile("bndstx %bnd0, 0x12345678(%eax)");
647+ asm volatile("bndstx %bnd0, 0x12345678(%ebp)");
648+ asm volatile("bndstx %bnd0, 0x12345678(%ecx,%eax,1)");
649+ asm volatile("bndstx %bnd0, 0x12345678(%ebp,%eax,1)");
650+ asm volatile("bndstx %bnd0, 0x12345678(%eax,%ecx,1)");
651+
652+ /* bnd prefix on call, ret, jmp and all jcc */
653+
654+ asm volatile("bnd call label1"); /* Expecting: call unconditional 0xfffffffc */
655+ asm volatile("bnd call *(%eax)"); /* Expecting: call indirect 0 */
656+ asm volatile("bnd ret"); /* Expecting: ret indirect 0 */
657+ asm volatile("bnd jmp label1"); /* Expecting: jmp unconditional 0xfffffffc */
658+ asm volatile("bnd jmp label1"); /* Expecting: jmp unconditional 0xfffffffc */
659+ asm volatile("bnd jmp *(%ecx)"); /* Expecting: jmp indirect 0 */
660+ asm volatile("bnd jne label1"); /* Expecting: jcc conditional 0xfffffffc */
661+
662+ /* sha1rnds4 imm8, xmm2/m128, xmm1 */
663+
664+ asm volatile("sha1rnds4 $0x0, %xmm1, %xmm0");
665+ asm volatile("sha1rnds4 $0x91, %xmm7, %xmm2");
666+ asm volatile("sha1rnds4 $0x91, (%eax), %xmm0");
667+ asm volatile("sha1rnds4 $0x91, (0x12345678), %xmm0");
668+ asm volatile("sha1rnds4 $0x91, (%eax), %xmm3");
669+ asm volatile("sha1rnds4 $0x91, (%ecx,%eax,1), %xmm0");
670+ asm volatile("sha1rnds4 $0x91, 0x12345678(,%eax,1), %xmm0");
671+ asm volatile("sha1rnds4 $0x91, (%eax,%ecx,1), %xmm0");
672+ asm volatile("sha1rnds4 $0x91, (%eax,%ecx,8), %xmm0");
673+ asm volatile("sha1rnds4 $0x91, 0x12(%eax), %xmm0");
674+ asm volatile("sha1rnds4 $0x91, 0x12(%ebp), %xmm0");
675+ asm volatile("sha1rnds4 $0x91, 0x12(%ecx,%eax,1), %xmm0");
676+ asm volatile("sha1rnds4 $0x91, 0x12(%ebp,%eax,1), %xmm0");
677+ asm volatile("sha1rnds4 $0x91, 0x12(%eax,%ecx,1), %xmm0");
678+ asm volatile("sha1rnds4 $0x91, 0x12(%eax,%ecx,8), %xmm0");
679+ asm volatile("sha1rnds4 $0x91, 0x12345678(%eax), %xmm0");
680+ asm volatile("sha1rnds4 $0x91, 0x12345678(%ebp), %xmm0");
681+ asm volatile("sha1rnds4 $0x91, 0x12345678(%ecx,%eax,1), %xmm0");
682+ asm volatile("sha1rnds4 $0x91, 0x12345678(%ebp,%eax,1), %xmm0");
683+ asm volatile("sha1rnds4 $0x91, 0x12345678(%eax,%ecx,1), %xmm0");
684+ asm volatile("sha1rnds4 $0x91, 0x12345678(%eax,%ecx,8), %xmm0");
685+
686+ /* sha1nexte xmm2/m128, xmm1 */
687+
688+ asm volatile("sha1nexte %xmm1, %xmm0");
689+ asm volatile("sha1nexte %xmm7, %xmm2");
690+ asm volatile("sha1nexte (%eax), %xmm0");
691+ asm volatile("sha1nexte (0x12345678), %xmm0");
692+ asm volatile("sha1nexte (%eax), %xmm3");
693+ asm volatile("sha1nexte (%ecx,%eax,1), %xmm0");
694+ asm volatile("sha1nexte 0x12345678(,%eax,1), %xmm0");
695+ asm volatile("sha1nexte (%eax,%ecx,1), %xmm0");
696+ asm volatile("sha1nexte (%eax,%ecx,8), %xmm0");
697+ asm volatile("sha1nexte 0x12(%eax), %xmm0");
698+ asm volatile("sha1nexte 0x12(%ebp), %xmm0");
699+ asm volatile("sha1nexte 0x12(%ecx,%eax,1), %xmm0");
700+ asm volatile("sha1nexte 0x12(%ebp,%eax,1), %xmm0");
701+ asm volatile("sha1nexte 0x12(%eax,%ecx,1), %xmm0");
702+ asm volatile("sha1nexte 0x12(%eax,%ecx,8), %xmm0");
703+ asm volatile("sha1nexte 0x12345678(%eax), %xmm0");
704+ asm volatile("sha1nexte 0x12345678(%ebp), %xmm0");
705+ asm volatile("sha1nexte 0x12345678(%ecx,%eax,1), %xmm0");
706+ asm volatile("sha1nexte 0x12345678(%ebp,%eax,1), %xmm0");
707+ asm volatile("sha1nexte 0x12345678(%eax,%ecx,1), %xmm0");
708+ asm volatile("sha1nexte 0x12345678(%eax,%ecx,8), %xmm0");
709+
710+ /* sha1msg1 xmm2/m128, xmm1 */
711+
712+ asm volatile("sha1msg1 %xmm1, %xmm0");
713+ asm volatile("sha1msg1 %xmm7, %xmm2");
714+ asm volatile("sha1msg1 (%eax), %xmm0");
715+ asm volatile("sha1msg1 (0x12345678), %xmm0");
716+ asm volatile("sha1msg1 (%eax), %xmm3");
717+ asm volatile("sha1msg1 (%ecx,%eax,1), %xmm0");
718+ asm volatile("sha1msg1 0x12345678(,%eax,1), %xmm0");
719+ asm volatile("sha1msg1 (%eax,%ecx,1), %xmm0");
720+ asm volatile("sha1msg1 (%eax,%ecx,8), %xmm0");
721+ asm volatile("sha1msg1 0x12(%eax), %xmm0");
722+ asm volatile("sha1msg1 0x12(%ebp), %xmm0");
723+ asm volatile("sha1msg1 0x12(%ecx,%eax,1), %xmm0");
724+ asm volatile("sha1msg1 0x12(%ebp,%eax,1), %xmm0");
725+ asm volatile("sha1msg1 0x12(%eax,%ecx,1), %xmm0");
726+ asm volatile("sha1msg1 0x12(%eax,%ecx,8), %xmm0");
727+ asm volatile("sha1msg1 0x12345678(%eax), %xmm0");
728+ asm volatile("sha1msg1 0x12345678(%ebp), %xmm0");
729+ asm volatile("sha1msg1 0x12345678(%ecx,%eax,1), %xmm0");
730+ asm volatile("sha1msg1 0x12345678(%ebp,%eax,1), %xmm0");
731+ asm volatile("sha1msg1 0x12345678(%eax,%ecx,1), %xmm0");
732+ asm volatile("sha1msg1 0x12345678(%eax,%ecx,8), %xmm0");
733+
734+ /* sha1msg2 xmm2/m128, xmm1 */
735+
736+ asm volatile("sha1msg2 %xmm1, %xmm0");
737+ asm volatile("sha1msg2 %xmm7, %xmm2");
738+ asm volatile("sha1msg2 (%eax), %xmm0");
739+ asm volatile("sha1msg2 (0x12345678), %xmm0");
740+ asm volatile("sha1msg2 (%eax), %xmm3");
741+ asm volatile("sha1msg2 (%ecx,%eax,1), %xmm0");
742+ asm volatile("sha1msg2 0x12345678(,%eax,1), %xmm0");
743+ asm volatile("sha1msg2 (%eax,%ecx,1), %xmm0");
744+ asm volatile("sha1msg2 (%eax,%ecx,8), %xmm0");
745+ asm volatile("sha1msg2 0x12(%eax), %xmm0");
746+ asm volatile("sha1msg2 0x12(%ebp), %xmm0");
747+ asm volatile("sha1msg2 0x12(%ecx,%eax,1), %xmm0");
748+ asm volatile("sha1msg2 0x12(%ebp,%eax,1), %xmm0");
749+ asm volatile("sha1msg2 0x12(%eax,%ecx,1), %xmm0");
750+ asm volatile("sha1msg2 0x12(%eax,%ecx,8), %xmm0");
751+ asm volatile("sha1msg2 0x12345678(%eax), %xmm0");
752+ asm volatile("sha1msg2 0x12345678(%ebp), %xmm0");
753+ asm volatile("sha1msg2 0x12345678(%ecx,%eax,1), %xmm0");
754+ asm volatile("sha1msg2 0x12345678(%ebp,%eax,1), %xmm0");
755+ asm volatile("sha1msg2 0x12345678(%eax,%ecx,1), %xmm0");
756+ asm volatile("sha1msg2 0x12345678(%eax,%ecx,8), %xmm0");
757+
758+ /* sha256rnds2 <XMM0>, xmm2/m128, xmm1 */
759+ /* Note sha256rnds2 has an implicit operand 'xmm0' */
760+
761+ asm volatile("sha256rnds2 %xmm4, %xmm1");
762+ asm volatile("sha256rnds2 %xmm7, %xmm2");
763+ asm volatile("sha256rnds2 (%eax), %xmm1");
764+ asm volatile("sha256rnds2 (0x12345678), %xmm1");
765+ asm volatile("sha256rnds2 (%eax), %xmm3");
766+ asm volatile("sha256rnds2 (%ecx,%eax,1), %xmm1");
767+ asm volatile("sha256rnds2 0x12345678(,%eax,1), %xmm1");
768+ asm volatile("sha256rnds2 (%eax,%ecx,1), %xmm1");
769+ asm volatile("sha256rnds2 (%eax,%ecx,8), %xmm1");
770+ asm volatile("sha256rnds2 0x12(%eax), %xmm1");
771+ asm volatile("sha256rnds2 0x12(%ebp), %xmm1");
772+ asm volatile("sha256rnds2 0x12(%ecx,%eax,1), %xmm1");
773+ asm volatile("sha256rnds2 0x12(%ebp,%eax,1), %xmm1");
774+ asm volatile("sha256rnds2 0x12(%eax,%ecx,1), %xmm1");
775+ asm volatile("sha256rnds2 0x12(%eax,%ecx,8), %xmm1");
776+ asm volatile("sha256rnds2 0x12345678(%eax), %xmm1");
777+ asm volatile("sha256rnds2 0x12345678(%ebp), %xmm1");
778+ asm volatile("sha256rnds2 0x12345678(%ecx,%eax,1), %xmm1");
779+ asm volatile("sha256rnds2 0x12345678(%ebp,%eax,1), %xmm1");
780+ asm volatile("sha256rnds2 0x12345678(%eax,%ecx,1), %xmm1");
781+ asm volatile("sha256rnds2 0x12345678(%eax,%ecx,8), %xmm1");
782+
783+ /* sha256msg1 xmm2/m128, xmm1 */
784+
785+ asm volatile("sha256msg1 %xmm1, %xmm0");
786+ asm volatile("sha256msg1 %xmm7, %xmm2");
787+ asm volatile("sha256msg1 (%eax), %xmm0");
788+ asm volatile("sha256msg1 (0x12345678), %xmm0");
789+ asm volatile("sha256msg1 (%eax), %xmm3");
790+ asm volatile("sha256msg1 (%ecx,%eax,1), %xmm0");
791+ asm volatile("sha256msg1 0x12345678(,%eax,1), %xmm0");
792+ asm volatile("sha256msg1 (%eax,%ecx,1), %xmm0");
793+ asm volatile("sha256msg1 (%eax,%ecx,8), %xmm0");
794+ asm volatile("sha256msg1 0x12(%eax), %xmm0");
795+ asm volatile("sha256msg1 0x12(%ebp), %xmm0");
796+ asm volatile("sha256msg1 0x12(%ecx,%eax,1), %xmm0");
797+ asm volatile("sha256msg1 0x12(%ebp,%eax,1), %xmm0");
798+ asm volatile("sha256msg1 0x12(%eax,%ecx,1), %xmm0");
799+ asm volatile("sha256msg1 0x12(%eax,%ecx,8), %xmm0");
800+ asm volatile("sha256msg1 0x12345678(%eax), %xmm0");
801+ asm volatile("sha256msg1 0x12345678(%ebp), %xmm0");
802+ asm volatile("sha256msg1 0x12345678(%ecx,%eax,1), %xmm0");
803+ asm volatile("sha256msg1 0x12345678(%ebp,%eax,1), %xmm0");
804+ asm volatile("sha256msg1 0x12345678(%eax,%ecx,1), %xmm0");
805+ asm volatile("sha256msg1 0x12345678(%eax,%ecx,8), %xmm0");
806+
807+ /* sha256msg2 xmm2/m128, xmm1 */
808+
809+ asm volatile("sha256msg2 %xmm1, %xmm0");
810+ asm volatile("sha256msg2 %xmm7, %xmm2");
811+ asm volatile("sha256msg2 (%eax), %xmm0");
812+ asm volatile("sha256msg2 (0x12345678), %xmm0");
813+ asm volatile("sha256msg2 (%eax), %xmm3");
814+ asm volatile("sha256msg2 (%ecx,%eax,1), %xmm0");
815+ asm volatile("sha256msg2 0x12345678(,%eax,1), %xmm0");
816+ asm volatile("sha256msg2 (%eax,%ecx,1), %xmm0");
817+ asm volatile("sha256msg2 (%eax,%ecx,8), %xmm0");
818+ asm volatile("sha256msg2 0x12(%eax), %xmm0");
819+ asm volatile("sha256msg2 0x12(%ebp), %xmm0");
820+ asm volatile("sha256msg2 0x12(%ecx,%eax,1), %xmm0");
821+ asm volatile("sha256msg2 0x12(%ebp,%eax,1), %xmm0");
822+ asm volatile("sha256msg2 0x12(%eax,%ecx,1), %xmm0");
823+ asm volatile("sha256msg2 0x12(%eax,%ecx,8), %xmm0");
824+ asm volatile("sha256msg2 0x12345678(%eax), %xmm0");
825+ asm volatile("sha256msg2 0x12345678(%ebp), %xmm0");
826+ asm volatile("sha256msg2 0x12345678(%ecx,%eax,1), %xmm0");
827+ asm volatile("sha256msg2 0x12345678(%ebp,%eax,1), %xmm0");
828+ asm volatile("sha256msg2 0x12345678(%eax,%ecx,1), %xmm0");
829+ asm volatile("sha256msg2 0x12345678(%eax,%ecx,8), %xmm0");
830+
831+ /* clflushopt m8 */
832+
833+ asm volatile("clflushopt (%eax)");
834+ asm volatile("clflushopt (0x12345678)");
835+ asm volatile("clflushopt 0x12345678(%eax,%ecx,8)");
836+ /* Also check instructions in the same group encoding as clflushopt */
837+ asm volatile("clflush (%eax)");
838+ asm volatile("sfence");
839+
840+ /* clwb m8 */
841+
842+ asm volatile("clwb (%eax)");
843+ asm volatile("clwb (0x12345678)");
844+ asm volatile("clwb 0x12345678(%eax,%ecx,8)");
845+ /* Also check instructions in the same group encoding as clwb */
846+ asm volatile("xsaveopt (%eax)");
847+ asm volatile("mfence");
848+
849+ /* xsavec mem */
850+
851+ asm volatile("xsavec (%eax)");
852+ asm volatile("xsavec (0x12345678)");
853+ asm volatile("xsavec 0x12345678(%eax,%ecx,8)");
854+
855+ /* xsaves mem */
856+
857+ asm volatile("xsaves (%eax)");
858+ asm volatile("xsaves (0x12345678)");
859+ asm volatile("xsaves 0x12345678(%eax,%ecx,8)");
860+
861+ /* xrstors mem */
862+
863+ asm volatile("xrstors (%eax)");
864+ asm volatile("xrstors (0x12345678)");
865+ asm volatile("xrstors 0x12345678(%eax,%ecx,8)");
866+
867+#endif /* #ifndef __x86_64__ */
868+
869+ /* pcommit */
870+
871+ asm volatile("pcommit");
872+
873+ /* Following line is a marker for the awk script - do not change */
874+ asm volatile("rdtsc"); /* Stop here */
875+
876+ return 0;
877+}
tools/perf/arch/x86/tests/insn-x86.c+185−0
@@ -0,0 +1,185 @@
1+#include <linux/types.h>
2+
3+#include "debug.h"
4+#include "tests/tests.h"
5+#include "arch-tests.h"
6+
7+#include "intel-pt-decoder/insn.h"
8+#include "intel-pt-decoder/intel-pt-insn-decoder.h"
9+
10+struct test_data {
11+ u8 data[MAX_INSN_SIZE];
12+ int expected_length;
13+ int expected_rel;
14+ const char *expected_op_str;
15+ const char *expected_branch_str;
16+ const char *asm_rep;
17+};
18+
19+struct test_data test_data_32[] = {
20+#include "insn-x86-dat-32.c"
21+ {{0x0f, 0x01, 0xee}, 3, 0, NULL, NULL, "0f 01 ee \trdpkru"},
22+ {{0x0f, 0x01, 0xef}, 3, 0, NULL, NULL, "0f 01 ef \twrpkru"},
23+ {{0}, 0, 0, NULL, NULL, NULL},
24+};
25+
26+struct test_data test_data_64[] = {
27+#include "insn-x86-dat-64.c"
28+ {{0x0f, 0x01, 0xee}, 3, 0, NULL, NULL, "0f 01 ee \trdpkru"},
29+ {{0x0f, 0x01, 0xef}, 3, 0, NULL, NULL, "0f 01 ef \twrpkru"},
30+ {{0}, 0, 0, NULL, NULL, NULL},
31+};
32+
33+static int get_op(const char *op_str)
34+{
35+ struct val_data {
36+ const char *name;
37+ int val;
38+ } vals[] = {
39+ {"other", INTEL_PT_OP_OTHER},
40+ {"call", INTEL_PT_OP_CALL},
41+ {"ret", INTEL_PT_OP_RET},
42+ {"jcc", INTEL_PT_OP_JCC},
43+ {"jmp", INTEL_PT_OP_JMP},
44+ {"loop", INTEL_PT_OP_LOOP},
45+ {"iret", INTEL_PT_OP_IRET},
46+ {"int", INTEL_PT_OP_INT},
47+ {"syscall", INTEL_PT_OP_SYSCALL},
48+ {"sysret", INTEL_PT_OP_SYSRET},
49+ {NULL, 0},
50+ };
51+ struct val_data *val;
52+
53+ if (!op_str || !strlen(op_str))
54+ return 0;
55+
56+ for (val = vals; val->name; val++) {
57+ if (!strcmp(val->name, op_str))
58+ return val->val;
59+ }
60+
61+ pr_debug("Failed to get op\n");
62+
63+ return -1;
64+}
65+
66+static int get_branch(const char *branch_str)
67+{
68+ struct val_data {
69+ const char *name;
70+ int val;
71+ } vals[] = {
72+ {"no_branch", INTEL_PT_BR_NO_BRANCH},
73+ {"indirect", INTEL_PT_BR_INDIRECT},
74+ {"conditional", INTEL_PT_BR_CONDITIONAL},
75+ {"unconditional", INTEL_PT_BR_UNCONDITIONAL},
76+ {NULL, 0},
77+ };
78+ struct val_data *val;
79+
80+ if (!branch_str || !strlen(branch_str))
81+ return 0;
82+
83+ for (val = vals; val->name; val++) {
84+ if (!strcmp(val->name, branch_str))
85+ return val->val;
86+ }
87+
88+ pr_debug("Failed to get branch\n");
89+
90+ return -1;
91+}
92+
93+static int test_data_item(struct test_data *dat, int x86_64)
94+{
95+ struct intel_pt_insn intel_pt_insn;
96+ struct insn insn;
97+ int op, branch;
98+
99+ insn_init(&insn, dat->data, MAX_INSN_SIZE, x86_64);
100+ insn_get_length(&insn);
101+
102+ if (!insn_complete(&insn)) {
103+ pr_debug("Failed to decode: %s\n", dat->asm_rep);
104+ return -1;
105+ }
106+
107+ if (insn.length != dat->expected_length) {
108+ pr_debug("Failed to decode length (%d vs expected %d): %s\n",
109+ insn.length, dat->expected_length, dat->asm_rep);
110+ return -1;
111+ }
112+
113+ op = get_op(dat->expected_op_str);
114+ branch = get_branch(dat->expected_branch_str);
115+
116+ if (intel_pt_get_insn(dat->data, MAX_INSN_SIZE, x86_64, &intel_pt_insn)) {
117+ pr_debug("Intel PT failed to decode: %s\n", dat->asm_rep);
118+ return -1;
119+ }
120+
121+ if ((int)intel_pt_insn.op != op) {
122+ pr_debug("Failed to decode 'op' value (%d vs expected %d): %s\n",
123+ intel_pt_insn.op, op, dat->asm_rep);
124+ return -1;
125+ }
126+
127+ if ((int)intel_pt_insn.branch != branch) {
128+ pr_debug("Failed to decode 'branch' value (%d vs expected %d): %s\n",
129+ intel_pt_insn.branch, branch, dat->asm_rep);
130+ return -1;
131+ }
132+
133+ if (intel_pt_insn.rel != dat->expected_rel) {
134+ pr_debug("Failed to decode 'rel' value (%#x vs expected %#x): %s\n",
135+ intel_pt_insn.rel, dat->expected_rel, dat->asm_rep);
136+ return -1;
137+ }
138+
139+ pr_debug("Decoded ok: %s\n", dat->asm_rep);
140+
141+ return 0;
142+}
143+
144+static int test_data_set(struct test_data *dat_set, int x86_64)
145+{
146+ struct test_data *dat;
147+ int ret = 0;
148+
149+ for (dat = dat_set; dat->expected_length; dat++) {
150+ if (test_data_item(dat, x86_64))
151+ ret = -1;
152+ }
153+
154+ return ret;
155+}
156+
157+/**
158+ * test__insn_x86 - test x86 instruction decoder - new instructions.
159+ *
160+ * This function implements a test that decodes a selection of instructions and
161+ * checks the results. The Intel PT function that further categorizes
162+ * instructions (i.e. intel_pt_get_insn()) is also checked.
163+ *
164+ * The instructions are originally in insn-x86-dat-src.c which has been
165+ * processed by scripts gen-insn-x86-dat.sh and gen-insn-x86-dat.awk to produce
166+ * insn-x86-dat-32.c and insn-x86-dat-64.c which are included into this program.
167+ * i.e. to add new instructions to the test, edit insn-x86-dat-src.c, run the
168+ * gen-insn-x86-dat.sh script, make perf, and then run the test.
169+ *
170+ * If the test passes %0 is returned, otherwise %-1 is returned. Use the
171+ * verbose (-v) option to see all the instructions and whether or not they
172+ * decoded successfuly.
173+ */
174+int test__insn_x86(void)
175+{
176+ int ret = 0;
177+
178+ if (test_data_set(test_data_32, 0))
179+ ret = -1;
180+
181+ if (test_data_set(test_data_64, 1))
182+ ret = -1;
183+
184+ return ret;
185+}
tools/perf/arch/x86/tests/intel-cqm.c+124−0
@@ -0,0 +1,124 @@
1+#include "tests/tests.h"
2+#include "perf.h"
3+#include "cloexec.h"
4+#include "debug.h"
5+#include "evlist.h"
6+#include "evsel.h"
7+#include "arch-tests.h"
8+
9+#include <sys/mman.h>
10+#include <string.h>
11+
12+static pid_t spawn(void)
13+{
14+ pid_t pid;
15+
16+ pid = fork();
17+ if (pid)
18+ return pid;
19+
20+ while(1);
21+ sleep(5);
22+ return 0;
23+}
24+
25+/*
26+ * Create an event group that contains both a sampled hardware
27+ * (cpu-cycles) and software (intel_cqm/llc_occupancy/) event. We then
28+ * wait for the hardware perf counter to overflow and generate a PMI,
29+ * which triggers an event read for both of the events in the group.
30+ *
31+ * Since reading Intel CQM event counters requires sending SMP IPIs, the
32+ * CQM pmu needs to handle the above situation gracefully, and return
33+ * the last read counter value to avoid triggering a WARN_ON_ONCE() in
34+ * smp_call_function_many() caused by sending IPIs from NMI context.
35+ */
36+int test__intel_cqm_count_nmi_context(void)
37+{
38+ struct perf_evlist *evlist = NULL;
39+ struct perf_evsel *evsel = NULL;
40+ struct perf_event_attr pe;
41+ int i, fd[2], flag, ret;
42+ size_t mmap_len;
43+ void *event;
44+ pid_t pid;
45+ int err = TEST_FAIL;
46+
47+ flag = perf_event_open_cloexec_flag();
48+
49+ evlist = perf_evlist__new();
50+ if (!evlist) {
51+ pr_debug("perf_evlist__new failed\n");
52+ return TEST_FAIL;
53+ }
54+
55+ ret = parse_events(evlist, "intel_cqm/llc_occupancy/", NULL);
56+ if (ret) {
57+ pr_debug("parse_events failed\n");
58+ err = TEST_SKIP;
59+ goto out;
60+ }
61+
62+ evsel = perf_evlist__first(evlist);
63+ if (!evsel) {
64+ pr_debug("perf_evlist__first failed\n");
65+ goto out;
66+ }
67+
68+ memset(&pe, 0, sizeof(pe));
69+ pe.size = sizeof(pe);
70+
71+ pe.type = PERF_TYPE_HARDWARE;
72+ pe.config = PERF_COUNT_HW_CPU_CYCLES;
73+ pe.read_format = PERF_FORMAT_GROUP;
74+
75+ pe.sample_period = 128;
76+ pe.sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_READ;
77+
78+ pid = spawn();
79+
80+ fd[0] = sys_perf_event_open(&pe, pid, -1, -1, flag);
81+ if (fd[0] < 0) {
82+ pr_debug("failed to open event\n");
83+ goto out;
84+ }
85+
86+ memset(&pe, 0, sizeof(pe));
87+ pe.size = sizeof(pe);
88+
89+ pe.type = evsel->attr.type;
90+ pe.config = evsel->attr.config;
91+
92+ fd[1] = sys_perf_event_open(&pe, pid, -1, fd[0], flag);
93+ if (fd[1] < 0) {
94+ pr_debug("failed to open event\n");
95+ goto out;
96+ }
97+
98+ /*
99+ * Pick a power-of-two number of pages + 1 for the meta-data
100+ * page (struct perf_event_mmap_page). See tools/perf/design.txt.
101+ */
102+ mmap_len = page_size * 65;
103+
104+ event = mmap(NULL, mmap_len, PROT_READ, MAP_SHARED, fd[0], 0);
105+ if (event == (void *)(-1)) {
106+ pr_debug("failed to mmap %d\n", errno);
107+ goto out;
108+ }
109+
110+ sleep(1);
111+
112+ err = TEST_OK;
113+
114+ munmap(event, mmap_len);
115+
116+ for (i = 0; i < 2; i++)
117+ close(fd[i]);
118+
119+ kill(pid, SIGKILL);
120+ wait(NULL);
121+out:
122+ perf_evlist__delete(evlist);
123+ return err;
124+}
tools/perf/arch/x86/tests/perf-time-to-tsc.crenamed from tools/perf/tests/perf-time-to-tsc.c+3−1
@@ -9,7 +9,9 @@ · 8 unmodified lines
99 #include "thread_map.h"
1010 #include "cpumap.h"
1111 #include "tsc.h"
12−#include "tests.h"
12+#include "tests/tests.h"
13+
14+#include "arch-tests.h"
1315
1416 #define CHECK__(x) { \
1517 while ((x) < 0) { \
tools/perf/arch/x86/tests/rdpmc.crenamed from tools/perf/tests/rdpmc.c+2−5
@@ -5,10 +5,9 @@ · 4 unmodified lines
55 #include <linux/types.h>
66 #include "perf.h"
77 #include "debug.h"
8−#include "tests.h"
8+#include "tests/tests.h"
99 #include "cloexec.h"
10−
11−#if defined(__x86_64__) || defined(__i386__)
10+#include "arch-tests.h"
1211
1312 static u64 rdpmc(unsigned int counter)
1413 {
@@ -173,5 +172,3 @@ int test__rdpmc(void) · 158 unmodified lines
173172
174173 return 0;
175174 }
176−
177−#endif
tools/perf/arch/x86/util/dwarf-regs.c+88−34
@@ -21,55 +21,109 @@ · 20 unmodified lines
2121 */
2222
2323 #include <stddef.h>
24+#include <errno.h> /* for EINVAL */
25+#include <string.h> /* for strcmp */
26+#include <linux/ptrace.h> /* for struct pt_regs */
27+#include <linux/kernel.h> /* for offsetof */
2428 #include <dwarf-regs.h>
2529
2630 /*
27− * Generic dwarf analysis helpers
31+ * See arch/x86/kernel/ptrace.c.
32+ * Different from it:
33+ *
34+ * - Since struct pt_regs is defined differently for user and kernel,
35+ * but we want to use 'ax, bx' instead of 'rax, rbx' (which is struct
36+ * field name of user's pt_regs), we make REG_OFFSET_NAME to accept
37+ * both string name and reg field name.
38+ *
39+ * - Since accessing x86_32's pt_regs from x86_64 building is difficult
40+ * and vise versa, we simply fill offset with -1, so
41+ * get_arch_regstr() still works but regs_query_register_offset()
42+ * returns error.
43+ * The only inconvenience caused by it now is that we are not allowed
44+ * to generate BPF prologue for a x86_64 kernel if perf is built for
45+ * x86_32. This is really a rare usecase.
46+ *
47+ * - Order is different from kernel's ptrace.c for get_arch_regstr(). Use
48+ * the order defined by dwarf.
2849 */
2950
30−#define X86_32_MAX_REGS 8
31−const char *x86_32_regs_table[X86_32_MAX_REGS] = {
32− "%ax",
33− "%cx",
34− "%dx",
35− "%bx",
36− "$stack", /* Stack address instead of %sp */
37− "%bp",
38− "%si",
39− "%di",
51+struct pt_regs_offset {
52+ const char *name;
53+ int offset;
54+};
55+
56+#define REG_OFFSET_END {.name = NULL, .offset = 0}
57+
58+#ifdef __x86_64__
59+# define REG_OFFSET_NAME_64(n, r) {.name = n, .offset = offsetof(struct pt_regs, r)}
60+# define REG_OFFSET_NAME_32(n, r) {.name = n, .offset = -1}
61+#else
62+# define REG_OFFSET_NAME_64(n, r) {.name = n, .offset = -1}
63+# define REG_OFFSET_NAME_32(n, r) {.name = n, .offset = offsetof(struct pt_regs, r)}
64+#endif
65+
66+static const struct pt_regs_offset x86_32_regoffset_table[] = {
67+ REG_OFFSET_NAME_32("%ax", eax),
68+ REG_OFFSET_NAME_32("%cx", ecx),
69+ REG_OFFSET_NAME_32("%dx", edx),
70+ REG_OFFSET_NAME_32("%bx", ebx),
71+ REG_OFFSET_NAME_32("$stack", esp), /* Stack address instead of %sp */
72+ REG_OFFSET_NAME_32("%bp", ebp),
73+ REG_OFFSET_NAME_32("%si", esi),
74+ REG_OFFSET_NAME_32("%di", edi),
75+ REG_OFFSET_END,
4076 };
4177
42−#define X86_64_MAX_REGS 16
43−const char *x86_64_regs_table[X86_64_MAX_REGS] = {
44− "%ax",
45− "%dx",
46− "%cx",
47− "%bx",
48− "%si",
49− "%di",
50− "%bp",
51− "%sp",
52− "%r8",
53− "%r9",
54− "%r10",
55− "%r11",
56− "%r12",
57− "%r13",
58− "%r14",
59− "%r15",
78+static const struct pt_regs_offset x86_64_regoffset_table[] = {
79+ REG_OFFSET_NAME_64("%ax", rax),
80+ REG_OFFSET_NAME_64("%dx", rdx),
81+ REG_OFFSET_NAME_64("%cx", rcx),
82+ REG_OFFSET_NAME_64("%bx", rbx),
83+ REG_OFFSET_NAME_64("%si", rsi),
84+ REG_OFFSET_NAME_64("%di", rdi),
85+ REG_OFFSET_NAME_64("%bp", rbp),
86+ REG_OFFSET_NAME_64("%sp", rsp),
87+ REG_OFFSET_NAME_64("%r8", r8),
88+ REG_OFFSET_NAME_64("%r9", r9),
89+ REG_OFFSET_NAME_64("%r10", r10),
90+ REG_OFFSET_NAME_64("%r11", r11),
91+ REG_OFFSET_NAME_64("%r12", r12),
92+ REG_OFFSET_NAME_64("%r13", r13),
93+ REG_OFFSET_NAME_64("%r14", r14),
94+ REG_OFFSET_NAME_64("%r15", r15),
95+ REG_OFFSET_END,
6096 };
6197
6298 /* TODO: switching by dwarf address size */
6399 #ifdef __x86_64__
64−#define ARCH_MAX_REGS X86_64_MAX_REGS
65−#define arch_regs_table x86_64_regs_table
100+#define regoffset_table x86_64_regoffset_table
66101 #else
67−#define ARCH_MAX_REGS X86_32_MAX_REGS
68−#define arch_regs_table x86_32_regs_table
102+#define regoffset_table x86_32_regoffset_table
69103 #endif
70104
105+/* Minus 1 for the ending REG_OFFSET_END */
106+#define ARCH_MAX_REGS ((sizeof(regoffset_table) / sizeof(regoffset_table[0])) - 1)
107+
71108 /* Return architecture dependent register string (for kprobe-tracer) */
72109 const char *get_arch_regstr(unsigned int n)
73110 {
74− return (n < ARCH_MAX_REGS) ? arch_regs_table[n] : NULL;
111+ return (n < ARCH_MAX_REGS) ? regoffset_table[n].name : NULL;
112+}
113+
114+/* Reuse code from arch/x86/kernel/ptrace.c */
115+/**
116+ * regs_query_register_offset() - query register offset from its name
117+ * @name: the name of a register
118+ *
119+ * regs_query_register_offset() returns the offset of a register in struct
120+ * pt_regs from its name. If the name is invalid, this returns -EINVAL;
121+ */
122+int regs_query_register_offset(const char *name)
123+{
124+ const struct pt_regs_offset *roff;
125+ for (roff = regoffset_table; roff->name != NULL; roff++)
126+ if (!strcmp(roff->name, name))
127+ return roff->offset;
128+ return -EINVAL;
75129 }
tools/perf/arch/x86/util/intel-pt.c+47−8
@@ -624,13 +624,49 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, · 623 unmodified lines
624624 * threads.
625625 */
626626 if (have_timing_info && !cpu_map__empty(cpus)) {
627− err = intel_pt_track_switches(evlist);
628− if (err == -EPERM)
629− pr_debug2("Unable to select sched:sched_switch\n");
630− else if (err)
631− return err;
632− else
633− ptr->have_sched_switch = 1;
627+ if (perf_can_record_switch_events()) {
628+ bool cpu_wide = !target__none(&opts->target) &&
629+ !target__has_task(&opts->target);
630+
631+ if (!cpu_wide && perf_can_record_cpu_wide()) {
632+ struct perf_evsel *switch_evsel;
633+
634+ err = parse_events(evlist, "dummy:u", NULL);
635+ if (err)
636+ return err;
637+
638+ switch_evsel = perf_evlist__last(evlist);
639+
640+ switch_evsel->attr.freq = 0;
641+ switch_evsel->attr.sample_period = 1;
642+ switch_evsel->attr.context_switch = 1;
643+
644+ switch_evsel->system_wide = true;
645+ switch_evsel->no_aux_samples = true;
646+ switch_evsel->immediate = true;
647+
648+ perf_evsel__set_sample_bit(switch_evsel, TID);
649+ perf_evsel__set_sample_bit(switch_evsel, TIME);
650+ perf_evsel__set_sample_bit(switch_evsel, CPU);
651+
652+ opts->record_switch_events = false;
653+ ptr->have_sched_switch = 3;
654+ } else {
655+ opts->record_switch_events = true;
656+ if (cpu_wide)
657+ ptr->have_sched_switch = 3;
658+ else
659+ ptr->have_sched_switch = 2;
660+ }
661+ } else {
662+ err = intel_pt_track_switches(evlist);
663+ if (err == -EPERM)
664+ pr_debug2("Unable to select sched:sched_switch\n");
665+ else if (err)
666+ return err;
667+ else
668+ ptr->have_sched_switch = 1;
669+ }
634670 }
635671
636672 if (intel_pt_evsel) {
@@ -663,8 +699,11 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, · 26 unmodified lines
663699 tracking_evsel->attr.sample_period = 1;
664700
665701 /* In per-cpu case, always need the time of mmap events etc */
666− if (!cpu_map__empty(cpus))
702+ if (!cpu_map__empty(cpus)) {
667703 perf_evsel__set_sample_bit(tracking_evsel, TIME);
704+ /* And the CPU for switch events */
705+ perf_evsel__set_sample_bit(tracking_evsel, CPU);
706+ }
668707 }
669708
670709 /*
tools/perf/bench/Build+1−1
@@ -1,6 +1,6 @@
11 perf-y += sched-messaging.o
22 perf-y += sched-pipe.o
3−perf-y += mem-memcpy.o
3+perf-y += mem-functions.o
44 perf-y += futex-hash.o
55 perf-y += futex-wake.o
66 perf-y += futex-wake-parallel.o
tools/perf/bench/mem-functions.c+379−0
@@ -0,0 +1,379 @@
1+/*
2+ * mem-memcpy.c
3+ *
4+ * Simple memcpy() and memset() benchmarks
5+ *
6+ * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
7+ */
8+
9+#include "../perf.h"
10+#include "../util/util.h"
11+#include "../util/parse-options.h"
12+#include "../util/header.h"
13+#include "../util/cloexec.h"
14+#include "bench.h"
15+#include "mem-memcpy-arch.h"
16+#include "mem-memset-arch.h"
17+
18+#include <stdio.h>
19+#include <stdlib.h>
20+#include <string.h>
21+#include <sys/time.h>
22+#include <errno.h>
23+
24+#define K 1024
25+
26+static const char *size_str = "1MB";
27+static const char *function_str = "all";
28+static int nr_loops = 1;
29+static bool use_cycles;
30+static int cycles_fd;
31+
32+static const struct option options[] = {
33+ OPT_STRING('s', "size", &size_str, "1MB",
34+ "Specify the size of the memory buffers. "
35+ "Available units: B, KB, MB, GB and TB (case insensitive)"),
36+
37+ OPT_STRING('f', "function", &function_str, "all",
38+ "Specify the function to run, \"all\" runs all available functions, \"help\" lists them"),
39+
40+ OPT_INTEGER('l', "nr_loops", &nr_loops,
41+ "Specify the number of loops to run. (default: 1)"),
42+
43+ OPT_BOOLEAN('c', "cycles", &use_cycles,
44+ "Use a cycles event instead of gettimeofday() to measure performance"),
45+
46+ OPT_END()
47+};
48+
49+typedef void *(*memcpy_t)(void *, const void *, size_t);
50+typedef void *(*memset_t)(void *, int, size_t);
51+
52+struct function {
53+ const char *name;
54+ const char *desc;
55+ union {
56+ memcpy_t memcpy;
57+ memset_t memset;
58+ } fn;
59+};
60+
61+static struct perf_event_attr cycle_attr = {
62+ .type = PERF_TYPE_HARDWARE,
63+ .config = PERF_COUNT_HW_CPU_CYCLES
64+};
65+
66+static void init_cycles(void)
67+{
68+ cycles_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1, perf_event_open_cloexec_flag());
69+
70+ if (cycles_fd < 0 && errno == ENOSYS)
71+ die("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
72+ else
73+ BUG_ON(cycles_fd < 0);
74+}
75+
76+static u64 get_cycles(void)
77+{
78+ int ret;
79+ u64 clk;
80+
81+ ret = read(cycles_fd, &clk, sizeof(u64));
82+ BUG_ON(ret != sizeof(u64));
83+
84+ return clk;
85+}
86+
87+static double timeval2double(struct timeval *ts)
88+{
89+ return (double)ts->tv_sec + (double)ts->tv_usec / (double)1000000;
90+}
91+
92+#define print_bps(x) do { \
93+ if (x < K) \
94+ printf(" %14lf bytes/sec\n", x); \
95+ else if (x < K * K) \
96+ printf(" %14lfd KB/sec\n", x / K); \
97+ else if (x < K * K * K) \
98+ printf(" %14lf MB/sec\n", x / K / K); \
99+ else \
100+ printf(" %14lf GB/sec\n", x / K / K / K); \
101+ } while (0)
102+
103+struct bench_mem_info {
104+ const struct function *functions;
105+ u64 (*do_cycles)(const struct function *r, size_t size);
106+ double (*do_gettimeofday)(const struct function *r, size_t size);
107+ const char *const *usage;
108+};
109+
110+static void __bench_mem_function(struct bench_mem_info *info, int r_idx, size_t size, double size_total)
111+{
112+ const struct function *r = &info->functions[r_idx];
113+ double result_bps = 0.0;
114+ u64 result_cycles = 0;
115+
116+ printf("# function '%s' (%s)\n", r->name, r->desc);
117+
118+ if (bench_format == BENCH_FORMAT_DEFAULT)
119+ printf("# Copying %s bytes ...\n\n", size_str);
120+
121+ if (use_cycles) {
122+ result_cycles = info->do_cycles(r, size);
123+ } else {
124+ result_bps = info->do_gettimeofday(r, size);
125+ }
126+
127+ switch (bench_format) {
128+ case BENCH_FORMAT_DEFAULT:
129+ if (use_cycles) {
130+ printf(" %14lf cycles/byte\n", (double)result_cycles/size_total);
131+ } else {
132+ print_bps(result_bps);
133+ }
134+ break;
135+
136+ case BENCH_FORMAT_SIMPLE:
137+ if (use_cycles) {
138+ printf("%lf\n", (double)result_cycles/size_total);
139+ } else {
140+ printf("%lf\n", result_bps);
141+ }
142+ break;
143+
144+ default:
145+ BUG_ON(1);
146+ break;
147+ }
148+}
149+
150+static int bench_mem_common(int argc, const char **argv, struct bench_mem_info *info)
151+{
152+ int i;
153+ size_t size;
154+ double size_total;
155+
156+ argc = parse_options(argc, argv, options, info->usage, 0);
157+
158+ if (use_cycles)
159+ init_cycles();
160+
161+ size = (size_t)perf_atoll((char *)size_str);
162+ size_total = (double)size * nr_loops;
163+
164+ if ((s64)size <= 0) {
165+ fprintf(stderr, "Invalid size:%s\n", size_str);
166+ return 1;
167+ }
168+
169+ if (!strncmp(function_str, "all", 3)) {
170+ for (i = 0; info->functions[i].name; i++)
171+ __bench_mem_function(info, i, size, size_total);
172+ return 0;
173+ }
174+
175+ for (i = 0; info->functions[i].name; i++) {
176+ if (!strcmp(info->functions[i].name, function_str))
177+ break;
178+ }
179+ if (!info->functions[i].name) {
180+ if (strcmp(function_str, "help") && strcmp(function_str, "h"))
181+ printf("Unknown function: %s\n", function_str);
182+ printf("Available functions:\n");
183+ for (i = 0; info->functions[i].name; i++) {
184+ printf("\t%s ... %s\n",
185+ info->functions[i].name, info->functions[i].desc);
186+ }
187+ return 1;
188+ }
189+
190+ __bench_mem_function(info, i, size, size_total);
191+
192+ return 0;
193+}
194+
195+static void memcpy_alloc_mem(void **dst, void **src, size_t size)
196+{
197+ *dst = zalloc(size);
198+ if (!*dst)
199+ die("memory allocation failed - maybe size is too large?\n");
200+
201+ *src = zalloc(size);
202+ if (!*src)
203+ die("memory allocation failed - maybe size is too large?\n");
204+
205+ /* Make sure to always prefault zero pages even if MMAP_THRESH is crossed: */
206+ memset(*src, 0, size);
207+}
208+
209+static u64 do_memcpy_cycles(const struct function *r, size_t size)
210+{
211+ u64 cycle_start = 0ULL, cycle_end = 0ULL;
212+ void *src = NULL, *dst = NULL;
213+ memcpy_t fn = r->fn.memcpy;
214+ int i;
215+
216+ memcpy_alloc_mem(&dst, &src, size);
217+
218+ /*
219+ * We prefault the freshly allocated memory range here,
220+ * to not measure page fault overhead:
221+ */
222+ fn(dst, src, size);
223+
224+ cycle_start = get_cycles();
225+ for (i = 0; i < nr_loops; ++i)
226+ fn(dst, src, size);
227+ cycle_end = get_cycles();
228+
229+ free(src);
230+ free(dst);
231+ return cycle_end - cycle_start;
232+}
233+
234+static double do_memcpy_gettimeofday(const struct function *r, size_t size)
235+{
236+ struct timeval tv_start, tv_end, tv_diff;
237+ memcpy_t fn = r->fn.memcpy;
238+ void *src = NULL, *dst = NULL;
239+ int i;
240+
241+ memcpy_alloc_mem(&dst, &src, size);
242+
243+ /*
244+ * We prefault the freshly allocated memory range here,
245+ * to not measure page fault overhead:
246+ */
247+ fn(dst, src, size);
248+
249+ BUG_ON(gettimeofday(&tv_start, NULL));
250+ for (i = 0; i < nr_loops; ++i)
251+ fn(dst, src, size);
252+ BUG_ON(gettimeofday(&tv_end, NULL));
253+
254+ timersub(&tv_end, &tv_start, &tv_diff);
255+
256+ free(src);
257+ free(dst);
258+
259+ return (double)(((double)size * nr_loops) / timeval2double(&tv_diff));
260+}
261+
262+struct function memcpy_functions[] = {
263+ { .name = "default",
264+ .desc = "Default memcpy() provided by glibc",
265+ .fn.memcpy = memcpy },
266+
267+#ifdef HAVE_ARCH_X86_64_SUPPORT
268+# define MEMCPY_FN(_fn, _name, _desc) {.name = _name, .desc = _desc, .fn.memcpy = _fn},
269+# include "mem-memcpy-x86-64-asm-def.h"
270+# undef MEMCPY_FN
271+#endif
272+
273+ { .name = NULL, }
274+};
275+
276+static const char * const bench_mem_memcpy_usage[] = {
277+ "perf bench mem memcpy <options>",
278+ NULL
279+};
280+
281+int bench_mem_memcpy(int argc, const char **argv, const char *prefix __maybe_unused)
282+{
283+ struct bench_mem_info info = {
284+ .functions = memcpy_functions,
285+ .do_cycles = do_memcpy_cycles,
286+ .do_gettimeofday = do_memcpy_gettimeofday,
287+ .usage = bench_mem_memcpy_usage,
288+ };
289+
290+ return bench_mem_common(argc, argv, &info);
291+}
292+
293+static void memset_alloc_mem(void **dst, size_t size)
294+{
295+ *dst = zalloc(size);
296+ if (!*dst)
297+ die("memory allocation failed - maybe size is too large?\n");
298+}
299+
300+static u64 do_memset_cycles(const struct function *r, size_t size)
301+{
302+ u64 cycle_start = 0ULL, cycle_end = 0ULL;
303+ memset_t fn = r->fn.memset;
304+ void *dst = NULL;
305+ int i;
306+
307+ memset_alloc_mem(&dst, size);
308+
309+ /*
310+ * We prefault the freshly allocated memory range here,
311+ * to not measure page fault overhead:
312+ */
313+ fn(dst, -1, size);
314+
315+ cycle_start = get_cycles();
316+ for (i = 0; i < nr_loops; ++i)
317+ fn(dst, i, size);
318+ cycle_end = get_cycles();
319+
320+ free(dst);
321+ return cycle_end - cycle_start;
322+}
323+
324+static double do_memset_gettimeofday(const struct function *r, size_t size)
325+{
326+ struct timeval tv_start, tv_end, tv_diff;
327+ memset_t fn = r->fn.memset;
328+ void *dst = NULL;
329+ int i;
330+
331+ memset_alloc_mem(&dst, size);
332+
333+ /*
334+ * We prefault the freshly allocated memory range here,
335+ * to not measure page fault overhead:
336+ */
337+ fn(dst, -1, size);
338+
339+ BUG_ON(gettimeofday(&tv_start, NULL));
340+ for (i = 0; i < nr_loops; ++i)
341+ fn(dst, i, size);
342+ BUG_ON(gettimeofday(&tv_end, NULL));
343+
344+ timersub(&tv_end, &tv_start, &tv_diff);
345+
346+ free(dst);
347+ return (double)(((double)size * nr_loops) / timeval2double(&tv_diff));
348+}
349+
350+static const char * const bench_mem_memset_usage[] = {
351+ "perf bench mem memset <options>",
352+ NULL
353+};
354+
355+static const struct function memset_functions[] = {
356+ { .name = "default",
357+ .desc = "Default memset() provided by glibc",
358+ .fn.memset = memset },
359+
360+#ifdef HAVE_ARCH_X86_64_SUPPORT
361+# define MEMSET_FN(_fn, _name, _desc) { .name = _name, .desc = _desc, .fn.memset = _fn },
362+# include "mem-memset-x86-64-asm-def.h"
363+# undef MEMSET_FN
364+#endif
365+
366+ { .name = NULL, }
367+};
368+
369+int bench_mem_memset(int argc, const char **argv, const char *prefix __maybe_unused)
370+{
371+ struct bench_mem_info info = {
372+ .functions = memset_functions,
373+ .do_cycles = do_memset_cycles,
374+ .do_gettimeofday = do_memset_gettimeofday,
375+ .usage = bench_mem_memset_usage,
376+ };
377+
378+ return bench_mem_common(argc, argv, &info);
379+}
tools/perf/bench/mem-memcpy.c+0−434
@@ -1,434 +0,0 @@
1−/*
2− * mem-memcpy.c
3− *
4− * memcpy: Simple memory copy in various ways
5− *
6− * Written by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
7− */
8−
9−#include "../perf.h"
10−#include "../util/util.h"
11−#include "../util/parse-options.h"
12−#include "../util/header.h"
13−#include "../util/cloexec.h"
14−#include "bench.h"
15−#include "mem-memcpy-arch.h"
16−#include "mem-memset-arch.h"
17−
18−#include <stdio.h>
19−#include <stdlib.h>
20−#include <string.h>
21−#include <sys/time.h>
22−#include <errno.h>
23−
24−#define K 1024
25−
26−static const char *length_str = "1MB";
27−static const char *routine = "default";
28−static int iterations = 1;
29−static bool use_cycle;
30−static int cycle_fd;
31−static bool only_prefault;
32−static bool no_prefault;
33−
34−static const struct option options[] = {
35− OPT_STRING('l', "length", &length_str, "1MB",
36− "Specify length of memory to copy. "
37− "Available units: B, KB, MB, GB and TB (upper and lower)"),
38− OPT_STRING('r', "routine", &routine, "default",
39− "Specify routine to copy, \"all\" runs all available routines"),
40− OPT_INTEGER('i', "iterations", &iterations,
41− "repeat memcpy() invocation this number of times"),
42− OPT_BOOLEAN('c', "cycle", &use_cycle,
43− "Use cycles event instead of gettimeofday() for measuring"),
44− OPT_BOOLEAN('o', "only-prefault", &only_prefault,
45− "Show only the result with page faults before memcpy()"),
46− OPT_BOOLEAN('n', "no-prefault", &no_prefault,
47− "Show only the result without page faults before memcpy()"),
48− OPT_END()
49−};
50−
51−typedef void *(*memcpy_t)(void *, const void *, size_t);
52−typedef void *(*memset_t)(void *, int, size_t);
53−
54−struct routine {
55− const char *name;
56− const char *desc;
57− union {
58− memcpy_t memcpy;
59− memset_t memset;
60− } fn;
61−};
62−
63−struct routine memcpy_routines[] = {
64− { .name = "default",
65− .desc = "Default memcpy() provided by glibc",
66− .fn.memcpy = memcpy },
67−#ifdef HAVE_ARCH_X86_64_SUPPORT
68−
69−#define MEMCPY_FN(_fn, _name, _desc) {.name = _name, .desc = _desc, .fn.memcpy = _fn},
70−#include "mem-memcpy-x86-64-asm-def.h"
71−#undef MEMCPY_FN
72−
73−#endif
74−
75− { NULL,
76− NULL,
77− {NULL} }
78−};
79−
80−static const char * const bench_mem_memcpy_usage[] = {
81− "perf bench mem memcpy <options>",
82− NULL
83−};
84−
85−static struct perf_event_attr cycle_attr = {
86− .type = PERF_TYPE_HARDWARE,
87− .config = PERF_COUNT_HW_CPU_CYCLES
88−};
89−
90−static void init_cycle(void)
91−{
92− cycle_fd = sys_perf_event_open(&cycle_attr, getpid(), -1, -1,
93− perf_event_open_cloexec_flag());
94−
95− if (cycle_fd < 0 && errno == ENOSYS)
96− die("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
97− else
98− BUG_ON(cycle_fd < 0);
99−}
100−
101−static u64 get_cycle(void)
102−{
103− int ret;
104− u64 clk;
105−
106− ret = read(cycle_fd, &clk, sizeof(u64));
107− BUG_ON(ret != sizeof(u64));
108−
109− return clk;
110−}
111−
112−static double timeval2double(struct timeval *ts)
113−{
114− return (double)ts->tv_sec +
115− (double)ts->tv_usec / (double)1000000;
116−}
117−
118−#define pf (no_prefault ? 0 : 1)
119−
120−#define print_bps(x) do { \
121− if (x < K) \
122− printf(" %14lf B/Sec", x); \
123− else if (x < K * K) \
124− printf(" %14lfd KB/Sec", x / K); \
125− else if (x < K * K * K) \
126− printf(" %14lf MB/Sec", x / K / K); \
127− else \
128− printf(" %14lf GB/Sec", x / K / K / K); \
129− } while (0)
130−
131−struct bench_mem_info {
132− const struct routine *routines;
133− u64 (*do_cycle)(const struct routine *r, size_t len, bool prefault);
134− double (*do_gettimeofday)(const struct routine *r, size_t len, bool prefault);
135− const char *const *usage;
136−};
137−
138−static void __bench_mem_routine(struct bench_mem_info *info, int r_idx, size_t len, double totallen)
139−{
140− const struct routine *r = &info->routines[r_idx];
141− double result_bps[2];
142− u64 result_cycle[2];
143−
144− result_cycle[0] = result_cycle[1] = 0ULL;
145− result_bps[0] = result_bps[1] = 0.0;
146−
147− printf("Routine %s (%s)\n", r->name, r->desc);
148−
149− if (bench_format == BENCH_FORMAT_DEFAULT)
150− printf("# Copying %s Bytes ...\n\n", length_str);
151−
152− if (!only_prefault && !no_prefault) {
153− /* show both of results */
154− if (use_cycle) {
155− result_cycle[0] = info->do_cycle(r, len, false);
156− result_cycle[1] = info->do_cycle(r, len, true);
157− } else {
158− result_bps[0] = info->do_gettimeofday(r, len, false);
159− result_bps[1] = info->do_gettimeofday(r, len, true);
160− }
161− } else {
162− if (use_cycle)
163− result_cycle[pf] = info->do_cycle(r, len, only_prefault);
164− else
165− result_bps[pf] = info->do_gettimeofday(r, len, only_prefault);
166− }
167−
168− switch (bench_format) {
169− case BENCH_FORMAT_DEFAULT:
170− if (!only_prefault && !no_prefault) {
171− if (use_cycle) {
172− printf(" %14lf Cycle/Byte\n",
173− (double)result_cycle[0]
174− / totallen);
175− printf(" %14lf Cycle/Byte (with prefault)\n",
176− (double)result_cycle[1]
177− / totallen);
178− } else {
179− print_bps(result_bps[0]);
180− printf("\n");
181− print_bps(result_bps[1]);
182− printf(" (with prefault)\n");
183− }
184− } else {
185− if (use_cycle) {
186− printf(" %14lf Cycle/Byte",
187− (double)result_cycle[pf]
188− / totallen);
189− } else
190− print_bps(result_bps[pf]);
191−
192− printf("%s\n", only_prefault ? " (with prefault)" : "");
193− }
194− break;
195− case BENCH_FORMAT_SIMPLE:
196− if (!only_prefault && !no_prefault) {
197− if (use_cycle) {
198− printf("%lf %lf\n",
199− (double)result_cycle[0] / totallen,
200− (double)result_cycle[1] / totallen);
201− } else {
202− printf("%lf %lf\n",
203− result_bps[0], result_bps[1]);
204− }
205− } else {
206− if (use_cycle) {
207− printf("%lf\n", (double)result_cycle[pf]
208− / totallen);
209− } else
210− printf("%lf\n", result_bps[pf]);
211− }
212− break;
213− default:
214− /* reaching this means there's some disaster: */
215− die("unknown format: %d\n", bench_format);
216− break;
217− }
218−}
219−
220−static int bench_mem_common(int argc, const char **argv,
221− const char *prefix __maybe_unused,
222− struct bench_mem_info *info)
223−{
224− int i;
225− size_t len;
226− double totallen;
227−
228− argc = parse_options(argc, argv, options,
229− info->usage, 0);
230−
231− if (no_prefault && only_prefault) {
232− fprintf(stderr, "Invalid options: -o and -n are mutually exclusive\n");
233− return 1;
234− }
235−
236− if (use_cycle)
237− init_cycle();
238−
239− len = (size_t)perf_atoll((char *)length_str);
240− totallen = (double)len * iterations;
241−
242− if ((s64)len <= 0) {
243− fprintf(stderr, "Invalid length:%s\n", length_str);
244− return 1;
245− }
246−
247− /* same to without specifying either of prefault and no-prefault */
248− if (only_prefault && no_prefault)
249− only_prefault = no_prefault = false;
250−
251− if (!strncmp(routine, "all", 3)) {
252− for (i = 0; info->routines[i].name; i++)
253− __bench_mem_routine(info, i, len, totallen);
254− return 0;
255− }
256−
257− for (i = 0; info->routines[i].name; i++) {
258− if (!strcmp(info->routines[i].name, routine))
259− break;
260− }
261− if (!info->routines[i].name) {
262− printf("Unknown routine:%s\n", routine);
263− printf("Available routines...\n");
264− for (i = 0; info->routines[i].name; i++) {
265− printf("\t%s ... %s\n",
266− info->routines[i].name, info->routines[i].desc);
267− }
268− return 1;
269− }
270−
271− __bench_mem_routine(info, i, len, totallen);
272−
273− return 0;
274−}
275−
276−static void memcpy_alloc_mem(void **dst, void **src, size_t length)
277−{
278− *dst = zalloc(length);
279− if (!*dst)
280− die("memory allocation failed - maybe length is too large?\n");
281−
282− *src = zalloc(length);
283− if (!*src)
284− die("memory allocation failed - maybe length is too large?\n");
285− /* Make sure to always replace the zero pages even if MMAP_THRESH is crossed */
286− memset(*src, 0, length);
287−}
288−
289−static u64 do_memcpy_cycle(const struct routine *r, size_t len, bool prefault)
290−{
291− u64 cycle_start = 0ULL, cycle_end = 0ULL;
292− void *src = NULL, *dst = NULL;
293− memcpy_t fn = r->fn.memcpy;
294− int i;
295−
296− memcpy_alloc_mem(&dst, &src, len);
297−
298− if (prefault)
299− fn(dst, src, len);
300−
301− cycle_start = get_cycle();
302− for (i = 0; i < iterations; ++i)
303− fn(dst, src, len);
304− cycle_end = get_cycle();
305−
306− free(src);
307− free(dst);
308− return cycle_end - cycle_start;
309−}
310−
311−static double do_memcpy_gettimeofday(const struct routine *r, size_t len,
312− bool prefault)
313−{
314− struct timeval tv_start, tv_end, tv_diff;
315− memcpy_t fn = r->fn.memcpy;
316− void *src = NULL, *dst = NULL;
317− int i;
318−
319− memcpy_alloc_mem(&dst, &src, len);
320−
321− if (prefault)
322− fn(dst, src, len);
323−
324− BUG_ON(gettimeofday(&tv_start, NULL));
325− for (i = 0; i < iterations; ++i)
326− fn(dst, src, len);
327− BUG_ON(gettimeofday(&tv_end, NULL));
328−
329− timersub(&tv_end, &tv_start, &tv_diff);
330−
331− free(src);
332− free(dst);
333− return (double)(((double)len * iterations) / timeval2double(&tv_diff));
334−}
335−
336−int bench_mem_memcpy(int argc, const char **argv,
337− const char *prefix __maybe_unused)
338−{
339− struct bench_mem_info info = {
340− .routines = memcpy_routines,
341− .do_cycle = do_memcpy_cycle,
342− .do_gettimeofday = do_memcpy_gettimeofday,
343− .usage = bench_mem_memcpy_usage,
344− };
345−
346− return bench_mem_common(argc, argv, prefix, &info);
347−}
348−
349−static void memset_alloc_mem(void **dst, size_t length)
350−{
351− *dst = zalloc(length);
352− if (!*dst)
353− die("memory allocation failed - maybe length is too large?\n");
354−}
355−
356−static u64 do_memset_cycle(const struct routine *r, size_t len, bool prefault)
357−{
358− u64 cycle_start = 0ULL, cycle_end = 0ULL;
359− memset_t fn = r->fn.memset;
360− void *dst = NULL;
361− int i;
362−
363− memset_alloc_mem(&dst, len);
364−
365− if (prefault)
366− fn(dst, -1, len);
367−
368− cycle_start = get_cycle();
369− for (i = 0; i < iterations; ++i)
370− fn(dst, i, len);
371− cycle_end = get_cycle();
372−
373− free(dst);
374− return cycle_end - cycle_start;
375−}
376−
377−static double do_memset_gettimeofday(const struct routine *r, size_t len,
378− bool prefault)
379−{
380− struct timeval tv_start, tv_end, tv_diff;
381− memset_t fn = r->fn.memset;
382− void *dst = NULL;
383− int i;
384−
385− memset_alloc_mem(&dst, len);
386−
387− if (prefault)
388− fn(dst, -1, len);
389−
390− BUG_ON(gettimeofday(&tv_start, NULL));
391− for (i = 0; i < iterations; ++i)
392− fn(dst, i, len);
393− BUG_ON(gettimeofday(&tv_end, NULL));
394−
395− timersub(&tv_end, &tv_start, &tv_diff);
396−
397− free(dst);
398− return (double)(((double)len * iterations) / timeval2double(&tv_diff));
399−}
400−
401−static const char * const bench_mem_memset_usage[] = {
402− "perf bench mem memset <options>",
403− NULL
404−};
405−
406−static const struct routine memset_routines[] = {
407− { .name ="default",
408− .desc = "Default memset() provided by glibc",
409− .fn.memset = memset },
410−#ifdef HAVE_ARCH_X86_64_SUPPORT
411−
412−#define MEMSET_FN(_fn, _name, _desc) { .name = _name, .desc = _desc, .fn.memset = _fn },
413−#include "mem-memset-x86-64-asm-def.h"
414−#undef MEMSET_FN
415−
416−#endif
417−
418− { .name = NULL,
419− .desc = NULL,
420− .fn.memset = NULL }
421−};
422−
423−int bench_mem_memset(int argc, const char **argv,
424− const char *prefix __maybe_unused)
425−{
426− struct bench_mem_info info = {
427− .routines = memset_routines,
428− .do_cycle = do_memset_cycle,
429− .do_gettimeofday = do_memset_gettimeofday,
430− .usage = bench_mem_memset_usage,
431− };
432−
433− return bench_mem_common(argc, argv, prefix, &info);
434−}
tools/perf/bench/numa.c+2−2
@@ -164,8 +164,8 @@ static const struct option options[] = { · 163 unmodified lines
164164 OPT_STRING('L', "mb_proc_locked", &p0.mb_proc_locked_str,"MB", "process serialized/locked memory access (MBs), <= process_memory"),
165165 OPT_STRING('T', "mb_thread" , &p0.mb_thread_str, "MB", "thread memory (MBs)"),
166166
167− OPT_UINTEGER('l', "nr_loops" , &p0.nr_loops, "max number of loops to run"),
168− OPT_UINTEGER('s', "nr_secs" , &p0.nr_secs, "max number of seconds to run"),
167+ OPT_UINTEGER('l', "nr_loops" , &p0.nr_loops, "max number of loops to run (default: unlimited)"),
168+ OPT_UINTEGER('s', "nr_secs" , &p0.nr_secs, "max number of seconds to run (default: 5 secs)"),
169169 OPT_UINTEGER('u', "usleep" , &p0.sleep_usecs, "usecs to sleep per loop iteration"),
170170
171171 OPT_BOOLEAN('R', "data_reads" , &p0.data_reads, "access the data via writes (can be mixed with -W)"),
tools/perf/bench/sched-messaging.c+5−5
@@ -33,7 +33,7 @@ · 32 unmodified lines
3333 #define DATASIZE 100
3434
3535 static bool use_pipes = false;
36−static unsigned int loops = 100;
36+static unsigned int nr_loops = 100;
3737 static bool thread_mode = false;
3838 static unsigned int num_groups = 10;
3939
@@ -79,7 +79,7 @@ static void ready(int ready_out, int wakefd) · 39 unmodified lines
7979 err(EXIT_FAILURE, "poll");
8080 }
8181
82−/* Sender sprays loops messages down each file descriptor */
82+/* Sender sprays nr_loops messages down each file descriptor */
8383 static void *sender(struct sender_context *ctx)
8484 {
8585 char data[DATASIZE];
@@ -88,7 +88,7 @@ static void *sender(struct sender_context *ctx) · 2 unmodified lines
8888 ready(ctx->ready_out, ctx->wakefd);
8989
9090 /* Now pump to every receiver. */
91− for (i = 0; i < loops; i++) {
91+ for (i = 0; i < nr_loops; i++) {
9292 for (j = 0; j < ctx->num_fds; j++) {
9393 int ret, done = 0;
9494
@@ -213,7 +213,7 @@ static unsigned int group(pthread_t *pth, · 118 unmodified lines
213213 /* Create the pipe between client and server */
214214 fdpair(fds);
215215
216− ctx->num_packets = num_fds * loops;
216+ ctx->num_packets = num_fds * nr_loops;
217217 ctx->in_fds[0] = fds[0];
218218 ctx->in_fds[1] = fds[1];
219219 ctx->ready_out = ready_out;
@@ -250,7 +250,7 @@ static const struct option options[] = { · 30 unmodified lines
250250 OPT_BOOLEAN('t', "thread", &thread_mode,
251251 "Be multi thread instead of multi process"),
252252 OPT_UINTEGER('g', "group", &num_groups, "Specify number of groups"),
253− OPT_UINTEGER('l', "loop", &loops, "Specify number of loops"),
253+ OPT_UINTEGER('l', "nr_loops", &nr_loops, "Specify the number of loops to run (default: 100)"),
254254 OPT_END()
255255 };
256256
tools/perf/builtin-annotate.c+1−1
@@ -211,7 +211,7 @@ static int __cmd_annotate(struct perf_annotate *ann) · 210 unmodified lines
211211 }
212212
213213 if (!objdump_path) {
214− ret = perf_session_env__lookup_objdump(&session->header.env);
214+ ret = perf_env__lookup_objdump(&session->header.env);
215215 if (ret)
216216 goto out;
217217 }
tools/perf/builtin-bench.c+7−7
@@ -36,7 +36,7 @@ struct bench { · 35 unmodified lines
3636 #ifdef HAVE_LIBNUMA_SUPPORT
3737 static struct bench numa_benchmarks[] = {
3838 { "mem", "Benchmark for NUMA workloads", bench_numa },
39− { "all", "Test all NUMA benchmarks", NULL },
39+ { "all", "Run all NUMA benchmarks", NULL },
4040 { NULL, NULL, NULL }
4141 };
4242 #endif
@@ -44,14 +44,14 @@ static struct bench numa_benchmarks[] = { · 1 unmodified line
4444 static struct bench sched_benchmarks[] = {
4545 { "messaging", "Benchmark for scheduling and IPC", bench_sched_messaging },
4646 { "pipe", "Benchmark for pipe() between two processes", bench_sched_pipe },
47− { "all", "Test all scheduler benchmarks", NULL },
47+ { "all", "Run all scheduler benchmarks", NULL },
4848 { NULL, NULL, NULL }
4949 };
5050
5151 static struct bench mem_benchmarks[] = {
52− { "memcpy", "Benchmark for memcpy()", bench_mem_memcpy },
53− { "memset", "Benchmark for memset() tests", bench_mem_memset },
54− { "all", "Test all memory benchmarks", NULL },
52+ { "memcpy", "Benchmark for memcpy() functions", bench_mem_memcpy },
53+ { "memset", "Benchmark for memset() functions", bench_mem_memset },
54+ { "all", "Run all memory access benchmarks", NULL },
5555 { NULL, NULL, NULL }
5656 };
5757
@@ -62,7 +62,7 @@ static struct bench futex_benchmarks[] = { · 4 unmodified lines
6262 { "requeue", "Benchmark for futex requeue calls", bench_futex_requeue },
6363 /* pi-futexes */
6464 { "lock-pi", "Benchmark for futex lock_pi calls", bench_futex_lock_pi },
65− { "all", "Test all futex benchmarks", NULL },
65+ { "all", "Run all futex benchmarks", NULL },
6666 { NULL, NULL, NULL }
6767 };
6868
@@ -110,7 +110,7 @@ int bench_format = BENCH_FORMAT_DEFAULT; · 41 unmodified lines
110110 unsigned int bench_repeat = 10; /* default number of times to repeat the run */
111111
112112 static const struct option bench_options[] = {
113− OPT_STRING('f', "format", &bench_format_str, "default", "Specify format style"),
113+ OPT_STRING('f', "format", &bench_format_str, "default|simple", "Specify the output formatting style"),
114114 OPT_UINTEGER('r', "repeat", &bench_repeat, "Specify amount of times to repeat the run"),
115115 OPT_END()
116116 };
tools/perf/builtin-evlist.c+2−2
@@ -61,8 +61,8 @@ int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused) · 60 unmodified lines
6161 usage_with_options(evlist_usage, options);
6262
6363 if (details.event_group && (details.verbose || details.freq)) {
64− pr_err("--group option is not compatible with other options\n");
65− usage_with_options(evlist_usage, options);
64+ usage_with_options_msg(evlist_usage, options,
65+ "--group option is not compatible with other options\n");
6666 }
6767
6868 return __cmd_evlist(input_name, &details);
tools/perf/builtin-help.c+1−1
@@ -463,7 +463,7 @@ int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused) · 462 unmodified lines
463463 builtin_help_subcommands, builtin_help_usage, 0);
464464
465465 if (show_all) {
466− printf("\n usage: %s\n\n", perf_usage_string);
466+ printf("\n Usage: %s\n\n", perf_usage_string);
467467 list_commands("perf commands", &main_cmds, &other_cmds);
468468 printf(" %s\n\n", perf_more_info_string);
469469 return 0;
tools/perf/builtin-inject.c+125−2
@@ -28,9 +28,11 @@ struct perf_inject { · 27 unmodified lines
2828 bool build_ids;
2929 bool sched_stat;
3030 bool have_auxtrace;
31+ bool strip;
3132 const char *input_name;
3233 struct perf_data_file output;
3334 u64 bytes_written;
35+ u64 aux_id;
3436 struct list_head samples;
3537 struct itrace_synth_opts itrace_synth_opts;
3638 };
@@ -176,6 +178,27 @@ static int perf_event__repipe(struct perf_tool *tool, · 139 unmodified lines
176178 return perf_event__repipe_synth(tool, event);
177179 }
178180
181+static int perf_event__drop(struct perf_tool *tool __maybe_unused,
182+ union perf_event *event __maybe_unused,
183+ struct perf_sample *sample __maybe_unused,
184+ struct machine *machine __maybe_unused)
185+{
186+ return 0;
187+}
188+
189+static int perf_event__drop_aux(struct perf_tool *tool,
190+ union perf_event *event __maybe_unused,
191+ struct perf_sample *sample,
192+ struct machine *machine __maybe_unused)
193+{
194+ struct perf_inject *inject = container_of(tool, struct perf_inject, tool);
195+
196+ if (!inject->aux_id)
197+ inject->aux_id = sample->id;
198+
199+ return 0;
200+}
201+
179202 typedef int (*inject_handler)(struct perf_tool *tool,
180203 union perf_event *event,
181204 struct perf_sample *sample,
@@ -466,6 +489,78 @@ static int perf_evsel__check_stype(struct perf_evsel *evsel, · 284 unmodified lines
466489 return 0;
467490 }
468491
492+static int drop_sample(struct perf_tool *tool __maybe_unused,
493+ union perf_event *event __maybe_unused,
494+ struct perf_sample *sample __maybe_unused,
495+ struct perf_evsel *evsel __maybe_unused,
496+ struct machine *machine __maybe_unused)
497+{
498+ return 0;
499+}
500+
501+static void strip_init(struct perf_inject *inject)
502+{
503+ struct perf_evlist *evlist = inject->session->evlist;
504+ struct perf_evsel *evsel;
505+
506+ inject->tool.context_switch = perf_event__drop;
507+
508+ evlist__for_each(evlist, evsel)
509+ evsel->handler = drop_sample;
510+}
511+
512+static bool has_tracking(struct perf_evsel *evsel)
513+{
514+ return evsel->attr.mmap || evsel->attr.mmap2 || evsel->attr.comm ||
515+ evsel->attr.task;
516+}
517+
518+#define COMPAT_MASK (PERF_SAMPLE_ID | PERF_SAMPLE_TID | PERF_SAMPLE_TIME | \
519+ PERF_SAMPLE_ID | PERF_SAMPLE_CPU | PERF_SAMPLE_IDENTIFIER)
520+
521+/*
522+ * In order that the perf.data file is parsable, tracking events like MMAP need
523+ * their selected event to exist, except if there is only 1 selected event left
524+ * and it has a compatible sample type.
525+ */
526+static bool ok_to_remove(struct perf_evlist *evlist,
527+ struct perf_evsel *evsel_to_remove)
528+{
529+ struct perf_evsel *evsel;
530+ int cnt = 0;
531+ bool ok = false;
532+
533+ if (!has_tracking(evsel_to_remove))
534+ return true;
535+
536+ evlist__for_each(evlist, evsel) {
537+ if (evsel->handler != drop_sample) {
538+ cnt += 1;
539+ if ((evsel->attr.sample_type & COMPAT_MASK) ==
540+ (evsel_to_remove->attr.sample_type & COMPAT_MASK))
541+ ok = true;
542+ }
543+ }
544+
545+ return ok && cnt == 1;
546+}
547+
548+static void strip_fini(struct perf_inject *inject)
549+{
550+ struct perf_evlist *evlist = inject->session->evlist;
551+ struct perf_evsel *evsel, *tmp;
552+
553+ /* Remove non-synthesized evsels if possible */
554+ evlist__for_each_safe(evlist, tmp, evsel) {
555+ if (evsel->handler == drop_sample &&
556+ ok_to_remove(evlist, evsel)) {
557+ pr_debug("Deleting %s\n", perf_evsel__name(evsel));
558+ perf_evlist__remove(evlist, evsel);
559+ perf_evsel__delete(evsel);
560+ }
561+ }
562+}
563+
469564 static int __cmd_inject(struct perf_inject *inject)
470565 {
471566 int ret = -EINVAL;
@@ -512,10 +607,14 @@ static int __cmd_inject(struct perf_inject *inject) · 40 unmodified lines
512607 inject->tool.id_index = perf_event__repipe_id_index;
513608 inject->tool.auxtrace_info = perf_event__process_auxtrace_info;
514609 inject->tool.auxtrace = perf_event__process_auxtrace;
610+ inject->tool.aux = perf_event__drop_aux;
611+ inject->tool.itrace_start = perf_event__drop_aux,
515612 inject->tool.ordered_events = true;
516613 inject->tool.ordering_requires_timestamps = true;
517614 /* Allow space in the header for new attributes */
518615 output_data_offset = 4096;
616+ if (inject->strip)
617+ strip_init(inject);
519618 }
520619
521620 if (!inject->itrace_synth_opts.set)
@@ -535,11 +634,28 @@ static int __cmd_inject(struct perf_inject *inject) · 13 unmodified lines
535634 }
536635 /*
537636 * The AUX areas have been removed and replaced with
538− * synthesized hardware events, so clear the feature flag.
637+ * synthesized hardware events, so clear the feature flag and
638+ * remove the evsel.
539639 */
540− if (inject->itrace_synth_opts.set)
640+ if (inject->itrace_synth_opts.set) {
641+ struct perf_evsel *evsel;
642+
541643 perf_header__clear_feat(&session->header,
542644 HEADER_AUXTRACE);
645+ if (inject->itrace_synth_opts.last_branch)
646+ perf_header__set_feat(&session->header,
647+ HEADER_BRANCH_STACK);
648+ evsel = perf_evlist__id2evsel_strict(session->evlist,
649+ inject->aux_id);
650+ if (evsel) {
651+ pr_debug("Deleting %s\n",
652+ perf_evsel__name(evsel));
653+ perf_evlist__remove(session->evlist, evsel);
654+ perf_evsel__delete(evsel);
655+ }
656+ if (inject->strip)
657+ strip_fini(inject);
658+ }
543659 session->header.data_offset = output_data_offset;
544660 session->header.data_size = inject->bytes_written;
545661 perf_session__write_header(session, session->evlist, fd, true);
@@ -604,6 +720,8 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) · 58 unmodified lines
604720 OPT_CALLBACK_OPTARG(0, "itrace", &inject.itrace_synth_opts,
605721 NULL, "opts", "Instruction Tracing options",
606722 itrace_parse_synth_opts),
723+ OPT_BOOLEAN(0, "strip", &inject.strip,
724+ "strip non-synthesized events (use with --itrace)"),
607725 OPT_END()
608726 };
609727 const char * const inject_usage[] = {
@@ -619,6 +737,11 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) · 9 unmodified lines
619737 if (argc)
620738 usage_with_options(inject_usage, options);
621739
740+ if (inject.strip && !inject.itrace_synth_opts.set) {
741+ pr_err("--strip option requires --itrace option\n");
742+ return -1;
743+ }
744+
622745 if (perf_data_file__open(&inject.output)) {
623746 perror("failed to create output file");
624747 return -1;
tools/perf/builtin-kmem.c+1−1
@@ -329,7 +329,7 @@ static int build_alloc_func_list(void) · 328 unmodified lines
329329 return -EINVAL;
330330 }
331331
332− kernel_map = machine->vmlinux_maps[MAP__FUNCTION];
332+ kernel_map = machine__kernel_map(machine);
333333 if (map__load(kernel_map, NULL) < 0) {
334334 pr_err("cannot load kernel map\n");
335335 return -ENOENT;
tools/perf/builtin-kvm.c+0−1
@@ -13,7 +13,6 @@ · 12 unmodified lines
1313 #include "util/parse-options.h"
1414 #include "util/trace-event.h"
1515 #include "util/debug.h"
16−#include <api/fs/debugfs.h>
1716 #include "util/tool.h"
1817 #include "util/stat.h"
1918 #include "util/top.h"
tools/perf/builtin-list.c+17−3
@@ -36,7 +36,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) · 35 unmodified lines
3636
3737 setup_pager();
3838
39− if (!raw_dump)
39+ if (!raw_dump && pager_in_use())
4040 printf("\nList of pre-defined events (to be used in -e):\n\n");
4141
4242 if (argc == 0) {
@@ -45,6 +45,8 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) · 2 unmodified lines
4545 }
4646
4747 for (i = 0; i < argc; ++i) {
48+ char *sep, *s;
49+
4850 if (strcmp(argv[i], "tracepoint") == 0)
4951 print_tracepoint_events(NULL, NULL, raw_dump);
5052 else if (strcmp(argv[i], "hw") == 0 ||
@@ -60,8 +62,7 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) · 9 unmodified lines
6062 print_hwcache_events(NULL, raw_dump);
6163 else if (strcmp(argv[i], "pmu") == 0)
6264 print_pmu_events(NULL, raw_dump);
63− else {
64− char *sep = strchr(argv[i], ':'), *s;
65+ else if ((sep = strchr(argv[i], ':')) != NULL) {
6566 int sep_idx;
6667
6768 if (sep == NULL) {
@@ -76,6 +77,19 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) · 8 unmodified lines
7677 s[sep_idx] = '\0';
7778 print_tracepoint_events(s, s + sep_idx + 1, raw_dump);
7879 free(s);
80+ } else {
81+ if (asprintf(&s, "*%s*", argv[i]) < 0) {
82+ printf("Critical: Not enough memory! Trying to continue...\n");
83+ continue;
84+ }
85+ print_symbol_events(s, PERF_TYPE_HARDWARE,
86+ event_symbols_hw, PERF_COUNT_HW_MAX, raw_dump);
87+ print_symbol_events(s, PERF_TYPE_SOFTWARE,
88+ event_symbols_sw, PERF_COUNT_SW_MAX, raw_dump);
89+ print_hwcache_events(s, raw_dump);
90+ print_pmu_events(s, raw_dump);
91+ print_tracepoint_events(NULL, s, raw_dump);
92+ free(s);
7993 }
8094 }
8195 return 0;
tools/perf/builtin-probe.c+131−16
@@ -37,10 +37,10 @@ · 36 unmodified lines
3737 #include "util/strfilter.h"
3838 #include "util/symbol.h"
3939 #include "util/debug.h"
40−#include <api/fs/debugfs.h>
4140 #include "util/parse-options.h"
4241 #include "util/probe-finder.h"
4342 #include "util/probe-event.h"
43+#include "util/probe-file.h"
4444
4545 #define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*"
4646 #define DEFAULT_FUNC_FILTER "!_*"
@@ -182,10 +182,8 @@ static int opt_set_target(const struct option *opt, const char *str, · 135 unmodified lines
182182 if (str) {
183183 if (!strcmp(opt->long_name, "exec"))
184184 params.uprobes = true;
185−#ifdef HAVE_DWARF_SUPPORT
186185 else if (!strcmp(opt->long_name, "module"))
187186 params.uprobes = false;
188−#endif
189187 else
190188 return ret;
191189
@@ -311,6 +309,119 @@ static void pr_err_with_code(const char *msg, int err) · 119 unmodified lines
311309 pr_err("\n");
312310 }
313311
312+static int perf_add_probe_events(struct perf_probe_event *pevs, int npevs)
313+{
314+ int ret;
315+ int i, k;
316+ const char *event = NULL, *group = NULL;
317+
318+ ret = init_probe_symbol_maps(pevs->uprobes);
319+ if (ret < 0)
320+ return ret;
321+
322+ ret = convert_perf_probe_events(pevs, npevs);
323+ if (ret < 0)
324+ goto out_cleanup;
325+
326+ ret = apply_perf_probe_events(pevs, npevs);
327+ if (ret < 0)
328+ goto out_cleanup;
329+
330+ for (i = k = 0; i < npevs; i++)
331+ k += pevs[i].ntevs;
332+
333+ pr_info("Added new event%s\n", (k > 1) ? "s:" : ":");
334+ for (i = 0; i < npevs; i++) {
335+ struct perf_probe_event *pev = &pevs[i];
336+
337+ for (k = 0; k < pev->ntevs; k++) {
338+ struct probe_trace_event *tev = &pev->tevs[k];
339+
340+ /* We use tev's name for showing new events */
341+ show_perf_probe_event(tev->group, tev->event, pev,
342+ tev->point.module, false);
343+
344+ /* Save the last valid name */
345+ event = tev->event;
346+ group = tev->group;
347+ }
348+ }
349+
350+ /* Note that it is possible to skip all events because of blacklist */
351+ if (event) {
352+ /* Show how to use the event. */
353+ pr_info("\nYou can now use it in all perf tools, such as:\n\n");
354+ pr_info("\tperf record -e %s:%s -aR sleep 1\n\n", group, event);
355+ }
356+
357+out_cleanup:
358+ cleanup_perf_probe_events(pevs, npevs);
359+ exit_probe_symbol_maps();
360+ return ret;
361+}
362+
363+static int perf_del_probe_events(struct strfilter *filter)
364+{
365+ int ret, ret2, ufd = -1, kfd = -1;
366+ char *str = strfilter__string(filter);
367+ struct strlist *klist = NULL, *ulist = NULL;
368+ struct str_node *ent;
369+
370+ if (!str)
371+ return -EINVAL;
372+
373+ pr_debug("Delete filter: \'%s\'\n", str);
374+
375+ /* Get current event names */
376+ ret = probe_file__open_both(&kfd, &ufd, PF_FL_RW);
377+ if (ret < 0)
378+ goto out;
379+
380+ klist = strlist__new(NULL, NULL);
381+ ulist = strlist__new(NULL, NULL);
382+ if (!klist || !ulist) {
383+ ret = -ENOMEM;
384+ goto out;
385+ }
386+
387+ ret = probe_file__get_events(kfd, filter, klist);
388+ if (ret == 0) {
389+ strlist__for_each(ent, klist)
390+ pr_info("Removed event: %s\n", ent->s);
391+
392+ ret = probe_file__del_strlist(kfd, klist);
393+ if (ret < 0)
394+ goto error;
395+ }
396+
397+ ret2 = probe_file__get_events(ufd, filter, ulist);
398+ if (ret2 == 0) {
399+ strlist__for_each(ent, ulist)
400+ pr_info("Removed event: %s\n", ent->s);
401+
402+ ret2 = probe_file__del_strlist(ufd, ulist);
403+ if (ret2 < 0)
404+ goto error;
405+ }
406+
407+ if (ret == -ENOENT && ret2 == -ENOENT)
408+ pr_debug("\"%s\" does not hit any event.\n", str);
409+ /* Note that this is silently ignored */
410+ ret = 0;
411+
412+error:
413+ if (kfd >= 0)
414+ close(kfd);
415+ if (ufd >= 0)
416+ close(ufd);
417+out:
418+ strlist__delete(klist);
419+ strlist__delete(ulist);
420+ free(str);
421+
422+ return ret;
423+}
424+
314425 static int
315426 __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
316427 {
@@ -377,9 +488,6 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) · 60 unmodified lines
377488 "file", "vmlinux pathname"),
378489 OPT_STRING('s', "source", &symbol_conf.source_prefix,
379490 "directory", "path to kernel source"),
380− OPT_CALLBACK('m', "module", NULL, "modname|path",
381− "target module name (for online) or path (for offline)",
382− opt_set_target),
383491 OPT_BOOLEAN('\0', "no-inlines", &probe_conf.no_inlines,
384492 "Don't search inlined functions"),
385493 #endif
@@ -396,6 +504,9 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) · 10 unmodified lines
396504 opt_set_filter),
397505 OPT_CALLBACK('x', "exec", NULL, "executable|path",
398506 "target executable name or path", opt_set_target),
507+ OPT_CALLBACK('m', "module", NULL, "modname|path",
508+ "target module name (for online) or path (for offline)",
509+ opt_set_target),
399510 OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
400511 "Enable symbol demangling"),
401512 OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
@@ -417,12 +528,12 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) · 15 unmodified lines
417528 PARSE_OPT_STOP_AT_NON_OPTION);
418529 if (argc > 0) {
419530 if (strcmp(argv[0], "-") == 0) {
420− pr_warning(" Error: '-' is not supported.\n");
421− usage_with_options(probe_usage, options);
531+ usage_with_options_msg(probe_usage, options,
532+ "'-' is not supported.\n");
422533 }
423534 if (params.command && params.command != 'a') {
424− pr_warning(" Error: another command except --add is set.\n");
425− usage_with_options(probe_usage, options);
535+ usage_with_options_msg(probe_usage, options,
536+ "another command except --add is set.\n");
426537 }
427538 ret = parse_probe_event_argv(argc, argv);
428539 if (ret < 0) {
@@ -451,8 +562,10 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) · 22 unmodified lines
451562 switch (params.command) {
452563 case 'l':
453564 if (params.uprobes) {
454− pr_warning(" Error: Don't use --list with --exec.\n");
455− usage_with_options(probe_usage, options);
565+ pr_err(" Error: Don't use --list with --exec.\n");
566+ parse_options_usage(probe_usage, options, "l", true);
567+ parse_options_usage(NULL, options, "x", true);
568+ return -EINVAL;
456569 }
457570 ret = show_perf_probe_events(params.filter);
458571 if (ret < 0)
@@ -483,7 +596,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) · 24 unmodified lines
483596 return ret;
484597 #endif
485598 case 'd':
486− ret = del_perf_probe_events(params.filter);
599+ ret = perf_del_probe_events(params.filter);
487600 if (ret < 0) {
488601 pr_err_with_code(" Error: Failed to delete events.", ret);
489602 return ret;
@@ -492,11 +605,13 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) · 2 unmodified lines
492605 case 'a':
493606 /* Ensure the last given target is used */
494607 if (params.target && !params.target_used) {
495− pr_warning(" Error: -x/-m must follow the probe definitions.\n");
496− usage_with_options(probe_usage, options);
608+ pr_err(" Error: -x/-m must follow the probe definitions.\n");
609+ parse_options_usage(probe_usage, options, "m", true);
610+ parse_options_usage(NULL, options, "x", true);
611+ return -EINVAL;
497612 }
498613
499− ret = add_perf_probe_events(params.events, params.nevents);
614+ ret = perf_add_probe_events(params.events, params.nevents);
500615 if (ret < 0) {
501616 pr_err_with_code(" Error: Failed to add events.", ret);
502617 return ret;
tools/perf/builtin-record.c+40−16
@@ -31,6 +31,7 @@ · 30 unmodified lines
3131 #include "util/auxtrace.h"
3232 #include "util/parse-branch-options.h"
3333 #include "util/parse-regs-options.h"
34+#include "util/llvm-utils.h"
3435
3536 #include <unistd.h>
3637 #include <sched.h>
@@ -49,7 +50,7 @@ struct record { · 12 unmodified lines
4950 int realtime_prio;
5051 bool no_buildid;
5152 bool no_buildid_cache;
52− long samples;
53+ unsigned long long samples;
5354 };
5455
5556 static int record__write(struct record *rec, void *bf, size_t size)
@@ -636,8 +637,29 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) · 580 unmodified lines
636637 /*
637638 * Let the child rip
638639 */
639− if (forks)
640+ if (forks) {
641+ union perf_event *event;
642+
643+ event = malloc(sizeof(event->comm) + machine->id_hdr_size);
644+ if (event == NULL) {
645+ err = -ENOMEM;
646+ goto out_child;
647+ }
648+
649+ /*
650+ * Some H/W events are generated before COMM event
651+ * which is emitted during exec(), so perf script
652+ * cannot see a correct process name for those events.
653+ * Synthesize COMM event to prevent it.
654+ */
655+ perf_event__synthesize_comm(tool, event,
656+ rec->evlist->workload.pid,
657+ process_synthesized_event,
658+ machine);
659+ free(event);
660+
640661 perf_evlist__start_workload(rec->evlist);
662+ }
641663
642664 if (opts->initial_delay) {
643665 usleep(opts->initial_delay * 1000);
@@ -646,7 +668,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) · 2 unmodified lines
646668
647669 auxtrace_snapshot_enabled = 1;
648670 for (;;) {
649− int hits = rec->samples;
671+ unsigned long long hits = rec->samples;
650672
651673 if (record__mmap_read_all(rec) < 0) {
652674 auxtrace_snapshot_enabled = 0;
@@ -989,13 +1011,8 @@ static struct record record = { · 336 unmodified lines
9891011 },
9901012 };
9911013
992−#define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace) recording: "
993−
994−#ifdef HAVE_DWARF_UNWIND_SUPPORT
995−const char record_callchain_help[] = CALLCHAIN_HELP "fp dwarf lbr";
996−#else
997−const char record_callchain_help[] = CALLCHAIN_HELP "fp lbr";
998−#endif
1014+const char record_callchain_help[] = CALLCHAIN_RECORD_HELP
1015+ "\n\t\t\t\tDefault: fp";
9991016
10001017 /*
10011018 * XXX Will stay a global variable till we fix builtin-script.c to stop messing
@@ -1043,7 +1060,7 @@ struct option __record_options[] = { · 41 unmodified lines
10431060 NULL, "enables call-graph recording" ,
10441061 &record_callchain_opt),
10451062 OPT_CALLBACK(0, "call-graph", &record.opts,
1046− "mode[,dump_size]", record_callchain_help,
1063+ "record_mode[,record_size]", record_callchain_help,
10471064 &record_parse_callchain_opt),
10481065 OPT_INCR('v', "verbose", &verbose,
10491066 "be more verbose (show counter open errors, etc)"),
@@ -1096,6 +1113,12 @@ struct option __record_options[] = { · 46 unmodified lines
10961113 "per thread proc mmap processing timeout in ms"),
10971114 OPT_BOOLEAN(0, "switch-events", &record.opts.record_switch_events,
10981115 "Record context switch events"),
1116+#ifdef HAVE_LIBBPF_SUPPORT
1117+ OPT_STRING(0, "clang-path", &llvm_param.clang_path, "clang path",
1118+ "clang binary to use for compiling BPF scriptlets"),
1119+ OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
1120+ "options passed to clang when compiling BPF scriptlets"),
1121+#endif
10991122 OPT_END()
11001123 };
11011124
@@ -1119,14 +1142,15 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) · 17 unmodified lines
11191142 usage_with_options(record_usage, record_options);
11201143
11211144 if (nr_cgroups && !rec->opts.target.system_wide) {
1122− ui__error("cgroup monitoring only available in"
1123− " system-wide mode\n");
1124− usage_with_options(record_usage, record_options);
1145+ usage_with_options_msg(record_usage, record_options,
1146+ "cgroup monitoring only available in system-wide mode");
1147+
11251148 }
11261149 if (rec->opts.record_switch_events &&
11271150 !perf_can_record_switch_events()) {
1128− ui__error("kernel does not support recording context switch events (--switch-events option)\n");
1129− usage_with_options(record_usage, record_options);
1151+ ui__error("kernel does not support recording context switch events\n");
1152+ parse_options_usage(record_usage, record_options, "switch-events", 0);
1153+ return -EINVAL;
11301154 }
11311155
11321156 if (!rec->itr) {
tools/perf/builtin-report.c+55−10
@@ -62,6 +62,7 @@ struct report { · 61 unmodified lines
6262 float min_percent;
6363 u64 nr_entries;
6464 u64 queue_size;
65+ int socket_filter;
6566 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
6667 };
6768
@@ -162,14 +163,21 @@ static int process_sample_event(struct perf_tool *tool, · 94 unmodified lines
162163 if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap))
163164 goto out_put;
164165
165− if (sort__mode == SORT_MODE__BRANCH)
166+ if (sort__mode == SORT_MODE__BRANCH) {
167+ /*
168+ * A non-synthesized event might not have a branch stack if
169+ * branch stacks have been synthesized (using itrace options).
170+ */
171+ if (!sample->branch_stack)
172+ goto out_put;
166173 iter.ops = &hist_iter_branch;
167− else if (rep->mem_mode)
174+ } else if (rep->mem_mode) {
168175 iter.ops = &hist_iter_mem;
169− else if (symbol_conf.cumulate_callchain)
176+ } else if (symbol_conf.cumulate_callchain) {
170177 iter.ops = &hist_iter_cumulative;
171− else
178+ } else {
172179 iter.ops = &hist_iter_normal;
180+ }
173181
174182 if (al.map != NULL)
175183 al.map->dso->hit = 1;
@@ -213,6 +221,15 @@ static int report__setup_sample_type(struct report *rep) · 37 unmodified lines
213221 u64 sample_type = perf_evlist__combined_sample_type(session->evlist);
214222 bool is_pipe = perf_data_file__is_pipe(session->file);
215223
224+ if (session->itrace_synth_opts->callchain ||
225+ (!is_pipe &&
226+ perf_header__has_feat(&session->header, HEADER_AUXTRACE) &&
227+ !session->itrace_synth_opts->set))
228+ sample_type |= PERF_SAMPLE_CALLCHAIN;
229+
230+ if (session->itrace_synth_opts->last_branch)
231+ sample_type |= PERF_SAMPLE_BRANCH_STACK;
232+
216233 if (!is_pipe && !(sample_type & PERF_SAMPLE_CALLCHAIN)) {
217234 if (sort__has_parent) {
218235 ui__error("Selected --sort parent, but no "
@@ -286,6 +303,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report · 67 unmodified lines
286303 struct perf_evsel *evsel = hists_to_evsel(hists);
287304 char buf[512];
288305 size_t size = sizeof(buf);
306+ int socked_id = hists->socket_filter;
289307
290308 if (symbol_conf.filter_relative) {
291309 nr_samples = hists->stats.nr_non_filtered_samples;
@@ -326,6 +344,10 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report · 34 unmodified lines
326344 ret += fprintf(fp, "\n# Sort order : %s", sort_order ? : default_mem_sort_order);
327345 } else
328346 ret += fprintf(fp, "\n# Event count (approx.): %" PRIu64, nr_events);
347+
348+ if (socked_id > -1)
349+ ret += fprintf(fp, "\n# Processor Socket: %d", socked_id);
350+
329351 return ret + fprintf(fp, "\n#\n");
330352 }
331353
@@ -365,7 +387,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, · 33 unmodified lines
365387
366388 static void report__warn_kptr_restrict(const struct report *rep)
367389 {
368− struct map *kernel_map = rep->session->machines.host.vmlinux_maps[MAP__FUNCTION];
390+ struct map *kernel_map = machine__kernel_map(&rep->session->machines.host);
369391 struct kmap *kernel_kmap = kernel_map ? map__kmap(kernel_map) : NULL;
370392
371393 if (kernel_map == NULL ||
@@ -450,6 +472,8 @@ static void report__collapse_hists(struct report *rep) · 78 unmodified lines
450472 if (pos->idx == 0)
451473 hists->symbol_filter_str = rep->symbol_filter_str;
452474
475+ hists->socket_filter = rep->socket_filter;
476+
453477 hists__collapse_resort(hists, &prog);
454478
455479 /* Non-group events are considered as leader */
@@ -601,6 +625,12 @@ parse_percent_limit(const struct option *opt, const char *str, · 145 unmodified lines
601625 return 0;
602626 }
603627
628+#define CALLCHAIN_DEFAULT_OPT "graph,0.5,caller,function"
629+
630+const char report_callchain_help[] = "Display call graph (stack chain/backtrace):\n\n"
631+ CALLCHAIN_REPORT_HELP
632+ "\n\t\t\t\tDefault: " CALLCHAIN_DEFAULT_OPT;
633+
604634 int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
605635 {
606636 struct perf_session *session;
@@ -609,7 +639,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) · 2 unmodified lines
609639 bool has_br_stack = false;
610640 int branch_mode = -1;
611641 bool branch_call_mode = false;
612− char callchain_default_opt[] = "fractal,0.5,callee";
642+ char callchain_default_opt[] = CALLCHAIN_DEFAULT_OPT;
613643 const char * const report_usage[] = {
614644 "perf report [<options>]",
615645 NULL
@@ -635,6 +665,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) · 19 unmodified lines
635665 },
636666 .max_stack = PERF_MAX_STACK_DEPTH,
637667 .pretty_printing_style = "normal",
668+ .socket_filter = -1,
638669 };
639670 const struct option options[] = {
640671 OPT_STRING('i', "input", &input_name, "file",
@@ -668,15 +699,18 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) · 27 unmodified lines
668699 " Please refer the man page for the complete list."),
669700 OPT_STRING('F', "fields", &field_order, "key[,keys...]",
670701 "output field(s): overhead, period, sample plus all of sort keys"),
671− OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
702+ OPT_BOOLEAN(0, "show-cpu-utilization", &symbol_conf.show_cpu_utilization,
672703 "Show sample percentage for different cpu modes"),
704+ OPT_BOOLEAN_FLAG(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
705+ "Show sample percentage for different cpu modes", PARSE_OPT_HIDDEN),
673706 OPT_STRING('p', "parent", &parent_pattern, "regex",
674707 "regex filter to identify parent, see: '--sort parent'"),
675708 OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other,
676709 "Only display entries with parent-match"),
677− OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order[,branch]",
678− "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address), add branches. "
679− "Default: fractal,0.5,callee,function", &report_parse_callchain_opt, callchain_default_opt),
710+ OPT_CALLBACK_DEFAULT('g', "call-graph", &report,
711+ "print_type,threshold[,print_limit],order,sort_key[,branch]",
712+ report_callchain_help, &report_parse_callchain_opt,
713+ callchain_default_opt),
680714 OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
681715 "Accumulate callchains of children and show total overhead as well"),
682716 OPT_INTEGER(0, "max-stack", &report.max_stack,
@@ -747,6 +781,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) · 64 unmodified lines
747781 "Show full source file name path for source lines"),
748782 OPT_BOOLEAN(0, "show-ref-call-graph", &symbol_conf.show_ref_callgraph,
749783 "Show callgraph from reference event"),
784+ OPT_INTEGER(0, "socket-filter", &report.socket_filter,
785+ "only show processor socket that match with this filter"),
750786 OPT_END()
751787 };
752788 struct perf_data_file file = {
@@ -781,6 +817,12 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) · 28 unmodified lines
781817
782818 if (report.inverted_callchain)
783819 callchain_param.order = ORDER_CALLER;
820+ if (symbol_conf.cumulate_callchain && !callchain_param.order_set)
821+ callchain_param.order = ORDER_CALLER;
822+
823+ if (itrace_synth_opts.callchain &&
824+ (int)itrace_synth_opts.callchain_sz > report.max_stack)
825+ report.max_stack = itrace_synth_opts.callchain_sz;
784826
785827 if (!input_name || !strlen(input_name)) {
786828 if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode))
@@ -809,6 +851,9 @@ repeat: · 22 unmodified lines
809851 has_br_stack = perf_header__has_feat(&session->header,
810852 HEADER_BRANCH_STACK);
811853
854+ if (itrace_synth_opts.last_branch)
855+ has_br_stack = true;
856+
812857 /*
813858 * Branch mode is a tristate:
814859 * -1 means default, so decide based on the file having branch data.
tools/perf/builtin-sched.c+2−2
@@ -1728,8 +1728,8 @@ static void setup_sorting(struct perf_sched *sched, const struct option *options · 1727 unmodified lines
17281728 for (tok = strtok_r(str, ", ", &tmp);
17291729 tok; tok = strtok_r(NULL, ", ", &tmp)) {
17301730 if (sort_dimension__add(tok, &sched->sort_list) < 0) {
1731− error("Unknown --sort key: `%s'", tok);
1732− usage_with_options(usage_msg, options);
1731+ usage_with_options_msg(usage_msg, options,
1732+ "Unknown --sort key: `%s'", tok);
17331733 }
17341734 }
17351735
tools/perf/builtin-script.c+104−9
@@ -29,9 +29,12 @@ static bool no_callchain; · 28 unmodified lines
2929 static bool latency_format;
3030 static bool system_wide;
3131 static bool print_flags;
32+static bool nanosecs;
3233 static const char *cpu_list;
3334 static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
3435
36+unsigned int scripting_max_stack = PERF_MAX_STACK_DEPTH;
37+
3538 enum perf_output_field {
3639 PERF_OUTPUT_COMM = 1U << 0,
3740 PERF_OUTPUT_TID = 1U << 1,
@@ -48,6 +51,8 @@ enum perf_output_field { · 10 unmodified lines
4851 PERF_OUTPUT_SRCLINE = 1U << 12,
4952 PERF_OUTPUT_PERIOD = 1U << 13,
5053 PERF_OUTPUT_IREGS = 1U << 14,
54+ PERF_OUTPUT_BRSTACK = 1U << 15,
55+ PERF_OUTPUT_BRSTACKSYM = 1U << 16,
5156 };
5257
5358 struct output_option {
@@ -69,6 +74,8 @@ struct output_option { · 15 unmodified lines
6974 {.str = "srcline", .field = PERF_OUTPUT_SRCLINE},
7075 {.str = "period", .field = PERF_OUTPUT_PERIOD},
7176 {.str = "iregs", .field = PERF_OUTPUT_IREGS},
77+ {.str = "brstack", .field = PERF_OUTPUT_BRSTACK},
78+ {.str = "brstacksym", .field = PERF_OUTPUT_BRSTACKSYM},
7279 };
7380
7481 /* default set to maintain compatibility with current format */
@@ -415,10 +422,84 @@ static void print_sample_start(struct perf_sample *sample, · 340 unmodified lines
415422 secs = nsecs / NSECS_PER_SEC;
416423 nsecs -= secs * NSECS_PER_SEC;
417424 usecs = nsecs / NSECS_PER_USEC;
418− printf("%5lu.%06lu: ", secs, usecs);
425+ if (nanosecs)
426+ printf("%5lu.%09llu: ", secs, nsecs);
427+ else
428+ printf("%5lu.%06lu: ", secs, usecs);
419429 }
420430 }
421431
432+static inline char
433+mispred_str(struct branch_entry *br)
434+{
435+ if (!(br->flags.mispred || br->flags.predicted))
436+ return '-';
437+
438+ return br->flags.predicted ? 'P' : 'M';
439+}
440+
441+static void print_sample_brstack(union perf_event *event __maybe_unused,
442+ struct perf_sample *sample,
443+ struct thread *thread __maybe_unused,
444+ struct perf_event_attr *attr __maybe_unused)
445+{
446+ struct branch_stack *br = sample->branch_stack;
447+ u64 i;
448+
449+ if (!(br && br->nr))
450+ return;
451+
452+ for (i = 0; i < br->nr; i++) {
453+ printf(" 0x%"PRIx64"/0x%"PRIx64"/%c/%c/%c/%d ",
454+ br->entries[i].from,
455+ br->entries[i].to,
456+ mispred_str( br->entries + i),
457+ br->entries[i].flags.in_tx? 'X' : '-',
458+ br->entries[i].flags.abort? 'A' : '-',
459+ br->entries[i].flags.cycles);
460+ }
461+}
462+
463+static void print_sample_brstacksym(union perf_event *event __maybe_unused,
464+ struct perf_sample *sample,
465+ struct thread *thread __maybe_unused,
466+ struct perf_event_attr *attr __maybe_unused)
467+{
468+ struct branch_stack *br = sample->branch_stack;
469+ struct addr_location alf, alt;
470+ u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
471+ u64 i, from, to;
472+
473+ if (!(br && br->nr))
474+ return;
475+
476+ for (i = 0; i < br->nr; i++) {
477+
478+ memset(&alf, 0, sizeof(alf));
479+ memset(&alt, 0, sizeof(alt));
480+ from = br->entries[i].from;
481+ to = br->entries[i].to;
482+
483+ thread__find_addr_map(thread, cpumode, MAP__FUNCTION, from, &alf);
484+ if (alf.map)
485+ alf.sym = map__find_symbol(alf.map, alf.addr, NULL);
486+
487+ thread__find_addr_map(thread, cpumode, MAP__FUNCTION, to, &alt);
488+ if (alt.map)
489+ alt.sym = map__find_symbol(alt.map, alt.addr, NULL);
490+
491+ symbol__fprintf_symname_offs(alf.sym, &alf, stdout);
492+ putchar('/');
493+ symbol__fprintf_symname_offs(alt.sym, &alt, stdout);
494+ printf("/%c/%c/%c/%d ",
495+ mispred_str( br->entries + i),
496+ br->entries[i].flags.in_tx? 'X' : '-',
497+ br->entries[i].flags.abort? 'A' : '-',
498+ br->entries[i].flags.cycles);
499+ }
500+}
501+
502+
422503 static void print_sample_addr(union perf_event *event,
423504 struct perf_sample *sample,
424505 struct thread *thread,
@@ -471,7 +552,7 @@ static void print_sample_bts(union perf_event *event, · 46 unmodified lines
471552 }
472553 }
473554 perf_evsel__print_ip(evsel, sample, al, print_opts,
474− PERF_MAX_STACK_DEPTH);
555+ scripting_max_stack);
475556 }
476557
477558 /* print branch_to information */
@@ -548,12 +629,17 @@ static void process_event(union perf_event *event, struct perf_sample *sample, · 70 unmodified lines
548629
549630 perf_evsel__print_ip(evsel, sample, al,
550631 output[attr->type].print_ip_opts,
551− PERF_MAX_STACK_DEPTH);
632+ scripting_max_stack);
552633 }
553634
554635 if (PRINT_FIELD(IREGS))
555636 print_sample_iregs(event, sample, thread, attr);
556637
638+ if (PRINT_FIELD(BRSTACK))
639+ print_sample_brstack(event, sample, thread, attr);
640+ else if (PRINT_FIELD(BRSTACKSYM))
641+ print_sample_brstacksym(event, sample, thread, attr);
642+
557643 printf("\n");
558644 }
559645
@@ -680,7 +766,10 @@ static int process_attr(struct perf_tool *tool, union perf_event *event, · 120 unmodified lines
680766
681767 set_print_ip_opts(&evsel->attr);
682768
683− return perf_evsel__check_attr(evsel, scr->session);
769+ if (evsel->attr.sample_type)
770+ err = perf_evsel__check_attr(evsel, scr->session);
771+
772+ return err;
684773 }
685774
686775 static int process_comm_event(struct perf_tool *tool,
@@ -1672,7 +1761,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) · 985 unmodified lines
16721761 "comma separated output fields prepend with 'type:'. "
16731762 "Valid types: hw,sw,trace,raw. "
16741763 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
1675− "addr,symoff,period,iregs,flags", parse_output_fields),
1764+ "addr,symoff,period,iregs,brstack,brstacksym,flags", parse_output_fields),
16761765 OPT_BOOLEAN('a', "all-cpus", &system_wide,
16771766 "system-wide collection from all CPUs"),
16781767 OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
@@ -1695,6 +1784,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) · 16 unmodified lines
16951784 OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events,
16961785 "Show context switch events (if recorded)"),
16971786 OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
1787+ OPT_BOOLEAN(0, "ns", &nanosecs,
1788+ "Use 9 decimal places when displaying time"),
16981789 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
16991790 "Instruction Tracing options",
17001791 itrace_parse_synth_opts),
@@ -1740,6 +1831,10 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) · 39 unmodified lines
17401831 }
17411832 }
17421833
1834+ if (itrace_synth_opts.callchain &&
1835+ itrace_synth_opts.callchain_sz > scripting_max_stack)
1836+ scripting_max_stack = itrace_synth_opts.callchain_sz;
1837+
17431838 /* make sure PERF_EXEC_PATH is set for scripts */
17441839 perf_set_argv_exec_path(perf_exec_path());
17451840
@@ -1752,9 +1847,9 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) · 6 unmodified lines
17521847 rep_script_path = get_script_path(argv[0], REPORT_SUFFIX);
17531848
17541849 if (!rec_script_path && !rep_script_path) {
1755− fprintf(stderr, " Couldn't find script %s\n\n See perf"
1850+ usage_with_options_msg(script_usage, options,
1851+ "Couldn't find script `%s'\n\n See perf"
17561852 " script -l for available scripts.\n", argv[0]);
1757− usage_with_options(script_usage, options);
17581853 }
17591854
17601855 if (is_top_script(argv[0])) {
@@ -1765,10 +1860,10 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) · 4 unmodified lines
17651860 rep_args = has_required_arg(rep_script_path);
17661861 rec_args = (argc - 1) - rep_args;
17671862 if (rec_args < 0) {
1768− fprintf(stderr, " %s script requires options."
1863+ usage_with_options_msg(script_usage, options,
1864+ "`%s' script requires options."
17691865 "\n\n See perf script -l for available "
17701866 "scripts and options.\n", argv[0]);
1771− usage_with_options(script_usage, options);
17721867 }
17731868 }
17741869
tools/perf/builtin-stat.c+82−11
@@ -100,6 +100,8 @@ static struct target target = { · 99 unmodified lines
100100 .uid = UINT_MAX,
101101 };
102102
103+typedef int (*aggr_get_id_t)(struct cpu_map *m, int cpu);
104+
103105 static int run_count = 1;
104106 static bool no_inherit = false;
105107 static volatile pid_t child_pid = -1;
@@ -119,7 +121,7 @@ static unsigned int unit_width = 4; /* strlen("unit") */ · 13 unmodified lines
119121 static bool forever = false;
120122 static struct timespec ref_time;
121123 static struct cpu_map *aggr_map;
122−static int (*aggr_get_id)(struct cpu_map *m, int cpu);
124+static aggr_get_id_t aggr_get_id;
123125
124126 static volatile int done = 0;
125127
@@ -215,7 +217,7 @@ static void read_counters(bool close_counters) · 89 unmodified lines
215217
216218 evlist__for_each(evsel_list, counter) {
217219 if (read_counter(counter))
218− pr_warning("failed to read counter %s\n", counter->name);
220+ pr_debug("failed to read counter %s\n", counter->name);
219221
220222 if (perf_stat_process_counter(&stat_config, counter))
221223 pr_warning("failed to process counter %s\n", counter->name);
@@ -434,7 +436,7 @@ static void print_noise_pct(double total, double avg) · 212 unmodified lines
434436
435437 static void print_noise(struct perf_evsel *evsel, double avg)
436438 {
437− struct perf_stat *ps;
439+ struct perf_stat_evsel *ps;
438440
439441 if (run_count == 1)
440442 return;
@@ -479,6 +481,7 @@ static void aggr_printout(struct perf_evsel *evsel, int id, int nr) · 38 unmodified lines
479481 csv_sep);
480482 break;
481483 case AGGR_GLOBAL:
484+ case AGGR_UNSET:
482485 default:
483486 break;
484487 }
@@ -671,7 +674,7 @@ static void print_aggr_thread(struct perf_evsel *counter, char *prefix) · 186 unmodified lines
671674 static void print_counter_aggr(struct perf_evsel *counter, char *prefix)
672675 {
673676 FILE *output = stat_config.output;
674− struct perf_stat *ps = counter->priv;
677+ struct perf_stat_evsel *ps = counter->priv;
675678 double avg = avg_stats(&ps->res_stats[0]);
676679 int scaled = counter->counts->scaled;
677680 double uval;
@@ -799,6 +802,8 @@ static void print_interval(char *prefix, struct timespec *ts) · 121 unmodified lines
799802 case AGGR_GLOBAL:
800803 default:
801804 fprintf(output, "# time counts %*s events\n", unit_width, "unit");
805+ case AGGR_UNSET:
806+ break;
802807 }
803808 }
804809
@@ -880,6 +885,7 @@ static void print_counters(struct timespec *ts, int argc, const char **argv) · 75 unmodified lines
880885 evlist__for_each(evsel_list, counter)
881886 print_counter(counter, prefix);
882887 break;
888+ case AGGR_UNSET:
883889 default:
884890 break;
885891 }
@@ -940,30 +946,90 @@ static int stat__set_big_num(const struct option *opt __maybe_unused, · 54 unmodified lines
940946 return 0;
941947 }
942948
949+static int perf_stat__get_socket(struct cpu_map *map, int cpu)
950+{
951+ return cpu_map__get_socket(map, cpu, NULL);
952+}
953+
954+static int perf_stat__get_core(struct cpu_map *map, int cpu)
955+{
956+ return cpu_map__get_core(map, cpu, NULL);
957+}
958+
959+static int cpu_map__get_max(struct cpu_map *map)
960+{
961+ int i, max = -1;
962+
963+ for (i = 0; i < map->nr; i++) {
964+ if (map->map[i] > max)
965+ max = map->map[i];
966+ }
967+
968+ return max;
969+}
970+
971+static struct cpu_map *cpus_aggr_map;
972+
973+static int perf_stat__get_aggr(aggr_get_id_t get_id, struct cpu_map *map, int idx)
974+{
975+ int cpu;
976+
977+ if (idx >= map->nr)
978+ return -1;
979+
980+ cpu = map->map[idx];
981+
982+ if (cpus_aggr_map->map[cpu] == -1)
983+ cpus_aggr_map->map[cpu] = get_id(map, idx);
984+
985+ return cpus_aggr_map->map[cpu];
986+}
987+
988+static int perf_stat__get_socket_cached(struct cpu_map *map, int idx)
989+{
990+ return perf_stat__get_aggr(perf_stat__get_socket, map, idx);
991+}
992+
993+static int perf_stat__get_core_cached(struct cpu_map *map, int idx)
994+{
995+ return perf_stat__get_aggr(perf_stat__get_core, map, idx);
996+}
997+
943998 static int perf_stat_init_aggr_mode(void)
944999 {
1000+ int nr;
1001+
9451002 switch (stat_config.aggr_mode) {
9461003 case AGGR_SOCKET:
9471004 if (cpu_map__build_socket_map(evsel_list->cpus, &aggr_map)) {
9481005 perror("cannot build socket map");
9491006 return -1;
9501007 }
951− aggr_get_id = cpu_map__get_socket;
1008+ aggr_get_id = perf_stat__get_socket_cached;
9521009 break;
9531010 case AGGR_CORE:
9541011 if (cpu_map__build_core_map(evsel_list->cpus, &aggr_map)) {
9551012 perror("cannot build core map");
9561013 return -1;
9571014 }
958− aggr_get_id = cpu_map__get_core;
1015+ aggr_get_id = perf_stat__get_core_cached;
9591016 break;
9601017 case AGGR_NONE:
9611018 case AGGR_GLOBAL:
9621019 case AGGR_THREAD:
1020+ case AGGR_UNSET:
9631021 default:
9641022 break;
9651023 }
966− return 0;
1024+
1025+ /*
1026+ * The evsel_list->cpus is the base we operate on,
1027+ * taking the highest cpu number to be the size of
1028+ * the aggregation translate cpumap.
1029+ */
1030+ nr = cpu_map__get_max(evsel_list->cpus);
1031+ cpus_aggr_map = cpu_map__empty_new(nr + 1);
1032+ return cpus_aggr_map ? 0 : -ENOMEM;
9671033 }
9681034
9691035 /*
@@ -1179,7 +1245,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) · 209 unmodified lines
11791245 OPT_STRING(0, "post", &post_cmd, "command",
11801246 "command to run after to the measured command"),
11811247 OPT_UINTEGER('I', "interval-print", &stat_config.interval,
1182− "print counts at regular interval in ms (>= 100)"),
1248+ "print counts at regular interval in ms (>= 10)"),
11831249 OPT_SET_UINT(0, "per-socket", &stat_config.aggr_mode,
11841250 "aggregate counts per processor socket", AGGR_SOCKET),
11851251 OPT_SET_UINT(0, "per-core", &stat_config.aggr_mode,
@@ -1332,9 +1398,14 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) · 146 unmodified lines
13321398 thread_map__read_comms(evsel_list->threads);
13331399
13341400 if (interval && interval < 100) {
1335− pr_err("print interval must be >= 100ms\n");
1336− parse_options_usage(stat_usage, options, "I", 1);
1337− goto out;
1401+ if (interval < 10) {
1402+ pr_err("print interval must be >= 10ms\n");
1403+ parse_options_usage(stat_usage, options, "I", 1);
1404+ goto out;
1405+ } else
1406+ pr_warning("print interval < 100ms. "
1407+ "The overhead percentage could be high in some cases. "
1408+ "Please proceed with caution.\n");
13381409 }
13391410
13401411 if (perf_evlist__alloc_stats(evsel_list, interval))
tools/perf/builtin-top.c+50−9
@@ -655,7 +655,7 @@ static int symbol_filter(struct map *map, struct symbol *sym) · 654 unmodified lines
655655 {
656656 const char *name = sym->name;
657657
658− if (!map->dso->kernel)
658+ if (!__map__is_kernel(map))
659659 return 0;
660660 /*
661661 * ppc64 uses function descriptors and appends a '.' to the
@@ -857,9 +857,12 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) · 195 unmodified lines
857857 * TODO: we don't process guest user from host side
858858 * except simple counting.
859859 */
860− /* Fall thru */
861− default:
862860 goto next_event;
861+ default:
862+ if (event->header.type == PERF_RECORD_SAMPLE)
863+ goto next_event;
864+ machine = &session->machines.host;
865+ break;
863866 }
864867
865868
@@ -952,7 +955,7 @@ static int __cmd_top(struct perf_top *top) · 86 unmodified lines
952955 machines__set_symbol_filter(&top->session->machines, symbol_filter);
953956
954957 if (!objdump_path) {
955− ret = perf_session_env__lookup_objdump(&top->session->header.env);
958+ ret = perf_env__lookup_objdump(&top->session->header.env);
956959 if (ret)
957960 goto out_delete;
958961 }
@@ -961,8 +964,18 @@ static int __cmd_top(struct perf_top *top) · 2 unmodified lines
961964 if (ret)
962965 goto out_delete;
963966
967+ if (perf_session__register_idle_thread(top->session) == NULL)
968+ goto out_delete;
969+
964970 machine__synthesize_threads(&top->session->machines.host, &opts->target,
965971 top->evlist->threads, false, opts->proc_map_timeout);
972+
973+ if (sort__has_socket) {
974+ ret = perf_env__read_cpu_topology_map(&perf_env);
975+ if (ret < 0)
976+ goto out_err_cpu_topo;
977+ }
978+
966979 ret = perf_top__start_counters(top);
967980 if (ret)
968981 goto out_delete;
@@ -1020,6 +1033,14 @@ out_delete: · 51 unmodified lines
10201033 top->session = NULL;
10211034
10221035 return ret;
1036+
1037+out_err_cpu_topo: {
1038+ char errbuf[BUFSIZ];
1039+ const char *err = strerror_r(-ret, errbuf, sizeof(errbuf));
1040+
1041+ ui__error("Could not read the CPU topology map: %s\n", err);
1042+ goto out_delete;
1043+}
10231044 }
10241045
10251046 static int
@@ -1032,8 +1053,22 @@ callchain_opt(const struct option *opt, const char *arg, int unset) · 6 unmodified lines
10321053 static int
10331054 parse_callchain_opt(const struct option *opt, const char *arg, int unset)
10341055 {
1035− symbol_conf.use_callchain = true;
1036− return record_parse_callchain_opt(opt, arg, unset);
1056+ struct record_opts *record = (struct record_opts *)opt->value;
1057+
1058+ record->callgraph_set = true;
1059+ callchain_param.enabled = !unset;
1060+ callchain_param.record_mode = CALLCHAIN_FP;
1061+
1062+ /*
1063+ * --no-call-graph
1064+ */
1065+ if (unset) {
1066+ symbol_conf.use_callchain = false;
1067+ callchain_param.record_mode = CALLCHAIN_NONE;
1068+ return 0;
1069+ }
1070+
1071+ return parse_callchain_top_opt(arg);
10371072 }
10381073
10391074 static int perf_top_config(const char *var, const char *value, void *cb)
@@ -1058,6 +1093,9 @@ parse_percent_limit(const struct option *opt, const char *arg, · 18 unmodified lines
10581093 return 0;
10591094 }
10601095
1096+const char top_callchain_help[] = CALLCHAIN_RECORD_HELP CALLCHAIN_REPORT_HELP
1097+ "\n\t\t\t\tDefault: fp,graph,0.5,caller,function";
1098+
10611099 int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
10621100 {
10631101 char errbuf[BUFSIZ];
@@ -1133,11 +1171,11 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) · 69 unmodified lines
11331171 OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
11341172 "Show a column with the number of samples"),
11351173 OPT_CALLBACK_NOOPT('g', NULL, &top.record_opts,
1136− NULL, "enables call-graph recording",
1174+ NULL, "enables call-graph recording and display",
11371175 &callchain_opt),
11381176 OPT_CALLBACK(0, "call-graph", &top.record_opts,
1139− "mode[,dump_size]", record_callchain_help,
1140− &parse_callchain_opt),
1177+ "record_mode[,record_size],print_type,threshold[,print_limit],order,sort_key[,branch]",
1178+ top_callchain_help, &parse_callchain_opt),
11411179 OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
11421180 "Accumulate callchains of children and show total overhead as well"),
11431181 OPT_INTEGER(0, "max-stack", &top.max_stack,
@@ -1267,6 +1305,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) · 123 unmodified lines
12671305 perf_hpp__cancel_cumulate();
12681306 }
12691307
1308+ if (symbol_conf.cumulate_callchain && !callchain_param.order_set)
1309+ callchain_param.order = ORDER_CALLER;
1310+
12701311 symbol_conf.priv_size = sizeof(struct annotation);
12711312
12721313 symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
tools/perf/builtin-trace.c+21−10
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 */
1818
1919 #include <traceevent/event-parse.h>
20+#include <api/fs/tracing_path.h>
2021 #include "builtin.h"
2122 #include "util/color.h"
2223 #include "util/debug.h"
@@ -37,6 +38,7 @@ · 14 unmodified lines
3738 #include <stdlib.h>
3839 #include <sys/mman.h>
3940 #include <linux/futex.h>
41+#include <linux/err.h>
4042
4143 /* For older distros: */
4244 #ifndef MAP_STACK
@@ -244,13 +246,14 @@ static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void · 201 unmodified lines
244246 struct perf_evsel *evsel = perf_evsel__newtp("raw_syscalls", direction);
245247
246248 /* older kernel (e.g., RHEL6) use syscalls:{enter,exit} */
247− if (evsel == NULL)
249+ if (IS_ERR(evsel))
248250 evsel = perf_evsel__newtp("syscalls", direction);
249251
250− if (evsel) {
251− if (perf_evsel__init_syscall_tp(evsel, handler))
252− goto out_delete;
253− }
252+ if (IS_ERR(evsel))
253+ return NULL;
254+
255+ if (perf_evsel__init_syscall_tp(evsel, handler))
256+ goto out_delete;
254257
255258 return evsel;
256259
@@ -582,6 +585,12 @@ static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct sysc · 325 unmodified lines
582585
583586 #define SCA_FUTEX_OP syscall_arg__scnprintf_futex_op
584587
588+static const char *bpf_cmd[] = {
589+ "MAP_CREATE", "MAP_LOOKUP_ELEM", "MAP_UPDATE_ELEM", "MAP_DELETE_ELEM",
590+ "MAP_GET_NEXT_KEY", "PROG_LOAD",
591+};
592+static DEFINE_STRARRAY(bpf_cmd);
593+
585594 static const char *epoll_ctl_ops[] = { "ADD", "DEL", "MOD", };
586595 static DEFINE_STRARRAY_OFFSET(epoll_ctl_ops, 1);
587596
@@ -1008,6 +1017,7 @@ static struct syscall_fmt { · 420 unmodified lines
10081017 .arg_scnprintf = { [0] = SCA_FILENAME, /* filename */
10091018 [1] = SCA_ACCMODE, /* mode */ }, },
10101019 { .name = "arch_prctl", .errmsg = true, .alias = "prctl", },
1020+ { .name = "bpf", .errmsg = true, STRARRAY(0, cmd, bpf_cmd), },
10111021 { .name = "brk", .hexret = true,
10121022 .arg_scnprintf = { [0] = SCA_HEX, /* brk */ }, },
10131023 { .name = "chdir", .errmsg = true,
@@ -1704,12 +1714,12 @@ static int trace__read_syscall_info(struct trace *trace, int id) · 690 unmodified lines
17041714 snprintf(tp_name, sizeof(tp_name), "sys_enter_%s", sc->name);
17051715 sc->tp_format = trace_event__tp_format("syscalls", tp_name);
17061716
1707− if (sc->tp_format == NULL && sc->fmt && sc->fmt->alias) {
1717+ if (IS_ERR(sc->tp_format) && sc->fmt && sc->fmt->alias) {
17081718 snprintf(tp_name, sizeof(tp_name), "sys_enter_%s", sc->fmt->alias);
17091719 sc->tp_format = trace_event__tp_format("syscalls", tp_name);
17101720 }
17111721
1712− if (sc->tp_format == NULL)
1722+ if (IS_ERR(sc->tp_format))
17131723 return -1;
17141724
17151725 sc->args = sc->tp_format->format.fields;
@@ -2389,7 +2399,8 @@ static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp); · 673 unmodified lines
23892399 static bool perf_evlist__add_vfs_getname(struct perf_evlist *evlist)
23902400 {
23912401 struct perf_evsel *evsel = perf_evsel__newtp("probe", "vfs_getname");
2392− if (evsel == NULL)
2402+
2403+ if (IS_ERR(evsel))
23932404 return false;
23942405
23952406 if (perf_evsel__field(evsel, "pathname") == NULL) {
@@ -2686,11 +2697,11 @@ out_delete_evlist: · 290 unmodified lines
26862697 char errbuf[BUFSIZ];
26872698
26882699 out_error_sched_stat_runtime:
2689− debugfs__strerror_open_tp(errno, errbuf, sizeof(errbuf), "sched", "sched_stat_runtime");
2700+ tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "sched", "sched_stat_runtime");
26902701 goto out_error;
26912702
26922703 out_error_raw_syscalls:
2693− debugfs__strerror_open_tp(errno, errbuf, sizeof(errbuf), "raw_syscalls", "sys_(enter|exit)");
2704+ tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "raw_syscalls", "sys_(enter|exit)");
26942705 goto out_error;
26952706
26962707 out_error_mmap:
tools/perf/config/Makefile+22−1
@@ -106,9 +106,14 @@ ifdef LIBBABELTRACE · 105 unmodified lines
106106 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf
107107 endif
108108
109+FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/arch/$(ARCH)/include/uapi -I$(srctree)/include/uapi
109110 # include ARCH specific config
110111 -include $(src-perf)/arch/$(ARCH)/Makefile
111112
113+ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
114+ CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
115+endif
116+
112117 include $(src-perf)/config/utilities.mak
113118
114119 ifeq ($(call get-executable,$(FLEX)),)
@@ -233,6 +238,7 @@ ifdef NO_LIBELF · 118 unmodified lines
233238 NO_DEMANGLE := 1
234239 NO_LIBUNWIND := 1
235240 NO_LIBDW_DWARF_UNWIND := 1
241+ NO_LIBBPF := 1
236242 else
237243 ifeq ($(feature-libelf), 0)
238244 ifeq ($(feature-glibc), 1)
@@ -242,13 +248,14 @@ else · 3 unmodified lines
242248 LIBC_SUPPORT := 1
243249 endif
244250 ifeq ($(LIBC_SUPPORT),1)
245− msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
251+ msg := $(warning No libelf found, disables 'probe' tool and BPF support in 'perf record', please install elfutils-libelf-devel/libelf-dev);
246252
247253 NO_LIBELF := 1
248254 NO_DWARF := 1
249255 NO_DEMANGLE := 1
250256 NO_LIBUNWIND := 1
251257 NO_LIBDW_DWARF_UNWIND := 1
258+ NO_LIBBPF := 1
252259 else
253260 ifneq ($(filter s% -static%,$(LDFLAGS),),)
254261 msg := $(error No static glibc found, please install glibc-static);
@@ -305,6 +312,13 @@ ifndef NO_LIBELF · 50 unmodified lines
305312 $(call detected,CONFIG_DWARF)
306313 endif # PERF_HAVE_DWARF_REGS
307314 endif # NO_DWARF
315+
316+ ifndef NO_LIBBPF
317+ ifeq ($(feature-bpf), 1)
318+ CFLAGS += -DHAVE_LIBBPF_SUPPORT
319+ $(call detected,CONFIG_LIBBPF)
320+ endif
321+ endif # NO_LIBBPF
308322 endif # NO_LIBELF
309323
310324 ifeq ($(ARCH),powerpc)
@@ -320,6 +334,13 @@ ifndef NO_LIBUNWIND · 9 unmodified lines
320334 endif
321335 endif
322336
337+ifndef NO_LIBBPF
338+ ifneq ($(feature-bpf), 1)
339+ msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
340+ NO_LIBBPF := 1
341+ endif
342+endif
343+
323344 dwarf-post-unwind := 1
324345 dwarf-post-unwind-text := BUG
325346
tools/perf/perf.c+25−5
@@ -8,14 +8,16 @@ · 7 unmodified lines
88 */
99 #include "builtin.h"
1010
11+#include "util/env.h"
1112 #include "util/exec_cmd.h"
1213 #include "util/cache.h"
1314 #include "util/quote.h"
1415 #include "util/run-command.h"
1516 #include "util/parse-events.h"
1617 #include "util/parse-options.h"
18+#include "util/bpf-loader.h"
1719 #include "util/debug.h"
18−#include <api/fs/debugfs.h>
20+#include <api/fs/tracing_path.h>
1921 #include <pthread.h>
2022
2123 const char perf_usage_string[] =
@@ -160,6 +162,20 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) · 138 unmodified lines
160162 if (!strcmp(cmd, "--help") || !strcmp(cmd, "--version"))
161163 break;
162164
165+ /*
166+ * Shortcut for '-h' and '-v' options to invoke help
167+ * and version command.
168+ */
169+ if (!strcmp(cmd, "-h")) {
170+ (*argv)[0] = "--help";
171+ break;
172+ }
173+
174+ if (!strcmp(cmd, "-v")) {
175+ (*argv)[0] = "--version";
176+ break;
177+ }
178+
163179 /*
164180 * Check remaining flags.
165181 */
@@ -214,7 +230,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) · 48 unmodified lines
214230 fprintf(stderr, "No directory given for --debugfs-dir.\n");
215231 usage(perf_usage_string);
216232 }
217− perf_debugfs_set_path((*argv)[1]);
233+ tracing_path_set((*argv)[1]);
218234 if (envchanged)
219235 *envchanged = 1;
220236 (*argv)++;
@@ -230,7 +246,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) · 9 unmodified lines
230246 (*argv)++;
231247 (*argc)--;
232248 } else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) {
233− perf_debugfs_set_path(cmd + strlen(CMD_DEBUGFS_DIR));
249+ tracing_path_set(cmd + strlen(CMD_DEBUGFS_DIR));
234250 fprintf(stderr, "dir: %s\n", tracing_path);
235251 if (envchanged)
236252 *envchanged = 1;
@@ -369,6 +385,8 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) · 132 unmodified lines
369385
370386 status = p->fn(argc, argv, prefix);
371387 exit_browser(status);
388+ perf_env__exit(&perf_env);
389+ bpf__clear();
372390
373391 if (status)
374392 return status & 0xff;
@@ -517,8 +535,10 @@ int main(int argc, const char **argv) · 142 unmodified lines
517535 cmd = perf_extract_argv0_path(argv[0]);
518536 if (!cmd)
519537 cmd = "perf-help";
520− /* get debugfs mount point from /proc/mounts */
521− perf_debugfs_mount(NULL);
538+
539+ /* get debugfs/tracefs mount point from /proc/mounts */
540+ tracing_path_mount();
541+
522542 /*
523543 * "perf-xxxx" is the same as "perf xxxx", but we obviously:
524544 *
tools/perf/python/twatch.py+20−3
@@ -15,14 +15,14 @@ · 14 unmodified lines
1515
1616 import perf
1717
18−def main():
18+def main(context_switch = 0, thread = -1):
1919 cpus = perf.cpu_map()
20− threads = perf.thread_map()
20+ threads = perf.thread_map(thread)
2121 evsel = perf.evsel(type = perf.TYPE_SOFTWARE,
2222 config = perf.COUNT_SW_DUMMY,
2323 task = 1, comm = 1, mmap = 0, freq = 0,
2424 wakeup_events = 1, watermark = 1,
25− sample_id_all = 1,
25+ sample_id_all = 1, context_switch = context_switch,
2626 sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU)
2727
2828 """What we want are just the PERF_RECORD_ lifetime events for threads,
@@ -48,4 +48,21 @@ def main(): · 19 unmodified lines
4848 print event
4949
5050 if __name__ == '__main__':
51+ """
52+ To test the PERF_RECORD_SWITCH record, pick a pid and replace
53+ in the following line.
54+
55+ Example output:
56+
57+cpu: 3, pid: 31463, tid: 31593 { type: context_switch, next_prev_pid: 31463, next_prev_tid: 31593, switch_out: 1 }
58+cpu: 1, pid: 31463, tid: 31489 { type: context_switch, next_prev_pid: 31463, next_prev_tid: 31489, switch_out: 1 }
59+cpu: 2, pid: 31463, tid: 31496 { type: context_switch, next_prev_pid: 31463, next_prev_tid: 31496, switch_out: 1 }
60+cpu: 3, pid: 31463, tid: 31491 { type: context_switch, next_prev_pid: 31463, next_prev_tid: 31491, switch_out: 0 }
61+
62+ It is possible as well to use event.misc & perf.PERF_RECORD_MISC_SWITCH_OUT
63+ to figure out if this is a context switch in or out of the monitored threads.
64+
65+ If bored, please add command line option parsing support for these options :-)
66+ """
67+ # main(context_switch = 1, thread = 31463)
5168 main()
tools/perf/scripts/python/export-to-postgresql.py+221−0
@@ -61,6 +61,142 @@ import datetime · 60 unmodified lines
6161 #
6262 # An example of using the database is provided by the script
6363 # call-graph-from-postgresql.py. Refer to that script for details.
64+#
65+# Tables:
66+#
67+# The tables largely correspond to perf tools' data structures. They are largely self-explanatory.
68+#
69+# samples
70+#
71+# 'samples' is the main table. It represents what instruction was executing at a point in time
72+# when something (a selected event) happened. The memory address is the instruction pointer or 'ip'.
73+#
74+# calls
75+#
76+# 'calls' represents function calls and is related to 'samples' by 'call_id' and 'return_id'.
77+# 'calls' is only created when the 'calls' option to this script is specified.
78+#
79+# call_paths
80+#
81+# 'call_paths' represents all the call stacks. Each 'call' has an associated record in 'call_paths'.
82+# 'calls_paths' is only created when the 'calls' option to this script is specified.
83+#
84+# branch_types
85+#
86+# 'branch_types' provides descriptions for each type of branch.
87+#
88+# comm_threads
89+#
90+# 'comm_threads' shows how 'comms' relates to 'threads'.
91+#
92+# comms
93+#
94+# 'comms' contains a record for each 'comm' - the name given to the executable that is running.
95+#
96+# dsos
97+#
98+# 'dsos' contains a record for each executable file or library.
99+#
100+# machines
101+#
102+# 'machines' can be used to distinguish virtual machines if virtualization is supported.
103+#
104+# selected_events
105+#
106+# 'selected_events' contains a record for each kind of event that has been sampled.
107+#
108+# symbols
109+#
110+# 'symbols' contains a record for each symbol. Only symbols that have samples are present.
111+#
112+# threads
113+#
114+# 'threads' contains a record for each thread.
115+#
116+# Views:
117+#
118+# Most of the tables have views for more friendly display. The views are:
119+#
120+# calls_view
121+# call_paths_view
122+# comm_threads_view
123+# dsos_view
124+# machines_view
125+# samples_view
126+# symbols_view
127+# threads_view
128+#
129+# More examples of browsing the database with psql:
130+# Note that some of the examples are not the most optimal SQL query.
131+# Note that call information is only available if the script's 'calls' option has been used.
132+#
133+# Top 10 function calls (not aggregated by symbol):
134+#
135+# SELECT * FROM calls_view ORDER BY elapsed_time DESC LIMIT 10;
136+#
137+# Top 10 function calls (aggregated by symbol):
138+#
139+# SELECT symbol_id,(SELECT name FROM symbols WHERE id = symbol_id) AS symbol,
140+# SUM(elapsed_time) AS tot_elapsed_time,SUM(branch_count) AS tot_branch_count
141+# FROM calls_view GROUP BY symbol_id ORDER BY tot_elapsed_time DESC LIMIT 10;
142+#
143+# Note that the branch count gives a rough estimation of cpu usage, so functions
144+# that took a long time but have a relatively low branch count must have spent time
145+# waiting.
146+#
147+# Find symbols by pattern matching on part of the name (e.g. names containing 'alloc'):
148+#
149+# SELECT * FROM symbols_view WHERE name LIKE '%alloc%';
150+#
151+# Top 10 function calls for a specific symbol (e.g. whose symbol_id is 187):
152+#
153+# SELECT * FROM calls_view WHERE symbol_id = 187 ORDER BY elapsed_time DESC LIMIT 10;
154+#
155+# Show function calls made by function in the same context (i.e. same call path) (e.g. one with call_path_id 254):
156+#
157+# SELECT * FROM calls_view WHERE parent_call_path_id = 254;
158+#
159+# Show branches made during a function call (e.g. where call_id is 29357 and return_id is 29370 and tid is 29670)
160+#
161+# SELECT * FROM samples_view WHERE id >= 29357 AND id <= 29370 AND tid = 29670 AND event LIKE 'branches%';
162+#
163+# Show transactions:
164+#
165+# SELECT * FROM samples_view WHERE event = 'transactions';
166+#
167+# Note transaction start has 'in_tx' true whereas, transaction end has 'in_tx' false.
168+# Transaction aborts have branch_type_name 'transaction abort'
169+#
170+# Show transaction aborts:
171+#
172+# SELECT * FROM samples_view WHERE event = 'transactions' AND branch_type_name = 'transaction abort';
173+#
174+# To print a call stack requires walking the call_paths table. For example this python script:
175+# #!/usr/bin/python2
176+#
177+# import sys
178+# from PySide.QtSql import *
179+#
180+# if __name__ == '__main__':
181+# if (len(sys.argv) < 3):
182+# print >> sys.stderr, "Usage is: printcallstack.py <database name> <call_path_id>"
183+# raise Exception("Too few arguments")
184+# dbname = sys.argv[1]
185+# call_path_id = sys.argv[2]
186+# db = QSqlDatabase.addDatabase('QPSQL')
187+# db.setDatabaseName(dbname)
188+# if not db.open():
189+# raise Exception("Failed to open database " + dbname + " error: " + db.lastError().text())
190+# query = QSqlQuery(db)
191+# print " id ip symbol_id symbol dso_id dso_short_name"
192+# while call_path_id != 0 and call_path_id != 1:
193+# ret = query.exec_('SELECT * FROM call_paths_view WHERE id = ' + str(call_path_id))
194+# if not ret:
195+# raise Exception("Query failed: " + query.lastError().text())
196+# if not query.next():
197+# raise Exception("Query failed")
198+# print "{0:>6} {1:>10} {2:>9} {3:<30} {4:>6} {5:<30}".format(query.value(0), query.value(1), query.value(2), query.value(3), query.value(4), query.value(5))
199+# call_path_id = query.value(6)
64200
65201 from PySide.QtSql import *
66202
@@ -244,6 +380,91 @@ if perf_db_export_calls: · 177 unmodified lines
244380 'parent_call_path_id bigint,'
245381 'flags integer)')
246382
383+do_query(query, 'CREATE VIEW machines_view AS '
384+ 'SELECT '
385+ 'id,'
386+ 'pid,'
387+ 'root_dir,'
388+ 'CASE WHEN id=0 THEN \'unknown\' WHEN pid=-1 THEN \'host\' ELSE \'guest\' END AS host_or_guest'
389+ ' FROM machines')
390+
391+do_query(query, 'CREATE VIEW dsos_view AS '
392+ 'SELECT '
393+ 'id,'
394+ 'machine_id,'
395+ '(SELECT host_or_guest FROM machines_view WHERE id = machine_id) AS host_or_guest,'
396+ 'short_name,'
397+ 'long_name,'
398+ 'build_id'
399+ ' FROM dsos')
400+
401+do_query(query, 'CREATE VIEW symbols_view AS '
402+ 'SELECT '
403+ 'id,'
404+ 'name,'
405+ '(SELECT short_name FROM dsos WHERE id=dso_id) AS dso,'
406+ 'dso_id,'
407+ 'sym_start,'
408+ 'sym_end,'
409+ 'CASE WHEN binding=0 THEN \'local\' WHEN binding=1 THEN \'global\' ELSE \'weak\' END AS binding'
410+ ' FROM symbols')
411+
412+do_query(query, 'CREATE VIEW threads_view AS '
413+ 'SELECT '
414+ 'id,'
415+ 'machine_id,'
416+ '(SELECT host_or_guest FROM machines_view WHERE id = machine_id) AS host_or_guest,'
417+ 'process_id,'
418+ 'pid,'
419+ 'tid'
420+ ' FROM threads')
421+
422+do_query(query, 'CREATE VIEW comm_threads_view AS '
423+ 'SELECT '
424+ 'comm_id,'
425+ '(SELECT comm FROM comms WHERE id = comm_id) AS command,'
426+ 'thread_id,'
427+ '(SELECT pid FROM threads WHERE id = thread_id) AS pid,'
428+ '(SELECT tid FROM threads WHERE id = thread_id) AS tid'
429+ ' FROM comm_threads')
430+
431+if perf_db_export_calls:
432+ do_query(query, 'CREATE VIEW call_paths_view AS '
433+ 'SELECT '
434+ 'c.id,'
435+ 'to_hex(c.ip) AS ip,'
436+ 'c.symbol_id,'
437+ '(SELECT name FROM symbols WHERE id = c.symbol_id) AS symbol,'
438+ '(SELECT dso_id FROM symbols WHERE id = c.symbol_id) AS dso_id,'
439+ '(SELECT dso FROM symbols_view WHERE id = c.symbol_id) AS dso_short_name,'
440+ 'c.parent_id,'
441+ 'to_hex(p.ip) AS parent_ip,'
442+ 'p.symbol_id AS parent_symbol_id,'
443+ '(SELECT name FROM symbols WHERE id = p.symbol_id) AS parent_symbol,'
444+ '(SELECT dso_id FROM symbols WHERE id = p.symbol_id) AS parent_dso_id,'
445+ '(SELECT dso FROM symbols_view WHERE id = p.symbol_id) AS parent_dso_short_name'
446+ ' FROM call_paths c INNER JOIN call_paths p ON p.id = c.parent_id')
447+ do_query(query, 'CREATE VIEW calls_view AS '
448+ 'SELECT '
449+ 'calls.id,'
450+ 'thread_id,'
451+ '(SELECT pid FROM threads WHERE id = thread_id) AS pid,'
452+ '(SELECT tid FROM threads WHERE id = thread_id) AS tid,'
453+ '(SELECT comm FROM comms WHERE id = comm_id) AS command,'
454+ 'call_path_id,'
455+ 'to_hex(ip) AS ip,'
456+ 'symbol_id,'
457+ '(SELECT name FROM symbols WHERE id = symbol_id) AS symbol,'
458+ 'call_time,'
459+ 'return_time,'
460+ 'return_time - call_time AS elapsed_time,'
461+ 'branch_count,'
462+ 'call_id,'
463+ 'return_id,'
464+ 'CASE WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' ELSE \'\' END AS flags,'
465+ 'parent_call_path_id'
466+ ' FROM calls INNER JOIN call_paths ON call_paths.id = call_path_id')
467+
247468 do_query(query, 'CREATE VIEW samples_view AS '
248469 'SELECT '
249470 'id,'
tools/perf/tests/Build+1−3
@@ -8,7 +8,6 @@ perf-y += openat-syscall-all-cpus.o · 7 unmodified lines
88 perf-y += openat-syscall-tp-fields.o
99 perf-y += mmap-basic.o
1010 perf-y += perf-record.o
11−perf-y += rdpmc.o
1211 perf-y += evsel-roundtrip-name.o
1312 perf-y += evsel-tp-sched.o
1413 perf-y += fdarray.o
@@ -33,8 +32,7 @@ perf-y += parse-no-sample-id-all.o · 18 unmodified lines
3332 perf-y += kmod-path.o
3433 perf-y += thread-map.o
3534 perf-y += llvm.o
36−
37−perf-$(CONFIG_X86) += perf-time-to-tsc.o
35+perf-y += topology.o
3836
3937 ifeq ($(ARCH),$(filter $(ARCH),x86 arm arm64))
4038 perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
tools/perf/tests/bpf-script-example.c+44−0
@@ -0,0 +1,44 @@
1+#ifndef LINUX_VERSION_CODE
2+# error Need LINUX_VERSION_CODE
3+# error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig'
4+#endif
5+#define BPF_ANY 0
6+#define BPF_MAP_TYPE_ARRAY 2
7+#define BPF_FUNC_map_lookup_elem 1
8+#define BPF_FUNC_map_update_elem 2
9+
10+static void *(*bpf_map_lookup_elem)(void *map, void *key) =
11+ (void *) BPF_FUNC_map_lookup_elem;
12+static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) =
13+ (void *) BPF_FUNC_map_update_elem;
14+
15+struct bpf_map_def {
16+ unsigned int type;
17+ unsigned int key_size;
18+ unsigned int value_size;
19+ unsigned int max_entries;
20+};
21+
22+#define SEC(NAME) __attribute__((section(NAME), used))
23+struct bpf_map_def SEC("maps") flip_table = {
24+ .type = BPF_MAP_TYPE_ARRAY,
25+ .key_size = sizeof(int),
26+ .value_size = sizeof(int),
27+ .max_entries = 1,
28+};
29+
30+SEC("func=sys_epoll_pwait")
31+int bpf_func__sys_epoll_pwait(void *ctx)
32+{
33+ int ind =0;
34+ int *flag = bpf_map_lookup_elem(&flip_table, &ind);
35+ int new_flag;
36+ if (!flag)
37+ return 0;
38+ /* flip flag and store back */
39+ new_flag = !*flag;
40+ bpf_map_update_elem(&flip_table, &ind, &new_flag, BPF_ANY);
41+ return new_flag;
42+}
43+char _license[] SEC("license") = "GPL";
44+int _version SEC("version") = LINUX_VERSION_CODE;
tools/perf/tests/builtin-test.c+36−40
@@ -14,10 +14,13 @@ · 13 unmodified lines
1414 #include "parse-options.h"
1515 #include "symbol.h"
1616
17−static struct test {
18− const char *desc;
19− int (*func)(void);
20−} tests[] = {
17+struct test __weak arch_tests[] = {
18+ {
19+ .func = NULL,
20+ },
21+};
22+
23+static struct test generic_tests[] = {
2124 {
2225 .desc = "vmlinux symtab matches kallsyms",
2326 .func = test__vmlinux_matches_kallsyms,
@@ -38,12 +41,6 @@ static struct test { · 14 unmodified lines
3841 .desc = "parse events tests",
3942 .func = test__parse_events,
4043 },
41−#if defined(__x86_64__) || defined(__i386__)
42− {
43− .desc = "x86 rdpmc test",
44− .func = test__rdpmc,
45− },
46−#endif
4744 {
4845 .desc = "Validate PERF_RECORD_* events & perf_sample fields",
4946 .func = test__PERF_RECORD,
@@ -104,12 +101,6 @@ static struct test { · 54 unmodified lines
104101 .desc = "Test software clock events have valid period values",
105102 .func = test__sw_clock_freq,
106103 },
107−#if defined(__x86_64__) || defined(__i386__)
108− {
109− .desc = "Test converting perf time to TSC",
110− .func = test__perf_time_to_tsc,
111− },
112−#endif
113104 {
114105 .desc = "Test object code reading",
115106 .func = test__code_reading,
@@ -126,14 +117,6 @@ static struct test { · 10 unmodified lines
126117 .desc = "Test parsing with no sample_id_all bit set",
127118 .func = test__parse_no_sample_id_all,
128119 },
129−#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
130−#ifdef HAVE_DWARF_UNWIND_SUPPORT
131− {
132− .desc = "Test dwarf unwind",
133− .func = test__dwarf_unwind,
134− },
135−#endif
136−#endif
137120 {
138121 .desc = "Test filtering hist entries",
139122 .func = test__hists_filter,
@@ -178,12 +161,21 @@ static struct test { · 38 unmodified lines
178161 .desc = "Test LLVM searching and compiling",
179162 .func = test__llvm,
180163 },
164+ {
165+ .desc = "Test topology in session",
166+ .func = test_session_topology,
167+ },
181168 {
182169 .func = NULL,
183170 },
184171 };
185172
186−static bool perf_test__matches(int curr, int argc, const char *argv[])
173+static struct test *tests[] = {
174+ generic_tests,
175+ arch_tests,
176+};
177+
178+static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[])
187179 {
188180 int i;
189181
@@ -200,7 +192,7 @@ static bool perf_test__matches(int curr, int argc, const char *argv[]) · 10 unmodified lines
200192 continue;
201193 }
202194
203− if (strstr(tests[curr].desc, argv[i]))
195+ if (strstr(test->desc, argv[i]))
204196 return true;
205197 }
206198
@@ -237,27 +229,31 @@ static int run_test(struct test *test) · 30 unmodified lines
237229 return err;
238230 }
239231
232+#define for_each_test(j, t) \
233+ for (j = 0; j < ARRAY_SIZE(tests); j++) \
234+ for (t = &tests[j][0]; t->func; t++)
235+
240236 static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
241237 {
238+ struct test *t;
239+ unsigned int j;
242240 int i = 0;
243241 int width = 0;
244242
245− while (tests[i].func) {
246− int len = strlen(tests[i].desc);
243+ for_each_test(j, t) {
244+ int len = strlen(t->desc);
247245
248246 if (width < len)
249247 width = len;
250− ++i;
251248 }
252249
253− i = 0;
254− while (tests[i].func) {
250+ for_each_test(j, t) {
255251 int curr = i++, err;
256252
257− if (!perf_test__matches(curr, argc, argv))
253+ if (!perf_test__matches(t, curr, argc, argv))
258254 continue;
259255
260− pr_info("%2d: %-*s:", i, width, tests[curr].desc);
256+ pr_info("%2d: %-*s:", i, width, t->desc);
261257
262258 if (intlist__find(skiplist, i)) {
263259 color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n");
@@ -265,8 +261,8 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) · 1 unmodified line
265261 }
266262
267263 pr_debug("\n--- start ---\n");
268− err = run_test(&tests[curr]);
269− pr_debug("---- end ----\n%s:", tests[curr].desc);
264+ err = run_test(t);
265+ pr_debug("---- end ----\n%s:", t->desc);
270266
271267 switch (err) {
272268 case TEST_OK:
@@ -287,15 +283,15 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) · 14 unmodified lines
287283
288284 static int perf_test__list(int argc, const char **argv)
289285 {
286+ unsigned int j;
287+ struct test *t;
290288 int i = 0;
291289
292− while (tests[i].func) {
293− int curr = i++;
294−
295− if (argc > 1 && !strstr(tests[curr].desc, argv[1]))
290+ for_each_test(j, t) {
291+ if (argc > 1 && !strstr(t->desc, argv[1]))
296292 continue;
297293
298− pr_info("%2d: %s\n", i, tests[curr].desc);
294+ pr_info("%2d: %s\n", ++i, t->desc);
299295 }
300296
301297 return 0;
tools/perf/tests/code-reading.c+61−15
@@ -33,20 +33,20 @@ static unsigned int hex(char c) · 32 unmodified lines
3333 return c - 'A' + 10;
3434 }
3535
36−static void read_objdump_line(const char *line, size_t line_len, void **buf,
37− size_t *len)
36+static size_t read_objdump_line(const char *line, size_t line_len, void *buf,
37+ size_t len)
3838 {
3939 const char *p;
40− size_t i;
40+ size_t i, j = 0;
4141
4242 /* Skip to a colon */
4343 p = strchr(line, ':');
4444 if (!p)
45− return;
45+ return 0;
4646 i = p + 1 - line;
4747
4848 /* Read bytes */
49− while (*len) {
49+ while (j < len) {
5050 char c1, c2;
5151
5252 /* Skip spaces */
@@ -65,20 +65,26 @@ static void read_objdump_line(const char *line, size_t line_len, void **buf, · 12 unmodified lines
6565 if (i < line_len && line[i] && !isspace(line[i]))
6666 break;
6767 /* Store byte */
68− *(unsigned char *)*buf = (hex(c1) << 4) | hex(c2);
69− *buf += 1;
70− *len -= 1;
68+ *(unsigned char *)buf = (hex(c1) << 4) | hex(c2);
69+ buf += 1;
70+ j++;
7171 }
72+ /* return number of successfully read bytes */
73+ return j;
7274 }
7375
74−static int read_objdump_output(FILE *f, void **buf, size_t *len)
76+static int read_objdump_output(FILE *f, void *buf, size_t *len, u64 start_addr)
7577 {
7678 char *line = NULL;
77− size_t line_len;
79+ size_t line_len, off_last = 0;
7880 ssize_t ret;
7981 int err = 0;
82+ u64 addr, last_addr = start_addr;
83+
84+ while (off_last < *len) {
85+ size_t off, read_bytes, written_bytes;
86+ unsigned char tmp[BUFSZ];
8087
81− while (1) {
8288 ret = getline(&line, &line_len, f);
8389 if (feof(f))
8490 break;
@@ -87,9 +93,33 @@ static int read_objdump_output(FILE *f, void **buf, size_t *len) · 2 unmodified lines
8793 err = -1;
8894 break;
8995 }
90− read_objdump_line(line, ret, buf, len);
96+
97+ /* read objdump data into temporary buffer */
98+ read_bytes = read_objdump_line(line, ret, tmp, sizeof(tmp));
99+ if (!read_bytes)
100+ continue;
101+
102+ if (sscanf(line, "%"PRIx64, &addr) != 1)
103+ continue;
104+ if (addr < last_addr) {
105+ pr_debug("addr going backwards, read beyond section?\n");
106+ break;
107+ }
108+ last_addr = addr;
109+
110+ /* copy it from temporary buffer to 'buf' according
111+ * to address on current objdump line */
112+ off = addr - start_addr;
113+ if (off >= *len)
114+ break;
115+ written_bytes = MIN(read_bytes, *len - off);
116+ memcpy(buf + off, tmp, written_bytes);
117+ off_last = off + written_bytes;
91118 }
92119
120+ /* len returns number of bytes that could not be read */
121+ *len -= off_last;
122+
93123 free(line);
94124
95125 return err;
@@ -103,7 +133,7 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf, · 7 unmodified lines
103133 FILE *f;
104134 int ret;
105135
106− fmt = "%s -d --start-address=0x%"PRIx64" --stop-address=0x%"PRIx64" %s";
136+ fmt = "%s -z -d --start-address=0x%"PRIx64" --stop-address=0x%"PRIx64" %s";
107137 ret = snprintf(cmd, sizeof(cmd), fmt, "objdump", addr, addr + len,
108138 filename);
109139 if (ret <= 0 || (size_t)ret >= sizeof(cmd))
@@ -120,7 +150,7 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf, · 10 unmodified lines
120150 return -1;
121151 }
122152
123− ret = read_objdump_output(f, &buf, &len);
153+ ret = read_objdump_output(f, buf, &len, addr);
124154 if (len) {
125155 pr_debug("objdump read too few bytes\n");
126156 if (!ret)
@@ -132,6 +162,18 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf, · 5 unmodified lines
132162 return ret;
133163 }
134164
165+static void dump_buf(unsigned char *buf, size_t len)
166+{
167+ size_t i;
168+
169+ for (i = 0; i < len; i++) {
170+ pr_debug("0x%02x ", buf[i]);
171+ if (i % 16 == 15)
172+ pr_debug("\n");
173+ }
174+ pr_debug("\n");
175+}
176+
135177 static int read_object_code(u64 addr, size_t len, u8 cpumode,
136178 struct thread *thread, struct state *state)
137179 {
@@ -234,6 +276,10 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode, · 96 unmodified lines
234276 /* The results should be identical */
235277 if (memcmp(buf1, buf2, len)) {
236278 pr_debug("Bytes read differ from those read by objdump\n");
279+ pr_debug("buf1 (dso):\n");
280+ dump_buf(buf1, len);
281+ pr_debug("buf2 (objdump):\n");
282+ dump_buf(buf2, len);
237283 return -1;
238284 }
239285 pr_debug("Bytes read match those read by objdump\n");
@@ -427,7 +473,7 @@ static int do_test_code_reading(bool try_kcore) · 187 unmodified lines
427473 symbol_conf.kallsyms_name = "/proc/kallsyms";
428474
429475 /* Load kernel map */
430− map = machine->vmlinux_maps[MAP__FUNCTION];
476+ map = machine__kernel_map(machine);
431477 ret = map__load(map, NULL);
432478 if (ret < 0) {
433479 pr_debug("map__load failed\n");
tools/perf/tests/dwarf-unwind.c+4−0
@@ -11,6 +11,10 @@ · 10 unmodified lines
1111 #include "thread.h"
1212 #include "callchain.h"
1313
14+#if defined (__x86_64__) || defined (__i386__)
15+#include "arch-tests.h"
16+#endif
17+
1418 /* For bsearch. We try to unwind functions in shared object. */
1519 #include <stdlib.h>
1620
tools/perf/tests/evsel-tp-sched.c+8−2
@@ -1,3 +1,4 @@
1+#include <linux/err.h>
12 #include <traceevent/event-parse.h>
23 #include "evsel.h"
34 #include "tests.h"
@@ -36,8 +37,8 @@ int test__perf_evsel__tp_sched_test(void) · 32 unmodified lines
3637 struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch");
3738 int ret = 0;
3839
39− if (evsel == NULL) {
40− pr_debug("perf_evsel__new\n");
40+ if (IS_ERR(evsel)) {
41+ pr_debug("perf_evsel__newtp failed with %ld\n", PTR_ERR(evsel));
4142 return -1;
4243 }
4344
@@ -66,6 +67,11 @@ int test__perf_evsel__tp_sched_test(void) · 22 unmodified lines
6667
6768 evsel = perf_evsel__newtp("sched", "sched_wakeup");
6869
70+ if (IS_ERR(evsel)) {
71+ pr_debug("perf_evsel__newtp failed with %ld\n", PTR_ERR(evsel));
72+ return -1;
73+ }
74+
6975 if (perf_evsel__test_field(evsel, "comm", 16, true))
7076 ret = -1;
7177
tools/perf/tests/hists_filter.c+45−10
@@ -16,30 +16,31 @@ struct sample { · 15 unmodified lines
1616 struct thread *thread;
1717 struct map *map;
1818 struct symbol *sym;
19+ int socket;
1920 };
2021
2122 /* For the numbers, see hists_common.c */
2223 static struct sample fake_samples[] = {
2324 /* perf [kernel] schedule() */
24− { .pid = FAKE_PID_PERF1, .ip = FAKE_IP_KERNEL_SCHEDULE, },
25+ { .pid = FAKE_PID_PERF1, .ip = FAKE_IP_KERNEL_SCHEDULE, .socket = 0 },
2526 /* perf [perf] main() */
26− { .pid = FAKE_PID_PERF1, .ip = FAKE_IP_PERF_MAIN, },
27+ { .pid = FAKE_PID_PERF1, .ip = FAKE_IP_PERF_MAIN, .socket = 0 },
2728 /* perf [libc] malloc() */
28− { .pid = FAKE_PID_PERF1, .ip = FAKE_IP_LIBC_MALLOC, },
29+ { .pid = FAKE_PID_PERF1, .ip = FAKE_IP_LIBC_MALLOC, .socket = 0 },
2930 /* perf [perf] main() */
30− { .pid = FAKE_PID_PERF2, .ip = FAKE_IP_PERF_MAIN, }, /* will be merged */
31+ { .pid = FAKE_PID_PERF2, .ip = FAKE_IP_PERF_MAIN, .socket = 0 }, /* will be merged */
3132 /* perf [perf] cmd_record() */
32− { .pid = FAKE_PID_PERF2, .ip = FAKE_IP_PERF_CMD_RECORD, },
33+ { .pid = FAKE_PID_PERF2, .ip = FAKE_IP_PERF_CMD_RECORD, .socket = 1 },
3334 /* perf [kernel] page_fault() */
34− { .pid = FAKE_PID_PERF2, .ip = FAKE_IP_KERNEL_PAGE_FAULT, },
35+ { .pid = FAKE_PID_PERF2, .ip = FAKE_IP_KERNEL_PAGE_FAULT, .socket = 1 },
3536 /* bash [bash] main() */
36− { .pid = FAKE_PID_BASH, .ip = FAKE_IP_BASH_MAIN, },
37+ { .pid = FAKE_PID_BASH, .ip = FAKE_IP_BASH_MAIN, .socket = 2 },
3738 /* bash [bash] xmalloc() */
38− { .pid = FAKE_PID_BASH, .ip = FAKE_IP_BASH_XMALLOC, },
39+ { .pid = FAKE_PID_BASH, .ip = FAKE_IP_BASH_XMALLOC, .socket = 2 },
3940 /* bash [libc] malloc() */
40− { .pid = FAKE_PID_BASH, .ip = FAKE_IP_LIBC_MALLOC, },
41+ { .pid = FAKE_PID_BASH, .ip = FAKE_IP_LIBC_MALLOC, .socket = 3 },
4142 /* bash [kernel] page_fault() */
42− { .pid = FAKE_PID_BASH, .ip = FAKE_IP_KERNEL_PAGE_FAULT, },
43+ { .pid = FAKE_PID_BASH, .ip = FAKE_IP_KERNEL_PAGE_FAULT, .socket = 3 },
4344 };
4445
4546 static int add_hist_entries(struct perf_evlist *evlist,
@@ -83,6 +84,7 @@ static int add_hist_entries(struct perf_evlist *evlist, · 37 unmodified lines
8384 &sample) < 0)
8485 goto out;
8586
87+ al.socket = fake_samples[i].socket;
8688 if (hist_entry_iter__add(&iter, &al,
8789 PERF_MAX_STACK_DEPTH, NULL) < 0) {
8890 addr_location__put(&al);
@@ -253,6 +255,39 @@ int test__hists_filter(void) · 164 unmodified lines
253255 TEST_ASSERT_VAL("Unmatched total period for symbol filter",
254256 hists->stats.total_non_filtered_period == 300);
255257
258+ /* remove symbol filter first */
259+ hists->symbol_filter_str = NULL;
260+ hists__filter_by_symbol(hists);
261+
262+ /* now applying socket filters */
263+ hists->socket_filter = 2;
264+ hists__filter_by_socket(hists);
265+
266+ if (verbose > 2) {
267+ pr_info("Histogram for socket filters\n");
268+ print_hists_out(hists);
269+ }
270+
271+ /* normal stats should be invariant */
272+ TEST_ASSERT_VAL("Invalid nr samples",
273+ hists->stats.nr_events[PERF_RECORD_SAMPLE] == 10);
274+ TEST_ASSERT_VAL("Invalid nr hist entries",
275+ hists->nr_entries == 9);
276+ TEST_ASSERT_VAL("Invalid total period",
277+ hists->stats.total_period == 1000);
278+
279+ /* but filter stats are changed */
280+ TEST_ASSERT_VAL("Unmatched nr samples for socket filter",
281+ hists->stats.nr_non_filtered_samples == 2);
282+ TEST_ASSERT_VAL("Unmatched nr hist entries for socket filter",
283+ hists->nr_non_filtered_entries == 2);
284+ TEST_ASSERT_VAL("Unmatched total period for socket filter",
285+ hists->stats.total_non_filtered_period == 200);
286+
287+ /* remove socket filter first */
288+ hists->socket_filter = -1;
289+ hists__filter_by_socket(hists);
290+
256291 /* now applying all filters at once. */
257292 hists->thread_filter = fake_samples[1].thread;
258293 hists->dso_filter = fake_samples[1].map->dso;
tools/perf/tests/make+3−1
@@ -44,6 +44,7 @@ make_no_libnuma := NO_LIBNUMA=1 · 43 unmodified lines
4444 make_no_libaudit := NO_LIBAUDIT=1
4545 make_no_libbionic := NO_LIBBIONIC=1
4646 make_no_auxtrace := NO_AUXTRACE=1
47+make_no_libbpf := NO_LIBBPF=1
4748 make_tags := tags
4849 make_cscope := cscope
4950 make_help := help
@@ -66,7 +67,7 @@ make_static := LDFLAGS=-static · 16 unmodified lines
6667 make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
6768 make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
6869 make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
69−make_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1
70+make_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
7071
7172 # $(run) contains all available tests
7273 run := make_pure
@@ -94,6 +95,7 @@ run += make_no_libnuma · 21 unmodified lines
9495 run += make_no_libaudit
9596 run += make_no_libbionic
9697 run += make_no_auxtrace
98+run += make_no_libbpf
9799 run += make_help
98100 run += make_doc
99101 run += make_perf_o
tools/perf/tests/mmap-basic.c+2−1
@@ -3,6 +3,7 @@ · 2 unmodified lines
33 #include "thread_map.h"
44 #include "cpumap.h"
55 #include "tests.h"
6+#include <linux/err.h>
67
78 /*
89 * This test will generate random numbers of calls to some getpid syscalls,
@@ -65,7 +66,7 @@ int test__basic_mmap(void) · 56 unmodified lines
6566
6667 snprintf(name, sizeof(name), "sys_enter_%s", syscall_names[i]);
6768 evsels[i] = perf_evsel__newtp("syscalls", name);
68− if (evsels[i] == NULL) {
69+ if (IS_ERR(evsels[i])) {
6970 pr_debug("perf_evsel__new\n");
7071 goto out_delete_evlist;
7172 }
tools/perf/tests/openat-syscall-all-cpus.c+6−7
@@ -1,3 +1,5 @@
1+#include <api/fs/fs.h>
2+#include <linux/err.h>
13 #include "evsel.h"
24 #include "tests.h"
35 #include "thread_map.h"
@@ -14,6 +16,7 @@ int test__openat_syscall_event_on_all_cpus(void) · 10 unmodified lines
1416 cpu_set_t cpu_set;
1517 struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
1618 char sbuf[STRERR_BUFSIZE];
19+ char errbuf[BUFSIZ];
1720
1821 if (threads == NULL) {
1922 pr_debug("thread_map__new\n");
@@ -29,13 +32,9 @@ int test__openat_syscall_event_on_all_cpus(void) · 9 unmodified lines
2932 CPU_ZERO(&cpu_set);
3033
3134 evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
32− if (evsel == NULL) {
33− if (tracefs_configured())
34− pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
35− else if (debugfs_configured())
36− pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
37− else
38− pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
35+ if (IS_ERR(evsel)) {
36+ tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat");
37+ pr_debug("%s\n", errbuf);
3938 goto out_thread_map_delete;
4039 }
4140
tools/perf/tests/openat-syscall-tp-fields.c+3−2
@@ -1,3 +1,4 @@
1+#include <linux/err.h>
12 #include "perf.h"
23 #include "evlist.h"
34 #include "evsel.h"
@@ -30,7 +31,7 @@ int test__syscall_openat_tp_fields(void) · 26 unmodified lines
3031 }
3132
3233 evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
33− if (evsel == NULL) {
34+ if (IS_ERR(evsel)) {
3435 pr_debug("%s: perf_evsel__newtp\n", __func__);
3536 goto out_delete_evlist;
3637 }
@@ -88,7 +89,7 @@ int test__syscall_openat_tp_fields(void) · 51 unmodified lines
8889
8990 err = perf_evsel__parse_sample(evsel, event, &sample);
9091 if (err) {
91− pr_err("Can't parse sample, err = %d\n", err);
92+ pr_debug("Can't parse sample, err = %d\n", err);
9293 goto out_delete_evlist;
9394 }
9495
tools/perf/tests/openat-syscall.c+6−7
@@ -1,3 +1,5 @@
1+#include <api/fs/tracing_path.h>
2+#include <linux/err.h>
13 #include "thread_map.h"
24 #include "evsel.h"
35 #include "debug.h"
@@ -10,6 +12,7 @@ int test__openat_syscall_event(void) · 6 unmodified lines
1012 unsigned int nr_openat_calls = 111, i;
1113 struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
1214 char sbuf[STRERR_BUFSIZE];
15+ char errbuf[BUFSIZ];
1316
1417 if (threads == NULL) {
1518 pr_debug("thread_map__new\n");
@@ -17,13 +20,9 @@ int test__openat_syscall_event(void) · 1 unmodified line
1720 }
1821
1922 evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
20− if (evsel == NULL) {
21− if (tracefs_configured())
22− pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
23− else if (debugfs_configured())
24− pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
25− else
26− pr_debug("Neither tracefs or debugfs is enabled in this kernel\n");
23+ if (IS_ERR(evsel)) {
24+ tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat");
25+ pr_debug("%s\n", errbuf);
2726 goto out_thread_map_delete;
2827 }
2928
tools/perf/tests/parse-events.c+33−16
@@ -3,11 +3,11 @@ · 2 unmodified lines
33 #include "evsel.h"
44 #include "evlist.h"
55 #include <api/fs/fs.h>
6−#include <api/fs/tracefs.h>
7−#include <api/fs/debugfs.h>
86 #include "tests.h"
97 #include "debug.h"
8+#include "util.h"
109 #include <linux/hw_breakpoint.h>
10+#include <api/fs/fs.h>
1111
1212 #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
1313 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
@@ -1260,25 +1260,24 @@ test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist) · 1246 unmodified lines
12601260 return test__checkevent_breakpoint_rw(evlist);
12611261 }
12621262
1263+static int test__checkevent_precise_max_modifier(struct perf_evlist *evlist)
1264+{
1265+ struct perf_evsel *evsel = perf_evlist__first(evlist);
1266+
1267+ TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
1268+ TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type);
1269+ TEST_ASSERT_VAL("wrong config",
1270+ PERF_COUNT_SW_TASK_CLOCK == evsel->attr.config);
1271+ return 0;
1272+}
1273+
12631274 static int count_tracepoints(void)
12641275 {
1265− char events_path[PATH_MAX];
12661276 struct dirent *events_ent;
1267− const char *mountpoint;
12681277 DIR *events_dir;
12691278 int cnt = 0;
12701279
1271− mountpoint = tracefs_find_mountpoint();
1272− if (mountpoint) {
1273− scnprintf(events_path, PATH_MAX, "%s/events",
1274− mountpoint);
1275− } else {
1276− mountpoint = debugfs_find_mountpoint();
1277− scnprintf(events_path, PATH_MAX, "%s/tracing/events",
1278− mountpoint);
1279− }
1280−
1281− events_dir = opendir(events_path);
1280+ events_dir = opendir(tracing_events_path);
12821281
12831282 TEST_ASSERT_VAL("Can't open events dir", events_dir);
12841283
@@ -1295,7 +1294,7 @@ static int count_tracepoints(void) · 10 unmodified lines
12951294 continue;
12961295
12971296 scnprintf(sys_path, PATH_MAX, "%s/%s",
1298− events_path, events_ent->d_name);
1297+ tracing_events_path, events_ent->d_name);
12991298
13001299 sys_dir = opendir(sys_path);
13011300 TEST_ASSERT_VAL("Can't open sys dir", sys_dir);
@@ -1575,6 +1574,11 @@ static struct evlist_test test__events[] = { · 273 unmodified lines
15751574 .check = test__checkevent_exclude_idle_modifier_1,
15761575 .id = 46,
15771576 },
1577+ {
1578+ .name = "task-clock:P,cycles",
1579+ .check = test__checkevent_precise_max_modifier,
1580+ .id = 47,
1581+ },
15781582 };
15791583
15801584 static struct evlist_test test__events_pmu[] = {
@@ -1750,6 +1754,17 @@ static int test_pmu_events(void) · 169 unmodified lines
17501754 return ret;
17511755 }
17521756
1757+static void debug_warn(const char *warn, va_list params)
1758+{
1759+ char msg[1024];
1760+
1761+ if (!verbose)
1762+ return;
1763+
1764+ vsnprintf(msg, sizeof(msg), warn, params);
1765+ fprintf(stderr, " Warning: %s\n", msg);
1766+}
1767+
17531768 int test__parse_events(void)
17541769 {
17551770 int ret1, ret2 = 0;
@@ -1761,6 +1776,8 @@ do { \ · 5 unmodified lines
17611776 ret2 = ret1; \
17621777 } while (0)
17631778
1779+ set_warning_routine(debug_warn);
1780+
17641781 TEST_EVENTS(test__events);
17651782
17661783 if (test_pmu())
tools/perf/tests/tests.h+7−3
@@ -24,13 +24,17 @@ enum { · 23 unmodified lines
2424 TEST_SKIP = -2,
2525 };
2626
27+struct test {
28+ const char *desc;
29+ int (*func)(void);
30+};
31+
2732 /* Tests */
2833 int test__vmlinux_matches_kallsyms(void);
2934 int test__openat_syscall_event(void);
3035 int test__openat_syscall_event_on_all_cpus(void);
3136 int test__basic_mmap(void);
3237 int test__PERF_RECORD(void);
33−int test__rdpmc(void);
3438 int test__perf_evsel__roundtrip_name_test(void);
3539 int test__perf_evsel__tp_sched_test(void);
3640 int test__syscall_openat_tp_fields(void);
@@ -46,7 +50,6 @@ int test__bp_signal(void); · 9 unmodified lines
4650 int test__bp_signal_overflow(void);
4751 int test__task_exit(void);
4852 int test__sw_clock_freq(void);
49−int test__perf_time_to_tsc(void);
5053 int test__code_reading(void);
5154 int test__sample_parsing(void);
5255 int test__keep_tracking(void);
@@ -63,8 +66,9 @@ int test__fdarray__add(void); · 10 unmodified lines
6366 int test__kmod_path__parse(void);
6467 int test__thread_map(void);
6568 int test__llvm(void);
69+int test_session_topology(void);
6670
67−#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
71+#if defined(__arm__) || defined(__aarch64__)
6872 #ifdef HAVE_DWARF_UNWIND_SUPPORT
6973 struct thread;
7074 struct perf_sample;
tools/perf/tests/topology.c+115−0
@@ -0,0 +1,115 @@
1+#include <string.h>
2+#include <stdlib.h>
3+#include <stdio.h>
4+#include "tests.h"
5+#include "util.h"
6+#include "session.h"
7+#include "evlist.h"
8+#include "debug.h"
9+
10+#define TEMPL "/tmp/perf-test-XXXXXX"
11+#define DATA_SIZE 10
12+
13+static int get_temp(char *path)
14+{
15+ int fd;
16+
17+ strcpy(path, TEMPL);
18+
19+ fd = mkstemp(path);
20+ if (fd < 0) {
21+ perror("mkstemp failed");
22+ return -1;
23+ }
24+
25+ close(fd);
26+ return 0;
27+}
28+
29+static int session_write_header(char *path)
30+{
31+ struct perf_session *session;
32+ struct perf_data_file file = {
33+ .path = path,
34+ .mode = PERF_DATA_MODE_WRITE,
35+ };
36+
37+ session = perf_session__new(&file, false, NULL);
38+ TEST_ASSERT_VAL("can't get session", session);
39+
40+ session->evlist = perf_evlist__new_default();
41+ TEST_ASSERT_VAL("can't get evlist", session->evlist);
42+
43+ perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
44+ perf_header__set_feat(&session->header, HEADER_NRCPUS);
45+
46+ session->header.data_size += DATA_SIZE;
47+
48+ TEST_ASSERT_VAL("failed to write header",
49+ !perf_session__write_header(session, session->evlist, file.fd, true));
50+
51+ perf_session__delete(session);
52+
53+ return 0;
54+}
55+
56+static int check_cpu_topology(char *path, struct cpu_map *map)
57+{
58+ struct perf_session *session;
59+ struct perf_data_file file = {
60+ .path = path,
61+ .mode = PERF_DATA_MODE_READ,
62+ };
63+ int i;
64+
65+ session = perf_session__new(&file, false, NULL);
66+ TEST_ASSERT_VAL("can't get session", session);
67+
68+ for (i = 0; i < session->header.env.nr_cpus_online; i++) {
69+ pr_debug("CPU %d, core %d, socket %d\n", i,
70+ session->header.env.cpu[i].core_id,
71+ session->header.env.cpu[i].socket_id);
72+ }
73+
74+ for (i = 0; i < map->nr; i++) {
75+ TEST_ASSERT_VAL("Core ID doesn't match",
76+ (session->header.env.cpu[map->map[i]].core_id == (cpu_map__get_core(map, i, NULL) & 0xffff)));
77+
78+ TEST_ASSERT_VAL("Socket ID doesn't match",
79+ (session->header.env.cpu[map->map[i]].socket_id == cpu_map__get_socket(map, i, NULL)));
80+ }
81+
82+ perf_session__delete(session);
83+
84+ return 0;
85+}
86+
87+int test_session_topology(void)
88+{
89+ char path[PATH_MAX];
90+ struct cpu_map *map;
91+ int ret = -1;
92+
93+ TEST_ASSERT_VAL("can't get templ file", !get_temp(path));
94+
95+ pr_debug("templ file: %s\n", path);
96+
97+ if (session_write_header(path))
98+ goto free_path;
99+
100+ map = cpu_map__new(NULL);
101+ if (map == NULL) {
102+ pr_debug("failed to get system cpumap\n");
103+ goto free_path;
104+ }
105+
106+ if (check_cpu_topology(path, map))
107+ goto free_map;
108+ ret = 0;
109+
110+free_map:
111+ cpu_map__put(map);
112+free_path:
113+ unlink(path);
114+ return ret;
115+}
tools/perf/tests/vmlinux-kallsyms.c+2−2
@@ -68,7 +68,7 @@ int test__vmlinux_matches_kallsyms(void) · 67 unmodified lines
6868 * to see if the running kernel was relocated by checking if it has the
6969 * same value in the vmlinux file we load.
7070 */
71− kallsyms_map = machine__kernel_map(&kallsyms, type);
71+ kallsyms_map = machine__kernel_map(&kallsyms);
7272
7373 /*
7474 * Step 5:
@@ -80,7 +80,7 @@ int test__vmlinux_matches_kallsyms(void) · 5 unmodified lines
8080 goto out;
8181 }
8282
83− vmlinux_map = machine__kernel_map(&vmlinux, type);
83+ vmlinux_map = machine__kernel_map(&vmlinux);
8484
8585 /*
8686 * Step 6:
tools/perf/trace/strace/groups/file+2−0
@@ -9,6 +9,7 @@ mkdir · 8 unmodified lines
99 open
1010 openat
1111 quotactl
12+read
1213 readlink
1314 rename
1415 rmdir
@@ -16,3 +17,4 @@ stat · 1 unmodified line
1617 statfs
1718 symlink
1819 unlink
20+write
tools/perf/ui/browser.c+14−0
@@ -393,6 +393,7 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs) · 392 unmodified lines
393393
394394 if (browser->use_navkeypressed && !browser->navkeypressed) {
395395 if (key == K_DOWN || key == K_UP ||
396+ (browser->columns && (key == K_LEFT || key == K_RIGHT)) ||
396397 key == K_PGDN || key == K_PGUP ||
397398 key == K_HOME || key == K_END ||
398399 key == ' ') {
@@ -421,6 +422,18 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs) · 22 unmodified lines
421422 browser->seek(browser, -1, SEEK_CUR);
422423 }
423424 break;
425+ case K_RIGHT:
426+ if (!browser->columns)
427+ goto out;
428+ if (browser->horiz_scroll < browser->columns - 1)
429+ ++browser->horiz_scroll;
430+ break;
431+ case K_LEFT:
432+ if (!browser->columns)
433+ goto out;
434+ if (browser->horiz_scroll != 0)
435+ --browser->horiz_scroll;
436+ break;
424437 case K_PGDN:
425438 case ' ':
426439 if (browser->top_idx + browser->rows > browser->nr_entries - 1)
@@ -459,6 +472,7 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs) · 32 unmodified lines
459472 browser->seek(browser, -offset, SEEK_END);
460473 break;
461474 default:
475+ out:
462476 return key;
463477 }
464478 }
tools/perf/ui/browser.h+1−1
@@ -14,7 +14,7 @@ · 13 unmodified lines
1414 struct ui_browser {
1515 u64 index, top_idx;
1616 void *top, *entries;
17− u16 y, x, width, height, rows;
17+ u16 y, x, width, height, rows, columns, horiz_scroll;
1818 int current_color;
1919 void *priv;
2020 const char *title;
tools/perf/ui/browsers/annotate.c+7−7
@@ -768,8 +768,8 @@ static int annotate_browser__run(struct annotate_browser *browser, · 767 unmodified lines
768768 "UP/DOWN/PGUP\n"
769769 "PGDN/SPACE Navigate\n"
770770 "q/ESC/CTRL+C Exit\n\n"
771− "-> Go to target\n"
772− "<- Exit\n"
771+ "ENTER Go to target\n"
772+ "ESC Exit\n"
773773 "H Cycle thru hottest instructions\n"
774774 "j Toggle showing jump to target arrows\n"
775775 "J Toggle showing number of jump sources on targets\n"
@@ -1056,7 +1056,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, · 280 unmodified lines
10561056 goto out_free_offsets;
10571057 }
10581058
1059− ui_helpline__push("Press <- or ESC to exit");
1059+ ui_helpline__push("Press ESC to exit");
10601060
10611061 notes = symbol__annotation(sym);
10621062 browser.start = map__rip_2objdump(map, sym->start);
@@ -1125,8 +1125,8 @@ static struct annotate_config { · 62 unmodified lines
11251125 ANNOTATE_CFG(jump_arrows),
11261126 ANNOTATE_CFG(show_linenr),
11271127 ANNOTATE_CFG(show_nr_jumps),
1128− ANNOTATE_CFG(use_offset),
11291128 ANNOTATE_CFG(show_total_period),
1129+ ANNOTATE_CFG(use_offset),
11301130 };
11311131
11321132 #undef ANNOTATE_CFG
@@ -1152,9 +1152,9 @@ static int annotate__config(const char *var, const char *value, · 19 unmodified lines
11521152 sizeof(struct annotate_config), annotate_config__cmp);
11531153
11541154 if (cfg == NULL)
1155− return -1;
1156−
1157− *cfg->value = perf_config_bool(name, value);
1155+ ui__warning("%s variable unknown, ignoring...", var);
1156+ else
1157+ *cfg->value = perf_config_bool(name, value);
11581158 return 0;
11591159 }
11601160
tools/perf/ui/browsers/hists.c+95−25
@@ -784,11 +784,12 @@ static int hist_browser__show_entry(struct hist_browser *browser, · 783 unmodified lines
784784 .size = sizeof(s),
785785 .ptr = &arg,
786786 };
787+ int column = 0;
787788
788789 hist_browser__gotorc(browser, row, 0);
789790
790791 perf_hpp__for_each_format(fmt) {
791− if (perf_hpp__should_skip(fmt))
792+ if (perf_hpp__should_skip(fmt) || column++ < browser->b.horiz_scroll)
792793 continue;
793794
794795 if (current_entry && browser->b.navkeypressed) {
@@ -861,14 +862,16 @@ static int advance_hpp_check(struct perf_hpp *hpp, int inc) · 66 unmodified lines
861862 return hpp->size <= 0;
862863 }
863864
864−static int hists__scnprintf_headers(char *buf, size_t size, struct hists *hists)
865+static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *buf, size_t size)
865866 {
867+ struct hists *hists = browser->hists;
866868 struct perf_hpp dummy_hpp = {
867869 .buf = buf,
868870 .size = size,
869871 };
870872 struct perf_hpp_fmt *fmt;
871873 size_t ret = 0;
874+ int column = 0;
872875
873876 if (symbol_conf.use_callchain) {
874877 ret = scnprintf(buf, size, " ");
@@ -877,7 +880,7 @@ static int hists__scnprintf_headers(char *buf, size_t size, struct hists *hists) · 2 unmodified lines
877880 }
878881
879882 perf_hpp__for_each_format(fmt) {
880− if (perf_hpp__should_skip(fmt))
883+ if (perf_hpp__should_skip(fmt) || column++ < browser->b.horiz_scroll)
881884 continue;
882885
883886 ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
@@ -896,7 +899,7 @@ static void hist_browser__show_headers(struct hist_browser *browser) · 12 unmodified lines
896899 {
897900 char headers[1024];
898901
899− hists__scnprintf_headers(headers, sizeof(headers), browser->hists);
902+ hists_browser__scnprintf_headers(browser, headers, sizeof(headers));
900903 ui_browser__gotorc(&browser->b, 0, 0);
901904 ui_browser__set_color(&browser->b, HE_COLORSET_ROOT);
902905 ui_browser__write_nstring(&browser->b, headers, browser->b.width + 1);
@@ -1261,6 +1264,7 @@ static int hists__browser_title(struct hists *hists, · 358 unmodified lines
12611264 int printed;
12621265 const struct dso *dso = hists->dso_filter;
12631266 const struct thread *thread = hists->thread_filter;
1267+ int socket_id = hists->socket_filter;
12641268 unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
12651269 u64 nr_events = hists->stats.total_period;
12661270 struct perf_evsel *evsel = hists_to_evsel(hists);
@@ -1314,6 +1318,9 @@ static int hists__browser_title(struct hists *hists, · 47 unmodified lines
13141318 if (dso)
13151319 printed += scnprintf(bf + printed, size - printed,
13161320 ", DSO: %s", dso->short_name);
1321+ if (socket_id > -1)
1322+ printed += scnprintf(bf + printed, size - printed,
1323+ ", Processor Socket: %d", socket_id);
13171324 if (!is_report_browser(hbt)) {
13181325 struct perf_top *top = hbt->arg;
13191326
@@ -1425,6 +1432,7 @@ struct popup_action { · 105 unmodified lines
14251432 struct thread *thread;
14261433 struct dso *dso;
14271434 struct map_symbol ms;
1435+ int socket;
14281436
14291437 int (*fn)(struct hist_browser *browser, struct popup_action *act);
14301438 };
@@ -1437,7 +1445,7 @@ do_annotate(struct hist_browser *browser, struct popup_action *act) · 6 unmodified lines
14371445 struct hist_entry *he;
14381446 int err;
14391447
1440− if (!objdump_path && perf_session_env__lookup_objdump(browser->env))
1448+ if (!objdump_path && perf_env__lookup_objdump(browser->env))
14411449 return 0;
14421450
14431451 notes = symbol__annotation(act->ms.sym);
@@ -1488,7 +1496,7 @@ do_zoom_thread(struct hist_browser *browser, struct popup_action *act) · 44 unmodified lines
14881496 thread__zput(browser->hists->thread_filter);
14891497 ui_helpline__pop();
14901498 } else {
1491− ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"",
1499+ ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s(%d) thread\"",
14921500 thread->comm_set ? thread__comm_str(thread) : "",
14931501 thread->tid);
14941502 browser->hists->thread_filter = thread__get(thread);
@@ -1522,7 +1530,7 @@ add_thread_opt(struct hist_browser *browser, struct popup_action *act, · 27 unmodified lines
15221530 static int
15231531 do_zoom_dso(struct hist_browser *browser, struct popup_action *act)
15241532 {
1525− struct dso *dso = act->dso;
1533+ struct map *map = act->ms.map;
15261534
15271535 if (browser->hists->dso_filter) {
15281536 pstack__remove(browser->pstack, &browser->hists->dso_filter);
@@ -1530,11 +1538,11 @@ do_zoom_dso(struct hist_browser *browser, struct popup_action *act) · 1 unmodified line
15301538 browser->hists->dso_filter = NULL;
15311539 ui_helpline__pop();
15321540 } else {
1533− if (dso == NULL)
1541+ if (map == NULL)
15341542 return 0;
1535− ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s DSO\"",
1536− dso->kernel ? "the Kernel" : dso->short_name);
1537− browser->hists->dso_filter = dso;
1543+ ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s DSO\"",
1544+ __map__is_kernel(map) ? "the Kernel" : map->dso->short_name);
1545+ browser->hists->dso_filter = map->dso;
15381546 perf_hpp__set_elide(HISTC_DSO, true);
15391547 pstack__push(browser->pstack, &browser->hists->dso_filter);
15401548 }
@@ -1546,17 +1554,18 @@ do_zoom_dso(struct hist_browser *browser, struct popup_action *act) · 5 unmodified lines
15461554
15471555 static int
15481556 add_dso_opt(struct hist_browser *browser, struct popup_action *act,
1549− char **optstr, struct dso *dso)
1557+ char **optstr, struct map *map)
15501558 {
1551− if (dso == NULL)
1559+ if (map == NULL)
15521560 return 0;
15531561
15541562 if (asprintf(optstr, "Zoom %s %s DSO",
15551563 browser->hists->dso_filter ? "out of" : "into",
1556− dso->kernel ? "the Kernel" : dso->short_name) < 0)
1564+ __map__is_kernel(map) ? "the Kernel" : map->dso->short_name) < 0)
15571565 return 0;
15581566
1559− act->dso = dso;
1567+ act->ms.map = map;
1568+ act->dso = map->dso;
15601569 act->fn = do_zoom_dso;
15611570 return 1;
15621571 }
@@ -1672,6 +1681,41 @@ add_exit_opt(struct hist_browser *browser __maybe_unused, · 109 unmodified lines
16721681 return 1;
16731682 }
16741683
1684+static int
1685+do_zoom_socket(struct hist_browser *browser, struct popup_action *act)
1686+{
1687+ if (browser->hists->socket_filter > -1) {
1688+ pstack__remove(browser->pstack, &browser->hists->socket_filter);
1689+ browser->hists->socket_filter = -1;
1690+ perf_hpp__set_elide(HISTC_SOCKET, false);
1691+ } else {
1692+ browser->hists->socket_filter = act->socket;
1693+ perf_hpp__set_elide(HISTC_SOCKET, true);
1694+ pstack__push(browser->pstack, &browser->hists->socket_filter);
1695+ }
1696+
1697+ hists__filter_by_socket(browser->hists);
1698+ hist_browser__reset(browser);
1699+ return 0;
1700+}
1701+
1702+static int
1703+add_socket_opt(struct hist_browser *browser, struct popup_action *act,
1704+ char **optstr, int socket_id)
1705+{
1706+ if (socket_id < 0)
1707+ return 0;
1708+
1709+ if (asprintf(optstr, "Zoom %s Processor Socket %d",
1710+ (browser->hists->socket_filter > -1) ? "out of" : "into",
1711+ socket_id) < 0)
1712+ return 0;
1713+
1714+ act->socket = socket_id;
1715+ act->fn = do_zoom_socket;
1716+ return 1;
1717+}
1718+
16751719 static void hist_browser__update_nr_entries(struct hist_browser *hb)
16761720 {
16771721 u64 nr_entries = 0;
@@ -1717,14 +1761,16 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, · 39 unmodified lines
17171761 "For multiple event sessions:\n\n" \
17181762 "TAB/UNTAB Switch events\n\n" \
17191763 "For symbolic views (--sort has sym):\n\n" \
1720− "-> Zoom into DSO/Threads & Annotate current symbol\n" \
1721− "<- Zoom out\n" \
1764+ "ENTER Zoom into DSO/Threads & Annotate current symbol\n" \
1765+ "ESC Zoom out\n" \
17221766 "a Annotate current symbol\n" \
17231767 "C Collapse all callchains\n" \
17241768 "d Zoom into current DSO\n" \
17251769 "E Expand all callchains\n" \
17261770 "F Toggle percentage of filtered entries\n" \
17271771 "H Display column headers\n" \
1772+ "m Display context menu\n" \
1773+ "S Zoom into current Processor Socket\n" \
17281774
17291775 /* help messages are sorted by lexical order of the hotkey */
17301776 const char report_help[] = HIST_BROWSER_HELP_COMMON
@@ -1755,7 +1801,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, · 24 unmodified lines
17551801 hist_browser__update_nr_entries(browser);
17561802 }
17571803
1758− browser->pstack = pstack__new(2);
1804+ browser->pstack = pstack__new(3);
17591805 if (browser->pstack == NULL)
17601806 goto out;
17611807
@@ -1764,8 +1810,17 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, · 2 unmodified lines
17641810 memset(options, 0, sizeof(options));
17651811 memset(actions, 0, sizeof(actions));
17661812
1767− perf_hpp__for_each_format(fmt)
1813+ perf_hpp__for_each_format(fmt) {
17681814 perf_hpp__reset_width(fmt, hists);
1815+ /*
1816+ * This is done just once, and activates the horizontal scrolling
1817+ * code in the ui_browser code, it would be better to have a the
1818+ * counter in the perf_hpp code, but I couldn't find doing it here
1819+ * works, FIXME by setting this in hist_browser__new, for now, be
1820+ * clever 8-)
1821+ */
1822+ ++browser->b.columns;
1823+ }
17691824
17701825 if (symbol_conf.col_width_list_str)
17711826 perf_hpp__set_user_width(symbol_conf.col_width_list_str);
@@ -1773,7 +1828,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, · 1 unmodified line
17731828 while (1) {
17741829 struct thread *thread = NULL;
17751830 struct dso *dso = NULL;
1831+ struct map *map = NULL;
17761832 int choice = 0;
1833+ int socked_id = -1;
17771834
17781835 nr_options = 0;
17791836
@@ -1781,7 +1838,10 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, · 1 unmodified line
17811838
17821839 if (browser->he_selection != NULL) {
17831840 thread = hist_browser__selected_thread(browser);
1784− dso = browser->selection->map ? browser->selection->map->dso : NULL;
1841+ map = browser->selection->map;
1842+ if (map)
1843+ dso = map->dso;
1844+ socked_id = browser->he_selection->socket;
17851845 }
17861846 switch (key) {
17871847 case K_TAB:
@@ -1824,9 +1884,14 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, · 36 unmodified lines
18241884 actions->thread = thread;
18251885 do_zoom_thread(browser, actions);
18261886 continue;
1887+ case 'S':
1888+ actions->socket = socked_id;
1889+ do_zoom_socket(browser, actions);
1890+ continue;
18271891 case '/':
18281892 if (ui_browser__input_window("Symbol to show",
1829− "Please enter the name of symbol you want to see",
1893+ "Please enter the name of symbol you want to see.\n"
1894+ "To remove the filter later, press / + ENTER.",
18301895 buf, "ENTER: OK, ESC: Cancel",
18311896 delay_secs * 2) == K_ENTER) {
18321897 hists->symbol_filter_str = *buf ? buf : NULL;
@@ -1871,6 +1936,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, · 38 unmodified lines
18711936 continue;
18721937 case K_ENTER:
18731938 case K_RIGHT:
1939+ case 'm':
18741940 /* menu */
18751941 break;
18761942 case K_ESC:
@@ -1899,9 +1965,11 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, · 22 unmodified lines
18991965 * Ditto for thread below.
19001966 */
19011967 do_zoom_dso(browser, actions);
1902− }
1903− if (top == &browser->hists->thread_filter)
1968+ } else if (top == &browser->hists->thread_filter) {
19041969 do_zoom_thread(browser, actions);
1970+ } else if (top == &browser->hists->socket_filter) {
1971+ do_zoom_socket(browser, actions);
1972+ }
19051973 continue;
19061974 }
19071975 case 'q':
@@ -1965,12 +2033,14 @@ skip_annotation: · 57 unmodified lines
19652033 nr_options += add_thread_opt(browser, &actions[nr_options],
19662034 &options[nr_options], thread);
19672035 nr_options += add_dso_opt(browser, &actions[nr_options],
1968− &options[nr_options], dso);
2036+ &options[nr_options], map);
19692037 nr_options += add_map_opt(browser, &actions[nr_options],
19702038 &options[nr_options],
19712039 browser->selection ?
19722040 browser->selection->map : NULL);
1973−
2041+ nr_options += add_socket_opt(browser, &actions[nr_options],
2042+ &options[nr_options],
2043+ socked_id);
19742044 /* perf script support */
19752045 if (browser->he_selection) {
19762046 nr_options += add_script_opt(browser,
tools/perf/ui/browsers/map.c+1−1
@@ -72,7 +72,7 @@ static int map_browser__run(struct map_browser *browser) · 71 unmodified lines
7272 int key;
7373
7474 if (ui_browser__show(&browser->b, browser->map->dso->long_name,
75− "Press <- or ESC to exit, %s / to search",
75+ "Press ESC to exit, %s / to search",
7676 verbose ? "" : "restart with -v to use") < 0)
7777 return -1;
7878
tools/perf/ui/browsers/scripts.c+1−1
@@ -89,7 +89,7 @@ static int script_browser__run(struct perf_script_browser *browser) · 88 unmodified lines
8989 int key;
9090
9191 if (ui_browser__show(&browser->b, browser->script_name,
92− "Press <- or ESC to exit") < 0)
92+ "Press ESC to exit") < 0)
9393 return -1;
9494
9595 while (1) {
tools/perf/ui/hist.c+8−8
@@ -463,27 +463,27 @@ void perf_hpp__init(void) · 462 unmodified lines
463463 return;
464464
465465 if (symbol_conf.cumulate_callchain) {
466− perf_hpp__column_enable(PERF_HPP__OVERHEAD_ACC);
466+ hpp_dimension__add_output(PERF_HPP__OVERHEAD_ACC);
467467 perf_hpp__format[PERF_HPP__OVERHEAD].name = "Self";
468468 }
469469
470− perf_hpp__column_enable(PERF_HPP__OVERHEAD);
470+ hpp_dimension__add_output(PERF_HPP__OVERHEAD);
471471
472472 if (symbol_conf.show_cpu_utilization) {
473− perf_hpp__column_enable(PERF_HPP__OVERHEAD_SYS);
474− perf_hpp__column_enable(PERF_HPP__OVERHEAD_US);
473+ hpp_dimension__add_output(PERF_HPP__OVERHEAD_SYS);
474+ hpp_dimension__add_output(PERF_HPP__OVERHEAD_US);
475475
476476 if (perf_guest) {
477− perf_hpp__column_enable(PERF_HPP__OVERHEAD_GUEST_SYS);
478− perf_hpp__column_enable(PERF_HPP__OVERHEAD_GUEST_US);
477+ hpp_dimension__add_output(PERF_HPP__OVERHEAD_GUEST_SYS);
478+ hpp_dimension__add_output(PERF_HPP__OVERHEAD_GUEST_US);
479479 }
480480 }
481481
482482 if (symbol_conf.show_nr_samples)
483− perf_hpp__column_enable(PERF_HPP__SAMPLES);
483+ hpp_dimension__add_output(PERF_HPP__SAMPLES);
484484
485485 if (symbol_conf.show_total_period)
486− perf_hpp__column_enable(PERF_HPP__PERIOD);
486+ hpp_dimension__add_output(PERF_HPP__PERIOD);
487487
488488 /* prepend overhead field for backward compatiblity. */
489489 list = &perf_hpp__format[PERF_HPP__OVERHEAD].sort_list;
tools/perf/ui/tui/setup.c+4−4
@@ -141,10 +141,6 @@ int ui__init(void) · 140 unmodified lines
141141
142142 SLkp_define_keysym((char *)"^(kB)", SL_KEY_UNTAB);
143143
144− ui_helpline__init();
145− ui_browser__init();
146− tui_progress__init();
147−
148144 signal(SIGSEGV, ui__signal_backtrace);
149145 signal(SIGFPE, ui__signal_backtrace);
150146 signal(SIGINT, ui__signal);
@@ -153,6 +149,10 @@ int ui__init(void) · 2 unmodified lines
153149
154150 perf_error__register(&perf_tui_eops);
155151
152+ ui_helpline__init();
153+ ui_browser__init();
154+ tui_progress__init();
155+
156156 hist_browser__init_hpp();
157157 out:
158158 return err;
tools/perf/util/Build+2−0
@@ -5,6 +5,7 @@ libperf-y += build-id.o · 4 unmodified lines
55 libperf-y += config.o
66 libperf-y += ctype.o
77 libperf-y += db-export.o
8+libperf-y += env.o
89 libperf-y += environment.o
910 libperf-y += event.o
1011 libperf-y += evlist.o
@@ -86,6 +87,7 @@ libperf-$(CONFIG_AUXTRACE) += intel-bts.o · 75 unmodified lines
8687 libperf-y += parse-branch-options.o
8788 libperf-y += parse-regs-options.o
8889
90+libperf-$(CONFIG_LIBBPF) += bpf-loader.o
8991 libperf-$(CONFIG_LIBELF) += symbol-elf.o
9092 libperf-$(CONFIG_LIBELF) += probe-file.o
9193 libperf-$(CONFIG_LIBELF) += probe-event.o
tools/perf/util/annotate.c+4−1
@@ -548,8 +548,11 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map, · 547 unmodified lines
548548
549549 pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));
550550
551− if (addr < sym->start || addr >= sym->end)
551+ if (addr < sym->start || addr >= sym->end) {
552+ pr_debug("%s(%d): ERANGE! sym->name=%s, start=%#" PRIx64 ", addr=%#" PRIx64 ", end=%#" PRIx64 "\n",
553+ __func__, __LINE__, sym->name, sym->start, addr, sym->end);
552554 return -ERANGE;
555+ }
553556
554557 offset = addr - sym->start;
555558 h = annotation__histogram(notes, evidx);
tools/perf/util/annotate.h+1−1
@@ -122,7 +122,7 @@ struct annotated_source { · 121 unmodified lines
122122 struct list_head source;
123123 struct source_line *lines;
124124 int nr_histograms;
125− int sizeof_sym_hist;
125+ size_t sizeof_sym_hist;
126126 struct cyc_hist *cycles_hist;
127127 struct sym_hist histograms[0];
128128 };
tools/perf/util/auxtrace.c+23−1
@@ -926,6 +926,8 @@ s64 perf_event__process_auxtrace(struct perf_tool *tool, · 925 unmodified lines
926926 #define PERF_ITRACE_DEFAULT_PERIOD 100000
927927 #define PERF_ITRACE_DEFAULT_CALLCHAIN_SZ 16
928928 #define PERF_ITRACE_MAX_CALLCHAIN_SZ 1024
929+#define PERF_ITRACE_DEFAULT_LAST_BRANCH_SZ 64
930+#define PERF_ITRACE_MAX_LAST_BRANCH_SZ 1024
929931
930932 void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts)
931933 {
@@ -936,6 +938,7 @@ void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts) · 4 unmodified lines
936938 synth_opts->period_type = PERF_ITRACE_DEFAULT_PERIOD_TYPE;
937939 synth_opts->period = PERF_ITRACE_DEFAULT_PERIOD;
938940 synth_opts->callchain_sz = PERF_ITRACE_DEFAULT_CALLCHAIN_SZ;
941+ synth_opts->last_branch_sz = PERF_ITRACE_DEFAULT_LAST_BRANCH_SZ;
939942 }
940943
941944 /*
@@ -950,6 +953,7 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str, · 8 unmodified lines
950953 const char *p;
951954 char *endptr;
952955 bool period_type_set = false;
956+ bool period_set = false;
953957
954958 synth_opts->set = true;
955959
@@ -971,6 +975,7 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str, · 15 unmodified lines
971975 p += 1;
972976 if (isdigit(*p)) {
973977 synth_opts->period = strtoull(p, &endptr, 10);
978+ period_set = true;
974979 p = endptr;
975980 while (*p == ' ' || *p == ',')
976981 p += 1;
@@ -1041,6 +1046,23 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str, · 64 unmodified lines
10411046 synth_opts->callchain_sz = val;
10421047 }
10431048 break;
1049+ case 'l':
1050+ synth_opts->last_branch = true;
1051+ synth_opts->last_branch_sz =
1052+ PERF_ITRACE_DEFAULT_LAST_BRANCH_SZ;
1053+ while (*p == ' ' || *p == ',')
1054+ p += 1;
1055+ if (isdigit(*p)) {
1056+ unsigned int val;
1057+
1058+ val = strtoul(p, &endptr, 10);
1059+ p = endptr;
1060+ if (!val ||
1061+ val > PERF_ITRACE_MAX_LAST_BRANCH_SZ)
1062+ goto out_err;
1063+ synth_opts->last_branch_sz = val;
1064+ }
1065+ break;
10441066 case ' ':
10451067 case ',':
10461068 break;
@@ -1053,7 +1075,7 @@ out: · 6 unmodified lines
10531075 if (!period_type_set)
10541076 synth_opts->period_type =
10551077 PERF_ITRACE_DEFAULT_PERIOD_TYPE;
1056− if (!synth_opts->period)
1078+ if (!period_set)
10571079 synth_opts->period = PERF_ITRACE_DEFAULT_PERIOD;
10581080 }
10591081
tools/perf/util/auxtrace.h+4−0
@@ -63,7 +63,9 @@ enum itrace_period_type { · 62 unmodified lines
6363 * @calls: limit branch samples to calls (can be combined with @returns)
6464 * @returns: limit branch samples to returns (can be combined with @calls)
6565 * @callchain: add callchain to 'instructions' events
66+ * @last_branch: add branch context to 'instruction' events
6667 * @callchain_sz: maximum callchain size
68+ * @last_branch_sz: branch context size
6769 * @period: 'instructions' events period
6870 * @period_type: 'instructions' events period type
6971 */
@@ -79,7 +81,9 @@ struct itrace_synth_opts { · 9 unmodified lines
7981 bool calls;
8082 bool returns;
8183 bool callchain;
84+ bool last_branch;
8285 unsigned int callchain_sz;
86+ unsigned int last_branch_sz;
8387 unsigned long long period;
8488 enum itrace_period_type period_type;
8589 };
tools/perf/util/bpf-loader.c+352−0
@@ -0,0 +1,352 @@
1+/*
2+ * bpf-loader.c
3+ *
4+ * Copyright (C) 2015 Wang Nan <wangnan0@huawei.com>
5+ * Copyright (C) 2015 Huawei Inc.
6+ */
7+
8+#include <bpf/libbpf.h>
9+#include <linux/err.h>
10+#include "perf.h"
11+#include "debug.h"
12+#include "bpf-loader.h"
13+#include "probe-event.h"
14+#include "probe-finder.h" // for MAX_PROBES
15+#include "llvm-utils.h"
16+
17+#define DEFINE_PRINT_FN(name, level) \
18+static int libbpf_##name(const char *fmt, ...) \
19+{ \
20+ va_list args; \
21+ int ret; \
22+ \
23+ va_start(args, fmt); \
24+ ret = veprintf(level, verbose, pr_fmt(fmt), args);\
25+ va_end(args); \
26+ return ret; \
27+}
28+
29+DEFINE_PRINT_FN(warning, 0)
30+DEFINE_PRINT_FN(info, 0)
31+DEFINE_PRINT_FN(debug, 1)
32+
33+struct bpf_prog_priv {
34+ struct perf_probe_event pev;
35+};
36+
37+struct bpf_object *bpf__prepare_load(const char *filename, bool source)
38+{
39+ struct bpf_object *obj;
40+ static bool libbpf_initialized;
41+
42+ if (!libbpf_initialized) {
43+ libbpf_set_print(libbpf_warning,
44+ libbpf_info,
45+ libbpf_debug);
46+ libbpf_initialized = true;
47+ }
48+
49+ if (source) {
50+ int err;
51+ void *obj_buf;
52+ size_t obj_buf_sz;
53+
54+ err = llvm__compile_bpf(filename, &obj_buf, &obj_buf_sz);
55+ if (err)
56+ return ERR_PTR(err);
57+ obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, filename);
58+ free(obj_buf);
59+ } else
60+ obj = bpf_object__open(filename);
61+
62+ if (!obj) {
63+ pr_debug("bpf: failed to load %s\n", filename);
64+ return ERR_PTR(-EINVAL);
65+ }
66+
67+ return obj;
68+}
69+
70+void bpf__clear(void)
71+{
72+ struct bpf_object *obj, *tmp;
73+
74+ bpf_object__for_each_safe(obj, tmp) {
75+ bpf__unprobe(obj);
76+ bpf_object__close(obj);
77+ }
78+}
79+
80+static void
81+bpf_prog_priv__clear(struct bpf_program *prog __maybe_unused,
82+ void *_priv)
83+{
84+ struct bpf_prog_priv *priv = _priv;
85+
86+ cleanup_perf_probe_events(&priv->pev, 1);
87+ free(priv);
88+}
89+
90+static int
91+config_bpf_program(struct bpf_program *prog)
92+{
93+ struct perf_probe_event *pev = NULL;
94+ struct bpf_prog_priv *priv = NULL;
95+ const char *config_str;
96+ int err;
97+
98+ config_str = bpf_program__title(prog, false);
99+ if (!config_str) {
100+ pr_debug("bpf: unable to get title for program\n");
101+ return -EINVAL;
102+ }
103+
104+ priv = calloc(sizeof(*priv), 1);
105+ if (!priv) {
106+ pr_debug("bpf: failed to alloc priv\n");
107+ return -ENOMEM;
108+ }
109+ pev = &priv->pev;
110+
111+ pr_debug("bpf: config program '%s'\n", config_str);
112+ err = parse_perf_probe_command(config_str, pev);
113+ if (err < 0) {
114+ pr_debug("bpf: '%s' is not a valid config string\n",
115+ config_str);
116+ err = -EINVAL;
117+ goto errout;
118+ }
119+
120+ if (pev->group && strcmp(pev->group, PERF_BPF_PROBE_GROUP)) {
121+ pr_debug("bpf: '%s': group for event is set and not '%s'.\n",
122+ config_str, PERF_BPF_PROBE_GROUP);
123+ err = -EINVAL;
124+ goto errout;
125+ } else if (!pev->group)
126+ pev->group = strdup(PERF_BPF_PROBE_GROUP);
127+
128+ if (!pev->group) {
129+ pr_debug("bpf: strdup failed\n");
130+ err = -ENOMEM;
131+ goto errout;
132+ }
133+
134+ if (!pev->event) {
135+ pr_debug("bpf: '%s': event name is missing\n",
136+ config_str);
137+ err = -EINVAL;
138+ goto errout;
139+ }
140+ pr_debug("bpf: config '%s' is ok\n", config_str);
141+
142+ err = bpf_program__set_private(prog, priv, bpf_prog_priv__clear);
143+ if (err) {
144+ pr_debug("Failed to set priv for program '%s'\n", config_str);
145+ goto errout;
146+ }
147+
148+ return 0;
149+
150+errout:
151+ if (pev)
152+ clear_perf_probe_event(pev);
153+ free(priv);
154+ return err;
155+}
156+
157+static int bpf__prepare_probe(void)
158+{
159+ static int err = 0;
160+ static bool initialized = false;
161+
162+ /*
163+ * Make err static, so if init failed the first, bpf__prepare_probe()
164+ * fails each time without calling init_probe_symbol_maps multiple
165+ * times.
166+ */
167+ if (initialized)
168+ return err;
169+
170+ initialized = true;
171+ err = init_probe_symbol_maps(false);
172+ if (err < 0)
173+ pr_debug("Failed to init_probe_symbol_maps\n");
174+ probe_conf.max_probes = MAX_PROBES;
175+ return err;
176+}
177+
178+int bpf__probe(struct bpf_object *obj)
179+{
180+ int err = 0;
181+ struct bpf_program *prog;
182+ struct bpf_prog_priv *priv;
183+ struct perf_probe_event *pev;
184+
185+ err = bpf__prepare_probe();
186+ if (err) {
187+ pr_debug("bpf__prepare_probe failed\n");
188+ return err;
189+ }
190+
191+ bpf_object__for_each_program(prog, obj) {
192+ err = config_bpf_program(prog);
193+ if (err)
194+ goto out;
195+
196+ err = bpf_program__get_private(prog, (void **)&priv);
197+ if (err || !priv)
198+ goto out;
199+ pev = &priv->pev;
200+
201+ err = convert_perf_probe_events(pev, 1);
202+ if (err < 0) {
203+ pr_debug("bpf_probe: failed to convert perf probe events");
204+ goto out;
205+ }
206+
207+ err = apply_perf_probe_events(pev, 1);
208+ if (err < 0) {
209+ pr_debug("bpf_probe: failed to apply perf probe events");
210+ goto out;
211+ }
212+ }
213+out:
214+ return err < 0 ? err : 0;
215+}
216+
217+#define EVENTS_WRITE_BUFSIZE 4096
218+int bpf__unprobe(struct bpf_object *obj)
219+{
220+ int err, ret = 0;
221+ struct bpf_program *prog;
222+ struct bpf_prog_priv *priv;
223+
224+ bpf_object__for_each_program(prog, obj) {
225+ int i;
226+
227+ err = bpf_program__get_private(prog, (void **)&priv);
228+ if (err || !priv)
229+ continue;
230+
231+ for (i = 0; i < priv->pev.ntevs; i++) {
232+ struct probe_trace_event *tev = &priv->pev.tevs[i];
233+ char name_buf[EVENTS_WRITE_BUFSIZE];
234+ struct strfilter *delfilter;
235+
236+ snprintf(name_buf, EVENTS_WRITE_BUFSIZE,
237+ "%s:%s", tev->group, tev->event);
238+ name_buf[EVENTS_WRITE_BUFSIZE - 1] = '\0';
239+
240+ delfilter = strfilter__new(name_buf, NULL);
241+ if (!delfilter) {
242+ pr_debug("Failed to create filter for unprobing\n");
243+ ret = -ENOMEM;
244+ continue;
245+ }
246+
247+ err = del_perf_probe_events(delfilter);
248+ strfilter__delete(delfilter);
249+ if (err) {
250+ pr_debug("Failed to delete %s\n", name_buf);
251+ ret = err;
252+ continue;
253+ }
254+ }
255+ }
256+ return ret;
257+}
258+
259+int bpf__load(struct bpf_object *obj)
260+{
261+ int err;
262+
263+ err = bpf_object__load(obj);
264+ if (err) {
265+ pr_debug("bpf: load objects failed\n");
266+ return err;
267+ }
268+ return 0;
269+}
270+
271+int bpf__foreach_tev(struct bpf_object *obj,
272+ bpf_prog_iter_callback_t func,
273+ void *arg)
274+{
275+ struct bpf_program *prog;
276+ int err;
277+
278+ bpf_object__for_each_program(prog, obj) {
279+ struct probe_trace_event *tev;
280+ struct perf_probe_event *pev;
281+ struct bpf_prog_priv *priv;
282+ int i, fd;
283+
284+ err = bpf_program__get_private(prog,
285+ (void **)&priv);
286+ if (err || !priv) {
287+ pr_debug("bpf: failed to get private field\n");
288+ return -EINVAL;
289+ }
290+
291+ pev = &priv->pev;
292+ for (i = 0; i < pev->ntevs; i++) {
293+ tev = &pev->tevs[i];
294+
295+ fd = bpf_program__fd(prog);
296+ if (fd < 0) {
297+ pr_debug("bpf: failed to get file descriptor\n");
298+ return fd;
299+ }
300+
301+ err = (*func)(tev, fd, arg);
302+ if (err) {
303+ pr_debug("bpf: call back failed, stop iterate\n");
304+ return err;
305+ }
306+ }
307+ }
308+ return 0;
309+}
310+
311+#define bpf__strerror_head(err, buf, size) \
312+ char sbuf[STRERR_BUFSIZE], *emsg;\
313+ if (!size)\
314+ return 0;\
315+ if (err < 0)\
316+ err = -err;\
317+ emsg = strerror_r(err, sbuf, sizeof(sbuf));\
318+ switch (err) {\
319+ default:\
320+ scnprintf(buf, size, "%s", emsg);\
321+ break;
322+
323+#define bpf__strerror_entry(val, fmt...)\
324+ case val: {\
325+ scnprintf(buf, size, fmt);\
326+ break;\
327+ }
328+
329+#define bpf__strerror_end(buf, size)\
330+ }\
331+ buf[size - 1] = '\0';
332+
333+int bpf__strerror_probe(struct bpf_object *obj __maybe_unused,
334+ int err, char *buf, size_t size)
335+{
336+ bpf__strerror_head(err, buf, size);
337+ bpf__strerror_entry(EEXIST, "Probe point exist. Try use 'perf probe -d \"*\"'");
338+ bpf__strerror_entry(EPERM, "You need to be root, and /proc/sys/kernel/kptr_restrict should be 0\n");
339+ bpf__strerror_entry(ENOENT, "You need to check probing points in BPF file\n");
340+ bpf__strerror_end(buf, size);
341+ return 0;
342+}
343+
344+int bpf__strerror_load(struct bpf_object *obj __maybe_unused,
345+ int err, char *buf, size_t size)
346+{
347+ bpf__strerror_head(err, buf, size);
348+ bpf__strerror_entry(EINVAL, "%s: Are you root and runing a CONFIG_BPF_SYSCALL kernel?",
349+ emsg)
350+ bpf__strerror_end(buf, size);
351+ return 0;
352+}
tools/perf/util/bpf-loader.h+85−0
@@ -0,0 +1,85 @@
1+/*
2+ * Copyright (C) 2015, Wang Nan <wangnan0@huawei.com>
3+ * Copyright (C) 2015, Huawei Inc.
4+ */
5+#ifndef __BPF_LOADER_H
6+#define __BPF_LOADER_H
7+
8+#include <linux/compiler.h>
9+#include <linux/err.h>
10+#include <string.h>
11+#include "probe-event.h"
12+#include "debug.h"
13+
14+struct bpf_object;
15+#define PERF_BPF_PROBE_GROUP "perf_bpf_probe"
16+
17+typedef int (*bpf_prog_iter_callback_t)(struct probe_trace_event *tev,
18+ int fd, void *arg);
19+
20+#ifdef HAVE_LIBBPF_SUPPORT
21+struct bpf_object *bpf__prepare_load(const char *filename, bool source);
22+
23+void bpf__clear(void);
24+
25+int bpf__probe(struct bpf_object *obj);
26+int bpf__unprobe(struct bpf_object *obj);
27+int bpf__strerror_probe(struct bpf_object *obj, int err,
28+ char *buf, size_t size);
29+
30+int bpf__load(struct bpf_object *obj);
31+int bpf__strerror_load(struct bpf_object *obj, int err,
32+ char *buf, size_t size);
33+int bpf__foreach_tev(struct bpf_object *obj,
34+ bpf_prog_iter_callback_t func, void *arg);
35+#else
36+static inline struct bpf_object *
37+bpf__prepare_load(const char *filename __maybe_unused,
38+ bool source __maybe_unused)
39+{
40+ pr_debug("ERROR: eBPF object loading is disabled during compiling.\n");
41+ return ERR_PTR(-ENOTSUP);
42+}
43+
44+static inline void bpf__clear(void) { }
45+
46+static inline int bpf__probe(struct bpf_object *obj __maybe_unused) { return 0;}
47+static inline int bpf__unprobe(struct bpf_object *obj __maybe_unused) { return 0;}
48+static inline int bpf__load(struct bpf_object *obj __maybe_unused) { return 0; }
49+
50+static inline int
51+bpf__foreach_tev(struct bpf_object *obj __maybe_unused,
52+ bpf_prog_iter_callback_t func __maybe_unused,
53+ void *arg __maybe_unused)
54+{
55+ return 0;
56+}
57+
58+static inline int
59+__bpf_strerror(char *buf, size_t size)
60+{
61+ if (!size)
62+ return 0;
63+ strncpy(buf,
64+ "ERROR: eBPF object loading is disabled during compiling.\n",
65+ size);
66+ buf[size - 1] = '\0';
67+ return 0;
68+}
69+
70+static inline int
71+bpf__strerror_probe(struct bpf_object *obj __maybe_unused,
72+ int err __maybe_unused,
73+ char *buf, size_t size)
74+{
75+ return __bpf_strerror(buf, size);
76+}
77+
78+static inline int bpf__strerror_load(struct bpf_object *obj __maybe_unused,
79+ int err __maybe_unused,
80+ char *buf, size_t size)
81+{
82+ return __bpf_strerror(buf, size);
83+}
84+#endif
85+#endif
tools/perf/util/callchain.c+39−3
@@ -51,10 +51,12 @@ static int parse_callchain_order(const char *value) · 50 unmodified lines
5151 {
5252 if (!strncmp(value, "caller", strlen(value))) {
5353 callchain_param.order = ORDER_CALLER;
54+ callchain_param.order_set = true;
5455 return 0;
5556 }
5657 if (!strncmp(value, "callee", strlen(value))) {
5758 callchain_param.order = ORDER_CALLEE;
59+ callchain_param.order_set = true;
5860 return 0;
5961 }
6062 return -1;
@@ -77,12 +79,14 @@ static int parse_callchain_sort_key(const char *value) · 16 unmodified lines
7779 return -1;
7880 }
7981
80−int
81−parse_callchain_report_opt(const char *arg)
82+static int
83+__parse_callchain_report_opt(const char *arg, bool allow_record_opt)
8284 {
8385 char *tok;
8486 char *endptr;
8587 bool minpcnt_set = false;
88+ bool record_opt_set = false;
89+ bool try_stack_size = false;
8690
8791 symbol_conf.use_callchain = true;
8892
@@ -100,6 +104,28 @@ parse_callchain_report_opt(const char *arg) · 11 unmodified lines
100104 !parse_callchain_order(tok) ||
101105 !parse_callchain_sort_key(tok)) {
102106 /* parsing ok - move on to the next */
107+ try_stack_size = false;
108+ goto next;
109+ } else if (allow_record_opt && !record_opt_set) {
110+ if (parse_callchain_record(tok, &callchain_param))
111+ goto try_numbers;
112+
113+ /* assume that number followed by 'dwarf' is stack size */
114+ if (callchain_param.record_mode == CALLCHAIN_DWARF)
115+ try_stack_size = true;
116+
117+ record_opt_set = true;
118+ goto next;
119+ }
120+
121+try_numbers:
122+ if (try_stack_size) {
123+ unsigned long size = 0;
124+
125+ if (get_stack_size(tok, &size) < 0)
126+ return -1;
127+ callchain_param.dump_size = size;
128+ try_stack_size = false;
103129 } else if (!minpcnt_set) {
104130 /* try to get the min percent */
105131 callchain_param.min_percent = strtod(tok, &endptr);
@@ -112,7 +138,7 @@ parse_callchain_report_opt(const char *arg) · 6 unmodified lines
112138 if (tok == endptr)
113139 return -1;
114140 }
115−
141+next:
116142 arg = NULL;
117143 }
118144
@@ -123,6 +149,16 @@ parse_callchain_report_opt(const char *arg) · 4 unmodified lines
123149 return 0;
124150 }
125151
152+int parse_callchain_report_opt(const char *arg)
153+{
154+ return __parse_callchain_report_opt(arg, false);
155+}
156+
157+int parse_callchain_top_opt(const char *arg)
158+{
159+ return __parse_callchain_report_opt(arg, true);
160+}
161+
126162 int perf_callchain_config(const char *var, const char *value)
127163 {
128164 char *endptr;
tools/perf/util/callchain.h+26−0
@@ -7,6 +7,30 @@ · 6 unmodified lines
77 #include "event.h"
88 #include "symbol.h"
99
10+#define HELP_PAD "\t\t\t\t"
11+
12+#define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace):\n\n"
13+
14+#ifdef HAVE_DWARF_UNWIND_SUPPORT
15+# define RECORD_MODE_HELP HELP_PAD "record_mode:\tcall graph recording mode (fp|dwarf|lbr)\n"
16+#else
17+# define RECORD_MODE_HELP HELP_PAD "record_mode:\tcall graph recording mode (fp|lbr)\n"
18+#endif
19+
20+#define RECORD_SIZE_HELP \
21+ HELP_PAD "record_size:\tif record_mode is 'dwarf', max size of stack recording (<bytes>)\n" \
22+ HELP_PAD "\t\tdefault: 8192 (bytes)\n"
23+
24+#define CALLCHAIN_RECORD_HELP CALLCHAIN_HELP RECORD_MODE_HELP RECORD_SIZE_HELP
25+
26+#define CALLCHAIN_REPORT_HELP \
27+ HELP_PAD "print_type:\tcall graph printing style (graph|flat|fractal|none)\n" \
28+ HELP_PAD "threshold:\tminimum call graph inclusion threshold (<percent>)\n" \
29+ HELP_PAD "print_limit:\tmaximum number of call graph entry (<number>)\n" \
30+ HELP_PAD "order:\t\tcall graph order (caller|callee)\n" \
31+ HELP_PAD "sort_key:\tcall graph sort key (function|address)\n" \
32+ HELP_PAD "branch:\t\tinclude last branch info to call graph (branch)\n"
33+
1034 enum perf_call_graph_mode {
1135 CALLCHAIN_NONE,
1236 CALLCHAIN_FP,
@@ -63,6 +87,7 @@ struct callchain_param { · 50 unmodified lines
6387 double min_percent;
6488 sort_chain_func_t sort;
6589 enum chain_order order;
90+ bool order_set;
6691 enum chain_key key;
6792 bool branch_callstack;
6893 };
@@ -180,6 +205,7 @@ extern const char record_callchain_help[]; · 111 unmodified lines
180205 extern int parse_callchain_record(const char *arg, struct callchain_param *param);
181206 int parse_callchain_record_opt(const char *arg, struct callchain_param *param);
182207 int parse_callchain_report_opt(const char *arg);
208+int parse_callchain_top_opt(const char *arg);
183209 int perf_callchain_config(const char *var, const char *value);
184210
185211 static inline void callchain_cursor_snapshot(struct callchain_cursor *dest,
tools/perf/util/cpumap.c+52−45
@@ -203,6 +203,23 @@ struct cpu_map *cpu_map__dummy_new(void) · 202 unmodified lines
203203 return cpus;
204204 }
205205
206+struct cpu_map *cpu_map__empty_new(int nr)
207+{
208+ struct cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int) * nr);
209+
210+ if (cpus != NULL) {
211+ int i;
212+
213+ cpus->nr = nr;
214+ for (i = 0; i < nr; i++)
215+ cpus->map[i] = -1;
216+
217+ atomic_set(&cpus->refcnt, 1);
218+ }
219+
220+ return cpus;
221+}
222+
206223 static void cpu_map__delete(struct cpu_map *map)
207224 {
208225 if (map) {
@@ -225,32 +242,32 @@ void cpu_map__put(struct cpu_map *map) · 16 unmodified lines
225242 cpu_map__delete(map);
226243 }
227244
228−int cpu_map__get_socket(struct cpu_map *map, int idx)
245+static int cpu__get_topology_int(int cpu, const char *name, int *value)
229246 {
230− FILE *fp;
231− const char *mnt;
232247 char path[PATH_MAX];
233− int cpu, ret;
234248
235− if (idx > map->nr)
236− return -1;
249+ snprintf(path, PATH_MAX,
250+ "devices/system/cpu/cpu%d/topology/%s", cpu, name);
237251
238− cpu = map->map[idx];
252+ return sysfs__read_int(path, value);
253+}
239254
240− mnt = sysfs__mountpoint();
241− if (!mnt)
242− return -1;
255+int cpu_map__get_socket_id(int cpu)
256+{
257+ int value, ret = cpu__get_topology_int(cpu, "physical_package_id", &value);
258+ return ret ?: value;
259+}
243260
244− snprintf(path, PATH_MAX,
245− "%s/devices/system/cpu/cpu%d/topology/physical_package_id",
246− mnt, cpu);
261+int cpu_map__get_socket(struct cpu_map *map, int idx, void *data __maybe_unused)
262+{
263+ int cpu;
247264
248− fp = fopen(path, "r");
249− if (!fp)
265+ if (idx > map->nr)
250266 return -1;
251− ret = fscanf(fp, "%d", &cpu);
252− fclose(fp);
253− return ret == 1 ? cpu : -1;
267+
268+ cpu = map->map[idx];
269+
270+ return cpu_map__get_socket_id(cpu);
254271 }
255272
256273 static int cmp_ids(const void *a, const void *b)
@@ -258,8 +275,9 @@ static int cmp_ids(const void *a, const void *b) · 1 unmodified line
258275 return *(int *)a - *(int *)b;
259276 }
260277
261−static int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res,
262− int (*f)(struct cpu_map *map, int cpu))
278+int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res,
279+ int (*f)(struct cpu_map *map, int cpu, void *data),
280+ void *data)
263281 {
264282 struct cpu_map *c;
265283 int nr = cpus->nr;
@@ -271,7 +289,7 @@ static int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res, · 5 unmodified lines
271289 return -1;
272290
273291 for (cpu = 0; cpu < nr; cpu++) {
274− s1 = f(cpus, cpu);
292+ s1 = f(cpus, cpu, data);
275293 for (s2 = 0; s2 < c->nr; s2++) {
276294 if (s1 == c->map[s2])
277295 break;
@@ -284,40 +302,29 @@ static int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res, · 6 unmodified lines
284302 /* ensure we process id in increasing order */
285303 qsort(c->map, c->nr, sizeof(int), cmp_ids);
286304
287− atomic_set(&cpus->refcnt, 1);
305+ atomic_set(&c->refcnt, 1);
288306 *res = c;
289307 return 0;
290308 }
291309
292−int cpu_map__get_core(struct cpu_map *map, int idx)
310+int cpu_map__get_core_id(int cpu)
293311 {
294− FILE *fp;
295− const char *mnt;
296− char path[PATH_MAX];
297− int cpu, ret, s;
312+ int value, ret = cpu__get_topology_int(cpu, "core_id", &value);
313+ return ret ?: value;
314+}
315+
316+int cpu_map__get_core(struct cpu_map *map, int idx, void *data)
317+{
318+ int cpu, s;
298319
299320 if (idx > map->nr)
300321 return -1;
301322
302323 cpu = map->map[idx];
303324
304− mnt = sysfs__mountpoint();
305− if (!mnt)
306− return -1;
307−
308− snprintf(path, PATH_MAX,
309− "%s/devices/system/cpu/cpu%d/topology/core_id",
310− mnt, cpu);
311−
312− fp = fopen(path, "r");
313− if (!fp)
314− return -1;
315− ret = fscanf(fp, "%d", &cpu);
316− fclose(fp);
317− if (ret != 1)
318− return -1;
325+ cpu = cpu_map__get_core_id(cpu);
319326
320− s = cpu_map__get_socket(map, idx);
327+ s = cpu_map__get_socket(map, idx, data);
321328 if (s == -1)
322329 return -1;
323330
@@ -332,12 +339,12 @@ int cpu_map__get_core(struct cpu_map *map, int idx) · 8 unmodified lines
332339
333340 int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp)
334341 {
335− return cpu_map__build_map(cpus, sockp, cpu_map__get_socket);
342+ return cpu_map__build_map(cpus, sockp, cpu_map__get_socket, NULL);
336343 }
337344
338345 int cpu_map__build_core_map(struct cpu_map *cpus, struct cpu_map **corep)
339346 {
340− return cpu_map__build_map(cpus, corep, cpu_map__get_core);
347+ return cpu_map__build_map(cpus, corep, cpu_map__get_core, NULL);
341348 }
342349
343350 /* setup simple routines to easily access node numbers given a cpu number */
tools/perf/util/cpumap.h+8−2
@@ -15,11 +15,14 @@ struct cpu_map { · 14 unmodified lines
1515 };
1616
1717 struct cpu_map *cpu_map__new(const char *cpu_list);
18+struct cpu_map *cpu_map__empty_new(int nr);
1819 struct cpu_map *cpu_map__dummy_new(void);
1920 struct cpu_map *cpu_map__read(FILE *file);
2021 size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp);
21−int cpu_map__get_socket(struct cpu_map *map, int idx);
22−int cpu_map__get_core(struct cpu_map *map, int idx);
22+int cpu_map__get_socket_id(int cpu);
23+int cpu_map__get_socket(struct cpu_map *map, int idx, void *data);
24+int cpu_map__get_core_id(int cpu);
25+int cpu_map__get_core(struct cpu_map *map, int idx, void *data);
2326 int cpu_map__build_socket_map(struct cpu_map *cpus, struct cpu_map **sockp);
2427 int cpu_map__build_core_map(struct cpu_map *cpus, struct cpu_map **corep);
2528
@@ -85,4 +88,7 @@ static inline int cpu__get_node(int cpu) · 59 unmodified lines
8588 return cpunode_map[cpu];
8689 }
8790
91+int cpu_map__build_map(struct cpu_map *cpus, struct cpu_map **res,
92+ int (*f)(struct cpu_map *map, int cpu, void *data),
93+ void *data);
8894 #endif /* __PERF_CPUMAP_H */
tools/perf/util/env.c+86−0
@@ -0,0 +1,86 @@
1+#include "cpumap.h"
2+#include "env.h"
3+#include "util.h"
4+
5+struct perf_env perf_env;
6+
7+void perf_env__exit(struct perf_env *env)
8+{
9+ zfree(&env->hostname);
10+ zfree(&env->os_release);
11+ zfree(&env->version);
12+ zfree(&env->arch);
13+ zfree(&env->cpu_desc);
14+ zfree(&env->cpuid);
15+ zfree(&env->cmdline);
16+ zfree(&env->cmdline_argv);
17+ zfree(&env->sibling_cores);
18+ zfree(&env->sibling_threads);
19+ zfree(&env->numa_nodes);
20+ zfree(&env->pmu_mappings);
21+ zfree(&env->cpu);
22+}
23+
24+int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[])
25+{
26+ int i;
27+
28+ /*
29+ * If env->cmdline_argv has already been set, do not override it. This allows
30+ * a command to set the cmdline, parse args and then call another
31+ * builtin function that implements a command -- e.g, cmd_kvm calling
32+ * cmd_record.
33+ */
34+ if (env->cmdline_argv != NULL)
35+ return 0;
36+
37+ /* do not include NULL termination */
38+ env->cmdline_argv = calloc(argc, sizeof(char *));
39+ if (env->cmdline_argv == NULL)
40+ goto out_enomem;
41+
42+ /*
43+ * Must copy argv contents because it gets moved around during option
44+ * parsing:
45+ */
46+ for (i = 0; i < argc ; i++) {
47+ env->cmdline_argv[i] = argv[i];
48+ if (env->cmdline_argv[i] == NULL)
49+ goto out_free;
50+ }
51+
52+ env->nr_cmdline = argc;
53+
54+ return 0;
55+out_free:
56+ zfree(&env->cmdline_argv);
57+out_enomem:
58+ return -ENOMEM;
59+}
60+
61+int perf_env__read_cpu_topology_map(struct perf_env *env)
62+{
63+ int cpu, nr_cpus;
64+
65+ if (env->cpu != NULL)
66+ return 0;
67+
68+ if (env->nr_cpus_avail == 0)
69+ env->nr_cpus_avail = sysconf(_SC_NPROCESSORS_CONF);
70+
71+ nr_cpus = env->nr_cpus_avail;
72+ if (nr_cpus == -1)
73+ return -EINVAL;
74+
75+ env->cpu = calloc(nr_cpus, sizeof(env->cpu[0]));
76+ if (env->cpu == NULL)
77+ return -ENOMEM;
78+
79+ for (cpu = 0; cpu < nr_cpus; ++cpu) {
80+ env->cpu[cpu].core_id = cpu_map__get_core_id(cpu);
81+ env->cpu[cpu].socket_id = cpu_map__get_socket_id(cpu);
82+ }
83+
84+ env->nr_cpus_avail = nr_cpus;
85+ return 0;
86+}
tools/perf/util/env.h+44−0
@@ -0,0 +1,44 @@
1+#ifndef __PERF_ENV_H
2+#define __PERF_ENV_H
3+
4+struct cpu_topology_map {
5+ int socket_id;
6+ int core_id;
7+};
8+
9+struct perf_env {
10+ char *hostname;
11+ char *os_release;
12+ char *version;
13+ char *arch;
14+ int nr_cpus_online;
15+ int nr_cpus_avail;
16+ char *cpu_desc;
17+ char *cpuid;
18+ unsigned long long total_mem;
19+ unsigned int msr_pmu_type;
20+
21+ int nr_cmdline;
22+ int nr_sibling_cores;
23+ int nr_sibling_threads;
24+ int nr_numa_nodes;
25+ int nr_pmu_mappings;
26+ int nr_groups;
27+ char *cmdline;
28+ const char **cmdline_argv;
29+ char *sibling_cores;
30+ char *sibling_threads;
31+ char *numa_nodes;
32+ char *pmu_mappings;
33+ struct cpu_topology_map *cpu;
34+};
35+
36+extern struct perf_env perf_env;
37+
38+void perf_env__exit(struct perf_env *env);
39+
40+int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[]);
41+
42+int perf_env__read_cpu_topology_map(struct perf_env *env);
43+
44+#endif /* __PERF_ENV_H */
tools/perf/util/event.c+15−7
@@ -67,7 +67,8 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, · 66 unmodified lines
6767 char filename[PATH_MAX];
6868 char bf[4096];
6969 int fd;
70− size_t size = 0, n;
70+ size_t size = 0;
71+ ssize_t n;
7172 char *nl, *name, *tgids, *ppids;
7273
7374 *tgid = -1;
@@ -167,7 +168,7 @@ static int perf_event__prepare_comm(union perf_event *event, pid_t pid, · 93 unmodified lines
167168 return 0;
168169 }
169170
170−static pid_t perf_event__synthesize_comm(struct perf_tool *tool,
171+pid_t perf_event__synthesize_comm(struct perf_tool *tool,
171172 union perf_event *event, pid_t pid,
172173 perf_event__handler_t process,
173174 struct machine *machine)
@@ -378,7 +379,7 @@ int perf_event__synthesize_modules(struct perf_tool *tool, · 204 unmodified lines
378379 for (pos = maps__first(maps); pos; pos = map__next(pos)) {
379380 size_t size;
380381
381− if (pos->dso->kernel)
382+ if (__map__is_kernel(pos))
382383 continue;
383384
384385 size = PERF_ALIGN(pos->dso->long_name_len + 1, sizeof(u64));
@@ -649,12 +650,12 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, · 264 unmodified lines
649650 size_t size;
650651 const char *mmap_name;
651652 char name_buff[PATH_MAX];
652− struct map *map;
653+ struct map *map = machine__kernel_map(machine);
653654 struct kmap *kmap;
654655 int err;
655656 union perf_event *event;
656657
657− if (machine->vmlinux_maps[0] == NULL)
658+ if (map == NULL)
658659 return -1;
659660
660661 /*
@@ -680,7 +681,6 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, · 19 unmodified lines
680681 event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL;
681682 }
682683
683− map = machine->vmlinux_maps[MAP__FUNCTION];
684684 kmap = map__kmap(map);
685685 size = snprintf(event->mmap.filename, sizeof(event->mmap.filename),
686686 "%s%s", mmap_name, kmap->ref_reloc_sym->name) + 1;
@@ -1008,7 +1008,7 @@ int perf_event__preprocess_sample(const union perf_event *event, · 321 unmodified lines
10081008 * it now.
10091009 */
10101010 if (cpumode == PERF_RECORD_MISC_KERNEL &&
1011− machine->vmlinux_maps[MAP__FUNCTION] == NULL)
1011+ machine__kernel_map(machine) == NULL)
10121012 machine__create_kernel_maps(machine);
10131013
10141014 thread__find_addr_map(thread, cpumode, MAP__FUNCTION, sample->ip, al);
@@ -1021,6 +1021,14 @@ int perf_event__preprocess_sample(const union perf_event *event, · 6 unmodified lines
10211021
10221022 al->sym = NULL;
10231023 al->cpu = sample->cpu;
1024+ al->socket = -1;
1025+
1026+ if (al->cpu >= 0) {
1027+ struct perf_env *env = machine->env;
1028+
1029+ if (env && env->cpu)
1030+ al->socket = env->cpu[al->cpu].socket_id;
1031+ }
10241032
10251033 if (al->map) {
10261034 struct dso *dso = al->map->dso;
tools/perf/util/event.h+6−0
@@ -257,6 +257,7 @@ struct events_stats { · 256 unmodified lines
257257 u64 total_non_filtered_period;
258258 u64 total_lost;
259259 u64 total_lost_samples;
260+ u64 total_aux_lost;
260261 u64 total_invalid_chains;
261262 u32 nr_events[PERF_RECORD_HEADER_MAX];
262263 u32 nr_non_filtered_samples;
@@ -478,6 +479,11 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, · 215 unmodified lines
478479 const struct perf_sample *sample,
479480 bool swapped);
480481
482+pid_t perf_event__synthesize_comm(struct perf_tool *tool,
483+ union perf_event *event, pid_t pid,
484+ perf_event__handler_t process,
485+ struct machine *machine);
486+
481487 int perf_event__synthesize_mmap_events(struct perf_tool *tool,
482488 union perf_event *event,
483489 pid_t pid, pid_t tgid,
tools/perf/util/evlist.c+43−4
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include <linux/bitops.h>
2626 #include <linux/hash.h>
2727 #include <linux/log2.h>
28+#include <linux/err.h>
2829
2930 static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx);
3031 static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx);
@@ -164,6 +165,13 @@ void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry) · 133 unmodified lines
164165 __perf_evlist__propagate_maps(evlist, entry);
165166 }
166167
168+void perf_evlist__remove(struct perf_evlist *evlist, struct perf_evsel *evsel)
169+{
170+ evsel->evlist = NULL;
171+ list_del_init(&evsel->node);
172+ evlist->nr_entries -= 1;
173+}
174+
167175 void perf_evlist__splice_list_tail(struct perf_evlist *evlist,
168176 struct list_head *list)
169177 {
@@ -197,6 +205,20 @@ void perf_evlist__set_leader(struct perf_evlist *evlist) · 27 unmodified lines
197205 }
198206 }
199207
208+void perf_event_attr__set_max_precise_ip(struct perf_event_attr *attr)
209+{
210+ attr->precise_ip = 3;
211+
212+ while (attr->precise_ip != 0) {
213+ int fd = sys_perf_event_open(attr, 0, -1, -1, 0);
214+ if (fd != -1) {
215+ close(fd);
216+ break;
217+ }
218+ --attr->precise_ip;
219+ }
220+}
221+
200222 int perf_evlist__add_default(struct perf_evlist *evlist)
201223 {
202224 struct perf_event_attr attr = {
@@ -207,13 +229,15 @@ int perf_evlist__add_default(struct perf_evlist *evlist) · 4 unmodified lines
207229
208230 event_attr_init(&attr);
209231
232+ perf_event_attr__set_max_precise_ip(&attr);
233+
210234 evsel = perf_evsel__new(&attr);
211235 if (evsel == NULL)
212236 goto error;
213237
214− /* use strdup() because free(evsel) assumes name is allocated */
215− evsel->name = strdup("cycles");
216− if (!evsel->name)
238+ /* use asprintf() because free(evsel) assumes name is allocated */
239+ if (asprintf(&evsel->name, "cycles%.*s",
240+ attr.precise_ip ? attr.precise_ip + 1 : 0, ":ppp") < 0)
217241 goto error_free;
218242
219243 perf_evlist__add(evlist, evsel);
@@ -293,7 +317,7 @@ int perf_evlist__add_newtp(struct perf_evlist *evlist, · 73 unmodified lines
293317 {
294318 struct perf_evsel *evsel = perf_evsel__newtp(sys, name);
295319
296− if (evsel == NULL)
320+ if (IS_ERR(evsel))
297321 return -1;
298322
299323 evsel->handler = handler;
@@ -616,6 +640,21 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id) · 316 unmodified lines
616640 return NULL;
617641 }
618642
643+struct perf_evsel *perf_evlist__id2evsel_strict(struct perf_evlist *evlist,
644+ u64 id)
645+{
646+ struct perf_sample_id *sid;
647+
648+ if (!id)
649+ return NULL;
650+
651+ sid = perf_evlist__id2sid(evlist, id);
652+ if (sid)
653+ return sid->evsel;
654+
655+ return NULL;
656+}
657+
619658 static int perf_evlist__event2id(struct perf_evlist *evlist,
620659 union perf_event *event, u64 *id)
621660 {
tools/perf/util/evlist.h+5−0
@@ -73,6 +73,7 @@ void perf_evlist__exit(struct perf_evlist *evlist); · 72 unmodified lines
7373 void perf_evlist__delete(struct perf_evlist *evlist);
7474
7575 void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry);
76+void perf_evlist__remove(struct perf_evlist *evlist, struct perf_evsel *evsel);
7677 int perf_evlist__add_default(struct perf_evlist *evlist);
7778 int __perf_evlist__add_default_attrs(struct perf_evlist *evlist,
7879 struct perf_event_attr *attrs, size_t nr_attrs);
@@ -104,6 +105,8 @@ int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mas · 25 unmodified lines
104105 int perf_evlist__poll(struct perf_evlist *evlist, int timeout);
105106
106107 struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
108+struct perf_evsel *perf_evlist__id2evsel_strict(struct perf_evlist *evlist,
109+ u64 id);
107110
108111 struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id);
109112
@@ -287,4 +290,6 @@ void perf_evlist__to_front(struct perf_evlist *evlist, · 177 unmodified lines
287290
288291 void perf_evlist__set_tracking_event(struct perf_evlist *evlist,
289292 struct perf_evsel *tracking_evsel);
293+
294+void perf_event_attr__set_max_precise_ip(struct perf_event_attr *attr);
290295 #endif /* __PERF_EVLIST_H */
tools/perf/util/evsel.c+45−5
@@ -9,10 +9,11 @@ · 8 unmodified lines
99
1010 #include <byteswap.h>
1111 #include <linux/bitops.h>
12−#include <api/fs/debugfs.h>
12+#include <api/fs/tracing_path.h>
1313 #include <traceevent/event-parse.h>
1414 #include <linux/hw_breakpoint.h>
1515 #include <linux/perf_event.h>
16+#include <linux/err.h>
1617 #include <sys/resource.h>
1718 #include "asm/bug.h"
1819 #include "callchain.h"
@@ -207,6 +208,7 @@ void perf_evsel__init(struct perf_evsel *evsel, · 188 unmodified lines
207208 evsel->unit = "";
208209 evsel->scale = 1.0;
209210 evsel->evlist = NULL;
211+ evsel->bpf_fd = -1;
210212 INIT_LIST_HEAD(&evsel->node);
211213 INIT_LIST_HEAD(&evsel->config_terms);
212214 perf_evsel__object.init(evsel);
@@ -225,11 +227,17 @@ struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx) · 12 unmodified lines
225227 return evsel;
226228 }
227229
230+/*
231+ * Returns pointer with encoded error via <linux/err.h> interface.
232+ */
228233 struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int idx)
229234 {
230235 struct perf_evsel *evsel = zalloc(perf_evsel__object.size);
236+ int err = -ENOMEM;
231237
232− if (evsel != NULL) {
238+ if (evsel == NULL) {
239+ goto out_err;
240+ } else {
233241 struct perf_event_attr attr = {
234242 .type = PERF_TYPE_TRACEPOINT,
235243 .sample_type = (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME |
@@ -240,8 +248,10 @@ struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int · 4 unmodified lines
240248 goto out_free;
241249
242250 evsel->tp_format = trace_event__tp_format(sys, name);
243− if (evsel->tp_format == NULL)
251+ if (IS_ERR(evsel->tp_format)) {
252+ err = PTR_ERR(evsel->tp_format);
244253 goto out_free;
254+ }
245255
246256 event_attr_init(&attr);
247257 attr.config = evsel->tp_format->id;
@@ -254,7 +264,8 @@ struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int · 6 unmodified lines
254264 out_free:
255265 zfree(&evsel->name);
256266 free(evsel);
257− return NULL;
267+out_err:
268+ return ERR_PTR(err);
258269 }
259270
260271 const char *perf_evsel__hw_names[PERF_COUNT_HW_MAX] = {
@@ -642,6 +653,15 @@ static void apply_config_terms(struct perf_evsel *evsel, · 381 unmodified lines
642653 case PERF_EVSEL__CONFIG_TERM_STACK_USER:
643654 dump_size = term->val.stack_user;
644655 break;
656+ case PERF_EVSEL__CONFIG_TERM_INHERIT:
657+ /*
658+ * attr->inherit should has already been set by
659+ * perf_evsel__config. If user explicitly set
660+ * inherit using config terms, override global
661+ * opt->no_inherit setting.
662+ */
663+ attr->inherit = term->val.inherit ? 1 : 0;
664+ break;
645665 default:
646666 break;
647667 }
@@ -872,6 +892,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) · 224 unmodified lines
872892 attr->clockid = opts->clockid;
873893 }
874894
895+ if (evsel->precise_max)
896+ perf_event_attr__set_max_precise_ip(attr);
897+
875898 /*
876899 * Apply event specific term settings,
877900 * it overloads any global configuration.
@@ -1168,7 +1191,7 @@ static void __p_sample_type(char *buf, size_t size, u64 value) · 290 unmodified lines
11681191 bit_name(READ), bit_name(CALLCHAIN), bit_name(ID), bit_name(CPU),
11691192 bit_name(PERIOD), bit_name(STREAM_ID), bit_name(RAW),
11701193 bit_name(BRANCH_STACK), bit_name(REGS_USER), bit_name(STACK_USER),
1171− bit_name(IDENTIFIER), bit_name(REGS_INTR),
1194+ bit_name(IDENTIFIER), bit_name(REGS_INTR), bit_name(DATA_SRC),
11721195 { .name = NULL, }
11731196 };
11741197 #undef bit_name
@@ -1249,6 +1272,7 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr, · 74 unmodified lines
12491272 PRINT_ATTRf(bp_type, p_unsigned);
12501273 PRINT_ATTRn("{ bp_addr, config1 }", bp_addr, p_hex);
12511274 PRINT_ATTRn("{ bp_len, config2 }", bp_len, p_hex);
1275+ PRINT_ATTRf(branch_sample_type, p_unsigned);
12521276 PRINT_ATTRf(sample_regs_user, p_hex);
12531277 PRINT_ATTRf(sample_stack_user, p_unsigned);
12541278 PRINT_ATTRf(clockid, p_signed);
@@ -1333,6 +1357,22 @@ retry_open: · 78 unmodified lines
13331357 err);
13341358 goto try_fallback;
13351359 }
1360+
1361+ if (evsel->bpf_fd >= 0) {
1362+ int evt_fd = FD(evsel, cpu, thread);
1363+ int bpf_fd = evsel->bpf_fd;
1364+
1365+ err = ioctl(evt_fd,
1366+ PERF_EVENT_IOC_SET_BPF,
1367+ bpf_fd);
1368+ if (err && errno != EEXIST) {
1369+ pr_err("failed to attach bpf fd %d: %s\n",
1370+ bpf_fd, strerror(errno));
1371+ err = -EINVAL;
1372+ goto out_close;
1373+ }
1374+ }
1375+
13361376 set_rlimit = NO_CHANGE;
13371377
13381378 /*
tools/perf/util/evsel.h+8−2
@@ -43,6 +43,7 @@ enum { · 42 unmodified lines
4343 PERF_EVSEL__CONFIG_TERM_TIME,
4444 PERF_EVSEL__CONFIG_TERM_CALLGRAPH,
4545 PERF_EVSEL__CONFIG_TERM_STACK_USER,
46+ PERF_EVSEL__CONFIG_TERM_INHERIT,
4647 PERF_EVSEL__CONFIG_TERM_MAX,
4748 };
4849
@@ -55,6 +56,7 @@ struct perf_evsel_config_term { · 6 unmodified lines
5556 bool time;
5657 char *callgraph;
5758 u64 stack_user;
59+ bool inherit;
5860 } val;
5961 };
6062
@@ -90,9 +92,9 @@ struct perf_evsel { · 29 unmodified lines
9092 double scale;
9193 const char *unit;
9294 struct event_format *tp_format;
95+ off_t id_offset;
9396 union {
9497 void *priv;
95− off_t id_offset;
9698 u64 db_id;
9799 };
98100 struct cgroup_sel *cgrp;
@@ -111,6 +113,7 @@ struct perf_evsel { · 12 unmodified lines
111113 bool system_wide;
112114 bool tracking;
113115 bool per_pkg;
116+ bool precise_max;
114117 /* parse modifier helper */
115118 int exclude_GH;
116119 int nr_members;
@@ -120,6 +123,7 @@ struct perf_evsel { · 3 unmodified lines
120123 char *group_name;
121124 bool cmdline_group_boundary;
122125 struct list_head config_terms;
126+ int bpf_fd;
123127 };
124128
125129 union u64_swap {
@@ -130,7 +134,6 @@ union u64_swap { · 4 unmodified lines
130134 struct cpu_map;
131135 struct target;
132136 struct thread_map;
133−struct perf_evlist;
134137 struct record_opts;
135138
136139 static inline struct cpu_map *perf_evsel__cpus(struct perf_evsel *evsel)
@@ -162,6 +165,9 @@ static inline struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr) · 25 unmodified lines
162165
163166 struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int idx);
164167
168+/*
169+ * Returns pointer with encoded error via <linux/err.h> interface.
170+ */
165171 static inline struct perf_evsel *perf_evsel__newtp(const char *sys, const char *name)
166172 {
167173 return perf_evsel__newtp_idx(sys, name, 0);
tools/perf/util/header.c+93−43
@@ -24,9 +24,6 @@ · 23 unmodified lines
2424 #include "build-id.h"
2525 #include "data.h"
2626
27−static u32 header_argc;
28−static const char **header_argv;
29−
3027 /*
3128 * magic2 = "PERFILE2"
3229 * must be a numerical value to let the endianness
@@ -88,6 +85,9 @@ int write_padded(int fd, const void *bf, size_t count, size_t count_aligned) · 55 unmodified lines
8885 return err;
8986 }
9087
88+#define string_size(str) \
89+ (PERF_ALIGN((strlen(str) + 1), NAME_ALIGN) + sizeof(u32))
90+
9191 static int do_write_string(int fd, const char *str)
9292 {
9393 u32 len, olen;
@@ -135,37 +135,6 @@ static char *do_read_string(int fd, struct perf_header *ph) · 41 unmodified lines
135135 return NULL;
136136 }
137137
138−int
139−perf_header__set_cmdline(int argc, const char **argv)
140−{
141− int i;
142−
143− /*
144− * If header_argv has already been set, do not override it.
145− * This allows a command to set the cmdline, parse args and
146− * then call another builtin function that implements a
147− * command -- e.g, cmd_kvm calling cmd_record.
148− */
149− if (header_argv)
150− return 0;
151−
152− header_argc = (u32)argc;
153−
154− /* do not include NULL termination */
155− header_argv = calloc(argc, sizeof(char *));
156− if (!header_argv)
157− return -ENOMEM;
158−
159− /*
160− * must copy argv contents because it gets moved
161− * around during option parsing
162− */
163− for (i = 0; i < argc ; i++)
164− header_argv[i] = argv[i];
165−
166− return 0;
167−}
168−
169138 static int write_tracing_data(int fd, struct perf_header *h __maybe_unused,
170139 struct perf_evlist *evlist)
171140 {
@@ -402,8 +371,8 @@ static int write_cmdline(int fd, struct perf_header *h __maybe_unused, · 230 unmodified lines
402371 {
403372 char buf[MAXPATHLEN];
404373 char proc[32];
405− u32 i, n;
406− int ret;
374+ u32 n;
375+ int i, ret;
407376
408377 /*
409378 * actual atual path to perf binary
@@ -417,7 +386,7 @@ static int write_cmdline(int fd, struct perf_header *h __maybe_unused, · 7 unmodified lines
417386 buf[ret] = '\0';
418387
419388 /* account for binary path */
420− n = header_argc + 1;
389+ n = perf_env.nr_cmdline + 1;
421390
422391 ret = do_write(fd, &n, sizeof(n));
423392 if (ret < 0)
@@ -427,8 +396,8 @@ static int write_cmdline(int fd, struct perf_header *h __maybe_unused, · 3 unmodified lines
427396 if (ret < 0)
428397 return ret;
429398
430− for (i = 0 ; i < header_argc; i++) {
431− ret = do_write_string(fd, header_argv[i]);
399+ for (i = 0 ; i < perf_env.nr_cmdline; i++) {
400+ ret = do_write_string(fd, perf_env.cmdline_argv[i]);
432401 if (ret < 0)
433402 return ret;
434403 }
@@ -441,6 +410,7 @@ static int write_cmdline(int fd, struct perf_header *h __maybe_unused, · 6 unmodified lines
441410 "/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list"
442411
443412 struct cpu_topo {
413+ u32 cpu_nr;
444414 u32 core_sib;
445415 u32 thread_sib;
446416 char **core_siblings;
@@ -551,7 +521,7 @@ static struct cpu_topo *build_cpu_topology(void) · 104 unmodified lines
551521 return NULL;
552522
553523 tp = addr;
554−
524+ tp->cpu_nr = nr;
555525 addr += sizeof(*tp);
556526 tp->core_siblings = addr;
557527 addr += sz;
@@ -574,7 +544,7 @@ static int write_cpu_topology(int fd, struct perf_header *h __maybe_unused, · 16 unmodified lines
574544 {
575545 struct cpu_topo *tp;
576546 u32 i;
577− int ret;
547+ int ret, j;
578548
579549 tp = build_cpu_topology();
580550 if (!tp)
@@ -598,6 +568,21 @@ static int write_cpu_topology(int fd, struct perf_header *h __maybe_unused, · 17 unmodified lines
598568 if (ret < 0)
599569 break;
600570 }
571+
572+ ret = perf_env__read_cpu_topology_map(&perf_env);
573+ if (ret < 0)
574+ goto done;
575+
576+ for (j = 0; j < perf_env.nr_cpus_avail; j++) {
577+ ret = do_write(fd, &perf_env.cpu[j].core_id,
578+ sizeof(perf_env.cpu[j].core_id));
579+ if (ret < 0)
580+ return ret;
581+ ret = do_write(fd, &perf_env.cpu[j].socket_id,
582+ sizeof(perf_env.cpu[j].socket_id));
583+ if (ret < 0)
584+ return ret;
585+ }
601586 done:
602587 free_cpu_topo(tp);
603588 return ret;
@@ -938,6 +923,7 @@ static void print_cpu_topology(struct perf_header *ph, int fd __maybe_unused, · 334 unmodified lines
938923 {
939924 int nr, i;
940925 char *str;
926+ int cpu_nr = ph->env.nr_cpus_online;
941927
942928 nr = ph->env.nr_sibling_cores;
943929 str = ph->env.sibling_cores;
@@ -954,6 +940,13 @@ static void print_cpu_topology(struct perf_header *ph, int fd __maybe_unused, · 10 unmodified lines
954940 fprintf(fp, "# sibling threads : %s\n", str);
955941 str += strlen(str) + 1;
956942 }
943+
944+ if (ph->env.cpu != NULL) {
945+ for (i = 0; i < cpu_nr; i++)
946+ fprintf(fp, "# CPU %d: Core ID %d, Socket ID %d\n", i,
947+ ph->env.cpu[i].core_id, ph->env.cpu[i].socket_id);
948+ } else
949+ fprintf(fp, "# Core ID and Socket ID information is not available\n");
957950 }
958951
959952 static void free_event_desc(struct perf_evsel *events)
@@ -1582,7 +1575,7 @@ error: · 622 unmodified lines
15821575 return -1;
15831576 }
15841577
1585−static int process_cpu_topology(struct perf_file_section *section __maybe_unused,
1578+static int process_cpu_topology(struct perf_file_section *section,
15861579 struct perf_header *ph, int fd,
15871580 void *data __maybe_unused)
15881581 {
@@ -1590,15 +1583,22 @@ static int process_cpu_topology(struct perf_file_section *section __maybe_unused · 1 unmodified line
15901583 u32 nr, i;
15911584 char *str;
15921585 struct strbuf sb;
1586+ int cpu_nr = ph->env.nr_cpus_online;
1587+ u64 size = 0;
1588+
1589+ ph->env.cpu = calloc(cpu_nr, sizeof(*ph->env.cpu));
1590+ if (!ph->env.cpu)
1591+ return -1;
15931592
15941593 ret = readn(fd, &nr, sizeof(nr));
15951594 if (ret != sizeof(nr))
1596− return -1;
1595+ goto free_cpu;
15971596
15981597 if (ph->needs_swap)
15991598 nr = bswap_32(nr);
16001599
16011600 ph->env.nr_sibling_cores = nr;
1601+ size += sizeof(u32);
16021602 strbuf_init(&sb, 128);
16031603
16041604 for (i = 0; i < nr; i++) {
@@ -1608,6 +1608,7 @@ static int process_cpu_topology(struct perf_file_section *section __maybe_unused · 3 unmodified lines
16081608
16091609 /* include a NULL character at the end */
16101610 strbuf_add(&sb, str, strlen(str) + 1);
1611+ size += string_size(str);
16111612 free(str);
16121613 }
16131614 ph->env.sibling_cores = strbuf_detach(&sb, NULL);
@@ -1620,6 +1621,7 @@ static int process_cpu_topology(struct perf_file_section *section __maybe_unused · 6 unmodified lines
16201621 nr = bswap_32(nr);
16211622
16221623 ph->env.nr_sibling_threads = nr;
1624+ size += sizeof(u32);
16231625
16241626 for (i = 0; i < nr; i++) {
16251627 str = do_read_string(fd, ph);
@@ -1628,13 +1630,57 @@ static int process_cpu_topology(struct perf_file_section *section __maybe_unused · 2 unmodified lines
16281630
16291631 /* include a NULL character at the end */
16301632 strbuf_add(&sb, str, strlen(str) + 1);
1633+ size += string_size(str);
16311634 free(str);
16321635 }
16331636 ph->env.sibling_threads = strbuf_detach(&sb, NULL);
1637+
1638+ /*
1639+ * The header may be from old perf,
1640+ * which doesn't include core id and socket id information.
1641+ */
1642+ if (section->size <= size) {
1643+ zfree(&ph->env.cpu);
1644+ return 0;
1645+ }
1646+
1647+ for (i = 0; i < (u32)cpu_nr; i++) {
1648+ ret = readn(fd, &nr, sizeof(nr));
1649+ if (ret != sizeof(nr))
1650+ goto free_cpu;
1651+
1652+ if (ph->needs_swap)
1653+ nr = bswap_32(nr);
1654+
1655+ if (nr > (u32)cpu_nr) {
1656+ pr_debug("core_id number is too big."
1657+ "You may need to upgrade the perf tool.\n");
1658+ goto free_cpu;
1659+ }
1660+ ph->env.cpu[i].core_id = nr;
1661+
1662+ ret = readn(fd, &nr, sizeof(nr));
1663+ if (ret != sizeof(nr))
1664+ goto free_cpu;
1665+
1666+ if (ph->needs_swap)
1667+ nr = bswap_32(nr);
1668+
1669+ if (nr > (u32)cpu_nr) {
1670+ pr_debug("socket_id number is too big."
1671+ "You may need to upgrade the perf tool.\n");
1672+ goto free_cpu;
1673+ }
1674+
1675+ ph->env.cpu[i].socket_id = nr;
1676+ }
1677+
16341678 return 0;
16351679
16361680 error:
16371681 strbuf_release(&sb);
1682+free_cpu:
1683+ zfree(&ph->env.cpu);
16381684 return -1;
16391685 }
16401686
@@ -1737,6 +1783,9 @@ static int process_pmu_mappings(struct perf_file_section *section __maybe_unused · 96 unmodified lines
17371783 /* include a NULL character at the end */
17381784 strbuf_add(&sb, "", 1);
17391785
1786+ if (!strcmp(name, "msr"))
1787+ ph->env.msr_pmu_type = type;
1788+
17401789 free(name);
17411790 pmu_num--;
17421791 }
@@ -2515,6 +2564,7 @@ int perf_session__read_header(struct perf_session *session) · 772 unmodified lines
25152564 return -ENOMEM;
25162565
25172566 session->evlist->env = &header->env;
2567+ session->machines.host.env = &header->env;
25182568 if (perf_data_file__is_pipe(file))
25192569 return perf_header__read_pipe(session);
25202570
tools/perf/util/header.h+1−26
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 #include <linux/bitmap.h>
88 #include <linux/types.h>
99 #include "event.h"
10−
10+#include "env.h"
1111
1212 enum {
1313 HEADER_RESERVED = 0, /* always cleared */
@@ -66,31 +66,6 @@ struct perf_header; · 52 unmodified lines
6666 int perf_file_header__read(struct perf_file_header *header,
6767 struct perf_header *ph, int fd);
6868
69−struct perf_env {
70− char *hostname;
71− char *os_release;
72− char *version;
73− char *arch;
74− int nr_cpus_online;
75− int nr_cpus_avail;
76− char *cpu_desc;
77− char *cpuid;
78− unsigned long long total_mem;
79−
80− int nr_cmdline;
81− int nr_sibling_cores;
82− int nr_sibling_threads;
83− int nr_numa_nodes;
84− int nr_pmu_mappings;
85− int nr_groups;
86− char *cmdline;
87− const char **cmdline_argv;
88− char *sibling_cores;
89− char *sibling_threads;
90− char *numa_nodes;
91− char *pmu_mappings;
92−};
93−
9469 struct perf_header {
9570 enum perf_header_version version;
9671 bool needs_swap;
tools/perf/util/hist.c+56−3
@@ -15,6 +15,8 @@ static bool hists__filter_entry_by_thread(struct hists *hists, · 14 unmodified lines
1515 struct hist_entry *he);
1616 static bool hists__filter_entry_by_symbol(struct hists *hists,
1717 struct hist_entry *he);
18+static bool hists__filter_entry_by_socket(struct hists *hists,
19+ struct hist_entry *he);
1820
1921 u16 hists__col_len(struct hists *hists, enum hist_column col)
2022 {
@@ -130,6 +132,18 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) · 109 unmodified lines
130132 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
131133 symlen);
132134 }
135+
136+ if (h->mem_info->iaddr.sym) {
137+ symlen = (int)h->mem_info->iaddr.sym->namelen + 4
138+ + unresolved_col_width + 2;
139+ hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL,
140+ symlen);
141+ } else {
142+ symlen = unresolved_col_width + 4 + 2;
143+ hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL,
144+ symlen);
145+ }
146+
133147 if (h->mem_info->daddr.map) {
134148 symlen = dso__name_len(h->mem_info->daddr.map->dso);
135149 hists__new_col_len(hists, HISTC_MEM_DADDR_DSO,
@@ -141,9 +155,12 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) · 5 unmodified lines
141155 } else {
142156 symlen = unresolved_col_width + 4 + 2;
143157 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, symlen);
158+ hists__new_col_len(hists, HISTC_MEM_IADDR_SYMBOL, symlen);
144159 hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
145160 }
146161
162+ hists__new_col_len(hists, HISTC_CPU, 3);
163+ hists__new_col_len(hists, HISTC_SOCKET, 6);
147164 hists__new_col_len(hists, HISTC_MEM_LOCKED, 6);
148165 hists__new_col_len(hists, HISTC_MEM_TLB, 22);
149166 hists__new_col_len(hists, HISTC_MEM_SNOOP, 12);
@@ -452,6 +469,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists, · 302 unmodified lines
452469 .map = al->map,
453470 .sym = al->sym,
454471 },
472+ .socket = al->socket,
455473 .cpu = al->cpu,
456474 .cpumode = al->cpumode,
457475 .ip = al->addr,
@@ -690,7 +708,7 @@ iter_finish_normal_entry(struct hist_entry_iter *iter, · 232 unmodified lines
690708 }
691709
692710 static int
693−iter_prepare_cumulative_entry(struct hist_entry_iter *iter __maybe_unused,
711+iter_prepare_cumulative_entry(struct hist_entry_iter *iter,
694712 struct addr_location *al __maybe_unused)
695713 {
696714 struct hist_entry **he_cache;
@@ -702,7 +720,7 @@ iter_prepare_cumulative_entry(struct hist_entry_iter *iter __maybe_unused, · 5 unmodified lines
702720 * cumulated only one time to prevent entries more than 100%
703721 * overhead.
704722 */
705− he_cache = malloc(sizeof(*he_cache) * (PERF_MAX_STACK_DEPTH + 1));
723+ he_cache = malloc(sizeof(*he_cache) * (iter->max_stack + 1));
706724 if (he_cache == NULL)
707725 return -ENOMEM;
708726
@@ -863,6 +881,8 @@ int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al, · 154 unmodified lines
863881 if (err)
864882 return err;
865883
884+ iter->max_stack = max_stack_depth;
885+
866886 err = iter->ops->prepare_entry(iter, al);
867887 if (err)
868888 goto out;
@@ -1024,6 +1044,7 @@ static void hists__apply_filters(struct hists *hists, struct hist_entry *he) · 155 unmodified lines
10241044 hists__filter_entry_by_dso(hists, he);
10251045 hists__filter_entry_by_thread(hists, he);
10261046 hists__filter_entry_by_symbol(hists, he);
1047+ hists__filter_entry_by_socket(hists, he);
10271048 }
10281049
10291050 void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
@@ -1143,7 +1164,7 @@ void hists__output_resort(struct hists *hists, struct ui_progress *prog) · 113 unmodified lines
11431164 struct perf_evsel *evsel = hists_to_evsel(hists);
11441165 bool use_callchain;
11451166
1146− if (evsel && !symbol_conf.show_ref_callgraph)
1167+ if (evsel && symbol_conf.use_callchain && !symbol_conf.show_ref_callgraph)
11471168 use_callchain = evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN;
11481169 else
11491170 use_callchain = symbol_conf.use_callchain;
@@ -1292,6 +1313,37 @@ void hists__filter_by_symbol(struct hists *hists) · 142 unmodified lines
12921313 }
12931314 }
12941315
1316+static bool hists__filter_entry_by_socket(struct hists *hists,
1317+ struct hist_entry *he)
1318+{
1319+ if ((hists->socket_filter > -1) &&
1320+ (he->socket != hists->socket_filter)) {
1321+ he->filtered |= (1 << HIST_FILTER__SOCKET);
1322+ return true;
1323+ }
1324+
1325+ return false;
1326+}
1327+
1328+void hists__filter_by_socket(struct hists *hists)
1329+{
1330+ struct rb_node *nd;
1331+
1332+ hists->stats.nr_non_filtered_samples = 0;
1333+
1334+ hists__reset_filter_stats(hists);
1335+ hists__reset_col_len(hists);
1336+
1337+ for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
1338+ struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1339+
1340+ if (hists__filter_entry_by_socket(hists, h))
1341+ continue;
1342+
1343+ hists__remove_entry_filter(hists, h, HIST_FILTER__SOCKET);
1344+ }
1345+}
1346+
12951347 void events_stats__inc(struct events_stats *stats, u32 type)
12961348 {
12971349 ++stats->nr_events[0];
@@ -1517,6 +1569,7 @@ static int hists_evsel__init(struct perf_evsel *evsel) · 219 unmodified lines
15171569 hists->entries_collapsed = RB_ROOT;
15181570 hists->entries = RB_ROOT;
15191571 pthread_mutex_init(&hists->lock, NULL);
1572+ hists->socket_filter = -1;
15201573 return 0;
15211574 }
15221575
tools/perf/util/hist.h+7−1
@@ -20,6 +20,7 @@ enum hist_filter { · 19 unmodified lines
2020 HIST_FILTER__SYMBOL,
2121 HIST_FILTER__GUEST,
2222 HIST_FILTER__HOST,
23+ HIST_FILTER__SOCKET,
2324 };
2425
2526 enum hist_column {
@@ -29,6 +30,7 @@ enum hist_column { · 3 unmodified lines
2930 HISTC_COMM,
3031 HISTC_PARENT,
3132 HISTC_CPU,
33+ HISTC_SOCKET,
3234 HISTC_SRCLINE,
3335 HISTC_SRCFILE,
3436 HISTC_MISPREDICT,
@@ -47,6 +49,7 @@ enum hist_column { · 12 unmodified lines
4749 HISTC_MEM_LVL,
4850 HISTC_MEM_SNOOP,
4951 HISTC_MEM_DCACHELINE,
52+ HISTC_MEM_IADDR_SYMBOL,
5053 HISTC_TRANSACTION,
5154 HISTC_CYCLES,
5255 HISTC_NR_COLS, /* Last entry */
@@ -70,6 +73,7 @@ struct hists { · 17 unmodified lines
7073 struct events_stats stats;
7174 u64 event_stream;
7275 u16 col_len[HISTC_NR_COLS];
76+ int socket_filter;
7377 };
7478
7579 struct hist_entry_iter;
@@ -87,6 +91,7 @@ struct hist_entry_iter { · 11 unmodified lines
8791 int curr;
8892
8993 bool hide_unresolved;
94+ int max_stack;
9095
9196 struct perf_evsel *evsel;
9297 struct perf_sample *sample;
@@ -144,11 +149,12 @@ size_t perf_evlist__fprintf_nr_events(struct perf_evlist *evlist, FILE *fp); · 51 unmodified lines
144149 void hists__filter_by_dso(struct hists *hists);
145150 void hists__filter_by_thread(struct hists *hists);
146151 void hists__filter_by_symbol(struct hists *hists);
152+void hists__filter_by_socket(struct hists *hists);
147153
148154 static inline bool hists__has_filter(struct hists *hists)
149155 {
150156 return hists->thread_filter || hists->dso_filter ||
151− hists->symbol_filter_str;
157+ hists->symbol_filter_str || (hists->socket_filter > -1);
152158 }
153159
154160 u16 hists__col_len(struct hists *hists, enum hist_column col);
tools/perf/util/include/dwarf-regs.h+8−0
@@ -5,4 +5,12 @@ · 4 unmodified lines
55 const char *get_arch_regstr(unsigned int n);
66 #endif
77
8+#ifdef HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET
9+/*
10+ * Arch should support fetching the offset of a register in pt_regs
11+ * by its name. See kernel's regs_query_register_offset in
12+ * arch/xxx/kernel/ptrace.c.
13+ */
14+int regs_query_register_offset(const char *name);
15+#endif
816 #endif
tools/perf/util/intel-pt-decoder/Build+12−1
@@ -7,6 +7,17 @@ $(OUTPUT)util/intel-pt-decoder/inat-tables.c: $(inat_tables_script) $(inat_table · 6 unmodified lines
77 $(call rule_mkdir)
88 @$(call echo-cmd,gen)$(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@ || rm -f $@
99
10−$(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/inat.c $(OUTPUT)util/intel-pt-decoder/inat-tables.c
10+$(OUTPUT)util/intel-pt-decoder/intel-pt-insn-decoder.o: util/intel-pt-decoder/intel-pt-insn-decoder.c util/intel-pt-decoder/inat.c $(OUTPUT)util/intel-pt-decoder/inat-tables.c
11+ @(test -d ../../kernel -a -d ../../tools -a -d ../perf && (( \
12+ diff -B -I'^#include' util/intel-pt-decoder/insn.c ../../arch/x86/lib/insn.c >/dev/null && \
13+ diff -B -I'^#include' util/intel-pt-decoder/inat.c ../../arch/x86/lib/inat.c >/dev/null && \
14+ diff -B util/intel-pt-decoder/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null && \
15+ diff -B util/intel-pt-decoder/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null && \
16+ diff -B -I'^#include' util/intel-pt-decoder/insn.h ../../arch/x86/include/asm/insn.h >/dev/null && \
17+ diff -B -I'^#include' util/intel-pt-decoder/inat.h ../../arch/x86/include/asm/inat.h >/dev/null && \
18+ diff -B -I'^#include' util/intel-pt-decoder/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) \
19+ || echo "Warning: Intel PT: x86 instruction decoder differs from kernel" >&2 )) || true
20+ $(call rule_mkdir)
21+ $(call if_changed_dep,cc_o_c)
1122
1223 CFLAGS_intel-pt-insn-decoder.o += -I$(OUTPUT)util/intel-pt-decoder -Wno-override-init
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c+2−2
@@ -650,7 +650,7 @@ static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info) · 649 unmodified lines
650650 if (data->from_mtc && timestamp < data->timestamp &&
651651 data->timestamp - timestamp < decoder->tsc_slip)
652652 return 1;
653− while (timestamp < data->timestamp)
653+ if (timestamp < data->timestamp)
654654 timestamp += (1ULL << 56);
655655 if (pkt_info->last_packet_type != INTEL_PT_CYC) {
656656 if (data->from_mtc)
@@ -1191,7 +1191,7 @@ static void intel_pt_calc_tsc_timestamp(struct intel_pt_decoder *decoder) · 534 unmodified lines
11911191 timestamp);
11921192 timestamp = decoder->timestamp;
11931193 }
1194− while (timestamp < decoder->timestamp) {
1194+ if (timestamp < decoder->timestamp) {
11951195 intel_pt_log_to("Wraparound timestamp", timestamp);
11961196 timestamp += (1ULL << 56);
11971197 decoder->tsc_timestamp = timestamp;
tools/perf/util/intel-pt-decoder/intel-pt-log.c+11−10
@@ -29,18 +29,18 @@ · 28 unmodified lines
2929
3030 static FILE *f;
3131 static char log_name[MAX_LOG_NAME];
32−static bool enable_logging;
32+bool intel_pt_enable_logging;
3333
3434 void intel_pt_log_enable(void)
3535 {
36− enable_logging = true;
36+ intel_pt_enable_logging = true;
3737 }
3838
3939 void intel_pt_log_disable(void)
4040 {
4141 if (f)
4242 fflush(f);
43− enable_logging = false;
43+ intel_pt_enable_logging = false;
4444 }
4545
4646 void intel_pt_log_set_name(const char *name)
@@ -80,7 +80,7 @@ static void intel_pt_print_no_data(uint64_t pos, int indent) · 33 unmodified lines
8080
8181 static int intel_pt_log_open(void)
8282 {
83− if (!enable_logging)
83+ if (!intel_pt_enable_logging)
8484 return -1;
8585
8686 if (f)
@@ -91,15 +91,15 @@ static int intel_pt_log_open(void) · 4 unmodified lines
9191
9292 f = fopen(log_name, "w+");
9393 if (!f) {
94− enable_logging = false;
94+ intel_pt_enable_logging = false;
9595 return -1;
9696 }
9797
9898 return 0;
9999 }
100100
101−void intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len,
102− uint64_t pos, const unsigned char *buf)
101+void __intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len,
102+ uint64_t pos, const unsigned char *buf)
103103 {
104104 char desc[INTEL_PT_PKT_DESC_MAX];
105105
@@ -111,7 +111,7 @@ void intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len, · 5 unmodified lines
111111 fprintf(f, "%s\n", desc);
112112 }
113113
114−void intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip)
114+void __intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip)
115115 {
116116 char desc[INTEL_PT_INSN_DESC_MAX];
117117 size_t len = intel_pt_insn->length;
@@ -128,7 +128,8 @@ void intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip) · 10 unmodified lines
128128 fprintf(f, "Bad instruction!\n");
129129 }
130130
131−void intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn, uint64_t ip)
131+void __intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn,
132+ uint64_t ip)
132133 {
133134 char desc[INTEL_PT_INSN_DESC_MAX];
134135
@@ -142,7 +143,7 @@ void intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn, uint64_t ip) · 7 unmodified lines
142143 fprintf(f, "Bad instruction!\n");
143144 }
144145
145−void intel_pt_log(const char *fmt, ...)
146+void __intel_pt_log(const char *fmt, ...)
146147 {
147148 va_list args;
148149
tools/perf/util/intel-pt-decoder/intel-pt-log.h+32−6
@@ -25,20 +25,46 @@ void intel_pt_log_enable(void); · 24 unmodified lines
2525 void intel_pt_log_disable(void);
2626 void intel_pt_log_set_name(const char *name);
2727
28−void intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len,
29− uint64_t pos, const unsigned char *buf);
28+void __intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len,
29+ uint64_t pos, const unsigned char *buf);
3030
3131 struct intel_pt_insn;
3232
33−void intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip);
34−void intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn,
35− uint64_t ip);
33+void __intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip);
34+void __intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn,
35+ uint64_t ip);
3636
3737 __attribute__((format(printf, 1, 2)))
38−void intel_pt_log(const char *fmt, ...);
38+void __intel_pt_log(const char *fmt, ...);
39+
40+#define intel_pt_log(fmt, ...) \
41+ do { \
42+ if (intel_pt_enable_logging) \
43+ __intel_pt_log(fmt, ##__VA_ARGS__); \
44+ } while (0)
45+
46+#define intel_pt_log_packet(arg, ...) \
47+ do { \
48+ if (intel_pt_enable_logging) \
49+ __intel_pt_log_packet(arg, ##__VA_ARGS__); \
50+ } while (0)
51+
52+#define intel_pt_log_insn(arg, ...) \
53+ do { \
54+ if (intel_pt_enable_logging) \
55+ __intel_pt_log_insn(arg, ##__VA_ARGS__); \
56+ } while (0)
57+
58+#define intel_pt_log_insn_no_data(arg, ...) \
59+ do { \
60+ if (intel_pt_enable_logging) \
61+ __intel_pt_log_insn_no_data(arg, ##__VA_ARGS__); \
62+ } while (0)
3963
4064 #define x64_fmt "0x%" PRIx64
4165
66+extern bool intel_pt_enable_logging;
67+
4268 static inline void intel_pt_log_at(const char *msg, uint64_t u)
4369 {
4470 intel_pt_log("%s at " x64_fmt "\n", msg, u);
tools/perf/util/intel-pt-decoder/x86-opcode-map.txt+19−5
@@ -353,8 +353,12 @@ AVXcode: 1 · 352 unmodified lines
353353 17: vmovhps Mq,Vq (v1) | vmovhpd Mq,Vq (66),(v1)
354354 18: Grp16 (1A)
355355 19:
356−1a: BNDCL Ev,Gv | BNDCU Ev,Gv | BNDMOV Gv,Ev | BNDLDX Gv,Ev,Gv
357−1b: BNDCN Ev,Gv | BNDMOV Ev,Gv | BNDMK Gv,Ev | BNDSTX Ev,GV,Gv
356+# Intel SDM opcode map does not list MPX instructions. For now using Gv for
357+# bnd registers and Ev for everything else is OK because the instruction
358+# decoder does not use the information except as an indication that there is
359+# a ModR/M byte.
360+1a: BNDCL Gv,Ev (F3) | BNDCU Gv,Ev (F2) | BNDMOV Gv,Ev (66) | BNDLDX Gv,Ev
361+1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv
358362 1c:
359363 1d:
360364 1e:
@@ -732,6 +736,12 @@ bd: vfnmadd231ss/d Vx,Hx,Wx (66),(v),(v1) · 371 unmodified lines
732736 be: vfnmsub231ps/d Vx,Hx,Wx (66),(v)
733737 bf: vfnmsub231ss/d Vx,Hx,Wx (66),(v),(v1)
734738 # 0x0f 0x38 0xc0-0xff
739+c8: sha1nexte Vdq,Wdq
740+c9: sha1msg1 Vdq,Wdq
741+ca: sha1msg2 Vdq,Wdq
742+cb: sha256rnds2 Vdq,Wdq
743+cc: sha256msg1 Vdq,Wdq
744+cd: sha256msg2 Vdq,Wdq
735745 db: VAESIMC Vdq,Wdq (66),(v1)
736746 dc: VAESENC Vdq,Hdq,Wdq (66),(v1)
737747 dd: VAESENCLAST Vdq,Hdq,Wdq (66),(v1)
@@ -790,6 +800,7 @@ AVXcode: 3 · 52 unmodified lines
790800 61: vpcmpestri Vdq,Wdq,Ib (66),(v1)
791801 62: vpcmpistrm Vdq,Wdq,Ib (66),(v1)
792802 63: vpcmpistri Vdq,Wdq,Ib (66),(v1)
803+cc: sha1rnds4 Vdq,Wdq,Ib
793804 df: VAESKEYGEN Vdq,Wdq,Ib (66),(v1)
794805 f0: RORX Gy,Ey,Ib (F2),(v)
795806 EndTable
@@ -874,7 +885,7 @@ GrpTable: Grp7 · 78 unmodified lines
874885 2: LGDT Ms | XGETBV (000),(11B) | XSETBV (001),(11B) | VMFUNC (100),(11B) | XEND (101)(11B) | XTEST (110)(11B)
875886 3: LIDT Ms
876887 4: SMSW Mw/Rv
877−5:
888+5: rdpkru (110),(11B) | wrpkru (111),(11B)
878889 6: LMSW Ew
879890 7: INVLPG Mb | SWAPGS (o64),(000),(11B) | RDTSCP (001),(11B)
880891 EndTable
@@ -888,6 +899,9 @@ EndTable · 7 unmodified lines
888899
889900 GrpTable: Grp9
890901 1: CMPXCHG8B/16B Mq/Mdq
902+3: xrstors
903+4: xsavec
904+5: xsaves
891905 6: VMPTRLD Mq | VMCLEAR Mq (66) | VMXON Mq (F3) | RDRAND Rv (11B)
892906 7: VMPTRST Mq | VMPTRST Mq (F3) | RDSEED Rv (11B)
893907 EndTable
@@ -932,8 +946,8 @@ GrpTable: Grp15 · 38 unmodified lines
932946 3: vstmxcsr Md (v1) | WRGSBASE Ry (F3),(11B)
933947 4: XSAVE
934948 5: XRSTOR | lfence (11B)
935−6: XSAVEOPT | mfence (11B)
936−7: clflush | sfence (11B)
949+6: XSAVEOPT | clwb (66) | mfence (11B)
950+7: clflush | clflushopt (66) | sfence (11B) | pcommit (66),(11B)
937951 EndTable
938952
939953 GrpTable: Grp16
tools/perf/util/intel-pt.c+237−29
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 #include "../perf.h"
2323 #include "session.h"
2424 #include "machine.h"
25+#include "sort.h"
2526 #include "tool.h"
2627 #include "event.h"
2728 #include "evlist.h"
@@ -63,6 +64,7 @@ struct intel_pt { · 35 unmodified lines
6364 bool data_queued;
6465 bool est_tsc;
6566 bool sync_switch;
67+ bool mispred_all;
6668 int have_sched_switch;
6769 u32 pmu_type;
6870 u64 kernel_start;
@@ -115,6 +117,9 @@ struct intel_pt_queue { · 46 unmodified lines
115117 void *decoder;
116118 const struct intel_pt_state *state;
117119 struct ip_callchain *chain;
120+ struct branch_stack *last_branch;
121+ struct branch_stack *last_branch_rb;
122+ size_t last_branch_pos;
118123 union perf_event *event_buf;
119124 bool on_heap;
120125 bool stop;
@@ -675,6 +680,19 @@ static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt, · 554 unmodified lines
675680 goto out_free;
676681 }
677682
683+ if (pt->synth_opts.last_branch) {
684+ size_t sz = sizeof(struct branch_stack);
685+
686+ sz += pt->synth_opts.last_branch_sz *
687+ sizeof(struct branch_entry);
688+ ptq->last_branch = zalloc(sz);
689+ if (!ptq->last_branch)
690+ goto out_free;
691+ ptq->last_branch_rb = zalloc(sz);
692+ if (!ptq->last_branch_rb)
693+ goto out_free;
694+ }
695+
678696 ptq->event_buf = malloc(PERF_SAMPLE_MAX_SIZE);
679697 if (!ptq->event_buf)
680698 goto out_free;
@@ -720,7 +738,7 @@ static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt, · 39 unmodified lines
720738
721739 if (!params.period) {
722740 params.period_type = INTEL_PT_PERIOD_INSTRUCTIONS;
723− params.period = 1000;
741+ params.period = 1;
724742 }
725743 }
726744
@@ -732,6 +750,8 @@ static struct intel_pt_queue *intel_pt_alloc_queue(struct intel_pt *pt, · 5 unmodified lines
732750
733751 out_free:
734752 zfree(&ptq->event_buf);
753+ zfree(&ptq->last_branch);
754+ zfree(&ptq->last_branch_rb);
735755 zfree(&ptq->chain);
736756 free(ptq);
737757 return NULL;
@@ -746,6 +766,8 @@ static void intel_pt_free_queue(void *priv) · 8 unmodified lines
746766 thread__zput(ptq->thread);
747767 intel_pt_decoder_free(ptq->decoder);
748768 zfree(&ptq->event_buf);
769+ zfree(&ptq->last_branch);
770+ zfree(&ptq->last_branch_rb);
749771 zfree(&ptq->chain);
750772 free(ptq);
751773 }
@@ -876,6 +898,58 @@ static int intel_pt_setup_queues(struct intel_pt *pt) · 124 unmodified lines
876898 return 0;
877899 }
878900
901+static inline void intel_pt_copy_last_branch_rb(struct intel_pt_queue *ptq)
902+{
903+ struct branch_stack *bs_src = ptq->last_branch_rb;
904+ struct branch_stack *bs_dst = ptq->last_branch;
905+ size_t nr = 0;
906+
907+ bs_dst->nr = bs_src->nr;
908+
909+ if (!bs_src->nr)
910+ return;
911+
912+ nr = ptq->pt->synth_opts.last_branch_sz - ptq->last_branch_pos;
913+ memcpy(&bs_dst->entries[0],
914+ &bs_src->entries[ptq->last_branch_pos],
915+ sizeof(struct branch_entry) * nr);
916+
917+ if (bs_src->nr >= ptq->pt->synth_opts.last_branch_sz) {
918+ memcpy(&bs_dst->entries[nr],
919+ &bs_src->entries[0],
920+ sizeof(struct branch_entry) * ptq->last_branch_pos);
921+ }
922+}
923+
924+static inline void intel_pt_reset_last_branch_rb(struct intel_pt_queue *ptq)
925+{
926+ ptq->last_branch_pos = 0;
927+ ptq->last_branch_rb->nr = 0;
928+}
929+
930+static void intel_pt_update_last_branch_rb(struct intel_pt_queue *ptq)
931+{
932+ const struct intel_pt_state *state = ptq->state;
933+ struct branch_stack *bs = ptq->last_branch_rb;
934+ struct branch_entry *be;
935+
936+ if (!ptq->last_branch_pos)
937+ ptq->last_branch_pos = ptq->pt->synth_opts.last_branch_sz;
938+
939+ ptq->last_branch_pos -= 1;
940+
941+ be = &bs->entries[ptq->last_branch_pos];
942+ be->from = state->from_ip;
943+ be->to = state->to_ip;
944+ be->flags.abort = !!(state->flags & INTEL_PT_ABORT_TX);
945+ be->flags.in_tx = !!(state->flags & INTEL_PT_IN_TX);
946+ /* No support for mispredict */
947+ be->flags.mispred = ptq->pt->mispred_all;
948+
949+ if (bs->nr < ptq->pt->synth_opts.last_branch_sz)
950+ bs->nr += 1;
951+}
952+
879953 static int intel_pt_inject_event(union perf_event *event,
880954 struct perf_sample *sample, u64 type,
881955 bool swapped)
@@ -890,6 +964,13 @@ static int intel_pt_synth_branch_sample(struct intel_pt_queue *ptq) · 8 unmodified lines
890964 struct intel_pt *pt = ptq->pt;
891965 union perf_event *event = ptq->event_buf;
892966 struct perf_sample sample = { .ip = 0, };
967+ struct dummy_branch_stack {
968+ u64 nr;
969+ struct branch_entry entries;
970+ } dummy_bs;
971+
972+ if (pt->branches_filter && !(pt->branches_filter & ptq->flags))
973+ return 0;
893974
894975 event->sample.header.type = PERF_RECORD_SAMPLE;
895976 event->sample.header.misc = PERF_RECORD_MISC_USER;
@@ -909,8 +990,20 @@ static int intel_pt_synth_branch_sample(struct intel_pt_queue *ptq) · 13 unmodified lines
909990 sample.flags = ptq->flags;
910991 sample.insn_len = ptq->insn_len;
911992
912− if (pt->branches_filter && !(pt->branches_filter & ptq->flags))
913− return 0;
993+ /*
994+ * perf report cannot handle events without a branch stack when using
995+ * SORT_MODE__BRANCH so make a dummy one.
996+ */
997+ if (pt->synth_opts.last_branch && sort__mode == SORT_MODE__BRANCH) {
998+ dummy_bs = (struct dummy_branch_stack){
999+ .nr = 1,
1000+ .entries = {
1001+ .from = sample.ip,
1002+ .to = sample.addr,
1003+ },
1004+ };
1005+ sample.branch_stack = (struct branch_stack *)&dummy_bs;
1006+ }
9141007
9151008 if (pt->synth_opts.inject) {
9161009 ret = intel_pt_inject_event(event, &sample,
@@ -961,6 +1054,11 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq) · 44 unmodified lines
9611054 sample.callchain = ptq->chain;
9621055 }
9631056
1057+ if (pt->synth_opts.last_branch) {
1058+ intel_pt_copy_last_branch_rb(ptq);
1059+ sample.branch_stack = ptq->last_branch;
1060+ }
1061+
9641062 if (pt->synth_opts.inject) {
9651063 ret = intel_pt_inject_event(event, &sample,
9661064 pt->instructions_sample_type,
@@ -974,6 +1072,9 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq) · 7 unmodified lines
9741072 pr_err("Intel Processor Trace: failed to deliver instruction event, error %d\n",
9751073 ret);
9761074
1075+ if (pt->synth_opts.last_branch)
1076+ intel_pt_reset_last_branch_rb(ptq);
1077+
9771078 return ret;
9781079 }
9791080
@@ -1008,6 +1109,11 @@ static int intel_pt_synth_transaction_sample(struct intel_pt_queue *ptq) · 28 unmodified lines
10081109 sample.callchain = ptq->chain;
10091110 }
10101111
1112+ if (pt->synth_opts.last_branch) {
1113+ intel_pt_copy_last_branch_rb(ptq);
1114+ sample.branch_stack = ptq->last_branch;
1115+ }
1116+
10111117 if (pt->synth_opts.inject) {
10121118 ret = intel_pt_inject_event(event, &sample,
10131119 pt->transactions_sample_type,
@@ -1021,6 +1127,9 @@ static int intel_pt_synth_transaction_sample(struct intel_pt_queue *ptq) · 7 unmodified lines
10211127 pr_err("Intel Processor Trace: failed to deliver transaction event, error %d\n",
10221128 ret);
10231129
1130+ if (pt->synth_opts.callchain)
1131+ intel_pt_reset_last_branch_rb(ptq);
1132+
10241133 return ret;
10251134 }
10261135
@@ -1116,6 +1225,9 @@ static int intel_pt_sample(struct intel_pt_queue *ptq) · 89 unmodified lines
11161225 return err;
11171226 }
11181227
1228+ if (pt->synth_opts.last_branch)
1229+ intel_pt_update_last_branch_rb(ptq);
1230+
11191231 if (!pt->sync_switch)
11201232 return 0;
11211233
@@ -1145,16 +1257,18 @@ static int intel_pt_sample(struct intel_pt_queue *ptq) · 23 unmodified lines
11451257 return 0;
11461258 }
11471259
1148−static u64 intel_pt_switch_ip(struct machine *machine, u64 *ptss_ip)
1260+static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip)
11491261 {
1262+ struct machine *machine = pt->machine;
11501263 struct map *map;
11511264 struct symbol *sym, *start;
11521265 u64 ip, switch_ip = 0;
1266+ const char *ptss;
11531267
11541268 if (ptss_ip)
11551269 *ptss_ip = 0;
11561270
1157− map = machine__kernel_map(machine, MAP__FUNCTION);
1271+ map = machine__kernel_map(machine);
11581272 if (!map)
11591273 return 0;
11601274
@@ -1177,8 +1291,13 @@ static u64 intel_pt_switch_ip(struct machine *machine, u64 *ptss_ip) · 16 unmodified lines
11771291 if (!switch_ip || !ptss_ip)
11781292 return 0;
11791293
1294+ if (pt->have_sched_switch == 1)
1295+ ptss = "perf_trace_sched_switch";
1296+ else
1297+ ptss = "__perf_event_task_sched_out";
1298+
11801299 for (sym = start; sym; sym = dso__next_symbol(sym)) {
1181− if (!strcmp(sym->name, "perf_trace_sched_switch")) {
1300+ if (!strcmp(sym->name, ptss)) {
11821301 ip = map->unmap_ip(map, sym->start);
11831302 if (ip >= map->start && ip < map->end) {
11841303 *ptss_ip = ip;
@@ -1198,11 +1317,11 @@ static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp) · 13 unmodified lines
11981317
11991318 if (!pt->kernel_start) {
12001319 pt->kernel_start = machine__kernel_start(pt->machine);
1201− if (pt->per_cpu_mmaps && pt->have_sched_switch &&
1320+ if (pt->per_cpu_mmaps &&
1321+ (pt->have_sched_switch == 1 || pt->have_sched_switch == 3) &&
12021322 !pt->timeless_decoding && intel_pt_tracing_kernel(pt) &&
12031323 !pt->sampling_mode) {
1204− pt->switch_ip = intel_pt_switch_ip(pt->machine,
1205− &pt->ptss_ip);
1324+ pt->switch_ip = intel_pt_switch_ip(pt, &pt->ptss_ip);
12061325 if (pt->switch_ip) {
12071326 intel_pt_log("switch_ip: %"PRIx64" ptss_ip: %"PRIx64"\n",
12081327 pt->switch_ip, pt->ptss_ip);
@@ -1387,31 +1506,18 @@ static struct intel_pt_queue *intel_pt_cpu_to_ptq(struct intel_pt *pt, int cpu) · 178 unmodified lines
13871506 return NULL;
13881507 }
13891508
1390−static int intel_pt_process_switch(struct intel_pt *pt,
1391− struct perf_sample *sample)
1509+static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid,
1510+ u64 timestamp)
13921511 {
13931512 struct intel_pt_queue *ptq;
1394− struct perf_evsel *evsel;
1395− pid_t tid;
1396− int cpu, err;
1397−
1398− evsel = perf_evlist__id2evsel(pt->session->evlist, sample->id);
1399− if (evsel != pt->switch_evsel)
1400− return 0;
1401−
1402− tid = perf_evsel__intval(evsel, sample, "next_pid");
1403− cpu = sample->cpu;
1404−
1405− intel_pt_log("sched_switch: cpu %d tid %d time %"PRIu64" tsc %#"PRIx64"\n",
1406− cpu, tid, sample->time, perf_time_to_tsc(sample->time,
1407− &pt->tc));
1513+ int err;
14081514
14091515 if (!pt->sync_switch)
1410− goto out;
1516+ return 1;
14111517
14121518 ptq = intel_pt_cpu_to_ptq(pt, cpu);
14131519 if (!ptq)
1414− goto out;
1520+ return 1;
14151521
14161522 switch (ptq->switch_state) {
14171523 case INTEL_PT_SS_NOT_TRACING:
@@ -1424,7 +1530,7 @@ static int intel_pt_process_switch(struct intel_pt *pt, · 6 unmodified lines
14241530 return 0;
14251531 case INTEL_PT_SS_EXPECTING_SWITCH_EVENT:
14261532 if (!ptq->on_heap) {
1427− ptq->timestamp = perf_time_to_tsc(sample->time,
1533+ ptq->timestamp = perf_time_to_tsc(timestamp,
14281534 &pt->tc);
14291535 err = auxtrace_heap__add(&pt->heap, ptq->queue_nr,
14301536 ptq->timestamp);
@@ -1441,10 +1547,76 @@ static int intel_pt_process_switch(struct intel_pt *pt, · 10 unmodified lines
14411547 default:
14421548 break;
14431549 }
1444−out:
1550+
1551+ return 1;
1552+}
1553+
1554+static int intel_pt_process_switch(struct intel_pt *pt,
1555+ struct perf_sample *sample)
1556+{
1557+ struct perf_evsel *evsel;
1558+ pid_t tid;
1559+ int cpu, ret;
1560+
1561+ evsel = perf_evlist__id2evsel(pt->session->evlist, sample->id);
1562+ if (evsel != pt->switch_evsel)
1563+ return 0;
1564+
1565+ tid = perf_evsel__intval(evsel, sample, "next_pid");
1566+ cpu = sample->cpu;
1567+
1568+ intel_pt_log("sched_switch: cpu %d tid %d time %"PRIu64" tsc %#"PRIx64"\n",
1569+ cpu, tid, sample->time, perf_time_to_tsc(sample->time,
1570+ &pt->tc));
1571+
1572+ ret = intel_pt_sync_switch(pt, cpu, tid, sample->time);
1573+ if (ret <= 0)
1574+ return ret;
1575+
14451576 return machine__set_current_tid(pt->machine, cpu, -1, tid);
14461577 }
14471578
1579+static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event,
1580+ struct perf_sample *sample)
1581+{
1582+ bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT;
1583+ pid_t pid, tid;
1584+ int cpu, ret;
1585+
1586+ cpu = sample->cpu;
1587+
1588+ if (pt->have_sched_switch == 3) {
1589+ if (!out)
1590+ return 0;
1591+ if (event->header.type != PERF_RECORD_SWITCH_CPU_WIDE) {
1592+ pr_err("Expecting CPU-wide context switch event\n");
1593+ return -EINVAL;
1594+ }
1595+ pid = event->context_switch.next_prev_pid;
1596+ tid = event->context_switch.next_prev_tid;
1597+ } else {
1598+ if (out)
1599+ return 0;
1600+ pid = sample->pid;
1601+ tid = sample->tid;
1602+ }
1603+
1604+ if (tid == -1) {
1605+ pr_err("context_switch event has no tid\n");
1606+ return -EINVAL;
1607+ }
1608+
1609+ intel_pt_log("context_switch: cpu %d pid %d tid %d time %"PRIu64" tsc %#"PRIx64"\n",
1610+ cpu, pid, tid, sample->time, perf_time_to_tsc(sample->time,
1611+ &pt->tc));
1612+
1613+ ret = intel_pt_sync_switch(pt, cpu, tid, sample->time);
1614+ if (ret <= 0)
1615+ return ret;
1616+
1617+ return machine__set_current_tid(pt->machine, cpu, pid, tid);
1618+}
1619+
14481620 static int intel_pt_process_itrace_start(struct intel_pt *pt,
14491621 union perf_event *event,
14501622 struct perf_sample *sample)
@@ -1515,6 +1687,9 @@ static int intel_pt_process_event(struct perf_session *session, · 64 unmodified lines
15151687 err = intel_pt_process_switch(pt, sample);
15161688 else if (event->header.type == PERF_RECORD_ITRACE_START)
15171689 err = intel_pt_process_itrace_start(pt, event, sample);
1690+ else if (event->header.type == PERF_RECORD_SWITCH ||
1691+ event->header.type == PERF_RECORD_SWITCH_CPU_WIDE)
1692+ err = intel_pt_context_switch(pt, event, sample);
15181693
15191694 intel_pt_log("event %s (%u): cpu %d time %"PRIu64" tsc %#"PRIx64"\n",
15201695 perf_event__name(event->header.type), event->header.type,
@@ -1700,6 +1875,8 @@ static int intel_pt_synth_events(struct intel_pt *pt, · 179 unmodified lines
17001875 pt->instructions_sample_period = attr.sample_period;
17011876 if (pt->synth_opts.callchain)
17021877 attr.sample_type |= PERF_SAMPLE_CALLCHAIN;
1878+ if (pt->synth_opts.last_branch)
1879+ attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
17031880 pr_debug("Synthesizing 'instructions' event with id %" PRIu64 " sample type %#" PRIx64 "\n",
17041881 id, (u64)attr.sample_type);
17051882 err = intel_pt_synth_event(session, &attr, id);
@@ -1719,6 +1896,8 @@ static int intel_pt_synth_events(struct intel_pt *pt, · 13 unmodified lines
17191896 attr.sample_period = 1;
17201897 if (pt->synth_opts.callchain)
17211898 attr.sample_type |= PERF_SAMPLE_CALLCHAIN;
1899+ if (pt->synth_opts.last_branch)
1900+ attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
17221901 pr_debug("Synthesizing 'transactions' event with id %" PRIu64 " sample type %#" PRIx64 "\n",
17231902 id, (u64)attr.sample_type);
17241903 err = intel_pt_synth_event(session, &attr, id);
@@ -1745,6 +1924,7 @@ static int intel_pt_synth_events(struct intel_pt *pt, · 20 unmodified lines
17451924 attr.sample_period = 1;
17461925 attr.sample_type |= PERF_SAMPLE_ADDR;
17471926 attr.sample_type &= ~(u64)PERF_SAMPLE_CALLCHAIN;
1927+ attr.sample_type &= ~(u64)PERF_SAMPLE_BRANCH_STACK;
17481928 pr_debug("Synthesizing 'branches' event with id %" PRIu64 " sample type %#" PRIx64 "\n",
17491929 id, (u64)attr.sample_type);
17501930 err = intel_pt_synth_event(session, &attr, id);
@@ -1777,6 +1957,28 @@ static struct perf_evsel *intel_pt_find_sched_switch(struct perf_evlist *evlist) · 26 unmodified lines
17771957 return NULL;
17781958 }
17791959
1960+static bool intel_pt_find_switch(struct perf_evlist *evlist)
1961+{
1962+ struct perf_evsel *evsel;
1963+
1964+ evlist__for_each(evlist, evsel) {
1965+ if (evsel->attr.context_switch)
1966+ return true;
1967+ }
1968+
1969+ return false;
1970+}
1971+
1972+static int intel_pt_perf_config(const char *var, const char *value, void *data)
1973+{
1974+ struct intel_pt *pt = data;
1975+
1976+ if (!strcmp(var, "intel-pt.mispred-all"))
1977+ pt->mispred_all = perf_config_bool(var, value);
1978+
1979+ return 0;
1980+}
1981+
17801982 static const char * const intel_pt_info_fmts[] = {
17811983 [INTEL_PT_PMU_TYPE] = " PMU Type %"PRId64"\n",
17821984 [INTEL_PT_TIME_SHIFT] = " Time Shift %"PRIu64"\n",
@@ -1821,6 +2023,8 @@ int intel_pt_process_auxtrace_info(union perf_event *event, · 38 unmodified lines
18212023 if (!pt)
18222024 return -ENOMEM;
18232025
2026+ perf_config(intel_pt_perf_config, pt);
2027+
18242028 err = auxtrace_queues__init(&pt->queues);
18252029 if (err)
18262030 goto err_free;
@@ -1888,6 +2092,10 @@ int intel_pt_process_auxtrace_info(union perf_event *event, · 61 unmodified lines
18882092 pr_err("%s: missing sched_switch event\n", __func__);
18892093 goto err_delete_thread;
18902094 }
2095+ } else if (pt->have_sched_switch == 2 &&
2096+ !intel_pt_find_switch(session->evlist)) {
2097+ pr_err("%s: missing context_switch attribute flag\n", __func__);
2098+ goto err_delete_thread;
18912099 }
18922100
18932101 if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
tools/perf/util/machine.c+15−14
@@ -35,6 +35,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) · 34 unmodified lines
3535 machine->last_match = NULL;
3636
3737 machine->vdso_info = NULL;
38+ machine->env = NULL;
3839
3940 machine->pid = pid;
4041
@@ -624,7 +625,7 @@ size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp) · 583 unmodified lines
624625 {
625626 int i;
626627 size_t printed = 0;
627− struct dso *kdso = machine->vmlinux_maps[MAP__FUNCTION]->dso;
628+ struct dso *kdso = machine__kernel_map(machine)->dso;
628629
629630 if (kdso->has_build_id) {
630631 char filename[PATH_MAX];
@@ -740,6 +741,7 @@ int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) · 109 unmodified lines
740741
741742 for (type = 0; type < MAP__NR_TYPES; ++type) {
742743 struct kmap *kmap;
744+ struct map *map;
743745
744746 machine->vmlinux_maps[type] = map__new2(start, kernel, type);
745747 if (machine->vmlinux_maps[type] == NULL)
@@ -748,13 +750,13 @@ int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) · 2 unmodified lines
748750 machine->vmlinux_maps[type]->map_ip =
749751 machine->vmlinux_maps[type]->unmap_ip =
750752 identity__map_ip;
751− kmap = map__kmap(machine->vmlinux_maps[type]);
753+ map = __machine__kernel_map(machine, type);
754+ kmap = map__kmap(map);
752755 if (!kmap)
753756 return -1;
754757
755758 kmap->kmaps = &machine->kmaps;
756− map_groups__insert(&machine->kmaps,
757− machine->vmlinux_maps[type]);
759+ map_groups__insert(&machine->kmaps, map);
758760 }
759761
760762 return 0;
@@ -766,13 +768,13 @@ void machine__destroy_kernel_maps(struct machine *machine) · 5 unmodified lines
766768
767769 for (type = 0; type < MAP__NR_TYPES; ++type) {
768770 struct kmap *kmap;
771+ struct map *map = __machine__kernel_map(machine, type);
769772
770− if (machine->vmlinux_maps[type] == NULL)
773+ if (map == NULL)
771774 continue;
772775
773− kmap = map__kmap(machine->vmlinux_maps[type]);
774− map_groups__remove(&machine->kmaps,
775− machine->vmlinux_maps[type]);
776+ kmap = map__kmap(map);
777+ map_groups__remove(&machine->kmaps, map);
776778 if (kmap && kmap->ref_reloc_sym) {
777779 /*
778780 * ref_reloc_sym is shared among all maps, so free just
@@ -866,7 +868,7 @@ int machines__create_kernel_maps(struct machines *machines, pid_t pid) · 87 unmodified lines
866868 int machine__load_kallsyms(struct machine *machine, const char *filename,
867869 enum map_type type, symbol_filter_t filter)
868870 {
869− struct map *map = machine->vmlinux_maps[type];
871+ struct map *map = machine__kernel_map(machine);
870872 int ret = dso__load_kallsyms(map->dso, filename, map, filter);
871873
872874 if (ret > 0) {
@@ -885,7 +887,7 @@ int machine__load_kallsyms(struct machine *machine, const char *filename, · 12 unmodified lines
885887 int machine__load_vmlinux_path(struct machine *machine, enum map_type type,
886888 symbol_filter_t filter)
887889 {
888− struct map *map = machine->vmlinux_maps[type];
890+ struct map *map = machine__kernel_map(machine);
889891 int ret = dso__load_vmlinux_path(map->dso, map, filter);
890892
891893 if (ret > 0)
@@ -1243,8 +1245,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine, · 351 unmodified lines
12431245 /*
12441246 * preload dso of guest kernel and modules
12451247 */
1246− dso__load(kernel, machine->vmlinux_maps[MAP__FUNCTION],
1247− NULL);
1248+ dso__load(kernel, machine__kernel_map(machine), NULL);
12481249 }
12491250 }
12501251 return 0;
@@ -1830,7 +1831,7 @@ static int thread__resolve_callchain_sample(struct thread *thread, · 579 unmodified lines
18301831 }
18311832
18321833 check_calls:
1833− if (chain->nr > PERF_MAX_STACK_DEPTH) {
1834+ if (chain->nr > PERF_MAX_STACK_DEPTH && (int)chain->nr > max_stack) {
18341835 pr_warning("corrupted callchain. skipping...\n");
18351836 return 0;
18361837 }
@@ -1996,7 +1997,7 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid, · 159 unmodified lines
19961997
19971998 int machine__get_kernel_start(struct machine *machine)
19981999 {
1999− struct map *map = machine__kernel_map(machine, MAP__FUNCTION);
2000+ struct map *map = machine__kernel_map(machine);
20002001 int err = 0;
20012002
20022003 /*
tools/perf/util/machine.h+8−1
@@ -34,6 +34,7 @@ struct machine { · 33 unmodified lines
3434 struct list_head dead_threads;
3535 struct thread *last_match;
3636 struct vdso_info *vdso_info;
37+ struct perf_env *env;
3738 struct dsos dsos;
3839 struct map_groups kmaps;
3940 struct map *vmlinux_maps[MAP__NR_TYPES];
@@ -47,11 +48,17 @@ struct machine { · 7 unmodified lines
4748 };
4849
4950 static inline
50−struct map *machine__kernel_map(struct machine *machine, enum map_type type)
51+struct map *__machine__kernel_map(struct machine *machine, enum map_type type)
5152 {
5253 return machine->vmlinux_maps[type];
5354 }
5455
56+static inline
57+struct map *machine__kernel_map(struct machine *machine)
58+{
59+ return __machine__kernel_map(machine, MAP__FUNCTION);
60+}
61+
5562 int machine__get_kernel_start(struct machine *machine);
5663
5764 static inline u64 machine__kernel_start(struct machine *machine)
tools/perf/util/map.c+14−7
@@ -235,7 +235,7 @@ struct map *map__new2(u64 start, struct dso *dso, enum map_type type) · 234 unmodified lines
235235 */
236236 bool __map__is_kernel(const struct map *map)
237237 {
238− return map->groups->machine->vmlinux_maps[map->type] == map;
238+ return __machine__kernel_map(map->groups->machine, map->type) == map;
239239 }
240240
241241 static void map__exit(struct map *map)
@@ -553,13 +553,9 @@ struct symbol *map_groups__find_symbol(struct map_groups *mg, · 311 unmodified lines
553553 return NULL;
554554 }
555555
556−struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
557− enum map_type type,
558− const char *name,
559− struct map **mapp,
560− symbol_filter_t filter)
556+struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
557+ struct map **mapp, symbol_filter_t filter)
561558 {
562− struct maps *maps = &mg->maps[type];
563559 struct symbol *sym;
564560 struct rb_node *nd;
565561
@@ -583,6 +579,17 @@ out: · 17 unmodified lines
583579 return sym;
584580 }
585581
582+struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
583+ enum map_type type,
584+ const char *name,
585+ struct map **mapp,
586+ symbol_filter_t filter)
587+{
588+ struct symbol *sym = maps__find_symbol_by_name(&mg->maps[type], name, mapp, filter);
589+
590+ return sym;
591+}
592+
586593 int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter)
587594 {
588595 if (ams->addr < ams->map->start || ams->addr >= ams->map->end) {
tools/perf/util/map.h+2−0
@@ -190,6 +190,8 @@ void maps__remove(struct maps *maps, struct map *map); · 189 unmodified lines
190190 struct map *maps__find(struct maps *maps, u64 addr);
191191 struct map *maps__first(struct maps *maps);
192192 struct map *map__next(struct map *map);
193+struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
194+ struct map **mapp, symbol_filter_t filter);
193195 void map_groups__init(struct map_groups *mg, struct machine *machine);
194196 void map_groups__exit(struct map_groups *mg);
195197 int map_groups__clone(struct map_groups *mg,
tools/perf/util/parse-branch-options.c+1−0
@@ -27,6 +27,7 @@ static const struct branch_mode branch_modes[] = { · 26 unmodified lines
2727 BRANCH_OPT("no_tx", PERF_SAMPLE_BRANCH_NO_TX),
2828 BRANCH_OPT("cond", PERF_SAMPLE_BRANCH_COND),
2929 BRANCH_OPT("ind_jmp", PERF_SAMPLE_BRANCH_IND_JUMP),
30+ BRANCH_OPT("call", PERF_SAMPLE_BRANCH_CALL),
3031 BRANCH_END
3132 };
3233
tools/perf/util/parse-events.c+334−40
@@ -1,4 +1,5 @@
11 #include <linux/hw_breakpoint.h>
2+#include <linux/err.h>
23 #include "util.h"
34 #include "../perf.h"
45 #include "evlist.h"
@@ -10,8 +11,9 @@ · 5 unmodified lines
1011 #include "symbol.h"
1112 #include "cache.h"
1213 #include "header.h"
14+#include "bpf-loader.h"
1315 #include "debug.h"
14−#include <api/fs/debugfs.h>
16+#include <api/fs/tracing_path.h>
1517 #include "parse-events-bison.h"
1618 #define YY_EXTRA_TYPE int
1719 #include "parse-events-flex.h"
@@ -26,6 +28,8 @@ · 8 unmodified lines
2628 extern int parse_events_debug;
2729 #endif
2830 int parse_events_parse(void *data, void *scanner);
31+static int get_config_terms(struct list_head *head_config,
32+ struct list_head *head_terms __maybe_unused);
2933
3034 static struct perf_pmu_event_symbol *perf_pmu_events_list;
3135 /*
@@ -386,32 +390,72 @@ int parse_events_add_cache(struct list_head *list, int *idx, · 354 unmodified lines
386390 return add_event(list, idx, &attr, name, NULL);
387391 }
388392
393+static void tracepoint_error(struct parse_events_error *e, int err,
394+ char *sys, char *name)
395+{
396+ char help[BUFSIZ];
397+
398+ /*
399+ * We get error directly from syscall errno ( > 0),
400+ * or from encoded pointer's error ( < 0).
401+ */
402+ err = abs(err);
403+
404+ switch (err) {
405+ case EACCES:
406+ e->str = strdup("can't access trace events");
407+ break;
408+ case ENOENT:
409+ e->str = strdup("unknown tracepoint");
410+ break;
411+ default:
412+ e->str = strdup("failed to add tracepoint");
413+ break;
414+ }
415+
416+ tracing_path__strerror_open_tp(err, help, sizeof(help), sys, name);
417+ e->help = strdup(help);
418+}
419+
389420 static int add_tracepoint(struct list_head *list, int *idx,
390− char *sys_name, char *evt_name)
421+ char *sys_name, char *evt_name,
422+ struct parse_events_error *err,
423+ struct list_head *head_config)
391424 {
392425 struct perf_evsel *evsel;
393426
394427 evsel = perf_evsel__newtp_idx(sys_name, evt_name, (*idx)++);
395− if (!evsel)
396− return -ENOMEM;
428+ if (IS_ERR(evsel)) {
429+ tracepoint_error(err, PTR_ERR(evsel), sys_name, evt_name);
430+ return PTR_ERR(evsel);
431+ }
397432
398− list_add_tail(&evsel->node, list);
433+ if (head_config) {
434+ LIST_HEAD(config_terms);
399435
436+ if (get_config_terms(head_config, &config_terms))
437+ return -ENOMEM;
438+ list_splice(&config_terms, &evsel->config_terms);
439+ }
440+
441+ list_add_tail(&evsel->node, list);
400442 return 0;
401443 }
402444
403445 static int add_tracepoint_multi_event(struct list_head *list, int *idx,
404− char *sys_name, char *evt_name)
446+ char *sys_name, char *evt_name,
447+ struct parse_events_error *err,
448+ struct list_head *head_config)
405449 {
406450 char evt_path[MAXPATHLEN];
407451 struct dirent *evt_ent;
408452 DIR *evt_dir;
409− int ret = 0;
453+ int ret = 0, found = 0;
410454
411455 snprintf(evt_path, MAXPATHLEN, "%s/%s", tracing_events_path, sys_name);
412456 evt_dir = opendir(evt_path);
413457 if (!evt_dir) {
414− perror("Can't open event dir");
458+ tracepoint_error(err, errno, sys_name, evt_name);
415459 return -1;
416460 }
417461
@@ -425,7 +469,15 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx, · 7 unmodified lines
425469 if (!strglobmatch(evt_ent->d_name, evt_name))
426470 continue;
427471
428− ret = add_tracepoint(list, idx, sys_name, evt_ent->d_name);
472+ found++;
473+
474+ ret = add_tracepoint(list, idx, sys_name, evt_ent->d_name,
475+ err, head_config);
476+ }
477+
478+ if (!found) {
479+ tracepoint_error(err, ENOENT, sys_name, evt_name);
480+ ret = -1;
429481 }
430482
431483 closedir(evt_dir);
@@ -433,15 +485,21 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx, · 1 unmodified line
433485 }
434486
435487 static int add_tracepoint_event(struct list_head *list, int *idx,
436− char *sys_name, char *evt_name)
488+ char *sys_name, char *evt_name,
489+ struct parse_events_error *err,
490+ struct list_head *head_config)
437491 {
438492 return strpbrk(evt_name, "*?") ?
439− add_tracepoint_multi_event(list, idx, sys_name, evt_name) :
440− add_tracepoint(list, idx, sys_name, evt_name);
493+ add_tracepoint_multi_event(list, idx, sys_name, evt_name,
494+ err, head_config) :
495+ add_tracepoint(list, idx, sys_name, evt_name,
496+ err, head_config);
441497 }
442498
443499 static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
444− char *sys_name, char *evt_name)
500+ char *sys_name, char *evt_name,
501+ struct parse_events_error *err,
502+ struct list_head *head_config)
445503 {
446504 struct dirent *events_ent;
447505 DIR *events_dir;
@@ -449,7 +507,7 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx, · 1 unmodified line
449507
450508 events_dir = opendir(tracing_events_path);
451509 if (!events_dir) {
452− perror("Can't open event dir");
510+ tracepoint_error(err, errno, sys_name, evt_name);
453511 return -1;
454512 }
455513
@@ -465,20 +523,135 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx, · 9 unmodified lines
465523 continue;
466524
467525 ret = add_tracepoint_event(list, idx, events_ent->d_name,
468− evt_name);
526+ evt_name, err, head_config);
469527 }
470528
471529 closedir(events_dir);
472530 return ret;
473531 }
474532
475−int parse_events_add_tracepoint(struct list_head *list, int *idx,
476− char *sys, char *event)
533+struct __add_bpf_event_param {
534+ struct parse_events_evlist *data;
535+ struct list_head *list;
536+};
537+
538+static int add_bpf_event(struct probe_trace_event *tev, int fd,
539+ void *_param)
477540 {
478− if (strpbrk(sys, "*?"))
479− return add_tracepoint_multi_sys(list, idx, sys, event);
480− else
481− return add_tracepoint_event(list, idx, sys, event);
541+ LIST_HEAD(new_evsels);
542+ struct __add_bpf_event_param *param = _param;
543+ struct parse_events_evlist *evlist = param->data;
544+ struct list_head *list = param->list;
545+ struct perf_evsel *pos;
546+ int err;
547+
548+ pr_debug("add bpf event %s:%s and attach bpf program %d\n",
549+ tev->group, tev->event, fd);
550+
551+ err = parse_events_add_tracepoint(&new_evsels, &evlist->idx, tev->group,
552+ tev->event, evlist->error, NULL);
553+ if (err) {
554+ struct perf_evsel *evsel, *tmp;
555+
556+ pr_debug("Failed to add BPF event %s:%s\n",
557+ tev->group, tev->event);
558+ list_for_each_entry_safe(evsel, tmp, &new_evsels, node) {
559+ list_del(&evsel->node);
560+ perf_evsel__delete(evsel);
561+ }
562+ return err;
563+ }
564+ pr_debug("adding %s:%s\n", tev->group, tev->event);
565+
566+ list_for_each_entry(pos, &new_evsels, node) {
567+ pr_debug("adding %s:%s to %p\n",
568+ tev->group, tev->event, pos);
569+ pos->bpf_fd = fd;
570+ }
571+ list_splice(&new_evsels, list);
572+ return 0;
573+}
574+
575+int parse_events_load_bpf_obj(struct parse_events_evlist *data,
576+ struct list_head *list,
577+ struct bpf_object *obj)
578+{
579+ int err;
580+ char errbuf[BUFSIZ];
581+ struct __add_bpf_event_param param = {data, list};
582+ static bool registered_unprobe_atexit = false;
583+
584+ if (IS_ERR(obj) || !obj) {
585+ snprintf(errbuf, sizeof(errbuf),
586+ "Internal error: load bpf obj with NULL");
587+ err = -EINVAL;
588+ goto errout;
589+ }
590+
591+ /*
592+ * Register atexit handler before calling bpf__probe() so
593+ * bpf__probe() don't need to unprobe probe points its already
594+ * created when failure.
595+ */
596+ if (!registered_unprobe_atexit) {
597+ atexit(bpf__clear);
598+ registered_unprobe_atexit = true;
599+ }
600+
601+ err = bpf__probe(obj);
602+ if (err) {
603+ bpf__strerror_probe(obj, err, errbuf, sizeof(errbuf));
604+ goto errout;
605+ }
606+
607+ err = bpf__load(obj);
608+ if (err) {
609+ bpf__strerror_load(obj, err, errbuf, sizeof(errbuf));
610+ goto errout;
611+ }
612+
613+ err = bpf__foreach_tev(obj, add_bpf_event, &param);
614+ if (err) {
615+ snprintf(errbuf, sizeof(errbuf),
616+ "Attach events in BPF object failed");
617+ goto errout;
618+ }
619+
620+ return 0;
621+errout:
622+ data->error->help = strdup("(add -v to see detail)");
623+ data->error->str = strdup(errbuf);
624+ return err;
625+}
626+
627+int parse_events_load_bpf(struct parse_events_evlist *data,
628+ struct list_head *list,
629+ char *bpf_file_name,
630+ bool source)
631+{
632+ struct bpf_object *obj;
633+
634+ obj = bpf__prepare_load(bpf_file_name, source);
635+ if (IS_ERR(obj) || !obj) {
636+ char errbuf[BUFSIZ];
637+ int err;
638+
639+ err = obj ? PTR_ERR(obj) : -EINVAL;
640+
641+ if (err == -ENOTSUP)
642+ snprintf(errbuf, sizeof(errbuf),
643+ "BPF support is not compiled");
644+ else
645+ snprintf(errbuf, sizeof(errbuf),
646+ "BPF object file '%s' is invalid",
647+ bpf_file_name);
648+
649+ data->error->help = strdup("(add -v to see detail)");
650+ data->error->str = strdup(errbuf);
651+ return err;
652+ }
653+
654+ return parse_events_load_bpf_obj(data, list, obj);
482655 }
483656
484657 static int
@@ -565,9 +738,13 @@ static int check_type_val(struct parse_events_term *term, · 80 unmodified lines
565738 return -EINVAL;
566739 }
567740
568−static int config_term(struct perf_event_attr *attr,
569− struct parse_events_term *term,
570− struct parse_events_error *err)
741+typedef int config_term_func_t(struct perf_event_attr *attr,
742+ struct parse_events_term *term,
743+ struct parse_events_error *err);
744+
745+static int config_term_common(struct perf_event_attr *attr,
746+ struct parse_events_term *term,
747+ struct parse_events_error *err)
571748 {
572749 #define CHECK_TYPE_VAL(type) \
573750 do { \
@@ -576,12 +753,6 @@ do { \ · 2 unmodified lines
576753 } while (0)
577754
578755 switch (term->type_term) {
579− case PARSE_EVENTS__TERM_TYPE_USER:
580− /*
581− * Always succeed for sysfs terms, as we dont know
582− * at this point what type they need to have.
583− */
584− return 0;
585756 case PARSE_EVENTS__TERM_TYPE_CONFIG:
586757 CHECK_TYPE_VAL(NUM);
587758 attr->config = term->val.num;
@@ -620,10 +791,19 @@ do { \ · 32 unmodified lines
620791 case PARSE_EVENTS__TERM_TYPE_STACKSIZE:
621792 CHECK_TYPE_VAL(NUM);
622793 break;
794+ case PARSE_EVENTS__TERM_TYPE_INHERIT:
795+ CHECK_TYPE_VAL(NUM);
796+ break;
797+ case PARSE_EVENTS__TERM_TYPE_NOINHERIT:
798+ CHECK_TYPE_VAL(NUM);
799+ break;
623800 case PARSE_EVENTS__TERM_TYPE_NAME:
624801 CHECK_TYPE_VAL(STR);
625802 break;
626803 default:
804+ err->str = strdup("unknown term");
805+ err->idx = term->err_term;
806+ err->help = parse_events_formats_error_string(NULL);
627807 return -EINVAL;
628808 }
629809
@@ -631,9 +811,46 @@ do { \ · 1 unmodified line
631811 #undef CHECK_TYPE_VAL
632812 }
633813
814+static int config_term_pmu(struct perf_event_attr *attr,
815+ struct parse_events_term *term,
816+ struct parse_events_error *err)
817+{
818+ if (term->type_term == PARSE_EVENTS__TERM_TYPE_USER)
819+ /*
820+ * Always succeed for sysfs terms, as we dont know
821+ * at this point what type they need to have.
822+ */
823+ return 0;
824+ else
825+ return config_term_common(attr, term, err);
826+}
827+
828+static int config_term_tracepoint(struct perf_event_attr *attr,
829+ struct parse_events_term *term,
830+ struct parse_events_error *err)
831+{
832+ switch (term->type_term) {
833+ case PARSE_EVENTS__TERM_TYPE_CALLGRAPH:
834+ case PARSE_EVENTS__TERM_TYPE_STACKSIZE:
835+ case PARSE_EVENTS__TERM_TYPE_INHERIT:
836+ case PARSE_EVENTS__TERM_TYPE_NOINHERIT:
837+ return config_term_common(attr, term, err);
838+ default:
839+ if (err) {
840+ err->idx = term->err_term;
841+ err->str = strdup("unknown term");
842+ err->help = strdup("valid terms: call-graph,stack-size\n");
843+ }
844+ return -EINVAL;
845+ }
846+
847+ return 0;
848+}
849+
634850 static int config_attr(struct perf_event_attr *attr,
635851 struct list_head *head,
636− struct parse_events_error *err)
852+ struct parse_events_error *err,
853+ config_term_func_t config_term)
637854 {
638855 struct parse_events_term *term;
639856
@@ -680,6 +897,12 @@ do { \ · 40 unmodified lines
680897 case PARSE_EVENTS__TERM_TYPE_STACKSIZE:
681898 ADD_CONFIG_TERM(STACK_USER, stack_user, term->val.num);
682899 break;
900+ case PARSE_EVENTS__TERM_TYPE_INHERIT:
901+ ADD_CONFIG_TERM(INHERIT, inherit, term->val.num ? 1 : 0);
902+ break;
903+ case PARSE_EVENTS__TERM_TYPE_NOINHERIT:
904+ ADD_CONFIG_TERM(INHERIT, inherit, term->val.num ? 0 : 1);
905+ break;
683906 default:
684907 break;
685908 }
@@ -688,6 +911,27 @@ do { \ · 2 unmodified lines
688911 return 0;
689912 }
690913
914+int parse_events_add_tracepoint(struct list_head *list, int *idx,
915+ char *sys, char *event,
916+ struct parse_events_error *err,
917+ struct list_head *head_config)
918+{
919+ if (head_config) {
920+ struct perf_event_attr attr;
921+
922+ if (config_attr(&attr, head_config, err,
923+ config_term_tracepoint))
924+ return -EINVAL;
925+ }
926+
927+ if (strpbrk(sys, "*?"))
928+ return add_tracepoint_multi_sys(list, idx, sys, event,
929+ err, head_config);
930+ else
931+ return add_tracepoint_event(list, idx, sys, event,
932+ err, head_config);
933+}
934+
691935 int parse_events_add_numeric(struct parse_events_evlist *data,
692936 struct list_head *list,
693937 u32 type, u64 config,
@@ -701,7 +945,8 @@ int parse_events_add_numeric(struct parse_events_evlist *data, · 7 unmodified lines
701945 attr.config = config;
702946
703947 if (head_config) {
704− if (config_attr(&attr, head_config, data->error))
948+ if (config_attr(&attr, head_config, data->error,
949+ config_term_common))
705950 return -EINVAL;
706951
707952 if (get_config_terms(head_config, &config_terms))
@@ -761,7 +1006,7 @@ int parse_events_add_pmu(struct parse_events_evlist *data, · 53 unmodified lines
7611006 * Configure hardcoded terms first, no need to check
7621007 * return value when called with fail == 0 ;)
7631008 */
764− if (config_attr(&attr, head_config, data->error))
1009+ if (config_attr(&attr, head_config, data->error, config_term_pmu))
7651010 return -EINVAL;
7661011
7671012 if (get_config_terms(head_config, &config_terms))
@@ -793,6 +1038,11 @@ void parse_events__set_leader(char *name, struct list_head *list) · 25 unmodified lines
7931038 {
7941039 struct perf_evsel *leader;
7951040
1041+ if (list_empty(list)) {
1042+ WARN_ONCE(true, "WARNING: failed to set leader: empty list");
1043+ return;
1044+ }
1045+
7961046 __perf_evlist__set_leader(list);
7971047 leader = list_entry(list->next, struct perf_evsel, node);
7981048 leader->group_name = name ? strdup(name) : NULL;
@@ -819,6 +1069,7 @@ struct event_modifier { · 20 unmodified lines
8191069 int eG;
8201070 int eI;
8211071 int precise;
1072+ int precise_max;
8221073 int exclude_GH;
8231074 int sample_read;
8241075 int pinned;
@@ -834,6 +1085,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str, · 9 unmodified lines
8341085 int eG = evsel ? evsel->attr.exclude_guest : 0;
8351086 int eI = evsel ? evsel->attr.exclude_idle : 0;
8361087 int precise = evsel ? evsel->attr.precise_ip : 0;
1088+ int precise_max = 0;
8371089 int sample_read = 0;
8381090 int pinned = evsel ? evsel->attr.pinned : 0;
8391091
@@ -870,6 +1122,8 @@ static int get_event_modifier(struct event_modifier *mod, char *str, · 30 unmodified lines
8701122 /* use of precise requires exclude_guest */
8711123 if (!exclude_GH)
8721124 eG = 1;
1125+ } else if (*str == 'P') {
1126+ precise_max = 1;
8731127 } else if (*str == 'S') {
8741128 sample_read = 1;
8751129 } else if (*str == 'D') {
@@ -900,6 +1154,7 @@ static int get_event_modifier(struct event_modifier *mod, char *str, · 24 unmodified lines
9001154 mod->eG = eG;
9011155 mod->eI = eI;
9021156 mod->precise = precise;
1157+ mod->precise_max = precise_max;
9031158 mod->exclude_GH = exclude_GH;
9041159 mod->sample_read = sample_read;
9051160 mod->pinned = pinned;
@@ -916,7 +1171,7 @@ static int check_modifier(char *str) · 10 unmodified lines
9161171 char *p = str;
9171172
9181173 /* The sizeof includes 0 byte as well. */
919− if (strlen(str) > (sizeof("ukhGHpppSDI") - 1))
1174+ if (strlen(str) > (sizeof("ukhGHpppPSDI") - 1))
9201175 return -1;
9211176
9221177 while (*p) {
@@ -955,6 +1210,7 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add) · 32 unmodified lines
9551210 evsel->attr.exclude_idle = mod.eI;
9561211 evsel->exclude_GH = mod.exclude_GH;
9571212 evsel->sample_read = mod.sample_read;
1213+ evsel->precise_max = mod.precise_max;
9581214
9591215 if (perf_evsel__is_group_leader(evsel))
9601216 evsel->attr.pinned = mod.pinned;
@@ -1142,6 +1398,11 @@ int parse_events(struct perf_evlist *evlist, const char *str, · 181 unmodified lines
11421398 if (!ret) {
11431399 struct perf_evsel *last;
11441400
1401+ if (list_empty(&data.list)) {
1402+ WARN_ONCE(true, "WARNING: event parser found nothing");
1403+ return -1;
1404+ }
1405+
11451406 perf_evlist__splice_list_tail(evlist, &data.list);
11461407 evlist->nr_groups += data.nr_groups;
11471408 last = perf_evlist__last(evlist);
@@ -1251,6 +1512,12 @@ foreach_evsel_in_last_glob(struct perf_evlist *evlist, · 103 unmodified lines
12511512 struct perf_evsel *last = NULL;
12521513 int err;
12531514
1515+ /*
1516+ * Don't return when list_empty, give func a chance to report
1517+ * error when it found last == NULL.
1518+ *
1519+ * So no need to WARN here, let *func do this.
1520+ */
12541521 if (evlist->nr_entries > 0)
12551522 last = perf_evlist__last(evlist);
12561523
@@ -1419,7 +1686,7 @@ restart: · 162 unmodified lines
14191686 printf(" %-50s [%s]\n", evt_list[evt_i++],
14201687 event_type_descriptors[PERF_TYPE_TRACEPOINT]);
14211688 }
1422− if (evt_num)
1689+ if (evt_num && pager_in_use())
14231690 printf("\n");
14241691
14251692 out_free:
@@ -1575,7 +1842,7 @@ restart: · 149 unmodified lines
15751842 printf(" %-50s [%s]\n", evt_list[evt_i++],
15761843 event_type_descriptors[PERF_TYPE_HW_CACHE]);
15771844 }
1578− if (evt_num)
1845+ if (evt_num && pager_in_use())
15791846 printf("\n");
15801847
15811848 out_free:
@@ -1648,7 +1915,7 @@ restart: · 66 unmodified lines
16481915 }
16491916 printf(" %-50s [%s]\n", evt_list[evt_i++], event_type_descriptors[type]);
16501917 }
1651− if (evt_num)
1918+ if (evt_num && pager_in_use())
16521919 printf("\n");
16531920
16541921 out_free:
@@ -1689,13 +1956,14 @@ void print_events(const char *event_glob, bool name_only) · 34 unmodified lines
16891956 printf(" %-50s [%s]\n",
16901957 "cpu/t1=v1[,t2=v2,t3 ...]/modifier",
16911958 event_type_descriptors[PERF_TYPE_RAW]);
1692− printf(" (see 'man perf-list' on how to encode it)\n");
1693− printf("\n");
1959+ if (pager_in_use())
1960+ printf(" (see 'man perf-list' on how to encode it)\n\n");
16941961
16951962 printf(" %-50s [%s]\n",
16961963 "mem:<addr>[/len][:access]",
16971964 event_type_descriptors[PERF_TYPE_BREAKPOINT]);
1698− printf("\n");
1965+ if (pager_in_use())
1966+ printf("\n");
16991967 }
17001968
17011969 print_tracepoint_events(NULL, NULL, name_only);
@@ -1811,3 +2079,29 @@ void parse_events_evlist_error(struct parse_events_evlist *data, · 109 unmodified lines
18112079 err->str = strdup(str);
18122080 WARN_ONCE(!err->str, "WARNING: failed to allocate error string");
18132081 }
2082+
2083+/*
2084+ * Return string contains valid config terms of an event.
2085+ * @additional_terms: For terms such as PMU sysfs terms.
2086+ */
2087+char *parse_events_formats_error_string(char *additional_terms)
2088+{
2089+ char *str;
2090+ static const char *static_terms = "config,config1,config2,name,"
2091+ "period,freq,branch_type,time,"
2092+ "call-graph,stack-size\n";
2093+
2094+ /* valid terms */
2095+ if (additional_terms) {
2096+ if (!asprintf(&str, "valid terms: %s,%s",
2097+ additional_terms, static_terms))
2098+ goto fail;
2099+ } else {
2100+ if (!asprintf(&str, "valid terms: %s", static_terms))
2101+ goto fail;
2102+ }
2103+ return str;
2104+
2105+fail:
2106+ return NULL;
2107+}
tools/perf/util/parse-events.h+15−1
@@ -67,6 +67,8 @@ enum { · 66 unmodified lines
6767 PARSE_EVENTS__TERM_TYPE_TIME,
6868 PARSE_EVENTS__TERM_TYPE_CALLGRAPH,
6969 PARSE_EVENTS__TERM_TYPE_STACKSIZE,
70+ PARSE_EVENTS__TERM_TYPE_NOINHERIT,
71+ PARSE_EVENTS__TERM_TYPE_INHERIT
7072 };
7173
7274 struct parse_events_term {
@@ -118,7 +120,18 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add); · 45 unmodified lines
118120 int parse_events__modifier_group(struct list_head *list, char *event_mod);
119121 int parse_events_name(struct list_head *list, char *name);
120122 int parse_events_add_tracepoint(struct list_head *list, int *idx,
121− char *sys, char *event);
123+ char *sys, char *event,
124+ struct parse_events_error *error,
125+ struct list_head *head_config);
126+int parse_events_load_bpf(struct parse_events_evlist *data,
127+ struct list_head *list,
128+ char *bpf_file_name,
129+ bool source);
130+/* Provide this function for perf test */
131+struct bpf_object;
132+int parse_events_load_bpf_obj(struct parse_events_evlist *data,
133+ struct list_head *list,
134+ struct bpf_object *obj);
122135 int parse_events_add_numeric(struct parse_events_evlist *data,
123136 struct list_head *list,
124137 u32 type, u64 config,
@@ -155,5 +168,6 @@ int print_hwcache_events(const char *event_glob, bool name_only); · 30 unmodified lines
155168 extern int is_valid_tracepoint(const char *event_string);
156169
157170 int valid_event_mount(const char *eventfs);
171+char *parse_events_formats_error_string(char *additional_terms);
158172
159173 #endif /* __PERF_PARSE_EVENTS_H */
tools/perf/util/parse-events.l+10−2
@@ -115,6 +115,8 @@ do { \ · 114 unmodified lines
115115 group [^,{}/]*[{][^}]*[}][^,{}/]*
116116 event_pmu [^,{}/]+[/][^/]*[/][^,{}/]*
117117 event [^,{}/]+
118+bpf_object .*\.(o|bpf)
119+bpf_source .*\.c
118120
119121 num_dec [0-9]+
120122 num_hex 0x[a-fA-F0-9]+
@@ -122,7 +124,7 @@ num_raw_hex [a-fA-F0-9]+ · 1 unmodified line
122124 name [a-zA-Z_*?][a-zA-Z0-9_*?.]*
123125 name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.]*
124126 /* If you add a modifier you need to update check_modifier() */
125−modifier_event [ukhpGHSDI]+
127+modifier_event [ukhpPGHSDI]+
126128 modifier_bp [rwx]{1,3}
127129
128130 %%
@@ -159,6 +161,8 @@ modifier_bp [rwx]{1,3} · 30 unmodified lines
159161 }
160162
161163 {event_pmu} |
164+{bpf_object} |
165+{bpf_source} |
162166 {event} {
163167 BEGIN(INITIAL);
164168 REWIND(1);
@@ -174,7 +178,7 @@ modifier_bp [rwx]{1,3} · 9 unmodified lines
174178
175179 <config>{
176180 /*
177− * Please update formats_error_string any time
181+ * Please update parse_events_formats_error_string any time
178182 * new static term is added.
179183 */
180184 config { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); }
@@ -187,6 +191,8 @@ branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE · 6 unmodified lines
187191 time { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); }
188192 call-graph { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CALLGRAPH); }
189193 stack-size { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_STACKSIZE); }
194+inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_INHERIT); }
195+no-inherit { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOINHERIT); }
190196 , { return ','; }
191197 "/" { BEGIN(INITIAL); return '/'; }
192198 {name_minus} { return str(yyscanner, PE_NAME); }
@@ -264,6 +270,8 @@ r{num_raw_hex} { return raw(yyscanner); } · 71 unmodified lines
264270 {num_hex} { return value(yyscanner, 16); }
265271
266272 {modifier_event} { return str(yyscanner, PE_MODIFIER_EVENT); }
273+{bpf_object} { return str(yyscanner, PE_BPF_OBJECT); }
274+{bpf_source} { return str(yyscanner, PE_BPF_SOURCE); }
267275 {name} { return pmu_str_check(yyscanner); }
268276 "/" { BEGIN(config); return '/'; }
269277 - { return '-'; }
tools/perf/util/parse-events.y+69−13
@@ -42,6 +42,7 @@ static inc_group_count(struct list_head *list, · 41 unmodified lines
4242 %token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM
4343 %token PE_EVENT_NAME
4444 %token PE_NAME
45+%token PE_BPF_OBJECT PE_BPF_SOURCE
4546 %token PE_MODIFIER_EVENT PE_MODIFIER_BP
4647 %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
4748 %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP
@@ -53,6 +54,8 @@ static inc_group_count(struct list_head *list, · 5 unmodified lines
5354 %type <num> PE_RAW
5455 %type <num> PE_TERM
5556 %type <str> PE_NAME
57+%type <str> PE_BPF_OBJECT
58+%type <str> PE_BPF_SOURCE
5659 %type <str> PE_NAME_CACHE_TYPE
5760 %type <str> PE_NAME_CACHE_OP_RESULT
5861 %type <str> PE_MODIFIER_EVENT
@@ -67,8 +70,10 @@ static inc_group_count(struct list_head *list, · 8 unmodified lines
6770 %type <head> event_legacy_cache
6871 %type <head> event_legacy_mem
6972 %type <head> event_legacy_tracepoint
73+%type <tracepoint_name> tracepoint_name
7074 %type <head> event_legacy_numeric
7175 %type <head> event_legacy_raw
76+%type <head> event_bpf_file
7277 %type <head> event_def
7378 %type <head> event_mod
7479 %type <head> event_name
@@ -84,6 +89,10 @@ static inc_group_count(struct list_head *list, · 9 unmodified lines
8489 u64 num;
8590 struct list_head *head;
8691 struct parse_events_term *term;
92+ struct tracepoint_name {
93+ char *sys;
94+ char *event;
95+ } tracepoint_name;
8796 }
8897 %%
8998
@@ -198,7 +207,8 @@ event_def: event_pmu | · 108 unmodified lines
198207 event_legacy_mem |
199208 event_legacy_tracepoint sep_dc |
200209 event_legacy_numeric sep_dc |
201− event_legacy_raw sep_dc
210+ event_legacy_raw sep_dc |
211+ event_bpf_file
202212
203213 event_pmu:
204214 PE_NAME '/' event_config '/'
@@ -368,36 +378,60 @@ PE_PREFIX_MEM PE_VALUE sep_dc · 163 unmodified lines
368378 }
369379
370380 event_legacy_tracepoint:
371−PE_NAME '-' PE_NAME ':' PE_NAME
381+tracepoint_name
372382 {
373383 struct parse_events_evlist *data = _data;
384+ struct parse_events_error *error = data->error;
374385 struct list_head *list;
375− char sys_name[128];
376− snprintf(&sys_name, 128, "%s-%s", $1, $3);
377386
378387 ALLOC_LIST(list);
379− ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5));
388+ if (error)
389+ error->idx = @1.first_column;
390+
391+ if (parse_events_add_tracepoint(list, &data->idx, $1.sys, $1.event,
392+ error, NULL))
393+ return -1;
394+
380395 $$ = list;
381396 }
382397 |
383−PE_NAME ':' PE_NAME
398+tracepoint_name '/' event_config '/'
384399 {
385400 struct parse_events_evlist *data = _data;
401+ struct parse_events_error *error = data->error;
386402 struct list_head *list;
387403
388404 ALLOC_LIST(list);
389− if (parse_events_add_tracepoint(list, &data->idx, $1, $3)) {
390− struct parse_events_error *error = data->error;
405+ if (error)
406+ error->idx = @1.first_column;
391407
392− if (error) {
393− error->idx = @1.first_column;
394− error->str = strdup("unknown tracepoint");
395− }
408+ if (parse_events_add_tracepoint(list, &data->idx, $1.sys, $1.event,
409+ error, $3))
396410 return -1;
397− }
411+
398412 $$ = list;
399413 }
400414
415+tracepoint_name:
416+PE_NAME '-' PE_NAME ':' PE_NAME
417+{
418+ char sys_name[128];
419+ struct tracepoint_name tracepoint;
420+
421+ snprintf(&sys_name, 128, "%s-%s", $1, $3);
422+ tracepoint.sys = &sys_name;
423+ tracepoint.event = $5;
424+
425+ $$ = tracepoint;
426+}
427+|
428+PE_NAME ':' PE_NAME
429+{
430+ struct tracepoint_name tracepoint = {$1, $3};
431+
432+ $$ = tracepoint;
433+}
434+
401435 event_legacy_numeric:
402436 PE_VALUE ':' PE_VALUE
403437 {
@@ -420,6 +454,28 @@ PE_RAW · 16 unmodified lines
420454 $$ = list;
421455 }
422456
457+event_bpf_file:
458+PE_BPF_OBJECT
459+{
460+ struct parse_events_evlist *data = _data;
461+ struct parse_events_error *error = data->error;
462+ struct list_head *list;
463+
464+ ALLOC_LIST(list);
465+ ABORT_ON(parse_events_load_bpf(data, list, $1, false));
466+ $$ = list;
467+}
468+|
469+PE_BPF_SOURCE
470+{
471+ struct parse_events_evlist *data = _data;
472+ struct list_head *list;
473+
474+ ALLOC_LIST(list);
475+ ABORT_ON(parse_events_load_bpf(data, list, $1, true));
476+ $$ = list;
477+}
478+
423479 start_terms: event_config
424480 {
425481 struct parse_events_terms *data = _data;
tools/perf/util/parse-options.c+133−23
@@ -2,10 +2,13 @@ · 1 unmodified line
22 #include "parse-options.h"
33 #include "cache.h"
44 #include "header.h"
5+#include <linux/string.h>
56
67 #define OPT_SHORT 1
78 #define OPT_UNSET 2
89
10+static struct strbuf error_buf = STRBUF_INIT;
11+
912 static int opterror(const struct option *opt, const char *reason, int flags)
1013 {
1114 if (flags & OPT_SHORT)
@@ -372,7 +375,8 @@ void parse_options_start(struct parse_opt_ctx_t *ctx, · 360 unmodified lines
372375 }
373376
374377 static int usage_with_options_internal(const char * const *,
375− const struct option *, int);
378+ const struct option *, int,
379+ struct parse_opt_ctx_t *);
376380
377381 int parse_options_step(struct parse_opt_ctx_t *ctx,
378382 const struct option *options,
@@ -396,8 +400,9 @@ int parse_options_step(struct parse_opt_ctx_t *ctx, · 17 unmodified lines
396400
397401 if (arg[1] != '-') {
398402 ctx->opt = ++arg;
399− if (internal_help && *ctx->opt == 'h')
400− return usage_with_options_internal(usagestr, options, 0);
403+ if (internal_help && *ctx->opt == 'h') {
404+ return usage_with_options_internal(usagestr, options, 0, ctx);
405+ }
401406 switch (parse_short_opt(ctx, options)) {
402407 case -1:
403408 return parse_options_usage(usagestr, options, arg, 1);
@@ -412,7 +417,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx, · 8 unmodified lines
412417 check_typos(arg, options);
413418 while (ctx->opt) {
414419 if (internal_help && *ctx->opt == 'h')
415− return usage_with_options_internal(usagestr, options, 0);
420+ return usage_with_options_internal(usagestr, options, 0, ctx);
416421 arg = ctx->opt;
417422 switch (parse_short_opt(ctx, options)) {
418423 case -1:
@@ -445,9 +450,9 @@ int parse_options_step(struct parse_opt_ctx_t *ctx, · 26 unmodified lines
445450
446451 arg += 2;
447452 if (internal_help && !strcmp(arg, "help-all"))
448− return usage_with_options_internal(usagestr, options, 1);
453+ return usage_with_options_internal(usagestr, options, 1, ctx);
449454 if (internal_help && !strcmp(arg, "help"))
450− return usage_with_options_internal(usagestr, options, 0);
455+ return usage_with_options_internal(usagestr, options, 0, ctx);
451456 if (!strcmp(arg, "list-opts"))
452457 return PARSE_OPT_LIST_OPTS;
453458 if (!strcmp(arg, "list-cmds"))
@@ -496,7 +501,7 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o · 42 unmodified lines
496501 {
497502 struct parse_opt_ctx_t ctx;
498503
499− perf_header__set_cmdline(argc, argv);
504+ perf_env__set_cmdline(&perf_env, argc, argv);
500505
501506 /* build usage string if it's not provided */
502507 if (subcommands && !usagestr[0]) {
@@ -537,9 +542,11 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o · 34 unmodified lines
537542 exit(130);
538543 default: /* PARSE_OPT_UNKNOWN */
539544 if (ctx.argv[0][1] == '-') {
540− error("unknown option `%s'", ctx.argv[0] + 2);
545+ strbuf_addf(&error_buf, "unknown option `%s'",
546+ ctx.argv[0] + 2);
541547 } else {
542− error("unknown switch `%c'", *ctx.opt);
548+ strbuf_addf(&error_buf, "unknown switch `%c'",
549+ *ctx.opt);
543550 }
544551 usage_with_options(usagestr, options);
545552 }
@@ -642,13 +649,93 @@ static void print_option_help(const struct option *opts, int full) · 96 unmodified lines
642649 fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
643650 }
644651
652+static int option__cmp(const void *va, const void *vb)
653+{
654+ const struct option *a = va, *b = vb;
655+ int sa = tolower(a->short_name), sb = tolower(b->short_name), ret;
656+
657+ if (sa == 0)
658+ sa = 'z' + 1;
659+ if (sb == 0)
660+ sb = 'z' + 1;
661+
662+ ret = sa - sb;
663+
664+ if (ret == 0) {
665+ const char *la = a->long_name ?: "",
666+ *lb = b->long_name ?: "";
667+ ret = strcmp(la, lb);
668+ }
669+
670+ return ret;
671+}
672+
673+static struct option *options__order(const struct option *opts)
674+{
675+ int nr_opts = 0;
676+ const struct option *o = opts;
677+ struct option *ordered;
678+
679+ for (o = opts; o->type != OPTION_END; o++)
680+ ++nr_opts;
681+
682+ ordered = memdup(opts, sizeof(*o) * (nr_opts + 1));
683+ if (ordered == NULL)
684+ goto out;
685+
686+ qsort(ordered, nr_opts, sizeof(*o), option__cmp);
687+out:
688+ return ordered;
689+}
690+
691+static bool option__in_argv(const struct option *opt, const struct parse_opt_ctx_t *ctx)
692+{
693+ int i;
694+
695+ for (i = 1; i < ctx->argc; ++i) {
696+ const char *arg = ctx->argv[i];
697+
698+ if (arg[0] != '-') {
699+ if (arg[1] == '\0') {
700+ if (arg[0] == opt->short_name)
701+ return true;
702+ continue;
703+ }
704+
705+ if (opt->long_name && strcmp(opt->long_name, arg) == 0)
706+ return true;
707+
708+ if (opt->help && strcasestr(opt->help, arg) != NULL)
709+ return true;
710+
711+ continue;
712+ }
713+
714+ if (arg[1] == opt->short_name ||
715+ (arg[1] == '-' && opt->long_name && strcmp(opt->long_name, arg + 2) == 0))
716+ return true;
717+ }
718+
719+ return false;
720+}
721+
645722 int usage_with_options_internal(const char * const *usagestr,
646− const struct option *opts, int full)
723+ const struct option *opts, int full,
724+ struct parse_opt_ctx_t *ctx)
647725 {
726+ struct option *ordered;
727+
648728 if (!usagestr)
649729 return PARSE_OPT_HELP;
650730
651− fprintf(stderr, "\n usage: %s\n", *usagestr++);
731+ setup_pager();
732+
733+ if (strbuf_avail(&error_buf)) {
734+ fprintf(stderr, " Error: %s\n", error_buf.buf);
735+ strbuf_release(&error_buf);
736+ }
737+
738+ fprintf(stderr, "\n Usage: %s\n", *usagestr++);
652739 while (*usagestr && **usagestr)
653740 fprintf(stderr, " or: %s\n", *usagestr++);
654741 while (*usagestr) {
@@ -661,11 +748,20 @@ int usage_with_options_internal(const char * const *usagestr, · 6 unmodified lines
661748 if (opts->type != OPTION_GROUP)
662749 fputc('\n', stderr);
663750
664− for ( ; opts->type != OPTION_END; opts++)
751+ ordered = options__order(opts);
752+ if (ordered)
753+ opts = ordered;
754+
755+ for ( ; opts->type != OPTION_END; opts++) {
756+ if (ctx && ctx->argc > 1 && !option__in_argv(opts, ctx))
757+ continue;
665758 print_option_help(opts, full);
759+ }
666760
667761 fputc('\n', stderr);
668762
763+ free(ordered);
764+
669765 return PARSE_OPT_HELP;
670766 }
671767
@@ -673,7 +769,22 @@ void usage_with_options(const char * const *usagestr, · 1 unmodified line
673769 const struct option *opts)
674770 {
675771 exit_browser(false);
676− usage_with_options_internal(usagestr, opts, 0);
772+ usage_with_options_internal(usagestr, opts, 0, NULL);
773+ exit(129);
774+}
775+
776+void usage_with_options_msg(const char * const *usagestr,
777+ const struct option *opts, const char *fmt, ...)
778+{
779+ va_list ap;
780+
781+ exit_browser(false);
782+
783+ va_start(ap, fmt);
784+ strbuf_addv(&error_buf, fmt, ap);
785+ va_end(ap);
786+
787+ usage_with_options_internal(usagestr, opts, 0, NULL);
677788 exit(129);
678789 }
679790
@@ -684,7 +795,7 @@ int parse_options_usage(const char * const *usagestr, · 4 unmodified lines
684795 if (!usagestr)
685796 goto opt;
686797
687− fprintf(stderr, "\n usage: %s\n", *usagestr++);
798+ fprintf(stderr, "\n Usage: %s\n", *usagestr++);
688799 while (*usagestr && **usagestr)
689800 fprintf(stderr, " or: %s\n", *usagestr++);
690801 while (*usagestr) {
@@ -698,24 +809,23 @@ int parse_options_usage(const char * const *usagestr, · 7 unmodified lines
698809 opt:
699810 for ( ; opts->type != OPTION_END; opts++) {
700811 if (short_opt) {
701− if (opts->short_name == *optstr)
812+ if (opts->short_name == *optstr) {
813+ print_option_help(opts, 0);
702814 break;
815+ }
703816 continue;
704817 }
705818
706819 if (opts->long_name == NULL)
707820 continue;
708821
709− if (!prefixcmp(optstr, opts->long_name))
710− break;
711− if (!prefixcmp(optstr, "no-") &&
712− !prefixcmp(optstr + 3, opts->long_name))
713− break;
822+ if (!prefixcmp(opts->long_name, optstr))
823+ print_option_help(opts, 0);
824+ if (!prefixcmp("no-", optstr) &&
825+ !prefixcmp(opts->long_name, optstr + 3))
826+ print_option_help(opts, 0);
714827 }
715828
716− if (opts->type != OPTION_END)
717− print_option_help(opts, 0);
718−
719829 return PARSE_OPT_HELP;
720830 }
721831
tools/perf/util/parse-options.h+5−0
@@ -111,6 +111,7 @@ struct option { · 110 unmodified lines
111111 #define OPT_GROUP(h) { .type = OPTION_GROUP, .help = (h) }
112112 #define OPT_BIT(s, l, v, h, b) { .type = OPTION_BIT, .short_name = (s), .long_name = (l), .value = check_vtype(v, int *), .help = (h), .defval = (b) }
113113 #define OPT_BOOLEAN(s, l, v, h) { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), .value = check_vtype(v, bool *), .help = (h) }
114+#define OPT_BOOLEAN_FLAG(s, l, v, h, f) { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), .value = check_vtype(v, bool *), .help = (h), .flags = (f) }
114115 #define OPT_BOOLEAN_SET(s, l, v, os, h) \
115116 { .type = OPTION_BOOLEAN, .short_name = (s), .long_name = (l), \
116117 .value = check_vtype(v, bool *), .help = (h), \
@@ -160,6 +161,10 @@ extern int parse_options_subcommand(int argc, const char **argv, · 43 unmodified lines
160161
161162 extern NORETURN void usage_with_options(const char * const *usagestr,
162163 const struct option *options);
164+extern NORETURN __attribute__((format(printf,3,4)))
165+void usage_with_options_msg(const char * const *usagestr,
166+ const struct option *options,
167+ const char *fmt, ...);
163168
164169 /*----- incremantal advanced APIs -----*/
165170
tools/perf/util/pmu.c+17−25
@@ -626,38 +626,26 @@ static int pmu_resolve_param_term(struct parse_events_term *term, · 625 unmodified lines
626626 return -1;
627627 }
628628
629−static char *formats_error_string(struct list_head *formats)
629+static char *pmu_formats_string(struct list_head *formats)
630630 {
631631 struct perf_pmu_format *format;
632− char *err, *str;
633− static const char *static_terms = "config,config1,config2,name,"
634− "period,freq,branch_type,time,"
635− "call-graph,stack-size\n";
632+ char *str;
633+ struct strbuf buf;
636634 unsigned i = 0;
637635
638− if (!asprintf(&str, "valid terms:"))
636+ if (!formats)
639637 return NULL;
640638
639+ strbuf_init(&buf, 0);
641640 /* sysfs exported terms */
642− list_for_each_entry(format, formats, list) {
643− char c = i++ ? ',' : ' ';
644−
645− err = str;
646− if (!asprintf(&str, "%s%c%s", err, c, format->name))
647− goto fail;
648− free(err);
649− }
641+ list_for_each_entry(format, formats, list)
642+ strbuf_addf(&buf, i++ ? ",%s" : "%s",
643+ format->name);
650644
651− /* static terms */
652− err = str;
653− if (!asprintf(&str, "%s,%s", err, static_terms))
654− goto fail;
645+ str = strbuf_detach(&buf, NULL);
646+ strbuf_release(&buf);
655647
656− free(err);
657648 return str;
658−fail:
659− free(err);
660− return NULL;
661649 }
662650
663651 /*
@@ -693,9 +681,12 @@ static int pmu_config_term(struct list_head *formats, · 29 unmodified lines
693681 if (verbose)
694682 printf("Invalid event/parameter '%s'\n", term->config);
695683 if (err) {
684+ char *pmu_term = pmu_formats_string(formats);
685+
696686 err->idx = term->err_term;
697687 err->str = strdup("unknown term");
698− err->help = formats_error_string(formats);
688+ err->help = parse_events_formats_error_string(pmu_term);
689+ free(pmu_term);
699690 }
700691 return -EINVAL;
701692 }
@@ -1017,7 +1008,8 @@ void print_pmu_events(const char *event_glob, bool name_only) · 315 unmodified lines
10171008 goto out_enomem;
10181009 j++;
10191010 }
1020− if (pmu->selectable) {
1011+ if (pmu->selectable &&
1012+ (event_glob == NULL || strglobmatch(pmu->name, event_glob))) {
10211013 char *s;
10221014 if (asprintf(&s, "%s//", pmu->name) < 0)
10231015 goto out_enomem;
@@ -1035,7 +1027,7 @@ void print_pmu_events(const char *event_glob, bool name_only) · 11 unmodified lines
10351027 printf(" %-50s [Kernel PMU event]\n", aliases[j]);
10361028 printed++;
10371029 }
1038− if (printed)
1030+ if (printed && pager_in_use())
10391031 printf("\n");
10401032 out_free:
10411033 for (j = 0; j < len; j++)
tools/perf/util/probe-event.c+122−112
@@ -40,8 +40,7 @@ · 39 unmodified lines
4040 #include "color.h"
4141 #include "symbol.h"
4242 #include "thread.h"
43−#include <api/fs/debugfs.h>
44−#include <api/fs/tracefs.h>
43+#include <api/fs/fs.h>
4544 #include "trace-event.h" /* For __maybe_unused */
4645 #include "probe-event.h"
4746 #include "probe-finder.h"
@@ -72,7 +71,7 @@ static char *synthesize_perf_probe_point(struct perf_probe_point *pp); · 24 unmodified lines
7271 static struct machine *host_machine;
7372
7473 /* Initialize symbol maps and path of vmlinux/modules */
75−static int init_symbol_maps(bool user_only)
74+int init_probe_symbol_maps(bool user_only)
7675 {
7776 int ret;
7877
@@ -102,7 +101,7 @@ out: · 23 unmodified lines
102101 return ret;
103102 }
104103
105−static void exit_symbol_maps(void)
104+void exit_probe_symbol_maps(void)
106105 {
107106 if (host_machine) {
108107 machine__delete(host_machine);
@@ -127,17 +126,19 @@ static struct ref_reloc_sym *kernel_get_ref_reloc_sym(void) · 18 unmodified lines
127126 {
128127 /* kmap->ref_reloc_sym should be set if host_machine is initialized */
129128 struct kmap *kmap;
129+ struct map *map = machine__kernel_map(host_machine);
130130
131− if (map__load(host_machine->vmlinux_maps[MAP__FUNCTION], NULL) < 0)
131+ if (map__load(map, NULL) < 0)
132132 return NULL;
133133
134− kmap = map__kmap(host_machine->vmlinux_maps[MAP__FUNCTION]);
134+ kmap = map__kmap(map);
135135 if (!kmap)
136136 return NULL;
137137 return kmap->ref_reloc_sym;
138138 }
139139
140−static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
140+static int kernel_get_symbol_address_by_name(const char *name, u64 *addr,
141+ bool reloc, bool reladdr)
141142 {
142143 struct ref_reloc_sym *reloc_sym;
143144 struct symbol *sym;
@@ -146,12 +147,14 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc) · 2 unmodified lines
146147 /* ref_reloc_sym is just a label. Need a special fix*/
147148 reloc_sym = kernel_get_ref_reloc_sym();
148149 if (reloc_sym && strcmp(name, reloc_sym->name) == 0)
149− return (reloc) ? reloc_sym->addr : reloc_sym->unrelocated_addr;
150+ *addr = (reloc) ? reloc_sym->addr : reloc_sym->unrelocated_addr;
150151 else {
151152 sym = __find_kernel_function_by_name(name, &map);
152− if (sym)
153− return map->unmap_ip(map, sym->start) -
154− ((reloc) ? 0 : map->reloc);
153+ if (!sym)
154+ return -ENOENT;
155+ *addr = map->unmap_ip(map, sym->start) -
156+ ((reloc) ? 0 : map->reloc) -
157+ ((reladdr) ? map->start : 0);
155158 }
156159 return 0;
157160 }
@@ -245,12 +248,14 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs) · 87 unmodified lines
245248 static bool kprobe_blacklist__listed(unsigned long address);
246249 static bool kprobe_warn_out_range(const char *symbol, unsigned long address)
247250 {
248− u64 etext_addr;
251+ u64 etext_addr = 0;
252+ int ret;
249253
250254 /* Get the address of _etext for checking non-probable text symbol */
251− etext_addr = kernel_get_symbol_address_by_name("_etext", false);
255+ ret = kernel_get_symbol_address_by_name("_etext", &etext_addr,
256+ false, false);
252257
253− if (etext_addr != 0 && etext_addr < address)
258+ if (ret == 0 && etext_addr < address)
254259 pr_warning("%s is out of .text, skip it.\n", symbol);
255260 else if (kprobe_blacklist__listed(address))
256261 pr_warning("%s is blacklisted function, skip it.\n", symbol);
@@ -282,7 +287,7 @@ static int kernel_get_module_dso(const char *module, struct dso **pdso) · 25 unmodified lines
282287 return -ENOENT;
283288 }
284289
285− map = host_machine->vmlinux_maps[MAP__FUNCTION];
290+ map = machine__kernel_map(host_machine);
286291 dso = map->dso;
287292
288293 vmlinux_name = symbol_conf.vmlinux_name;
@@ -436,19 +441,22 @@ static char *debuginfo_cache_path; · 147 unmodified lines
436441
437442 static struct debuginfo *debuginfo_cache__open(const char *module, bool silent)
438443 {
439− if ((debuginfo_cache_path && !strcmp(debuginfo_cache_path, module)) ||
440− (!debuginfo_cache_path && !module && debuginfo_cache))
444+ const char *path = module;
445+
446+ /* If the module is NULL, it should be the kernel. */
447+ if (!module)
448+ path = "kernel";
449+
450+ if (debuginfo_cache_path && !strcmp(debuginfo_cache_path, path))
441451 goto out;
442452
443453 /* Copy module path */
444454 free(debuginfo_cache_path);
445− if (module) {
446− debuginfo_cache_path = strdup(module);
447− if (!debuginfo_cache_path) {
448− debuginfo__delete(debuginfo_cache);
449− debuginfo_cache = NULL;
450− goto out;
451− }
455+ debuginfo_cache_path = strdup(path);
456+ if (!debuginfo_cache_path) {
457+ debuginfo__delete(debuginfo_cache);
458+ debuginfo_cache = NULL;
459+ goto out;
452460 }
453461
454462 debuginfo_cache = open_debuginfo(module, silent);
@@ -517,8 +525,10 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp, · 62 unmodified lines
517525 goto error;
518526 addr += stext;
519527 } else if (tp->symbol) {
520− addr = kernel_get_symbol_address_by_name(tp->symbol, false);
521− if (addr == 0)
528+ /* If the module is given, this returns relative address */
529+ ret = kernel_get_symbol_address_by_name(tp->symbol, &addr,
530+ false, !!tp->module);
531+ if (ret != 0)
522532 goto error;
523533 addr += tp->offset;
524534 }
@@ -861,11 +871,11 @@ int show_line_range(struct line_range *lr, const char *module, bool user) · 336 unmodified lines
861871 {
862872 int ret;
863873
864− ret = init_symbol_maps(user);
874+ ret = init_probe_symbol_maps(user);
865875 if (ret < 0)
866876 return ret;
867877 ret = __show_line_range(lr, module, user);
868− exit_symbol_maps();
878+ exit_probe_symbol_maps();
869879
870880 return ret;
871881 }
@@ -943,7 +953,7 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs, · 71 unmodified lines
943953 int i, ret = 0;
944954 struct debuginfo *dinfo;
945955
946− ret = init_symbol_maps(pevs->uprobes);
956+ ret = init_probe_symbol_maps(pevs->uprobes);
947957 if (ret < 0)
948958 return ret;
949959
@@ -960,7 +970,7 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs, · 10 unmodified lines
960970
961971 debuginfo__delete(dinfo);
962972 out:
963− exit_symbol_maps();
973+ exit_probe_symbol_maps();
964974 return ret;
965975 }
966976
@@ -1884,8 +1894,12 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp, · 917 unmodified lines
18841894 goto out;
18851895 sym = map__find_symbol(map, addr, NULL);
18861896 } else {
1887− if (tp->symbol)
1888− addr = kernel_get_symbol_address_by_name(tp->symbol, true);
1897+ if (tp->symbol && !addr) {
1898+ ret = kernel_get_symbol_address_by_name(tp->symbol,
1899+ &addr, true, false);
1900+ if (ret < 0)
1901+ goto out;
1902+ }
18891903 if (addr) {
18901904 addr += tp->offset;
18911905 sym = __find_kernel_function(addr, &map);
@@ -2055,7 +2069,7 @@ static void kprobe_blacklist__delete(struct list_head *blacklist) · 163 unmodified lines
20552069 static int kprobe_blacklist__load(struct list_head *blacklist)
20562070 {
20572071 struct kprobe_blacklist_node *node;
2058− const char *__debugfs = debugfs_find_mountpoint();
2072+ const char *__debugfs = debugfs__mountpoint();
20592073 char buf[PATH_MAX], *p;
20602074 FILE *fp;
20612075 int ret;
@@ -2181,9 +2195,9 @@ out: · 119 unmodified lines
21812195 }
21822196
21832197 /* Show an event */
2184−static int show_perf_probe_event(const char *group, const char *event,
2185− struct perf_probe_event *pev,
2186− const char *module, bool use_stdout)
2198+int show_perf_probe_event(const char *group, const char *event,
2199+ struct perf_probe_event *pev,
2200+ const char *module, bool use_stdout)
21872201 {
21882202 struct strbuf buf = STRBUF_INIT;
21892203 int ret;
@@ -2264,7 +2278,7 @@ int show_perf_probe_events(struct strfilter *filter) · 74 unmodified lines
22642278
22652279 setup_pager();
22662280
2267− ret = init_symbol_maps(false);
2281+ ret = init_probe_symbol_maps(false);
22682282 if (ret < 0)
22692283 return ret;
22702284
@@ -2280,7 +2294,7 @@ int show_perf_probe_events(struct strfilter *filter) · 9 unmodified lines
22802294 close(kp_fd);
22812295 if (up_fd > 0)
22822296 close(up_fd);
2283− exit_symbol_maps();
2297+ exit_probe_symbol_maps();
22842298
22852299 return ret;
22862300 }
@@ -2289,36 +2303,41 @@ static int get_new_event_name(char *buf, size_t len, const char *base, · 2 unmodified lines
22892303 struct strlist *namelist, bool allow_suffix)
22902304 {
22912305 int i, ret;
2292− char *p;
2306+ char *p, *nbase;
22932307
22942308 if (*base == '.')
22952309 base++;
2310+ nbase = strdup(base);
2311+ if (!nbase)
2312+ return -ENOMEM;
2313+
2314+ /* Cut off the dot suffixes (e.g. .const, .isra)*/
2315+ p = strchr(nbase, '.');
2316+ if (p && p != nbase)
2317+ *p = '\0';
22962318
2297− /* Try no suffix */
2298− ret = e_snprintf(buf, len, "%s", base);
2319+ /* Try no suffix number */
2320+ ret = e_snprintf(buf, len, "%s", nbase);
22992321 if (ret < 0) {
23002322 pr_debug("snprintf() failed: %d\n", ret);
2301− return ret;
2323+ goto out;
23022324 }
2303− /* Cut off the postfixes (e.g. .const, .isra)*/
2304− p = strchr(buf, '.');
2305− if (p && p != buf)
2306− *p = '\0';
23072325 if (!strlist__has_entry(namelist, buf))
2308− return 0;
2326+ goto out;
23092327
23102328 if (!allow_suffix) {
23112329 pr_warning("Error: event \"%s\" already exists. "
2312− "(Use -f to force duplicates.)\n", base);
2313− return -EEXIST;
2330+ "(Use -f to force duplicates.)\n", buf);
2331+ ret = -EEXIST;
2332+ goto out;
23142333 }
23152334
23162335 /* Try to add suffix */
23172336 for (i = 1; i < MAX_EVENT_INDEX; i++) {
2318− ret = e_snprintf(buf, len, "%s_%d", base, i);
2337+ ret = e_snprintf(buf, len, "%s_%d", nbase, i);
23192338 if (ret < 0) {
23202339 pr_debug("snprintf() failed: %d\n", ret);
2321− return ret;
2340+ goto out;
23222341 }
23232342 if (!strlist__has_entry(namelist, buf))
23242343 break;
@@ -2328,6 +2347,8 @@ static int get_new_event_name(char *buf, size_t len, const char *base, · 3 unmodified lines
23282347 ret = -ERANGE;
23292348 }
23302349
2350+out:
2351+ free(nbase);
23312352 return ret;
23322353 }
23332354
@@ -2400,7 +2421,6 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, · 66 unmodified lines
24002421 {
24012422 int i, fd, ret;
24022423 struct probe_trace_event *tev = NULL;
2403− const char *event = NULL, *group = NULL;
24042424 struct strlist *namelist;
24052425
24062426 fd = probe_file__open(PF_FL_RW | (pev->uprobes ? PF_FL_UPROBE : 0));
@@ -2416,7 +2436,6 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, · 9 unmodified lines
24162436 }
24172437
24182438 ret = 0;
2419− pr_info("Added new event%s\n", (ntevs > 1) ? "s:" : ":");
24202439 for (i = 0; i < ntevs; i++) {
24212440 tev = &tevs[i];
24222441 /* Skip if the symbol is out of .text or blacklisted */
@@ -2433,13 +2452,6 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, · 10 unmodified lines
24332452 if (ret < 0)
24342453 break;
24352454
2436− /* We use tev's name for showing new events */
2437− show_perf_probe_event(tev->group, tev->event, pev,
2438− tev->point.module, false);
2439− /* Save the last valid name */
2440− event = tev->event;
2441− group = tev->group;
2442−
24432455 /*
24442456 * Probes after the first probe which comes from same
24452457 * user input are always allowed to add suffix, because
@@ -2451,13 +2463,6 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, · 5 unmodified lines
24512463 if (ret == -EINVAL && pev->uprobes)
24522464 warn_uprobe_event_compat(tev);
24532465
2454− /* Note that it is possible to skip all events because of blacklist */
2455− if (ret >= 0 && event) {
2456− /* Show how to use the event. */
2457− pr_info("\nYou can now use it in all perf tools, such as:\n\n");
2458− pr_info("\tperf record -e %s:%s -aR sleep 1\n\n", group, event);
2459− }
2460−
24612466 strlist__delete(namelist);
24622467 close_out:
24632468 close(fd);
@@ -2538,7 +2543,8 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, · 74 unmodified lines
25382543 goto out;
25392544 }
25402545
2541− if (!pev->uprobes && !pp->retprobe) {
2546+ /* Note that the symbols in the kmodule are not relocated */
2547+ if (!pev->uprobes && !pp->retprobe && !pev->target) {
25422548 reloc_sym = kernel_get_ref_reloc_sym();
25432549 if (!reloc_sym) {
25442550 pr_warning("Relocated base symbol is not found!\n");
@@ -2575,8 +2581,9 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev, · 30 unmodified lines
25752581 }
25762582 /* Add one probe point */
25772583 tp->address = map->unmap_ip(map, sym->start) + pp->offset;
2578− /* If we found a wrong one, mark it by NULL symbol */
2579− if (!pev->uprobes &&
2584+
2585+ /* Check the kprobe (not in module) is within .text */
2586+ if (!pev->uprobes && !pev->target &&
25802587 kprobe_warn_out_range(sym->name, tp->address)) {
25812588 tp->symbol = NULL; /* Skip it */
25822589 skipped++;
@@ -2760,63 +2767,71 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev, · 177 unmodified lines
27602767 return find_probe_trace_events_from_map(pev, tevs);
27612768 }
27622769
2763−struct __event_package {
2764− struct perf_probe_event *pev;
2765− struct probe_trace_event *tevs;
2766− int ntevs;
2767−};
2768−
2769−int add_perf_probe_events(struct perf_probe_event *pevs, int npevs)
2770+int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs)
27702771 {
2771− int i, j, ret;
2772− struct __event_package *pkgs;
2773−
2774− ret = 0;
2775− pkgs = zalloc(sizeof(struct __event_package) * npevs);
2776−
2777− if (pkgs == NULL)
2778− return -ENOMEM;
2779−
2780− ret = init_symbol_maps(pevs->uprobes);
2781− if (ret < 0) {
2782− free(pkgs);
2783− return ret;
2784− }
2772+ int i, ret;
27852773
27862774 /* Loop 1: convert all events */
27872775 for (i = 0; i < npevs; i++) {
2788− pkgs[i].pev = &pevs[i];
27892776 /* Init kprobe blacklist if needed */
2790− if (!pkgs[i].pev->uprobes)
2777+ if (!pevs[i].uprobes)
27912778 kprobe_blacklist__init();
27922779 /* Convert with or without debuginfo */
2793− ret = convert_to_probe_trace_events(pkgs[i].pev,
2794− &pkgs[i].tevs);
2780+ ret = convert_to_probe_trace_events(&pevs[i], &pevs[i].tevs);
27952781 if (ret < 0)
2796− goto end;
2797− pkgs[i].ntevs = ret;
2782+ return ret;
2783+ pevs[i].ntevs = ret;
27982784 }
27992785 /* This just release blacklist only if allocated */
28002786 kprobe_blacklist__release();
28012787
2788+ return 0;
2789+}
2790+
2791+int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs)
2792+{
2793+ int i, ret = 0;
2794+
28022795 /* Loop 2: add all events */
28032796 for (i = 0; i < npevs; i++) {
2804− ret = __add_probe_trace_events(pkgs[i].pev, pkgs[i].tevs,
2805− pkgs[i].ntevs,
2797+ ret = __add_probe_trace_events(&pevs[i], pevs[i].tevs,
2798+ pevs[i].ntevs,
28062799 probe_conf.force_add);
28072800 if (ret < 0)
28082801 break;
28092802 }
2810−end:
2803+ return ret;
2804+}
2805+
2806+void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs)
2807+{
2808+ int i, j;
2809+
28112810 /* Loop 3: cleanup and free trace events */
28122811 for (i = 0; i < npevs; i++) {
2813− for (j = 0; j < pkgs[i].ntevs; j++)
2814− clear_probe_trace_event(&pkgs[i].tevs[j]);
2815− zfree(&pkgs[i].tevs);
2812+ for (j = 0; j < pevs[i].ntevs; j++)
2813+ clear_probe_trace_event(&pevs[i].tevs[j]);
2814+ zfree(&pevs[i].tevs);
2815+ pevs[i].ntevs = 0;
2816+ clear_perf_probe_event(&pevs[i]);
28162817 }
2817− free(pkgs);
2818− exit_symbol_maps();
2818+}
28192819
2820+int add_perf_probe_events(struct perf_probe_event *pevs, int npevs)
2821+{
2822+ int ret;
2823+
2824+ ret = init_probe_symbol_maps(pevs->uprobes);
2825+ if (ret < 0)
2826+ return ret;
2827+
2828+ ret = convert_perf_probe_events(pevs, npevs);
2829+ if (ret == 0)
2830+ ret = apply_perf_probe_events(pevs, npevs);
2831+
2832+ cleanup_perf_probe_events(pevs, npevs);
2833+
2834+ exit_probe_symbol_maps();
28202835 return ret;
28212836 }
28222837
@@ -2828,8 +2843,6 @@ int del_perf_probe_events(struct strfilter *filter) · 5 unmodified lines
28282843 if (!str)
28292844 return -EINVAL;
28302845
2831− pr_debug("Delete filter: \'%s\'\n", str);
2832−
28332846 /* Get current event names */
28342847 ret = probe_file__open_both(&kfd, &ufd, PF_FL_RW);
28352848 if (ret < 0)
@@ -2844,9 +2857,6 @@ int del_perf_probe_events(struct strfilter *filter) · 8 unmodified lines
28442857 ret = ret2;
28452858 goto error;
28462859 }
2847− if (ret == -ENOENT && ret2 == -ENOENT)
2848− pr_debug("\"%s\" does not hit any event.\n", str);
2849− /* Note that this is silently ignored */
28502860 ret = 0;
28512861
28522862 error:
@@ -2881,7 +2891,7 @@ int show_available_funcs(const char *target, struct strfilter *_filter, · 28 unmodified lines
28812891 struct map *map;
28822892 int ret;
28832893
2884− ret = init_symbol_maps(user);
2894+ ret = init_probe_symbol_maps(user);
28852895 if (ret < 0)
28862896 return ret;
28872897
@@ -2911,7 +2921,7 @@ end: · 23 unmodified lines
29112921 if (user) {
29122922 map__put(map);
29132923 }
2914− exit_symbol_maps();
2924+ exit_probe_symbol_maps();
29152925
29162926 return ret;
29172927 }
tools/perf/util/probe-event.h+11−0
@@ -87,6 +87,8 @@ struct perf_probe_event { · 86 unmodified lines
8787 bool uprobes; /* Uprobe event flag */
8888 char *target; /* Target binary */
8989 struct perf_probe_arg *args; /* Arguments */
90+ struct probe_trace_event *tevs;
91+ int ntevs;
9092 };
9193
9294 /* Line range */
@@ -108,6 +110,8 @@ struct variable_list { · 15 unmodified lines
108110 };
109111
110112 struct map;
113+int init_probe_symbol_maps(bool user_only);
114+void exit_probe_symbol_maps(void);
111115
112116 /* Command string to events */
113117 extern int parse_perf_probe_command(const char *cmd,
@@ -138,7 +142,14 @@ extern void line_range__clear(struct line_range *lr); · 24 unmodified lines
138142 extern int line_range__init(struct line_range *lr);
139143
140144 extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs);
145+extern int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs);
146+extern int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs);
147+extern void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs);
141148 extern int del_perf_probe_events(struct strfilter *filter);
149+
150+extern int show_perf_probe_event(const char *group, const char *event,
151+ struct perf_probe_event *pev,
152+ const char *module, bool use_stdout);
142153 extern int show_perf_probe_events(struct strfilter *filter);
143154 extern int show_line_range(struct line_range *lr, const char *module,
144155 bool user);
tools/perf/util/probe-file.c+38−18
@@ -22,8 +22,7 @@ · 21 unmodified lines
2222 #include "color.h"
2323 #include "symbol.h"
2424 #include "thread.h"
25−#include <api/fs/debugfs.h>
26−#include <api/fs/tracefs.h>
25+#include <api/fs/tracing_path.h>
2726 #include "probe-event.h"
2827 #include "probe-file.h"
2928 #include "session.h"
@@ -73,21 +72,11 @@ static void print_both_open_warning(int kerr, int uerr) · 43 unmodified lines
7372 static int open_probe_events(const char *trace_file, bool readwrite)
7473 {
7574 char buf[PATH_MAX];
76− const char *__debugfs;
7775 const char *tracing_dir = "";
7876 int ret;
7977
80− __debugfs = tracefs_find_mountpoint();
81− if (__debugfs == NULL) {
82− tracing_dir = "tracing/";
83−
84− __debugfs = debugfs_find_mountpoint();
85− if (__debugfs == NULL)
86− return -ENOTSUP;
87− }
88−
8978 ret = e_snprintf(buf, PATH_MAX, "%s/%s%s",
90− __debugfs, tracing_dir, trace_file);
79+ tracing_path, tracing_dir, trace_file);
9180 if (ret >= 0) {
9281 pr_debug("Opening %s write=%d\n", buf, readwrite);
9382 if (readwrite && !probe_event_dry_run)
@@ -267,7 +256,6 @@ static int __del_trace_probe_event(int fd, struct str_node *ent) · 173 unmodified lines
267256 goto error;
268257 }
269258
270− pr_info("Removed event: %s\n", ent->s);
271259 return 0;
272260 error:
273261 pr_warning("Failed to delete event: %s\n",
@@ -275,7 +263,8 @@ error: · 1 unmodified line
275263 return ret;
276264 }
277265
278−int probe_file__del_events(int fd, struct strfilter *filter)
266+int probe_file__get_events(int fd, struct strfilter *filter,
267+ struct strlist *plist)
279268 {
280269 struct strlist *namelist;
281270 struct str_node *ent;
@@ -290,12 +279,43 @@ int probe_file__del_events(int fd, struct strfilter *filter) · 8 unmodified lines
290279 p = strchr(ent->s, ':');
291280 if ((p && strfilter__compare(filter, p + 1)) ||
292281 strfilter__compare(filter, ent->s)) {
293− ret = __del_trace_probe_event(fd, ent);
294− if (ret < 0)
295− break;
282+ strlist__add(plist, ent->s);
283+ ret = 0;
296284 }
297285 }
298286 strlist__delete(namelist);
299287
300288 return ret;
301289 }
290+
291+int probe_file__del_strlist(int fd, struct strlist *namelist)
292+{
293+ int ret = 0;
294+ struct str_node *ent;
295+
296+ strlist__for_each(ent, namelist) {
297+ ret = __del_trace_probe_event(fd, ent);
298+ if (ret < 0)
299+ break;
300+ }
301+ return ret;
302+}
303+
304+int probe_file__del_events(int fd, struct strfilter *filter)
305+{
306+ struct strlist *namelist;
307+ int ret;
308+
309+ namelist = strlist__new(NULL, NULL);
310+ if (!namelist)
311+ return -ENOMEM;
312+
313+ ret = probe_file__get_events(fd, filter, namelist);
314+ if (ret < 0)
315+ return ret;
316+
317+ ret = probe_file__del_strlist(fd, namelist);
318+ strlist__delete(namelist);
319+
320+ return ret;
321+}
tools/perf/util/probe-file.h+4−0
@@ -14,5 +14,9 @@ struct strlist *probe_file__get_namelist(int fd); · 13 unmodified lines
1414 struct strlist *probe_file__get_rawlist(int fd);
1515 int probe_file__add_event(int fd, struct probe_trace_event *tev);
1616 int probe_file__del_events(int fd, struct strfilter *filter);
17+int probe_file__get_events(int fd, struct strfilter *filter,
18+ struct strlist *plist);
19+int probe_file__del_strlist(int fd, struct strlist *namelist);
20+
1721
1822 #endif
tools/perf/util/probe-finder.c+54−4
@@ -70,6 +70,7 @@ static int debuginfo__init_offline_dwarf(struct debuginfo *dbg, · 69 unmodified lines
7070 if (!dbg->dwfl)
7171 goto error;
7272
73+ dwfl_report_begin(dbg->dwfl);
7374 dbg->mod = dwfl_report_offline(dbg->dwfl, "", "", fd);
7475 if (!dbg->mod)
7576 goto error;
@@ -78,6 +79,8 @@ static int debuginfo__init_offline_dwarf(struct debuginfo *dbg, · 2 unmodified lines
7879 if (!dbg->dbg)
7980 goto error;
8081
82+ dwfl_report_end(dbg->dwfl, NULL, NULL);
83+
8184 return 0;
8285 error:
8386 if (dbg->dwfl)
@@ -591,6 +594,7 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf) · 507 unmodified lines
591594 /* Convert subprogram DIE to trace point */
592595 static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
593596 Dwarf_Addr paddr, bool retprobe,
597+ const char *function,
594598 struct probe_trace_point *tp)
595599 {
596600 Dwarf_Addr eaddr, highaddr;
@@ -634,8 +638,10 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod, · 37 unmodified lines
634638 /* Return probe must be on the head of a subprogram */
635639 if (retprobe) {
636640 if (eaddr != paddr) {
637− pr_warning("Return probe must be on the head of"
638− " a real function.\n");
641+ pr_warning("Failed to find \"%s%%return\",\n"
642+ " because %s is an inlined function and"
643+ " has no return point.\n", function,
644+ function);
639645 return -EINVAL;
640646 }
641647 tp->retprobe = true;
@@ -1175,6 +1181,7 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf) · 533 unmodified lines
11751181 {
11761182 struct trace_event_finder *tf =
11771183 container_of(pf, struct trace_event_finder, pf);
1184+ struct perf_probe_point *pp = &pf->pev->point;
11781185 struct probe_trace_event *tev;
11791186 struct perf_probe_arg *args;
11801187 int ret, i;
@@ -1189,7 +1196,7 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf) · 8 unmodified lines
11891196
11901197 /* Trace point should be converted from subprogram DIE */
11911198 ret = convert_to_trace_point(&pf->sp_die, tf->mod, pf->addr,
1192− pf->pev->point.retprobe, &tev->point);
1199+ pp->retprobe, pp->function, &tev->point);
11931200 if (ret < 0)
11941201 return ret;
11951202
@@ -1319,6 +1326,7 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf) · 123 unmodified lines
13191326 {
13201327 struct available_var_finder *af =
13211328 container_of(pf, struct available_var_finder, pf);
1329+ struct perf_probe_point *pp = &pf->pev->point;
13221330 struct variable_list *vl;
13231331 Dwarf_Die die_mem;
13241332 int ret;
@@ -1332,7 +1340,7 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf) · 7 unmodified lines
13321340
13331341 /* Trace point should be converted from subprogram DIE */
13341342 ret = convert_to_trace_point(&pf->sp_die, af->mod, pf->addr,
1335− pf->pev->point.retprobe, &vl->point);
1343+ pp->retprobe, pp->function, &vl->point);
13361344 if (ret < 0)
13371345 return ret;
13381346
@@ -1399,6 +1407,41 @@ int debuginfo__find_available_vars_at(struct debuginfo *dbg, · 60 unmodified lines
13991407 return (ret < 0) ? ret : af.nvls;
14001408 }
14011409
1410+/* For the kernel module, we need a special code to get a DIE */
1411+static int debuginfo__get_text_offset(struct debuginfo *dbg, Dwarf_Addr *offs)
1412+{
1413+ int n, i;
1414+ Elf32_Word shndx;
1415+ Elf_Scn *scn;
1416+ Elf *elf;
1417+ GElf_Shdr mem, *shdr;
1418+ const char *p;
1419+
1420+ elf = dwfl_module_getelf(dbg->mod, &dbg->bias);
1421+ if (!elf)
1422+ return -EINVAL;
1423+
1424+ /* Get the number of relocations */
1425+ n = dwfl_module_relocations(dbg->mod);
1426+ if (n < 0)
1427+ return -ENOENT;
1428+ /* Search the relocation related .text section */
1429+ for (i = 0; i < n; i++) {
1430+ p = dwfl_module_relocation_info(dbg->mod, i, &shndx);
1431+ if (strcmp(p, ".text") == 0) {
1432+ /* OK, get the section header */
1433+ scn = elf_getscn(elf, shndx);
1434+ if (!scn)
1435+ return -ENOENT;
1436+ shdr = gelf_getshdr(scn, &mem);
1437+ if (!shdr)
1438+ return -ENOENT;
1439+ *offs = shdr->sh_addr;
1440+ }
1441+ }
1442+ return 0;
1443+}
1444+
14021445 /* Reverse search */
14031446 int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
14041447 struct perf_probe_point *ppt)
@@ -1407,9 +1450,16 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr, · 2 unmodified lines
14071450 Dwarf_Addr _addr = 0, baseaddr = 0;
14081451 const char *fname = NULL, *func = NULL, *basefunc = NULL, *tmp;
14091452 int baseline = 0, lineno = 0, ret = 0;
1453+ bool reloc = false;
14101454
1455+retry:
14111456 /* Find cu die */
14121457 if (!dwarf_addrdie(dbg->dbg, (Dwarf_Addr)addr, &cudie)) {
1458+ if (!reloc && debuginfo__get_text_offset(dbg, &baseaddr) == 0) {
1459+ addr += baseaddr;
1460+ reloc = true;
1461+ goto retry;
1462+ }
14131463 pr_warning("Failed to find debug information for address %lx\n",
14141464 addr);
14151465 ret = -EINVAL;
tools/perf/util/python.c+55−4
@@ -67,6 +67,7 @@ static char pyrf_mmap_event__doc[] = PyDoc_STR("perf mmap event object."); · 66 unmodified lines
6767 static PyMemberDef pyrf_mmap_event__members[] = {
6868 sample_members
6969 member_def(perf_event_header, type, T_UINT, "event type"),
70+ member_def(perf_event_header, misc, T_UINT, "event misc"),
7071 member_def(mmap_event, pid, T_UINT, "event pid"),
7172 member_def(mmap_event, tid, T_UINT, "event tid"),
7273 member_def(mmap_event, start, T_ULONGLONG, "start of the map"),
@@ -297,6 +298,43 @@ static PyTypeObject pyrf_sample_event__type = { · 224 unmodified lines
297298 .tp_repr = (reprfunc)pyrf_sample_event__repr,
298299 };
299300
301+static char pyrf_context_switch_event__doc[] = PyDoc_STR("perf context_switch event object.");
302+
303+static PyMemberDef pyrf_context_switch_event__members[] = {
304+ sample_members
305+ member_def(perf_event_header, type, T_UINT, "event type"),
306+ member_def(context_switch_event, next_prev_pid, T_UINT, "next/prev pid"),
307+ member_def(context_switch_event, next_prev_tid, T_UINT, "next/prev tid"),
308+ { .name = NULL, },
309+};
310+
311+static PyObject *pyrf_context_switch_event__repr(struct pyrf_event *pevent)
312+{
313+ PyObject *ret;
314+ char *s;
315+
316+ if (asprintf(&s, "{ type: context_switch, next_prev_pid: %u, next_prev_tid: %u, switch_out: %u }",
317+ pevent->event.context_switch.next_prev_pid,
318+ pevent->event.context_switch.next_prev_tid,
319+ !!(pevent->event.header.misc & PERF_RECORD_MISC_SWITCH_OUT)) < 0) {
320+ ret = PyErr_NoMemory();
321+ } else {
322+ ret = PyString_FromString(s);
323+ free(s);
324+ }
325+ return ret;
326+}
327+
328+static PyTypeObject pyrf_context_switch_event__type = {
329+ PyVarObject_HEAD_INIT(NULL, 0)
330+ .tp_name = "perf.context_switch_event",
331+ .tp_basicsize = sizeof(struct pyrf_event),
332+ .tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
333+ .tp_doc = pyrf_context_switch_event__doc,
334+ .tp_members = pyrf_context_switch_event__members,
335+ .tp_repr = (reprfunc)pyrf_context_switch_event__repr,
336+};
337+
300338 static int pyrf_event__setup_types(void)
301339 {
302340 int err;
@@ -306,6 +344,7 @@ static int pyrf_event__setup_types(void) · 3 unmodified lines
306344 pyrf_lost_event__type.tp_new =
307345 pyrf_read_event__type.tp_new =
308346 pyrf_sample_event__type.tp_new =
347+ pyrf_context_switch_event__type.tp_new =
309348 pyrf_throttle_event__type.tp_new = PyType_GenericNew;
310349 err = PyType_Ready(&pyrf_mmap_event__type);
311350 if (err < 0)
@@ -328,6 +367,9 @@ static int pyrf_event__setup_types(void) · 16 unmodified lines
328367 err = PyType_Ready(&pyrf_sample_event__type);
329368 if (err < 0)
330369 goto out;
370+ err = PyType_Ready(&pyrf_context_switch_event__type);
371+ if (err < 0)
372+ goto out;
331373 out:
332374 return err;
333375 }
@@ -342,6 +384,8 @@ static PyTypeObject *pyrf_event__type[] = { · 8 unmodified lines
342384 [PERF_RECORD_FORK] = &pyrf_task_event__type,
343385 [PERF_RECORD_READ] = &pyrf_read_event__type,
344386 [PERF_RECORD_SAMPLE] = &pyrf_sample_event__type,
387+ [PERF_RECORD_SWITCH] = &pyrf_context_switch_event__type,
388+ [PERF_RECORD_SWITCH_CPU_WIDE] = &pyrf_context_switch_event__type,
345389 };
346390
347391 static PyObject *pyrf_event__new(union perf_event *event)
@@ -349,8 +393,10 @@ static PyObject *pyrf_event__new(union perf_event *event) · 1 unmodified line
349393 struct pyrf_event *pevent;
350394 PyTypeObject *ptype;
351395
352− if (event->header.type < PERF_RECORD_MMAP ||
353− event->header.type > PERF_RECORD_SAMPLE)
396+ if ((event->header.type < PERF_RECORD_MMAP ||
397+ event->header.type > PERF_RECORD_SAMPLE) &&
398+ !(event->header.type == PERF_RECORD_SWITCH ||
399+ event->header.type == PERF_RECORD_SWITCH_CPU_WIDE))
354400 return NULL;
355401
356402 ptype = pyrf_event__type[event->header.type];
@@ -528,6 +574,7 @@ static int pyrf_evsel__init(struct pyrf_evsel *pevsel, · 171 unmodified lines
528574 "exclude_hv",
529575 "exclude_idle",
530576 "mmap",
577+ "context_switch",
531578 "comm",
532579 "freq",
533580 "inherit_stat",
@@ -553,6 +600,7 @@ static int pyrf_evsel__init(struct pyrf_evsel *pevsel, · 19 unmodified lines
553600 exclude_hv = 0,
554601 exclude_idle = 0,
555602 mmap = 0,
603+ context_switch = 0,
556604 comm = 0,
557605 freq = 1,
558606 inherit_stat = 0,
@@ -565,13 +613,13 @@ static int pyrf_evsel__init(struct pyrf_evsel *pevsel, · 6 unmodified lines
565613 int idx = 0;
566614
567615 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
568− "|iKiKKiiiiiiiiiiiiiiiiiiiiiKK", kwlist,
616+ "|iKiKKiiiiiiiiiiiiiiiiiiiiiiKK", kwlist,
569617 &attr.type, &attr.config, &attr.sample_freq,
570618 &sample_period, &attr.sample_type,
571619 &attr.read_format, &disabled, &inherit,
572620 &pinned, &exclusive, &exclude_user,
573621 &exclude_kernel, &exclude_hv, &exclude_idle,
574− &mmap, &comm, &freq, &inherit_stat,
622+ &mmap, &context_switch, &comm, &freq, &inherit_stat,
575623 &enable_on_exec, &task, &watermark,
576624 &precise_ip, &mmap_data, &sample_id_all,
577625 &attr.wakeup_events, &attr.bp_type,
@@ -595,6 +643,7 @@ static int pyrf_evsel__init(struct pyrf_evsel *pevsel, · 17 unmodified lines
595643 attr.exclude_hv = exclude_hv;
596644 attr.exclude_idle = exclude_idle;
597645 attr.mmap = mmap;
646+ attr.context_switch = context_switch;
598647 attr.comm = comm;
599648 attr.freq = freq;
600649 attr.inherit_stat = inherit_stat;
@@ -1019,6 +1068,8 @@ static struct { · 418 unmodified lines
10191068 PERF_CONST(RECORD_LOST_SAMPLES),
10201069 PERF_CONST(RECORD_SWITCH),
10211070 PERF_CONST(RECORD_SWITCH_CPU_WIDE),
1071+
1072+ PERF_CONST(RECORD_MISC_SWITCH_OUT),
10221073 { .name = NULL, },
10231074 };
10241075
tools/perf/util/scripting-engines/trace-event-perl.c+1−0
@@ -221,6 +221,7 @@ static void define_event_symbols(struct event_format *event, · 220 unmodified lines
221221 break;
222222 case PRINT_BSTRING:
223223 case PRINT_DYNAMIC_ARRAY:
224+ case PRINT_DYNAMIC_ARRAY_LEN:
224225 case PRINT_STRING:
225226 case PRINT_BITMASK:
226227 break;
tools/perf/util/scripting-engines/trace-event-python.c+2−1
@@ -251,6 +251,7 @@ static void define_event_symbols(struct event_format *event, · 250 unmodified lines
251251 /* gcc warns for these? */
252252 case PRINT_BSTRING:
253253 case PRINT_DYNAMIC_ARRAY:
254+ case PRINT_DYNAMIC_ARRAY_LEN:
254255 case PRINT_FUNC:
255256 case PRINT_BITMASK:
256257 /* we should warn... */
@@ -318,7 +319,7 @@ static PyObject *python_process_callchain(struct perf_sample *sample, · 61 unmodified lines
318319
319320 if (thread__resolve_callchain(al->thread, evsel,
320321 sample, NULL, NULL,
321− PERF_MAX_STACK_DEPTH) != 0) {
322+ scripting_max_stack) != 0) {
322323 pr_err("Failed to resolve callchain. Skipping\n");
323324 goto exit;
324325 }
tools/perf/util/session.c+16−21
@@ -138,6 +138,8 @@ struct perf_session *perf_session__new(struct perf_data_file *file, · 137 unmodified lines
138138 perf_session__set_id_hdr_size(session);
139139 perf_session__set_comm_exec(session);
140140 }
141+ } else {
142+ session->machines.host.env = &perf_env;
141143 }
142144
143145 if (!file || perf_data_file__is_write(file)) {
@@ -170,30 +172,13 @@ static void perf_session__delete_threads(struct perf_session *session) · 26 unmodified lines
170172 machine__delete_threads(&session->machines.host);
171173 }
172174
173−static void perf_session_env__exit(struct perf_env *env)
174−{
175− zfree(&env->hostname);
176− zfree(&env->os_release);
177− zfree(&env->version);
178− zfree(&env->arch);
179− zfree(&env->cpu_desc);
180− zfree(&env->cpuid);
181−
182− zfree(&env->cmdline);
183− zfree(&env->cmdline_argv);
184− zfree(&env->sibling_cores);
185− zfree(&env->sibling_threads);
186− zfree(&env->numa_nodes);
187− zfree(&env->pmu_mappings);
188−}
189−
190175 void perf_session__delete(struct perf_session *session)
191176 {
192177 auxtrace__free(session);
193178 auxtrace_index__free(&session->auxtrace_index);
194179 perf_session__destroy_kernel_maps(session);
195180 perf_session__delete_threads(session);
196− perf_session_env__exit(&session->header.env);
181+ perf_env__exit(&session->header.env);
197182 machines__exit(&session->machines);
198183 if (session->file)
199184 perf_data_file__close(session->file);
@@ -1079,11 +1064,11 @@ static int machines__deliver_event(struct machines *machines, · 879 unmodified lines
10791064
10801065 switch (event->header.type) {
10811066 case PERF_RECORD_SAMPLE:
1082− dump_sample(evsel, event, sample);
10831067 if (evsel == NULL) {
10841068 ++evlist->stats.nr_unknown_id;
10851069 return 0;
10861070 }
1071+ dump_sample(evsel, event, sample);
10871072 if (machine == NULL) {
10881073 ++evlist->stats.nr_unprocessable_samples;
10891074 return 0;
@@ -1116,6 +1101,9 @@ static int machines__deliver_event(struct machines *machines, · 26 unmodified lines
11161101 case PERF_RECORD_UNTHROTTLE:
11171102 return tool->unthrottle(tool, event, sample, machine);
11181103 case PERF_RECORD_AUX:
1104+ if (tool->aux == perf_event__process_aux &&
1105+ (event->aux.flags & PERF_AUX_FLAG_TRUNCATED))
1106+ evlist->stats.total_aux_lost += 1;
11191107 return tool->aux(tool, event, sample, machine);
11201108 case PERF_RECORD_ITRACE_START:
11211109 return tool->itrace_start(tool, event, sample, machine);
@@ -1323,7 +1311,7 @@ struct thread *perf_session__findnew(struct perf_session *session, pid_t pid) · 201 unmodified lines
13231311 return machine__findnew_thread(&session->machines.host, -1, pid);
13241312 }
13251313
1326−static struct thread *perf_session__register_idle_thread(struct perf_session *session)
1314+struct thread *perf_session__register_idle_thread(struct perf_session *session)
13271315 {
13281316 struct thread *thread;
13291317
@@ -1361,6 +1349,13 @@ static void perf_session__warn_about_errors(const struct perf_session *session) · 31 unmodified lines
13611349 }
13621350 }
13631351
1352+ if (session->tool->aux == perf_event__process_aux &&
1353+ stats->total_aux_lost != 0) {
1354+ ui__warning("AUX data lost %" PRIu64 " times out of %u!\n\n",
1355+ stats->total_aux_lost,
1356+ stats->nr_events[PERF_RECORD_AUX]);
1357+ }
1358+
13641359 if (stats->nr_unknown_events != 0) {
13651360 ui__warning("Found %u unknown events!\n\n"
13661361 "Is this an older tool processing a perf.data "
@@ -1805,7 +1800,7 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, · 438 unmodified lines
18051800
18061801 if (thread__resolve_callchain(al->thread, evsel,
18071802 sample, NULL, NULL,
1808− PERF_MAX_STACK_DEPTH) != 0) {
1803+ stack_depth) != 0) {
18091804 if (verbose)
18101805 error("Failed to resolve callchain. Skipping\n");
18111806 return;
tools/perf/util/session.h+2−0
@@ -89,6 +89,8 @@ struct machine *perf_session__findnew_machine(struct perf_session *session, pid_ · 88 unmodified lines
8989 }
9090
9191 struct thread *perf_session__findnew(struct perf_session *session, pid_t pid);
92+struct thread *perf_session__register_idle_thread(struct perf_session *session);
93+
9294 size_t perf_session__fprintf(struct perf_session *session, FILE *fp);
9395
9496 size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp);
tools/perf/util/sort.c+70−4
@@ -21,6 +21,7 @@ int sort__need_collapse = 0; · 20 unmodified lines
2121 int sort__has_parent = 0;
2222 int sort__has_sym = 0;
2323 int sort__has_dso = 0;
24+int sort__has_socket = 0;
2425 enum sort_mode sort__mode = SORT_MODE__NORMAL;
2526
2627
@@ -328,8 +329,8 @@ static char *get_srcfile(struct hist_entry *e) · 301 unmodified lines
328329 char *sf, *p;
329330 struct map *map = e->ms.map;
330331
331− sf = get_srcline(map->dso, map__rip_2objdump(map, e->ip),
332− e->ms.sym, true);
332+ sf = __get_srcline(map->dso, map__rip_2objdump(map, e->ip),
333+ e->ms.sym, false, true);
333334 if (!strcmp(sf, SRCLINE_UNKNOWN))
334335 return no_srcfile;
335336 p = strchr(sf, ':');
@@ -421,6 +422,27 @@ struct sort_entry sort_cpu = { · 85 unmodified lines
421422 .se_width_idx = HISTC_CPU,
422423 };
423424
425+/* --sort socket */
426+
427+static int64_t
428+sort__socket_cmp(struct hist_entry *left, struct hist_entry *right)
429+{
430+ return right->socket - left->socket;
431+}
432+
433+static int hist_entry__socket_snprintf(struct hist_entry *he, char *bf,
434+ size_t size, unsigned int width)
435+{
436+ return repsep_snprintf(bf, size, "%*.*d", width, width-3, he->socket);
437+}
438+
439+struct sort_entry sort_socket = {
440+ .se_header = "Socket",
441+ .se_cmp = sort__socket_cmp,
442+ .se_snprintf = hist_entry__socket_snprintf,
443+ .se_width_idx = HISTC_SOCKET,
444+};
445+
424446 /* sort keys for branch stacks */
425447
426448 static int64_t
@@ -632,6 +654,35 @@ static int hist_entry__daddr_snprintf(struct hist_entry *he, char *bf, · 205 unmodified lines
632654 width);
633655 }
634656
657+static int64_t
658+sort__iaddr_cmp(struct hist_entry *left, struct hist_entry *right)
659+{
660+ uint64_t l = 0, r = 0;
661+
662+ if (left->mem_info)
663+ l = left->mem_info->iaddr.addr;
664+ if (right->mem_info)
665+ r = right->mem_info->iaddr.addr;
666+
667+ return (int64_t)(r - l);
668+}
669+
670+static int hist_entry__iaddr_snprintf(struct hist_entry *he, char *bf,
671+ size_t size, unsigned int width)
672+{
673+ uint64_t addr = 0;
674+ struct map *map = NULL;
675+ struct symbol *sym = NULL;
676+
677+ if (he->mem_info) {
678+ addr = he->mem_info->iaddr.addr;
679+ map = he->mem_info->iaddr.map;
680+ sym = he->mem_info->iaddr.sym;
681+ }
682+ return _hist_entry__sym_snprintf(map, sym, addr, he->level, bf, size,
683+ width);
684+}
685+
635686 static int64_t
636687 sort__dso_daddr_cmp(struct hist_entry *left, struct hist_entry *right)
637688 {
@@ -1055,6 +1106,13 @@ struct sort_entry sort_mem_daddr_sym = { · 417 unmodified lines
10551106 .se_width_idx = HISTC_MEM_DADDR_SYMBOL,
10561107 };
10571108
1109+struct sort_entry sort_mem_iaddr_sym = {
1110+ .se_header = "Code Symbol",
1111+ .se_cmp = sort__iaddr_cmp,
1112+ .se_snprintf = hist_entry__iaddr_snprintf,
1113+ .se_width_idx = HISTC_MEM_IADDR_SYMBOL,
1114+};
1115+
10581116 struct sort_entry sort_mem_daddr_dso = {
10591117 .se_header = "Data Object",
10601118 .se_cmp = sort__dso_daddr_cmp,
@@ -1248,6 +1306,7 @@ static struct sort_dimension common_sort_dimensions[] = { · 187 unmodified lines
12481306 DIM(SORT_SYM, "symbol", sort_sym),
12491307 DIM(SORT_PARENT, "parent", sort_parent),
12501308 DIM(SORT_CPU, "cpu", sort_cpu),
1309+ DIM(SORT_SOCKET, "socket", sort_socket),
12511310 DIM(SORT_SRCLINE, "srcline", sort_srcline),
12521311 DIM(SORT_SRCFILE, "srcfile", sort_srcfile),
12531312 DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight),
@@ -1276,6 +1335,7 @@ static struct sort_dimension bstack_sort_dimensions[] = { · 22 unmodified lines
12761335
12771336 static struct sort_dimension memory_sort_dimensions[] = {
12781337 DIM(SORT_MEM_DADDR_SYMBOL, "symbol_daddr", sort_mem_daddr_sym),
1338+ DIM(SORT_MEM_IADDR_SYMBOL, "symbol_iaddr", sort_mem_iaddr_sym),
12791339 DIM(SORT_MEM_DADDR_DSO, "dso_daddr", sort_mem_daddr_dso),
12801340 DIM(SORT_MEM_LOCKED, "locked", sort_mem_locked),
12811341 DIM(SORT_MEM_TLB, "tlb", sort_mem_tlb),
@@ -1517,6 +1577,12 @@ static int __hpp_dimension__add_output(struct hpp_dimension *hd) · 235 unmodified lines
15171577 return 0;
15181578 }
15191579
1580+int hpp_dimension__add_output(unsigned col)
1581+{
1582+ BUG_ON(col >= PERF_HPP__MAX_INDEX);
1583+ return __hpp_dimension__add_output(&hpp_sort_dimensions[col]);
1584+}
1585+
15201586 int sort_dimension__add(const char *tok)
15211587 {
15221588 unsigned int i;
@@ -1550,6 +1616,8 @@ int sort_dimension__add(const char *tok) · 27 unmodified lines
15501616
15511617 } else if (sd->entry == &sort_dso) {
15521618 sort__has_dso = 1;
1619+ } else if (sd->entry == &sort_socket) {
1620+ sort__has_socket = 1;
15531621 }
15541622
15551623 return __sort_dimension__add(sd);
@@ -1855,8 +1923,6 @@ static int __setup_output_field(void) · 299 unmodified lines
18551923 if (field_order == NULL)
18561924 return 0;
18571925
1858− reset_dimensions();
1859−
18601926 strp = str = strdup(field_order);
18611927 if (str == NULL) {
18621928 error("Not enough memory to setup output fields");
tools/perf/util/sort.h+6−0
@@ -34,6 +34,7 @@ extern int have_ignore_callees; · 33 unmodified lines
3434 extern int sort__need_collapse;
3535 extern int sort__has_parent;
3636 extern int sort__has_sym;
37+extern int sort__has_socket;
3738 extern enum sort_mode sort__mode;
3839 extern struct sort_entry sort_comm;
3940 extern struct sort_entry sort_dso;
@@ -90,6 +91,7 @@ struct hist_entry { · 50 unmodified lines
9091 struct comm *comm;
9192 u64 ip;
9293 u64 transaction;
94+ s32 socket;
9395 s32 cpu;
9496 u8 cpumode;
9597
@@ -172,6 +174,7 @@ enum sort_type { · 76 unmodified lines
172174 SORT_SYM,
173175 SORT_PARENT,
174176 SORT_CPU,
177+ SORT_SOCKET,
175178 SORT_SRCLINE,
176179 SORT_SRCFILE,
177180 SORT_LOCAL_WEIGHT,
@@ -198,6 +201,7 @@ enum sort_type { · 20 unmodified lines
198201 SORT_MEM_LVL,
199202 SORT_MEM_SNOOP,
200203 SORT_MEM_DCACHELINE,
204+ SORT_MEM_IADDR_SYMBOL,
201205 };
202206
203207 /*
@@ -230,4 +234,6 @@ void perf_hpp__set_elide(int idx, bool elide); · 26 unmodified lines
230234 int report_parse_ignore_callees_opt(const struct option *opt, const char *arg, int unset);
231235
232236 bool is_strict_order(const char *order);
237+
238+int hpp_dimension__add_output(unsigned col);
233239 #endif /* __PERF_SORT_H */
tools/perf/util/srcline.c+24−5
@@ -149,8 +149,11 @@ static void addr2line_cleanup(struct a2l_data *a2l) · 148 unmodified lines
149149 free(a2l);
150150 }
151151
152+#define MAX_INLINE_NEST 1024
153+
152154 static int addr2line(const char *dso_name, u64 addr,
153− char **file, unsigned int *line, struct dso *dso)
155+ char **file, unsigned int *line, struct dso *dso,
156+ bool unwind_inlines)
154157 {
155158 int ret = 0;
156159 struct a2l_data *a2l = dso->a2l;
@@ -170,6 +173,15 @@ static int addr2line(const char *dso_name, u64 addr, · 13 unmodified lines
170173
171174 bfd_map_over_sections(a2l->abfd, find_address_in_section, a2l);
172175
176+ if (a2l->found && unwind_inlines) {
177+ int cnt = 0;
178+
179+ while (bfd_find_inliner_info(a2l->abfd, &a2l->filename,
180+ &a2l->funcname, &a2l->line) &&
181+ cnt++ < MAX_INLINE_NEST)
182+ ;
183+ }
184+
173185 if (a2l->found && a2l->filename) {
174186 *file = strdup(a2l->filename);
175187 *line = a2l->line;
@@ -197,7 +209,8 @@ void dso__free_a2l(struct dso *dso) · 21 unmodified lines
197209
198210 static int addr2line(const char *dso_name, u64 addr,
199211 char **file, unsigned int *line_nr,
200− struct dso *dso __maybe_unused)
212+ struct dso *dso __maybe_unused,
213+ bool unwind_inlines __maybe_unused)
201214 {
202215 FILE *fp;
203216 char cmd[PATH_MAX];
@@ -254,8 +267,8 @@ void dso__free_a2l(struct dso *dso __maybe_unused) · 50 unmodified lines
254267 */
255268 #define A2L_FAIL_LIMIT 123
256269
257−char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
258− bool show_sym)
270+char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
271+ bool show_sym, bool unwind_inlines)
259272 {
260273 char *file = NULL;
261274 unsigned line = 0;
@@ -276,7 +289,7 @@ char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym, · 14 unmodified lines
276289 if (!strncmp(dso_name, "/tmp/perf-", 10))
277290 goto out;
278291
279− if (!addr2line(dso_name, addr, &file, &line, dso))
292+ if (!addr2line(dso_name, addr, &file, &line, dso, unwind_inlines))
280293 goto out;
281294
282295 if (asprintf(&srcline, "%s:%u",
@@ -310,3 +323,9 @@ void free_srcline(char *srcline) · 27 unmodified lines
310323 if (srcline && strcmp(srcline, SRCLINE_UNKNOWN) != 0)
311324 free(srcline);
312325 }
326+
327+char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
328+ bool show_sym)
329+{
330+ return __get_srcline(dso, addr, sym, show_sym, false);
331+}
tools/perf/util/stat.c+7−6
@@ -67,7 +67,7 @@ double rel_stddev_stats(double stddev, double avg) · 66 unmodified lines
6767 bool __perf_evsel_stat__is(struct perf_evsel *evsel,
6868 enum perf_stat_evsel_id id)
6969 {
70− struct perf_stat *ps = evsel->priv;
70+ struct perf_stat_evsel *ps = evsel->priv;
7171
7272 return ps->id == id;
7373 }
@@ -84,7 +84,7 @@ static const char *id_str[PERF_STAT_EVSEL_ID__MAX] = { · 10 unmodified lines
8484
8585 void perf_stat_evsel_id_init(struct perf_evsel *evsel)
8686 {
87− struct perf_stat *ps = evsel->priv;
87+ struct perf_stat_evsel *ps = evsel->priv;
8888 int i;
8989
9090 /* ps->id is 0 hence PERF_STAT_EVSEL_ID__NONE by default */
@@ -100,7 +100,7 @@ void perf_stat_evsel_id_init(struct perf_evsel *evsel) · 9 unmodified lines
100100 void perf_evsel__reset_stat_priv(struct perf_evsel *evsel)
101101 {
102102 int i;
103− struct perf_stat *ps = evsel->priv;
103+ struct perf_stat_evsel *ps = evsel->priv;
104104
105105 for (i = 0; i < 3; i++)
106106 init_stats(&ps->res_stats[i]);
@@ -110,7 +110,7 @@ void perf_evsel__reset_stat_priv(struct perf_evsel *evsel) · 3 unmodified lines
110110
111111 int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel)
112112 {
113− evsel->priv = zalloc(sizeof(struct perf_stat));
113+ evsel->priv = zalloc(sizeof(struct perf_stat_evsel));
114114 if (evsel->priv == NULL)
115115 return -ENOMEM;
116116 perf_evsel__reset_stat_priv(evsel);
@@ -230,7 +230,7 @@ static int check_per_pkg(struct perf_evsel *counter, · 113 unmodified lines
230230 if (!(vals->run && vals->ena))
231231 return 0;
232232
233− s = cpu_map__get_socket(cpus, cpu);
233+ s = cpu_map__get_socket(cpus, cpu, NULL);
234234 if (s < 0)
235235 return -1;
236236
@@ -272,6 +272,7 @@ process_counter_values(struct perf_stat_config *config, struct perf_evsel *evsel · 35 unmodified lines
272272 aggr->ena += count->ena;
273273 aggr->run += count->run;
274274 }
275+ case AGGR_UNSET:
275276 default:
276277 break;
277278 }
@@ -304,7 +305,7 @@ int perf_stat_process_counter(struct perf_stat_config *config, · 26 unmodified lines
304305 struct perf_evsel *counter)
305306 {
306307 struct perf_counts_values *aggr = &counter->counts->aggr;
307− struct perf_stat *ps = counter->priv;
308+ struct perf_stat_evsel *ps = counter->priv;
308309 u64 *count = counter->counts->aggr.values;
309310 int i, ret;
310311
tools/perf/util/stat.h+2−1
@@ -20,7 +20,7 @@ enum perf_stat_evsel_id { · 19 unmodified lines
2020 PERF_STAT_EVSEL_ID__MAX,
2121 };
2222
23−struct perf_stat {
23+struct perf_stat_evsel {
2424 struct stats res_stats[3];
2525 enum perf_stat_evsel_id id;
2626 };
@@ -31,6 +31,7 @@ enum aggr_mode { · 4 unmodified lines
3131 AGGR_SOCKET,
3232 AGGR_CORE,
3333 AGGR_THREAD,
34+ AGGR_UNSET,
3435 };
3536
3637 struct perf_stat_config {
tools/perf/util/strbuf.c+15−7
@@ -82,23 +82,22 @@ void strbuf_add(struct strbuf *sb, const void *data, size_t len) · 81 unmodified lines
8282 strbuf_setlen(sb, sb->len + len);
8383 }
8484
85−void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
85+void strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap)
8686 {
8787 int len;
88− va_list ap;
88+ va_list ap_saved;
8989
9090 if (!strbuf_avail(sb))
9191 strbuf_grow(sb, 64);
92− va_start(ap, fmt);
92+
93+ va_copy(ap_saved, ap);
9394 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
94− va_end(ap);
9595 if (len < 0)
9696 die("your vsnprintf is broken");
9797 if (len > strbuf_avail(sb)) {
9898 strbuf_grow(sb, len);
99− va_start(ap, fmt);
100− len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
101− va_end(ap);
99+ len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap_saved);
100+ va_end(ap_saved);
102101 if (len > strbuf_avail(sb)) {
103102 die("this should not happen, your vsnprintf is broken");
104103 }
@@ -106,6 +105,15 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...) · 1 unmodified line
106105 strbuf_setlen(sb, sb->len + len);
107106 }
108107
108+void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
109+{
110+ va_list ap;
111+
112+ va_start(ap, fmt);
113+ strbuf_addv(sb, fmt, ap);
114+ va_end(ap);
115+}
116+
109117 ssize_t strbuf_read(struct strbuf *sb, int fd, ssize_t hint)
110118 {
111119 size_t oldlen = sb->len;
tools/perf/util/strbuf.h+2−0
@@ -39,6 +39,7 @@ · 38 unmodified lines
3939 */
4040
4141 #include <assert.h>
42+#include <stdarg.h>
4243
4344 extern char strbuf_slopbuf[];
4445 struct strbuf {
@@ -85,6 +86,7 @@ static inline void strbuf_addstr(struct strbuf *sb, const char *s) { · 40 unmodified lines
8586
8687 __attribute__((format(printf,2,3)))
8788 extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
89+extern void strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap);
8890
8991 /* XXX: if read fails, any partial read is undone */
9092 extern ssize_t strbuf_read(struct strbuf *, int fd, ssize_t hint);
tools/perf/util/symbol-minimal.c+1−1
@@ -337,7 +337,7 @@ int dso__load_sym(struct dso *dso, struct map *map __maybe_unused, · 336 unmodified lines
337337 symbol_filter_t filter __maybe_unused,
338338 int kmodule __maybe_unused)
339339 {
340− unsigned char *build_id[BUILD_ID_SIZE];
340+ unsigned char build_id[BUILD_ID_SIZE];
341341 int ret;
342342
343343 ret = fd__is_64_bit(ss->fd);
tools/perf/util/symbol.c+20−11
@@ -624,7 +624,7 @@ static int map__process_kallsym_symbol(void *arg, const char *name, · 623 unmodified lines
624624 * symbols, setting length to 0, and rely on
625625 * symbols__fixup_end() to fix it up.
626626 */
627− sym = symbol__new(start, 0, kallsyms2elf_type(type), name);
627+ sym = symbol__new(start, 0, kallsyms2elf_binding(type), name);
628628 if (sym == NULL)
629629 return -ENOMEM;
630630 /*
@@ -680,7 +680,7 @@ static int dso__split_kallsyms_for_kcore(struct dso *dso, struct map *map, · 49 unmodified lines
680680 pos->start -= curr_map->start - curr_map->pgoff;
681681 if (pos->end)
682682 pos->end -= curr_map->start - curr_map->pgoff;
683− if (curr_map != map) {
683+ if (curr_map->dso != map->dso) {
684684 rb_erase_init(&pos->rb_node, root);
685685 symbols__insert(
686686 &curr_map->dso->symbols[curr_map->type],
@@ -1406,6 +1406,7 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) · 719 unmodified lines
14061406 struct symsrc ss_[2];
14071407 struct symsrc *syms_ss = NULL, *runtime_ss = NULL;
14081408 bool kmod;
1409+ unsigned char build_id[BUILD_ID_SIZE];
14091410
14101411 pthread_mutex_lock(&dso->lock);
14111412
@@ -1461,6 +1462,14 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) · 49 unmodified lines
14611462 dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE ||
14621463 dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
14631464
1465+
1466+ /*
1467+ * Read the build id if possible. This is required for
1468+ * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work
1469+ */
1470+ if (filename__read_build_id(dso->name, build_id, BUILD_ID_SIZE) > 0)
1471+ dso__set_build_id(dso, build_id);
1472+
14641473 /*
14651474 * Iterate over candidate debug images.
14661475 * Keep track of "interesting" ones (those which have a symtab, dynsym,
@@ -1607,6 +1616,15 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map, · 140 unmodified lines
16071616 int i, err = 0;
16081617 char *filename = NULL;
16091618
1619+ pr_debug("Looking at the vmlinux_path (%d entries long)\n",
1620+ vmlinux_path__nr_entries + 1);
1621+
1622+ for (i = 0; i < vmlinux_path__nr_entries; ++i) {
1623+ err = dso__load_vmlinux(dso, map, vmlinux_path[i], false, filter);
1624+ if (err > 0)
1625+ goto out;
1626+ }
1627+
16101628 if (!symbol_conf.ignore_vmlinux_buildid)
16111629 filename = dso__build_id_filename(dso, NULL, 0);
16121630 if (filename != NULL) {
@@ -1615,15 +1633,6 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map, · 2 unmodified lines
16151633 goto out;
16161634 free(filename);
16171635 }
1618−
1619− pr_debug("Looking at the vmlinux_path (%d entries long)\n",
1620− vmlinux_path__nr_entries + 1);
1621−
1622− for (i = 0; i < vmlinux_path__nr_entries; ++i) {
1623− err = dso__load_vmlinux(dso, map, vmlinux_path[i], false, filter);
1624− if (err > 0)
1625− break;
1626− }
16271636 out:
16281637 return err;
16291638 }
tools/perf/util/symbol.h+1−0
@@ -191,6 +191,7 @@ struct addr_location { · 190 unmodified lines
191191 u8 filtered;
192192 u8 cpumode;
193193 s32 cpu;
194+ s32 socket;
194195 };
195196
196197 struct symsrc {
tools/perf/util/trace-event-info.c+1−1
@@ -38,7 +38,7 @@ · 37 unmodified lines
3838
3939 #include "../perf.h"
4040 #include "trace-event.h"
41−#include <api/fs/debugfs.h>
41+#include <api/fs/tracing_path.h>
4242 #include "evsel.h"
4343 #include "debug.h"
4444
tools/perf/util/trace-event.c+13−3
@@ -7,7 +7,9 @@ · 6 unmodified lines
77 #include <sys/stat.h>
88 #include <fcntl.h>
99 #include <linux/kernel.h>
10+#include <linux/err.h>
1011 #include <traceevent/event-parse.h>
12+#include <api/fs/tracing_path.h>
1113 #include "trace-event.h"
1214 #include "machine.h"
1315 #include "util.h"
@@ -65,6 +67,9 @@ void trace_event__cleanup(struct trace_event *t) · 51 unmodified lines
6567 pevent_free(t->pevent);
6668 }
6769
70+/*
71+ * Returns pointer with encoded error via <linux/err.h> interface.
72+ */
6873 static struct event_format*
6974 tp_format(const char *sys, const char *name)
7075 {
@@ -73,12 +78,14 @@ tp_format(const char *sys, const char *name) · 2 unmodified lines
7378 char path[PATH_MAX];
7479 size_t size;
7580 char *data;
81+ int err;
7682
7783 scnprintf(path, PATH_MAX, "%s/%s/%s/format",
7884 tracing_events_path, sys, name);
7985
80− if (filename__read_str(path, &data, &size))
81− return NULL;
86+ err = filename__read_str(path, &data, &size);
87+ if (err)
88+ return ERR_PTR(err);
8289
8390 pevent_parse_format(pevent, &event, data, size, sys);
8491
@@ -86,11 +93,14 @@ tp_format(const char *sys, const char *name) · 1 unmodified line
8693 return event;
8794 }
8895
96+/*
97+ * Returns pointer with encoded error via <linux/err.h> interface.
98+ */
8999 struct event_format*
90100 trace_event__tp_format(const char *sys, const char *name)
91101 {
92102 if (!tevent_initialized && trace_event__init2())
93− return NULL;
103+ return ERR_PTR(-ENOMEM);
94104
95105 return tp_format(sys, name);
96106 }
tools/perf/util/trace-event.h+2−0
@@ -78,6 +78,8 @@ struct scripting_ops { · 77 unmodified lines
7878 int (*generate_script) (struct pevent *pevent, const char *outfile);
7979 };
8080
81+extern unsigned int scripting_max_stack;
82+
8183 int script_spec_register(const char *spec, struct scripting_ops *ops);
8284
8385 void setup_perl_scripting(void);
tools/perf/util/unwind-libunwind.c+12−7
@@ -330,6 +330,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, · 329 unmodified lines
330330 struct map *map;
331331 unw_dyn_info_t di;
332332 u64 table_data, segbase, fde_count;
333+ int ret = -EINVAL;
333334
334335 map = find_map(ip, ui);
335336 if (!map || !map->dso)
@@ -348,29 +349,33 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, · 12 unmodified lines
348349 di.u.rti.table_data = map->start + table_data;
349350 di.u.rti.table_len = fde_count * sizeof(struct table_entry)
350351 / sizeof(unw_word_t);
351− return dwarf_search_unwind_table(as, ip, &di, pi,
352− need_unwind_info, arg);
352+ ret = dwarf_search_unwind_table(as, ip, &di, pi,
353+ need_unwind_info, arg);
353354 }
354355
355356 #ifndef NO_LIBUNWIND_DEBUG_FRAME
356357 /* Check the .debug_frame section for unwinding info */
357− if (!read_unwind_spec_debug_frame(map->dso, ui->machine, &segbase)) {
358+ if (ret < 0 &&
359+ !read_unwind_spec_debug_frame(map->dso, ui->machine, &segbase)) {
358360 int fd = dso__data_get_fd(map->dso, ui->machine);
359361 int is_exec = elf_is_exec(fd, map->dso->name);
360362 unw_word_t base = is_exec ? 0 : map->start;
363+ const char *symfile;
361364
362365 if (fd >= 0)
363366 dso__data_put_fd(map->dso);
364367
368+ symfile = map->dso->symsrc_filename ?: map->dso->name;
369+
365370 memset(&di, 0, sizeof(di));
366− if (dwarf_find_debug_frame(0, &di, ip, base, map->dso->name,
371+ if (dwarf_find_debug_frame(0, &di, ip, base, symfile,
367372 map->start, map->end))
368373 return dwarf_search_unwind_table(as, ip, &di, pi,
369374 need_unwind_info, arg);
370375 }
371376 #endif
372377
373− return -EINVAL;
378+ return ret;
374379 }
375380
376381 static int access_fpreg(unw_addr_space_t __maybe_unused as,
@@ -461,7 +466,7 @@ static int access_mem(unw_addr_space_t __maybe_unused as, · 84 unmodified lines
461466 if (ret) {
462467 pr_debug("unwind: access_mem %p not inside range"
463468 " 0x%" PRIx64 "-0x%" PRIx64 "\n",
464− (void *) addr, start, end);
469+ (void *) (uintptr_t) addr, start, end);
465470 *valp = 0;
466471 return ret;
467472 }
@@ -471,7 +476,7 @@ static int access_mem(unw_addr_space_t __maybe_unused as, · 3 unmodified lines
471476 offset = addr - start;
472477 *valp = *(unw_word_t *)&stack->data[offset];
473478 pr_debug("unwind: access_mem addr %p val %lx, offset %d\n",
474− (void *) addr, (unsigned long)*valp, offset);
479+ (void *) (uintptr_t) addr, (unsigned long)*valp, offset);
475480 return 0;
476481 }
477482
tools/perf/util/usage.c+5−0
@@ -50,6 +50,11 @@ void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN) · 49 unmodified lines
5050 die_routine = routine;
5151 }
5252
53+void set_warning_routine(void (*routine)(const char *err, va_list params))
54+{
55+ warn_routine = routine;
56+}
57+
5358 void usage(const char *err)
5459 {
5560 usage_routine(err);
tools/perf/util/util.c+1−71
@@ -17,7 +17,7 @@ · 16 unmodified lines
1717 #include "callchain.h"
1818
1919 struct callchain_param callchain_param = {
20− .mode = CHAIN_GRAPH_REL,
20+ .mode = CHAIN_GRAPH_ABS,
2121 .min_percent = 0.5,
2222 .order = ORDER_CALLEE,
2323 .key = CCKEY_FUNCTION
@@ -34,9 +34,6 @@ bool test_attr__enabled; · 10 unmodified lines
3434 bool perf_host = true;
3535 bool perf_guest = false;
3636
37−char tracing_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing";
38−char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";
39−
4037 void event_attr_init(struct perf_event_attr *attr)
4138 {
4239 if (!perf_host)
@@ -390,73 +387,6 @@ void set_term_quiet_input(struct termios *old) · 347 unmodified lines
390387 tcsetattr(0, TCSANOW, &tc);
391388 }
392389
393−static void set_tracing_events_path(const char *tracing, const char *mountpoint)
394−{
395− snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
396− mountpoint, tracing);
397− snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
398− mountpoint, tracing, "events");
399−}
400−
401−static const char *__perf_tracefs_mount(const char *mountpoint)
402−{
403− const char *mnt;
404−
405− mnt = tracefs_mount(mountpoint);
406− if (!mnt)
407− return NULL;
408−
409− set_tracing_events_path("", mnt);
410−
411− return mnt;
412−}
413−
414−static const char *__perf_debugfs_mount(const char *mountpoint)
415−{
416− const char *mnt;
417−
418− mnt = debugfs_mount(mountpoint);
419− if (!mnt)
420− return NULL;
421−
422− set_tracing_events_path("tracing/", mnt);
423−
424− return mnt;
425−}
426−
427−const char *perf_debugfs_mount(const char *mountpoint)
428−{
429− const char *mnt;
430−
431− mnt = __perf_tracefs_mount(mountpoint);
432− if (mnt)
433− return mnt;
434−
435− mnt = __perf_debugfs_mount(mountpoint);
436−
437− return mnt;
438−}
439−
440−void perf_debugfs_set_path(const char *mntpt)
441−{
442− set_tracing_events_path("tracing/", mntpt);
443−}
444−
445−char *get_tracing_file(const char *name)
446−{
447− char *file;
448−
449− if (asprintf(&file, "%s/%s", tracing_path, name) < 0)
450− return NULL;
451−
452− return file;
453−}
454−
455−void put_tracing_file(char *file)
456−{
457− free(file);
458−}
459−
460390 int parse_nsec_time(const char *str, u64 *ptime)
461391 {
462392 u64 time_sec, time_nsec;
tools/perf/util/util.h+4−8
@@ -74,8 +74,7 @@ · 73 unmodified lines
7474 #include <linux/magic.h>
7575 #include <linux/types.h>
7676 #include <sys/ttydefaults.h>
77−#include <api/fs/debugfs.h>
78−#include <api/fs/tracefs.h>
77+#include <api/fs/tracing_path.h>
7978 #include <termios.h>
8079 #include <linux/bitops.h>
8180 #include <termios.h>
@@ -83,12 +82,6 @@ · 1 unmodified line
8382 extern const char *graph_line;
8483 extern const char *graph_dotted_line;
8584 extern char buildid_dir[];
86−extern char tracing_path[];
87−extern char tracing_events_path[];
88−extern void perf_debugfs_set_path(const char *mountpoint);
89−const char *perf_debugfs_mount(const char *mountpoint);
90−char *get_tracing_file(const char *name);
91−void put_tracing_file(char *file);
9285
9386 /* On most systems <limits.h> would have given us this, but
9487 * not on some systems (e.g. GNU/Hurd).
@@ -152,6 +145,7 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2))) · 57 unmodified lines
152145
153146
154147 extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN);
148+extern void set_warning_routine(void (*routine)(const char *err, va_list params));
155149
156150 extern int prefixcmp(const char *str, const char *prefix);
157151 extern void set_buildid_dir(const char *dir);
@@ -321,6 +315,8 @@ struct symbol; · 163 unmodified lines
321315 extern bool srcline_full_filename;
322316 char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
323317 bool show_sym);
318+char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
319+ bool show_sym, bool unwind_inlines);
324320 void free_srcline(char *srcline);
325321
326322 int filename__read_str(const char *filename, char **buf, size_t *sizep);
tools/vm/page-types.c+3−3
@@ -42,7 +42,7 @@ · 41 unmodified lines
4242 #include <sys/mman.h>
4343 #include "../../include/uapi/linux/magic.h"
4444 #include "../../include/uapi/linux/kernel-page-flags.h"
45−#include <api/fs/debugfs.h>
45+#include <api/fs/fs.h>
4646
4747 #ifndef MAX_PATH
4848 # define MAX_PATH 256
@@ -188,7 +188,7 @@ static int kpageflags_fd; · 139 unmodified lines
188188 static int opt_hwpoison;
189189 static int opt_unpoison;
190190
191−static char *hwpoison_debug_fs;
191+static const char *hwpoison_debug_fs;
192192 static int hwpoison_inject_fd;
193193 static int hwpoison_forget_fd;
194194
@@ -487,7 +487,7 @@ static void prepare_hwpoison_fd(void) · 292 unmodified lines
487487 {
488488 char buf[MAX_PATH + 1];
489489
490− hwpoison_debug_fs = debugfs_mount(NULL);
490+ hwpoison_debug_fs = debugfs__mount();
491491 if (!hwpoison_debug_fs) {
492492 perror("mount debugfs");
493493 exit(EXIT_FAILURE);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t