Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'perf-tools-fixes-for-v5.13-2021-05-24' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

Pull perf tool fixes from Arnaldo Carvalho de Melo:

- Fix 'perf script' decoding of Intel PT traces for abort handling and
sample instruction bytes.

- Add missing PERF_IP_FLAG_CHARS for VM-Entry and VM-Exit to Intel PT
'perf script' decoder.

- Fixes for the python based Intel PT trace viewer GUI.

- Sync UAPI copies (unwire quotactl_path, some comment fixes).

- Fix handling of missing kernel software events, such as the recently
added 'cgroup-switches', and add the trivial glue for it in the
tooling side, since it was added in this merge window.

- Add missing initialization of zstd_data in 'perf buildid-list',
detected with valgrind's memcheck.

- Remove needless event enable/disable when all events uses BPF.

- Fix libpfm4 support (63) test error for nested event groups.

* tag 'perf-tools-fixes-for-v5.13-2021-05-24' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
perf stat: Skip evlist__[enable|disable] when all events uses BPF
perf script: Add missing PERF_IP_FLAG_CHARS for VM-Entry and VM-Exit
perf scripts python: exported-sql-viewer.py: Fix warning display
perf scripts python: exported-sql-viewer.py: Fix Array TypeError
perf scripts python: exported-sql-viewer.py: Fix copy to clipboard from Top Calls by elapsed Time report
tools headers UAPI: Sync files changed by the quotactl_path unwiring
tools headers UAPI: Sync linux/perf_event.h with the kernel sources
tools headers UAPI: Sync linux/fs.h with the kernel sources
perf parse-events: Check if the software events array slots are populated
perf tools: Add 'cgroup-switches' software event
perf intel-pt: Remove redundant setting of ptq->insn_len
perf intel-pt: Fix sample instruction bytes
perf intel-pt: Fix transaction abort handling
perf test: Fix libpfm4 support (63) test error for nested event groups
tools arch kvm: Sync kvm headers with the kernel sources
perf buildid-list: Initialize zstd_data

