Skip to content

Commit

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

Pull perf/core improvements and fixes from Jiri Olsa:

User visible changes:

  * Add --percentage option to control absolute/relative percentage output (Namhyung Kim)

Plumbing changes:

  * Add --list-cmds to 'kmem', 'mem', 'lock' and 'sched', for use by completion scripts (Ramkumar Ramachandra)

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Apr 17, 2014
2 parents fbdd17e + a83edb2 commit b3d5fc3
Show file tree
Hide file tree
Showing 18 changed files with 230 additions and 76 deletions.
21 changes: 18 additions & 3 deletions tools/perf/Documentation/perf-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@ OPTIONS
-d::
--dsos=::
Only consider symbols in these dsos. CSV that understands
file://filename entries.
file://filename entries. This option will affect the percentage
of the Baseline/Delta column. See --percentage for more info.

-C::
--comms=::
Only consider symbols in these comms. CSV that understands
file://filename entries.
file://filename entries. This option will affect the percentage
of the Baseline/Delta column. See --percentage for more info.

-S::
--symbols=::
Only consider these symbols. CSV that understands
file://filename entries.
file://filename entries. This option will affect the percentage
of the Baseline/Delta column. See --percentage for more info.

-s::
--sort=::
Expand Down Expand Up @@ -89,6 +92,14 @@ OPTIONS
--order::
Specify compute sorting column number.

--percentage::
Determine how to display the overhead percentage of filtered entries.
Filters can be applied by --comms, --dsos and/or --symbols options.

"relative" means it's relative to filtered entries only so that the
sum of shown entries will be always 100%. "absolute" means it retains
the original value before and after the filter is applied.

COMPARISON
----------
The comparison is governed by the baseline file. The baseline perf.data
Expand Down Expand Up @@ -157,6 +168,10 @@ with:
- period_percent being the % of the hist entry period value within
single data file

- with filtering by -C, -d and/or -S, period_percent might be changed
relative to how entries are filtered. Use --percentage=absolute to
prevent such fluctuation.

ratio
~~~~~
If specified the 'Ratio' column is displayed with value 'r' computed as:
Expand Down
24 changes: 18 additions & 6 deletions tools/perf/Documentation/perf-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ OPTIONS
--verbose::
Be more verbose. (show symbol address, etc)

-d::
--dsos=::
Only consider symbols in these dsos. CSV that understands
file://filename entries.
-n::
--show-nr-samples::
Show the number of samples for each symbol
Expand All @@ -42,11 +38,18 @@ OPTIONS
-c::
--comms=::
Only consider symbols in these comms. CSV that understands
file://filename entries.
file://filename entries. This option will affect the percentage of
the overhead column. See --percentage for more info.
-d::
--dsos=::
Only consider symbols in these dsos. CSV that understands
file://filename entries. This option will affect the percentage of
the overhead column. See --percentage for more info.
-S::
--symbols=::
Only consider these symbols. CSV that understands
file://filename entries.
file://filename entries. This option will affect the percentage of
the overhead column. See --percentage for more info.

--symbol-filter=::
Only show symbols that match (partially) with this filter.
Expand Down Expand Up @@ -237,6 +240,15 @@ OPTIONS
Do not show entries which have an overhead under that percent.
(Default: 0).

--percentage::
Determine how to display the overhead percentage of filtered entries.
Filters can be applied by --comms, --dsos and/or --symbols options and
Zoom operations on the TUI (thread, dso, etc).

"relative" means it's relative to filtered entries only so that the
sum of shown entries will be always 100%. "absolute" means it retains
the original value before and after the filter is applied.

--header::
Show header information in the perf.data file. This includes
various information like hostname, OS and perf version, cpu/mem
Expand Down
18 changes: 15 additions & 3 deletions tools/perf/Documentation/perf-top.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,16 @@ Default is to monitor all CPUS.
Show a column with the sum of periods.

--dsos::
Only consider symbols in these dsos.
Only consider symbols in these dsos. This option will affect the
percentage of the overhead column. See --percentage for more info.

--comms::
Only consider symbols in these comms.
Only consider symbols in these comms. This option will affect the
percentage of the overhead column. See --percentage for more info.

--symbols::
Only consider these symbols.
Only consider these symbols. This option will affect the
percentage of the overhead column. See --percentage for more info.

-M::
--disassembler-style=:: Set disassembler style for objdump.
Expand Down Expand Up @@ -165,6 +168,15 @@ Default is to monitor all CPUS.
Do not show entries which have an overhead under that percent.
(Default: 0).

