perf evlist: Add perf_evlist__set_tracking_event()
authorAdrian Hunter <adrian.hunter@intel.com>
Thu, 31 Jul 2014 06:00:52 +0000 (09:00 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 13 Aug 2014 22:21:32 +0000 (19:21 -0300)
Add a function to change which event is used to track mmap, comm and
task events.

This is needed with Instruction Tracing because the Instruction Tracing
event must come first but cannot be used for tracking because it will be
disabled under some circumstances.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1406786474-9306-10-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c
tools/perf/util/evlist.h
tools/perf/util/evsel.c
tools/perf/util/evsel.h
tools/perf/util/record.c

index c74d8ecc9c70a457d1c595d1c79d67036811ad79..9d863db3f4b239a84cd4eb9a9c90a4ba01dd62c2 100644 (file)
@@ -122,6 +122,7 @@ void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry)
 {
        list_add_tail(&entry->node, &evlist->entries);
        entry->idx = evlist->nr_entries;
+       entry->tracking = !entry->idx;
 
        if (!evlist->nr_entries++)
                perf_evlist__set_id_pos(evlist);
@@ -1295,3 +1296,19 @@ void perf_evlist__to_front(struct perf_evlist *evlist,
 
        list_splice(&move, &evlist->entries);
 }
+
+void perf_evlist__set_tracking_event(struct perf_evlist *evlist,
+                                    struct perf_evsel *tracking_evsel)
+{
+       struct perf_evsel *evsel;
+
+       if (tracking_evsel->tracking)
+               return;
+
+       evlist__for_each(evlist, evsel) {
+               if (evsel != tracking_evsel)
+                       evsel->tracking = false;
+       }
+
+       tracking_evsel->tracking = true;
+}
index f5173cd63693cc7944b500a65a0b407567512143..e0084f90c27130b66119f33eb67ff06bc7e3a756 100644 (file)
@@ -262,4 +262,7 @@ void perf_evlist__to_front(struct perf_evlist *evlist,
 #define evlist__for_each_safe(evlist, tmp, evsel) \
        __evlist__for_each_safe(&(evlist)->entries, tmp, evsel)
 
+void perf_evlist__set_tracking_event(struct perf_evlist *evlist,
+                                    struct perf_evsel *tracking_evsel);
+
 #endif /* __PERF_EVLIST_H */
index 66de9a708163353fc8db7d68d479ee61f1509bb8..01ce14c3575e0e5141fdf5f151f0fc1faa3c2913 100644 (file)
@@ -162,6 +162,7 @@ void perf_evsel__init(struct perf_evsel *evsel,
                      struct perf_event_attr *attr, int idx)
 {
        evsel->idx         = idx;
+       evsel->tracking    = !idx;
        evsel->attr        = *attr;
        evsel->leader      = evsel;
        evsel->unit        = "";
@@ -561,7 +562,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
 {
        struct perf_evsel *leader = evsel->leader;
        struct perf_event_attr *attr = &evsel->attr;
-       int track = !evsel->idx; /* only the first counter needs these */
+       int track = evsel->tracking;
        bool per_cpu = opts->target.default_per_cpu && !opts->target.per_thread;
 
        attr->sample_id_all = perf_missing_features.sample_id_all ? 0 : 1;
index dbb2a0d20907ce917e6a4a85b0ed44fb8714f32f..7bc314be6a7bea55b81611788c57e95313041af9 100644 (file)
@@ -86,6 +86,7 @@ struct perf_evsel {
        bool                    no_aux_samples;
        bool                    immediate;
        bool                    system_wide;
+       bool                    tracking;
        /* parse modifier helper */
        int                     exclude_GH;
        int                     nr_members;
index e778afda0fb9881759228fba341196e659fb34bf..cf69325b985f15534fcb54303b98cfd5409d6e50 100644 (file)
@@ -115,7 +115,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts)
 
        evlist__for_each(evlist, evsel) {
                perf_evsel__config(evsel, opts);
-               if (!evsel->idx && use_comm_exec)
+               if (evsel->tracking && use_comm_exec)
                        evsel->attr.comm_exec = 1;
        }