lkml.org 
[lkml]   [2016]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 19/27] perf intel-pt: Record address filter in AUXTRACE_INFO event
    Date
    From: Adrian Hunter <adrian.hunter@intel.com>

    The address filter is needed to help decode the trace, so store it in
    the AUXTRACE_INFO event.

    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
    Link: http://lkml.kernel.org/r/1474641528-18776-14-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    ---
    tools/perf/arch/x86/util/intel-pt.c | 51 ++++++++++++++++++++++++++++++++++---
    tools/perf/util/intel-pt.h | 3 +--
    2 files changed, 48 insertions(+), 6 deletions(-)

    diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
    index 18b21514c153..90fa2286edcf 100644
    --- a/tools/perf/arch/x86/util/intel-pt.c
    +++ b/tools/perf/arch/x86/util/intel-pt.c
    @@ -62,6 +62,7 @@ struct intel_pt_recording {
    size_t snapshot_ref_buf_size;
    int snapshot_ref_cnt;
    struct intel_pt_snapshot_ref *snapshot_refs;
    + size_t priv_size;
    };

    static int intel_pt_parse_terms_with_default(struct list_head *formats,
    @@ -273,11 +274,37 @@ intel_pt_pmu_default_config(struct perf_pmu *intel_pt_pmu)
    return attr;
    }

    +static const char *intel_pt_find_filter(struct perf_evlist *evlist,
    + struct perf_pmu *intel_pt_pmu)
    +{
    + struct perf_evsel *evsel;
    +
    + evlist__for_each_entry(evlist, evsel) {
    + if (evsel->attr.type == intel_pt_pmu->type)
    + return evsel->filter;
    + }
    +
    + return NULL;
    +}
    +
    +static size_t intel_pt_filter_bytes(const char *filter)
    +{
    + size_t len = filter ? strlen(filter) : 0;
    +
    + return len ? roundup(len + 1, 8) : 0;
    +}
    +
    static size_t
    -intel_pt_info_priv_size(struct auxtrace_record *itr __maybe_unused,
    - struct perf_evlist *evlist __maybe_unused)
    +intel_pt_info_priv_size(struct auxtrace_record *itr, struct perf_evlist *evlist)
    {
    - return INTEL_PT_AUXTRACE_PRIV_SIZE;
    + struct intel_pt_recording *ptr =
    + container_of(itr, struct intel_pt_recording, itr);
    + const char *filter = intel_pt_find_filter(evlist, ptr->intel_pt_pmu);
    +
    + ptr->priv_size = (INTEL_PT_AUXTRACE_PRIV_MAX * sizeof(u64)) +
    + intel_pt_filter_bytes(filter);
    +
    + return ptr->priv_size;
    }

    static void intel_pt_tsc_ctc_ratio(u32 *n, u32 *d)
    @@ -303,9 +330,12 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
    u64 tsc_bit, mtc_bit, mtc_freq_bits, cyc_bit, noretcomp_bit;
    u32 tsc_ctc_ratio_n, tsc_ctc_ratio_d;
    unsigned long max_non_turbo_ratio;
    + size_t filter_str_len;
    + const char *filter;
    + u64 *info;
    int err;

    - if (priv_size != INTEL_PT_AUXTRACE_PRIV_SIZE)
    + if (priv_size != ptr->priv_size)
    return -EINVAL;

    intel_pt_parse_terms(&intel_pt_pmu->format, "tsc", &tsc_bit);
    @@ -322,6 +352,9 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
    "%lu", &max_non_turbo_ratio) != 1)
    max_non_turbo_ratio = 0;

    + filter = intel_pt_find_filter(session->evlist, ptr->intel_pt_pmu);
    + filter_str_len = filter ? strlen(filter) : 0;
    +
    if (!session->evlist->nr_mmaps)
    return -EINVAL;

    @@ -357,6 +390,16 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
    auxtrace_info->priv[INTEL_PT_TSC_CTC_D] = tsc_ctc_ratio_d;
    auxtrace_info->priv[INTEL_PT_CYC_BIT] = cyc_bit;
    auxtrace_info->priv[INTEL_PT_MAX_NONTURBO_RATIO] = max_non_turbo_ratio;
    + auxtrace_info->priv[INTEL_PT_FILTER_STR_LEN] = filter_str_len;
    +
    + info = &auxtrace_info->priv[INTEL_PT_FILTER_STR_LEN] + 1;
    +
    + if (filter_str_len) {
    + size_t len = intel_pt_filter_bytes(filter);
    +
    + strncpy((char *)info, filter, len);
    + info += len >> 3;
    + }

    return 0;
    }
    diff --git a/tools/perf/util/intel-pt.h b/tools/perf/util/intel-pt.h
    index 8b8356233e6a..e13b14e5a37b 100644
    --- a/tools/perf/util/intel-pt.h
    +++ b/tools/perf/util/intel-pt.h
    @@ -35,11 +35,10 @@ enum {
    INTEL_PT_TSC_CTC_D,
    INTEL_PT_CYC_BIT,
    INTEL_PT_MAX_NONTURBO_RATIO,
    + INTEL_PT_FILTER_STR_LEN,
    INTEL_PT_AUXTRACE_PRIV_MAX,
    };

    -#define INTEL_PT_AUXTRACE_PRIV_SIZE (INTEL_PT_AUXTRACE_PRIV_MAX * sizeof(u64))
    -
    struct auxtrace_record;
    struct perf_tool;
    union perf_event;
    --
    2.7.4
    \
     
     \ /
      Last update: 2016-09-29 16:39    [W:5.532 / U:0.164 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site