Commit 24a0b220 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'perf-tools-fixes-for-v5.16-2022-01-02' of...

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()
parents 859431ac 64f18d2d
...@@ -2473,7 +2473,7 @@ static int process_switch_event(struct perf_tool *tool, ...@@ -2473,7 +2473,7 @@ static int process_switch_event(struct perf_tool *tool,
if (perf_event__process_switch(tool, event, sample, machine) < 0) if (perf_event__process_switch(tool, event, sample, machine) < 0)
return -1; return -1;
if (scripting_ops && scripting_ops->process_switch) if (scripting_ops && scripting_ops->process_switch && !filter_cpu(sample))
scripting_ops->process_switch(event, sample, machine); scripting_ops->process_switch(event, sample, machine);
if (!script->show_switch_events) if (!script->show_switch_events)
......
...@@ -32,8 +32,7 @@ try: ...@@ -32,8 +32,7 @@ try:
except: except:
broken_pipe_exception = IOError broken_pipe_exception = IOError
glb_switch_str = None glb_switch_str = {}
glb_switch_printed = True
glb_insn = False glb_insn = False
glb_disassembler = None glb_disassembler = None
glb_src = False glb_src = False
...@@ -70,6 +69,7 @@ def trace_begin(): ...@@ -70,6 +69,7 @@ def trace_begin():
ap = argparse.ArgumentParser(usage = "", add_help = False) ap = argparse.ArgumentParser(usage = "", add_help = False)
ap.add_argument("--insn-trace", action='store_true') ap.add_argument("--insn-trace", action='store_true')
ap.add_argument("--src-trace", action='store_true') ap.add_argument("--src-trace", action='store_true')
ap.add_argument("--all-switch-events", action='store_true')
global glb_args global glb_args
global glb_insn global glb_insn
global glb_src global glb_src
...@@ -256,10 +256,6 @@ def print_srccode(comm, param_dict, sample, symbol, dso, with_insn): ...@@ -256,10 +256,6 @@ def print_srccode(comm, param_dict, sample, symbol, dso, with_insn):
print(start_str, src_str) print(start_str, src_str)
def do_process_event(param_dict): def do_process_event(param_dict):
global glb_switch_printed
if not glb_switch_printed:
print(glb_switch_str)
glb_switch_printed = True
event_attr = param_dict["attr"] event_attr = param_dict["attr"]
sample = param_dict["sample"] sample = param_dict["sample"]
raw_buf = param_dict["raw_buf"] raw_buf = param_dict["raw_buf"]
...@@ -274,6 +270,11 @@ def do_process_event(param_dict): ...@@ -274,6 +270,11 @@ def do_process_event(param_dict):
dso = get_optional(param_dict, "dso") dso = get_optional(param_dict, "dso")
symbol = get_optional(param_dict, "symbol") symbol = get_optional(param_dict, "symbol")
cpu = sample["cpu"]
if cpu in glb_switch_str:
print(glb_switch_str[cpu])
del glb_switch_str[cpu]
if name[0:12] == "instructions": if name[0:12] == "instructions":
if glb_src: if glb_src:
print_srccode(comm, param_dict, sample, symbol, dso, True) print_srccode(comm, param_dict, sample, symbol, dso, True)
...@@ -336,8 +337,6 @@ def auxtrace_error(typ, code, cpu, pid, tid, ip, ts, msg, cpumode, *x): ...@@ -336,8 +337,6 @@ def auxtrace_error(typ, code, cpu, pid, tid, ip, ts, msg, cpumode, *x):
sys.exit(1) sys.exit(1)
def context_switch(ts, cpu, pid, tid, np_pid, np_tid, machine_pid, out, out_preempt, *x): def context_switch(ts, cpu, pid, tid, np_pid, np_tid, machine_pid, out, out_preempt, *x):
global glb_switch_printed
global glb_switch_str
if out: if out:
out_str = "Switch out " out_str = "Switch out "
else: else:
...@@ -350,6 +349,10 @@ def context_switch(ts, cpu, pid, tid, np_pid, np_tid, machine_pid, out, out_pree ...@@ -350,6 +349,10 @@ def context_switch(ts, cpu, pid, tid, np_pid, np_tid, machine_pid, out, out_pree
machine_str = "" machine_str = ""
else: else:
machine_str = "machine PID %d" % machine_pid machine_str = "machine PID %d" % machine_pid
glb_switch_str = "%16s %5d/%-5d [%03u] %9u.%09u %5d/%-5d %s %s" % \ switch_str = "%16s %5d/%-5d [%03u] %9u.%09u %5d/%-5d %s %s" % \
(out_str, pid, tid, cpu, ts / 1000000000, ts %1000000000, np_pid, np_tid, machine_str, preempt_str) (out_str, pid, tid, cpu, ts / 1000000000, ts %1000000000, np_pid, np_tid, machine_str, preempt_str)
glb_switch_printed = False if glb_args.all_switch_events:
print(switch_str);
else:
global glb_switch_str
glb_switch_str[cpu] = switch_str
...@@ -170,9 +170,11 @@ void ui__exit(bool wait_for_ok) ...@@ -170,9 +170,11 @@ void ui__exit(bool wait_for_ok)
"Press any key...", 0); "Press any key...", 0);
SLtt_set_cursor_visibility(1); SLtt_set_cursor_visibility(1);
SLsmg_refresh(); if (!pthread_mutex_trylock(&ui__lock)) {
SLsmg_reset_smg(); SLsmg_refresh();
SLsmg_reset_smg();
pthread_mutex_unlock(&ui__lock);
}
SLang_reset_tty(); SLang_reset_tty();
perf_error__unregister(&perf_tui_eops); perf_error__unregister(&perf_tui_eops);
} }
...@@ -66,7 +66,12 @@ static bool key_equal(const void *key1, const void *key2, ...@@ -66,7 +66,12 @@ static bool key_equal(const void *key1, const void *key2,
struct hashmap *ids__new(void) struct hashmap *ids__new(void)
{ {
return hashmap__new(key_hash, key_equal, NULL); struct hashmap *hash;
hash = hashmap__new(key_hash, key_equal, NULL);
if (IS_ERR(hash))
return NULL;
return hash;
} }
void ids__free(struct hashmap *ids) void ids__free(struct hashmap *ids)
......
...@@ -3625,6 +3625,7 @@ static int intel_pt_parse_vm_tm_corr_arg(struct intel_pt *pt, char **args) ...@@ -3625,6 +3625,7 @@ static int intel_pt_parse_vm_tm_corr_arg(struct intel_pt *pt, char **args)
*args = p; *args = p;
return 0; return 0;
} }
p += 1;
while (1) { while (1) {
vmcs = strtoull(p, &p, 0); vmcs = strtoull(p, &p, 0);
if (errno) if (errno)
......
...@@ -1659,6 +1659,21 @@ bool is_pmu_core(const char *name) ...@@ -1659,6 +1659,21 @@ bool is_pmu_core(const char *name)
return !strcmp(name, "cpu") || is_arm_pmu_core(name); return !strcmp(name, "cpu") || is_arm_pmu_core(name);
} }
static bool pmu_alias_is_duplicate(struct sevent *alias_a,
struct sevent *alias_b)
{
/* Different names -> never duplicates */
if (strcmp(alias_a->name, alias_b->name))
return false;
/* Don't remove duplicates for hybrid PMUs */
if (perf_pmu__is_hybrid(alias_a->pmu) &&
perf_pmu__is_hybrid(alias_b->pmu))
return false;
return true;
}
void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag, void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
bool long_desc, bool details_flag, bool deprecated, bool long_desc, bool details_flag, bool deprecated,
const char *pmu_name) const char *pmu_name)
...@@ -1744,12 +1759,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag, ...@@ -1744,12 +1759,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
qsort(aliases, len, sizeof(struct sevent), cmp_sevent); qsort(aliases, len, sizeof(struct sevent), cmp_sevent);
for (j = 0; j < len; j++) { for (j = 0; j < len; j++) {
/* Skip duplicates */ /* Skip duplicates */
if (j > 0 && !strcmp(aliases[j].name, aliases[j - 1].name)) { if (j > 0 && pmu_alias_is_duplicate(&aliases[j], &aliases[j - 1]))
if (!aliases[j].pmu || !aliases[j - 1].pmu || continue;
!strcmp(aliases[j].pmu, aliases[j - 1].pmu)) {
continue;
}
}
if (name_only) { if (name_only) {
printf("%s ", aliases[j].name); printf("%s ", aliases[j].name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment