Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo-4.14-20170821' of git://git.kernel.org…
Browse files Browse the repository at this point in the history
…/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

- Support --show-nr-samples in annotate's --stdio and --tui, using
  the existing 't' toggle to circulate 'percent', 'total-period' and
  'nr-samples' as the first column (Taeung Song)

- Support FCMask and PortMask in JSON vendor events (Andi Kleen)

- Fix off by one string allocation problem in 'perf trace' (Arnaldo Carvalho de Melo)

- Use just one parse events state struct in yyparse(), fixing one
  reported segfault when a routine received a different data struct,
  smaller than the one it expected to use (Arnaldo Carvalho de Melo)

- Remove unused cpu_relax() macros, they stopped being used when
  tools/perf lived in Documentation/ (Arnaldo Carvalho de Melo)

- Fix double file test in libbpf's Makefile (Daniel Díaz):

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Aug 22, 2017
2 parents 9881223 + 3a555c7 commit ba63f76
Show file tree
Hide file tree
Showing 13 changed files with 159 additions and 158 deletions.
4 changes: 2 additions & 2 deletions tools/lib/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ all: fixdep $(VERSION_FILES) all_cmd
all_cmd: $(CMD_TARGETS)

$(BPF_IN): force elfdep bpfdep
@(test -f ../../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \
@(test -f ../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \
(diff -B ../../include/uapi/linux/bpf.h ../../../include/uapi/linux/bpf.h >/dev/null) || \
echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'" >&2 )) || true
@(test -f ../../../include/uapi/linux/bpf_common.h -a -f ../../../include/uapi/linux/bpf_common.h && ( \
@(test -f ../../include/uapi/linux/bpf_common.h -a -f ../../../include/uapi/linux/bpf_common.h && ( \
(diff -B ../../include/uapi/linux/bpf_common.h ../../../include/uapi/linux/bpf_common.h >/dev/null) || \
echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf_common.h' differs from latest version at 'include/uapi/linux/bpf_common.h'" >&2 )) || true
$(Q)$(MAKE) $(build)=libbpf
Expand Down
6 changes: 6 additions & 0 deletions tools/perf/Documentation/perf-annotate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ OPTIONS
--quiet::
Do not show any message. (Suppress -v)

-n::
--show-nr-samples::
Show the number of samples for each symbol

-D::
--dump-raw-trace::
Dump raw trace in ASCII.
Expand Down Expand Up @@ -88,6 +92,8 @@ OPTIONS
--asm-raw::
Show raw instruction encoding of assembly instructions.

--show-total-period:: Show a column with the sum of periods.

--source::
Interleave source code with assembly code. Enabled by default,
disable with --no-source.
Expand Down
16 changes: 14 additions & 2 deletions tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ int cmd_annotate(int argc, const char **argv)
struct perf_data_file file = {
.mode = PERF_DATA_MODE_READ,
};
const struct option options[] = {
struct option options[] = {
OPT_STRING('i', "input", &input_name, "file",
"input file name"),
OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
Expand Down Expand Up @@ -445,13 +445,20 @@ int cmd_annotate(int argc, const char **argv)
"Show event group information together"),
OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
"Show a column with the sum of periods"),
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
"Show a column with the number of samples"),
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
"'always' (default), 'never' or 'auto' only applicable to --stdio mode",
stdio__config_color, "always"),
OPT_END()
};
int ret = hists__init();
int ret;

set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE);
set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE);


ret = hists__init();
if (ret < 0)
return ret;

Expand All @@ -467,6 +474,11 @@ int cmd_annotate(int argc, const char **argv)
annotate.sym_hist_filter = argv[0];
}

if (symbol_conf.show_nr_samples && annotate.use_gtk) {
pr_err("--show-nr-samples is not available in --gtk mode at this time\n");
return ret;
}

