Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1424014 > unrolled thread
| Started by | Adrian Hunter <adrian.hunter@intel.com> |
|---|---|
| First post | 2016-06-16 14:40 +0200 |
| Last post | 2016-06-16 18:40 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH RFC 0/3] perf script: Add callindent option Adrian Hunter <adrian.hunter@intel.com> - 2016-06-16 14:40 +0200
[PATCH RFC 2/3] perf auxtrace: Add option to feed branches to the thread stack Adrian Hunter <adrian.hunter@intel.com> - 2016-06-16 14:50 +0200
Re: [PATCH RFC 0/3] perf script: Add callindent option Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-16 18:40 +0200
| From | Adrian Hunter <adrian.hunter@intel.com> |
|---|---|
| Date | 2016-06-16 14:40 +0200 |
| Subject | [PATCH RFC 0/3] perf script: Add callindent option |
| Message-ID | <rKEKu-8mu-13@gated-at.bofh.it> |
Hi
Andi Kleen sent a couple of patches to add a callindent option to
perf script. If Andi is agreeable, I would like to propose an
alternative implementation.
While there are some differences in the resulting output, the main
differences are:
1. Tell the decoder to feed branches to the thread stack, which has the
advantage that it happens before branch filtering and so can be used
with different itrace options (e.g. it still works when only showing
calls, even though the thread stack needs to see calls and returns). Also
it does not conflict with using the thread stack to get callchains.
2. Print "call" or "ret" instead of using a different event
Adrian Hunter (3):
perf: script: Fix documentation of '-f' when it should be '-F'
perf auxtrace: Add option to feed branches to the thread stack
perf script: Add callindent option
tools/perf/Documentation/perf-script.txt | 26 +++++++-----
tools/perf/builtin-script.c | 70 ++++++++++++++++++++++++++++++++
tools/perf/util/auxtrace.h | 2 +
tools/perf/util/intel-bts.c | 22 +++++++---
tools/perf/util/intel-pt.c | 5 ++-
tools/perf/util/thread-stack.c | 7 ++++
tools/perf/util/thread-stack.h | 1 +
7 files changed, 117 insertions(+), 16 deletions(-)
Regards
Adrian
[toc] | [next] | [standalone]
| From | Adrian Hunter <adrian.hunter@intel.com> |
|---|---|
| Date | 2016-06-16 14:50 +0200 |
| Subject | [PATCH RFC 2/3] perf auxtrace: Add option to feed branches to the thread stack |
| Message-ID | <rKEUa-8qv-3@gated-at.bofh.it> |
| In reply to | #1424014 |
In preparation for using the thread stack to print an indent representing
the stack depth in perf script, add an option to tell decoders to feed
branches to the thread stack. Add support for that option to Intel PT and
Intel BTS.
The advantage of using the decoder to feed the thread stack is that it
happens before branch filtering and so can be used with different itrace
options (e.g. it still works when only showing calls, even though the
thread stack needs to see calls and returns). Also it does not conflict
with using the thread stack to get callchains.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/auxtrace.h | 2 ++
tools/perf/util/intel-bts.c | 22 +++++++++++++++++-----
tools/perf/util/intel-pt.c | 5 ++++-
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index 767989e0e312..ac5f0d7167e6 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -63,6 +63,7 @@ enum itrace_period_type {
* @calls: limit branch samples to calls (can be combined with @returns)
* @returns: limit branch samples to returns (can be combined with @calls)
* @callchain: add callchain to 'instructions' events
+ * @thread_stack: feed branches to the thread_stack
* @last_branch: add branch context to 'instruction' events
* @callchain_sz: maximum callchain size
* @last_branch_sz: branch context size
@@ -82,6 +83,7 @@ struct itrace_synth_opts {
bool calls;
bool returns;
bool callchain;
+ bool thread_stack;
bool last_branch;
unsigned int callchain_sz;
unsigned int last_branch_sz;
diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c
index 9df996085563..6d16b5c059b9 100644
--- a/tools/perf/util/intel-bts.c
+++ b/tools/perf/util/intel-bts.c
@@ -422,7 +422,8 @@ static int intel_bts_get_branch_type(struct intel_bts_queue *btsq,
}
static int intel_bts_process_buffer(struct intel_bts_queue *btsq,
- struct auxtrace_buffer *buffer)
+ struct auxtrace_buffer *buffer,
+ struct thread *thread)
{
struct branch *branch;
size_t sz, bsz = sizeof(struct branch);
@@ -444,6 +445,12 @@ static int intel_bts_process_buffer(struct intel_bts_queue *btsq,
if (!branch->from && !branch->to)
continue;
intel_bts_get_branch_type(btsq, branch);
+ if (btsq->bts->synth_opts.thread_stack)
+ thread_stack__event(thread, btsq->sample_flags,
+ le64_to_cpu(branch->from),
+ le64_to_cpu(branch->to),
+ btsq->intel_pt_insn.length,
+ buffer->buffer_nr + 1);
if (filter && !(filter & btsq->sample_flags))
continue;
err = intel_bts_synth_branch_sample(btsq, branch);
@@ -507,12 +514,13 @@ static int intel_bts_process_queue(struct intel_bts_queue *btsq, u64 *timestamp)
goto out_put;
}
- if (!btsq->bts->synth_opts.callchain && thread &&
+ if (!btsq->bts->synth_opts.callchain &&
+ !btsq->bts->synth_opts.thread_stack && thread &&
(!old_buffer || btsq->bts->sampling_mode ||
(btsq->bts->snapshot_mode && !buffer->consecutive)))
thread_stack__set_trace_nr(thread, buffer->buffer_nr + 1);
- err = intel_bts_process_buffer(btsq, buffer);
+ err = intel_bts_process_buffer(btsq, buffer, thread);
auxtrace_buffer__drop_data(buffer);
@@ -905,10 +913,14 @@ int intel_bts_process_auxtrace_info(union perf_event *event,
if (dump_trace)
return 0;
- if (session->itrace_synth_opts && session->itrace_synth_opts->set)
+ if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
bts->synth_opts = *session->itrace_synth_opts;
- else
+ } else {
itrace_synth_opts__set_default(&bts->synth_opts);
+ if (session->itrace_synth_opts)
+ bts->synth_opts.thread_stack =
+ session->itrace_synth_opts->thread_stack;
+ }
if (bts->synth_opts.calls)
bts->branches_filter |= PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC |
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 137196990012..b2f7e5474f3c 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1233,7 +1233,7 @@ static int intel_pt_sample(struct intel_pt_queue *ptq)
if (!(state->type & INTEL_PT_BRANCH))
return 0;
- if (pt->synth_opts.callchain)
+ if (pt->synth_opts.callchain || pt->synth_opts.thread_stack)
thread_stack__event(ptq->thread, ptq->flags, state->from_ip,
state->to_ip, ptq->insn_len,
state->trace_nr);
@@ -2136,6 +2136,9 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
pt->synth_opts.branches = false;
pt->synth_opts.callchain = true;
}
+ if (session->itrace_synth_opts)
+ pt->synth_opts.thread_stack =
+ session->itrace_synth_opts->thread_stack;
}
if (pt->synth_opts.log)
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-06-16 18:40 +0200 |
| Message-ID | <rKIuK-2fo-31@gated-at.bofh.it> |
| In reply to | #1424014 |
Em Thu, Jun 16, 2016 at 03:34:31PM +0300, Adrian Hunter escreveu: > Hi > > Andi Kleen sent a couple of patches to add a callindent option to > perf script. If Andi is agreeable, I would like to propose an > alternative implementation. Andi? - Arnaldo > While there are some differences in the resulting output, the main > differences are: > > 1. Tell the decoder to feed branches to the thread stack, which has the > advantage that it happens before branch filtering and so can be used > with different itrace options (e.g. it still works when only showing > calls, even though the thread stack needs to see calls and returns). Also > it does not conflict with using the thread stack to get callchains. > > 2. Print "call" or "ret" instead of using a different event > > > Adrian Hunter (3): > perf: script: Fix documentation of '-f' when it should be '-F' > perf auxtrace: Add option to feed branches to the thread stack > perf script: Add callindent option > > tools/perf/Documentation/perf-script.txt | 26 +++++++----- > tools/perf/builtin-script.c | 70 ++++++++++++++++++++++++++++++++ > tools/perf/util/auxtrace.h | 2 + > tools/perf/util/intel-bts.c | 22 +++++++--- > tools/perf/util/intel-pt.c | 5 ++- > tools/perf/util/thread-stack.c | 7 ++++ > tools/perf/util/thread-stack.h | 1 + > 7 files changed, 117 insertions(+), 16 deletions(-) > > > Regards > Adrian
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web