[PATCH 10/10] perf stat: Support inherit/no-inherit terms
From: Jiri Olsa
Date: Thu Aug 24 2017 - 12:28:13 EST
Adding support to use 'inherit' and 'no-inherit' terms
in perf stat command, like:
To disable perf_event_attr::inherit (enabled by default):
$ perf stat -e cpu/cpu-cycles,no-inherit/u ...
Enable perf_event_attr::inherit (disabled by -i):
$ perf stat -i -e cpu/cpu-cycles,inherit/u ...
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/builtin-stat.c | 19 +++++++++++++++++++
tools/perf/util/parse-events.c | 2 ++
2 files changed, 21 insertions(+)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 866da7aa54bf..92053b93e452 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -210,6 +210,23 @@ static void perf_stat__reset_stats(void)
perf_stat__reset_shadow_stats();
}
+static void apply_stat_config_terms(struct perf_evsel *evsel)
+{
+ struct perf_evsel_config_term *term;
+ struct list_head *config_terms = &evsel->config_terms;
+ struct perf_event_attr *attr = &evsel->attr;
+
+ list_for_each_entry(term, config_terms, list) {
+ switch (term->type) {
+ case PERF_EVSEL__CONFIG_TERM_INHERIT:
+ attr->inherit = term->val.inherit ? 1 : 0;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
static int create_perf_stat_counter(struct perf_evsel *evsel)
{
struct perf_event_attr *attr = &evsel->attr;
@@ -264,6 +281,8 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
attr->enable_on_exec = 1;
}
+ apply_stat_config_terms(evsel);
+
if (target__has_cpu(&target))
return perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel));
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index f44aeba51d1f..b2b448ff0a36 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -934,6 +934,8 @@ config_term_avail(int term_type, struct parse_events_error *err)
case PARSE_EVENTS__TERM_TYPE_CONFIG2:
case PARSE_EVENTS__TERM_TYPE_NAME:
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
+ case PARSE_EVENTS__TERM_TYPE_INHERIT:
+ case PARSE_EVENTS__TERM_TYPE_NOINHERIT:
return true;
default:
if (!err)
--
2.9.5