if (quiet)
perf_quiet_option();

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2806,7 +2806,7 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
struct trace *trace = (struct trace *)opt->value;
const char *s = str;
char *sep = NULL, *lists[2] = { NULL, NULL, };
int len = strlen(str), err = -1, list;
int len = strlen(str) + 1, err = -1, list;
char *strace_groups_dir = system_path(STRACE_GROUPS_DIR);
char group_name[PATH_MAX];

Expand Down
28 changes: 2 additions & 26 deletions tools/perf/perf-sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
#include <linux/perf_event.h>
#include <asm/barrier.h>

#if defined(__i386__)
#define cpu_relax() asm volatile("rep; nop" ::: "memory");
#define CPUINFO_PROC {"model name"}
#endif

#if defined(__x86_64__)
#define cpu_relax() asm volatile("rep; nop" ::: "memory");
#define CPUINFO_PROC {"model name"}
#endif

#ifdef __powerpc__
#define CPUINFO_PROC {"cpu"}
#endif
Expand All @@ -43,19 +33,10 @@
#define CPUINFO_PROC {"cpu model"}
#endif

#ifdef __ia64__
#define cpu_relax() asm volatile ("hint @pause" ::: "memory")
#define CPUINFO_PROC {"model name"}
#endif

#ifdef __arm__
#define CPUINFO_PROC {"model name", "Processor"}
#endif

#ifdef __aarch64__
#define cpu_relax() asm volatile("yield" ::: "memory")
#endif

#ifdef __mips__
#define CPUINFO_PROC {"cpu model"}
#endif
Expand All @@ -72,13 +53,8 @@
#define CPUINFO_PROC {"core ID"}
#endif

#ifdef __tile__
#define cpu_relax() asm volatile ("mfspr zero, PASS" ::: "memory")
#define CPUINFO_PROC {"model name"}
#endif

#ifndef cpu_relax
#define cpu_relax() barrier()
#ifndef CPUINFO_PROC
#define CPUINFO_PROC { "model name", }
#endif

static inline int
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/pmu-events/jevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ static struct field {
{ "AnyThread", "any=" },
{ "EdgeDetect", "edge=" },
{ "SampleAfterValue", "period=" },
{ "FCMask", "fc_mask=" },
{ "PortMask", "ch_mask=" },
{ NULL, NULL }
};

Expand Down
16 changes: 8 additions & 8 deletions tools/perf/tests/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,16 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
struct perf_evlist *evlist;
int i, ret = TEST_FAIL, err = 0, count = 0;

struct parse_events_evlist parse_evlist;
struct parse_events_state parse_state;
struct parse_events_error parse_error;

bzero(&parse_error, sizeof(parse_error));
bzero(&parse_evlist, sizeof(parse_evlist));
parse_evlist.error = &parse_error;
INIT_LIST_HEAD(&parse_evlist.list);
bzero(&parse_state, sizeof(parse_state));
parse_state.error = &parse_error;
INIT_LIST_HEAD(&parse_state.list);

err = parse_events_load_bpf_obj(&parse_evlist, &parse_evlist.list, obj, NULL);
if (err || list_empty(&parse_evlist.list)) {
err = parse_events_load_bpf_obj(&parse_state, &parse_state.list, obj, NULL);
if (err || list_empty(&parse_state.list)) {
pr_debug("Failed to add events selected by BPF\n");
return TEST_FAIL;
}
Expand All @@ -155,8 +155,8 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
goto out_delete_evlist;
}

perf_evlist__splice_list_tail(evlist, &parse_evlist.list);
evlist->nr_groups = parse_evlist.nr_groups;
perf_evlist__splice_list_tail(evlist, &parse_state.list);
evlist->nr_groups = parse_state.nr_groups;

perf_evlist__config(evlist, &opts, NULL);