--percentage::
Determine how to display the overhead percentage of filtered entries.
Filters can be applied by --comms, --dsos and/or --symbols options and
Zoom operations on the TUI (thread, dso, etc).

"relative" means it's relative to filtered entries only so that the
sum of shown entries will be always 100%. "absolute" means it retains
the original value before and after the filter is applied.

INTERACTIVE PROMPTING KEYS
--------------------------

Expand Down
32 changes: 24 additions & 8 deletions tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ static int setup_compute(const struct option *opt, const char *str,

static double period_percent(struct hist_entry *he, u64 period)
{
u64 total = he->hists->stats.total_period;
u64 total = hists__total_period(he->hists);

return (period * 100.0) / total;
}

Expand Down Expand Up @@ -259,11 +260,18 @@ static s64 compute_wdiff(struct hist_entry *he, struct hist_entry *pair)
static int formula_delta(struct hist_entry *he, struct hist_entry *pair,
char *buf, size_t size)
{
u64 he_total = he->hists->stats.total_period;
u64 pair_total = pair->hists->stats.total_period;

if (symbol_conf.filter_relative) {
he_total = he->hists->stats.total_non_filtered_period;
pair_total = pair->hists->stats.total_non_filtered_period;
}
return scnprintf(buf, size,
"(%" PRIu64 " * 100 / %" PRIu64 ") - "
"(%" PRIu64 " * 100 / %" PRIu64 ")",
pair->stat.period, pair->hists->stats.total_period,
he->stat.period, he->hists->stats.total_period);
pair->stat.period, pair_total,
he->stat.period, he_total);
}

static int formula_ratio(struct hist_entry *he, struct hist_entry *pair,
Expand Down Expand Up @@ -327,15 +335,16 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
return -1;
}

if (al.filtered)
return 0;

if (hists__add_entry(&evsel->hists, &al, sample->period,
sample->weight, sample->transaction)) {
pr_warning("problem incrementing symbol period, skipping event\n");
return -1;
}

if (al.filtered == 0) {
evsel->hists.stats.total_non_filtered_period += sample->period;
evsel->hists.nr_non_filtered_entries++;
}
evsel->hists.stats.total_period += sample->period;
return 0;
}
Expand Down Expand Up @@ -565,7 +574,9 @@ static void hists__compute_resort(struct hists *hists)
next = rb_first(root);

hists->nr_entries = 0;
hists->nr_non_filtered_entries = 0;
hists->stats.total_period = 0;
hists->stats.total_non_filtered_period = 0;
hists__reset_col_len(hists);

while (next != NULL) {
Expand Down Expand Up @@ -732,13 +743,16 @@ static const struct option options[] = {
OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
"Look for files with symbols relative to this directory"),
OPT_UINTEGER('o', "order", &sort_compute, "Specify compute sorting."),
OPT_CALLBACK(0, "percentage", NULL, "relative|absolute",
"How to display percentage of filtered entries", parse_filter_percentage),
OPT_END()
};

static double baseline_percent(struct hist_entry *he)
{
struct hists *hists = he->hists;
return 100.0 * he->stat.period / hists->stats.total_period;
u64 total = hists__total_period(he->hists);

return 100.0 * he->stat.period / total;
}

