linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 06/11] perf intel-pt: Synthesize PEBS sample basic information
Date: Mon, 10 Jun 2019 10:27:58 +0300	[thread overview]
Message-ID: <20190610072803.10456-7-adrian.hunter@intel.com> (raw)
In-Reply-To: <20190610072803.10456-1-adrian.hunter@intel.com>

Synthesize a PEBS sample using basic information (ip, timestamp) only.
Other PEBS information will be added in later patches.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/intel-pt.c | 52 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 50 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 1f5520f964ab..4517c02fa478 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1443,9 +1443,57 @@ static int intel_pt_synth_pwrx_sample(struct intel_pt_queue *ptq)
 					    pt->pwr_events_sample_type);
 }
 
-static int intel_pt_synth_pebs_sample(struct intel_pt_queue *ptq __maybe_unused)
+static int intel_pt_synth_pebs_sample(struct intel_pt_queue *ptq)
 {
-	return 0;
+	const struct intel_pt_blk_items *items = &ptq->state->items;
+	struct perf_sample sample = { .ip = 0, };
+	union perf_event *event = ptq->event_buf;
+	struct intel_pt *pt = ptq->pt;
+	struct perf_evsel *evsel = pt->pebs_evsel;
+	u64 sample_type = evsel->attr.sample_type;
+	u64 id = evsel->id[0];
+	u8 cpumode;
+
+	if (intel_pt_skip_event(pt))
+		return 0;
+
+	intel_pt_prep_a_sample(ptq, event, &sample);
+
+	sample.id = id;
+	sample.stream_id = id;
+
+	if (!evsel->attr.freq)
+		sample.period = evsel->attr.sample_period;
+
+	/* No support for non-zero CS base */
+	if (items->has_ip)
+		sample.ip = items->ip;
+	else if (items->has_rip)
+		sample.ip = items->rip;
+	else
+		sample.ip = ptq->state->from_ip;
+
+	/* No support for guest mode at this time */
+	cpumode = sample.ip < ptq->pt->kernel_start ?
+		  PERF_RECORD_MISC_USER :
+		  PERF_RECORD_MISC_KERNEL;
+
+	event->sample.header.misc = cpumode | PERF_RECORD_MISC_EXACT_IP;
+
+	sample.cpumode = cpumode;
+
+	if (sample_type & PERF_SAMPLE_TIME) {
+		u64 timestamp = 0;
+
+		if (items->has_timestamp)
+			timestamp = items->timestamp;
+		else if (!pt->timeless_decoding)
+			timestamp = ptq->timestamp;
+		if (timestamp)
+			sample.time = tsc_to_perf_time(timestamp, &pt->tc);
+	}
+
+	return intel_pt_deliver_synth_event(pt, ptq, event, &sample, sample_type);
 }
 
 static int intel_pt_synth_error(struct intel_pt *pt, int code, int cpu,
-- 
2.17.1


  parent reply	other threads:[~2019-06-10  7:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-10  7:27 [PATCH 00/11] perf intel-pt: Prepare for PEBS via PT Adrian Hunter
2019-06-10  7:27 ` [PATCH 01/11] perf intel-pt: Add new packets " Adrian Hunter
2019-06-12  0:09   ` Arnaldo Carvalho de Melo
2019-06-12  5:58     ` Adrian Hunter
2019-06-12 12:41       ` Arnaldo Carvalho de Melo
2019-06-12 12:52         ` Adrian Hunter
2019-06-12 13:28           ` Arnaldo Carvalho de Melo
2019-06-13  8:13             ` Adrian Hunter
2019-07-04 16:10             ` Alexander Shishkin
2019-06-22  6:35   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-10  7:27 ` [PATCH 02/11] perf intel-pt: Add Intel PT packet decoder test Adrian Hunter
2019-06-22  6:36   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-10  7:27 ` [PATCH 03/11] perf intel-pt: Add decoder support for PEBS via PT Adrian Hunter
2019-06-22  6:37   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-10  7:27 ` [PATCH 04/11] perf intel-pt: Prepare to synthesize PEBS samples Adrian Hunter
2019-06-22  6:38   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-10  7:27 ` [PATCH 05/11] perf intel-pt: Factor out common sample preparation for re-use Adrian Hunter
2019-06-22  6:38   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-10  7:27 ` Adrian Hunter [this message]
2019-06-22  6:39   ` [tip:perf/core] perf intel-pt: Synthesize PEBS sample basic information tip-bot for Adrian Hunter
2019-06-10  7:27 ` [PATCH 07/11] perf intel-pt: Add gp registers to synthesized PEBS sample Adrian Hunter
2019-06-22  6:40   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-10  7:28 ` [PATCH 08/11] perf intel-pt: Add xmm " Adrian Hunter
2019-06-22  6:40   ` [tip:perf/core] perf intel-pt: Add XMM " tip-bot for Adrian Hunter
2019-06-10  7:28 ` [PATCH 09/11] perf intel-pt: Add lbr information " Adrian Hunter
2019-06-22  6:41   ` [tip:perf/core] perf intel-pt: Add LBR " tip-bot for Adrian Hunter
2019-06-10  7:28 ` [PATCH 10/11] perf intel-pt: Add memory " Adrian Hunter
2019-06-22  6:42   ` [tip:perf/core] " tip-bot for Adrian Hunter
2019-06-10  7:28 ` [PATCH 11/11] perf intel-pt: Add callchain " Adrian Hunter
2019-06-22  6:43   ` [tip:perf/core] " tip-bot for Adrian Hunter

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=20190610072803.10456-7-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).