Expand Down
25 changes: 19 additions & 6 deletions tools/perf/ui/browsers/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static struct annotate_browser_opt {
jump_arrows,
show_linenr,
show_nr_jumps,
show_nr_samples,
show_total_period;
} annotate_browser__opts = {
.use_offset = true,
Expand Down Expand Up @@ -155,6 +156,9 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%11" PRIu64 " ",
bdl->samples[i].he.period);
} else if (annotate_browser__opts.show_nr_samples) {
ui_browser__printf(browser, "%6" PRIu64 " ",
bdl->samples[i].he.nr_samples);
} else {
ui_browser__printf(browser, "%6.2f ",
bdl->samples[i].percent);
Expand All @@ -167,7 +171,8 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
ui_browser__write_nstring(browser, " ", pcnt_width);
else {
ui_browser__printf(browser, "%*s", pcnt_width,
annotate_browser__opts.show_total_period ? "Period" : "Percent");
annotate_browser__opts.show_total_period ? "Period" :
annotate_browser__opts.show_nr_samples ? "Samples" : "Percent");
}
}
if (ab->have_cycles) {
Expand Down Expand Up @@ -830,7 +835,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
"n Search next string\n"
"o Toggle disassembler output/simplified view\n"
"s Toggle source code view\n"
"t Toggle total period view\n"
"t Circulate percent, total period, samples view\n"
"/ Search string\n"
"k Toggle line numbers\n"
"r Run available scripts\n"
Expand Down Expand Up @@ -907,8 +912,13 @@ static int annotate_browser__run(struct annotate_browser *browser,
}
continue;
case 't':
annotate_browser__opts.show_total_period =
!annotate_browser__opts.show_total_period;
if (annotate_browser__opts.show_total_period) {
annotate_browser__opts.show_total_period = false;
annotate_browser__opts.show_nr_samples = true;
} else if (annotate_browser__opts.show_nr_samples)
annotate_browser__opts.show_nr_samples = false;
else
annotate_browser__opts.show_total_period = true;
annotate_browser__update_addr_width(browser);
continue;
case K_LEFT:
Expand All @@ -931,9 +941,11 @@ static int annotate_browser__run(struct annotate_browser *browser,
int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
struct hist_browser_timer *hbt)
{
/* Set default value for show_total_period. */
/* Set default value for show_total_period and show_nr_samples */
annotate_browser__opts.show_total_period =
symbol_conf.show_total_period;
symbol_conf.show_total_period;
annotate_browser__opts.show_nr_samples =
symbol_conf.show_nr_samples;

return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
}
Expand Down Expand Up @@ -1184,6 +1196,7 @@ static struct annotate_config {
ANNOTATE_CFG(jump_arrows),
ANNOTATE_CFG(show_linenr),
ANNOTATE_CFG(show_nr_jumps),
ANNOTATE_CFG(show_nr_samples),
ANNOTATE_CFG(show_total_period),
ANNOTATE_CFG(use_offset),
};
Expand Down
6 changes: 5 additions & 1 deletion tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
if (symbol_conf.show_total_period)
color_fprintf(stdout, color, " %11" PRIu64,
sample.period);
else if (symbol_conf.show_nr_samples)
color_fprintf(stdout, color, " %7" PRIu64,
sample.nr_samples);
else
color_fprintf(stdout, color, " %7.2f", percent);
}
Expand Down Expand Up @@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
width *= evsel->nr_members;

graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",
width, width, symbol_conf.show_total_period ? "Event count" : "Percent",
width, width, symbol_conf.show_total_period ? "Period" :
symbol_conf.show_nr_samples ? "Samples" : "Percent",
d_filename, evsel_name, h->nr_samples);

printf("%-*.*s----\n",
Expand Down
3 changes: 0 additions & 3 deletions tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,6 @@ static int __write_cpudesc(struct feat_fd *ff, const char *cpuinfo_proc)
static int write_cpudesc(struct feat_fd *ff,
struct perf_evlist *evlist __maybe_unused)
{
#ifndef CPUINFO_PROC
#define CPUINFO_PROC {"model name", }
#endif
const char *cpuinfo_procs[] = CPUINFO_PROC;
unsigned int i;

Expand Down
Loading

0 comments on commit ba63f76

Please sign in to comment.