2014-01-14 04:43:23

by Namhyung Kim

[permalink] [raw]
Subject: [PATCHSET 0/5] perf tools: Update on filtered entries' percentage output

Hello,

I added --percentage option to perf report to control display of
percentage of filtered entries.

usage: perf report [<options>]

--percentage <relative|absolute>
how to display percentage of filtered entries

"relative" means it's relative to filtered entries only so that the
sum of shown entries will be always 100%. "absolute" means it retains
original value before and after the filter applied. In patch 5, I
made the "absolute" as default since it makes more sense IMHO.

$ perf report -s comm
# Overhead Command
# ........ ............
#
74.19% cc1
7.61% gcc
6.11% as
4.35% sh
4.14% make
1.13% fixdep
...

$ perf report -s comm -c cc1,gcc --percentage absolute
# Overhead Command
# ........ ............
#
74.19% cc1
7.61% gcc

$ perf report -s comm -c cc1,gcc --percentage relative
# Overhead Command
# ........ ............
#
90.69% cc1
9.31% gcc

Note that it has zero effect if no filter was applied.

I only added the option to perf report for now. If it looks good to
you I'll add it to perf top too.

Any comments are welcome, thanks
Namhyung


Namhyung Kim (5):
perf tools: Count filtered entries to total period also
perf ui/tui: Add support for showing relative percentage
perf report: Add --percentage option
perf report: Add report.percentage config option
perf tools: Show absolute percentage by default

tools/perf/Documentation/perf-report.txt | 6 ++++++
tools/perf/builtin-report.c | 28 +++++++++++++++++++++++++++-
tools/perf/util/event.c | 18 ++++++++----------
tools/perf/util/hist.c | 27 ++++++++++++++-------------
tools/perf/util/hist.h | 7 +++++++
tools/perf/util/symbol.h | 5 +++--
6 files changed, 65 insertions(+), 26 deletions(-)

--
1.7.11.7


2014-01-14 04:43:27

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 1/5] perf tools: Count filtered entries to total period also

Currently if a sample was filtered by command line option, it just
dropped. But this affects final output in that the percentage can be
different since the filtered entries were not included to the total.

But user might want to see the original percentages when filter
applied so change the behavior depends on a new symbol_conf.filter_
relative value in order to be controlled by user later.

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/builtin-report.c | 2 +-
tools/perf/util/event.c | 18 ++++++++----------
tools/perf/util/hist.c | 12 +++---------
tools/perf/util/hist.h | 7 +++++++
tools/perf/util/symbol.c | 1 +
tools/perf/util/symbol.h | 5 +++--
6 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 46864dd7eb83..664a3dcdf0e0 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -247,7 +247,7 @@ static int process_sample_event(struct perf_tool *tool,
return -1;
}

- if (al.filtered || (rep->hide_unresolved && al.sym == NULL))
+ if (rep->hide_unresolved && al.sym == NULL)
return 0;

