public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Stephane Eranian <eranian@google.com>
Subject: [PATCH V2 07/22] perf tools: Add a user event for Instruction Tracing errors
Date: Thu, 20 Nov 2014 15:23:13 +0200	[thread overview]
Message-ID: <1416489808-4489-8-git-send-email-adrian.hunter@intel.com> (raw)
In-Reply-To: <1416489808-4489-1-git-send-email-adrian.hunter@intel.com>

Errors encountered when decoding an Instruction
Trace need to be reported to the user. However
the "user" might be a script or another tool,
so provide a new user event to capture those
errors.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/util/event.c   |  1 +
 tools/perf/util/event.h   | 16 ++++++++++++++++
 tools/perf/util/session.c | 25 +++++++++++++++++++++++++
 tools/perf/util/tool.h    |  3 ++-
 4 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index efe6475..573fed2 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -31,6 +31,7 @@ static const char *perf_event__names[] = {
 	[PERF_RECORD_ID_INDEX]			= "ID_INDEX",
 	[PERF_RECORD_ITRACE_INFO]		= "ITRACE_INFO",
 	[PERF_RECORD_ITRACE]			= "ITRACE",
+	[PERF_RECORD_ITRACE_ERROR]		= "ITRACE_ERROR",
 };
 
 const char *perf_event__name(unsigned int id)
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index a093d56..7c1daae 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -217,6 +217,7 @@ enum perf_user_event_type { /* above any possible kernel type */
 	PERF_RECORD_ID_INDEX			= 69,
 	PERF_RECORD_ITRACE_INFO			= 70,
 	PERF_RECORD_ITRACE			= 71,
+	PERF_RECORD_ITRACE_ERROR		= 72,
 	PERF_RECORD_HEADER_MAX
 };
 
@@ -300,6 +301,20 @@ struct itrace_event {
 	u32 reserved__; /* For alignment */
 };
 
+#define MAX_ITRACE_ERROR_MSG 64
+
+struct itrace_error_event {
+	struct perf_event_header header;
+	u32 type;
+	u32 code;
+	u32 cpu;
+	u32 pid;
+	u32 tid;
+	u32 reserved__; /* For alignment */
+	u64 ip;
+	char msg[MAX_ITRACE_ERROR_MSG];
+};
+
 union perf_event {
 	struct perf_event_header	header;
 	struct mmap_event		mmap;
@@ -317,6 +332,7 @@ union perf_event {
 	struct id_index_event		id_index;
 	struct itrace_info_event	itrace_info;
 	struct itrace_event		itrace;
+	struct itrace_error_event	itrace_error;
 };
 
 void perf_event__print_totals(void);
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 6f56afb..7fb5e90 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -271,6 +271,15 @@ static s64 process_event_itrace_stub(struct perf_tool *tool __maybe_unused,
 	return event->itrace.size;
 }
 
+static
+int process_event_itrace_error_stub(struct perf_tool *tool __maybe_unused,
+				    union perf_event *event __maybe_unused,
+				    struct perf_session *session __maybe_unused)
+{
+	dump_printf(": unhandled!\n");
+	return 0;
+}
+
 void perf_tool__fill_defaults(struct perf_tool *tool)
 {
 	if (tool->sample == NULL)
@@ -311,6 +320,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
 		tool->itrace_info = process_event_itrace_info_stub;
 	if (tool->itrace == NULL)
 		tool->itrace = process_event_itrace_stub;
+	if (tool->itrace_error == NULL)
+		tool->itrace_error = process_event_itrace_error_stub;
 }
  
 static void swap_sample_id_all(union perf_event *event, void *data)
@@ -514,6 +525,17 @@ static void perf_event__itrace_swap(union perf_event *event,
 	event->itrace.cpu       = bswap_32(event->itrace.cpu);
 }
 
+static void perf_event__itrace_error_swap(union perf_event *event,
+					  bool sample_id_all __maybe_unused)
+{
+	event->itrace_error.type = bswap_32(event->itrace_error.type);
+	event->itrace_error.code = bswap_32(event->itrace_error.code);
+	event->itrace_error.cpu  = bswap_32(event->itrace_error.cpu);
+	event->itrace_error.pid  = bswap_32(event->itrace_error.pid);
+	event->itrace_error.tid  = bswap_32(event->itrace_error.tid);
+	event->itrace_error.ip   = bswap_64(event->itrace_error.ip);
+}
+
 typedef void (*perf_event__swap_op)(union perf_event *event,
 				    bool sample_id_all);
 
@@ -535,6 +557,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
 	[PERF_RECORD_ID_INDEX]		  = perf_event__all64_swap,
 	[PERF_RECORD_ITRACE_INFO]	  = perf_event__itrace_info_swap,
 	[PERF_RECORD_ITRACE]		  = perf_event__itrace_swap,
+	[PERF_RECORD_ITRACE_ERROR]	  = perf_event__itrace_error_swap,
 	[PERF_RECORD_HEADER_MAX]	  = NULL,
 };
 