+71 -30
+2
tools/arch/x86/include/uapi/asm/kvm.h
··· 437 437 __u16 flags; 438 438 } smm; 439 439 440 + __u16 pad; 441 + 440 442 __u32 flags; 441 443 __u64 preemption_timer_deadline; 442 444 };
+1 -1
tools/include/uapi/linux/fs.h
··· 185 185 #define BLKROTATIONAL _IO(0x12,126) 186 186 #define BLKZEROOUT _IO(0x12,127) 187 187 /* 188 - * A jump here: 130-131 are reserved for zoned block devices 188 + * A jump here: 130-136 are reserved for zoned block devices 189 189 * (see uapi/linux/blkzoned.h) 190 190 */ 191 191
+1 -1
tools/include/uapi/linux/perf_event.h
··· 464 464 465 465 /* 466 466 * User provided data if sigtrap=1, passed back to user via 467 - * siginfo_t::si_perf, e.g. to permit user to identify the event. 467 + * siginfo_t::si_perf_data, e.g. to permit user to identify the event. 468 468 */ 469 469 __u64 sig_data; 470 470 };
+3 -3
tools/perf/Documentation/perf-intel-pt.txt
··· 108 108 109 109 perf script --itrace=ibxwpe -F+flags 110 110 111 - The flags are "bcrosyiABEx" which stand for branch, call, return, conditional, 112 - system, asynchronous, interrupt, transaction abort, trace begin, trace end, and 113 - in transaction, respectively. 111 + The flags are "bcrosyiABExgh" which stand for branch, call, return, conditional, 112 + system, asynchronous, interrupt, transaction abort, trace begin, trace end, 113 + in transaction, VM-entry, and VM-exit respectively. 114 114 115 115 perf script also supports higher level ways to dump instruction traces: 116 116
+4 -3
tools/perf/Documentation/perf-script.txt
··· 183 183 At this point usage is displayed, and perf-script exits. 184 184 185 185 The flags field is synthesized and may have a value when Instruction 186 - Trace decoding. The flags are "bcrosyiABEx" which stand for branch, 186 + Trace decoding. The flags are "bcrosyiABExgh" which stand for branch, 187 187 call, return, conditional, system, asynchronous, interrupt, 188 - transaction abort, trace begin, trace end, and in transaction, 188 + transaction abort, trace begin, trace end, in transaction, VM-Entry, and VM-Exit 189 189 respectively. Known combinations of flags are printed more nicely e.g. 190 190 "call" for "bc", "return" for "br", "jcc" for "bo", "jmp" for "b", 191 191 "int" for "bci", "iret" for "bri", "syscall" for "bcs", "sysret" for "brs", 192 192 "async" for "by", "hw int" for "bcyi", "tx abrt" for "bA", "tr strt" for "bB", 193 - "tr end" for "bE". However the "x" flag will be display separately in those 193 + "tr end" for "bE", "vmentry" for "bcg", "vmexit" for "bch". 194 + However the "x" flag will be displayed separately in those 194 195 cases e.g. "jcc (x)" for a condition branch within a transaction. 195 196 196 197 The callindent field is synthesized and may have a value when
+1 -1
tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
··· 357 357 440 n64 process_madvise sys_process_madvise 358 358 441 n64 epoll_pwait2 sys_epoll_pwait2 359 359 442 n64 mount_setattr sys_mount_setattr 360 - 443 n64 quotactl_path sys_quotactl_path 360 + # 443 reserved for quotactl_path 361 361 444 n64 landlock_create_ruleset sys_landlock_create_ruleset 362 362 445 n64 landlock_add_rule sys_landlock_add_rule 363 363 446 n64 landlock_restrict_self sys_landlock_restrict_self
+1 -1
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
··· 522 522 440 common process_madvise sys_process_madvise 523 523 441 common epoll_pwait2 sys_epoll_pwait2 compat_sys_epoll_pwait2 524 524 442 common mount_setattr sys_mount_setattr 525 - 443 common quotactl_path sys_quotactl_path 525 + # 443 reserved for quotactl_path 526 526 444 common landlock_create_ruleset sys_landlock_create_ruleset 527 527 445 common landlock_add_rule sys_landlock_add_rule 528 528 446 common landlock_restrict_self sys_landlock_restrict_self
+1 -1
tools/perf/arch/s390/entry/syscalls/syscall.tbl
··· 445 445 440 common process_madvise sys_process_madvise sys_process_madvise 446 446 441 common epoll_pwait2 sys_epoll_pwait2 compat_sys_epoll_pwait2 447 447 442 common mount_setattr sys_mount_setattr sys_mount_setattr 448 - 443 common quotactl_path sys_quotactl_path sys_quotactl_path 448 + # 443 reserved for quotactl_path 449 449 444 common landlock_create_ruleset sys_landlock_create_ruleset sys_landlock_create_ruleset 450 450 445 common landlock_add_rule sys_landlock_add_rule sys_landlock_add_rule 451 451 446 common landlock_restrict_self sys_landlock_restrict_self sys_landlock_restrict_self
+1 -1
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
··· 364 364 440 common process_madvise sys_process_madvise 365 365 441 common epoll_pwait2 sys_epoll_pwait2 366 366 442 common mount_setattr sys_mount_setattr 367 - 443 common quotactl_path sys_quotactl_path 367 + # 443 reserved for quotactl_path 368 368 444 common landlock_create_ruleset sys_landlock_create_ruleset 369 369 445 common landlock_add_rule sys_landlock_add_rule 370 370 446 common landlock_restrict_self sys_landlock_restrict_self
+3
tools/perf/builtin-buildid-list.c
··· 80 80 if (!perf_header__has_feat(&session->header, HEADER_BUILD_ID)) 81 81 with_hits = true; 82 82 83 + if (zstd_init(&(session->zstd_data), 0) < 0) 84 + pr_warning("Decompression initialization failed. Reported data may be incomplete.\n"); 85 + 83 86 /* 84 87 * in pipe-mode, the only way to get the buildids is to parse 85 88 * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID
+10 -3
tools/perf/builtin-stat.c
··· 572 572 * - we have initial delay configured 573 573 */ 574 574 if (!target__none(&target) || stat_config.initial_delay) { 575 - evlist__enable(evsel_list); 575 + if (!all_counters_use_bpf) 576 + evlist__enable(evsel_list); 576 577 if (stat_config.initial_delay > 0) 577 578 pr_info(EVLIST_ENABLED_MSG); 578 579 } ··· 582 581 583 582 static void disable_counters(void) 584 583 { 584 + struct evsel *counter; 585 + 585 586 /* 586 587 * If we don't have tracee (attaching to task or cpu), counters may 587 588 * still be running. To get accurate group ratios, we must stop groups 588 589 * from counting before reading their constituent counters. 589 590 */ 590 - if (!target__none(&target)) 591 - evlist__disable(evsel_list); 591 + if (!target__none(&target)) { 592 + evlist__for_each_entry(evsel_list, counter) 593 + bpf_counter__disable(counter); 594 + if (!all_counters_use_bpf) 595 + evlist__disable(evsel_list); 596 + } 592 597 } 593 598 594 599 static volatile int workload_exec_errno;
+9 -3
tools/perf/scripts/python/exported-sql-viewer.py
··· 91 91 from __future__ import print_function 92 92 93 93 import sys 94 + # Only change warnings if the python -W option was not used 95 + if not sys.warnoptions: 96 + import warnings 97 + # PySide2 causes deprecation warnings, ignore them. 98 + warnings.filterwarnings("ignore", category=DeprecationWarning) 94 99 import argparse 95 100 import weakref 96 101 import threading ··· 130 125 from PySide.QtGui import * 131 126 from PySide.QtSql import * 132 127 133 - from decimal import * 134 - from ctypes import * 128 + from decimal import Decimal, ROUND_HALF_UP 129 + from ctypes import CDLL, Structure, create_string_buffer, addressof, sizeof, \ 130 + c_void_p, c_bool, c_byte, c_char, c_int, c_uint, c_longlong, c_ulonglong 135 131 from multiprocessing import Process, Array, Value, Event 136 132 137 133 # xrange is range in Python3 ··· 3874 3868 if with_hdr: 3875 3869 model = indexes[0].model() 3876 3870 for col in range(min_col, max_col + 1): 3877 - val = model.headerData(col, Qt.Horizontal) 3871 + val = model.headerData(col, Qt.Horizontal, Qt.DisplayRole) 3878 3872 if as_csv: 3879 3873 text += sep + ToCSValue(val) 3880 3874 sep = ","
+2 -2
tools/perf/tests/pfm.c
··· 131 131 }, 132 132 { 133 133 .events = "{},{instructions}", 134 - .nr_events = 0, 135 - .nr_groups = 0, 134 + .nr_events = 1, 135 + .nr_groups = 1, 136 136 }, 137 137 { 138 138 .events = "{instructions},{instructions}",
+1 -1
tools/perf/util/event.h
··· 100 100 PERF_IP_FLAG_VMEXIT = 1ULL << 12, 101 101 }; 102 102 103 - #define PERF_IP_FLAG_CHARS "bcrosyiABEx" 103 + #define PERF_IP_FLAG_CHARS "bcrosyiABExgh" 104 104 105 105 #define PERF_BRANCH_MASK (\ 106 106 PERF_IP_FLAG_BRANCH |\
-3
tools/perf/util/evlist.c
··· 425 425 if (affinity__setup(&affinity) < 0) 426 426 return; 427 427 428 - evlist__for_each_entry(evlist, pos) 429 - bpf_counter__disable(pos); 430 - 431 428 /* Disable 'immediate' events last */ 432 429 for (imm = 0; imm <= 1; imm++) { 433 430 evlist__for_each_cpu(evlist, i, cpu) {
+5 -1
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
··· 1146 1146 decoder->set_fup_tx_flags = false; 1147 1147 decoder->tx_flags = decoder->fup_tx_flags; 1148 1148 decoder->state.type = INTEL_PT_TRANSACTION; 1149 + if (decoder->fup_tx_flags & INTEL_PT_ABORT_TX) 1150 + decoder->state.type |= INTEL_PT_BRANCH; 1149 1151 decoder->state.from_ip = decoder->ip; 1150 1152 decoder->state.to_ip = 0; 1151 1153 decoder->state.flags = decoder->fup_tx_flags; ··· 1222 1220 return 0; 1223 1221 if (err == -EAGAIN || 1224 1222 intel_pt_fup_with_nlip(decoder, &intel_pt_insn, ip, err)) { 1223 + bool no_tip = decoder->pkt_state != INTEL_PT_STATE_FUP; 1224 + 1225 1225 decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; 1226 - if (intel_pt_fup_event(decoder)) 1226 + if (intel_pt_fup_event(decoder) && no_tip) 1227 1227 return 0; 1228 1228 return -EAGAIN; 1229 1229 }
+4 -2
tools/perf/util/intel-pt.c
··· 707 707 708 708 *ip += intel_pt_insn->length; 709 709 710 - if (to_ip && *ip == to_ip) 710 + if (to_ip && *ip == to_ip) { 711 + intel_pt_insn->length = 0; 711 712 goto out_no_cache; 713 + } 712 714 713 715 if (*ip >= al.map->end) 714 716 break; ··· 1200 1198 1201 1199 static void intel_pt_sample_flags(struct intel_pt_queue *ptq) 1202 1200 { 1201 + ptq->insn_len = 0; 1203 1202 if (ptq->state->flags & INTEL_PT_ABORT_TX) { 1204 1203 ptq->flags = PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TX_ABORT; 1205 1204 } else if (ptq->state->flags & INTEL_PT_ASYNC) { ··· 1214 1211 ptq->flags = PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | 1215 1212 PERF_IP_FLAG_ASYNC | 1216 1213 PERF_IP_FLAG_INTERRUPT; 1217 - ptq->insn_len = 0; 1218 1214 } else { 1219 1215 if (ptq->state->from_ip) 1220 1216 ptq->flags = intel_pt_insn_type(ptq->state->insn_op);
+11 -2
tools/perf/util/parse-events.c
··· 150 150 .symbol = "bpf-output", 151 151 .alias = "", 152 152 }, 153 + [PERF_COUNT_SW_CGROUP_SWITCHES] = { 154 + .symbol = "cgroup-switches", 155 + .alias = "", 156 + }, 153 157 }; 154 158 155 159 #define __PERF_EVENT_FIELD(config, name) \ ··· 2932 2928 } 2933 2929 2934 2930 for (i = 0; i < max; i++, syms++) { 2931 + /* 2932 + * New attr.config still not supported here, the latest 2933 + * example was PERF_COUNT_SW_CGROUP_SWITCHES 2934 + */ 2935 + if (syms->symbol == NULL) 2936 + continue; 2935 2937 2936 - if (event_glob != NULL && syms->symbol != NULL && 2937 - !(strglobmatch(syms->symbol, event_glob) || 2938 + if (event_glob != NULL && !(strglobmatch(syms->symbol, event_glob) || 2938 2939 (syms->alias && strglobmatch(syms->alias, event_glob)))) 2939 2940 continue; 2940 2941
+1
tools/perf/util/parse-events.l
··· 347 347 dummy { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_DUMMY); } 348 348 duration_time { return tool(yyscanner, PERF_TOOL_DURATION_TIME); } 349 349 bpf-output { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_BPF_OUTPUT); } 350 + cgroup-switches { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CGROUP_SWITCHES); } 350 351 351 352 /* 352 353 * We have to handle the kernel PMU event cycles-ct/cycles-t/mem-loads/mem-stores separately.
+10 -1
tools/perf/util/pfm.c
··· 62 62 } 63 63 64 64 /* no event */ 65 - if (*q == '\0') 65 + if (*q == '\0') { 66 + if (*sep == '}') { 67 + if (grp_evt < 0) { 68 + ui__error("cannot close a non-existing event group\n"); 69 + goto error; 70 + } 71 + grp_evt--; 72 + } 66 73 continue; 74 + } 67 75 68 76 memset(&attr, 0, sizeof(attr)); 69 77 event_attr_init(&attr); ··· 115 107 grp_evt = -1; 116 108 } 117 109 } 110 + free(p_orig); 118 111 return 0; 119 112 error: 120 113 free(p_orig);