Commit a448a0318af1a11b8f54d01a349b0036a3cff965

Authored by Ingo Molnar

Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/g…

…it/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

* The python binding needs to link with libtraceevent and to initialize
  the 'page_size' variable so that mmaping works again.

* The callchain folding character that appears on the TUI just before
  the overhead had disappeared due to recent changes, add it back.

* Intel PEBS in VT-x context uses the DS address as a guest linear address,
  even though its programmed by the host as a host linear address. This either
  results in guest memory corruption and or the hardware faulting and 'crashing'
  the virtual machine.  Therefore we have to disable PEBS on VT-x enter and
  re-enable on VT-x exit, enforcing a strict exclude_guest.

  Kernel side enforcement fix by Peter Zijlstra, tooling side fix by David Ahern.

* Fix build on sparc due to UAPI, fix from David Miller.

* Fixes for the srclike sort key for unresolved symbols and when processing
  samples in JITted code, where we don't have an ELF file, just an special
  symbol table, fixes from Namhyung Kim.

* Fix some leaks in libtraceevent, from Steven Rostedt.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>

Showing 9 changed files Side-by-side Diff

arch/x86/kernel/cpu/perf_event.c
... ... @@ -338,6 +338,9 @@
338 338 /* BTS is currently only allowed for user-mode. */
339 339 if (!attr->exclude_kernel)
340 340 return -EOPNOTSUPP;
  341 +
  342 + if (!attr->exclude_guest)
  343 + return -EOPNOTSUPP;
341 344 }
342 345  
343 346 hwc->config |= config;
... ... @@ -379,6 +382,9 @@
379 382 {
380 383 if (event->attr.precise_ip) {
381 384 int precise = 0;
  385 +
  386 + if (!event->attr.exclude_guest)
  387 + return -EOPNOTSUPP;
382 388  
383 389 /* Support for constant skid */
384 390 if (x86_pmu.pebs_active && !x86_pmu.pebs_broken) {
tools/lib/traceevent/event-parse.c
... ... @@ -2602,6 +2602,9 @@
2602 2602 {
2603 2603 struct pevent_function_handler *func;
2604 2604  
  2605 + if (!pevent)
  2606 + return NULL;
  2607 +
2605 2608 for (func = pevent->func_handlers; func; func = func->next) {
2606 2609 if (strcmp(func->name, func_name) == 0)
2607 2610 break;
... ... @@ -4938,6 +4941,9 @@
4938 4941 goto event_alloc_failed;
4939 4942 }
4940 4943  
  4944 + /* Add pevent to event so that it can be referenced */
  4945 + event->pevent = pevent;
  4946 +
4941 4947 ret = event_read_format(event);
4942 4948 if (ret < 0) {
4943 4949 ret = PEVENT_ERRNO__READ_FORMAT_FAILED;
... ... @@ -5040,9 +5046,6 @@
5040 5046  
5041 5047 if (event == NULL)
5042 5048 return ret;
5043   -
5044   - /* Add pevent to event so that it can be referenced */
5045   - event->pevent = pevent;
5046 5049  
5047 5050 if (add_event(pevent, event)) {
5048 5051 ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
tools/lib/traceevent/parse-filter.c
... ... @@ -209,13 +209,28 @@
209 209 switch (arg->type) {
210 210 case FILTER_ARG_NONE:
211 211 case FILTER_ARG_BOOLEAN:
  212 + break;
  213 +
212 214 case FILTER_ARG_NUM:
  215 + free_arg(arg->num.left);
  216 + free_arg(arg->num.right);
213 217 break;
214 218  
  219 + case FILTER_ARG_EXP:
  220 + free_arg(arg->exp.left);
  221 + free_arg(arg->exp.right);
  222 + break;
  223 +
215 224 case FILTER_ARG_STR:
216 225 free(arg->str.val);
217 226 regfree(&arg->str.reg);
218 227 free(arg->str.buffer);
  228 + break;
  229 +
  230 + case FILTER_ARG_VALUE:
  231 + if (arg->value.type == FILTER_STRING ||
  232 + arg->value.type == FILTER_CHAR)
  233 + free(arg->value.str);
219 234 break;
220 235  
221 236 case FILTER_ARG_OP:
... ... @@ -57,7 +57,7 @@
57 57 #endif
58 58  
59 59 #ifdef __sparc__
60   -#include "../../arch/sparc/include/asm/unistd.h"
  60 +#include "../../arch/sparc/include/uapi/asm/unistd.h"
61 61 #define rmb() asm volatile("":::"memory")
62 62 #define cpu_relax() asm volatile("":::"memory")
63 63 #define CPUINFO_PROC "cpu"
tools/perf/ui/browsers/hists.c
... ... @@ -610,6 +610,7 @@
610 610 char folded_sign = ' ';
611 611 bool current_entry = ui_browser__is_current_entry(&browser->b, row);
612 612 off_t row_offset = entry->row_offset;
  613 + bool first = true;
613 614  
614 615 if (current_entry) {
615 616 browser->he_selection = entry;
616 617  
... ... @@ -633,10 +634,11 @@
633 634 if (!perf_hpp__format[i].cond)
634 635 continue;
635 636  
636   - if (i) {
  637 + if (!first) {
637 638 slsmg_printf(" ");
638 639 width -= 2;
639 640 }
  641 + first = false;
640 642  
641 643 if (perf_hpp__format[i].color) {
642 644 hpp.ptr = &percent;
... ... @@ -645,7 +647,7 @@
645 647  
646 648 ui_browser__set_percent_color(&browser->b, percent, current_entry);
647 649  
648   - if (i == 0 && symbol_conf.use_callchain) {
  650 + if (i == PERF_HPP__OVERHEAD && symbol_conf.use_callchain) {
649 651 slsmg_printf("%c ", folded_sign);
650 652 width -= 2;
651 653 }
tools/perf/util/parse-events.c
... ... @@ -690,6 +690,9 @@
690 690 eH = 0;
691 691 } else if (*str == 'p') {
692 692 precise++;
  693 + /* use of precise requires exclude_guest */
  694 + if (!exclude_GH)
  695 + eG = 1;
693 696 } else
694 697 break;
695 698  
tools/perf/util/python.c
... ... @@ -1015,6 +1015,8 @@
1015 1015 pyrf_cpu_map__setup_types() < 0)
1016 1016 return;
1017 1017  
  1018 + page_size = sysconf(_SC_PAGE_SIZE);
  1019 +
1018 1020 Py_INCREF(&pyrf_evlist__type);
1019 1021 PyModule_AddObject(module, "evlist", (PyObject*)&pyrf_evlist__type);
1020 1022  
tools/perf/util/setup.py
... ... @@ -31,6 +31,7 @@
31 31 sources = ext_sources,
32 32 include_dirs = ['util/include'],
33 33 extra_compile_args = cflags,
  34 + extra_objects = [build_tmp + '/../../libtraceevent.a'],
34 35 )
35 36  
36 37 setup(name='perf',
tools/perf/util/sort.c
... ... @@ -260,6 +260,12 @@
260 260 if (path != NULL)
261 261 goto out_path;
262 262  
  263 + if (!self->ms.map)
  264 + goto out_ip;
  265 +
  266 + if (!strncmp(self->ms.map->dso->long_name, "/tmp/perf-", 10))
  267 + goto out_ip;
  268 +
263 269 snprintf(cmd, sizeof(cmd), "addr2line -e %s %016" PRIx64,
264 270 self->ms.map->dso->long_name, self->ip);
265 271 fp = popen(cmd, "r");