Re: [PATCH V6 05/25] perf record: Add basic AUX area tracing support
From: Jiri Olsa
Date: Tue Mar 24 2015 - 07:09:12 EST
On Mon, Mar 16, 2015 at 02:41:27PM +0200, Adrian Hunter wrote:
> Amend the perf record tool to read the
> AUX area tracing mmap and synthesize
> AUX area tracing events.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> ---
> tools/perf/builtin-record.c | 80 ++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 76 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 5a2ff51..8b3a50e 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -27,6 +27,7 @@
> #include "util/cpumap.h"
> #include "util/thread_map.h"
> #include "util/data.h"
> +#include "util/auxtrace.h"
>
> #include <unistd.h>
> #include <sched.h>
> @@ -38,6 +39,7 @@ struct record {
> struct record_opts opts;
> u64 bytes_written;
> struct perf_data_file file;
> + struct auxtrace_record *itr;
> struct perf_evlist *evlist;
> struct perf_session *session;
> const char *progname;
> @@ -110,6 +112,43 @@ out:
> return rc;
> }
>
> +static int record__process_auxtrace(struct perf_tool *tool,
> + union perf_event *event, void *data1,
> + size_t len1, void *data2, size_t len2)
> +{
> + struct record *rec = container_of(tool, struct record, tool);
> + size_t padding;
> + u8 pad[8] = {0};
> +
> + /* event.auxtrace.size includes padding, see __auxtrace_mmap__read() */
> + padding = (len1 + len2) & 7;
> + if (padding)
> + padding = 8 - padding;
> +
> + record__write(rec, event, event->header.size);
> + record__write(rec, data1, len1);
> + record__write(rec, data2, len2);
record__write goes quite deep down the stack before it realizes
there's nothing to write (len2 == 0) which I'm guessing is the
likely case for data2/len2 (buffer wrap around) ?
maybe you want to check on that before calling that
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/