diff options
author | Mathieu Poirier <mathieu.poirier@linaro.org> | 2018-04-27 14:05:02 -0600 |
---|---|---|
committer | Mathieu Poirier <mathieu.poirier@linaro.org> | 2019-04-03 04:17:30 -0600 |
commit | bfab6de86f6604dfe1f1287957905b61e6220747 (patch) | |
tree | 9121eb5427d0a0866bf63d5b933a506eeca261d5 | |
parent | 13772ff5826f99c824f02df0ec48c9bc77104900 (diff) |
perf tools: Add handling of switch-CPU-wide events
Add handling of SWITCH-CPU-WIDE events in order to add the tid/pid of the
incoming process to the perf tools machine infrastructure. This
information is later retrieved when a contextID packet is found in the
trace stream.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
-rw-r--r-- | tools/perf/util/cs-etm.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index c58a6b87a376..b6fb389adcc3 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1686,6 +1686,42 @@ static int cs_etm__process_itrace_start(struct cs_etm_auxtrace *etm, return 0; } +static int cs_etm__process_switch_cpu_wide(struct cs_etm_auxtrace *etm, + union perf_event *event) +{ + struct thread *th; + bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT; + + /* + * Context switch in per-thread mode are irrelevant since perf + * will start/stop tracing as the process is scheduled. + */ + if (etm->timeless_decoding) + return 0; + + /* + * SWITCH_IN events carry the next process to be switched out while + * SWITCH_OUT events carry the process to be switched in. As such + * we don't care about IN events. + */ + if (!out) + return 0; + + /* + * Add the tid/pid to the log so that we can get a match when + * we get a contextID from the decoder. + */ + th = machine__findnew_thread(etm->machine, + event->context_switch.next_prev_pid, + event->context_switch.next_prev_tid); + if (!th) + return -ENOMEM; + + thread__put(th); + + return 0; +} + static int cs_etm__process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, @@ -1725,6 +1761,8 @@ static int cs_etm__process_event(struct perf_session *session, if (event->header.type == PERF_RECORD_ITRACE_START) return cs_etm__process_itrace_start(etm, event); + else if (event->header.type == PERF_RECORD_SWITCH_CPU_WIDE) + return cs_etm__process_switch_cpu_wide(etm, event); return 0; } |