[PATCH 7/9] perf tools: Allow PERF_FORMAT_GROUP for inherited events

From: Jiri Olsa
Date: Mon Aug 25 2014 - 10:46:40 EST


Swithing on leader sampling on inherited events.

Following command will now get data from all children processes:
$ perf record -e '{cycles,cache-misses}:S' <workload>

Use following command to display the data:
$ perf report --group

Adding warning for record command if the support
is not detected:
$ perf record -e '{cycles,cache-misses}:S,{instructions,branch}:S' kill
Disabling inherit for sample read events, no kernel support.
...

Reported-by: Jen-Cheng(Tommy) Huang <tommy24@xxxxxxxxxx>
Cc: Andi Kleen <andi@xxxxxxxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Corey Ashford <cjashfor@xxxxxxxxxxxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Jen-Cheng(Tommy) Huang <tommy24@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Stephane Eranian <eranian@xxxxxxxxxx>
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/perf.h | 1 +
tools/perf/util/evsel.c | 6 +++++-
tools/perf/util/record.c | 12 ++++++++++++
3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 510c65f72858..54e1cb42277e 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -45,6 +45,7 @@ struct record_opts {
bool call_graph_enabled;
bool group;
bool inherit_stat;
+ bool inherit_format_group;
bool no_buffering;
bool no_inherit;
bool no_inherit_set;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 507d458ded2c..7415159bbcea 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -586,7 +586,11 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
*/
if (leader->nr_members > 1) {
attr->read_format |= PERF_FORMAT_GROUP;
- attr->inherit = 0;
+ attr->inherit = opts->inherit_format_group;
+ if (!opts->inherit_format_group) {
+ pr_warning_once("Disabling inherit for sample read events, "
+ "no kernel support.\n");
+ }
}
}

diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c
index cf69325b985f..22b1d9c79ac0 100644
--- a/tools/perf/util/record.c
+++ b/tools/perf/util/record.c
@@ -85,6 +85,12 @@ static void perf_probe_comm_exec(struct perf_evsel *evsel)
evsel->attr.comm_exec = 1;
}

+static void perf_probe_inherit_format_group(struct perf_evsel *evsel)
+{
+ evsel->attr.inherit = 1;
+ evsel->attr.read_format |= PERF_FORMAT_GROUP;
+}
+
bool perf_can_sample_identifier(void)
{
return perf_probe_api(perf_probe_sample_identifier);
@@ -95,6 +101,11 @@ static bool perf_can_comm_exec(void)
return perf_probe_api(perf_probe_comm_exec);
}

+static bool perf_can_inherit_format_group(void)
+{
+ return perf_probe_api(perf_probe_inherit_format_group);
+}
+
void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts)
{
struct perf_evsel *evsel;
@@ -111,6 +122,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts)
if (evlist->cpus->map[0] < 0)
opts->no_inherit = true;

+ opts->inherit_format_group = perf_can_inherit_format_group();
use_comm_exec = perf_can_comm_exec();

evlist__for_each(evlist, evsel) {
--
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/