if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap))
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 1fc1c2f04772..f5a0bcd6be64 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -3,6 +3,7 @@
#include "debug.h"
#include "machine.h"
#include "sort.h"
+#include "hist.h"
#include "string.h"
#include "strlist.h"
#include "thread.h"
@@ -663,7 +664,7 @@ void thread__find_addr_map(struct thread *thread,
al->thread = thread;
al->addr = addr;
al->cpumode = cpumode;
- al->filtered = false;
+ al->filtered = 0;

if (machine == NULL) {
al->map = NULL;
@@ -750,9 +751,6 @@ int perf_event__preprocess_sample(const union perf_event *event,
if (thread == NULL)
return -1;

- if (thread__is_filtered(thread))
- goto out_filtered;
-
dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), thread->tid);
/*
* Have we already created the kernel maps for this machine?
@@ -767,6 +765,10 @@ int perf_event__preprocess_sample(const union perf_event *event,

thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION,
sample->ip, al);
+
+ if (thread__is_filtered(thread))
+ al->filtered |= (1 << HIST_FILTER__THREAD);
+
dump_printf(" ...... dso: %s\n",
al->map ? al->map->dso->long_name :
al->level == 'H' ? "[hypervisor]" : "<not found>");
@@ -782,7 +784,7 @@ int perf_event__preprocess_sample(const union perf_event *event,
(dso->short_name != dso->long_name &&
strlist__has_entry(symbol_conf.dso_list,
dso->long_name)))))
- goto out_filtered;
+ al->filtered |= (1 << HIST_FILTER__DSO);

al->sym = map__find_symbol(al->map, al->addr,
machine->symbol_filter);
@@ -791,11 +793,7 @@ int perf_event__preprocess_sample(const union perf_event *event,
if (symbol_conf.sym_list &&
(!al->sym || !strlist__has_entry(symbol_conf.sym_list,
al->sym->name)))
- goto out_filtered;
-
- return 0;
+ al->filtered |= (1 << HIST_FILTER__SYMBOL);

-out_filtered:
- al->filtered = true;
return 0;
}
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 4ed3e883240d..2d81f3aefad0 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -13,13 +13,6 @@ static bool hists__filter_entry_by_thread(struct hists *hists,
static bool hists__filter_entry_by_symbol(struct hists *hists,
struct hist_entry *he);

-enum hist_filter {
- HIST_FILTER__DSO,
- HIST_FILTER__THREAD,
- HIST_FILTER__PARENT,
- HIST_FILTER__SYMBOL,
-};
-
struct callchain_param callchain_param = {
.mode = CHAIN_GRAPH_REL,
.min_percent = 0.5,
@@ -329,8 +322,9 @@ void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h)
if (!h->filtered) {
hists__calc_col_len(hists, h);
++hists->nr_entries;
- hists->stats.total_period += h->stat.period;
}
+ if (!h->filtered || !symbol_conf.filter_relative)
+ hists->stats.total_period += h->stat.period;
}

static u8 symbol__parent_filter(const struct symbol *parent)
@@ -429,7 +423,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
.weight = weight,
},
.parent = sym_parent,
- .filtered = symbol__parent_filter(sym_parent),
+ .filtered = symbol__parent_filter(sym_parent) | al->filtered,
.hists = hists,
.branch_info = bi,
.mem_info = mi,
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index a59743fa3ef7..7d1d973d9a39 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -14,6 +14,13 @@ struct hist_entry;
struct addr_location;
struct symbol;

+enum hist_filter {
+ HIST_FILTER__DSO,
+ HIST_FILTER__THREAD,
+ HIST_FILTER__PARENT,
+ HIST_FILTER__SYMBOL,
+};
+
/*
* The kernel collects the number of events it couldn't send in a stretch and
* when possible sends this number in a PERF_RECORD_LOST event. The number of
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 39ce9adbaaf0..ac3d9748993c 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -33,6 +33,7 @@ struct symbol_conf symbol_conf = {
.try_vmlinux_path = true,
.annotate_src = true,
.demangle = true,
+ .filter_relative = true,
.symfs = "",
};

diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index cbd680361806..4ccc5c4b3a65 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -99,7 +99,8 @@ struct symbol_conf {
annotate_asm_raw,
annotate_src,
event_group,
- demangle;
+ demangle,
+ filter_relative;
const char *vmlinux_name,
*kallsyms_name,
*source_prefix,
@@ -170,7 +171,7 @@ struct addr_location {
struct symbol *sym;
u64 addr;
char level;
- bool filtered;
+ u8 filtered;
u8 cpumode;
s32 cpu;
};
--
1.7.11.7

2014-01-14 04:43:30

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 5/5] perf tools: Show absolute percentage by default

Now perf report will show absolute percentage on filter entries by
default.

Suggested-by: Jiri Olsa <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/util/symbol.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index ac3d9748993c..39ce9adbaaf0 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -33,7 +33,6 @@ struct symbol_conf symbol_conf = {
.try_vmlinux_path = true,
.annotate_src = true,
.demangle = true,
- .filter_relative = true,
.symfs = "",
};

--
1.7.11.7

2014-01-14 04:43:51

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 4/5] perf report: Add report.percentage config option

Add report.percentage option for setting default value of the
symbol_conf.filter_relative. It affects the report output only if a
filter applied.

An user can write .perfconfig file like below to show absolute
percentage of filtered entries by default:

$ cat ~/.perfconfig
[report]
percentage = absolute

And it can be changed through command line:

$ perf report --percentage relative

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/builtin-report.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 535bd6745355..1bb9e989c7bd 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -71,6 +71,16 @@ static int report__config(const char *var, const char *value, void *cb)
rep->min_percent = strtof(value, NULL);
return 0;
}
+ if (!strcmp(var, "report.percentage")) {
+ if (!strcmp(value, "relative"))
+ symbol_conf.filter_relative = true;
+ else if (!strcmp(value, "absolute"))
+ symbol_conf.filter_relative = false;
+ else
+ return -1;
+
+ return 0;
+ }

return perf_default_config(var, value, cb);
}
--
1.7.11.7

2014-01-14 04:44:18

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 2/5] perf ui/tui: Add support for showing relative percentage

When filtering by thread, dso or symbol on TUI it also update total
period so that the output shows different result than no filter - the
percentage changed to relative to filtered entries only. Sometimes
(always?) this is not desired since users might expect same results
with filter.

So change this behavior depends on symbol_conf.filter_relative value.

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/util/hist.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 2d81f3aefad0..58c799d9b689 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -696,10 +696,11 @@ static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h
return;

++hists->nr_entries;
+ if (symbol_conf.filter_relative)
+ hists->stats.total_period += h->stat.period;
if (h->ms.unfolded)
hists->nr_entries += h->nr_rows;
h->row_offset = 0;
- hists->stats.total_period += h->stat.period;
hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->stat.nr_events;

hists__calc_col_len(hists, h);
@@ -722,7 +723,9 @@ void hists__filter_by_dso(struct hists *hists)
{
struct rb_node *nd;

- hists->nr_entries = hists->stats.total_period = 0;
+ hists->nr_entries = 0;
+ if (symbol_conf.filter_relative)
+ hists->stats.total_period = 0;
hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
hists__reset_col_len(hists);

@@ -755,7 +758,9 @@ void hists__filter_by_thread(struct hists *hists)
{
struct rb_node *nd;

- hists->nr_entries = hists->stats.total_period = 0;
+ hists->nr_entries = 0;
+ if (symbol_conf.filter_relative)
+ hists->stats.total_period = 0;
hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
hists__reset_col_len(hists);

@@ -786,7 +791,9 @@ void hists__filter_by_symbol(struct hists *hists)
{
struct rb_node *nd;

- hists->nr_entries = hists->stats.total_period = 0;
+ hists->nr_entries = 0;
+ if (symbol_conf.filter_relative)
+ hists->stats.total_period = 0;
hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
hists__reset_col_len(hists);

--
1.7.11.7

2014-01-14 04:44:14

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 3/5] perf report: Add --percentage option

The --percentage option is for controlling overhead percentage
displayed. It can only receive either of "relative" or "absolute".

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

$ perf report -s comm
# Overhead Command
# ........ ............
#
74.19% cc1
7.61% gcc
6.11% as
4.35% sh
4.14% make
1.13% fixdep
...

$ perf report -s comm -c cc1,gcc --percentage absolute
# Overhead Command
# ........ ............
#
74.19% cc1
7.61% gcc

$ perf report -s comm -c cc1,gcc --percentage relative
# Overhead Command
# ........ ............
#
90.69% cc1
9.31% gcc

Note that it has zero effect if no filter was applied.

Suggested-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/Documentation/perf-report.txt | 6 ++++++
tools/perf/builtin-report.c | 16 ++++++++++++++++
2 files changed, 22 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 8eab8a4bdeb8..9a67a42356d6 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -237,6 +237,12 @@ 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.
+ "relative" means it's relative to filtered entries only so that the
+ sum of shown entries will be always 100%. "absolute" means it retains
+ original value before and after the filter applied.
+
--header::
Show header information in the perf.data file. This includes
various information like hostname, OS and perf version, cpu/mem
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 664a3dcdf0e0..535bd6745355 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -717,6 +717,20 @@ parse_percent_limit(const struct option *opt, const char *str,
return 0;
}

+static int
+parse_percentage(const struct option *opt __maybe_unused, const char *str,
+ int unset __maybe_unused)
+{
+ if (!strcmp(str, "relative"))
+ symbol_conf.filter_relative = true;
+ else if (!strcmp(str, "absolute"))
+ symbol_conf.filter_relative = false;
+ else
+ return -1;
+
+ return 0;
+}
+
int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
{
struct perf_session *session;
@@ -839,6 +853,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_percentage),
OPT_END()
};
struct perf_data_file file = {
--
1.7.11.7

2014-01-14 21:07:10

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH 3/5] perf report: Add --percentage option

Namhyung Kim <[email protected]> writes:
>
> +--percentage::
> + Determine how to display the overhead percentage of filtered
> entries.

This should describe also what a "filtered entry" exactly is. It's not clear
even to me.

-Andi

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

--
[email protected] -- Speaking for myself only

2014-01-14 21:26:08

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 3/5] perf report: Add --percentage option

Em Tue, Jan 14, 2014 at 01:07:00PM -0800, Andi Kleen escreveu:
> Namhyung Kim <[email protected]> writes:
> >
> > +--percentage::
> > + Determine how to display the overhead percentage of filtered
> > entries.
>
> This should describe also what a "filtered entry" exactly is. It's not clear
> even to me.

Yeah, the text should give some context, mentioning the "Zoom"
operations that can be done in the TUI (DSO, thread, etc) that allows
applying what he is calling "filters".`

> -Andi
>
> > + "relative" means it's relative to filtered entries only so that the
> > + sum of shown entries will be always 100%. "absolute" means it retains
> > + original value before and after the filter applied.
> > +
>
> --
> [email protected] -- Speaking for myself only

2014-01-15 02:18:28

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 3/5] perf report: Add --percentage option

On Tue, 14 Jan 2014 18:25:55 -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jan 14, 2014 at 01:07:00PM -0800, Andi Kleen escreveu:
>> Namhyung Kim <[email protected]> writes:
>> >
>> > +--percentage::
>> > + Determine how to display the overhead percentage of filtered
>> > entries.
>>
>> This should describe also what a "filtered entry" exactly is. It's not clear
>> even to me.
>
> Yeah, the text should give some context, mentioning the "Zoom"
> operations that can be done in the TUI (DSO, thread, etc) that allows
> applying what he is calling "filters".`

Ah, okay.

How about this:


-c::
--comms=::
Only consider symbols in these comms. CSV that understands
file://filename entries. This option will affect the percentage of
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
overhead column. See --percentage for more info.
-S::
--symbols=::
Only consider these symbols. CSV that understands
file://filename entries. This option will affect the percentage of
overhead column. See --percentage for more info.

--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
original value before and after the filter applied.


Thanks,
Namhyung

2014-01-15 18:30:17

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 3/5] perf report: Add --percentage option

Em Wed, Jan 15, 2014 at 11:18:23AM +0900, Namhyung Kim escreveu:
> On Tue, 14 Jan 2014 18:25:55 -0300, Arnaldo Carvalho de Melo wrote:
> > Em Tue, Jan 14, 2014 at 01:07:00PM -0800, Andi Kleen escreveu:
> >> Namhyung Kim <[email protected]> writes:
> >> >
> >> > +--percentage::
> >> > + Determine how to display the overhead percentage of filtered
> >> > entries.
> >>
> >> This should describe also what a "filtered entry" exactly is. It's not clear
> >> even to me.
> >
> > Yeah, the text should give some context, mentioning the "Zoom"
> > operations that can be done in the TUI (DSO, thread, etc) that allows
> > applying what he is calling "filters".`
>
> Ah, okay.
>
> How about this:

Ack, much clearer, minor things below:

>
> -c::
> --comms=::
> Only consider symbols in these comms. CSV that understands
> file://filename entries. This option will affect the percentage of
> overhead column. See --percentage for more info.
the overhead column. ...
> -d::
> --dsos=::
> Only consider symbols in these dsos. CSV that understands
> file://filename entries. This option will affect the percentage of
> overhead column. See --percentage for more info.

ditto

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

ditto

>
> --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
> original value before and after the filter applied.

Another missing 'the': "... retains the original value ..." plus a
missing 'is' just before 'applied'.

- Arnaldo

2014-01-16 01:26:50

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 3/5] perf report: Add --percentage option

On Wed, 15 Jan 2014 15:30:03 -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Jan 15, 2014 at 11:18:23AM +0900, Namhyung Kim escreveu:
>> On Tue, 14 Jan 2014 18:25:55 -0300, Arnaldo Carvalho de Melo wrote:
>> > Em Tue, Jan 14, 2014 at 01:07:00PM -0800, Andi Kleen escreveu:
>> >> Namhyung Kim <[email protected]> writes:
>> >> >
>> >> > +--percentage::
>> >> > + Determine how to display the overhead percentage of filtered
>> >> > entries.
>> >>
>> >> This should describe also what a "filtered entry" exactly is. It's not clear
>> >> even to me.
>> >
>> > Yeah, the text should give some context, mentioning the "Zoom"
>> > operations that can be done in the TUI (DSO, thread, etc) that allows
>> > applying what he is calling "filters".`
>>
>> Ah, okay.
>>
>> How about this:
>
> Ack, much clearer, minor things below:


Here goes an update :)


>From abd3ee476573087339794730bf8797913cf1a909 Mon Sep 17 00:00:00 2001
From: Namhyung Kim <[email protected]>
Date: Tue, 14 Jan 2014 11:52:48 +0900
Subject: [PATCH] perf report: Add --percentage option

The --percentage option is for controlling overhead percentage
displayed. It can only receive either of "relative" or "absolute".

"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.

$ perf report -s comm
# Overhead Command
# ........ ............
#
74.19% cc1
7.61% gcc
6.11% as
4.35% sh
4.14% make
1.13% fixdep
...

$ perf report -s comm -c cc1,gcc --percentage absolute
# Overhead Command
# ........ ............
#
74.19% cc1
7.61% gcc

$ perf report -s comm -c cc1,gcc --percentage relative
# Overhead Command
# ........ ............
#
90.69% cc1
9.31% gcc

Note that it has zero effect if no filter was applied.

Suggested-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/Documentation/perf-report.txt | 24 ++++++++++++++++++------
tools/perf/builtin-report.c | 16 ++++++++++++++++
2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 8eab8a4bdeb8..09af66298564 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -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
@@ -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.
@@ -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
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index dddacb0056e3..cb81d45e514c 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -699,6 +699,20 @@ parse_percent_limit(const struct option *opt, const char *str,
return 0;
}

+static int
+parse_percentage(const struct option *opt __maybe_unused, const char *str,
+ int unset __maybe_unused)
+{
+ if (!strcmp(str, "relative"))
+ symbol_conf.filter_relative = true;
+ else if (!strcmp(str, "absolute"))
+ symbol_conf.filter_relative = false;
+ else
+ return -1;
+
+ return 0;
+}
+
int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
{
struct perf_session *session;
@@ -821,6 +835,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_percentage),
OPT_END()
};
struct perf_data_file file = {
--
1.7.11.7