From 9e15cbff9c5a123119f55ee5ecad289f92945973 Mon Sep 17 00:00:00 2001 From: Daniel Walter Date: Wed, 26 Sep 2012 22:08:38 +0200 Subject: [PATCH] --- yaml --- r: 338989 b: refs/heads/master c: bcd83ea6cbfee54e33d1527b87538dc99ca2137b h: refs/heads/master i: 338987: e4e2fd1b6c0539857b688a24ed1f379833c3d451 v: v3 --- [refs] | 2 +- trunk/kernel/trace/ftrace.c | 2 +- trunk/kernel/trace/trace.c | 2 +- trunk/kernel/trace/trace_events_filter.c | 4 +- trunk/kernel/trace/trace_functions.c | 2 +- trunk/kernel/trace/trace_kprobe.c | 2 +- trunk/kernel/trace/trace_probe.c | 14 +- trunk/kernel/trace/trace_uprobe.c | 2 +- trunk/tools/lib/traceevent/event-parse.c | 22 +- trunk/tools/perf/Documentation/android.txt | 5 +- trunk/tools/perf/Makefile | 34 +- trunk/tools/perf/arch/common.c | 47 +-- trunk/tools/perf/builtin-annotate.c | 2 +- trunk/tools/perf/builtin-diff.c | 48 ++- trunk/tools/perf/builtin-report.c | 11 +- trunk/tools/perf/{tests => }/builtin-test.c | 51 +-- trunk/tools/perf/builtin-top.c | 10 +- trunk/tools/perf/perf.c | 2 - trunk/tools/perf/perf.h | 17 +- trunk/tools/perf/tests/attr.c | 174 ---------- trunk/tools/perf/tests/attr.py | 322 ------------------ trunk/tools/perf/tests/attr/README | 64 ---- trunk/tools/perf/tests/attr/base-record | 39 --- trunk/tools/perf/tests/attr/base-stat | 39 --- trunk/tools/perf/tests/attr/test-record-basic | 5 - .../perf/tests/attr/test-record-branch-any | 8 - .../tests/attr/test-record-branch-filter-any | 8 - .../attr/test-record-branch-filter-any_call | 8 - .../attr/test-record-branch-filter-any_ret | 8 - .../tests/attr/test-record-branch-filter-hv | 8 - .../attr/test-record-branch-filter-ind_call | 8 - .../tests/attr/test-record-branch-filter-k | 8 - .../tests/attr/test-record-branch-filter-u | 8 - trunk/tools/perf/tests/attr/test-record-count | 8 - trunk/tools/perf/tests/attr/test-record-data | 8 - trunk/tools/perf/tests/attr/test-record-freq | 6 - .../perf/tests/attr/test-record-graph-default | 6 - .../perf/tests/attr/test-record-graph-dwarf | 10 - .../perf/tests/attr/test-record-graph-fp | 6 - trunk/tools/perf/tests/attr/test-record-group | 17 - .../tools/perf/tests/attr/test-record-group1 | 20 -- .../perf/tests/attr/test-record-no-delay | 9 - .../perf/tests/attr/test-record-no-inherit | 7 - .../perf/tests/attr/test-record-no-samples | 6 - .../tools/perf/tests/attr/test-record-period | 7 - trunk/tools/perf/tests/attr/test-record-raw | 7 - trunk/tools/perf/tests/attr/test-stat-basic | 6 - trunk/tools/perf/tests/attr/test-stat-default | 64 ---- .../perf/tests/attr/test-stat-detailed-1 | 101 ------ .../perf/tests/attr/test-stat-detailed-2 | 155 --------- .../perf/tests/attr/test-stat-detailed-3 | 173 ---------- trunk/tools/perf/tests/attr/test-stat-group | 15 - trunk/tools/perf/tests/attr/test-stat-group1 | 17 - .../perf/tests/attr/test-stat-no-inherit | 7 - trunk/tools/perf/ui/browsers/annotate.c | 39 +-- trunk/tools/perf/ui/browsers/hists.c | 63 ++-- trunk/tools/perf/ui/gtk/browser.c | 4 +- trunk/tools/perf/ui/hist.c | 10 +- trunk/tools/perf/util/PERF-VERSION-GEN | 14 +- trunk/tools/perf/util/annotate.c | 71 +--- trunk/tools/perf/util/annotate.h | 9 +- .../dso-data.c => util/dso-test-data.c} | 1 - trunk/tools/perf/util/dso.c | 1 - trunk/tools/perf/util/hist.c | 100 ------ trunk/tools/perf/util/hist.h | 34 +- trunk/tools/perf/util/machine.c | 205 +---------- trunk/tools/perf/util/machine.h | 131 +------ trunk/tools/perf/util/map.c | 181 +++++++++- trunk/tools/perf/util/map.h | 93 +++++ .../parse-events-test.c} | 0 trunk/tools/perf/util/parse-events.l | 2 - trunk/tools/perf/util/session.h | 5 +- trunk/tools/perf/util/sort.h | 27 +- trunk/tools/perf/util/symbol.c | 1 - trunk/tools/perf/util/symbol.h | 20 ++ 75 files changed, 519 insertions(+), 2133 deletions(-) rename trunk/tools/perf/{tests => }/builtin-test.c (98%) delete mode 100644 trunk/tools/perf/tests/attr.c delete mode 100644 trunk/tools/perf/tests/attr.py delete mode 100644 trunk/tools/perf/tests/attr/README delete mode 100644 trunk/tools/perf/tests/attr/base-record delete mode 100644 trunk/tools/perf/tests/attr/base-stat delete mode 100644 trunk/tools/perf/tests/attr/test-record-basic delete mode 100644 trunk/tools/perf/tests/attr/test-record-branch-any delete mode 100644 trunk/tools/perf/tests/attr/test-record-branch-filter-any delete mode 100644 trunk/tools/perf/tests/attr/test-record-branch-filter-any_call delete mode 100644 trunk/tools/perf/tests/attr/test-record-branch-filter-any_ret delete mode 100644 trunk/tools/perf/tests/attr/test-record-branch-filter-hv delete mode 100644 trunk/tools/perf/tests/attr/test-record-branch-filter-ind_call delete mode 100644 trunk/tools/perf/tests/attr/test-record-branch-filter-k delete mode 100644 trunk/tools/perf/tests/attr/test-record-branch-filter-u delete mode 100644 trunk/tools/perf/tests/attr/test-record-count delete mode 100644 trunk/tools/perf/tests/attr/test-record-data delete mode 100644 trunk/tools/perf/tests/attr/test-record-freq delete mode 100644 trunk/tools/perf/tests/attr/test-record-graph-default delete mode 100644 trunk/tools/perf/tests/attr/test-record-graph-dwarf delete mode 100644 trunk/tools/perf/tests/attr/test-record-graph-fp delete mode 100644 trunk/tools/perf/tests/attr/test-record-group delete mode 100644 trunk/tools/perf/tests/attr/test-record-group1 delete mode 100644 trunk/tools/perf/tests/attr/test-record-no-delay delete mode 100644 trunk/tools/perf/tests/attr/test-record-no-inherit delete mode 100644 trunk/tools/perf/tests/attr/test-record-no-samples delete mode 100644 trunk/tools/perf/tests/attr/test-record-period delete mode 100644 trunk/tools/perf/tests/attr/test-record-raw delete mode 100644 trunk/tools/perf/tests/attr/test-stat-basic delete mode 100644 trunk/tools/perf/tests/attr/test-stat-default delete mode 100644 trunk/tools/perf/tests/attr/test-stat-detailed-1 delete mode 100644 trunk/tools/perf/tests/attr/test-stat-detailed-2 delete mode 100644 trunk/tools/perf/tests/attr/test-stat-detailed-3 delete mode 100644 trunk/tools/perf/tests/attr/test-stat-group delete mode 100644 trunk/tools/perf/tests/attr/test-stat-group1 delete mode 100644 trunk/tools/perf/tests/attr/test-stat-no-inherit rename trunk/tools/perf/{tests/dso-data.c => util/dso-test-data.c} (99%) rename trunk/tools/perf/{tests/parse-events.c => util/parse-events-test.c} (100%) diff --git a/[refs] b/[refs] index fae16a7ab222..8562394e45ad 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ccf59d8da119ab03dcbdf95fb5e5adcef6ba51f2 +refs/heads/master: bcd83ea6cbfee54e33d1527b87538dc99ca2137b diff --git a/trunk/kernel/trace/ftrace.c b/trunk/kernel/trace/ftrace.c index 9dcf15d38380..60ad606dc85f 100644 --- a/trunk/kernel/trace/ftrace.c +++ b/trunk/kernel/trace/ftrace.c @@ -4381,7 +4381,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf, if (strlen(tmp) == 0) return 1; - ret = strict_strtol(tmp, 10, &val); + ret = kstrtol(tmp, 10, &val); if (ret < 0) return ret; diff --git a/trunk/kernel/trace/trace.c b/trunk/kernel/trace/trace.c index 31e4f55773f1..f6928edacd6d 100644 --- a/trunk/kernel/trace/trace.c +++ b/trunk/kernel/trace/trace.c @@ -431,7 +431,7 @@ static int __init set_tracing_thresh(char *str) if (!str) return 0; - ret = strict_strtoul(str, 0, &threshold); + ret = kstrtoul(str, 0, &threshold); if (ret < 0) return 0; tracing_thresh = threshold * 1000; diff --git a/trunk/kernel/trace/trace_events_filter.c b/trunk/kernel/trace/trace_events_filter.c index c154797a7ff7..e5b0ca8b8d4d 100644 --- a/trunk/kernel/trace/trace_events_filter.c +++ b/trunk/kernel/trace/trace_events_filter.c @@ -1000,9 +1000,9 @@ static int init_pred(struct filter_parse_state *ps, } } else { if (field->is_signed) - ret = strict_strtoll(pred->regex.pattern, 0, &val); + ret = kstrtoll(pred->regex.pattern, 0, &val); else - ret = strict_strtoull(pred->regex.pattern, 0, &val); + ret = kstrtoull(pred->regex.pattern, 0, &val); if (ret) { parse_error(ps, FILT_ERR_ILLEGAL_INTVAL, 0); return -EINVAL; diff --git a/trunk/kernel/trace/trace_functions.c b/trunk/kernel/trace/trace_functions.c index 507a7a9630bf..618dcf8bdb87 100644 --- a/trunk/kernel/trace/trace_functions.c +++ b/trunk/kernel/trace/trace_functions.c @@ -366,7 +366,7 @@ ftrace_trace_onoff_callback(struct ftrace_hash *hash, * We use the callback data field (which is a pointer) * as our counter. */ - ret = strict_strtoul(number, 0, (unsigned long *)&count); + ret = kstrtoul(number, 0, (unsigned long *)&count); if (ret) return ret; diff --git a/trunk/kernel/trace/trace_kprobe.c b/trunk/kernel/trace/trace_kprobe.c index 1a2117043bb1..5a3c533ef060 100644 --- a/trunk/kernel/trace/trace_kprobe.c +++ b/trunk/kernel/trace/trace_kprobe.c @@ -444,7 +444,7 @@ static int create_trace_probe(int argc, char **argv) return -EINVAL; } /* an address specified */ - ret = strict_strtoul(&argv[1][0], 0, (unsigned long *)&addr); + ret = kstrtoul(&argv[1][0], 0, (unsigned long *)&addr); if (ret) { pr_info("Failed to parse address.\n"); return ret; diff --git a/trunk/kernel/trace/trace_probe.c b/trunk/kernel/trace/trace_probe.c index daa9980153af..412e959709b4 100644 --- a/trunk/kernel/trace/trace_probe.c +++ b/trunk/kernel/trace/trace_probe.c @@ -441,7 +441,7 @@ static const struct fetch_type *find_fetch_type(const char *type) goto fail; type++; - if (strict_strtoul(type, 0, &bs)) + if (kstrtoul(type, 0, &bs)) goto fail; switch (bs) { @@ -501,8 +501,8 @@ int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset) tmp = strchr(symbol, '+'); if (tmp) { - /* skip sign because strict_strtol doesn't accept '+' */ - ret = strict_strtoul(tmp + 1, 0, offset); + /* skip sign because kstrtoul doesn't accept '+' */ + ret = kstrtoul(tmp + 1, 0, offset); if (ret) return ret; @@ -533,7 +533,7 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t, else ret = -EINVAL; } else if (isdigit(arg[5])) { - ret = strict_strtoul(arg + 5, 10, ¶m); + ret = kstrtoul(arg + 5, 10, ¶m); if (ret || param > PARAM_MAX_STACK) ret = -EINVAL; else { @@ -579,7 +579,7 @@ static int parse_probe_arg(char *arg, const struct fetch_type *t, case '@': /* memory or symbol */ if (isdigit(arg[1])) { - ret = strict_strtoul(arg + 1, 0, ¶m); + ret = kstrtoul(arg + 1, 0, ¶m); if (ret) break; @@ -597,14 +597,14 @@ static int parse_probe_arg(char *arg, const struct fetch_type *t, break; case '+': /* deref memory */ - arg++; /* Skip '+', because strict_strtol() rejects it. */ + arg++; /* Skip '+', because kstrtol() rejects it. */ case '-': tmp = strchr(arg, '('); if (!tmp) break; *tmp = '\0'; - ret = strict_strtol(arg, 0, &offset); + ret = kstrtol(arg, 0, &offset); if (ret) break; diff --git a/trunk/kernel/trace/trace_uprobe.c b/trunk/kernel/trace/trace_uprobe.c index 03003cd7dd96..4ff9ca4f359a 100644 --- a/trunk/kernel/trace/trace_uprobe.c +++ b/trunk/kernel/trace/trace_uprobe.c @@ -252,7 +252,7 @@ static int create_trace_uprobe(int argc, char **argv) if (ret) goto fail_address_parse; - ret = strict_strtoul(arg, 0, &offset); + ret = kstrtoul(arg, 0, &offset); if (ret) goto fail_address_parse; diff --git a/trunk/tools/lib/traceevent/event-parse.c b/trunk/tools/lib/traceevent/event-parse.c index 5a824e355d04..f2989c525e48 100644 --- a/trunk/tools/lib/traceevent/event-parse.c +++ b/trunk/tools/lib/traceevent/event-parse.c @@ -174,7 +174,7 @@ static int cmdline_init(struct pevent *pevent) return 0; } -static const char *find_cmdline(struct pevent *pevent, int pid) +static char *find_cmdline(struct pevent *pevent, int pid) { const struct cmdline *comm; struct cmdline key; @@ -2637,7 +2637,7 @@ process_func_handler(struct event_format *event, struct pevent_function_handler struct print_arg *farg; enum event_type type; char *token; - const char *test; + char *test; int i; arg->type = PRINT_FUNC; @@ -3889,7 +3889,7 @@ static void print_mac_arg(struct trace_seq *s, int mac, void *data, int size, struct event_format *event, struct print_arg *arg) { unsigned char *buf; - const char *fmt = "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x"; + char *fmt = "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x"; if (arg->type == PRINT_FUNC) { process_defined_func(s, data, size, event, arg); @@ -3931,8 +3931,7 @@ static int is_printable_array(char *p, unsigned int len) return 1; } -static void print_event_fields(struct trace_seq *s, void *data, - int size __maybe_unused, +static void print_event_fields(struct trace_seq *s, void *data, int size, struct event_format *event) { struct format_field *field; @@ -4409,7 +4408,7 @@ void pevent_event_info(struct trace_seq *s, struct event_format *event, void pevent_print_event(struct pevent *pevent, struct trace_seq *s, struct pevent_record *record) { - static const char *spaces = " "; /* 20 spaces */ + static char *spaces = " "; /* 20 spaces */ struct event_format *event; unsigned long secs; unsigned long usecs; @@ -5071,8 +5070,8 @@ static const char * const pevent_error_str[] = { }; #undef _PE -int pevent_strerror(struct pevent *pevent __maybe_unused, - enum pevent_errno errnum, char *buf, size_t buflen) +int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum, + char *buf, size_t buflen) { int idx; const char *msg; @@ -5101,7 +5100,6 @@ int pevent_strerror(struct pevent *pevent __maybe_unused, case PEVENT_ERRNO__READ_FORMAT_FAILED: case PEVENT_ERRNO__READ_PRINT_FAILED: case PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED: - case PEVENT_ERRNO__INVALID_ARG_TYPE: snprintf(buf, buflen, "%s", msg); break; @@ -5364,7 +5362,7 @@ int pevent_register_print_function(struct pevent *pevent, if (type == PEVENT_FUNC_ARG_VOID) break; - if (type >= PEVENT_FUNC_ARG_MAX_TYPES) { + if (type < 0 || type >= PEVENT_FUNC_ARG_MAX_TYPES) { do_warning("Invalid argument type %d", type); ret = PEVENT_ERRNO__INVALID_ARG_TYPE; goto out_free; @@ -5562,7 +5560,7 @@ void pevent_free(struct pevent *pevent) } if (pevent->func_map) { - for (i = 0; i < (int)pevent->func_count; i++) { + for (i = 0; i < pevent->func_count; i++) { free(pevent->func_map[i].func); free(pevent->func_map[i].mod); } @@ -5584,7 +5582,7 @@ void pevent_free(struct pevent *pevent) } if (pevent->printk_map) { - for (i = 0; i < (int)pevent->printk_count; i++) + for (i = 0; i < pevent->printk_count; i++) free(pevent->printk_map[i].printk); free(pevent->printk_map); } diff --git a/trunk/tools/perf/Documentation/android.txt b/trunk/tools/perf/Documentation/android.txt index 8484c3a04a6a..a39dbbb44c4c 100644 --- a/trunk/tools/perf/Documentation/android.txt +++ b/trunk/tools/perf/Documentation/android.txt @@ -48,10 +48,7 @@ For x86: II. Compile perf for Android ------------------------------------------------ You need to run make with the NDK toolchain and sysroot defined above: -For arm: - make ARCH=arm CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}" -For x86: - make ARCH=x86 CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}" + make CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}" III. Install perf ----------------------------------------------- diff --git a/trunk/tools/perf/Makefile b/trunk/tools/perf/Makefile index cca5bb8334ad..7e25f59e5e89 100644 --- a/trunk/tools/perf/Makefile +++ b/trunk/tools/perf/Makefile @@ -169,7 +169,7 @@ endif ### --- END CONFIGURATION SECTION --- -BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -Iutil -I. -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE +BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include -I$(OUTPUT)util -I$(TRACE_EVENT_DIR) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE BASIC_LDFLAGS = ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) @@ -371,6 +371,7 @@ LIB_OBJS += $(OUTPUT)util/help.o LIB_OBJS += $(OUTPUT)util/levenshtein.o LIB_OBJS += $(OUTPUT)util/parse-options.o LIB_OBJS += $(OUTPUT)util/parse-events.o +LIB_OBJS += $(OUTPUT)util/parse-events-test.o LIB_OBJS += $(OUTPUT)util/path.o LIB_OBJS += $(OUTPUT)util/rbtree.o LIB_OBJS += $(OUTPUT)util/bitmap.o @@ -388,6 +389,7 @@ LIB_OBJS += $(OUTPUT)util/sigchain.o LIB_OBJS += $(OUTPUT)util/dso.o LIB_OBJS += $(OUTPUT)util/symbol.o LIB_OBJS += $(OUTPUT)util/symbol-elf.o +LIB_OBJS += $(OUTPUT)util/dso-test-data.o LIB_OBJS += $(OUTPUT)util/color.o LIB_OBJS += $(OUTPUT)util/pager.o LIB_OBJS += $(OUTPUT)util/header.o @@ -428,10 +430,6 @@ LIB_OBJS += $(OUTPUT)ui/stdio/hist.o LIB_OBJS += $(OUTPUT)arch/common.o -LIB_OBJS += $(OUTPUT)tests/parse-events.o -LIB_OBJS += $(OUTPUT)tests/dso-data.o -LIB_OBJS += $(OUTPUT)tests/attr.o - BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o BUILTIN_OBJS += $(OUTPUT)builtin-bench.o # Benchmark modules @@ -461,8 +459,8 @@ BUILTIN_OBJS += $(OUTPUT)builtin-probe.o BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o BUILTIN_OBJS += $(OUTPUT)builtin-lock.o BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o +BUILTIN_OBJS += $(OUTPUT)builtin-test.o BUILTIN_OBJS += $(OUTPUT)builtin-inject.o -BUILTIN_OBJS += $(OUTPUT)tests/builtin-test.o PERFLIBS = $(LIB_FILE) $(LIBTRACEEVENT) @@ -492,8 +490,6 @@ ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) LIBC_SUPPORT := 1 endif ifeq ($(LIBC_SUPPORT),1) - msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); - NO_LIBELF := 1 NO_DWARF := 1 NO_DEMANGLE := 1 @@ -501,14 +497,7 @@ ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); endif else - # for linking with debug library, run like: - # make DEBUG=1 LIBDW_DIR=/opt/libdw/ - ifdef LIBDW_DIR - LIBDW_CFLAGS := -I$(LIBDW_DIR)/include - LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib - endif - - FLAGS_DWARF=$(ALL_CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) + FLAGS_DWARF=$(ALL_CFLAGS) -ldw -lelf $(ALL_LDFLAGS) $(EXTLIBS) ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); NO_DWARF := 1 @@ -563,8 +552,7 @@ ifndef NO_DWARF ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); else - BASIC_CFLAGS := -DDWARF_SUPPORT $(LIBDW_CFLAGS) $(BASIC_CFLAGS) - BASIC_LDFLAGS := $(LIBDW_LDFLAGS) $(BASIC_LDFLAGS) + BASIC_CFLAGS += -DDWARF_SUPPORT EXTLIBS += -lelf -ldw LIB_OBJS += $(OUTPUT)util/probe-finder.o LIB_OBJS += $(OUTPUT)util/dwarf-aux.o @@ -903,14 +891,10 @@ $(OUTPUT)%.s: %.S $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \ + '-DBINDIR="$(bindir_relative_SQ)"' \ '-DPREFIX="$(prefix_SQ)"' \ $< -$(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ - '-DBINDIR="$(bindir_SQ)"' \ - $< - $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< @@ -1075,10 +1059,6 @@ install: all try-install-man $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin' $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d' $(INSTALL) bash_completion '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf' - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests' - $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests' - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' - $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' install-python_ext: $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)' diff --git a/trunk/tools/perf/arch/common.c b/trunk/tools/perf/arch/common.c index 3e975cb6232e..2367b253f039 100644 --- a/trunk/tools/perf/arch/common.c +++ b/trunk/tools/perf/arch/common.c @@ -93,46 +93,16 @@ static int lookup_triplets(const char *const *triplets, const char *name) return -1; } -/* - * Return architecture name in a normalized form. - * The conversion logic comes from the Makefile. - */ -static const char *normalize_arch(char *arch) -{ - if (!strcmp(arch, "x86_64")) - return "x86"; - if (arch[0] == 'i' && arch[2] == '8' && arch[3] == '6') - return "x86"; - if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5)) - return "sparc"; - if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110")) - return "arm"; - if (!strncmp(arch, "s390", 4)) - return "s390"; - if (!strncmp(arch, "parisc", 6)) - return "parisc"; - if (!strncmp(arch, "powerpc", 7) || !strncmp(arch, "ppc", 3)) - return "powerpc"; - if (!strncmp(arch, "mips", 4)) - return "mips"; - if (!strncmp(arch, "sh", 2) && isdigit(arch[2])) - return "sh"; - - return arch; -} - static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, const char *name, const char **path) { int idx; - const char *arch, *cross_env; + char *arch, *cross_env; struct utsname uts; const char *const *path_list; char *buf = NULL; - arch = normalize_arch(env->arch); - if (uname(&uts) < 0) goto out; @@ -140,7 +110,7 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, * We don't need to try to find objdump path for native system. * Just use default binutils path (e.g.: "objdump"). */ - if (!strcmp(normalize_arch(uts.machine), arch)) + if (!strcmp(uts.machine, env->arch)) goto out; cross_env = getenv("CROSS_COMPILE"); @@ -157,6 +127,8 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, free(buf); } + arch = env->arch; + if (!strcmp(arch, "arm")) path_list = arm_triplets; else if (!strcmp(arch, "powerpc")) @@ -167,7 +139,9 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, path_list = s390_triplets; else if (!strcmp(arch, "sparc")) path_list = sparc_triplets; - else if (!strcmp(arch, "x86")) + else if (!strcmp(arch, "x86") || !strcmp(arch, "i386") || + !strcmp(arch, "i486") || !strcmp(arch, "i586") || + !strcmp(arch, "i686")) path_list = x86_triplets; else if (!strcmp(arch, "mips")) path_list = mips_triplets; @@ -199,13 +173,6 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, int perf_session_env__lookup_objdump(struct perf_session_env *env) { - /* - * For live mode, env->arch will be NULL and we can use - * the native objdump tool. - */ - if (env->arch == NULL) - return 0; - return perf_session_env__lookup_binutils_path(env, "objdump", &objdump_path); } diff --git a/trunk/tools/perf/builtin-annotate.c b/trunk/tools/perf/builtin-annotate.c index dc870cf31b79..cb234765ce3d 100644 --- a/trunk/tools/perf/builtin-annotate.c +++ b/trunk/tools/perf/builtin-annotate.c @@ -139,7 +139,7 @@ static void hists__find_annotations(struct hists *self, int evidx, } if (use_browser > 0) { - key = hist_entry__tui_annotate(he, evidx, NULL); + key = hist_entry__tui_annotate(he, evidx, NULL, NULL, 0); switch (key) { case K_RIGHT: next = rb_next(nd); diff --git a/trunk/tools/perf/builtin-diff.c b/trunk/tools/perf/builtin-diff.c index 93b852f8a5d5..380683de1df3 100644 --- a/trunk/tools/perf/builtin-diff.c +++ b/trunk/tools/perf/builtin-diff.c @@ -154,7 +154,7 @@ static double get_period_percent(struct hist_entry *he, u64 period) double perf_diff__compute_delta(struct hist_entry *he) { - struct hist_entry *pair = hist_entry__next_pair(he); + struct hist_entry *pair = he->pair; double new_percent = get_period_percent(he, he->stat.period); double old_percent = pair ? get_period_percent(pair, pair->stat.period) : 0.0; @@ -165,7 +165,7 @@ double perf_diff__compute_delta(struct hist_entry *he) double perf_diff__compute_ratio(struct hist_entry *he) { - struct hist_entry *pair = hist_entry__next_pair(he); + struct hist_entry *pair = he->pair; double new_period = he->stat.period; double old_period = pair ? pair->stat.period : 0; @@ -176,7 +176,7 @@ double perf_diff__compute_ratio(struct hist_entry *he) s64 perf_diff__compute_wdiff(struct hist_entry *he) { - struct hist_entry *pair = hist_entry__next_pair(he); + struct hist_entry *pair = he->pair; u64 new_period = he->stat.period; u64 old_period = pair ? pair->stat.period : 0; @@ -193,7 +193,7 @@ s64 perf_diff__compute_wdiff(struct hist_entry *he) static int formula_delta(struct hist_entry *he, char *buf, size_t size) { - struct hist_entry *pair = hist_entry__next_pair(he); + struct hist_entry *pair = he->pair; if (!pair) return -1; @@ -207,7 +207,7 @@ static int formula_delta(struct hist_entry *he, char *buf, size_t size) static int formula_ratio(struct hist_entry *he, char *buf, size_t size) { - struct hist_entry *pair = hist_entry__next_pair(he); + struct hist_entry *pair = he->pair; double new_period = he->stat.period; double old_period = pair ? pair->stat.period : 0; @@ -219,7 +219,7 @@ static int formula_ratio(struct hist_entry *he, char *buf, size_t size) static int formula_wdiff(struct hist_entry *he, char *buf, size_t size) { - struct hist_entry *pair = hist_entry__next_pair(he); + struct hist_entry *pair = he->pair; u64 new_period = he->stat.period; u64 old_period = pair ? pair->stat.period : 0; @@ -334,6 +334,36 @@ static void hists__name_resort(struct hists *self, bool sort) self->entries = tmp; } +static struct hist_entry *hists__find_entry(struct hists *self, + struct hist_entry *he) +{ + struct rb_node *n = self->entries.rb_node; + + while (n) { + struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node); + int64_t cmp = hist_entry__cmp(he, iter); + + if (cmp < 0) + n = n->rb_left; + else if (cmp > 0) + n = n->rb_right; + else + return iter; + } + + return NULL; +} + +static void hists__match(struct hists *older, struct hists *newer) +{ + struct rb_node *nd; + + for (nd = rb_first(&newer->entries); nd; nd = rb_next(nd)) { + struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node); + pos->pair = hists__find_entry(older, pos); + } +} + static struct perf_evsel *evsel_match(struct perf_evsel *evsel, struct perf_evlist *evlist) { @@ -372,7 +402,7 @@ static void hists__baseline_only(struct hists *hists) struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node); next = rb_next(&he->rb_node); - if (!hist_entry__next_pair(he)) { + if (!he->pair) { rb_erase(&he->rb_node, &hists->entries); hist_entry__free(he); } @@ -487,12 +517,10 @@ static void hists__compute_resort(struct hists *hists) static void hists__process(struct hists *old, struct hists *new) { - hists__match(new, old); + hists__match(old, new); if (show_baseline_only) hists__baseline_only(new); - else - hists__link(new, old); if (sort_compute) { hists__precompute(new); diff --git a/trunk/tools/perf/builtin-report.c b/trunk/tools/perf/builtin-report.c index fc251005dd3d..f07eae73e692 100644 --- a/trunk/tools/perf/builtin-report.c +++ b/trunk/tools/perf/builtin-report.c @@ -428,11 +428,10 @@ static int __cmd_report(struct perf_report *rep) if (use_browser > 0) { if (use_browser == 1) { perf_evlist__tui_browse_hists(session->evlist, help, - NULL, - &session->header.env); + NULL, NULL, 0); } else if (use_browser == 2) { perf_evlist__gtk_browse_hists(session->evlist, help, - NULL); + NULL, NULL, 0); } } else perf_evlist__tty_browse_hists(session->evlist, rep, help); @@ -673,6 +672,12 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) has_br_stack = perf_header__has_feat(&session->header, HEADER_BRANCH_STACK); + if (!objdump_path) { + ret = perf_session_env__lookup_objdump(&session->header.env); + if (ret) + goto error; + } + if (sort__branch_mode == -1 && has_br_stack) sort__branch_mode = 1; diff --git a/trunk/tools/perf/tests/builtin-test.c b/trunk/tools/perf/builtin-test.c similarity index 98% rename from trunk/tools/perf/tests/builtin-test.c rename to trunk/tools/perf/builtin-test.c index 5d4354e24457..a04276e81f40 100644 --- a/trunk/tools/perf/tests/builtin-test.c +++ b/trunk/tools/perf/builtin-test.c @@ -10,7 +10,6 @@ #include "util/debug.h" #include "util/debugfs.h" #include "util/evlist.h" -#include "util/machine.h" #include "util/parse-options.h" #include "util/parse-events.h" #include "util/symbol.h" @@ -319,7 +318,7 @@ static int test__open_syscall_event(void) nr_open_calls, evsel->counts->cpu[0].val); goto out_close_fd; } - + err = 0; out_close_fd: perf_evsel__close_fd(evsel, 1, threads->nr); @@ -605,13 +604,19 @@ static int test__basic_mmap(void) #undef nsyscalls } -static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp) +static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t **maskp, + size_t *sizep) { + cpu_set_t *mask; + size_t size; int i, cpu = -1, nrcpus = 1024; realloc: - CPU_ZERO(maskp); + mask = CPU_ALLOC(nrcpus); + size = CPU_ALLOC_SIZE(nrcpus); + CPU_ZERO_S(size, mask); - if (sched_getaffinity(pid, sizeof(*maskp), maskp) == -1) { + if (sched_getaffinity(pid, size, mask) == -1) { + CPU_FREE(mask); if (errno == EINVAL && nrcpus < (1024 << 8)) { nrcpus = nrcpus << 2; goto realloc; @@ -621,14 +626,19 @@ static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp) } for (i = 0; i < nrcpus; i++) { - if (CPU_ISSET(i, maskp)) { - if (cpu == -1) + if (CPU_ISSET_S(i, size, mask)) { + if (cpu == -1) { cpu = i; - else - CPU_CLR(i, maskp); + *maskp = mask; + *sizep = size; + } else + CPU_CLR_S(i, size, mask); } } + if (cpu == -1) + CPU_FREE(mask); + return cpu; } @@ -643,8 +653,8 @@ static int test__PERF_RECORD(void) .freq = 10, .mmap_pages = 256, }; - cpu_set_t cpu_mask; - size_t cpu_mask_size = sizeof(cpu_mask); + cpu_set_t *cpu_mask = NULL; + size_t cpu_mask_size = 0; struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); struct perf_evsel *evsel; struct perf_sample sample; @@ -708,7 +718,8 @@ static int test__PERF_RECORD(void) evsel->attr.sample_type |= PERF_SAMPLE_TIME; perf_evlist__config_attrs(evlist, &opts); - err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask); + err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask, + &cpu_mask_size); if (err < 0) { pr_debug("sched__get_first_possible_cpu: %s\n", strerror(errno)); goto out_delete_evlist; @@ -719,9 +730,9 @@ static int test__PERF_RECORD(void) /* * So that we can check perf_sample.cpu on all the samples. */ - if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, &cpu_mask) < 0) { + if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, cpu_mask) < 0) { pr_debug("sched_setaffinity: %s\n", strerror(errno)); - goto out_delete_evlist; + goto out_free_cpu_mask; } /* @@ -905,6 +916,8 @@ static int test__PERF_RECORD(void) } out_err: perf_evlist__munmap(evlist); +out_free_cpu_mask: + CPU_FREE(cpu_mask); out_delete_evlist: perf_evlist__delete(evlist); out: @@ -1331,8 +1344,8 @@ static int test__syscall_open_tp_fields(void) perf_evlist__enable(evlist); /* - * Generate the event: - */ + * Generate the event: + */ open(filename, flags); while (1) { @@ -1441,10 +1454,6 @@ static struct test { .desc = "Generate and check syscalls:sys_enter_open event fields", .func = test__syscall_open_tp_fields, }, - { - .desc = "struct perf_event_attr setup", - .func = test_attr__run, - }, { .func = NULL, }, @@ -1486,7 +1495,7 @@ static int __cmd_test(int argc, const char *argv[]) width = len; ++i; } - + i = 0; while (tests[i].func) { int curr = i++, err; diff --git a/trunk/tools/perf/builtin-top.c b/trunk/tools/perf/builtin-top.c index c9ff3950cd4b..f2ecd498c72d 100644 --- a/trunk/tools/perf/builtin-top.c +++ b/trunk/tools/perf/builtin-top.c @@ -582,11 +582,6 @@ static void *display_thread_tui(void *arg) struct perf_evsel *pos; struct perf_top *top = arg; const char *help = "For a higher level overview, try: perf top --sort comm,dso"; - struct hist_browser_timer hbt = { - .timer = perf_top__sort_new_samples, - .arg = top, - .refresh = top->delay_secs, - }; perf_top__sort_new_samples(top); @@ -598,8 +593,9 @@ static void *display_thread_tui(void *arg) list_for_each_entry(pos, &top->evlist->entries, node) pos->hists.uid_filter_str = top->target.uid_str; - perf_evlist__tui_browse_hists(top->evlist, help, &hbt, - &top->session->header.env); + perf_evlist__tui_browse_hists(top->evlist, help, + perf_top__sort_new_samples, + top, top->delay_secs); exit_browser(0); exit(0); diff --git a/trunk/tools/perf/perf.c b/trunk/tools/perf/perf.c index a0ae2902f9c9..e9683738d89f 100644 --- a/trunk/tools/perf/perf.c +++ b/trunk/tools/perf/perf.c @@ -484,8 +484,6 @@ int main(int argc, const char **argv) } cmd = argv[0]; - test_attr__init(); - /* * We use PATH to find perf commands, but we prepend some higher * precedence paths: the "--exec-path" option, the PERF_EXEC_PATH diff --git a/trunk/tools/perf/perf.h b/trunk/tools/perf/perf.h index 054182e41dca..469fbf2daea4 100644 --- a/trunk/tools/perf/perf.h +++ b/trunk/tools/perf/perf.h @@ -174,26 +174,13 @@ static inline unsigned long long rdclock(void) (void) (&_min1 == &_min2); \ _min1 < _min2 ? _min1 : _min2; }) -extern bool test_attr__enabled; -void test_attr__init(void); -void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, - int fd, int group_fd, unsigned long flags); -int test_attr__run(void); - static inline int sys_perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu, int group_fd, unsigned long flags) { - int fd; - - fd = syscall(__NR_perf_event_open, attr, pid, cpu, - group_fd, flags); - - if (unlikely(test_attr__enabled)) - test_attr__open(attr, pid, cpu, fd, group_fd, flags); - - return fd; + return syscall(__NR_perf_event_open, attr, pid, cpu, + group_fd, flags); } #define MAX_COUNTERS 256 diff --git a/trunk/tools/perf/tests/attr.c b/trunk/tools/perf/tests/attr.c deleted file mode 100644 index 6e2feee8db2a..000000000000 --- a/trunk/tools/perf/tests/attr.c +++ /dev/null @@ -1,174 +0,0 @@ - -/* - * The struct perf_event_attr test support. - * - * This test is embedded inside into perf directly and is governed - * by the PERF_TEST_ATTR environment variable and hook inside - * sys_perf_event_open function. - * - * The general idea is to store 'struct perf_event_attr' details for - * each event created within single perf command. Each event details - * are stored into separate text file. Once perf command is finished - * these files can be checked for values we expect for command. - * - * Besides 'struct perf_event_attr' values we also store 'fd' and - * 'group_fd' values to allow checking for groups created. - * - * This all is triggered by setting PERF_TEST_ATTR environment variable. - * It must contain name of existing directory with access and write - * permissions. All the event text files are stored there. - */ - -#include -#include -#include -#include -#include -#include "../perf.h" -#include "util.h" -#include "exec_cmd.h" - -#define ENV "PERF_TEST_ATTR" - -extern int verbose; - -bool test_attr__enabled; - -static char *dir; - -void test_attr__init(void) -{ - dir = getenv(ENV); - test_attr__enabled = (dir != NULL); -} - -#define BUFSIZE 1024 - -#define __WRITE_ASS(str, fmt, data) \ -do { \ - char buf[BUFSIZE]; \ - size_t size; \ - \ - size = snprintf(buf, BUFSIZE, #str "=%"fmt "\n", data); \ - if (1 != fwrite(buf, size, 1, file)) { \ - perror("test attr - failed to write event file"); \ - fclose(file); \ - return -1; \ - } \ - \ -} while (0) - -#define WRITE_ASS(field, fmt) __WRITE_ASS(field, fmt, attr->field) - -static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu, - int fd, int group_fd, unsigned long flags) -{ - FILE *file; - char path[PATH_MAX]; - - snprintf(path, PATH_MAX, "%s/event-%d-%llu-%d", dir, - attr->type, attr->config, fd); - - file = fopen(path, "w+"); - if (!file) { - perror("test attr - failed to open event file"); - return -1; - } - - if (fprintf(file, "[event-%d-%llu-%d]\n", - attr->type, attr->config, fd) < 0) { - perror("test attr - failed to write event file"); - fclose(file); - return -1; - } - - /* syscall arguments */ - __WRITE_ASS(fd, "d", fd); - __WRITE_ASS(group_fd, "d", group_fd); - __WRITE_ASS(cpu, "d", cpu); - __WRITE_ASS(pid, "d", pid); - __WRITE_ASS(flags, "lu", flags); - - /* struct perf_event_attr */ - WRITE_ASS(type, PRIu32); - WRITE_ASS(size, PRIu32); - WRITE_ASS(config, "llu"); - WRITE_ASS(sample_period, "llu"); - WRITE_ASS(sample_type, "llu"); - WRITE_ASS(read_format, "llu"); - WRITE_ASS(disabled, "d"); - WRITE_ASS(inherit, "d"); - WRITE_ASS(pinned, "d"); - WRITE_ASS(exclusive, "d"); - WRITE_ASS(exclude_user, "d"); - WRITE_ASS(exclude_kernel, "d"); - WRITE_ASS(exclude_hv, "d"); - WRITE_ASS(exclude_idle, "d"); - WRITE_ASS(mmap, "d"); - WRITE_ASS(comm, "d"); - WRITE_ASS(freq, "d"); - WRITE_ASS(inherit_stat, "d"); - WRITE_ASS(enable_on_exec, "d"); - WRITE_ASS(task, "d"); - WRITE_ASS(watermark, "d"); - WRITE_ASS(precise_ip, "d"); - WRITE_ASS(mmap_data, "d"); - WRITE_ASS(sample_id_all, "d"); - WRITE_ASS(exclude_host, "d"); - WRITE_ASS(exclude_guest, "d"); - WRITE_ASS(exclude_callchain_kernel, "d"); - WRITE_ASS(exclude_callchain_user, "d"); - WRITE_ASS(wakeup_events, PRIu32); - WRITE_ASS(bp_type, PRIu32); - WRITE_ASS(config1, "llu"); - WRITE_ASS(config2, "llu"); - WRITE_ASS(branch_sample_type, "llu"); - WRITE_ASS(sample_regs_user, "llu"); - WRITE_ASS(sample_stack_user, PRIu32); - - fclose(file); - return 0; -} - -void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, - int fd, int group_fd, unsigned long flags) -{ - int errno_saved = errno; - - if (store_event(attr, pid, cpu, fd, group_fd, flags)) - die("test attr FAILED"); - - errno = errno_saved; -} - -static int run_dir(const char *d, const char *perf) -{ - char cmd[3*PATH_MAX]; - - snprintf(cmd, 3*PATH_MAX, "python %s/attr.py -d %s/attr/ -p %s %s", - d, d, perf, verbose ? "-v" : ""); - - return system(cmd); -} - -int test_attr__run(void) -{ - struct stat st; - char path_perf[PATH_MAX]; - char path_dir[PATH_MAX]; - - /* First try developement tree tests. */ - if (!lstat("./tests", &st)) - return run_dir("./tests", "./perf"); - - /* Then installed path. */ - snprintf(path_dir, PATH_MAX, "%s/tests", perf_exec_path()); - snprintf(path_perf, PATH_MAX, "%s/perf", BINDIR); - - if (!lstat(path_dir, &st) && - !lstat(path_perf, &st)) - return run_dir(path_dir, path_perf); - - fprintf(stderr, " (ommitted)"); - return 0; -} diff --git a/trunk/tools/perf/tests/attr.py b/trunk/tools/perf/tests/attr.py deleted file mode 100644 index e702b82dcb86..000000000000 --- a/trunk/tools/perf/tests/attr.py +++ /dev/null @@ -1,322 +0,0 @@ -#! /usr/bin/python - -import os -import sys -import glob -import optparse -import tempfile -import logging -import shutil -import ConfigParser - -class Fail(Exception): - def __init__(self, test, msg): - self.msg = msg - self.test = test - def getMsg(self): - return '\'%s\' - %s' % (self.test.path, self.msg) - -class Unsup(Exception): - def __init__(self, test): - self.test = test - def getMsg(self): - return '\'%s\'' % self.test.path - -class Event(dict): - terms = [ - 'flags', - 'type', - 'size', - 'config', - 'sample_period', - 'sample_type', - 'read_format', - 'disabled', - 'inherit', - 'pinned', - 'exclusive', - 'exclude_user', - 'exclude_kernel', - 'exclude_hv', - 'exclude_idle', - 'mmap', - 'comm', - 'freq', - 'inherit_stat', - 'enable_on_exec', - 'task', - 'watermark', - 'precise_ip', - 'mmap_data', - 'sample_id_all', - 'exclude_host', - 'exclude_guest', - 'exclude_callchain_kernel', - 'exclude_callchain_user', - 'wakeup_events', - 'bp_type', - 'config1', - 'config2', - 'branch_sample_type', - 'sample_regs_user', - 'sample_stack_user', - ] - - def add(self, data): - for key, val in data: - log.debug(" %s = %s" % (key, val)) - self[key] = val - - def __init__(self, name, data, base): - log.info(" Event %s" % name); - self.name = name; - self.group = '' - self.add(base) - self.add(data) - - def compare_data(self, a, b): - # Allow multiple values in assignment separated by '|' - a_list = a.split('|') - b_list = b.split('|') - - for a_item in a_list: - for b_item in b_list: - if (a_item == b_item): - return True - elif (a_item == '*') or (b_item == '*'): - return True - - return False - - def equal(self, other): - for t in Event.terms: - log.debug(" [%s] %s %s" % (t, self[t], other[t])); - if not self.has_key(t) or not other.has_key(t): - return False - if not self.compare_data(self[t], other[t]): - return False - return True - -# Test file description needs to have following sections: -# [config] -# - just single instance in file -# - needs to specify: -# 'command' - perf command name -# 'args' - special command arguments -# 'ret' - expected command return value (0 by default) -# -# [eventX:base] -# - one or multiple instances in file -# - expected values assignments -class Test(object): - def __init__(self, path, options): - parser = ConfigParser.SafeConfigParser() - parser.read(path) - - log.warning("running '%s'" % path) - - self.path = path - self.test_dir = options.test_dir - self.perf = options.perf - self.command = parser.get('config', 'command') - self.args = parser.get('config', 'args') - - try: - self.ret = parser.get('config', 'ret') - except: - self.ret = 0 - - self.expect = {} - self.result = {} - log.info(" loading expected events"); - self.load_events(path, self.expect) - - def is_event(self, name): - if name.find("event") == -1: - return False - else: - return True - - def load_events(self, path, events): - parser_event = ConfigParser.SafeConfigParser() - parser_event.read(path) - - # The event record section header contains 'event' word, - # optionaly followed by ':' allowing to load 'parent - # event' first as a base - for section in filter(self.is_event, parser_event.sections()): - - parser_items = parser_event.items(section); - base_items = {} - - # Read parent event if there's any - if (':' in section): - base = section[section.index(':') + 1:] - parser_base = ConfigParser.SafeConfigParser() - parser_base.read(self.test_dir + '/' + base) - base_items = parser_base.items('event') - - e = Event(section, parser_items, base_items) - events[section] = e - - def run_cmd(self, tempdir): - cmd = "PERF_TEST_ATTR=%s %s %s -o %s/perf.data %s" % (tempdir, - self.perf, self.command, tempdir, self.args) - ret = os.WEXITSTATUS(os.system(cmd)) - - log.info(" running '%s' ret %d " % (cmd, ret)) - - if ret != int(self.ret): - raise Unsup(self) - - def compare(self, expect, result): - match = {} - - log.info(" compare"); - - # For each expected event find all matching - # events in result. Fail if there's not any. - for exp_name, exp_event in expect.items(): - exp_list = [] - log.debug(" matching [%s]" % exp_name) - for res_name, res_event in result.items(): - log.debug(" to [%s]" % res_name) - if (exp_event.equal(res_event)): - exp_list.append(res_name) - log.debug(" ->OK") - else: - log.debug(" ->FAIL"); - - log.info(" match: [%s] matches %s" % (exp_name, str(exp_list))) - - # we did not any matching event - fail - if (not exp_list): - raise Fail(self, 'match failure'); - - match[exp_name] = exp_list - - # For each defined group in the expected events - # check we match the same group in the result. - for exp_name, exp_event in expect.items(): - group = exp_event.group - - if (group == ''): - continue - - for res_name in match[exp_name]: - res_group = result[res_name].group - if res_group not in match[group]: - raise Fail(self, 'group failure') - - log.info(" group: [%s] matches group leader %s" % - (exp_name, str(match[group]))) - - log.info(" matched") - - def resolve_groups(self, events): - for name, event in events.items(): - group_fd = event['group_fd']; - if group_fd == '-1': - continue; - - for iname, ievent in events.items(): - if (ievent['fd'] == group_fd): - event.group = iname - log.debug('[%s] has group leader [%s]' % (name, iname)) - break; - - def run(self): - tempdir = tempfile.mkdtemp(); - - try: - # run the test script - self.run_cmd(tempdir); - - # load events expectation for the test - log.info(" loading result events"); - for f in glob.glob(tempdir + '/event*'): - self.load_events(f, self.result); - - # resolve group_fd to event names - self.resolve_groups(self.expect); - self.resolve_groups(self.result); - - # do the expectation - results matching - both ways - self.compare(self.expect, self.result) - self.compare(self.result, self.expect) - - finally: - # cleanup - shutil.rmtree(tempdir) - - -def run_tests(options): - for f in glob.glob(options.test_dir + '/' + options.test): - try: - Test(f, options).run() - except Unsup, obj: - log.warning("unsupp %s" % obj.getMsg()) - -def setup_log(verbose): - global log - level = logging.CRITICAL - - if verbose == 1: - level = logging.WARNING - if verbose == 2: - level = logging.INFO - if verbose >= 3: - level = logging.DEBUG - - log = logging.getLogger('test') - log.setLevel(level) - ch = logging.StreamHandler() - ch.setLevel(level) - formatter = logging.Formatter('%(message)s') - ch.setFormatter(formatter) - log.addHandler(ch) - -USAGE = '''%s [OPTIONS] - -d dir # tests dir - -p path # perf binary - -t test # single test - -v # verbose level -''' % sys.argv[0] - -def main(): - parser = optparse.OptionParser(usage=USAGE) - - parser.add_option("-t", "--test", - action="store", type="string", dest="test") - parser.add_option("-d", "--test-dir", - action="store", type="string", dest="test_dir") - parser.add_option("-p", "--perf", - action="store", type="string", dest="perf") - parser.add_option("-v", "--verbose", - action="count", dest="verbose") - - options, args = parser.parse_args() - if args: - parser.error('FAILED wrong arguments %s' % ' '.join(args)) - return -1 - - setup_log(options.verbose) - - if not options.test_dir: - print 'FAILED no -d option specified' - sys.exit(-1) - - if not options.test: - options.test = 'test*' - - try: - run_tests(options) - - except Fail, obj: - print "FAILED %s" % obj.getMsg(); - sys.exit(-1) - - sys.exit(0) - -if __name__ == '__main__': - main() diff --git a/trunk/tools/perf/tests/attr/README b/trunk/tools/perf/tests/attr/README deleted file mode 100644 index d102957cd59a..000000000000 --- a/trunk/tools/perf/tests/attr/README +++ /dev/null @@ -1,64 +0,0 @@ -The struct perf_event_attr test (attr tests) support -==================================================== -This testing support is embedded into perf directly and is governed -by the PERF_TEST_ATTR environment variable and hook inside the -sys_perf_event_open function. - -The general idea is to store 'struct perf_event_attr' details for -each event created within single perf command. Each event details -are stored into separate text file. Once perf command is finished -these files are checked for values we expect for command. - -The attr tests consist of following parts: - -tests/attr.c ------------- -This is the sys_perf_event_open hook implementation. The hook -is triggered when the PERF_TEST_ATTR environment variable is -defined. It must contain name of existing directory with access -and write permissions. - -For each sys_perf_event_open call event details are stored in -separate file. Besides 'struct perf_event_attr' values we also -store 'fd' and 'group_fd' values to allow checking for groups. - -tests/attr.py -------------- -This is the python script that does all the hard work. It reads -the test definition, executes it and checks results. - -tests/attr/ ------------ -Directory containing all attr test definitions. -Following tests are defined (with perf commands): - - perf record kill (test-record-basic) - perf record -b kill (test-record-branch-any) - perf record -j any kill (test-record-branch-filter-any) - perf record -j any_call kill (test-record-branch-filter-any_call) - perf record -j any_ret kill (test-record-branch-filter-any_ret) - perf record -j hv kill (test-record-branch-filter-hv) - perf record -j ind_call kill (test-record-branch-filter-ind_call) - perf record -j k kill (test-record-branch-filter-k) - perf record -j u kill (test-record-branch-filter-u) - perf record -c 123 kill (test-record-count) - perf record -d kill (test-record-data) - perf record -F 100 kill (test-record-freq) - perf record -g -- kill (test-record-graph-default) - perf record -g dwarf -- kill (test-record-graph-dwarf) - perf record -g fp kill (test-record-graph-fp) - perf record --group -e cycles,instructions kill (test-record-group) - perf record -e '{cycles,instructions}' kill (test-record-group1) - perf record -D kill (test-record-no-delay) - perf record -i kill (test-record-no-inherit) - perf record -n kill (test-record-no-samples) - perf record -c 100 -P kill (test-record-period) - perf record -R kill (test-record-raw) - perf stat -e cycles kill (test-stat-basic) - perf stat kill (test-stat-default) - perf stat -d kill (test-stat-detailed-1) - perf stat -dd kill (test-stat-detailed-2) - perf stat -ddd kill (test-stat-detailed-3) - perf stat --group -e cycles,instructions kill (test-stat-group) - perf stat -e '{cycles,instructions}' kill (test-stat-group1) - perf stat -i -e cycles kill (test-stat-no-inherit) diff --git a/trunk/tools/perf/tests/attr/base-record b/trunk/tools/perf/tests/attr/base-record deleted file mode 100644 index f1485d8e6a0b..000000000000 --- a/trunk/tools/perf/tests/attr/base-record +++ /dev/null @@ -1,39 +0,0 @@ -[event] -fd=1 -group_fd=-1 -flags=0 -type=0|1 -size=96 -config=0 -sample_period=4000 -sample_type=263 -read_format=7 -disabled=1 -inherit=1 -pinned=0 -exclusive=0 -exclude_user=0 -exclude_kernel=0 -exclude_hv=0 -exclude_idle=0 -mmap=1 -comm=1 -freq=1 -inherit_stat=0 -enable_on_exec=1 -task=0 -watermark=0 -precise_ip=0 -mmap_data=0 -sample_id_all=1 -exclude_host=0 -exclude_guest=1 -exclude_callchain_kernel=0 -exclude_callchain_user=0 -wakeup_events=0 -bp_type=0 -config1=0 -config2=0 -branch_sample_type=0 -sample_regs_user=0 -sample_stack_user=0 diff --git a/trunk/tools/perf/tests/attr/base-stat b/trunk/tools/perf/tests/attr/base-stat deleted file mode 100644 index 4bd79a82784f..000000000000 --- a/trunk/tools/perf/tests/attr/base-stat +++ /dev/null @@ -1,39 +0,0 @@ -[event] -fd=1 -group_fd=-1 -flags=0 -type=0 -size=96 -config=0 -sample_period=0 -sample_type=0 -read_format=3 -disabled=1 -inherit=1 -pinned=0 -exclusive=0 -exclude_user=0 -exclude_kernel=0 -exclude_hv=0 -exclude_idle=0 -mmap=0 -comm=0 -freq=0 -inherit_stat=0 -enable_on_exec=1 -task=0 -watermark=0 -precise_ip=0 -mmap_data=0 -sample_id_all=0 -exclude_host=0 -exclude_guest=1 -exclude_callchain_kernel=0 -exclude_callchain_user=0 -wakeup_events=0 -bp_type=0 -config1=0 -config2=0 -branch_sample_type=0 -sample_regs_user=0 -sample_stack_user=0 diff --git a/trunk/tools/perf/tests/attr/test-record-basic b/trunk/tools/perf/tests/attr/test-record-basic deleted file mode 100644 index 55c0428370ca..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-basic +++ /dev/null @@ -1,5 +0,0 @@ -[config] -command = record -args = kill >/dev/null 2>&1 - -[event:base-record] diff --git a/trunk/tools/perf/tests/attr/test-record-branch-any b/trunk/tools/perf/tests/attr/test-record-branch-any deleted file mode 100644 index 1421960ed4e9..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-branch-any +++ /dev/null @@ -1,8 +0,0 @@ -[config] -command = record -args = -b kill >/dev/null 2>&1 - -[event:base-record] -sample_period=4000 -sample_type=2311 -branch_sample_type=8 diff --git a/trunk/tools/perf/tests/attr/test-record-branch-filter-any b/trunk/tools/perf/tests/attr/test-record-branch-filter-any deleted file mode 100644 index 915c4df0e0c2..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-branch-filter-any +++ /dev/null @@ -1,8 +0,0 @@ -[config] -command = record -args = -j any kill >/dev/null 2>&1 - -[event:base-record] -sample_period=4000 -sample_type=2311 -branch_sample_type=8 diff --git a/trunk/tools/perf/tests/attr/test-record-branch-filter-any_call b/trunk/tools/perf/tests/attr/test-record-branch-filter-any_call deleted file mode 100644 index 8708dbd4f373..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-branch-filter-any_call +++ /dev/null @@ -1,8 +0,0 @@ -[config] -command = record -args = -j any_call kill >/dev/null 2>&1 - -[event:base-record] -sample_period=4000 -sample_type=2311 -branch_sample_type=16 diff --git a/trunk/tools/perf/tests/attr/test-record-branch-filter-any_ret b/trunk/tools/perf/tests/attr/test-record-branch-filter-any_ret deleted file mode 100644 index 0d3607a6dcbe..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-branch-filter-any_ret +++ /dev/null @@ -1,8 +0,0 @@ -[config] -command = record -args = -j any_ret kill >/dev/null 2>&1 - -[event:base-record] -sample_period=4000 -sample_type=2311 -branch_sample_type=32 diff --git a/trunk/tools/perf/tests/attr/test-record-branch-filter-hv b/trunk/tools/perf/tests/attr/test-record-branch-filter-hv deleted file mode 100644 index f25526740cec..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-branch-filter-hv +++ /dev/null @@ -1,8 +0,0 @@ -[config] -command = record -args = -j hv kill >/dev/null 2>&1 - -[event:base-record] -sample_period=4000 -sample_type=2311 -branch_sample_type=8 diff --git a/trunk/tools/perf/tests/attr/test-record-branch-filter-ind_call b/trunk/tools/perf/tests/attr/test-record-branch-filter-ind_call deleted file mode 100644 index e862dd179128..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-branch-filter-ind_call +++ /dev/null @@ -1,8 +0,0 @@ -[config] -command = record -args = -j ind_call kill >/dev/null 2>&1 - -[event:base-record] -sample_period=4000 -sample_type=2311 -branch_sample_type=64 diff --git a/trunk/tools/perf/tests/attr/test-record-branch-filter-k b/trunk/tools/perf/tests/attr/test-record-branch-filter-k deleted file mode 100644 index 182971e898f5..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-branch-filter-k +++ /dev/null @@ -1,8 +0,0 @@ -[config] -command = record -args = -j k kill >/dev/null 2>&1 - -[event:base-record] -sample_period=4000 -sample_type=2311 -branch_sample_type=8 diff --git a/trunk/tools/perf/tests/attr/test-record-branch-filter-u b/trunk/tools/perf/tests/attr/test-record-branch-filter-u deleted file mode 100644 index 83449ef9e687..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-branch-filter-u +++ /dev/null @@ -1,8 +0,0 @@ -[config] -command = record -args = -j u kill >/dev/null 2>&1 - -[event:base-record] -sample_period=4000 -sample_type=2311 -branch_sample_type=8 diff --git a/trunk/tools/perf/tests/attr/test-record-count b/trunk/tools/perf/tests/attr/test-record-count deleted file mode 100644 index 2f841de56f6b..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-count +++ /dev/null @@ -1,8 +0,0 @@ -[config] -command = record -args = -c 123 kill >/dev/null 2>&1 - -[event:base-record] -sample_period=123 -sample_type=7 -freq=0 diff --git a/trunk/tools/perf/tests/attr/test-record-data b/trunk/tools/perf/tests/attr/test-record-data deleted file mode 100644 index 6627c3e7534a..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-data +++ /dev/null @@ -1,8 +0,0 @@ -[config] -command = record -args = -d kill >/dev/null 2>&1 - -[event:base-record] -sample_period=4000 -sample_type=271 -mmap_data=1 diff --git a/trunk/tools/perf/tests/attr/test-record-freq b/trunk/tools/perf/tests/attr/test-record-freq deleted file mode 100644 index 600d0f8f2583..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-freq +++ /dev/null @@ -1,6 +0,0 @@ -[config] -command = record -args = -F 100 kill >/dev/null 2>&1 - -[event:base-record] -sample_period=100 diff --git a/trunk/tools/perf/tests/attr/test-record-graph-default b/trunk/tools/perf/tests/attr/test-record-graph-default deleted file mode 100644 index 833d1849d767..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-graph-default +++ /dev/null @@ -1,6 +0,0 @@ -[config] -command = record -args = -g -- kill >/dev/null 2>&1 - -[event:base-record] -sample_type=295 diff --git a/trunk/tools/perf/tests/attr/test-record-graph-dwarf b/trunk/tools/perf/tests/attr/test-record-graph-dwarf deleted file mode 100644 index e93e082f5208..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-graph-dwarf +++ /dev/null @@ -1,10 +0,0 @@ -[config] -command = record -args = -g dwarf -- kill >/dev/null 2>&1 - -[event:base-record] -sample_type=12583 -exclude_callchain_user=1 -sample_stack_user=8192 -# TODO different for each arch, no support for that now -sample_regs_user=* diff --git a/trunk/tools/perf/tests/attr/test-record-graph-fp b/trunk/tools/perf/tests/attr/test-record-graph-fp deleted file mode 100644 index 7cef3743f03f..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-graph-fp +++ /dev/null @@ -1,6 +0,0 @@ -[config] -command = record -args = -g fp kill >/dev/null 2>&1 - -[event:base-record] -sample_type=295 diff --git a/trunk/tools/perf/tests/attr/test-record-group b/trunk/tools/perf/tests/attr/test-record-group deleted file mode 100644 index b945f770dc9e..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-group +++ /dev/null @@ -1,17 +0,0 @@ -[config] -command = record -args = --group -e cycles,instructions kill >/dev/null 2>&1 - -[event-1:base-record] -fd=1 -group_fd=-1 -sample_type=327 - -[event-2:base-record] -fd=2 -group_fd=1 -config=1 -sample_type=327 -mmap=0 -comm=0 -enable_on_exec=0 diff --git a/trunk/tools/perf/tests/attr/test-record-group1 b/trunk/tools/perf/tests/attr/test-record-group1 deleted file mode 100644 index 39bf8609538c..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-group1 +++ /dev/null @@ -1,20 +0,0 @@ -[config] -command = record -args = -e '{cycles,instructions}' kill >/tmp/krava 2>&1 - -[event-1:base-record] -fd=1 -group_fd=-1 -sample_type=327 - -[event-2:base-record] -fd=2 -group_fd=1 -type=0 -config=1 -sample_type=327 -mmap=0 -comm=0 -# TODO this is disabled for --group option, enabled otherwise -# check why.. -enable_on_exec=1 diff --git a/trunk/tools/perf/tests/attr/test-record-no-delay b/trunk/tools/perf/tests/attr/test-record-no-delay deleted file mode 100644 index f253b78cdbf2..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-no-delay +++ /dev/null @@ -1,9 +0,0 @@ -[config] -command = record -args = -D kill >/dev/null 2>&1 - -[event:base-record] -sample_period=4000 -sample_type=263 -watermark=0 -wakeup_events=1 diff --git a/trunk/tools/perf/tests/attr/test-record-no-inherit b/trunk/tools/perf/tests/attr/test-record-no-inherit deleted file mode 100644 index 9079a25cd643..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-no-inherit +++ /dev/null @@ -1,7 +0,0 @@ -[config] -command = record -args = -i kill >/dev/null 2>&1 - -[event:base-record] -sample_type=259 -inherit=0 diff --git a/trunk/tools/perf/tests/attr/test-record-no-samples b/trunk/tools/perf/tests/attr/test-record-no-samples deleted file mode 100644 index d0141b2418b5..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-no-samples +++ /dev/null @@ -1,6 +0,0 @@ -[config] -command = record -args = -n kill >/dev/null 2>&1 - -[event:base-record] -sample_period=0 diff --git a/trunk/tools/perf/tests/attr/test-record-period b/trunk/tools/perf/tests/attr/test-record-period deleted file mode 100644 index 8abc5314fc52..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-period +++ /dev/null @@ -1,7 +0,0 @@ -[config] -command = record -args = -c 100 -P kill >/dev/null 2>&1 - -[event:base-record] -sample_period=100 -freq=0 diff --git a/trunk/tools/perf/tests/attr/test-record-raw b/trunk/tools/perf/tests/attr/test-record-raw deleted file mode 100644 index 4a8ef25b5f49..000000000000 --- a/trunk/tools/perf/tests/attr/test-record-raw +++ /dev/null @@ -1,7 +0,0 @@ -[config] -command = record -args = -R kill >/dev/null 2>&1 - -[event:base-record] -sample_period=4000 -sample_type=1415 diff --git a/trunk/tools/perf/tests/attr/test-stat-basic b/trunk/tools/perf/tests/attr/test-stat-basic deleted file mode 100644 index 74e17881f2ba..000000000000 --- a/trunk/tools/perf/tests/attr/test-stat-basic +++ /dev/null @@ -1,6 +0,0 @@ -[config] -command = stat -args = -e cycles kill >/dev/null 2>&1 -ret = 1 - -[event:base-stat] diff --git a/trunk/tools/perf/tests/attr/test-stat-default b/trunk/tools/perf/tests/attr/test-stat-default deleted file mode 100644 index 19270f54c96e..000000000000 --- a/trunk/tools/perf/tests/attr/test-stat-default +++ /dev/null @@ -1,64 +0,0 @@ -[config] -command = stat -args = kill >/dev/null 2>&1 -ret = 1 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_TASK_CLOCK -[event1:base-stat] -fd=1 -type=1 -config=1 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_CONTEXT_SWITCHES -[event2:base-stat] -fd=2 -type=1 -config=3 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_CPU_MIGRATIONS -[event3:base-stat] -fd=3 -type=1 -config=4 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_PAGE_FAULTS -[event4:base-stat] -fd=4 -type=1 -config=2 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_CPU_CYCLES -[event5:base-stat] -fd=5 -type=0 -config=0 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_FRONTEND -[event6:base-stat] -fd=6 -type=0 -config=7 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND -[event7:base-stat] -fd=7 -type=0 -config=8 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS -[event8:base-stat] -fd=8 -type=0 -config=1 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_BRANCH_INSTRUCTIONS -[event9:base-stat] -fd=9 -type=0 -config=4 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_BRANCH_MISSES -[event10:base-stat] -fd=10 -type=0 -config=5 diff --git a/trunk/tools/perf/tests/attr/test-stat-detailed-1 b/trunk/tools/perf/tests/attr/test-stat-detailed-1 deleted file mode 100644 index 51426b87153b..000000000000 --- a/trunk/tools/perf/tests/attr/test-stat-detailed-1 +++ /dev/null @@ -1,101 +0,0 @@ -[config] -command = stat -args = -d kill >/dev/null 2>&1 -ret = 1 - - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_TASK_CLOCK -[event1:base-stat] -fd=1 -type=1 -config=1 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_CONTEXT_SWITCHES -[event2:base-stat] -fd=2 -type=1 -config=3 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_CPU_MIGRATIONS -[event3:base-stat] -fd=3 -type=1 -config=4 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_PAGE_FAULTS -[event4:base-stat] -fd=4 -type=1 -config=2 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_CPU_CYCLES -[event5:base-stat] -fd=5 -type=0 -config=0 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_FRONTEND -[event6:base-stat] -fd=6 -type=0 -config=7 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND -[event7:base-stat] -fd=7 -type=0 -config=8 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS -[event8:base-stat] -fd=8 -type=0 -config=1 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_BRANCH_INSTRUCTIONS -[event9:base-stat] -fd=9 -type=0 -config=4 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_BRANCH_MISSES -[event10:base-stat] -fd=10 -type=0 -config=5 - -# PERF_TYPE_HW_CACHE / -# PERF_COUNT_HW_CACHE_L1D << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event11:base-stat] -fd=11 -type=3 -config=0 - -# PERF_TYPE_HW_CACHE / -# PERF_COUNT_HW_CACHE_L1D << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event12:base-stat] -fd=12 -type=3 -config=65536 - -# PERF_TYPE_HW_CACHE / -# PERF_COUNT_HW_CACHE_LL << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event13:base-stat] -fd=13 -type=3 -config=2 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_LL << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event14:base-stat] -fd=14 -type=3 -config=65538 diff --git a/trunk/tools/perf/tests/attr/test-stat-detailed-2 b/trunk/tools/perf/tests/attr/test-stat-detailed-2 deleted file mode 100644 index 8de5acc31c27..000000000000 --- a/trunk/tools/perf/tests/attr/test-stat-detailed-2 +++ /dev/null @@ -1,155 +0,0 @@ -[config] -command = stat -args = -dd kill >/dev/null 2>&1 -ret = 1 - - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_TASK_CLOCK -[event1:base-stat] -fd=1 -type=1 -config=1 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_CONTEXT_SWITCHES -[event2:base-stat] -fd=2 -type=1 -config=3 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_CPU_MIGRATIONS -[event3:base-stat] -fd=3 -type=1 -config=4 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_PAGE_FAULTS -[event4:base-stat] -fd=4 -type=1 -config=2 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_CPU_CYCLES -[event5:base-stat] -fd=5 -type=0 -config=0 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_FRONTEND -[event6:base-stat] -fd=6 -type=0 -config=7 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND -[event7:base-stat] -fd=7 -type=0 -config=8 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS -[event8:base-stat] -fd=8 -type=0 -config=1 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_BRANCH_INSTRUCTIONS -[event9:base-stat] -fd=9 -type=0 -config=4 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_BRANCH_MISSES -[event10:base-stat] -fd=10 -type=0 -config=5 - -# PERF_TYPE_HW_CACHE / -# PERF_COUNT_HW_CACHE_L1D << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event11:base-stat] -fd=11 -type=3 -config=0 - -# PERF_TYPE_HW_CACHE / -# PERF_COUNT_HW_CACHE_L1D << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event12:base-stat] -fd=12 -type=3 -config=65536 - -# PERF_TYPE_HW_CACHE / -# PERF_COUNT_HW_CACHE_LL << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event13:base-stat] -fd=13 -type=3 -config=2 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_LL << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event14:base-stat] -fd=14 -type=3 -config=65538 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_L1I << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event15:base-stat] -fd=15 -type=3 -config=1 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_L1I << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event16:base-stat] -fd=16 -type=3 -config=65537 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_DTLB << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event17:base-stat] -fd=17 -type=3 -config=3 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_DTLB << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event18:base-stat] -fd=18 -type=3 -config=65539 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_ITLB << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event19:base-stat] -fd=19 -type=3 -config=4 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_ITLB << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event20:base-stat] -fd=20 -type=3 -config=65540 diff --git a/trunk/tools/perf/tests/attr/test-stat-detailed-3 b/trunk/tools/perf/tests/attr/test-stat-detailed-3 deleted file mode 100644 index 0a1f45bf7d79..000000000000 --- a/trunk/tools/perf/tests/attr/test-stat-detailed-3 +++ /dev/null @@ -1,173 +0,0 @@ -[config] -command = stat -args = -ddd kill >/dev/null 2>&1 -ret = 1 - - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_TASK_CLOCK -[event1:base-stat] -fd=1 -type=1 -config=1 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_CONTEXT_SWITCHES -[event2:base-stat] -fd=2 -type=1 -config=3 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_CPU_MIGRATIONS -[event3:base-stat] -fd=3 -type=1 -config=4 - -# PERF_TYPE_SOFTWARE / PERF_COUNT_SW_PAGE_FAULTS -[event4:base-stat] -fd=4 -type=1 -config=2 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_CPU_CYCLES -[event5:base-stat] -fd=5 -type=0 -config=0 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_FRONTEND -[event6:base-stat] -fd=6 -type=0 -config=7 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_STALLED_CYCLES_BACKEND -[event7:base-stat] -fd=7 -type=0 -config=8 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_INSTRUCTIONS -[event8:base-stat] -fd=8 -type=0 -config=1 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_BRANCH_INSTRUCTIONS -[event9:base-stat] -fd=9 -type=0 -config=4 - -# PERF_TYPE_HARDWARE / PERF_COUNT_HW_BRANCH_MISSES -[event10:base-stat] -fd=10 -type=0 -config=5 - -# PERF_TYPE_HW_CACHE / -# PERF_COUNT_HW_CACHE_L1D << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event11:base-stat] -fd=11 -type=3 -config=0 - -# PERF_TYPE_HW_CACHE / -# PERF_COUNT_HW_CACHE_L1D << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event12:base-stat] -fd=12 -type=3 -config=65536 - -# PERF_TYPE_HW_CACHE / -# PERF_COUNT_HW_CACHE_LL << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event13:base-stat] -fd=13 -type=3 -config=2 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_LL << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event14:base-stat] -fd=14 -type=3 -config=65538 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_L1I << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event15:base-stat] -fd=15 -type=3 -config=1 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_L1I << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event16:base-stat] -fd=16 -type=3 -config=65537 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_DTLB << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event17:base-stat] -fd=17 -type=3 -config=3 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_DTLB << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event18:base-stat] -fd=18 -type=3 -config=65539 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_ITLB << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event19:base-stat] -fd=19 -type=3 -config=4 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_ITLB << 0 | -# (PERF_COUNT_HW_CACHE_OP_READ << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event20:base-stat] -fd=20 -type=3 -config=65540 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_L1D << 0 | -# (PERF_COUNT_HW_CACHE_OP_PREFETCH << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) -[event21:base-stat] -fd=21 -type=3 -config=512 - -# PERF_TYPE_HW_CACHE, -# PERF_COUNT_HW_CACHE_L1D << 0 | -# (PERF_COUNT_HW_CACHE_OP_PREFETCH << 8) | -# (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) -[event22:base-stat] -fd=22 -type=3 -config=66048 diff --git a/trunk/tools/perf/tests/attr/test-stat-group b/trunk/tools/perf/tests/attr/test-stat-group deleted file mode 100644 index fdc1596a8862..000000000000 --- a/trunk/tools/perf/tests/attr/test-stat-group +++ /dev/null @@ -1,15 +0,0 @@ -[config] -command = stat -args = --group -e cycles,instructions kill >/dev/null 2>&1 -ret = 1 - -[event-1:base-stat] -fd=1 -group_fd=-1 - -[event-2:base-stat] -fd=2 -group_fd=1 -config=1 -disabled=0 -enable_on_exec=0 diff --git a/trunk/tools/perf/tests/attr/test-stat-group1 b/trunk/tools/perf/tests/attr/test-stat-group1 deleted file mode 100644 index 5ae2718de864..000000000000 --- a/trunk/tools/perf/tests/attr/test-stat-group1 +++ /dev/null @@ -1,17 +0,0 @@ -[config] -command = stat -args = -e '{cycles,instructions}' kill >/dev/null 2>&1 -ret = 1 - -[event-1:base-stat] -fd=1 -group_fd=-1 - -[event-2:base-stat] -fd=2 -group_fd=1 -config=1 -# TODO both disabled and enable_on_exec are disabled for --group option, -# enabled otherwise, check why.. -disabled=1 -enable_on_exec=1 diff --git a/trunk/tools/perf/tests/attr/test-stat-no-inherit b/trunk/tools/perf/tests/attr/test-stat-no-inherit deleted file mode 100644 index d54b2a1e3e28..000000000000 --- a/trunk/tools/perf/tests/attr/test-stat-no-inherit +++ /dev/null @@ -1,7 +0,0 @@ -[config] -command = stat -args = -i -e cycles kill >/dev/null 2>&1 -ret = 1 - -[event:base-stat] -inherit=0 diff --git a/trunk/tools/perf/ui/browsers/annotate.c b/trunk/tools/perf/ui/browsers/annotate.c index 5dab3ca96980..28f8aab73aee 100644 --- a/trunk/tools/perf/ui/browsers/annotate.c +++ b/trunk/tools/perf/ui/browsers/annotate.c @@ -188,12 +188,6 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) struct disasm_line *cursor = ab->selection, *target; struct browser_disasm_line *btarget, *bcursor; unsigned int from, to; - struct map_symbol *ms = ab->b.priv; - struct symbol *sym = ms->sym; - - /* PLT symbols contain external offsets */ - if (strstr(sym->name, "@plt")) - return; if (!cursor || !cursor->ins || !ins__is_jump(cursor->ins) || !disasm_line__has_offset(cursor)) @@ -392,8 +386,9 @@ static void annotate_browser__init_asm_mode(struct annotate_browser *browser) browser->b.nr_entries = browser->nr_asm_entries; } -static bool annotate_browser__callq(struct annotate_browser *browser, int evidx, - struct hist_browser_timer *hbt) +static bool annotate_browser__callq(struct annotate_browser *browser, + int evidx, void (*timer)(void *arg), + void *arg, int delay_secs) { struct map_symbol *ms = browser->b.priv; struct disasm_line *dl = browser->selection; @@ -423,7 +418,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, int evidx, } pthread_mutex_unlock(¬es->lock); - symbol__tui_annotate(target, ms->map, evidx, hbt); + symbol__tui_annotate(target, ms->map, evidx, timer, arg, delay_secs); ui_browser__show_title(&browser->b, sym->name); return true; } @@ -607,13 +602,13 @@ static void annotate_browser__update_addr_width(struct annotate_browser *browser } static int annotate_browser__run(struct annotate_browser *browser, int evidx, - struct hist_browser_timer *hbt) + void(*timer)(void *arg), + void *arg, int delay_secs) { struct rb_node *nd = NULL; struct map_symbol *ms = browser->b.priv; struct symbol *sym = ms->sym; const char *help = "Press 'h' for help on key bindings"; - int delay_secs = hbt ? hbt->refresh : 0; int key; if (ui_browser__show(&browser->b, sym->name, help) < 0) @@ -644,8 +639,8 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx, switch (key) { case K_TIMER: - if (hbt) - hbt->timer(hbt->arg); + if (timer != NULL) + timer(arg); if (delay_secs != 0) symbol__annotate_decay_histogram(sym, evidx); @@ -745,7 +740,7 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx, goto show_sup_ins; goto out; } else if (!(annotate_browser__jump(browser) || - annotate_browser__callq(browser, evidx, hbt))) { + annotate_browser__callq(browser, evidx, timer, arg, delay_secs))) { show_sup_ins: ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions."); } @@ -768,21 +763,16 @@ static int annotate_browser__run(struct annotate_browser *browser, int evidx, } int hist_entry__tui_annotate(struct hist_entry *he, int evidx, - struct hist_browser_timer *hbt) + void(*timer)(void *arg), void *arg, int delay_secs) { - return symbol__tui_annotate(he->ms.sym, he->ms.map, evidx, hbt); + return symbol__tui_annotate(he->ms.sym, he->ms.map, evidx, + timer, arg, delay_secs); } static void annotate_browser__mark_jump_targets(struct annotate_browser *browser, size_t size) { u64 offset; - struct map_symbol *ms = browser->b.priv; - struct symbol *sym = ms->sym; - - /* PLT symbols contain external offsets */ - if (strstr(sym->name, "@plt")) - return; for (offset = 0; offset < size; ++offset) { struct disasm_line *dl = browser->offsets[offset], *dlt; @@ -826,7 +816,8 @@ static inline int width_jumps(int n) } int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, - struct hist_browser_timer *hbt) + void(*timer)(void *arg), void *arg, + int delay_secs) { struct disasm_line *pos, *n; struct annotation *notes; @@ -908,7 +899,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, annotate_browser__update_addr_width(&browser); - ret = annotate_browser__run(&browser, evidx, hbt); + ret = annotate_browser__run(&browser, evidx, timer, arg, delay_secs); list_for_each_entry_safe(pos, n, ¬es->src->source, node) { list_del(&pos->node); disasm_line__free(pos); diff --git a/trunk/tools/perf/ui/browsers/hists.c b/trunk/tools/perf/ui/browsers/hists.c index ccc4bd161420..fe622845872e 100644 --- a/trunk/tools/perf/ui/browsers/hists.c +++ b/trunk/tools/perf/ui/browsers/hists.c @@ -11,7 +11,6 @@ #include "../../util/pstack.h" #include "../../util/sort.h" #include "../../util/util.h" -#include "../../arch/common.h" #include "../browser.h" #include "../helpline.h" @@ -311,11 +310,10 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser) } static int hist_browser__run(struct hist_browser *browser, const char *ev_name, - struct hist_browser_timer *hbt) + void(*timer)(void *arg), void *arg, int delay_secs) { int key; char title[160]; - int delay_secs = hbt ? hbt->refresh : 0; browser->b.entries = &browser->hists->entries; browser->b.nr_entries = browser->hists->nr_entries; @@ -332,7 +330,7 @@ static int hist_browser__run(struct hist_browser *browser, const char *ev_name, switch (key) { case K_TIMER: - hbt->timer(hbt->arg); + timer(arg); ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries); if (browser->hists->stats.nr_lost_warned != @@ -1129,17 +1127,11 @@ static inline void free_popup_options(char **options, int n) } } -/* Check whether the browser is for 'top' or 'report' */ -static inline bool is_report_browser(void *timer) -{ - return timer == NULL; -} - static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, const char *helpline, const char *ev_name, bool left_exits, - struct hist_browser_timer *hbt, - struct perf_session_env *env) + void(*timer)(void *arg), void *arg, + int delay_secs) { struct hists *hists = &evsel->hists; struct hist_browser *browser = hist_browser__new(hists); @@ -1150,7 +1142,6 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, int key = -1; char buf[64]; char script_opt[64]; - int delay_secs = hbt ? hbt->refresh : 0; if (browser == NULL) return -1; @@ -1173,7 +1164,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, nr_options = 0; - key = hist_browser__run(browser, ev_name, hbt); + key = hist_browser__run(browser, ev_name, timer, arg, delay_secs); if (browser->he_selection != NULL) { thread = hist_browser__selected_thread(browser); @@ -1223,9 +1214,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, } continue; case 'r': - if (is_report_browser(hbt)) - goto do_scripts; - continue; + goto do_scripts; case K_F1: case 'h': case '?': @@ -1244,7 +1233,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, "E Expand all callchains\n" "d Zoom into current DSO\n" "t Zoom into current Thread\n" - "r Run available scripts('perf report' only)\n" + "r Run available scripts\n" "P Print histograms to perf.hist.N\n" "V Verbose (DSO names in callchains, etc)\n" "/ Filter symbol by name"); @@ -1369,9 +1358,6 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, struct hist_entry *he; int err; do_annotate: - if (!objdump_path && perf_session_env__lookup_objdump(env)) - continue; - he = hist_browser__selected_entry(browser); if (he == NULL) continue; @@ -1394,7 +1380,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, * Don't let this be freed, say, by hists__decay_entry. */ he->used = true; - err = hist_entry__tui_annotate(he, evsel->idx, hbt); + err = hist_entry__tui_annotate(he, evsel->idx, + timer, arg, delay_secs); he->used = false; /* * offer option to annotate the other branch source or target @@ -1475,7 +1462,6 @@ struct perf_evsel_menu { struct ui_browser b; struct perf_evsel *selection; bool lost_events, lost_events_warned; - struct perf_session_env *env; }; static void perf_evsel_menu__write(struct ui_browser *browser, @@ -1518,12 +1504,11 @@ static void perf_evsel_menu__write(struct ui_browser *browser, static int perf_evsel_menu__run(struct perf_evsel_menu *menu, int nr_events, const char *help, - struct hist_browser_timer *hbt) + void(*timer)(void *arg), void *arg, int delay_secs) { struct perf_evlist *evlist = menu->b.priv; struct perf_evsel *pos; const char *ev_name, *title = "Available samples"; - int delay_secs = hbt ? hbt->refresh : 0; int key; if (ui_browser__show(&menu->b, title, @@ -1535,7 +1520,7 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu, switch (key) { case K_TIMER: - hbt->timer(hbt->arg); + timer(arg); if (!menu->lost_events_warned && menu->lost_events) { ui_browser__warn_lost_events(&menu->b); @@ -1553,12 +1538,12 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu, * Give the calling tool a chance to populate the non * default evsel resorted hists tree. */ - if (hbt) - hbt->timer(hbt->arg); + if (timer) + timer(arg); ev_name = perf_evsel__name(pos); key = perf_evsel__hists_browse(pos, nr_events, help, - ev_name, true, hbt, - menu->env); + ev_name, true, timer, + arg, delay_secs); ui_browser__show_title(&menu->b, title); switch (key) { case K_TAB: @@ -1606,8 +1591,8 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu, static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, - struct hist_browser_timer *hbt, - struct perf_session_env *env) + void(*timer)(void *arg), void *arg, + int delay_secs) { struct perf_evsel *pos; struct perf_evsel_menu menu = { @@ -1619,7 +1604,6 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, .nr_entries = evlist->nr_entries, .priv = evlist, }, - .env = env, }; ui_helpline__push("Press ESC to exit"); @@ -1632,20 +1616,23 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, menu.b.width = line_len; } - return perf_evsel_menu__run(&menu, evlist->nr_entries, help, hbt); + return perf_evsel_menu__run(&menu, evlist->nr_entries, help, timer, + arg, delay_secs); } int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, - struct hist_browser_timer *hbt, - struct perf_session_env *env) + void(*timer)(void *arg), void *arg, + int delay_secs) { if (evlist->nr_entries == 1) { struct perf_evsel *first = list_entry(evlist->entries.next, struct perf_evsel, node); const char *ev_name = perf_evsel__name(first); return perf_evsel__hists_browse(first, evlist->nr_entries, help, - ev_name, false, hbt, env); + ev_name, false, timer, arg, + delay_secs); } - return __perf_evlist__tui_browse_hists(evlist, help, hbt, env); + return __perf_evlist__tui_browse_hists(evlist, help, + timer, arg, delay_secs); } diff --git a/trunk/tools/perf/ui/gtk/browser.c b/trunk/tools/perf/ui/gtk/browser.c index 253b6219a39e..4125c6284114 100644 --- a/trunk/tools/perf/ui/gtk/browser.c +++ b/trunk/tools/perf/ui/gtk/browser.c @@ -237,7 +237,9 @@ static GtkWidget *perf_gtk__setup_statusbar(void) int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help, - struct hist_browser_timer *hbt __maybe_unused) + void (*timer) (void *arg)__maybe_unused, + void *arg __maybe_unused, + int delay_secs __maybe_unused) { struct perf_evsel *pos; GtkWidget *vbox; diff --git a/trunk/tools/perf/ui/hist.c b/trunk/tools/perf/ui/hist.c index aa84130024d5..4f5f4756faac 100644 --- a/trunk/tools/perf/ui/hist.c +++ b/trunk/tools/perf/ui/hist.c @@ -161,7 +161,7 @@ static int hpp__width_baseline(struct perf_hpp *hpp __maybe_unused) static double baseline_percent(struct hist_entry *he) { - struct hist_entry *pair = hist_entry__next_pair(he); + struct hist_entry *pair = he->pair; struct hists *pair_hists = pair ? pair->hists : NULL; double percent = 0.0; @@ -179,7 +179,7 @@ static int hpp__color_baseline(struct perf_hpp *hpp, struct hist_entry *he) { double percent = baseline_percent(he); - if (hist_entry__has_pairs(he)) + if (he->pair) return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%%", percent); else return scnprintf(hpp->buf, hpp->size, " "); @@ -190,7 +190,7 @@ static int hpp__entry_baseline(struct perf_hpp *hpp, struct hist_entry *he) double percent = baseline_percent(he); const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%"; - if (hist_entry__has_pairs(he) || symbol_conf.field_sep) + if (he->pair || symbol_conf.field_sep) return scnprintf(hpp->buf, hpp->size, fmt, percent); else return scnprintf(hpp->buf, hpp->size, " "); @@ -248,7 +248,7 @@ static int hpp__width_period_baseline(struct perf_hpp *hpp __maybe_unused) static int hpp__entry_period_baseline(struct perf_hpp *hpp, struct hist_entry *he) { - struct hist_entry *pair = hist_entry__next_pair(he); + struct hist_entry *pair = he->pair; u64 period = pair ? pair->stat.period : 0; const char *fmt = symbol_conf.field_sep ? "%" PRIu64 : "%12" PRIu64; @@ -354,7 +354,7 @@ static int hpp__width_displ(struct perf_hpp *hpp __maybe_unused) static int hpp__entry_displ(struct perf_hpp *hpp, struct hist_entry *he) { - struct hist_entry *pair = hist_entry__next_pair(he); + struct hist_entry *pair = he->pair; long displacement = pair ? pair->position - he->position : 0; const char *fmt = symbol_conf.field_sep ? "%s" : "%6.6s"; char buf[32] = " "; diff --git a/trunk/tools/perf/util/PERF-VERSION-GEN b/trunk/tools/perf/util/PERF-VERSION-GEN index 6aa34e5afdcf..95264f304179 100755 --- a/trunk/tools/perf/util/PERF-VERSION-GEN +++ b/trunk/tools/perf/util/PERF-VERSION-GEN @@ -9,14 +9,18 @@ GVF=${OUTPUT}PERF-VERSION-FILE LF=' ' -# # First check if there is a .git to get the version from git describe -# otherwise try to get the version from the kernel Makefile -# +# otherwise try to get the version from the kernel makefile if test -d ../../.git -o -f ../../.git && - VN=$(git tag 2>/dev/null | tail -1 | grep -E "v[0-9].[0-9]*") + VN=$(git describe --match 'v[0-9].[0-9]*' --abbrev=4 HEAD 2>/dev/null) && + case "$VN" in + *$LF*) (exit 1) ;; + v[0-9]*) + git update-index -q --refresh + test -z "$(git diff-index --name-only HEAD --)" || + VN="$VN-dirty" ;; + esac then - VN=$(echo $VN"-g"$(git log -1 --abbrev=4 --pretty=format:"%h" HEAD)) VN=$(echo "$VN" | sed -e 's/-/./g'); else VN=$(MAKEFLAGS= make -sC ../.. kernelversion) diff --git a/trunk/tools/perf/util/annotate.c b/trunk/tools/perf/util/annotate.c index 07aaeea60000..7a34dd18b74c 100644 --- a/trunk/tools/perf/util/annotate.c +++ b/trunk/tools/perf/util/annotate.c @@ -171,15 +171,15 @@ static int lock__parse(struct ins_operands *ops) if (disasm_line__parse(ops->raw, &name, &ops->locked.ops->raw) < 0) goto out_free_ops; - ops->locked.ins = ins__find(name); - if (ops->locked.ins == NULL) - goto out_free_ops; + ops->locked.ins = ins__find(name); + if (ops->locked.ins == NULL) + goto out_free_ops; - if (!ops->locked.ins->ops) - return 0; + if (!ops->locked.ins->ops) + return 0; - if (ops->locked.ins->ops->parse) - ops->locked.ins->ops->parse(ops->locked.ops); + if (ops->locked.ins->ops->parse) + ops->locked.ins->ops->parse(ops->locked.ops); return 0; @@ -401,8 +401,6 @@ static struct ins instructions[] = { { .name = "testb", .ops = &mov_ops, }, { .name = "testl", .ops = &mov_ops, }, { .name = "xadd", .ops = &mov_ops, }, - { .name = "xbeginl", .ops = &jump_ops, }, - { .name = "xbeginq", .ops = &jump_ops, }, }; static int ins__cmp(const void *name, const void *insp) @@ -858,68 +856,21 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin struct source_line *iter; struct rb_node **p = &root->rb_node; struct rb_node *parent = NULL; - int ret; while (*p != NULL) { parent = *p; iter = rb_entry(parent, struct source_line, node); - ret = strcmp(iter->path, src_line->path); - if (ret == 0) { - iter->percent_sum += src_line->percent; - return; - } - - if (ret < 0) + if (src_line->percent > iter->percent) p = &(*p)->rb_left; else p = &(*p)->rb_right; } - src_line->percent_sum = src_line->percent; - rb_link_node(&src_line->node, parent, p); rb_insert_color(&src_line->node, root); } -static void __resort_source_line(struct rb_root *root, struct source_line *src_line) -{ - struct source_line *iter; - struct rb_node **p = &root->rb_node; - struct rb_node *parent = NULL; - - while (*p != NULL) { - parent = *p; - iter = rb_entry(parent, struct source_line, node); - - if (src_line->percent_sum > iter->percent_sum) - p = &(*p)->rb_left; - else - p = &(*p)->rb_right; - } - - rb_link_node(&src_line->node, parent, p); - rb_insert_color(&src_line->node, root); -} - -static void resort_source_line(struct rb_root *dest_root, struct rb_root *src_root) -{ - struct source_line *src_line; - struct rb_node *node; - - node = rb_first(src_root); - while (node) { - struct rb_node *next; - - src_line = rb_entry(node, struct source_line, node); - next = rb_next(node); - rb_erase(node, src_root); - - __resort_source_line(dest_root, src_line); - node = next; - } -} - static void symbol__free_source_line(struct symbol *sym, int len) { struct annotation *notes = symbol__annotation(sym); @@ -944,7 +895,6 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, struct source_line *src_line; struct annotation *notes = symbol__annotation(sym); struct sym_hist *h = annotation__histogram(notes, evidx); - struct rb_root tmp_root = RB_ROOT; if (!h->sum) return 0; @@ -979,13 +929,12 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, goto next; strcpy(src_line[i].path, path); - insert_source_line(&tmp_root, &src_line[i]); + insert_source_line(root, &src_line[i]); next: pclose(fp); } - resort_source_line(root, &tmp_root); return 0; } @@ -1009,7 +958,7 @@ static void print_summary(struct rb_root *root, const char *filename) char *path; src_line = rb_entry(node, struct source_line, node); - percent = src_line->percent_sum; + percent = src_line->percent; color = get_percent_color(percent); path = src_line->path; diff --git a/trunk/tools/perf/util/annotate.h b/trunk/tools/perf/util/annotate.h index 8eec94358a4a..a4dd25a61a07 100644 --- a/trunk/tools/perf/util/annotate.h +++ b/trunk/tools/perf/util/annotate.h @@ -5,7 +5,6 @@ #include #include "types.h" #include "symbol.h" -#include "hist.h" #include #include #include @@ -76,7 +75,6 @@ struct sym_hist { struct source_line { struct rb_node node; double percent; - double percent_sum; char *path; }; @@ -142,13 +140,14 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, #ifdef NEWT_SUPPORT int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, - struct hist_browser_timer *hbt); + void(*timer)(void *arg), void *arg, int delay_secs); #else static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, struct map *map __maybe_unused, int evidx __maybe_unused, - struct hist_browser_timer *hbt - __maybe_unused) + void(*timer)(void *arg) __maybe_unused, + void *arg __maybe_unused, + int delay_secs __maybe_unused) { return 0; } diff --git a/trunk/tools/perf/tests/dso-data.c b/trunk/tools/perf/util/dso-test-data.c similarity index 99% rename from trunk/tools/perf/tests/dso-data.c rename to trunk/tools/perf/util/dso-test-data.c index 0cd42fc9bc13..c6caedeb1d6b 100644 --- a/trunk/tools/perf/tests/dso-data.c +++ b/trunk/tools/perf/util/dso-test-data.c @@ -6,7 +6,6 @@ #include #include -#include "machine.h" #include "symbol.h" #define TEST_ASSERT_VAL(text, cond) \ diff --git a/trunk/tools/perf/util/dso.c b/trunk/tools/perf/util/dso.c index d6d9a465acdb..db24a3f0c820 100644 --- a/trunk/tools/perf/util/dso.c +++ b/trunk/tools/perf/util/dso.c @@ -1,6 +1,5 @@ #include "symbol.h" #include "dso.h" -#include "machine.h" #include "util.h" #include "debug.h" diff --git a/trunk/tools/perf/util/hist.c b/trunk/tools/perf/util/hist.c index 7c6e73b1b7ea..277947a669b2 100644 --- a/trunk/tools/perf/util/hist.c +++ b/trunk/tools/perf/util/hist.c @@ -244,8 +244,6 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template) he->ms.map->referenced = true; if (symbol_conf.use_callchain) callchain_init(he->callchain); - - INIT_LIST_HEAD(&he->pairs.node); } return he; @@ -412,7 +410,6 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right) void hist_entry__free(struct hist_entry *he) { - free(he->branch_info); free(he); } @@ -716,100 +713,3 @@ void hists__inc_nr_events(struct hists *hists, u32 type) ++hists->stats.nr_events[0]; ++hists->stats.nr_events[type]; } - -static struct hist_entry *hists__add_dummy_entry(struct hists *hists, - struct hist_entry *pair) -{ - struct rb_node **p = &hists->entries.rb_node; - struct rb_node *parent = NULL; - struct hist_entry *he; - int cmp; - - while (*p != NULL) { - parent = *p; - he = rb_entry(parent, struct hist_entry, rb_node); - - cmp = hist_entry__cmp(pair, he); - - if (!cmp) - goto out; - - if (cmp < 0) - p = &(*p)->rb_left; - else - p = &(*p)->rb_right; - } - - he = hist_entry__new(pair); - if (he) { - he->stat.nr_events = 0; - he->stat.period = 0; - he->hists = hists; - rb_link_node(&he->rb_node, parent, p); - rb_insert_color(&he->rb_node, &hists->entries); - hists__inc_nr_entries(hists, he); - } -out: - return he; -} - -static struct hist_entry *hists__find_entry(struct hists *hists, - struct hist_entry *he) -{ - struct rb_node *n = hists->entries.rb_node; - - while (n) { - struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node); - int64_t cmp = hist_entry__cmp(he, iter); - - if (cmp < 0) - n = n->rb_left; - else if (cmp > 0) - n = n->rb_right; - else - return iter; - } - - return NULL; -} - -/* - * Look for pairs to link to the leader buckets (hist_entries): - */ -void hists__match(struct hists *leader, struct hists *other) -{ - struct rb_node *nd; - struct hist_entry *pos, *pair; - - for (nd = rb_first(&leader->entries); nd; nd = rb_next(nd)) { - pos = rb_entry(nd, struct hist_entry, rb_node); - pair = hists__find_entry(other, pos); - - if (pair) - hist__entry_add_pair(pos, pair); - } -} - -/* - * Look for entries in the other hists that are not present in the leader, if - * we find them, just add a dummy entry on the leader hists, with period=0, - * nr_events=0, to serve as the list header. - */ -int hists__link(struct hists *leader, struct hists *other) -{ - struct rb_node *nd; - struct hist_entry *pos, *pair; - - for (nd = rb_first(&other->entries); nd; nd = rb_next(nd)) { - pos = rb_entry(nd, struct hist_entry, rb_node); - - if (!hist_entry__has_pairs(pos)) { - pair = hists__add_dummy_entry(leader, pos); - if (pair == NULL) - return -1; - hist__entry_add_pair(pair, pos); - } - } - - return 0; -} diff --git a/trunk/tools/perf/util/hist.h b/trunk/tools/perf/util/hist.h index 1278c2c72a96..b87460971736 100644 --- a/trunk/tools/perf/util/hist.h +++ b/trunk/tools/perf/util/hist.h @@ -4,7 +4,6 @@ #include #include #include "callchain.h" -#include "header.h" extern struct callchain_param callchain_param; @@ -115,9 +114,6 @@ bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len); void hists__reset_col_len(struct hists *hists); void hists__calc_col_len(struct hists *hists, struct hist_entry *he); -void hists__match(struct hists *leader, struct hists *other); -int hists__link(struct hists *leader, struct hists *other); - struct perf_hpp { char *buf; size_t size; @@ -161,27 +157,22 @@ int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he, struct perf_evlist; -struct hist_browser_timer { - void (*timer)(void *arg); - void *arg; - int refresh; -}; - #ifdef NEWT_SUPPORT #include "../ui/keysyms.h" int hist_entry__tui_annotate(struct hist_entry *he, int evidx, - struct hist_browser_timer *hbt); + void(*timer)(void *arg), void *arg, int delay_secs); int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, - struct hist_browser_timer *hbt, - struct perf_session_env *env); + void(*timer)(void *arg), void *arg, + int refresh); int script_browse(const char *script_opt); #else static inline int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, const char *help __maybe_unused, - struct hist_browser_timer *hbt __maybe_unused, - struct perf_session_env *env __maybe_unused) + void(*timer)(void *arg) __maybe_unused, + void *arg __maybe_unused, + int refresh __maybe_unused) { return 0; } @@ -189,8 +180,10 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, static inline int hist_entry__tui_annotate(struct hist_entry *self __maybe_unused, int evidx __maybe_unused, - struct hist_browser_timer *hbt - __maybe_unused) + void(*timer)(void *arg) + __maybe_unused, + void *arg __maybe_unused, + int delay_secs __maybe_unused) { return 0; } @@ -206,12 +199,15 @@ static inline int script_browse(const char *script_opt) #ifdef GTK2_SUPPORT int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help, - struct hist_browser_timer *hbt __maybe_unused); + void(*timer)(void *arg), void *arg, + int refresh); #else static inline int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused, const char *help __maybe_unused, - struct hist_browser_timer *hbt __maybe_unused) + void(*timer)(void *arg) __maybe_unused, + void *arg __maybe_unused, + int refresh __maybe_unused) { return 0; } diff --git a/trunk/tools/perf/util/machine.c b/trunk/tools/perf/util/machine.c index 1f09d0581e6b..502eec0d4773 100644 --- a/trunk/tools/perf/util/machine.c +++ b/trunk/tools/perf/util/machine.c @@ -2,192 +2,9 @@ #include "event.h" #include "machine.h" #include "map.h" -#include "strlist.h" #include "thread.h" #include -int machine__init(struct machine *machine, const char *root_dir, pid_t pid) -{ - map_groups__init(&machine->kmaps); - RB_CLEAR_NODE(&machine->rb_node); - INIT_LIST_HEAD(&machine->user_dsos); - INIT_LIST_HEAD(&machine->kernel_dsos); - - machine->threads = RB_ROOT; - INIT_LIST_HEAD(&machine->dead_threads); - machine->last_match = NULL; - - machine->kmaps.machine = machine; - machine->pid = pid; - - machine->root_dir = strdup(root_dir); - if (machine->root_dir == NULL) - return -ENOMEM; - - if (pid != HOST_KERNEL_ID) { - struct thread *thread = machine__findnew_thread(machine, pid); - char comm[64]; - - if (thread == NULL) - return -ENOMEM; - - snprintf(comm, sizeof(comm), "[guest/%d]", pid); - thread__set_comm(thread, comm); - } - - return 0; -} - -static void dsos__delete(struct list_head *dsos) -{ - struct dso *pos, *n; - - list_for_each_entry_safe(pos, n, dsos, node) { - list_del(&pos->node); - dso__delete(pos); - } -} - -void machine__exit(struct machine *machine) -{ - map_groups__exit(&machine->kmaps); - dsos__delete(&machine->user_dsos); - dsos__delete(&machine->kernel_dsos); - free(machine->root_dir); - machine->root_dir = NULL; -} - -void machine__delete(struct machine *machine) -{ - machine__exit(machine); - free(machine); -} - -struct machine *machines__add(struct rb_root *machines, pid_t pid, - const char *root_dir) -{ - struct rb_node **p = &machines->rb_node; - struct rb_node *parent = NULL; - struct machine *pos, *machine = malloc(sizeof(*machine)); - - if (machine == NULL) - return NULL; - - if (machine__init(machine, root_dir, pid) != 0) { - free(machine); - return NULL; - } - - while (*p != NULL) { - parent = *p; - pos = rb_entry(parent, struct machine, rb_node); - if (pid < pos->pid) - p = &(*p)->rb_left; - else - p = &(*p)->rb_right; - } - - rb_link_node(&machine->rb_node, parent, p); - rb_insert_color(&machine->rb_node, machines); - - return machine; -} - -struct machine *machines__find(struct rb_root *machines, pid_t pid) -{ - struct rb_node **p = &machines->rb_node; - struct rb_node *parent = NULL; - struct machine *machine; - struct machine *default_machine = NULL; - - while (*p != NULL) { - parent = *p; - machine = rb_entry(parent, struct machine, rb_node); - if (pid < machine->pid) - p = &(*p)->rb_left; - else if (pid > machine->pid) - p = &(*p)->rb_right; - else - return machine; - if (!machine->pid) - default_machine = machine; - } - - return default_machine; -} - -struct machine *machines__findnew(struct rb_root *machines, pid_t pid) -{ - char path[PATH_MAX]; - const char *root_dir = ""; - struct machine *machine = machines__find(machines, pid); - - if (machine && (machine->pid == pid)) - goto out; - - if ((pid != HOST_KERNEL_ID) && - (pid != DEFAULT_GUEST_KERNEL_ID) && - (symbol_conf.guestmount)) { - sprintf(path, "%s/%d", symbol_conf.guestmount, pid); - if (access(path, R_OK)) { - static struct strlist *seen; - - if (!seen) - seen = strlist__new(true, NULL); - - if (!strlist__has_entry(seen, path)) { - pr_err("Can't access file %s\n", path); - strlist__add(seen, path); - } - machine = NULL; - goto out; - } - root_dir = path; - } - - machine = machines__add(machines, pid, root_dir); -out: - return machine; -} - -void machines__process(struct rb_root *machines, - machine__process_t process, void *data) -{ - struct rb_node *nd; - - for (nd = rb_first(machines); nd; nd = rb_next(nd)) { - struct machine *pos = rb_entry(nd, struct machine, rb_node); - process(pos, data); - } -} - -char *machine__mmap_name(struct machine *machine, char *bf, size_t size) -{ - if (machine__is_host(machine)) - snprintf(bf, size, "[%s]", "kernel.kallsyms"); - else if (machine__is_default_guest(machine)) - snprintf(bf, size, "[%s]", "guest.kernel.kallsyms"); - else { - snprintf(bf, size, "[%s.%d]", "guest.kernel.kallsyms", - machine->pid); - } - - return bf; -} - -void machines__set_id_hdr_size(struct rb_root *machines, u16 id_hdr_size) -{ - struct rb_node *node; - struct machine *machine; - - for (node = rb_first(machines); node; node = rb_next(node)) { - machine = rb_entry(node, struct machine, rb_node); - machine->id_hdr_size = id_hdr_size; - } - - return; -} - static struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, bool create) { @@ -267,19 +84,15 @@ int machine__process_lost_event(struct machine *machine __maybe_unused, static void machine__set_kernel_mmap_len(struct machine *machine, union perf_event *event) { - int i; - - for (i = 0; i < MAP__NR_TYPES; i++) { - machine->vmlinux_maps[i]->start = event->mmap.start; - machine->vmlinux_maps[i]->end = (event->mmap.start + - event->mmap.len); - /* - * Be a bit paranoid here, some perf.data file came with - * a zero sized synthesized MMAP event for the kernel. - */ - if (machine->vmlinux_maps[i]->end == 0) - machine->vmlinux_maps[i]->end = ~0ULL; - } + machine->vmlinux_maps[MAP__FUNCTION]->start = event->mmap.start; + machine->vmlinux_maps[MAP__FUNCTION]->end = (event->mmap.start + + event->mmap.len); + /* + * Be a bit paranoid here, some perf.data file came with + * a zero sized synthesized MMAP event for the kernel. + */ + if (machine->vmlinux_maps[MAP__FUNCTION]->end == 0) + machine->vmlinux_maps[MAP__FUNCTION]->end = ~0ULL; } static int machine__process_kernel_mmap_event(struct machine *machine, diff --git a/trunk/tools/perf/util/machine.h b/trunk/tools/perf/util/machine.h index b7cde7467d55..df152f1768be 100644 --- a/trunk/tools/perf/util/machine.h +++ b/trunk/tools/perf/util/machine.h @@ -2,40 +2,11 @@ #define __PERF_MACHINE_H #include -#include -#include "map.h" -struct branch_stack; -struct perf_evsel; -struct perf_sample; -struct symbol; struct thread; +struct machine; union perf_event; -/* Native host kernel uses -1 as pid index in machine */ -#define HOST_KERNEL_ID (-1) -#define DEFAULT_GUEST_KERNEL_ID (0) - -struct machine { - struct rb_node rb_node; - pid_t pid; - u16 id_hdr_size; - char *root_dir; - struct rb_root threads; - struct list_head dead_threads; - struct thread *last_match; - struct list_head user_dsos; - struct list_head kernel_dsos; - struct map_groups kmaps; - struct map *vmlinux_maps[MAP__NR_TYPES]; -}; - -static inline -struct map *machine__kernel_map(struct machine *machine, enum map_type type) -{ - return machine->vmlinux_maps[type]; -} - struct thread *machine__find_thread(struct machine *machine, pid_t pid); int machine__process_comm_event(struct machine *machine, union perf_event *event); @@ -45,104 +16,4 @@ int machine__process_lost_event(struct machine *machine, union perf_event *event int machine__process_mmap_event(struct machine *machine, union perf_event *event); int machine__process_event(struct machine *machine, union perf_event *event); -typedef void (*machine__process_t)(struct machine *machine, void *data); - -void machines__process(struct rb_root *machines, - machine__process_t process, void *data); - -struct machine *machines__add(struct rb_root *machines, pid_t pid, - const char *root_dir); -struct machine *machines__find_host(struct rb_root *machines); -struct machine *machines__find(struct rb_root *machines, pid_t pid); -struct machine *machines__findnew(struct rb_root *machines, pid_t pid); - -void machines__set_id_hdr_size(struct rb_root *machines, u16 id_hdr_size); -char *machine__mmap_name(struct machine *machine, char *bf, size_t size); - -int machine__init(struct machine *machine, const char *root_dir, pid_t pid); -void machine__exit(struct machine *machine); -void machine__delete(struct machine *machine); - - -struct branch_info *machine__resolve_bstack(struct machine *machine, - struct thread *thread, - struct branch_stack *bs); -int machine__resolve_callchain(struct machine *machine, - struct perf_evsel *evsel, - struct thread *thread, - struct perf_sample *sample, - struct symbol **parent); - -/* - * Default guest kernel is defined by parameter --guestkallsyms - * and --guestmodules - */ -static inline bool machine__is_default_guest(struct machine *machine) -{ - return machine ? machine->pid == DEFAULT_GUEST_KERNEL_ID : false; -} - -static inline bool machine__is_host(struct machine *machine) -{ - return machine ? machine->pid == HOST_KERNEL_ID : false; -} - -struct thread *machine__findnew_thread(struct machine *machine, pid_t pid); -void machine__remove_thread(struct machine *machine, struct thread *th); - -size_t machine__fprintf(struct machine *machine, FILE *fp); - -static inline -struct symbol *machine__find_kernel_symbol(struct machine *machine, - enum map_type type, u64 addr, - struct map **mapp, - symbol_filter_t filter) -{ - return map_groups__find_symbol(&machine->kmaps, type, addr, - mapp, filter); -} - -static inline -struct symbol *machine__find_kernel_function(struct machine *machine, u64 addr, - struct map **mapp, - symbol_filter_t filter) -{ - return machine__find_kernel_symbol(machine, MAP__FUNCTION, addr, - mapp, filter); -} - -static inline -struct symbol *machine__find_kernel_function_by_name(struct machine *machine, - const char *name, - struct map **mapp, - symbol_filter_t filter) -{ - return map_groups__find_function_by_name(&machine->kmaps, name, mapp, - filter); -} - -struct map *machine__new_module(struct machine *machine, u64 start, - const char *filename); - -int machine__load_kallsyms(struct machine *machine, const char *filename, - enum map_type type, symbol_filter_t filter); -int machine__load_vmlinux_path(struct machine *machine, enum map_type type, - symbol_filter_t filter); - -size_t machine__fprintf_dsos_buildid(struct machine *machine, - FILE *fp, bool with_hits); -size_t machines__fprintf_dsos(struct rb_root *machines, FILE *fp); -size_t machines__fprintf_dsos_buildid(struct rb_root *machines, - FILE *fp, bool with_hits); - -void machine__destroy_kernel_maps(struct machine *machine); -int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel); -int machine__create_kernel_maps(struct machine *machine); - -int machines__create_kernel_maps(struct rb_root *machines, pid_t pid); -int machines__create_guest_kernel_maps(struct rb_root *machines); -void machines__destroy_guest_kernel_maps(struct rb_root *machines); - -size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp); - #endif /* __PERF_MACHINE_H */ diff --git a/trunk/tools/perf/util/map.c b/trunk/tools/perf/util/map.c index 0328d45c4f2a..9b40c444039c 100644 --- a/trunk/tools/perf/util/map.c +++ b/trunk/tools/perf/util/map.c @@ -24,7 +24,7 @@ static inline int is_anon_memory(const char *filename) static inline int is_no_dso_memory(const char *filename) { - return !strncmp(filename, "[stack", 6) || + return !strcmp(filename, "[stack]") || !strcmp(filename, "[heap]"); } @@ -590,3 +590,182 @@ struct map *maps__find(struct rb_root *maps, u64 ip) return NULL; } + +int machine__init(struct machine *self, const char *root_dir, pid_t pid) +{ + map_groups__init(&self->kmaps); + RB_CLEAR_NODE(&self->rb_node); + INIT_LIST_HEAD(&self->user_dsos); + INIT_LIST_HEAD(&self->kernel_dsos); + + self->threads = RB_ROOT; + INIT_LIST_HEAD(&self->dead_threads); + self->last_match = NULL; + + self->kmaps.machine = self; + self->pid = pid; + self->root_dir = strdup(root_dir); + if (self->root_dir == NULL) + return -ENOMEM; + + if (pid != HOST_KERNEL_ID) { + struct thread *thread = machine__findnew_thread(self, pid); + char comm[64]; + + if (thread == NULL) + return -ENOMEM; + + snprintf(comm, sizeof(comm), "[guest/%d]", pid); + thread__set_comm(thread, comm); + } + + return 0; +} + +static void dsos__delete(struct list_head *self) +{ + struct dso *pos, *n; + + list_for_each_entry_safe(pos, n, self, node) { + list_del(&pos->node); + dso__delete(pos); + } +} + +void machine__exit(struct machine *self) +{ + map_groups__exit(&self->kmaps); + dsos__delete(&self->user_dsos); + dsos__delete(&self->kernel_dsos); + free(self->root_dir); + self->root_dir = NULL; +} + +void machine__delete(struct machine *self) +{ + machine__exit(self); + free(self); +} + +struct machine *machines__add(struct rb_root *self, pid_t pid, + const char *root_dir) +{ + struct rb_node **p = &self->rb_node; + struct rb_node *parent = NULL; + struct machine *pos, *machine = malloc(sizeof(*machine)); + + if (!machine) + return NULL; + + if (machine__init(machine, root_dir, pid) != 0) { + free(machine); + return NULL; + } + + while (*p != NULL) { + parent = *p; + pos = rb_entry(parent, struct machine, rb_node); + if (pid < pos->pid) + p = &(*p)->rb_left; + else + p = &(*p)->rb_right; + } + + rb_link_node(&machine->rb_node, parent, p); + rb_insert_color(&machine->rb_node, self); + + return machine; +} + +struct machine *machines__find(struct rb_root *self, pid_t pid) +{ + struct rb_node **p = &self->rb_node; + struct rb_node *parent = NULL; + struct machine *machine; + struct machine *default_machine = NULL; + + while (*p != NULL) { + parent = *p; + machine = rb_entry(parent, struct machine, rb_node); + if (pid < machine->pid) + p = &(*p)->rb_left; + else if (pid > machine->pid) + p = &(*p)->rb_right; + else + return machine; + if (!machine->pid) + default_machine = machine; + } + + return default_machine; +} + +struct machine *machines__findnew(struct rb_root *self, pid_t pid) +{ + char path[PATH_MAX]; + const char *root_dir = ""; + struct machine *machine = machines__find(self, pid); + + if (machine && (machine->pid == pid)) + goto out; + + if ((pid != HOST_KERNEL_ID) && + (pid != DEFAULT_GUEST_KERNEL_ID) && + (symbol_conf.guestmount)) { + sprintf(path, "%s/%d", symbol_conf.guestmount, pid); + if (access(path, R_OK)) { + static struct strlist *seen; + + if (!seen) + seen = strlist__new(true, NULL); + + if (!strlist__has_entry(seen, path)) { + pr_err("Can't access file %s\n", path); + strlist__add(seen, path); + } + machine = NULL; + goto out; + } + root_dir = path; + } + + machine = machines__add(self, pid, root_dir); + +out: + return machine; +} + +void machines__process(struct rb_root *self, machine__process_t process, void *data) +{ + struct rb_node *nd; + + for (nd = rb_first(self); nd; nd = rb_next(nd)) { + struct machine *pos = rb_entry(nd, struct machine, rb_node); + process(pos, data); + } +} + +char *machine__mmap_name(struct machine *self, char *bf, size_t size) +{ + if (machine__is_host(self)) + snprintf(bf, size, "[%s]", "kernel.kallsyms"); + else if (machine__is_default_guest(self)) + snprintf(bf, size, "[%s]", "guest.kernel.kallsyms"); + else + snprintf(bf, size, "[%s.%d]", "guest.kernel.kallsyms", self->pid); + + return bf; +} + +void machines__set_id_hdr_size(struct rb_root *machines, u16 id_hdr_size) +{ + struct rb_node *node; + struct machine *machine; + + for (node = rb_first(machines); node; node = rb_next(node)) { + machine = rb_entry(node, struct machine, rb_node); + machine->id_hdr_size = id_hdr_size; + } + + return; +} diff --git a/trunk/tools/perf/util/map.h b/trunk/tools/perf/util/map.h index bcb39e2a6965..d2250fc97e25 100644 --- a/trunk/tools/perf/util/map.h +++ b/trunk/tools/perf/util/map.h @@ -57,6 +57,30 @@ struct map_groups { struct machine *machine; }; +/* Native host kernel uses -1 as pid index in machine */ +#define HOST_KERNEL_ID (-1) +#define DEFAULT_GUEST_KERNEL_ID (0) + +struct machine { + struct rb_node rb_node; + pid_t pid; + u16 id_hdr_size; + char *root_dir; + struct rb_root threads; + struct list_head dead_threads; + struct thread *last_match; + struct list_head user_dsos; + struct list_head kernel_dsos; + struct map_groups kmaps; + struct map *vmlinux_maps[MAP__NR_TYPES]; +}; + +static inline +struct map *machine__kernel_map(struct machine *self, enum map_type type) +{ + return self->vmlinux_maps[type]; +} + static inline struct kmap *map__kmap(struct map *self) { return (struct kmap *)(self + 1); @@ -119,9 +143,44 @@ int map_groups__clone(struct map_groups *mg, size_t map_groups__fprintf(struct map_groups *mg, int verbose, FILE *fp); size_t map_groups__fprintf_maps(struct map_groups *mg, int verbose, FILE *fp); +typedef void (*machine__process_t)(struct machine *self, void *data); + +void machines__process(struct rb_root *self, machine__process_t process, void *data); +struct machine *machines__add(struct rb_root *self, pid_t pid, + const char *root_dir); +struct machine *machines__find_host(struct rb_root *self); +struct machine *machines__find(struct rb_root *self, pid_t pid); +struct machine *machines__findnew(struct rb_root *self, pid_t pid); +void machines__set_id_hdr_size(struct rb_root *self, u16 id_hdr_size); +char *machine__mmap_name(struct machine *self, char *bf, size_t size); +int machine__init(struct machine *self, const char *root_dir, pid_t pid); +void machine__exit(struct machine *self); +void machine__delete(struct machine *self); + +struct perf_evsel; +struct perf_sample; +int machine__resolve_callchain(struct machine *machine, + struct perf_evsel *evsel, + struct thread *thread, + struct perf_sample *sample, + struct symbol **parent); int maps__set_kallsyms_ref_reloc_sym(struct map **maps, const char *symbol_name, u64 addr); +/* + * Default guest kernel is defined by parameter --guestkallsyms + * and --guestmodules + */ +static inline bool machine__is_default_guest(struct machine *self) +{ + return self ? self->pid == DEFAULT_GUEST_KERNEL_ID : false; +} + +static inline bool machine__is_host(struct machine *self) +{ + return self ? self->pid == HOST_KERNEL_ID : false; +} + static inline void map_groups__insert(struct map_groups *mg, struct map *map) { maps__insert(&mg->maps[map->type], map); @@ -150,6 +209,29 @@ struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg, struct map **mapp, symbol_filter_t filter); + +struct thread *machine__findnew_thread(struct machine *machine, pid_t pid); +void machine__remove_thread(struct machine *machine, struct thread *th); + +size_t machine__fprintf(struct machine *machine, FILE *fp); + +static inline +struct symbol *machine__find_kernel_symbol(struct machine *self, + enum map_type type, u64 addr, + struct map **mapp, + symbol_filter_t filter) +{ + return map_groups__find_symbol(&self->kmaps, type, addr, mapp, filter); +} + +static inline +struct symbol *machine__find_kernel_function(struct machine *self, u64 addr, + struct map **mapp, + symbol_filter_t filter) +{ + return machine__find_kernel_symbol(self, MAP__FUNCTION, addr, mapp, filter); +} + static inline struct symbol *map_groups__find_function_by_name(struct map_groups *mg, const char *name, struct map **mapp, @@ -158,11 +240,22 @@ struct symbol *map_groups__find_function_by_name(struct map_groups *mg, return map_groups__find_symbol_by_name(mg, MAP__FUNCTION, name, mapp, filter); } +static inline +struct symbol *machine__find_kernel_function_by_name(struct machine *self, + const char *name, + struct map **mapp, + symbol_filter_t filter) +{ + return map_groups__find_function_by_name(&self->kmaps, name, mapp, + filter); +} + int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, int verbose, FILE *fp); struct map *map_groups__find_by_name(struct map_groups *mg, enum map_type type, const char *name); +struct map *machine__new_module(struct machine *self, u64 start, const char *filename); void map_groups__flush(struct map_groups *mg); diff --git a/trunk/tools/perf/tests/parse-events.c b/trunk/tools/perf/util/parse-events-test.c similarity index 100% rename from trunk/tools/perf/tests/parse-events.c rename to trunk/tools/perf/util/parse-events-test.c diff --git a/trunk/tools/perf/util/parse-events.l b/trunk/tools/perf/util/parse-events.l index 66959fab6634..c87efc12579d 100644 --- a/trunk/tools/perf/util/parse-events.l +++ b/trunk/tools/perf/util/parse-events.l @@ -81,7 +81,6 @@ num_dec [0-9]+ num_hex 0x[a-fA-F0-9]+ num_raw_hex [a-fA-F0-9]+ name [a-zA-Z_*?][a-zA-Z0-9_*?]* -name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?]* modifier_event [ukhpGH]{1,8} modifier_bp [rwx]{1,3} @@ -169,7 +168,6 @@ period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); } branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); } , { return ','; } "/" { BEGIN(INITIAL); return '/'; } -{name_minus} { return str(yyscanner, PE_NAME); } } mem: { BEGIN(mem); return PE_PREFIX_MEM; } diff --git a/trunk/tools/perf/util/session.h b/trunk/tools/perf/util/session.h index 18d1222b05a2..dd6426163ba6 100644 --- a/trunk/tools/perf/util/session.h +++ b/trunk/tools/perf/util/session.h @@ -4,7 +4,6 @@ #include "hist.h" #include "event.h" #include "header.h" -#include "machine.h" #include "symbol.h" #include "thread.h" #include @@ -69,6 +68,10 @@ int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel struct ip_callchain *chain, struct symbol **parent); +struct branch_info *machine__resolve_bstack(struct machine *self, + struct thread *thread, + struct branch_stack *bs); + bool perf_session__has_traces(struct perf_session *self, const char *msg); void mem_bswap_64(void *src, int byte_size); diff --git a/trunk/tools/perf/util/sort.h b/trunk/tools/perf/util/sort.h index b4e8c3ba559d..13761d83a5a0 100644 --- a/trunk/tools/perf/util/sort.h +++ b/trunk/tools/perf/util/sort.h @@ -77,10 +77,6 @@ struct hist_entry_diff { struct hist_entry { struct rb_node rb_node_in; struct rb_node rb_node; - union { - struct list_head node; - struct list_head head; - } pairs; struct he_stat stat; struct map_symbol ms; struct thread *thread; @@ -100,30 +96,15 @@ struct hist_entry { char *srcline; struct symbol *parent; unsigned long position; - struct rb_root sorted_chain; + union { + struct hist_entry *pair; + struct rb_root sorted_chain; + }; struct branch_info *branch_info; struct hists *hists; struct callchain_root callchain[0]; }; -static inline bool hist_entry__has_pairs(struct hist_entry *he) -{ - return !list_empty(&he->pairs.node); -} - -static inline struct hist_entry *hist_entry__next_pair(struct hist_entry *he) -{ - if (hist_entry__has_pairs(he)) - return list_entry(he->pairs.node.next, struct hist_entry, pairs.node); - return NULL; -} - -static inline void hist__entry_add_pair(struct hist_entry *he, - struct hist_entry *pair) -{ - list_add_tail(&he->pairs.head, &pair->pairs.node); -} - enum sort_type { SORT_PID, SORT_COMM, diff --git a/trunk/tools/perf/util/symbol.c b/trunk/tools/perf/util/symbol.c index 295f8d4feedf..624c65e6ab98 100644 --- a/trunk/tools/perf/util/symbol.c +++ b/trunk/tools/perf/util/symbol.c @@ -12,7 +12,6 @@ #include "build-id.h" #include "util.h" #include "debug.h" -#include "machine.h" #include "symbol.h" #include "strlist.h" diff --git a/trunk/tools/perf/util/symbol.h b/trunk/tools/perf/util/symbol.h index 04ccf2962080..863b05bea5ff 100644 --- a/trunk/tools/perf/util/symbol.h +++ b/trunk/tools/perf/util/symbol.h @@ -200,6 +200,16 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map, symbol_filter_t filter); int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map, symbol_filter_t filter); +int machine__load_kallsyms(struct machine *machine, const char *filename, + enum map_type type, symbol_filter_t filter); +int machine__load_vmlinux_path(struct machine *machine, enum map_type type, + symbol_filter_t filter); + +size_t machine__fprintf_dsos_buildid(struct machine *machine, + FILE *fp, bool with_hits); +size_t machines__fprintf_dsos(struct rb_root *machines, FILE *fp); +size_t machines__fprintf_dsos_buildid(struct rb_root *machines, + FILE *fp, bool with_hits); struct symbol *dso__find_symbol(struct dso *dso, enum map_type type, u64 addr); @@ -214,6 +224,14 @@ int kallsyms__parse(const char *filename, void *arg, int filename__read_debuglink(const char *filename, char *debuglink, size_t size); +void machine__destroy_kernel_maps(struct machine *machine); +int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel); +int machine__create_kernel_maps(struct machine *machine); + +int machines__create_kernel_maps(struct rb_root *machines, pid_t pid); +int machines__create_guest_kernel_maps(struct rb_root *machines); +void machines__destroy_guest_kernel_maps(struct rb_root *machines); + int symbol__init(void); void symbol__exit(void); void symbol__elf_init(void); @@ -224,6 +242,8 @@ size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp); size_t symbol__fprintf(struct symbol *sym, FILE *fp); bool symbol_type__is_a(char symbol_type, enum map_type map_type); +size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp); + int dso__test_data(void); int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, struct symsrc *runtime_ss, symbol_filter_t filter,