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 branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf fixes from Thomas Gleixner:
"A pile of perf updates:

- Fix broken sanity check in the /proc/sys/kernel/perf_cpu_time_max_percent
write handler

- Cure a perf script crash which caused by an unitinialized data
structure

- Highlight the hottest instruction in perf top and not a random one

- Cure yet another clang issue when building perf python

- Handle topology entries with no CPU correctly in the tools

- Handle perf data which contains both tracepoints and performance
counter entries correctly.

- Add a missing NULL pointer check in perf ordered_events_free()"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
perf script: Fix crash when processing recorded stat data
perf top: Fix wrong hottest instruction highlighted
perf tools: Handle TOPOLOGY headers with no CPU
perf python: Remove -fstack-clash-protection when building with some clang versions
perf core: Fix perf_proc_update_handler() bug
perf script: Fix crash with printing mixed trace point and other events
perf ordered_events: Fix crash in ordered_events__free

+35 -23
+7 -7
kernel/events/core.c
··· 436 436 void __user *buffer, size_t *lenp, 437 437 loff_t *ppos) 438 438 { 439 - int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 440 - 441 - if (ret || !write) 442 - return ret; 443 - 439 + int ret; 440 + int perf_cpu = sysctl_perf_cpu_time_max_percent; 444 441 /* 445 442 * If throttling is disabled don't allow the write: 446 443 */ 447 - if (sysctl_perf_cpu_time_max_percent == 100 || 448 - sysctl_perf_cpu_time_max_percent == 0) 444 + if (write && (perf_cpu == 100 || perf_cpu == 0)) 449 445 return -EINVAL; 446 + 447 + ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 448 + if (ret || !write) 449 + return ret; 450 450 451 451 max_samples_per_tick = DIV_ROUND_UP(sysctl_perf_event_sample_rate, HZ); 452 452 perf_sample_period_ns = NSEC_PER_SEC / sysctl_perf_event_sample_rate;
+3 -6
tools/perf/builtin-script.c
··· 1681 1681 .force_header = false, 1682 1682 }; 1683 1683 struct perf_evsel *ev2; 1684 - static bool init; 1685 1684 u64 val; 1686 1685 1687 - if (!init) { 1688 - perf_stat__init_shadow_stats(); 1689 - init = true; 1690 - } 1691 1686 if (!evsel->stats) 1692 1687 perf_evlist__alloc_stats(script->session->evlist, false); 1693 1688 if (evsel_script(evsel->leader)->gnum++ == 0) ··· 1789 1794 return; 1790 1795 } 1791 1796 1792 - if (PRINT_FIELD(TRACE)) { 1797 + if (PRINT_FIELD(TRACE) && sample->raw_data) { 1793 1798 event_format__fprintf(evsel->tp_format, sample->cpu, 1794 1799 sample->raw_data, sample->raw_size, fp); 1795 1800 } ··· 2353 2358 int ret; 2354 2359 2355 2360 signal(SIGINT, sig_handler); 2361 + 2362 + perf_stat__init_shadow_stats(); 2356 2363 2357 2364 /* override event processing functions */ 2358 2365 if (script->show_task_events) {
+10 -6
tools/perf/ui/browsers/annotate.c
··· 224 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 230 int i; 230 231 231 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 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 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 245 struct rb_node **p = &root->rb_node; 242 246 struct rb_node *parent = NULL; 243 247 struct annotation_line *l; ··· 250 246 parent = *p; 251 247 l = rb_entry(parent, struct annotation_line, rb_node); 252 248 253 - if (disasm__cmp(al, l)) 249 + if (disasm__cmp(al, l, browser->opts->percent_type) < 0) 254 250 p = &(*p)->rb_left; 255 251 else 256 252 p = &(*p)->rb_right; ··· 333 329 RB_CLEAR_NODE(&pos->al.rb_node); 334 330 continue; 335 331 } 336 - disasm_rb_tree__insert(&browser->entries, &pos->al); 332 + disasm_rb_tree__insert(browser, &pos->al); 337 333 } 338 334 pthread_mutex_unlock(&notes->lock); 339 335
+9 -2
tools/perf/util/cpumap.c
··· 134 134 if (!cpu_list) 135 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 143 goto out; 139 144 140 145 while (isdigit(*cpu_list)) { ··· 186 181 187 182 if (nr_cpus > 0) 188 183 cpus = cpu_map__trim_new(nr_cpus, tmp_cpus); 189 - else 184 + else if (*cpu_list != '\0') 190 185 cpus = cpu_map__default_new(); 186 + else 187 + cpus = cpu_map__dummy_new(); 191 188 invalid: 192 189 free(tmp_cpus); 193 190 out:
+4 -2
tools/perf/util/ordered-events.c
··· 391 391 * Current buffer might not have all the events allocated 392 392 * yet, we need to free only allocated ones ... 393 393 */ 394 - list_del(&oe->buffer->list); 395 - ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe); 394 + if (oe->buffer) { 395 + list_del(&oe->buffer->list); 396 + ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe); 397 + } 396 398 397 399 /* ... and continue with the rest */ 398 400 list_for_each_entry_safe(buffer, tmp, &oe->to_free, list) {
+2
tools/perf/util/setup.py
··· 17 17 vars[var] = sub("-mcet", "", vars[var]) 18 18 if not clang_has_option("-fcf-protection"): 19 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 23 from distutils.core import setup, Extension 22 24