diff options
| author | Ingo Molnar <mingo@kernel.org> | 2019-01-22 05:08:47 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2019-01-22 05:08:47 -0500 |
| commit | d3c8c0af7565ae5b4f9e65cff6e824ee2acdd451 (patch) | |
| tree | 16e78103b91039758bea5104dbfee345cbb246c3 | |
| parent | d7393226d15add056285c8fc86723d54d7e0c77d (diff) | |
| parent | 8bf8c6da53c2265aea365a1de6038f118f522113 (diff) | |
Merge tag 'perf-urgent-for-mingo-5.0-20190121' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
Kernel:
Stephane Eranian:
- Fix perf_proc_update_handler() bug.
perf script:
Andi Kleen:
- Fix crash with printing mixed trace point and other events.
Tony Jones:
- Fix crash when processing recorded stat data.
perf top:
He Kuang:
- Fix wrong hottest instruction highlighted.
perf python:
Arnaldo Carvalho de Melo:
- Remove -fstack-clash-protection when building with some clang versions.
perf ordered_events:
Jiri Olsa:
- Fix out of buffers crash in ordered_events__free().
perf cpu_map:
Stephane Eranian:
- Handle TOPOLOGY headers with no CPU.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | kernel/events/core.c | 14 | ||||
| -rw-r--r-- | tools/perf/builtin-script.c | 9 | ||||
| -rw-r--r-- | tools/perf/ui/browsers/annotate.c | 16 | ||||
| -rw-r--r-- | tools/perf/util/cpumap.c | 11 | ||||
| -rw-r--r-- | tools/perf/util/ordered-events.c | 6 | ||||
| -rw-r--r-- | tools/perf/util/setup.py | 2 |
6 files changed, 35 insertions, 23 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 3cd13a30f732..e5ede6918050 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
| @@ -436,18 +436,18 @@ int perf_proc_update_handler(struct ctl_table *table, int write, | |||
| 436 | void __user *buffer, size_t *lenp, | 436 | void __user *buffer, size_t *lenp, |
| 437 | loff_t *ppos) | 437 | loff_t *ppos) |
| 438 | { | 438 | { |
| 439 | int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | 439 | int ret; |
| 440 | 440 | int perf_cpu = sysctl_perf_cpu_time_max_percent; | |
| 441 | if (ret || !write) | ||
| 442 | return ret; | ||
| 443 | |||
| 444 | /* | 441 | /* |
| 445 | * If throttling is disabled don't allow the write: | 442 | * If throttling is disabled don't allow the write: |
| 446 | */ | 443 | */ |
| 447 | if (sysctl_perf_cpu_time_max_percent == 100 || | 444 | if (write && (perf_cpu == 100 || perf_cpu == 0)) |
| 448 | sysctl_perf_cpu_time_max_percent == 0) | ||
| 449 | return -EINVAL; | 445 | return -EINVAL; |
| 450 | 446 | ||
| 447 | ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | ||
| 448 | if (ret || !write) | ||
| 449 | return ret; | ||
| 450 | |||
| 451 | max_samples_per_tick = DIV_ROUND_UP(sysctl_perf_event_sample_rate, HZ); | 451 | max_samples_per_tick = DIV_ROUND_UP(sysctl_perf_event_sample_rate, HZ); |
| 452 | perf_sample_period_ns = NSEC_PER_SEC / sysctl_perf_event_sample_rate; | 452 | perf_sample_period_ns = NSEC_PER_SEC / sysctl_perf_event_sample_rate; |
| 453 | update_perf_cpu_limits(); | 453 | update_perf_cpu_limits(); |
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index d079f36d342d..ac221f137ed2 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
| @@ -1681,13 +1681,8 @@ static void perf_sample__fprint_metric(struct perf_script *script, | |||
| 1681 | .force_header = false, | 1681 | .force_header = false, |
| 1682 | }; | 1682 | }; |
| 1683 | struct perf_evsel *ev2; | 1683 | struct perf_evsel *ev2; |
| 1684 | static bool init; | ||
| 1685 | u64 val; | 1684 | u64 val; |
| 1686 | 1685 | ||
| 1687 | if (!init) { | ||
| 1688 | perf_stat__init_shadow_stats(); | ||
| 1689 | init = true; | ||
| 1690 | } | ||
| 1691 | if (!evsel->stats) | 1686 | if (!evsel->stats) |
| 1692 | perf_evlist__alloc_stats(script->session->evlist, false); | 1687 | perf_evlist__alloc_stats(script->session->evlist, false); |
| 1693 | if (evsel_script(evsel->leader)->gnum++ == 0) | 1688 | if (evsel_script(evsel->leader)->gnum++ == 0) |
| @@ -1794,7 +1789,7 @@ static void process_event(struct perf_script *script, | |||
| 1794 | return; | 1789 | return; |
| 1795 | } | 1790 | } |
| 1796 | 1791 | ||
| 1797 | if (PRINT_FIELD(TRACE)) { | 1792 | if (PRINT_FIELD(TRACE) && sample->raw_data) { |
| 1798 | event_format__fprintf(evsel->tp_format, sample->cpu, | 1793 | event_format__fprintf(evsel->tp_format, sample->cpu, |
| 1799 | sample->raw_data, sample->raw_size, fp); | 1794 | sample->raw_data, sample->raw_size, fp); |
| 1800 | } | 1795 | } |
| @@ -2359,6 +2354,8 @@ static int __cmd_script(struct perf_script *script) | |||
| 2359 | 2354 | ||
| 2360 | signal(SIGINT, sig_handler); | 2355 | signal(SIGINT, sig_handler); |
| 2361 | 2356 | ||
| 2357 | perf_stat__init_shadow_stats(); | ||
| 2358 | |||
| 2362 | /* override event processing functions */ | 2359 | /* override event processing functions */ |
| 2363 | if (script->show_task_events) { | 2360 | if (script->show_task_events) { |
| 2364 | script->tool.comm = process_comm_event; | 2361 | script->tool.comm = process_comm_event; |
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 1d00e5ec7906..82e16bf84466 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
| @@ -224,20 +224,24 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser) | |||
| 224 | return ret; | 224 | return ret; |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | static int disasm__cmp(struct annotation_line *a, struct annotation_line *b) | 227 | static double disasm__cmp(struct annotation_line *a, struct annotation_line *b, |
| 228 | int percent_type) | ||
| 228 | { | 229 | { |
| 229 | int i; | 230 | int i; |
| 230 | 231 | ||
| 231 | for (i = 0; i < a->data_nr; i++) { | 232 | for (i = 0; i < a->data_nr; i++) { |
| 232 | if (a->data[i].percent == b->data[i].percent) | 233 | if (a->data[i].percent[percent_type] == b->data[i].percent[percent_type]) |
| 233 | continue; | 234 | continue; |
| 234 | return a->data[i].percent < b->data[i].percent; | 235 | return a->data[i].percent[percent_type] - |
| 236 | b->data[i].percent[percent_type]; | ||
| 235 | } | 237 | } |
| 236 | return 0; | 238 | return 0; |
| 237 | } | 239 | } |
| 238 | 240 | ||
| 239 | static void disasm_rb_tree__insert(struct rb_root *root, struct annotation_line *al) | 241 | static void disasm_rb_tree__insert(struct annotate_browser *browser, |
| 242 | struct annotation_line *al) | ||
| 240 | { | 243 | { |
| 244 | struct rb_root *root = &browser->entries; | ||
| 241 | struct rb_node **p = &root->rb_node; | 245 | struct rb_node **p = &root->rb_node; |
| 242 | struct rb_node *parent = NULL; | 246 | struct rb_node *parent = NULL; |
| 243 | struct annotation_line *l; | 247 | struct annotation_line *l; |
| @@ -246,7 +250,7 @@ static void disasm_rb_tree__insert(struct rb_root *root, struct annotation_line | |||
| 246 | parent = *p; | 250 | parent = *p; |
| 247 | l = rb_entry(parent, struct annotation_line, rb_node); | 251 | l = rb_entry(parent, struct annotation_line, rb_node); |
| 248 | 252 | ||
| 249 | if (disasm__cmp(al, l)) | 253 | if (disasm__cmp(al, l, browser->opts->percent_type) < 0) |
| 250 | p = &(*p)->rb_left; | 254 | p = &(*p)->rb_left; |
| 251 | else | 255 | else |
| 252 | p = &(*p)->rb_right; | 256 | p = &(*p)->rb_right; |
| @@ -329,7 +333,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, | |||
| 329 | RB_CLEAR_NODE(&pos->al.rb_node); | 333 | RB_CLEAR_NODE(&pos->al.rb_node); |
| 330 | continue; | 334 | continue; |
| 331 | } | 335 | } |
| 332 | disasm_rb_tree__insert(&browser->entries, &pos->al); | 336 | disasm_rb_tree__insert(browser, &pos->al); |
| 333 | } | 337 | } |
| 334 | pthread_mutex_unlock(¬es->lock); | 338 | pthread_mutex_unlock(¬es->lock); |
| 335 | 339 | ||
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 1ccbd3342069..383674f448fc 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c | |||
| @@ -134,7 +134,12 @@ struct cpu_map *cpu_map__new(const char *cpu_list) | |||
| 134 | if (!cpu_list) | 134 | if (!cpu_list) |
| 135 | return cpu_map__read_all_cpu_map(); | 135 | return cpu_map__read_all_cpu_map(); |
| 136 | 136 | ||
| 137 | if (!isdigit(*cpu_list)) | 137 | /* |
| 138 | * must handle the case of empty cpumap to cover | ||
| 139 | * TOPOLOGY header for NUMA nodes with no CPU | ||
| 140 | * ( e.g., because of CPU hotplug) | ||
| 141 | */ | ||
| 142 | if (!isdigit(*cpu_list) && *cpu_list != '\0') | ||
| 138 | goto out; | 143 | goto out; |
| 139 | 144 | ||
| 140 | while (isdigit(*cpu_list)) { | 145 | while (isdigit(*cpu_list)) { |
| @@ -181,8 +186,10 @@ struct cpu_map *cpu_map__new(const char *cpu_list) | |||
| 181 | 186 | ||
| 182 | if (nr_cpus > 0) | 187 | if (nr_cpus > 0) |
| 183 | cpus = cpu_map__trim_new(nr_cpus, tmp_cpus); | 188 | cpus = cpu_map__trim_new(nr_cpus, tmp_cpus); |
| 184 | else | 189 | else if (*cpu_list != '\0') |
| 185 | cpus = cpu_map__default_new(); | 190 | cpus = cpu_map__default_new(); |
| 191 | else | ||
| 192 | cpus = cpu_map__dummy_new(); | ||
| 186 | invalid: | 193 | invalid: |
| 187 | free(tmp_cpus); | 194 | free(tmp_cpus); |
| 188 | out: | 195 | out: |
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c index 897589507d97..ea523d3b248f 100644 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c | |||
| @@ -391,8 +391,10 @@ void ordered_events__free(struct ordered_events *oe) | |||
| 391 | * Current buffer might not have all the events allocated | 391 | * Current buffer might not have all the events allocated |
| 392 | * yet, we need to free only allocated ones ... | 392 | * yet, we need to free only allocated ones ... |
| 393 | */ | 393 | */ |
| 394 | list_del(&oe->buffer->list); | 394 | if (oe->buffer) { |
| 395 | ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe); | 395 | list_del(&oe->buffer->list); |
| 396 | ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe); | ||
| 397 | } | ||
| 396 | 398 | ||
| 397 | /* ... and continue with the rest */ | 399 | /* ... and continue with the rest */ |
| 398 | list_for_each_entry_safe(buffer, tmp, &oe->to_free, list) { | 400 | list_for_each_entry_safe(buffer, tmp, &oe->to_free, list) { |
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py index 63f758c655d5..64d1f36dee99 100644 --- a/tools/perf/util/setup.py +++ b/tools/perf/util/setup.py | |||
| @@ -17,6 +17,8 @@ if cc == "clang": | |||
| 17 | vars[var] = sub("-mcet", "", vars[var]) | 17 | vars[var] = sub("-mcet", "", vars[var]) |
| 18 | if not clang_has_option("-fcf-protection"): | 18 | if not clang_has_option("-fcf-protection"): |
| 19 | vars[var] = sub("-fcf-protection", "", vars[var]) | 19 | vars[var] = sub("-fcf-protection", "", vars[var]) |
| 20 | if not clang_has_option("-fstack-clash-protection"): | ||
| 21 | vars[var] = sub("-fstack-clash-protection", "", vars[var]) | ||
| 20 | 22 | ||
| 21 | from distutils.core import setup, Extension | 23 | from distutils.core import setup, Extension |
| 22 | 24 | ||
