lkml.org 
[lkml]   [2013]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v0 49/71] perf itrace: Add helpers for Instruction Tracing errors
    Date
    From: Adrian Hunter <adrian.hunter@intel.com>

    Add functions to synthesize, count and print
    Instruction Tracing error events.

    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    ---
    tools/perf/util/itrace.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
    tools/perf/util/itrace.h | 16 ++++++++++++++
    2 files changed, 71 insertions(+)

    diff --git a/tools/perf/util/itrace.c b/tools/perf/util/itrace.c
    index b80411d..865b584 100644
    --- a/tools/perf/util/itrace.c
    +++ b/tools/perf/util/itrace.c
    @@ -25,6 +25,7 @@
    #include <linux/perf_event.h>

    #include <stdlib.h>
    +#include <stdio.h>
    #include <string.h>
    #include <errno.h>

    @@ -37,6 +38,7 @@
    #include "itrace.h"

    #include "event.h"
    +#include "session.h"
    #include "debug.h"
    #include "parse-options.h"

    @@ -162,6 +164,28 @@ struct itrace_record *__attribute__ ((weak)) itrace_record__init(int *err)
    return NULL;
    }

    +void itrace_synth_error(struct itrace_error_event *itrace_error, int type,
    + int code, int cpu, pid_t pid, pid_t tid, u64 ip,
    + const char *msg)
    +{
    + size_t size;
    +
    + memset(itrace_error, 0, sizeof(struct itrace_error_event));
    +
    + itrace_error->header.type = PERF_RECORD_ITRACE_ERROR;
    + itrace_error->type = type;
    + itrace_error->code = code;
    + itrace_error->cpu = cpu;
    + itrace_error->pid = pid;
    + itrace_error->tid = tid;
    + itrace_error->ip = ip;
    + strncpy(itrace_error->msg, msg, MAX_ITRACE_ERROR_MSG - 1);
    +
    + size = (void *)itrace_error->msg - (void *)itrace_error +
    + strlen(itrace_error->msg);
    + itrace_error->header.size = PERF_ALIGN(size, sizeof(u64));
    +}
    +
    int perf_event__synthesize_itrace_info(struct itrace_record *itr,
    struct perf_tool *tool,
    struct perf_session *session,
    @@ -310,6 +334,37 @@ out_err:
    return -EINVAL;
    }

    +size_t perf_event__fprintf_itrace_error(union perf_event *event, FILE *fp)
    +{
    + struct itrace_error_event *e = &event->itrace_error;
    + int ret;
    +
    + ret = fprintf(fp, " Instruction trace error type %u", e->type);
    + ret += fprintf(fp, " cpu %d pid %d tid %d ip %#"PRIx64" code %u: %s\n",
    + e->cpu, e->pid, e->tid, e->ip, e->code, e->msg);
    + return ret;
    +}
    +
    +int perf_event__process_itrace_error(struct perf_tool *tool __maybe_unused,
    + union perf_event *event,
    + struct perf_session *session)
    +{
    + if (session->itrace)
    + session->itrace->error_count += 1;
    +
    + perf_event__fprintf_itrace_error(event, stdout);
    + return 0;
    +}
    +
    +int perf_event__count_itrace_error(struct perf_tool *tool __maybe_unused,
    + union perf_event *event __maybe_unused,
    + struct perf_session *session)
    +{
    + if (session->itrace)
    + session->itrace->error_count += 1;
    + return 0;
    +}
    +
    int itrace_mmap__read(struct itrace_mmap *mm, struct itrace_record *itr,
    struct perf_tool *tool, process_itrace_t fn)
    {
    diff --git a/tools/perf/util/itrace.h b/tools/perf/util/itrace.h
    index 8453351..08877d2 100644
    --- a/tools/perf/util/itrace.h
    +++ b/tools/perf/util/itrace.h
    @@ -37,6 +37,10 @@ struct option;
    struct perf_record_opts;
    struct itrace_info_event;

    +enum itrace_error_type {
    + PERF_ITRACE_DECODER_ERROR = 1,
    +};
    +
    enum itrace_period_type {
    PERF_ITRACE_PERIOD_INSTRUCTIONS,
    PERF_ITRACE_PERIOD_TICKS,
    @@ -198,6 +202,10 @@ int itrace_record__info_fill(struct itrace_record *itr,
    void itrace_record__free(struct itrace_record *itr);
    u64 itrace_record__reference(struct itrace_record *itr);

    +void itrace_synth_error(struct itrace_error_event *itrace_error, int type,
    + int code, int cpu, pid_t pid, pid_t tid, u64 ip,
    + const char *msg);
    +
    int perf_event__synthesize_itrace_info(struct itrace_record *itr,
    struct perf_tool *tool,
    struct perf_session *session,
    @@ -206,10 +214,18 @@ int perf_event__synthesize_itrace(struct perf_tool *tool,
    perf_event__handler_t process,
    size_t size, u64 offset, u64 ref, int idx,
    u32 tid, u32 cpu);
    +int perf_event__process_itrace_error(struct perf_tool *tool,
    + union perf_event *event,
    + struct perf_session *session);
    +int perf_event__count_itrace_error(struct perf_tool *tool __maybe_unused,
    + union perf_event *event __maybe_unused,
    + struct perf_session *session);
    int itrace_parse_synth_opts(const struct option *opt, const char *str,
    int unset);
    void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts);

    +size_t perf_event__fprintf_itrace_error(union perf_event *event, FILE *fp);
    +
    static inline int itrace__process_event(struct perf_session *session,
    union perf_event *event,
    struct perf_sample *sample,
    --
    1.8.5.1


    \
     
     \ /
      Last update: 2013-12-11 14:01    [W:4.028 / U:0.092 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site