diff options
author | Ingo Molnar <mingo@kernel.org> | 2016-10-06 18:36:49 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-10-06 18:36:49 -0400 |
commit | c68306ce20ad03ce655a367fc33ad06e12bb87a6 (patch) | |
tree | 73eb2890678d20f32da70d5f373612e03bd6e509 /tools | |
parent | 8657355f5b5f657407efc12a2223e8a3a6d658de (diff) | |
parent | 87095f7ddeff3038a0cf8e6574922f9c11688619 (diff) |
Merge tag 'perf-core-for-mingo-20161005' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
- Intel PT timestamp fixes (Adrian Hunter)
- Fix Intel JSON fixed counter conversions (Andi Kleen)
- Sync memcpy, cpufeatures and bpf headers with the kernel (Arnaldo Carvalho de Melo)
- Add some more tool tips (Donghyun Kim, Kim SeonYoung, Nambong Ha)
- Fix libtraceevent's kbuffer_read_at_offset() handling of offsets before or
equal the first event (Namhyung Kim)
- Fix uretprobe probe placement on ppc64le (Ravi Bangoria)
- Support building C++ source files and add feature detection for g++,
prep work for supporting a builtin clang/llvm, to remove the need for having
that toolchain installed to automagically build BPF scriptlets that then
gets uploaded to the kernel via sys_bpf() (Wang Nan)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/arch/x86/include/asm/cpufeatures.h | 1 | ||||
-rw-r--r-- | tools/arch/x86/lib/memcpy_64.S | 6 | ||||
-rw-r--r-- | tools/build/Build.include | 1 | ||||
-rw-r--r-- | tools/build/Makefile.build | 7 | ||||
-rw-r--r-- | tools/build/Makefile.feature | 2 | ||||
-rw-r--r-- | tools/build/feature/Makefile | 10 | ||||
-rw-r--r-- | tools/build/feature/test-cxx.cpp | 15 | ||||
-rw-r--r-- | tools/include/uapi/linux/bpf.h | 4 | ||||
-rw-r--r-- | tools/lib/traceevent/kbuffer-parse.c | 1 | ||||
-rw-r--r-- | tools/perf/Documentation/tips.txt | 4 | ||||
-rw-r--r-- | tools/perf/arch/powerpc/util/sym-handling.c | 3 | ||||
-rw-r--r-- | tools/perf/pmu-events/jevents.c | 2 | ||||
-rw-r--r-- | tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 38 |
13 files changed, 85 insertions, 9 deletions
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h index 92a8308b96f6..1188bc849ee3 100644 --- a/tools/arch/x86/include/asm/cpufeatures.h +++ b/tools/arch/x86/include/asm/cpufeatures.h | |||
@@ -106,7 +106,6 @@ | |||
106 | #define X86_FEATURE_APERFMPERF ( 3*32+28) /* APERFMPERF */ | 106 | #define X86_FEATURE_APERFMPERF ( 3*32+28) /* APERFMPERF */ |
107 | #define X86_FEATURE_EAGER_FPU ( 3*32+29) /* "eagerfpu" Non lazy FPU restore */ | 107 | #define X86_FEATURE_EAGER_FPU ( 3*32+29) /* "eagerfpu" Non lazy FPU restore */ |
108 | #define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30) /* TSC doesn't stop in S3 state */ | 108 | #define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30) /* TSC doesn't stop in S3 state */ |
109 | #define X86_FEATURE_MCE_RECOVERY ( 3*32+31) /* cpu has recoverable machine checks */ | ||
110 | 109 | ||
111 | /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ | 110 | /* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ |
112 | #define X86_FEATURE_XMM3 ( 4*32+ 0) /* "pni" SSE-3 */ | 111 | #define X86_FEATURE_XMM3 ( 4*32+ 0) /* "pni" SSE-3 */ |
diff --git a/tools/arch/x86/lib/memcpy_64.S b/tools/arch/x86/lib/memcpy_64.S index 2ec0b0abbfaa..49e6ebac7e73 100644 --- a/tools/arch/x86/lib/memcpy_64.S +++ b/tools/arch/x86/lib/memcpy_64.S | |||
@@ -181,11 +181,11 @@ ENDPROC(memcpy_orig) | |||
181 | 181 | ||
182 | #ifndef CONFIG_UML | 182 | #ifndef CONFIG_UML |
183 | /* | 183 | /* |
184 | * memcpy_mcsafe - memory copy with machine check exception handling | 184 | * memcpy_mcsafe_unrolled - memory copy with machine check exception handling |
185 | * Note that we only catch machine checks when reading the source addresses. | 185 | * Note that we only catch machine checks when reading the source addresses. |
186 | * Writes to target are posted and don't generate machine checks. | 186 | * Writes to target are posted and don't generate machine checks. |
187 | */ | 187 | */ |
188 | ENTRY(memcpy_mcsafe) | 188 | ENTRY(memcpy_mcsafe_unrolled) |
189 | cmpl $8, %edx | 189 | cmpl $8, %edx |
190 | /* Less than 8 bytes? Go to byte copy loop */ | 190 | /* Less than 8 bytes? Go to byte copy loop */ |
191 | jb .L_no_whole_words | 191 | jb .L_no_whole_words |
@@ -273,7 +273,7 @@ ENTRY(memcpy_mcsafe) | |||
273 | .L_done_memcpy_trap: | 273 | .L_done_memcpy_trap: |
274 | xorq %rax, %rax | 274 | xorq %rax, %rax |
275 | ret | 275 | ret |
276 | ENDPROC(memcpy_mcsafe) | 276 | ENDPROC(memcpy_mcsafe_unrolled) |
277 | 277 | ||
278 | .section .fixup, "ax" | 278 | .section .fixup, "ax" |
279 | /* Return -EFAULT for any failure */ | 279 | /* Return -EFAULT for any failure */ |
diff --git a/tools/build/Build.include b/tools/build/Build.include index 02489380d79b..1dcb95e76f70 100644 --- a/tools/build/Build.include +++ b/tools/build/Build.include | |||
@@ -90,6 +90,7 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ | |||
90 | # - per object C flags | 90 | # - per object C flags |
91 | # - BUILD_STR macro to allow '-D"$(variable)"' constructs | 91 | # - BUILD_STR macro to allow '-D"$(variable)"' constructs |
92 | c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj)) | 92 | c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj)) |
93 | cxx_flags = -Wp,-MD,$(depfile),-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj)) | ||
93 | 94 | ||
94 | ### | 95 | ### |
95 | ## HOSTCC C flags | 96 | ## HOSTCC C flags |
diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build index 190519a94ce5..99c0ccd2f176 100644 --- a/tools/build/Makefile.build +++ b/tools/build/Makefile.build | |||
@@ -61,6 +61,9 @@ quiet_cmd_cc_o_c = CC $@ | |||
61 | quiet_cmd_host_cc_o_c = HOSTCC $@ | 61 | quiet_cmd_host_cc_o_c = HOSTCC $@ |
62 | cmd_host_cc_o_c = $(HOSTCC) $(host_c_flags) -c -o $@ $< | 62 | cmd_host_cc_o_c = $(HOSTCC) $(host_c_flags) -c -o $@ $< |
63 | 63 | ||
64 | quiet_cmd_cxx_o_c = CXX $@ | ||
65 | cmd_cxx_o_c = $(CXX) $(cxx_flags) -c -o $@ $< | ||
66 | |||
64 | quiet_cmd_cpp_i_c = CPP $@ | 67 | quiet_cmd_cpp_i_c = CPP $@ |
65 | cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $< | 68 | cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $< |
66 | 69 | ||
@@ -88,6 +91,10 @@ $(OUTPUT)%.o: %.c FORCE | |||
88 | $(call rule_mkdir) | 91 | $(call rule_mkdir) |
89 | $(call if_changed_dep,$(host)cc_o_c) | 92 | $(call if_changed_dep,$(host)cc_o_c) |
90 | 93 | ||
94 | $(OUTPUT)%.o: %.cpp FORCE | ||
95 | $(call rule_mkdir) | ||
96 | $(call if_changed_dep,cxx_o_c) | ||
97 | |||
91 | $(OUTPUT)%.o: %.S FORCE | 98 | $(OUTPUT)%.o: %.S FORCE |
92 | $(call rule_mkdir) | 99 | $(call rule_mkdir) |
93 | $(call if_changed_dep,$(host)cc_o_c) | 100 | $(call if_changed_dep,$(host)cc_o_c) |
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index a120c6b755a9..ae52e029dd22 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature | |||
@@ -7,7 +7,7 @@ endif | |||
7 | 7 | ||
8 | feature_check = $(eval $(feature_check_code)) | 8 | feature_check = $(eval $(feature_check_code)) |
9 | define feature_check_code | 9 | define feature_check_code |
10 | feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) | 10 | feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) |
11 | endef | 11 | endef |
12 | 12 | ||
13 | feature_set = $(eval $(feature_set_code)) | 13 | feature_set = $(eval $(feature_set_code)) |
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index a0b29a311816..ac9c477a2a48 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile | |||
@@ -46,11 +46,13 @@ FILES= \ | |||
46 | test-lzma.bin \ | 46 | test-lzma.bin \ |
47 | test-bpf.bin \ | 47 | test-bpf.bin \ |
48 | test-get_cpuid.bin \ | 48 | test-get_cpuid.bin \ |
49 | test-sdt.bin | 49 | test-sdt.bin \ |
50 | test-cxx.bin | ||
50 | 51 | ||
51 | FILES := $(addprefix $(OUTPUT),$(FILES)) | 52 | FILES := $(addprefix $(OUTPUT),$(FILES)) |
52 | 53 | ||
53 | CC := $(CROSS_COMPILE)gcc -MD | 54 | CC := $(CROSS_COMPILE)gcc -MD |
55 | CXX := $(CROSS_COMPILE)g++ -MD | ||
54 | PKG_CONFIG := $(CROSS_COMPILE)pkg-config | 56 | PKG_CONFIG := $(CROSS_COMPILE)pkg-config |
55 | 57 | ||
56 | all: $(FILES) | 58 | all: $(FILES) |
@@ -58,6 +60,9 @@ all: $(FILES) | |||
58 | __BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS) | 60 | __BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS) |
59 | BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1 | 61 | BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1 |
60 | 62 | ||
63 | __BUILDXX = $(CXX) $(CXXFLAGS) -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS) | ||
64 | BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1 | ||
65 | |||
61 | ############################### | 66 | ############################### |
62 | 67 | ||
63 | $(OUTPUT)test-all.bin: | 68 | $(OUTPUT)test-all.bin: |
@@ -217,6 +222,9 @@ $(OUTPUT)test-bpf.bin: | |||
217 | $(OUTPUT)test-sdt.bin: | 222 | $(OUTPUT)test-sdt.bin: |
218 | $(BUILD) | 223 | $(BUILD) |
219 | 224 | ||
225 | $(OUTPUT)test-cxx.bin: | ||
226 | $(BUILDXX) -std=gnu++11 | ||
227 | |||
220 | -include $(OUTPUT)*.d | 228 | -include $(OUTPUT)*.d |
221 | 229 | ||
222 | ############################### | 230 | ############################### |
diff --git a/tools/build/feature/test-cxx.cpp b/tools/build/feature/test-cxx.cpp new file mode 100644 index 000000000000..b1dee9a31d6c --- /dev/null +++ b/tools/build/feature/test-cxx.cpp | |||
@@ -0,0 +1,15 @@ | |||
1 | #include <iostream> | ||
2 | #include <memory> | ||
3 | |||
4 | static void print_str(std::string s) | ||
5 | { | ||
6 | std::cout << s << std::endl; | ||
7 | } | ||
8 | |||
9 | int main() | ||
10 | { | ||
11 | std::string s("Hello World!"); | ||
12 | print_str(std::move(s)); | ||
13 | std::cout << "|" << s << "|" << std::endl; | ||
14 | return 0; | ||
15 | } | ||
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index da218fec6056..9e5fc168c8a3 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h | |||
@@ -339,7 +339,7 @@ enum bpf_func_id { | |||
339 | BPF_FUNC_skb_change_type, | 339 | BPF_FUNC_skb_change_type, |
340 | 340 | ||
341 | /** | 341 | /** |
342 | * bpf_skb_in_cgroup(skb, map, index) - Check cgroup2 membership of skb | 342 | * bpf_skb_under_cgroup(skb, map, index) - Check cgroup2 membership of skb |
343 | * @skb: pointer to skb | 343 | * @skb: pointer to skb |
344 | * @map: pointer to bpf_map in BPF_MAP_TYPE_CGROUP_ARRAY type | 344 | * @map: pointer to bpf_map in BPF_MAP_TYPE_CGROUP_ARRAY type |
345 | * @index: index of the cgroup in the bpf_map | 345 | * @index: index of the cgroup in the bpf_map |
@@ -348,7 +348,7 @@ enum bpf_func_id { | |||
348 | * == 1 skb succeeded the cgroup2 descendant test | 348 | * == 1 skb succeeded the cgroup2 descendant test |
349 | * < 0 error | 349 | * < 0 error |
350 | */ | 350 | */ |
351 | BPF_FUNC_skb_in_cgroup, | 351 | BPF_FUNC_skb_under_cgroup, |
352 | 352 | ||
353 | /** | 353 | /** |
354 | * bpf_get_hash_recalc(skb) | 354 | * bpf_get_hash_recalc(skb) |
diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c index 3bcada3ae05a..65984f1c2974 100644 --- a/tools/lib/traceevent/kbuffer-parse.c +++ b/tools/lib/traceevent/kbuffer-parse.c | |||
@@ -622,6 +622,7 @@ void *kbuffer_read_at_offset(struct kbuffer *kbuf, int offset, | |||
622 | 622 | ||
623 | /* Reset the buffer */ | 623 | /* Reset the buffer */ |
624 | kbuffer_load_subbuffer(kbuf, kbuf->subbuffer); | 624 | kbuffer_load_subbuffer(kbuf, kbuf->subbuffer); |
625 | data = kbuffer_read_event(kbuf, ts); | ||
625 | 626 | ||
626 | while (kbuf->curr < offset) { | 627 | while (kbuf->curr < offset) { |
627 | data = kbuffer_next_event(kbuf, ts); | 628 | data = kbuffer_next_event(kbuf, ts); |
diff --git a/tools/perf/Documentation/tips.txt b/tools/perf/Documentation/tips.txt index 5950b5a24efd..8a6479c0eac9 100644 --- a/tools/perf/Documentation/tips.txt +++ b/tools/perf/Documentation/tips.txt | |||
@@ -28,3 +28,7 @@ To change sampling frequency to 100 Hz: perf record -F 100 | |||
28 | See assembly instructions with percentage: perf annotate <symbol> | 28 | See assembly instructions with percentage: perf annotate <symbol> |
29 | If you prefer Intel style assembly, try: perf annotate -M intel | 29 | If you prefer Intel style assembly, try: perf annotate -M intel |
30 | For hierarchical output, try: perf report --hierarchy | 30 | For hierarchical output, try: perf report --hierarchy |
31 | Order by the overhead of source file name and line number: perf report -s srcline | ||
32 | System-wide collection from all CPUs: perf record -a | ||
33 | Show current config key-value pairs: perf config --list | ||
34 | Show user configuration overrides: perf config --user --list | ||
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c index ed9d5d15d5b6..1030a6e504bb 100644 --- a/tools/perf/arch/powerpc/util/sym-handling.c +++ b/tools/perf/arch/powerpc/util/sym-handling.c | |||
@@ -82,7 +82,8 @@ void arch__fix_tev_from_maps(struct perf_probe_event *pev, | |||
82 | * | 82 | * |
83 | * In addition, we shouldn't specify an offset for kretprobes. | 83 | * In addition, we shouldn't specify an offset for kretprobes. |
84 | */ | 84 | */ |
85 | if (pev->point.offset || pev->point.retprobe || !map || !sym) | 85 | if (pev->point.offset || (!pev->uprobes && pev->point.retprobe) || |
86 | !map || !sym) | ||
86 | return; | 87 | return; |
87 | 88 | ||
88 | lep_offset = PPC64_LOCAL_ENTRY_OFFSET(sym->arch_sym); | 89 | lep_offset = PPC64_LOCAL_ENTRY_OFFSET(sym->arch_sym); |
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index 79c2133bc534..41611d7f9873 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c | |||
@@ -312,6 +312,8 @@ static struct fixed { | |||
312 | const char *event; | 312 | const char *event; |
313 | } fixed[] = { | 313 | } fixed[] = { |
314 | { "inst_retired.any", "event=0xc0" }, | 314 | { "inst_retired.any", "event=0xc0" }, |
315 | { "inst_retired.any_p", "event=0xc0" }, | ||
316 | { "cpu_clk_unhalted.ref", "event=0x0,umask=0x03" }, | ||
315 | { "cpu_clk_unhalted.thread", "event=0x3c" }, | 317 | { "cpu_clk_unhalted.thread", "event=0x3c" }, |
316 | { "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" }, | 318 | { "cpu_clk_unhalted.thread_any", "event=0x3c,any=1" }, |
317 | { NULL, NULL}, | 319 | { NULL, NULL}, |
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c index 7591a0c37473..16c06d3ae577 100644 --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | |||
@@ -90,6 +90,7 @@ struct intel_pt_decoder { | |||
90 | bool pge; | 90 | bool pge; |
91 | bool have_tma; | 91 | bool have_tma; |
92 | bool have_cyc; | 92 | bool have_cyc; |
93 | bool fixup_last_mtc; | ||
93 | uint64_t pos; | 94 | uint64_t pos; |
94 | uint64_t last_ip; | 95 | uint64_t last_ip; |
95 | uint64_t ip; | 96 | uint64_t ip; |
@@ -586,10 +587,31 @@ struct intel_pt_calc_cyc_to_tsc_info { | |||
586 | uint64_t tsc_timestamp; | 587 | uint64_t tsc_timestamp; |
587 | uint64_t timestamp; | 588 | uint64_t timestamp; |
588 | bool have_tma; | 589 | bool have_tma; |
590 | bool fixup_last_mtc; | ||
589 | bool from_mtc; | 591 | bool from_mtc; |
590 | double cbr_cyc_to_tsc; | 592 | double cbr_cyc_to_tsc; |
591 | }; | 593 | }; |
592 | 594 | ||
595 | /* | ||
596 | * MTC provides a 8-bit slice of CTC but the TMA packet only provides the lower | ||
597 | * 16 bits of CTC. If mtc_shift > 8 then some of the MTC bits are not in the CTC | ||
598 | * provided by the TMA packet. Fix-up the last_mtc calculated from the TMA | ||
599 | * packet by copying the missing bits from the current MTC assuming the least | ||
600 | * difference between the two, and that the current MTC comes after last_mtc. | ||
601 | */ | ||
602 | static void intel_pt_fixup_last_mtc(uint32_t mtc, int mtc_shift, | ||
603 | uint32_t *last_mtc) | ||
604 | { | ||
605 | uint32_t first_missing_bit = 1U << (16 - mtc_shift); | ||
606 | uint32_t mask = ~(first_missing_bit - 1); | ||
607 | |||
608 | *last_mtc |= mtc & mask; | ||
609 | if (*last_mtc >= mtc) { | ||
610 | *last_mtc -= first_missing_bit; | ||
611 | *last_mtc &= 0xff; | ||
612 | } | ||
613 | } | ||
614 | |||
593 | static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info) | 615 | static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info) |
594 | { | 616 | { |
595 | struct intel_pt_decoder *decoder = pkt_info->decoder; | 617 | struct intel_pt_decoder *decoder = pkt_info->decoder; |
@@ -619,6 +641,11 @@ static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info) | |||
619 | return 0; | 641 | return 0; |
620 | 642 | ||
621 | mtc = pkt_info->packet.payload; | 643 | mtc = pkt_info->packet.payload; |
644 | if (decoder->mtc_shift > 8 && data->fixup_last_mtc) { | ||
645 | data->fixup_last_mtc = false; | ||
646 | intel_pt_fixup_last_mtc(mtc, decoder->mtc_shift, | ||
647 | &data->last_mtc); | ||
648 | } | ||
622 | if (mtc > data->last_mtc) | 649 | if (mtc > data->last_mtc) |
623 | mtc_delta = mtc - data->last_mtc; | 650 | mtc_delta = mtc - data->last_mtc; |
624 | else | 651 | else |
@@ -687,6 +714,7 @@ static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info) | |||
687 | 714 | ||
688 | data->ctc_delta = 0; | 715 | data->ctc_delta = 0; |
689 | data->have_tma = true; | 716 | data->have_tma = true; |
717 | data->fixup_last_mtc = true; | ||
690 | 718 | ||
691 | return 0; | 719 | return 0; |
692 | 720 | ||
@@ -753,6 +781,7 @@ static void intel_pt_calc_cyc_to_tsc(struct intel_pt_decoder *decoder, | |||
753 | .tsc_timestamp = decoder->tsc_timestamp, | 781 | .tsc_timestamp = decoder->tsc_timestamp, |
754 | .timestamp = decoder->timestamp, | 782 | .timestamp = decoder->timestamp, |
755 | .have_tma = decoder->have_tma, | 783 | .have_tma = decoder->have_tma, |
784 | .fixup_last_mtc = decoder->fixup_last_mtc, | ||
756 | .from_mtc = from_mtc, | 785 | .from_mtc = from_mtc, |
757 | .cbr_cyc_to_tsc = 0, | 786 | .cbr_cyc_to_tsc = 0, |
758 | }; | 787 | }; |
@@ -1271,6 +1300,7 @@ static void intel_pt_calc_tma(struct intel_pt_decoder *decoder) | |||
1271 | } | 1300 | } |
1272 | decoder->ctc_delta = 0; | 1301 | decoder->ctc_delta = 0; |
1273 | decoder->have_tma = true; | 1302 | decoder->have_tma = true; |
1303 | decoder->fixup_last_mtc = true; | ||
1274 | intel_pt_log("CTC timestamp " x64_fmt " last MTC %#x CTC rem %#x\n", | 1304 | intel_pt_log("CTC timestamp " x64_fmt " last MTC %#x CTC rem %#x\n", |
1275 | decoder->ctc_timestamp, decoder->last_mtc, ctc_rem); | 1305 | decoder->ctc_timestamp, decoder->last_mtc, ctc_rem); |
1276 | } | 1306 | } |
@@ -1285,6 +1315,12 @@ static void intel_pt_calc_mtc_timestamp(struct intel_pt_decoder *decoder) | |||
1285 | 1315 | ||
1286 | mtc = decoder->packet.payload; | 1316 | mtc = decoder->packet.payload; |
1287 | 1317 | ||
1318 | if (decoder->mtc_shift > 8 && decoder->fixup_last_mtc) { | ||
1319 | decoder->fixup_last_mtc = false; | ||
1320 | intel_pt_fixup_last_mtc(mtc, decoder->mtc_shift, | ||
1321 | &decoder->last_mtc); | ||
1322 | } | ||
1323 | |||
1288 | if (mtc > decoder->last_mtc) | 1324 | if (mtc > decoder->last_mtc) |
1289 | mtc_delta = mtc - decoder->last_mtc; | 1325 | mtc_delta = mtc - decoder->last_mtc; |
1290 | else | 1326 | else |
@@ -1353,6 +1389,8 @@ static void intel_pt_calc_cyc_timestamp(struct intel_pt_decoder *decoder) | |||
1353 | timestamp, decoder->timestamp); | 1389 | timestamp, decoder->timestamp); |
1354 | else | 1390 | else |
1355 | decoder->timestamp = timestamp; | 1391 | decoder->timestamp = timestamp; |
1392 | |||
1393 | decoder->timestamp_insn_cnt = 0; | ||
1356 | } | 1394 | } |
1357 | 1395 | ||
1358 | /* Walk PSB+ packets when already in sync. */ | 1396 | /* Walk PSB+ packets when already in sync. */ |