Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf intel-pt: Add a helper function for processing AUXTRACE_INFO

Add a helper function 'intel_pt_has()' to make it easier to determine
which members the AUXTRACE_INFO event contains.

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-13-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
40b746a0 4d34e10a

+8 -4
+8 -4
tools/perf/util/intel-pt.c
··· 2037 2037 fprintf(stdout, intel_pt_info_fmts[i], arr[i]); 2038 2038 } 2039 2039 2040 + static bool intel_pt_has(struct auxtrace_info_event *auxtrace_info, int pos) 2041 + { 2042 + return auxtrace_info->header.size >= 2043 + sizeof(struct auxtrace_info_event) + (sizeof(u64) * (pos + 1)); 2044 + } 2045 + 2040 2046 int intel_pt_process_auxtrace_info(union perf_event *event, 2041 2047 struct perf_session *session) 2042 2048 { ··· 2083 2077 intel_pt_print_info(&auxtrace_info->priv[0], INTEL_PT_PMU_TYPE, 2084 2078 INTEL_PT_PER_CPU_MMAPS); 2085 2079 2086 - if (auxtrace_info->header.size >= sizeof(struct auxtrace_info_event) + 2087 - (sizeof(u64) * INTEL_PT_CYC_BIT)) { 2080 + if (intel_pt_has(auxtrace_info, INTEL_PT_CYC_BIT)) { 2088 2081 pt->mtc_bit = auxtrace_info->priv[INTEL_PT_MTC_BIT]; 2089 2082 pt->mtc_freq_bits = auxtrace_info->priv[INTEL_PT_MTC_FREQ_BITS]; 2090 2083 pt->tsc_ctc_ratio_n = auxtrace_info->priv[INTEL_PT_TSC_CTC_N]; ··· 2093 2088 INTEL_PT_CYC_BIT); 2094 2089 } 2095 2090 2096 - if (auxtrace_info->header.size >= sizeof(struct auxtrace_info_event) + 2097 - (sizeof(u64) * INTEL_PT_MAX_NONTURBO_RATIO)) { 2091 + if (intel_pt_has(auxtrace_info, INTEL_PT_MAX_NONTURBO_RATIO)) { 2098 2092 pt->max_non_turbo_ratio = 2099 2093 auxtrace_info->priv[INTEL_PT_MAX_NONTURBO_RATIO]; 2100 2094 intel_pt_print_info(&auxtrace_info->priv[0],