Skip to content

Commit

Permalink
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…linux/kernel/git/tip/tip

Pull perf fixes from Ingo Molnar:
 "Assorted small fixes"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf python: Properly link with libtraceevent
  perf hists browser: Add back callchain folding symbol
  perf tools: Fix build on sparc.
  perf python: Link with libtraceevent
  perf python: Initialize 'page_size' variable
  tools lib traceevent: Fix missed freeing of subargs in free_arg() in filter
  lib tools traceevent: Add back pevent assignment in __pevent_parse_format()
  perf hists browser: Fix off-by-two bug on the first column
  perf tools: Remove warnings on JIT samples for srcline sort key
  perf tools: Fix segfault when using srcline sort key
  perf: Require exclude_guest to use PEBS - kernel side enforcement
  perf tool: Precise mode requires exclude_guest
  • Loading branch information
torvalds committed Oct 20, 2012
2 parents 3782010 + 45bff41 commit 8c1bee6
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 17 deletions.
6 changes: 6 additions & 0 deletions arch/x86/kernel/cpu/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ int x86_setup_perfctr(struct perf_event *event)
/* BTS is currently only allowed for user-mode. */
if (!attr->exclude_kernel)
return -EOPNOTSUPP;

if (!attr->exclude_guest)
return -EOPNOTSUPP;
}

hwc->config |= config;
Expand Down Expand Up @@ -380,6 +383,9 @@ int x86_pmu_hw_config(struct perf_event *event)
if (event->attr.precise_ip) {
int precise = 0;

if (!event->attr.exclude_guest)
return -EOPNOTSUPP;

/* Support for constant skid */
if (x86_pmu.pebs_active && !x86_pmu.pebs_broken) {
precise++;
Expand Down
9 changes: 6 additions & 3 deletions tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -2602,6 +2602,9 @@ find_func_handler(struct pevent *pevent, char *func_name)
{
struct pevent_function_handler *func;

if (!pevent)
return NULL;

for (func = pevent->func_handlers; func; func = func->next) {
if (strcmp(func->name, func_name) == 0)
break;
Expand Down Expand Up @@ -4938,6 +4941,9 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp,
goto event_alloc_failed;
}

/* Add pevent to event so that it can be referenced */
event->pevent = pevent;

ret = event_read_format(event);
if (ret < 0) {
ret = PEVENT_ERRNO__READ_FORMAT_FAILED;
Expand Down Expand Up @@ -5041,9 +5047,6 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
if (event == NULL)
return ret;

/* Add pevent to event so that it can be referenced */
event->pevent = pevent;

if (add_event(pevent, event)) {
ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
goto event_add_failed;
Expand Down
15 changes: 15 additions & 0 deletions tools/lib/traceevent/parse-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,16 @@ static void free_arg(struct filter_arg *arg)
switch (arg->type) {
case FILTER_ARG_NONE:
case FILTER_ARG_BOOLEAN:
break;

case FILTER_ARG_NUM:
free_arg(arg->num.left);
free_arg(arg->num.right);
break;

case FILTER_ARG_EXP:
free_arg(arg->exp.left);
free_arg(arg->exp.right);
break;

case FILTER_ARG_STR:
Expand All @@ -218,6 +227,12 @@ static void free_arg(struct filter_arg *arg)
free(arg->str.buffer);
break;

case FILTER_ARG_VALUE:
if (arg->value.type == FILTER_STRING ||
arg->value.type == FILTER_CHAR)
free(arg->value.str);
break;

case FILTER_ARG_OP:
free_arg(arg->op.left);
free_arg(arg->op.right);
Expand Down
24 changes: 13 additions & 11 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,22 @@ SCRIPT_SH += perf-archive.sh
grep-libs = $(filter -l%,$(1))
strip-libs = $(filter-out -l%,$(1))

TRACE_EVENT_DIR = ../lib/traceevent/

ifneq ($(OUTPUT),)
TE_PATH=$(OUTPUT)
else
TE_PATH=$(TRACE_EVENT_DIR)
endif

LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
TE_LIB := -L$(TE_PATH) -ltraceevent

PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py

export LIBTRACEEVENT

$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
$(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \
--quiet build_ext; \
Expand All @@ -198,17 +211,6 @@ $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)

SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))

TRACE_EVENT_DIR = ../lib/traceevent/

ifneq ($(OUTPUT),)
TE_PATH=$(OUTPUT)
else
TE_PATH=$(TRACE_EVENT_DIR)
endif

LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
TE_LIB := -L$(TE_PATH) -ltraceevent

#
# Single 'perf' binary right now:
#
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void get_term_dimensions(struct winsize *ws);
#endif

#ifdef __sparc__
#include "../../arch/sparc/include/asm/unistd.h"
#include "../../arch/sparc/include/uapi/asm/unistd.h"
#define rmb() asm volatile("":::"memory")
#define cpu_relax() asm volatile("":::"memory")
#define CPUINFO_PROC "cpu"
Expand Down
6 changes: 4 additions & 2 deletions tools/perf/ui/browsers/hists.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
char folded_sign = ' ';
bool current_entry = ui_browser__is_current_entry(&browser->b, row);
off_t row_offset = entry->row_offset;
bool first = true;

if (current_entry) {
browser->he_selection = entry;
Expand All @@ -633,10 +634,11 @@ static int hist_browser__show_entry(struct hist_browser *browser,
if (!perf_hpp__format[i].cond)
continue;

if (i) {
if (!first) {
slsmg_printf(" ");
width -= 2;
}
first = false;

if (perf_hpp__format[i].color) {
hpp.ptr = &percent;
Expand All @@ -645,7 +647,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,

ui_browser__set_percent_color(&browser->b, percent, current_entry);

if (i == 0 && symbol_conf.use_callchain) {
if (i == PERF_HPP__OVERHEAD && symbol_conf.use_callchain) {
slsmg_printf("%c ", folded_sign);
width -= 2;
}
Expand Down
3 changes: 3 additions & 0 deletions tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,9 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
eH = 0;
} else if (*str == 'p') {
precise++;
/* use of precise requires exclude_guest */
if (!exclude_GH)
eG = 1;
} else
break;

Expand Down
2 changes: 2 additions & 0 deletions tools/perf/util/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def finalize_options(self):

build_lib = getenv('PYTHON_EXTBUILD_LIB')
build_tmp = getenv('PYTHON_EXTBUILD_TMP')
libtraceevent = getenv('LIBTRACEEVENT')

ext_sources = [f.strip() for f in file('util/python-ext-sources')
if len(f.strip()) > 0 and f[0] != '#']
Expand All @@ -31,6 +32,7 @@ def finalize_options(self):
sources = ext_sources,
include_dirs = ['util/include'],
extra_compile_args = cflags,
extra_objects = [libtraceevent],
)

setup(name='perf',
Expand Down
6 changes: 6 additions & 0 deletions tools/perf/util/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf,
if (path != NULL)
goto out_path;

if (!self->ms.map)
goto out_ip;

if (!strncmp(self->ms.map->dso->long_name, "/tmp/perf-", 10))
goto out_ip;

snprintf(cmd, sizeof(cmd), "addr2line -e %s %016" PRIx64,
self->ms.map->dso->long_name, self->ip);
fp = popen(cmd, "r");
Expand Down

0 comments on commit 8c1bee6

Please sign in to comment.