diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/Build | 1 | ||||
-rw-r--r-- | tools/perf/Documentation/perf-record.txt | 3 | ||||
-rw-r--r-- | tools/perf/Documentation/tips.txt | 15 | ||||
-rw-r--r-- | tools/perf/MANIFEST | 2 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 26 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 10 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 8 | ||||
-rw-r--r-- | tools/perf/config/Makefile | 7 | ||||
-rw-r--r-- | tools/perf/config/Makefile.arch | 18 | ||||
-rw-r--r-- | tools/perf/tests/hists_common.c | 5 | ||||
-rw-r--r-- | tools/perf/tests/hists_cumulate.c | 1 | ||||
-rw-r--r-- | tools/perf/tests/hists_filter.c | 1 | ||||
-rw-r--r-- | tools/perf/tests/hists_link.c | 1 | ||||
-rw-r--r-- | tools/perf/tests/hists_output.c | 1 | ||||
-rw-r--r-- | tools/perf/tests/make | 18 | ||||
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 2 | ||||
-rw-r--r-- | tools/perf/util/event.c | 4 | ||||
-rw-r--r-- | tools/perf/util/strlist.c | 8 | ||||
-rw-r--r-- | tools/perf/util/strlist.h | 9 | ||||
-rw-r--r-- | tools/perf/util/util.c | 11 |
20 files changed, 104 insertions, 47 deletions
diff --git a/tools/perf/Build b/tools/perf/Build index 6b67e6f4179f..a43fae7f439a 100644 --- a/tools/perf/Build +++ b/tools/perf/Build @@ -42,6 +42,7 @@ CFLAGS_perf.o += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))" \ -include $(OUTPUT)PERF-VERSION-FILE CFLAGS_builtin-trace.o += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))" CFLAGS_builtin-report.o += -DTIPDIR="BUILD_STR($(tipdir_SQ))" +CFLAGS_builtin-report.o += -DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)" libperf-y += util/ libperf-y += arch/ diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 3a1a32f5479f..fbceb631387c 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -338,6 +338,9 @@ Options passed to clang when compiling BPF scriptlets. Specify vmlinux path which has debuginfo. (enabled when BPF prologue is on) +--buildid-all:: +Record build-id of all DSOs regardless whether it's actually hit or not. + SEE ALSO -------- linkperf:perf-stat[1], linkperf:perf-list[1] diff --git a/tools/perf/Documentation/tips.txt b/tools/perf/Documentation/tips.txt index a1c10e360db5..e0ce9573b79b 100644 --- a/tools/perf/Documentation/tips.txt +++ b/tools/perf/Documentation/tips.txt @@ -12,3 +12,18 @@ List events using substring match: perf list <keyword> To see list of saved events and attributes: perf evlist -v Use --symfs <dir> if your symbol files are in non-standard locations To see callchains in a more compact form: perf report -g folded +Show individual samples with: perf script +Limit to show entries above 5% only: perf report --percent-limit 5 +Profiling branch (mis)predictions with: perf record -b / perf report +Treat branches as callchains: perf report --branch-history +To count events in every 1000 msec: perf stat -I 1000 +Print event counts in CSV format with: perf stat -x, +If you have debuginfo enabled, try: perf report -s sym,srcline +For memory address profiling, try: perf mem record / perf mem report +For tracepoint events, try: perf report -s trace_fields +To record callchains for each sample: perf record -g +To record every process run by an user: perf record -u <user> +Skip collecing build-id when recording: perf record -B +To change sampling frequency to 100 Hz: perf record -F 100 +See assembly instructions with percentage: perf annotate <symbol> +If you prefer Intel style assembly, try: perf annotate -M intel diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST index ddf922f93aa1..2e1fa2357528 100644 --- a/tools/perf/MANIFEST +++ b/tools/perf/MANIFEST @@ -28,6 +28,7 @@ tools/lib/string.c tools/lib/symbol/kallsyms.c tools/lib/symbol/kallsyms.h tools/lib/find_bit.c +tools/lib/bitmap.c tools/include/asm/atomic.h tools/include/asm/barrier.h tools/include/asm/bug.h @@ -57,6 +58,7 @@ tools/include/linux/rbtree_augmented.h tools/include/linux/string.h tools/include/linux/types.h tools/include/linux/err.h +tools/include/linux/bitmap.h include/asm-generic/bitops/arch_hweight.h include/asm-generic/bitops/const_hweight.h include/asm-generic/bitops/fls64.h diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index dc4e0adf5c5b..319712a4e02b 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -50,6 +50,7 @@ struct record { int realtime_prio; bool no_buildid; bool no_buildid_cache; + bool buildid_all; unsigned long long samples; }; @@ -362,6 +363,13 @@ static int process_buildids(struct record *rec) */ symbol_conf.ignore_vmlinux_buildid = true; + /* + * If --buildid-all is given, it marks all DSO regardless of hits, + * so no need to process samples. + */ + if (rec->buildid_all) + rec->tool.sample = NULL; + return perf_session__process_events(session); } @@ -756,12 +764,8 @@ out_child: if (!rec->no_buildid) { process_buildids(rec); - /* - * We take all buildids when the file contains - * AUX area tracing data because we do not decode the - * trace because it would take too long. - */ - if (rec->opts.full_auxtrace) + + if (rec->buildid_all) dsos__hit_all(rec->session); } perf_session__write_header(rec->session, rec->evlist, fd, true); @@ -1138,6 +1142,8 @@ struct option __record_options[] = { "options passed to clang when compiling BPF scriptlets"), OPT_STRING(0, "vmlinux", &symbol_conf.vmlinux_name, "file", "vmlinux pathname"), + OPT_BOOLEAN(0, "buildid-all", &record.buildid_all, + "Record build-id of all DSOs regardless of hits"), OPT_END() }; @@ -1255,6 +1261,14 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) if (err) goto out_symbol_exit; + /* + * We take all buildids when the file contains + * AUX area tracing data because we do not decode the + * trace because it would take too long. + */ + if (rec->opts.full_auxtrace) + rec->buildid_all = true; + if (record_opts__config(&rec->opts)) { err = -EINVAL; goto out_symbol_exit; diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index d5a42ee12529..2bf537f190a0 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -28,6 +28,7 @@ #include "util/tool.h" #include <subcmd/parse-options.h> +#include <subcmd/exec-cmd.h> #include "util/parse-events.h" #include "util/thread.h" @@ -433,7 +434,14 @@ static int report__browse_hists(struct report *rep) int ret; struct perf_session *session = rep->session; struct perf_evlist *evlist = session->evlist; - const char *help = perf_tip(TIPDIR); + const char *help = perf_tip(system_path(TIPDIR)); + + if (help == NULL) { + /* fallback for people who don't install perf ;-) */ + help = perf_tip(DOCDIR); + if (help == NULL) + help = "Cannot load tips.txt file, please install perf!"; + } switch (use_browser) { case 1: diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 7f568244662b..038e877081b6 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1588,7 +1588,7 @@ static int add_default_attributes(void) return perf_evlist__add_default_attrs(evsel_list, very_very_detailed_attrs); } -static const char * const recort_usage[] = { +static const char * const stat_record_usage[] = { "perf stat record [<options>]", NULL, }; @@ -1611,7 +1611,7 @@ static int __cmd_record(int argc, const char **argv) struct perf_session *session; struct perf_data_file *file = &perf_stat.file; - argc = parse_options(argc, argv, stat_options, record_usage, + argc = parse_options(argc, argv, stat_options, stat_record_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (output_name) @@ -1745,7 +1745,7 @@ int process_cpu_map_event(struct perf_tool *tool __maybe_unused, return set_maps(st); } -static const char * const report_usage[] = { +static const char * const stat_report_usage[] = { "perf stat report [<options>]", NULL, }; @@ -1779,7 +1779,7 @@ static int __cmd_report(int argc, const char **argv) struct stat st; int ret; - argc = parse_options(argc, argv, options, report_usage, 0); + argc = parse_options(argc, argv, options, stat_report_usage, 0); if (!input_name || !strlen(input_name)) { if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode)) diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 254d06e39bea..e5959c136a19 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -17,7 +17,7 @@ detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected) CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) -include $(src-perf)/config/Makefile.arch +include $(srctree)/tools/scripts/Makefile.arch $(call detected_var,ARCH) @@ -493,7 +493,7 @@ else PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null) PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) - PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) + PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) @@ -692,6 +692,7 @@ template_dir = share/perf-core/templates STRACE_GROUPS_DIR = share/perf-core/strace/groups htmldir = share/doc/perf-doc tipdir = share/doc/perf-tip +srcdir = $(srctree)/tools/perf ifeq ($(prefix),/usr) sysconfdir = /etc ETC_PERFCONFIG = $(sysconfdir)/perfconfig @@ -722,6 +723,7 @@ tipdir_SQ = $(subst ','\'',$(tipdir)) prefix_SQ = $(subst ','\'',$(prefix)) sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) libdir_SQ = $(subst ','\'',$(libdir)) +srcdir_SQ = $(subst ','\'',$(srcdir)) ifneq ($(filter /%,$(firstword $(perfexecdir))),) perfexec_instdir = $(perfexecdir) @@ -776,6 +778,7 @@ $(call detected_var,STRACE_GROUPS_DIR_SQ) $(call detected_var,prefix_SQ) $(call detected_var,perfexecdir_SQ) $(call detected_var,tipdir_SQ) +$(call detected_var,srcdir_SQ) $(call detected_var,LIBDIR) $(call detected_var,GTK_CFLAGS) $(call detected_var,PERL_EMBED_CCOPTS) diff --git a/tools/perf/config/Makefile.arch b/tools/perf/config/Makefile.arch deleted file mode 100644 index e11fbd6fae78..000000000000 --- a/tools/perf/config/Makefile.arch +++ /dev/null @@ -1,18 +0,0 @@ -ifndef ARCH -ARCH := $(shell uname -m 2>/dev/null || echo not) -endif - -ARCH := $(shell echo $(ARCH) | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ - -e s/sun4u/sparc/ -e s/sparc64/sparc/ \ - -e /arm64/!s/arm.*/arm/ -e s/sa110/arm/ \ - -e s/s390x/s390/ -e s/parisc64/parisc/ \ - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ - -e s/tile.*/tile/ ) - -LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1) -ifeq ($(LP64), 1) - IS_64_BIT := 1 -else - IS_64_BIT := 0 -endif diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c index bcfd081ee1d2..071a8b5f5232 100644 --- a/tools/perf/tests/hists_common.c +++ b/tools/perf/tests/hists_common.c @@ -87,11 +87,6 @@ struct machine *setup_fake_machine(struct machines *machines) return NULL; } - if (machine__create_kernel_maps(machine)) { - pr_debug("Cannot create kernel maps\n"); - return NULL; - } - for (i = 0; i < ARRAY_SIZE(fake_threads); i++) { struct thread *thread; diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c index e36089212061..5e6a86e50fb9 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -706,6 +706,7 @@ int test__hists_cumulate(int subtest __maybe_unused) err = parse_events(evlist, "cpu-clock", NULL); if (err) goto out; + err = TEST_FAIL; machines__init(&machines); diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c index 2a784befd9ce..351a42463444 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c @@ -120,6 +120,7 @@ int test__hists_filter(int subtest __maybe_unused) err = parse_events(evlist, "task-clock", NULL); if (err) goto out; + err = TEST_FAIL; /* default sort order (comm,dso,sym) will be used */ if (setup_sorting(NULL) < 0) diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index c764d69ac6ef..64b257d8d557 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c @@ -293,6 +293,7 @@ int test__hists_link(int subtest __maybe_unused) if (err) goto out; + err = TEST_FAIL; /* default sort order (comm,dso,sym) will be used */ if (setup_sorting(NULL) < 0) goto out; diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c index ebe6cd485b5d..b231265148d8 100644 --- a/tools/perf/tests/hists_output.c +++ b/tools/perf/tests/hists_output.c @@ -597,6 +597,7 @@ int test__hists_output(int subtest __maybe_unused) err = parse_events(evlist, "cpu-clock", NULL); if (err) goto out; + err = TEST_FAIL; machines__init(&machines); diff --git a/tools/perf/tests/make b/tools/perf/tests/make index c1fbb8e884c0..df38decc48c3 100644 --- a/tools/perf/tests/make +++ b/tools/perf/tests/make @@ -1,3 +1,5 @@ +include ../scripts/Makefile.include + ifndef MK ifeq ($(MAKECMDGOALS),) # no target specified, trigger the whole suite @@ -12,7 +14,19 @@ endif else PERF := . -include config/Makefile.arch +# As per kernel Makefile, avoid funny character set dependencies +unexport LC_ALL +LC_COLLATE=C +LC_NUMERIC=C +export LC_COLLATE LC_NUMERIC + +ifeq ($(srctree),) +srctree := $(patsubst %/,%,$(dir $(shell pwd))) +srctree := $(patsubst %/,%,$(dir $(srctree))) +#$(info Determined 'srctree' to be $(srctree)) +endif + +include $(srctree)/tools/scripts/Makefile.arch # FIXME looks like x86 is the only arch running tests ;-) # we need some IS_(32/64) flag to make this generic @@ -280,5 +294,5 @@ all: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools out: $(run_O) @echo OK -.PHONY: all $(run) $(run_O) tarpkg clean +.PHONY: all $(run) $(run_O) tarpkg clean make_kernelsrc make_kernelsrc_tools endif # ifndef MK diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 901d481e6cea..08c09ad755d2 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -480,7 +480,7 @@ static int hist_browser__run(struct hist_browser *browser, const char *help) hists__browser_title(browser->hists, hbt, title, sizeof(title)); - if (ui_browser__show(&browser->b, title, help) < 0) + if (ui_browser__show(&browser->b, title, "%s", help) < 0) return -1; while (1) { diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index cd61bb1f3917..85155e91b61b 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -503,7 +503,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool, if (comm_event == NULL) goto out; - mmap_event = malloc(sizeof(mmap_event->mmap) + machine->id_hdr_size); + mmap_event = malloc(sizeof(mmap_event->mmap2) + machine->id_hdr_size); if (mmap_event == NULL) goto out_free_comm; @@ -577,7 +577,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool, if (comm_event == NULL) goto out; - mmap_event = malloc(sizeof(mmap_event->mmap) + machine->id_hdr_size); + mmap_event = malloc(sizeof(mmap_event->mmap2) + machine->id_hdr_size); if (mmap_event == NULL) goto out_free_comm; diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c index bdf98f6f27bb..0d3dfcb919b4 100644 --- a/tools/perf/util/strlist.c +++ b/tools/perf/util/strlist.c @@ -126,6 +126,11 @@ static int strlist__parse_list_entry(struct strlist *slist, const char *s, err = strlist__load(slist, subst); goto out; } + + if (slist->file_only) { + err = -ENOENT; + goto out; + } } err = strlist__add(slist, s); @@ -157,11 +162,13 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf if (slist != NULL) { bool dupstr = true; + bool file_only = false; const char *dirname = NULL; if (config) { dupstr = !config->dont_dupstr; dirname = config->dirname; + file_only = config->file_only; } rblist__init(&slist->rblist); @@ -170,6 +177,7 @@ struct strlist *strlist__new(const char *list, const struct strlist_config *conf slist->rblist.node_delete = strlist__node_delete; slist->dupstr = dupstr; + slist->file_only = file_only; if (list && strlist__parse_list(slist, list, dirname) != 0) goto out_error; diff --git a/tools/perf/util/strlist.h b/tools/perf/util/strlist.h index 297565aa7535..ca990029e243 100644 --- a/tools/perf/util/strlist.h +++ b/tools/perf/util/strlist.h @@ -13,11 +13,18 @@ struct str_node { struct strlist { struct rblist rblist; - bool dupstr; + bool dupstr; + bool file_only; }; +/* + * @file_only: When dirname is present, only consider entries as filenames, + * that should not be added to the list if dirname/entry is not + * found + */ struct strlist_config { bool dont_dupstr; + bool file_only; const char *dirname; }; diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 88b8f8d21f58..ead9509835d2 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -17,7 +17,6 @@ #include <unistd.h> #include "callchain.h" #include "strlist.h" -#include <subcmd/exec-cmd.h> struct callchain_param callchain_param = { .mode = CHAIN_GRAPH_ABS, @@ -672,14 +671,16 @@ const char *perf_tip(const char *dirpath) struct str_node *node; char *tip = NULL; struct strlist_config conf = { - .dirname = system_path(dirpath) , + .dirname = dirpath, + .file_only = true, }; tips = strlist__new("tips.txt", &conf); - if (tips == NULL || strlist__nr_entries(tips) == 1) { - tip = (char *)"Cannot find tips.txt file"; + if (tips == NULL) + return errno == ENOENT ? NULL : "Tip: get more memory! ;-p"; + + if (strlist__nr_entries(tips) == 0) goto out; - } node = strlist__entry(tips, random() % strlist__nr_entries(tips)); if (asprintf(&tip, "Tip: %s", node->s) < 0) |