static int hpp__color_baseline(struct perf_hpp_fmt *fmt,
Expand Down Expand Up @@ -1120,6 +1134,8 @@ static int data_init(int argc, const char **argv)

int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
{
perf_config(perf_default_config, NULL);

sort_order = diff__default_sort_order;
argc = parse_options(argc, argv, options, diff_usage, 0);

Expand Down
8 changes: 5 additions & 3 deletions tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,11 +756,13 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
OPT_END()
};
const char * const kmem_usage[] = {
"perf kmem [<options>] {record|stat}",
const char *const kmem_subcommands[] = { "record", "stat", NULL };
const char *kmem_usage[] = {
NULL,
NULL
};
argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
argc = parse_options_subcommand(argc, argv, kmem_options,
kmem_subcommands, kmem_usage, 0);

if (!argc)
usage_with_options(kmem_usage, kmem_options);
Expand Down
10 changes: 6 additions & 4 deletions tools/perf/builtin-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,8 +961,10 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
"perf lock info [<options>]",
NULL
};
const char * const lock_usage[] = {
"perf lock [<options>] {record|report|script|info}",
const char *const lock_subcommands[] = { "record", "report", "script",
"info", NULL };
const char *lock_usage[] = {
NULL,
NULL
};
const char * const report_usage[] = {
Expand All @@ -976,8 +978,8 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
for (i = 0; i < LOCKHASH_SIZE; i++)
INIT_LIST_HEAD(lockhash_table + i);

argc = parse_options(argc, argv, lock_options, lock_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
argc = parse_options_subcommand(argc, argv, lock_options, lock_subcommands,
lock_usage, PARSE_OPT_STOP_AT_NON_OPTION);
if (!argc)
usage_with_options(lock_usage, lock_options);

Expand Down
15 changes: 8 additions & 7 deletions tools/perf/builtin-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ struct perf_mem {
DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
};

static const char * const mem_usage[] = {
"perf mem [<options>] {record <command> |report}",
NULL
};

static int __cmd_record(int argc, const char **argv)
{
int rec_argc, i = 0, j;
Expand Down Expand Up @@ -220,9 +215,15 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
" between columns '.' is reserved."),
OPT_END()
};
const char *const mem_subcommands[] = { "record", "report", NULL };
const char *mem_usage[] = {
NULL,
NULL
};


argc = parse_options(argc, argv, mem_options, mem_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
mem_usage, PARSE_OPT_STOP_AT_NON_OPTION);

if (!argc || !(strncmp(argv[0], "rec", 3) || mem_operation))
usage_with_options(mem_usage, mem_options);
Expand Down
22 changes: 20 additions & 2 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ static int report__add_mem_hist_entry(struct report *rep, struct addr_location *

evsel->hists.stats.total_period += cost;
hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
if (!he->filtered)
evsel->hists.stats.nr_non_filtered_samples++;
err = hist_entry__append_callchain(he, sample);
out:
return err;
Expand Down Expand Up @@ -176,6 +178,8 @@ static int report__add_branch_hist_entry(struct report *rep, struct addr_locatio

evsel->hists.stats.total_period += 1;
hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
if (!he->filtered)
evsel->hists.stats.nr_non_filtered_samples++;
} else
goto out;
}
Expand Down Expand Up @@ -209,6 +213,8 @@ static int report__add_hist_entry(struct report *rep, struct perf_evsel *evsel,
err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);

evsel->hists.stats.total_period += sample->period;
if (!he->filtered)
evsel->hists.stats.nr_non_filtered_samples++;
hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
out:
return err;
Expand Down Expand Up @@ -337,15 +343,25 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
char buf[512];
size_t size = sizeof(buf);

if (symbol_conf.filter_relative) {
nr_samples = hists->stats.nr_non_filtered_samples;
nr_events = hists->stats.total_non_filtered_period;
}

if (perf_evsel__is_group_event(evsel)) {
struct perf_evsel *pos;

perf_evsel__group_desc(evsel, buf, size);
evname = buf;

for_each_group_member(pos, evsel) {
nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE];
nr_events += pos->hists.stats.total_period;
if (symbol_conf.filter_relative) {
nr_samples += pos->hists.stats.nr_non_filtered_samples;
nr_events += pos->hists.stats.total_non_filtered_period;
} else {
nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE];
nr_events += pos->hists.stats.total_period;
}
}
}

Expand Down Expand Up @@ -823,6 +839,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN(0, "mem-mode", &report.mem_mode, "mem access profile"),
OPT_CALLBACK(0, "percent-limit", &report, "percent",
"Don't show entries under that percent", parse_percent_limit),
OPT_CALLBACK(0, "percentage", NULL, "relative|absolute",
"how to display percentage of filtered entries", parse_filter_percentage),
OPT_END()
};
struct perf_data_file file = {
Expand Down
10 changes: 6 additions & 4 deletions tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1713,8 +1713,10 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
"perf sched replay [<options>]",
NULL
};
const char * const sched_usage[] = {
"perf sched [<options>] {record|latency|map|replay|script}",
const char *const sched_subcommands[] = { "record", "latency", "map",
"replay", "script", NULL };
const char *sched_usage[] = {
NULL,
NULL
};
struct trace_sched_handler lat_ops = {
Expand All @@ -1736,8 +1738,8 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
for (i = 0; i < ARRAY_SIZE(sched.curr_pid); i++)
sched.curr_pid[i] = -1;

argc = parse_options(argc, argv, sched_options, sched_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
argc = parse_options_subcommand(argc, argv, sched_options, sched_subcommands,
sched_usage, PARSE_OPT_STOP_AT_NON_OPTION);
if (!argc)
usage_with_options(sched_usage, sched_options);

Expand Down
Loading

0 comments on commit b3d5fc3

Please sign in to comment.