linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 12/16] perf intel-pt: Add a helper function for processing AUXTRACE_INFO
Date: Fri, 23 Sep 2016 17:38:44 +0300	[thread overview]
Message-ID: <1474641528-18776-13-git-send-email-adrian.hunter@intel.com> (raw)
In-Reply-To: <1474641528-18776-1-git-send-email-adrian.hunter@intel.com>

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>
---
 tools/perf/util/intel-pt.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 96519e801e53..f16b00f55a19 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -2037,6 +2037,12 @@ static void intel_pt_print_info(u64 *arr, int start, int finish)
 		fprintf(stdout, intel_pt_info_fmts[i], arr[i]);
 }
 
+static bool intel_pt_has(struct auxtrace_info_event *auxtrace_info, int pos)
+{
+	return auxtrace_info->header.size >=
+		sizeof(struct auxtrace_info_event) + (sizeof(u64) * (pos + 1));
+}
+
 int intel_pt_process_auxtrace_info(union perf_event *event,
 				   struct perf_session *session)
 {
@@ -2077,8 +2083,7 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
 	intel_pt_print_info(&auxtrace_info->priv[0], INTEL_PT_PMU_TYPE,
 			    INTEL_PT_PER_CPU_MMAPS);
 
-	if (auxtrace_info->header.size >= sizeof(struct auxtrace_info_event) +
-					(sizeof(u64) * INTEL_PT_CYC_BIT)) {
+	if (intel_pt_has(auxtrace_info, INTEL_PT_CYC_BIT)) {
 		pt->mtc_bit = auxtrace_info->priv[INTEL_PT_MTC_BIT];
 		pt->mtc_freq_bits = auxtrace_info->priv[INTEL_PT_MTC_FREQ_BITS];
 		pt->tsc_ctc_ratio_n = auxtrace_info->priv[INTEL_PT_TSC_CTC_N];
@@ -2088,8 +2093,7 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
 				    INTEL_PT_CYC_BIT);
 	}
 
-	if (auxtrace_info->header.size >= sizeof(struct auxtrace_info_event) +
-				(sizeof(u64) * INTEL_PT_MAX_NONTURBO_RATIO)) {
+	if (intel_pt_has(auxtrace_info, INTEL_PT_MAX_NONTURBO_RATIO)) {
 		pt->max_non_turbo_ratio =
 			auxtrace_info->priv[INTEL_PT_MAX_NONTURBO_RATIO];
 		intel_pt_print_info(&auxtrace_info->priv[0],
-- 
1.9.1

  parent reply	other threads:[~2016-09-23 14:43 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-23 14:38 [PATCH 00/16] perf tools: Add support for using symbols in address filters Adrian Hunter
2016-09-23 14:38 ` [PATCH 01/16] perf record: Fix documentation 'event_sources' -> 'event_source' Adrian Hunter
2016-09-29 18:10   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 02/16] perf tools: Fix MMAP event synthesis broken by MAP_HUGETLB change Adrian Hunter
2016-09-29 18:10   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 03/16] perf script: Fix vanished idle symbols Adrian Hunter
2016-09-29 18:13   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 04/16] perf record: Rename label 'out_symbol_exit' Adrian Hunter
2016-09-29 18:14   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 05/16] perf record: Fix error paths Adrian Hunter
2016-09-29 18:14   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 06/16] perf symbols: Add dso__last_symbol() Adrian Hunter
2016-09-29 18:14   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 07/16] perf record: Add support for using symbols in address filters Adrian Hunter
2016-09-29 18:15   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 08/16] perf tools: Increase debug level of SDT debug messages Adrian Hunter
2016-09-24  0:15   ` Masami Hiramatsu
2016-09-26  7:27     ` Adrian Hunter
2016-09-27 17:42       ` Masami Hiramatsu
2016-09-29 18:15   ` [tip:perf/core] perf probe: " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 09/16] perf intel-pt: Fix snapshot overlap detection decoder errors Adrian Hunter
2016-09-29 18:16   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 10/16] perf intel-pt: Add support for recording the max non-turbo ratio Adrian Hunter
2016-09-29 18:16   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 11/16] perf intel-pt: Fix missing error codes processing auxtrace_info Adrian Hunter
2016-09-29 18:17   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` Adrian Hunter [this message]
2016-09-29 18:17   ` [tip:perf/core] perf intel-pt: Add a helper function for processing AUXTRACE_INFO tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 13/16] perf intel-pt: Record address filter in AUXTRACE_INFO event Adrian Hunter
2016-09-29 18:17   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 14/16] perf intel-pt: Read address filter from " Adrian Hunter
2016-09-29 18:18   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 15/16] perf intel-pt: Enable decoder to handle TIP.PGD with missing IP Adrian Hunter
2016-09-29 18:18   ` [tip:perf/core] " tip-bot for Adrian Hunter
2016-09-23 14:38 ` [PATCH 16/16] perf intel-pt: Fix decoding when there are address filters Adrian Hunter
2016-09-29 18:19   ` [tip:perf/core] " tip-bot for 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=1474641528-18776-13-git-send-email-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mhiramat@kernel.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;
as well as URLs for NNTP newsgroup(s).