From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Linux Weekly News <lwn@lwn.net>,
Andi Kleen <ak@linux.intel.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 04/68] perf intel-pt/bts: Report instruction bytes and length in sample
Date: Tue, 11 Oct 2016 14:30:59 -0300 [thread overview]
Message-ID: <1476207123-21791-5-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1476207123-21791-1-git-send-email-acme@kernel.org>
From: Andi Kleen <ak@linux.intel.com>
Change Intel PT and BTS to pass up the length and the instruction
bytes of the decoded or sampled instruction in the perf sample.
The decoder already knows this information, we just need to pass it
up. Since it is only a couple of movs it is not very expensive.
Handle instruction cache too. Make sure ilen is always initialized.
Used in the next patch.
[Adrian: re-base on top (and adjust for) instruction buffer size tidy-up]
[Adrian: add BTS support and adjust commit message accordingly]
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Link: http://lkml.kernel.org/r/1475847747-30994-3-git-send-email-adrian.hunter@intel.com
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/event.h | 3 +++
tools/perf/util/intel-bts.c | 1 +
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 ++
tools/perf/util/intel-pt-decoder/intel-pt-decoder.h | 1 +
tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 2 +-
tools/perf/util/intel-pt.c | 11 +++++++++++
6 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 8d363d5e65a2..c735c53a26f8 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -177,6 +177,8 @@ enum {
PERF_IP_FLAG_TRACE_BEGIN |\
PERF_IP_FLAG_TRACE_END)
+#define MAX_INSN 16
+
struct perf_sample {
u64 ip;
u32 pid, tid;
@@ -193,6 +195,7 @@ struct perf_sample {
u32 flags;
u16 insn_len;
u8 cpumode;
+ char insn[MAX_INSN];
void *raw_data;
struct ip_callchain *callchain;
struct branch_stack *branch_stack;
diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c
index 8bc7fec817d7..6c2eb5da4afc 100644
--- a/tools/perf/util/intel-bts.c
+++ b/tools/perf/util/intel-bts.c
@@ -295,6 +295,7 @@ static int intel_bts_synth_branch_sample(struct intel_bts_queue *btsq,
sample.cpu = btsq->cpu;
sample.flags = btsq->sample_flags;
sample.insn_len = btsq->intel_pt_insn.length;
+ memcpy(sample.insn, btsq->intel_pt_insn.buf, INTEL_PT_INSN_BUF_SZ);
if (bts->synth_opts.inject) {
event.sample.header.size = bts->branches_event_size;
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
index 16c06d3ae577..e4e7dc781d21 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -980,6 +980,8 @@ out:
out_no_progress:
decoder->state.insn_op = intel_pt_insn->op;
decoder->state.insn_len = intel_pt_insn->length;
+ memcpy(decoder->state.insn, intel_pt_insn->buf,
+ INTEL_PT_INSN_BUF_SZ);
if (decoder->tx_flags & INTEL_PT_IN_TX)
decoder->state.flags |= INTEL_PT_IN_TX;
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
index 89399985fa4d..e90619a43c0c 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h
@@ -66,6 +66,7 @@ struct intel_pt_state {
uint32_t flags;
enum intel_pt_insn_op insn_op;
int insn_len;
+ char insn[INTEL_PT_INSN_BUF_SZ];
};
struct intel_pt_insn;
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
index 5f95cd442075..7913363bde5c 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c
@@ -27,7 +27,7 @@
#include "intel-pt-insn-decoder.h"
-#if INTEL_PT_INSN_BUF_SZ < MAX_INSN_SIZE
+#if INTEL_PT_INSN_BUF_SZ < MAX_INSN_SIZE || INTEL_PT_INSN_BUF_SZ > MAX_INSN
#error Instruction buffer size too small
#endif
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 815a14d8904b..85d5eeb66c75 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -143,6 +143,7 @@ struct intel_pt_queue {
u32 flags;
u16 insn_len;
u64 last_insn_cnt;
+ char insn[INTEL_PT_INSN_BUF_SZ];
};
static void intel_pt_dump(struct intel_pt *pt __maybe_unused,
@@ -315,6 +316,7 @@ struct intel_pt_cache_entry {
enum intel_pt_insn_branch branch;
int length;
int32_t rel;
+ char insn[INTEL_PT_INSN_BUF_SZ];
};
static int intel_pt_config_div(const char *var, const char *value, void *data)
@@ -400,6 +402,7 @@ static int intel_pt_cache_add(struct dso *dso, struct machine *machine,
e->branch = intel_pt_insn->branch;
e->length = intel_pt_insn->length;
e->rel = intel_pt_insn->rel;
+ memcpy(e->insn, intel_pt_insn->buf, INTEL_PT_INSN_BUF_SZ);
err = auxtrace_cache__add(c, offset, &e->entry);
if (err)
@@ -436,6 +439,8 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn,
u64 insn_cnt = 0;
bool one_map = true;
+ intel_pt_insn->length = 0;
+
if (to_ip && *ip == to_ip)
goto out_no_cache;
@@ -475,6 +480,8 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn,
intel_pt_insn->branch = e->branch;
intel_pt_insn->length = e->length;
intel_pt_insn->rel = e->rel;
+ memcpy(intel_pt_insn->buf, e->insn,
+ INTEL_PT_INSN_BUF_SZ);
intel_pt_log_insn_no_data(intel_pt_insn, *ip);
return 0;
}
@@ -898,6 +905,7 @@ static void intel_pt_sample_flags(struct intel_pt_queue *ptq)
if (ptq->state->flags & INTEL_PT_IN_TX)
ptq->flags |= PERF_IP_FLAG_IN_TX;
ptq->insn_len = ptq->state->insn_len;
+ memcpy(ptq->insn, ptq->state->insn, INTEL_PT_INSN_BUF_SZ);
}
}
@@ -1078,6 +1086,7 @@ static int intel_pt_synth_branch_sample(struct intel_pt_queue *ptq)
sample.cpu = ptq->cpu;
sample.flags = ptq->flags;
sample.insn_len = ptq->insn_len;
+ memcpy(sample.insn, ptq->insn, INTEL_PT_INSN_BUF_SZ);
/*
* perf report cannot handle events without a branch stack when using
@@ -1139,6 +1148,7 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq)
sample.cpu = ptq->cpu;
sample.flags = ptq->flags;
sample.insn_len = ptq->insn_len;
+ memcpy(sample.insn, ptq->insn, INTEL_PT_INSN_BUF_SZ);
ptq->last_insn_cnt = ptq->state->tot_insn_cnt;
@@ -1201,6 +1211,7 @@ static int intel_pt_synth_transaction_sample(struct intel_pt_queue *ptq)
sample.cpu = ptq->cpu;
sample.flags = ptq->flags;
sample.insn_len = ptq->insn_len;
+ memcpy(sample.insn, ptq->insn, INTEL_PT_INSN_BUF_SZ);
if (pt->synth_opts.callchain) {
thread_stack__sample(ptq->thread, ptq->chain,
--
2.7.4
next prev parent reply other threads:[~2016-10-11 18:00 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-11 17:30 [GIT PULL 00/68] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-10-11 17:30 ` [PATCH 01/68] perf list: Add support for listing only json events Arnaldo Carvalho de Melo
2016-10-11 17:30 ` [PATCH 02/68] perf tools: Handle completion of upper case events Arnaldo Carvalho de Melo
2016-10-11 17:30 ` [PATCH 03/68] perf intel-pt/bts: Tidy instruction buffer size usage Arnaldo Carvalho de Melo
2016-10-11 17:30 ` Arnaldo Carvalho de Melo [this message]
2016-10-11 17:31 ` [PATCH 05/68] perf top: Fix refreshing hierarchy entries on TUI Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 06/68] perf tools: Sync copy of x86's syscall table Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 07/68] perf c2c: Introduce c2c_decode_stats function Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 08/68] perf c2c: Introduce c2c_add_stats function Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 09/68] perf c2c: Add c2c command Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 10/68] perf c2c: Add record subcommand Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 11/68] perf c2c: Add report subcommand Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 12/68] perf c2c report: Add dimension support Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 13/68] perf c2c report: Add sort_entry " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 14/68] perf c2c report: Fallback to standard dimensions Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 15/68] perf c2c report: Add sample processing Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 16/68] perf c2c report: Add cacheline hists processing Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 17/68] perf c2c report: Decode c2c_stats for hist entries Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 18/68] perf c2c report: Add header macros Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 19/68] perf c2c report: Add 'dcacheline' dimension key Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 20/68] perf c2c report: Add 'offset' " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 21/68] perf c2c report: Add 'iaddr' " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 22/68] perf c2c report: Add hitm related dimension keys Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 23/68] perf c2c report: Add stores " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 24/68] perf c2c report: Add loads " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 25/68] perf c2c report: Add llc and remote " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 26/68] perf c2c report: Add llc load miss dimension key Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 27/68] perf c2c report: Add total record sort key Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 28/68] perf c2c report: Add total loads " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 29/68] perf c2c report: Add hitm percent " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 30/68] perf c2c report: Add hitm/store percent related sort keys Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 31/68] perf c2c report: Add dram " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 32/68] perf c2c report: Add 'pid' sort key Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 33/68] perf c2c report: Add 'tid' " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 34/68] perf c2c report: Add 'symbol' and 'dso' sort keys Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 35/68] perf c2c report: Add 'node' sort key Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 36/68] perf c2c report: Add stats related sort keys Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 37/68] perf c2c report: Add 'cpucnt' sort key Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 38/68] perf c2c report: Add src line " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 39/68] perf c2c report: Setup number of header lines for hists Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 40/68] perf c2c report: Set final resort fields Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 41/68] perf c2c report: Add stdio output support Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 42/68] perf c2c report: Add main TUI browser Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 43/68] perf c2c report: Add TUI cacheline browser Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 44/68] perf c2c report: Add global stats stdio output Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 45/68] perf c2c report: Add shared cachelines " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 46/68] perf c2c report: Add c2c related " Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 47/68] perf c2c report: Allow to report callchains Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 48/68] perf c2c report: Limit the cachelines table entries Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 49/68] perf c2c report: Add support to choose local HITMs Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 50/68] perf c2c report: Allow to set cacheline sort fields Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 51/68] perf c2c report: Recalc width of global sort entries Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 52/68] perf c2c report: Add cacheline index entry Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 53/68] perf c2c report: Add support to manage symbol name length Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 54/68] perf c2c report: Iterate node display in browser Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 55/68] perf c2c report: Add help windows Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 56/68] perf c2c: Add man page and credits Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 57/68] tools lib traceevent: Add install_headers target Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 58/68] tools lib traceevent: Add do_install_mkdir Makefile function Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 59/68] tools lib traceevent: Rename LIB_FILE to LIB_TARGET Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 60/68] tools lib traceevent: Add version for traceevent shared object Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 61/68] tools lib: Add for_each_clear_bit macro Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 62/68] perf report: Move captured info to generic header info Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 63/68] perf header: Display missing features Arnaldo Carvalho de Melo
2016-10-11 17:31 ` [PATCH 64/68] perf header: Display feature name on write failure Arnaldo Carvalho de Melo
2016-10-11 17:32 ` [PATCH 65/68] perf header: Set nr_numa_nodes only when we parsed all the data Arnaldo Carvalho de Melo
2016-10-11 17:32 ` [PATCH 66/68] perf c2c report: Add --no-source option Arnaldo Carvalho de Melo
2016-10-11 17:32 ` [PATCH 67/68] perf c2c report: Add --show-all option Arnaldo Carvalho de Melo
2016-10-11 17:32 ` [PATCH 68/68] perf jevents: Handle events including .c and .o 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=1476207123-21791-5-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lwn@lwn.net \
--cc=mingo@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
Powered by JetHome