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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'perf-tools-fixes-for-v5.16-2022-01-02' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

Pull perf tools fixes from Arnaldo Carvalho de Melo:

- Fix TUI exit screen refresh race condition in 'perf top'.

- Fix parsing of Intel PT VM time correlation arguments.

- Honour CPU filtering command line request of a script's switch events
in 'perf script'.

- Fix printing of switch events in Intel PT python script.

- Fix duplicate alias events list printing in 'perf list', noticed on
heterogeneous arm64 systems.

- Fix return value of ids__new(), users expect NULL for failure, not
ERR_PTR(-ENOMEM).

* tag 'perf-tools-fixes-for-v5.16-2022-01-02' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
perf top: Fix TUI exit screen refresh race condition
perf pmu: Fix alias events list
perf scripts python: intel-pt-events.py: Fix printing of switch events
perf script: Fix CPU filtering of a script's switch events
perf intel-pt: Fix parsing of VM time correlation arguments
perf expr: Fix return value of ids__new()

+43 -21
+1 -1
tools/perf/builtin-script.c
··· 2473 2473 if (perf_event__process_switch(tool, event, sample, machine) < 0) 2474 2474 return -1; 2475 2475 2476 - if (scripting_ops && scripting_ops->process_switch) 2476 + if (scripting_ops && scripting_ops->process_switch && !filter_cpu(sample)) 2477 2477 scripting_ops->process_switch(event, sample, machine); 2478 2478 2479 2479 if (!script->show_switch_events)
+13 -10
tools/perf/scripts/python/intel-pt-events.py
··· 32 32 except: 33 33 broken_pipe_exception = IOError 34 34 35 - glb_switch_str = None 36 - glb_switch_printed = True 35 + glb_switch_str = {} 37 36 glb_insn = False 38 37 glb_disassembler = None 39 38 glb_src = False ··· 69 70 ap = argparse.ArgumentParser(usage = "", add_help = False) 70 71 ap.add_argument("--insn-trace", action='store_true') 71 72 ap.add_argument("--src-trace", action='store_true') 73 + ap.add_argument("--all-switch-events", action='store_true') 72 74 global glb_args 73 75 global glb_insn 74 76 global glb_src ··· 256 256 print(start_str, src_str) 257 257 258 258 def do_process_event(param_dict): 259 - global glb_switch_printed 260 - if not glb_switch_printed: 261 - print(glb_switch_str) 262 - glb_switch_printed = True 263 259 event_attr = param_dict["attr"] 264 260 sample = param_dict["sample"] 265 261 raw_buf = param_dict["raw_buf"] ··· 269 273 # Symbol and dso info are not always resolved 270 274 dso = get_optional(param_dict, "dso") 271 275 symbol = get_optional(param_dict, "symbol") 276 + 277 + cpu = sample["cpu"] 278 + if cpu in glb_switch_str: 279 + print(glb_switch_str[cpu]) 280 + del glb_switch_str[cpu] 272 281 273 282 if name[0:12] == "instructions": 274 283 if glb_src: ··· 337 336 sys.exit(1) 338 337 339 338 def context_switch(ts, cpu, pid, tid, np_pid, np_tid, machine_pid, out, out_preempt, *x): 340 - global glb_switch_printed 341 - global glb_switch_str 342 339 if out: 343 340 out_str = "Switch out " 344 341 else: ··· 349 350 machine_str = "" 350 351 else: 351 352 machine_str = "machine PID %d" % machine_pid 352 - glb_switch_str = "%16s %5d/%-5d [%03u] %9u.%09u %5d/%-5d %s %s" % \ 353 + switch_str = "%16s %5d/%-5d [%03u] %9u.%09u %5d/%-5d %s %s" % \ 353 354 (out_str, pid, tid, cpu, ts / 1000000000, ts %1000000000, np_pid, np_tid, machine_str, preempt_str) 354 - glb_switch_printed = False 355 + if glb_args.all_switch_events: 356 + print(switch_str); 357 + else: 358 + global glb_switch_str 359 + glb_switch_str[cpu] = switch_str
+5 -3
tools/perf/ui/tui/setup.c
··· 170 170 "Press any key...", 0); 171 171 172 172 SLtt_set_cursor_visibility(1); 173 - SLsmg_refresh(); 174 - SLsmg_reset_smg(); 173 + if (!pthread_mutex_trylock(&ui__lock)) { 174 + SLsmg_refresh(); 175 + SLsmg_reset_smg(); 176 + pthread_mutex_unlock(&ui__lock); 177 + } 175 178 SLang_reset_tty(); 176 - 177 179 perf_error__unregister(&perf_tui_eops); 178 180 }
+6 -1
tools/perf/util/expr.c
··· 66 66 67 67 struct hashmap *ids__new(void) 68 68 { 69 - return hashmap__new(key_hash, key_equal, NULL); 69 + struct hashmap *hash; 70 + 71 + hash = hashmap__new(key_hash, key_equal, NULL); 72 + if (IS_ERR(hash)) 73 + return NULL; 74 + return hash; 70 75 } 71 76 72 77 void ids__free(struct hashmap *ids)
+1
tools/perf/util/intel-pt.c
··· 3625 3625 *args = p; 3626 3626 return 0; 3627 3627 } 3628 + p += 1; 3628 3629 while (1) { 3629 3630 vmcs = strtoull(p, &p, 0); 3630 3631 if (errno)
+17 -6
tools/perf/util/pmu.c
··· 1659 1659 return !strcmp(name, "cpu") || is_arm_pmu_core(name); 1660 1660 } 1661 1661 1662 + static bool pmu_alias_is_duplicate(struct sevent *alias_a, 1663 + struct sevent *alias_b) 1664 + { 1665 + /* Different names -> never duplicates */ 1666 + if (strcmp(alias_a->name, alias_b->name)) 1667 + return false; 1668 + 1669 + /* Don't remove duplicates for hybrid PMUs */ 1670 + if (perf_pmu__is_hybrid(alias_a->pmu) && 1671 + perf_pmu__is_hybrid(alias_b->pmu)) 1672 + return false; 1673 + 1674 + return true; 1675 + } 1676 + 1662 1677 void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag, 1663 1678 bool long_desc, bool details_flag, bool deprecated, 1664 1679 const char *pmu_name) ··· 1759 1744 qsort(aliases, len, sizeof(struct sevent), cmp_sevent); 1760 1745 for (j = 0; j < len; j++) { 1761 1746 /* Skip duplicates */ 1762 - if (j > 0 && !strcmp(aliases[j].name, aliases[j - 1].name)) { 1763 - if (!aliases[j].pmu || !aliases[j - 1].pmu || 1764 - !strcmp(aliases[j].pmu, aliases[j - 1].pmu)) { 1765 - continue; 1766 - } 1767 - } 1747 + if (j > 0 && pmu_alias_is_duplicate(&aliases[j], &aliases[j - 1])) 1748 + continue; 1768 1749 1769 1750 if (name_only) { 1770 1751 printf("%s ", aliases[j].name);