]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
perf intel-pt: Factor out common sample preparation for re-use
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 10 Jun 2019 07:27:57 +0000 (10:27 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 17 Jun 2019 18:57:18 +0000 (15:57 -0300)
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

index cc91c1413c22e773e6db788b79d1daba65845684..a2d90b2f1f114307a7081a55ada5c740161ace87 100644 (file)
@@ -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,