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 2/9] perf intel-pt: Fix sync_switch
Date: Wed, 7 Mar 2018 16:02:22 +0200 [thread overview]
Message-ID: <1520431349-30689-3-git-send-email-adrian.hunter@intel.com> (raw)
In-Reply-To: <1520431349-30689-1-git-send-email-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. The flag when
sync_switch is enabled was global to the decoding, whereas it is really
specific to the CPU. The trace data for different CPUs is put on different
queues, so add sync_switch to the intel_pt_queue structure and use that in
preference to the global setting in the intel_pt structure. That fixes
problems decoding one CPU's trace because sync_switch was disabled on a
different CPU's queue.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: <stable@vger.kernel.org>
---
tools/perf/util/intel-pt.c | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 4a7746249999..0979a6e8b2b7 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -143,6 +143,7 @@ struct intel_pt_queue {
bool stop;
bool step_through_buffers;
bool use_buffer_pid_tid;
+ bool sync_switch;
pid_t pid, tid;
int cpu;
int switch_state;
@@ -963,10 +964,12 @@ static int intel_pt_setup_queue(struct intel_pt *pt,
if (pt->timeless_decoding || !pt->have_sched_switch)
ptq->use_buffer_pid_tid = true;
}
+
+ ptq->sync_switch = pt->sync_switch;
}
if (!ptq->on_heap &&
- (!pt->sync_switch ||
+ (!ptq->sync_switch ||
ptq->switch_state != INTEL_PT_SS_EXPECTING_SWITCH_EVENT)) {
const struct intel_pt_state *state;
int ret;
@@ -1549,7 +1552,7 @@ static int intel_pt_sample(struct intel_pt_queue *ptq)
if (pt->synth_opts.last_branch)
intel_pt_update_last_branch_rb(ptq);
- if (!pt->sync_switch)
+ if (!ptq->sync_switch)
return 0;
if (intel_pt_is_switch_ip(ptq, state->to_ip)) {
@@ -1630,6 +1633,21 @@ static u64 intel_pt_switch_ip(struct intel_pt *pt, u64 *ptss_ip)
return switch_ip;
}
+static void intel_pt_enable_sync_switch(struct intel_pt *pt)
+{
+ unsigned int i;
+
+ pt->sync_switch = true;
+
+ for (i = 0; i < pt->queues.nr_queues; i++) {
+ struct auxtrace_queue *queue = &pt->queues.queue_array[i];
+ struct intel_pt_queue *ptq = queue->priv;
+
+ if (ptq)
+ ptq->sync_switch = true;
+ }
+}
+
static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp)
{
const struct intel_pt_state *state = ptq->state;
@@ -1646,7 +1664,7 @@ static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp)
if (pt->switch_ip) {
intel_pt_log("switch_ip: %"PRIx64" ptss_ip: %"PRIx64"\n",
pt->switch_ip, pt->ptss_ip);
- pt->sync_switch = true;
+ intel_pt_enable_sync_switch(pt);
}
}
}
@@ -1662,9 +1680,9 @@ static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp)
if (state->err) {
if (state->err == INTEL_PT_ERR_NODATA)
return 1;
- if (pt->sync_switch &&
+ if (ptq->sync_switch &&
state->from_ip >= pt->kernel_start) {
- pt->sync_switch = false;
+ ptq->sync_switch = false;
intel_pt_next_tid(pt, ptq);
}
if (pt->synth_opts.errors) {
@@ -1690,7 +1708,7 @@ static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp)
state->timestamp, state->est_timestamp);
ptq->timestamp = state->est_timestamp;
/* Use estimated TSC in unknown switch state */
- } else if (pt->sync_switch &&
+ } else if (ptq->sync_switch &&
ptq->switch_state == INTEL_PT_SS_UNKNOWN &&
intel_pt_is_switch_ip(ptq, state->to_ip) &&
ptq->next_tid == -1) {
@@ -1837,7 +1855,7 @@ static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid,
return 1;
ptq = intel_pt_cpu_to_ptq(pt, cpu);
- if (!ptq)
+ if (!ptq || !ptq->sync_switch)
return 1;
switch (ptq->switch_state) {
--
1.9.1
next prev parent reply other threads:[~2018-03-07 14:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-07 14:02 [PATCH 0/9] perf intel-pt: Some fixes and preparation for AUX area sampling Adrian Hunter
2018-03-07 14:02 ` [PATCH 1/9] perf intel-pt: Fix overlap detection to identify consecutive buffers correctly Adrian Hunter
2018-03-09 8:47 ` [tip:perf/core] " tip-bot for Adrian Hunter
2018-03-07 14:02 ` Adrian Hunter [this message]
2018-03-09 8:47 ` [tip:perf/core] perf intel-pt: Fix sync_switch tip-bot for Adrian Hunter
2018-03-07 14:02 ` [PATCH 3/9] perf intel-pt: Fix error recovery from missing TIP packet Adrian Hunter
2018-03-09 8:48 ` [tip:perf/core] " tip-bot for Adrian Hunter
2018-03-07 14:02 ` [PATCH 4/9] perf intel-pt: Fix timestamp following overflow Adrian Hunter
2018-03-09 8:48 ` [tip:perf/core] " tip-bot for Adrian Hunter
2018-03-07 14:02 ` [PATCH 5/9] perf intel-pt/bts: In auxtrace_record__init_intel() evlist is never NULL Adrian Hunter
2018-03-09 8:49 ` [tip:perf/core] " tip-bot for Adrian Hunter
2018-03-07 14:02 ` [PATCH 6/9] perf intel-pt: Get rid of intel_pt_use_buffer_pid_tid() Adrian Hunter
2018-03-09 8:49 ` [tip:perf/core] " tip-bot for Adrian Hunter
2018-03-07 14:02 ` [PATCH 7/9] perf intel-pt: Tidy old_buffer handling in intel_pt_get_trace() Adrian Hunter
2018-03-09 8:50 ` [tip:perf/core] " tip-bot for Adrian Hunter
2018-03-07 14:02 ` [PATCH 8/9] perf intel-pt: Remove a check for sampling mode Adrian Hunter
2018-03-09 8:50 ` [tip:perf/core] " tip-bot for Adrian Hunter
2018-03-07 14:02 ` [PATCH 9/9] perf intel-pt: Adjust overlap-checking to support " Adrian Hunter
2018-03-09 8:51 ` [tip:perf/core] " tip-bot for Adrian Hunter
2018-03-07 14:36 ` [PATCH 0/9] perf intel-pt: Some fixes and preparation for AUX area sampling 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=1520431349-30689-3-git-send-email-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).