linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Adrian Hunter <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de,
	adrian.hunter@intel.com, linux-kernel@vger.kernel.org,
	acme@redhat.com, jolsa@redhat.com
Subject: [tip:perf/core] perf intel-pt: Factor out common sample preparation for re-use
Date: Fri, 21 Jun 2019 23:38:49 -0700	[thread overview]
Message-ID: <tip-0dfded34a2e3b517c149ee9c7d1e5173025017b7@git.kernel.org> (raw)
In-Reply-To: <20190610072803.10456-6-adrian.hunter@intel.com>

Commit-ID:  0dfded34a2e3b517c149ee9c7d1e5173025017b7
Gitweb:     https://git.kernel.org/tip/0dfded34a2e3b517c149ee9c7d1e5173025017b7
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Mon, 10 Jun 2019 10:27:57 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 17 Jun 2019 15:57:18 -0300

perf intel-pt: Factor out common sample preparation for re-use

Factor out common sample preparation for re-use when synthesizing PEBS
samples.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190610072803.10456-6-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/intel-pt.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index cc91c1413c22..a2d90b2f1f11 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1182,28 +1182,37 @@ static inline bool intel_pt_skip_event(struct intel_pt *pt)
 	       pt->num_events++ < pt->synth_opts.initial_skip;
 }
 
+static void intel_pt_prep_a_sample(struct intel_pt_queue *ptq,
+				   union perf_event *event,
+				   struct perf_sample *sample)
+{
+	event->sample.header.type = PERF_RECORD_SAMPLE;
+	event->sample.header.size = sizeof(struct perf_event_header);
+
+	sample->pid = ptq->pid;
+	sample->tid = ptq->tid;
+	sample->cpu = ptq->cpu;
+	sample->insn_len = ptq->insn_len;
+	memcpy(sample->insn, ptq->insn, INTEL_PT_INSN_BUF_SZ);
+}
+
 static void intel_pt_prep_b_sample(struct intel_pt *pt,
 				   struct intel_pt_queue *ptq,
 				   union perf_event *event,
 				   struct perf_sample *sample)
 {
+	intel_pt_prep_a_sample(ptq, event, sample);
+
 	if (!pt->timeless_decoding)
 		sample->time = tsc_to_perf_time(ptq->timestamp, &pt->tc);
 
 	sample->ip = ptq->state->from_ip;
 	sample->cpumode = intel_pt_cpumode(pt, sample->ip);
-	sample->pid = ptq->pid;
-	sample->tid = ptq->tid;
 	sample->addr = ptq->state->to_ip;
 	sample->period = 1;
-	sample->cpu = ptq->cpu;
 	sample->flags = ptq->flags;
-	sample->insn_len = ptq->insn_len;
-	memcpy(sample->insn, ptq->insn, INTEL_PT_INSN_BUF_SZ);
 
-	event->sample.header.type = PERF_RECORD_SAMPLE;
 	event->sample.header.misc = sample->cpumode;
-	event->sample.header.size = sizeof(struct perf_event_header);
 }
 
 static int intel_pt_inject_event(union perf_event *event,

  reply	other threads:[~2019-06-22  6:39 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-bot for Adrian Hunter [this message]
2019-06-10  7:27 ` [PATCH 06/11] perf intel-pt: Synthesize PEBS sample basic information Adrian Hunter
2019-06-22  6:39   ` [tip:perf/core] " 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=tip-0dfded34a2e3b517c149ee9c7d1e5173025017b7@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /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).