@@ -1005,6 +1028,8 @@ static s64 perf_session__process_user_event(struct perf_session *session,
 		/* setup for reading amidst mmap */
 		lseek(fd, file_offset + event->header.size, SEEK_SET);
 		return tool->itrace(tool, event, session);
+	case PERF_RECORD_ITRACE_ERROR:
+		return tool->itrace_error(tool, event, session);
 	default:
 		return -EINVAL;
 	}
diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h
index b734c1a..b5c55de 100644
--- a/tools/perf/util/tool.h
+++ b/tools/perf/util/tool.h
@@ -46,7 +46,8 @@ struct perf_tool {
 	event_op2	finished_round,
 			build_id,
 			id_index,
-			itrace_info;
+			itrace_info,
+			itrace_error;
 	event_op3	itrace;
 	bool		ordered_events;
 	bool		ordering_requires_timestamps;
-- 
1.9.1


  parent reply	other threads:[~2014-11-20 13:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20 13:23 [PATCH V2 00/22] perf tools: Introduce an abstraction for Instruction Tracing Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 01/22] perf header: Add Instruction Tracing feature Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 02/22] perf evlist: Add initial support for mmapping an Instruction Trace buffer Adrian Hunter
2014-11-25 16:57   ` Jiri Olsa
2014-11-26 13:11     ` Adrian Hunter
2014-12-09 13:24       ` Arnaldo Carvalho de Melo
2014-12-10 12:28         ` Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 03/22] perf tools: Add user events for Instruction Tracing Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 04/22] perf tools: Add support for Instruction Trace recording Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 05/22] perf record: Add basic Instruction Tracing support Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 06/22] perf record: Extend -m option for Instruction Tracing mmap pages Adrian Hunter
2014-11-20 13:23 ` Adrian Hunter [this message]
2014-11-20 13:23 ` [PATCH V2 08/22] perf session: Add hooks to allow transparent decoding of Instruction Tracing data Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 09/22] perf session: Add Instruction Tracing options Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 10/22] perf itrace: Add helpers for Instruction Tracing errors Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 11/22] perf itrace: Add helpers for queuing Instruction Tracing data Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 12/22] perf itrace: Add a heap for sorting Instruction Tracing queues Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 13/22] perf itrace: Add processing for Instruction Tracing events Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 14/22] perf itrace: Add a hashtable for caching decoded instructions Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 15/22] perf tools: Add member to struct dso for an instruction cache Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 16/22] perf script: Add Instruction Tracing support Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 17/22] perf script: Always allow fields 'addr' and 'cpu' for itrace Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 18/22] perf report: Add Instruction Tracing support Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 19/22] perf inject: Re-pipe Instruction Tracing events Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 20/22] perf inject: Add Instruction Tracing support Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 21/22] perf tools: Add Instruction Tracing index Adrian Hunter
2014-11-20 13:23 ` [PATCH V2 22/22] perf tools: Hit all build ids when Instruction Tracing 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=1416489808-4489-8-git-send-email-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.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