All of lore.kernel.org
 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 14/16] perf intel-pt: Read address filter from AUXTRACE_INFO event
Date: Fri, 23 Sep 2016 17:38:46 +0300	[thread overview]
Message-ID: <1474641528-18776-15-git-send-email-adrian.hunter@intel.com> (raw)
In-Reply-To: <1474641528-18776-1-git-send-email-adrian.hunter@intel.com>

Read the address filter from the AUXTRACE_INFO event in preparation for
using it to assist in decoding.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/intel-pt.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index f16b00f55a19..c9fec19a7914 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -103,6 +103,8 @@ struct intel_pt {
 	unsigned max_non_turbo_ratio;
 
 	unsigned long num_events;
+
+	char *filter;
 };
 
 enum switch_state {
@@ -1774,6 +1776,7 @@ static void intel_pt_free(struct perf_session *session)
 	intel_pt_free_events(session);
 	session->auxtrace = NULL;
 	thread__put(pt->unknown_thread);
+	zfree(&pt->filter);
 	free(pt);
 }
 
@@ -2024,6 +2027,7 @@ static const char * const intel_pt_info_fmts[] = {
 	[INTEL_PT_TSC_CTC_D]		= "  TSC:CTC denominator %"PRIu64"\n",
 	[INTEL_PT_CYC_BIT]		= "  CYC bit             %#"PRIx64"\n",
 	[INTEL_PT_MAX_NONTURBO_RATIO]	= "  Max non-turbo ratio %"PRIu64"\n",
+	[INTEL_PT_FILTER_STR_LEN]	= "  Filter string len.  %"PRIu64"\n",
 };
 
 static void intel_pt_print_info(u64 *arr, int start, int finish)
@@ -2037,6 +2041,14 @@ static void intel_pt_print_info(u64 *arr, int start, int finish)
 		fprintf(stdout, intel_pt_info_fmts[i], arr[i]);
 }
 
+static void intel_pt_print_info_str(const char *name, const char *str)
+{
+	if (!dump_trace)
+		return;
+
+	fprintf(stdout, "  %-20s%s\n", name, str ? str : "");
+}
+
 static bool intel_pt_has(struct auxtrace_info_event *auxtrace_info, int pos)
 {
 	return auxtrace_info->header.size >=
@@ -2049,6 +2061,8 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
 	struct auxtrace_info_event *auxtrace_info = &event->auxtrace_info;
 	size_t min_sz = sizeof(u64) * INTEL_PT_PER_CPU_MMAPS;
 	struct intel_pt *pt;
+	void *info_end;
+	u64 *info;
 	int err;
 
 	if (auxtrace_info->header.size < sizeof(struct auxtrace_info_event) +
@@ -2101,6 +2115,42 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
 				    INTEL_PT_MAX_NONTURBO_RATIO);
 	}
 
+	info = &auxtrace_info->priv[INTEL_PT_FILTER_STR_LEN] + 1;
+	info_end = (void *)info + auxtrace_info->header.size;
+
+	if (intel_pt_has(auxtrace_info, INTEL_PT_FILTER_STR_LEN)) {
+		size_t len;
+
+		len = auxtrace_info->priv[INTEL_PT_FILTER_STR_LEN];
+		intel_pt_print_info(&auxtrace_info->priv[0],
+				    INTEL_PT_FILTER_STR_LEN,
+				    INTEL_PT_FILTER_STR_LEN);
+		if (len) {
+			const char *filter = (const char *)info;
+
+			len = roundup(len + 1, 8);
+			info += len >> 3;
+			if ((void *)info > info_end) {
+				pr_err("%s: bad filter string length\n", __func__);
+				err = -EINVAL;
+				goto err_free_queues;
+			}
+			pt->filter = memdup(filter, len);
+			if (!pt->filter) {
+				err = -ENOMEM;
+				goto err_free_queues;
+			}
+			if (session->header.needs_swap)
+				mem_bswap_64(pt->filter, len);
+			if (pt->filter[len - 1]) {
+				pr_err("%s: filter string not null terminated\n", __func__);
+				err = -EINVAL;
+				goto err_free_queues;
+			}
+		}
+		intel_pt_print_info_str("Filter string", pt->filter);
+	}
+
 	pt->timeless_decoding = intel_pt_timeless_decoding(pt);
 	pt->have_tsc = intel_pt_have_tsc(pt);
 	pt->sampling_mode = false;
@@ -2218,6 +2268,7 @@ err_free_queues:
 	auxtrace_queues__free(&pt->queues);
 	session->auxtrace = NULL;
 err_free:
+	zfree(&pt->filter);
 	free(pt);
 	return err;
 }
-- 
1.9.1

  parent reply	other threads:[~2016-09-23 14:44 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 ` [PATCH 12/16] perf intel-pt: Add a helper function for processing AUXTRACE_INFO Adrian Hunter
2016-09-29 18:17   ` [tip:perf/core] " 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 ` Adrian Hunter [this message]
2016-09-29 18:18   ` [tip:perf/core] perf intel-pt: Read address filter from " 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-15-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.