From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 7/8] perf intel-pt: Improve sync_switch
Date: Fri, 12 Apr 2019 14:38:29 +0300 [thread overview]
Message-ID: <20190412113830.4126-8-adrian.hunter@intel.com> (raw)
In-Reply-To: <20190412113830.4126-1-adrian.hunter@intel.com>
sync_switch is a facility to synchronize decoding more closely with the
point in the kernel when the context actually switched.
Improve it by processing "context switch in" events.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/intel-pt.c | 40 +++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 6d288237887b..deaf2888dc55 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1914,6 +1914,44 @@ static int intel_pt_process_switch(struct intel_pt *pt,
return machine__set_current_tid(pt->machine, cpu, -1, tid);
}
+static int intel_pt_context_switch_in(struct intel_pt *pt,
+ struct perf_sample *sample)
+{
+ pid_t pid = sample->pid;
+ pid_t tid = sample->tid;
+ int cpu = sample->cpu;
+
+ if (pt->sync_switch) {
+ struct intel_pt_queue *ptq;
+
+ ptq = intel_pt_cpu_to_ptq(pt, cpu);
+ if (ptq && ptq->sync_switch) {
+ ptq->next_tid = -1;
+ switch (ptq->switch_state) {
+ case INTEL_PT_SS_NOT_TRACING:
+ case INTEL_PT_SS_UNKNOWN:
+ case INTEL_PT_SS_TRACING:
+ break;
+ case INTEL_PT_SS_EXPECTING_SWITCH_EVENT:
+ case INTEL_PT_SS_EXPECTING_SWITCH_IP:
+ ptq->switch_state = INTEL_PT_SS_TRACING;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ /*
+ * If the current tid has not been updated yet, ensure it is now that
+ * a "switch in" event has occurred.
+ */
+ if (machine__get_current_tid(pt->machine, cpu) == tid)
+ return 0;
+
+ return machine__set_current_tid(pt->machine, cpu, pid, tid);
+}
+
static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event,
struct perf_sample *sample)
{
@@ -1925,7 +1963,7 @@ static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event,
if (pt->have_sched_switch == 3) {
if (!out)
- return 0;
+ return intel_pt_context_switch_in(pt, sample);
if (event->header.type != PERF_RECORD_SWITCH_CPU_WIDE) {
pr_err("Expecting CPU-wide context switch event\n");
return -EINVAL;
--
2.17.1
next prev parent reply other threads:[~2019-04-12 11:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-12 11:38 [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
2019-04-12 11:38 ` [PATCH 1/8] perf scripts python: exported-sql-viewer.py: Change python2 to python Adrian Hunter
2019-05-30 8:17 ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 2/8] perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing Adrian Hunter
2019-05-30 8:18 ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 3/8] perf scripts python: exported-sql-viewer.py: Add support for pyside2 Adrian Hunter
2019-05-30 8:19 ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 4/8] perf scripts python: export-to-sqlite.py: " Adrian Hunter
2019-05-30 8:19 ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 5/8] perf scripts python: export-to-postgresql.py: " Adrian Hunter
2019-05-30 8:20 ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 6/8] perf tools: perf-with-kcore.sh: Always allow fix_buildid_cache_permissions Adrian Hunter
2019-05-30 7:52 ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-12 11:38 ` Adrian Hunter [this message]
2019-05-30 8:21 ` [tip:perf/core] perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in events tip-bot for Adrian Hunter
2019-04-12 11:38 ` [PATCH 8/8] perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid Adrian Hunter
2019-05-30 8:21 ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-04-29 7:28 ` [PATCH 0/8] perf scripts python: Support pyside2 and misc Intel PT Adrian Hunter
2019-05-20 14:39 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190412113830.4126-8-adrian.hunter@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).