From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org, David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@gmail.com>,
Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 08/44] perf session: Add hooks to allow transparent decoding of AUX area tracing data
Date: Tue, 21 Apr 2015 11:46:32 -0300 [thread overview]
Message-ID: <20150421144632.GC11111@kernel.org> (raw)
In-Reply-To: <20150421144154.GB11111@kernel.org>
Em Tue, Apr 21, 2015 at 11:41:54AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Thu, Apr 09, 2015 at 06:53:48PM +0300, Adrian Hunter escreveu:
> > Hook into session processing so that AUX area decoding can
> > synthesize events transparently to the tools.
> >
> > The advantages of transparent decoding are that tools can be used
> > directly with perf.data files containing AUX area tracing data,
> > which is easier for the user and more efficient than having a
> > separate decoding tool.
> >
> > This will work as follows:
> > 1. Tools will feed auxtrace events to the decoder using
> > perf_tool->auxtrace() (support for that still to come).
> > 2. The decoder can process side-band events as needed due
> > to the auxtrace->process_event() hook.
> > 3. The decoder can deliver synthesized events into the
> > event stream using perf_session__deliver_synth_event().
>
> So, here this clashes with work I'm doing to untie ordered_events from
> perf_session, undoes it even, trying to decipher if this is really
> needed...
Sorry, gut reaction, it only touches perf_session code, it can be left
for later to figure out if that auxtrace fits better in 'struct
perf_evlist' or even 'struct machine', as perf_session is about a
'perf.data' file, i.e. post processing.
But I think that processing intel PT events _as they are generated_ (in
fact as fast as possible, as there is buffering, etc), i.e. a la 'perf
trace' or 'perf top' will be difficult/impossible, given its volume...
But perhaps with some filtering/narrowing... anyway, will leave this for
later, applying this patch.
- Arnaldo
> - Arnaldo
>
> > Note the expectation is that decoding will work on data that is
> > time-ordered with respect to the per-cpu or per-thread contexts
> > that were recorded.
>
> > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> > ---
> > tools/perf/util/auxtrace.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++
> > tools/perf/util/session.c | 54 ++++++++++++++++++++++++++++++++++++---------
> > tools/perf/util/session.h | 3 +++
> > 3 files changed, 102 insertions(+), 10 deletions(-)
> >
> > diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
> > index 7ab4850..199fc27 100644
> > --- a/tools/perf/util/auxtrace.h
> > +++ b/tools/perf/util/auxtrace.h
> > @@ -23,6 +23,7 @@
> > #include <linux/types.h>
> >
> > #include "../perf.h"
> > +#include "session.h"
> >
> > union perf_event;
> > struct perf_session;
> > @@ -32,6 +33,24 @@ struct record_opts;
> > struct auxtrace_info_event;
> >
> > /**
> > + * struct auxtrace - session callbacks to allow AUX area data decoding.
> > + * @process_event: lets the decoder see all session events
> > + * @flush_events: process any remaining data
> > + * @free_events: free resources associated with event processing
> > + * @free: free resources associated with the session
> > + */
> > +struct auxtrace {
> > + int (*process_event)(struct perf_session *session,
> > + union perf_event *event,
> > + struct perf_sample *sample,
> > + struct perf_tool *tool);
> > + int (*flush_events)(struct perf_session *session,
> > + struct perf_tool *tool);
> > + void (*free_events)(struct perf_session *session);
> > + void (*free)(struct perf_session *session);
> > +};
> > +
> > +/**
> > * struct auxtrace_mmap - records an mmap of the auxtrace buffer.
> > * @base: address of mapped area
> > * @userpg: pointer to buffer's perf_event_mmap_page
> > @@ -168,4 +187,40 @@ int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr,
> > struct perf_session *session,
> > perf_event__handler_t process);
> >
> > +static inline int auxtrace__process_event(struct perf_session *session,
> > + union perf_event *event,
> > + struct perf_sample *sample,
> > + struct perf_tool *tool)
> > +{
> > + if (!session->auxtrace)
> > + return 0;
> > +
> > + return session->auxtrace->process_event(session, event, sample, tool);
> > +}
> > +
> > +static inline int auxtrace__flush_events(struct perf_session *session,
> > + struct perf_tool *tool)
> > +{
> > + if (!session->auxtrace)
> > + return 0;
> > +
> > + return session->auxtrace->flush_events(session, tool);
> > +}
> > +
> > +static inline void auxtrace__free_events(struct perf_session *session)
> > +{
> > + if (!session->auxtrace)
> > + return;
> > +
> > + return session->auxtrace->free_events(session);
> > +}
> > +
> > +static inline void auxtrace__free(struct perf_session *session)
> > +{
> > + if (!session->auxtrace)
> > + return;
> > +
> > + return session->auxtrace->free(session);
> > +}
> > +
> > #endif
> > diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> > index 18e4034..cf9d678 100644
> > --- a/tools/perf/util/session.c
> > +++ b/tools/perf/util/session.c
> > @@ -15,12 +15,13 @@
> > #include "cpumap.h"
> > #include "perf_regs.h"
> > #include "asm/bug.h"
> > +#include "auxtrace.h"
> >
> > -static int machines__deliver_event(struct machines *machines,
> > - struct perf_evlist *evlist,
> > - union perf_event *event,
> > - struct perf_sample *sample,
> > - struct perf_tool *tool, u64 file_offset);
> > +static int perf_session__deliver_event(struct perf_session *session,
> > + union perf_event *event,
> > + struct perf_sample *sample,
> > + struct perf_tool *tool,
> > + u64 file_offset);
> >
> > static int perf_session__open(struct perf_session *session)
> > {
> > @@ -105,8 +106,8 @@ static int ordered_events__deliver_event(struct ordered_events *oe,
> > return ret;
> > }
> >
> > - return machines__deliver_event(&session->machines, session->evlist, event->event,
> > - &sample, session->tool, event->file_offset);
> > + return perf_session__deliver_event(session, event->event, &sample,
> > + session->tool, event->file_offset);
> > }
> >
> > struct perf_session *perf_session__new(struct perf_data_file *file,
> > @@ -185,6 +186,7 @@ static void perf_session_env__delete(struct perf_session_env *env)
> >
> > void perf_session__delete(struct perf_session *session)
> > {
> > + auxtrace__free(session);
> > perf_session__destroy_kernel_maps(session);
> > perf_session__delete_threads(session);
> > perf_session_env__delete(&session->header.env);
> > @@ -1030,6 +1032,24 @@ static int machines__deliver_event(struct machines *machines,
> > }
> > }
> >
> > +static int perf_session__deliver_event(struct perf_session *session,
> > + union perf_event *event,
> > + struct perf_sample *sample,
> > + struct perf_tool *tool,
> > + u64 file_offset)
> > +{
> > + int ret;
> > +
> > + ret = auxtrace__process_event(session, event, sample, tool);
> > + if (ret < 0)
> > + return ret;
> > + if (ret > 0)
> > + return 0;
> > +
> > + return machines__deliver_event(&session->machines, session->evlist,
> > + event, sample, tool, file_offset);
> > +}
> > +
> > static s64 perf_session__process_user_event(struct perf_session *session,
> > union perf_event *event,
> > u64 file_offset)
> > @@ -1190,8 +1210,8 @@ static s64 perf_session__process_event(struct perf_session *session,
> > return ret;
> > }
> >
> > - return machines__deliver_event(&session->machines, evlist, event,
> > - &sample, tool, file_offset);
> > + return perf_session__deliver_event(session, event, &sample, tool,
> > + file_offset);
> > }
> >
> > void perf_event_header__bswap(struct perf_event_header *hdr)
> > @@ -1350,10 +1370,14 @@ more:
> > done:
> > /* do the final flush for ordered samples */
> > err = ordered_events__flush(oe, OE_FLUSH__FINAL);
> > + if (err)
> > + goto out_err;
> > + err = auxtrace__flush_events(session, tool);
> > out_err:
> > free(buf);
> > perf_session__warn_about_errors(session);
> > ordered_events__free(&session->ordered_events);
> > + auxtrace__free_events(session);
> > return err;
> > }
> >
> > @@ -1496,10 +1520,14 @@ more:
> > out:
> > /* do the final flush for ordered samples */
> > err = ordered_events__flush(oe, OE_FLUSH__FINAL);
> > + if (err)
> > + goto out_err;
> > + err = auxtrace__flush_events(session, tool);
> > out_err:
> > ui_progress__finish();
> > perf_session__warn_about_errors(session);
> > ordered_events__free(&session->ordered_events);
> > + auxtrace__free_events(session);
> > session->one_mmap = false;
> > return err;
> > }
> > @@ -1582,7 +1610,13 @@ size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp
> >
> > size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
> > {
> > - size_t ret = fprintf(fp, "Aggregated stats:\n");
> > + size_t ret;
> > + const char *msg = "";
> > +
> > + if (perf_header__has_feat(&session->header, HEADER_AUXTRACE))
> > + msg = " (excludes AUX area (e.g. instruction trace) decoded / synthesized events)";
> > +
> > + ret = fprintf(fp, "Aggregated stats:%s\n", msg);
> >
> > ret += events_stats__fprintf(&session->evlist->stats, fp);
> > return ret;
> > diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
> > index d5fa7b791..8a69d3b 100644
> > --- a/tools/perf/util/session.h
> > +++ b/tools/perf/util/session.h
> > @@ -15,10 +15,13 @@
> > struct ip_callchain;
> > struct thread;
> >
> > +struct auxtrace;
> > +
> > struct perf_session {
> > struct perf_header header;
> > struct machines machines;
> > struct perf_evlist *evlist;
> > + struct auxtrace *auxtrace;
> > struct trace_event tevent;
> > bool repipe;
> > bool one_mmap;
> > --
> > 1.9.1
next prev parent reply other threads:[~2015-04-21 14:46 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-09 15:53 [PATCH 00/44] perf tools: Introduce an abstraction for AUX Area and Instruction Tracing Adrian Hunter
2015-04-09 15:53 ` [PATCH 01/44] perf header: Add AUX area tracing feature Adrian Hunter
2015-05-06 2:58 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 02/44] perf evlist: Add support for mmapping an AUX area buffer Adrian Hunter
2015-05-06 2:58 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 03/44] perf tools: Add user events for AUX area tracing Adrian Hunter
2015-04-20 23:06 ` Arnaldo Carvalho de Melo
2015-04-20 23:10 ` Arnaldo Carvalho de Melo
2015-04-21 9:23 ` Adrian Hunter
2015-05-06 2:59 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 04/44] perf tools: Add support for AUX area recording Adrian Hunter
2015-04-20 23:17 ` Arnaldo Carvalho de Melo
2015-05-06 2:59 ` [tip:perf/core] perf auxtrace: " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 05/44] perf record: Add basic AUX area tracing support Adrian Hunter
2015-05-06 2:59 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 06/44] perf record: Extend -m option for AUX area tracing mmap pages Adrian Hunter
2015-05-06 2:59 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 07/44] perf tools: Add a user event for AUX area tracing errors Adrian Hunter
2015-05-06 3:00 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 08/44] perf session: Add hooks to allow transparent decoding of AUX area tracing data Adrian Hunter
2015-04-21 14:41 ` Arnaldo Carvalho de Melo
2015-04-21 14:46 ` Arnaldo Carvalho de Melo [this message]
2015-05-06 3:00 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 09/44] perf session: Add instruction tracing options Adrian Hunter
2015-04-21 14:50 ` Arnaldo Carvalho de Melo
2015-04-22 6:23 ` Adrian Hunter
2015-04-23 14:08 ` Arnaldo Carvalho de Melo
2015-05-06 3:00 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 10/44] perf auxtrace: Add helpers for AUX area tracing errors Adrian Hunter
2015-05-06 3:01 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 11/44] perf auxtrace: Add helpers for queuing AUX area tracing data Adrian Hunter
2015-04-21 9:21 ` [PATCH V2 " Adrian Hunter
2015-05-06 3:01 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 12/44] perf auxtrace: Add a heap for sorting AUX area tracing queues Adrian Hunter
2015-04-21 15:01 ` Arnaldo Carvalho de Melo
2015-05-06 3:01 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 13/44] perf auxtrace: Add processing for AUX area tracing events Adrian Hunter
2015-05-06 3:01 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 14/44] perf auxtrace: Add a hashtable for caching Adrian Hunter
2015-05-06 3:02 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 15/44] perf tools: Add member to struct dso for an instruction cache Adrian Hunter
2015-05-06 3:02 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 16/44] perf script: Add Instruction Tracing support Adrian Hunter
2015-05-06 3:02 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:53 ` [PATCH 17/44] perf script: Always allow fields 'addr' and 'cpu' for auxtrace Adrian Hunter
2015-04-09 15:53 ` [PATCH 18/44] perf report: Add Instruction Tracing support Adrian Hunter
2015-04-23 14:16 ` Arnaldo Carvalho de Melo
2015-04-09 15:53 ` [PATCH 19/44] perf inject: Re-pipe AUX area tracing events Adrian Hunter
2015-04-21 9:21 ` [PATCH V2 " Adrian Hunter
2015-05-06 3:03 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:54 ` [PATCH 20/44] perf inject: Add Instruction Tracing support Adrian Hunter
2015-05-06 3:03 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:54 ` [PATCH 21/44] perf tools: Add AUX area tracing index Adrian Hunter
2015-04-09 15:54 ` [PATCH 22/44] perf tools: Hit all build ids when AUX area tracing Adrian Hunter
2015-04-09 15:54 ` [PATCH 23/44] perf tools: Add build option NO_AUXTRACE to exclude " Adrian Hunter
2015-04-21 9:21 ` [PATCH V2 " Adrian Hunter
2015-04-09 15:54 ` [PATCH 24/44] perf auxtrace: Add option to synthesize events for transactions Adrian Hunter
2015-04-09 15:54 ` [PATCH 25/44] perf script: Add field option 'flags' to print sample flags Adrian Hunter
2015-05-06 3:03 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:54 ` [PATCH 26/44] perf tools: Add aux_watermark member of struct perf_event_attr Adrian Hunter
2015-05-06 3:03 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-04-09 15:54 ` [PATCH 27/44] perf tools: Add support for PERF_RECORD_AUX Adrian Hunter
2015-04-09 15:54 ` [PATCH 28/44] perf tools: Add support for PERF_RECORD_ITRACE_START Adrian Hunter
2015-04-09 15:54 ` [PATCH 29/44] perf tools: Add AUX area tracing Snapshot Mode Adrian Hunter
2015-04-09 15:54 ` [PATCH 30/44] perf record: Add AUX area tracing Snapshot Mode support Adrian Hunter
2015-04-09 15:54 ` [PATCH 31/44] perf auxtrace: Add Intel PT as an AUX area tracing type Adrian Hunter
2015-04-09 15:54 ` [PATCH 32/44] perf tools: Add Intel PT packet decoder Adrian Hunter
2015-04-09 15:54 ` [PATCH 33/44] perf tools: Add Intel PT instruction decoder Adrian Hunter
2015-04-09 15:54 ` [PATCH 34/44] perf tools: Add Intel PT log Adrian Hunter
2015-04-09 15:54 ` [PATCH 35/44] perf tools: Add Intel PT decoder Adrian Hunter
2015-04-09 15:54 ` [PATCH 36/44] perf tools: Add Intel PT support Adrian Hunter
2015-04-09 15:54 ` [PATCH 37/44] perf tools: Take Intel PT into use Adrian Hunter
2015-04-09 15:54 ` [PATCH 38/44] perf tools: Allow auxtrace data alignment Adrian Hunter
2015-04-09 15:54 ` [PATCH 39/44] perf tools: Add Intel BTS support Adrian Hunter
2015-04-09 15:54 ` [PATCH 40/44] perf tools: Output sample flags and insn_len from intel_pt Adrian Hunter
2015-04-09 15:54 ` [PATCH 41/44] perf tools: Output sample flags and insn_len from intel_bts Adrian Hunter
2015-04-09 15:54 ` [PATCH 42/44] perf tools: Intel PT to always update thread stack trace number Adrian Hunter
2015-04-09 15:54 ` [PATCH 43/44] perf tools: Intel BTS " Adrian Hunter
2015-04-09 15:54 ` [PATCH 44/44] perf tools: Add example call-graph script 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=20150421144632.GC11111@kernel.org \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@gmail.com \
--cc=peterz@infradead.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