perf stat record: Initialize record features
authorJiri Olsa <jolsa@kernel.org>
Thu, 5 Nov 2015 14:40:47 +0000 (15:40 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 17 Dec 2015 18:15:17 +0000 (15:15 -0300)
Disabling all non stat related features.

Also as we now enable STAT feature in the data file, adding code to
instruct session open to skip sample type checking for stat data files.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Kan Liang <kan.liang@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1446734469-11352-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-stat.c
tools/perf/util/session.c

index af2a3bf659f76e096ca53a09f922cc3e4cf77f5e..c9c896a94feea1428fa3c896384b6c454532dea2 100644 (file)
@@ -1310,6 +1310,19 @@ static const char * const recort_usage[] = {
        NULL,
 };
 
+static void init_features(struct perf_session *session)
+{
+       int feat;
+
+       for (feat = HEADER_FIRST_FEATURE; feat < HEADER_LAST_FEATURE; feat++)
+               perf_header__set_feat(&session->header, feat);
+
+       perf_header__clear_feat(&session->header, HEADER_BUILD_ID);
+       perf_header__clear_feat(&session->header, HEADER_TRACING_DATA);
+       perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK);
+       perf_header__clear_feat(&session->header, HEADER_AUXTRACE);
+}
+
 static int __cmd_record(int argc, const char **argv)
 {
        struct perf_session *session;
@@ -1331,6 +1344,8 @@ static int __cmd_record(int argc, const char **argv)
        if (perf_stat.file.is_pipe)
                return -EINVAL;
 
+       init_features(session);
+
        session->evlist   = evsel_list;
        perf_stat.session = session;
        perf_stat.record  = true;
index a90c74b67e43337fd77b05e39dbf73f8a3b795a8..d5636ba94b20f722d3f521614e8fae08b620fad4 100644 (file)
@@ -37,6 +37,9 @@ static int perf_session__open(struct perf_session *session)
        if (perf_data_file__is_pipe(file))
                return 0;
 
+       if (perf_header__has_feat(&session->header, HEADER_STAT))
+               return 0;
+
        if (!perf_evlist__valid_sample_type(session->evlist)) {
                pr_err("non matching sample_type\n");
                return -1;